Skip to content

Instantly share code, notes, and snippets.

@nathanpc
nathanpc / os.asm
Created June 18, 2011 15:50
OS Hello World Example
[BITS 16] ; 16 bit code generation
[ORG 0x7C00] ; ORGin location is 7C00
JMP short main ; Jump past disk description section
NOP ; Pad out before disk description
; ------------------------------------------------------------------
; Disk description table, to make it a valid floppy
; Note: some of these values are hard-coded in the source!
; Values are those used by IBM for 1.44 MB, 3.5" diskette
@nathanpc
nathanpc / vbe_mouse.asm
Created June 18, 2011 15:51
VBE And Mouse Use
org 100h
main:
call set_video_mode
.main_loop:
call get_mouse_input
call draw_top_bar
call get_keyboard_input
@nathanpc
nathanpc / VBlank.S
Created June 18, 2011 15:52
Waiting For The VBlank Refresh At GameBoy Advance
ldr r0,=#0x4000006 @ VBlank memory address
waitVBlank:
ldrh r1, [r0] @ Loads the memory address to the r1 register
cmp r1, #161 @ Compare if the memory address have completed the VBlank
bne waitVBlank @ Loopback until r1 != 161
@nathanpc
nathanpc / addb.sh
Created June 18, 2011 15:53
Using Files As Databases
#!/bin/sh
# Access AddressBook file and use it as a database
# Variables
name=$1
number=$2
db=AddressBook
### AddressBook File Example ###
# Maria Daher (27)5564-4392 #
@nathanpc
nathanpc / tic-tac-toe.sh
Created June 18, 2011 15:54
Tic-Tac-Toe Game
#!/bin/bash
#
#######################################################
# TIC TAC TOE #
# I WON'T GIVE YOU A CHANCE. YOU'LL NEVER WIN! #
#######################################################
# This program was developed as a funny way to test #
# the compatibility between arrays in ksh and bash. #
# Feel free for develop the module that the opponent #
# start playing, but don't forget to send me the new #
@nathanpc
nathanpc / hello_dlg.asm
Created June 18, 2011 15:55
HelloWorld Dialog For Win32
; Hello world in Assembler for the Win32 architecture
TITLE Hello world in win32. Tasm
VERSION T310
Model use32 Flat,StdCall
start_code segment byte public 'code' use32
begin:
Call MessageBox, 0, offset sHallo, offset caption, 0
@nathanpc
nathanpc / get_comp.asm
Created June 18, 2011 15:55
Getting And Comparing Input
; How to call it from the program
main:
call getinput
mov si, buffer
cmp byte[si], 0 ; Blank line
je main ; Ignore it
mov si, buffer
@nathanpc
nathanpc / midp.java
Created June 18, 2011 15:56
Fully Featured RecordStore Example(Java ME)
package contacts;
import java.io.*;
import java.util.Vector;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.rms.*;
import javax.microedition.lcdui.*;
public class simplecontacts extends MIDlet implements CommandListener {
private Display display;
@nathanpc
nathanpc / div_neg.asm
Created June 18, 2011 15:57
Dividing By Negative Numbers
; ********************
; * DIVIDE.ASM *
; ********************
.model small
.stack 512d
.data
a dw -9d
b db 2d
@nathanpc
nathanpc / ascii_bin.asm
Created June 18, 2011 15:57
Convert ASCII To Binary
#make_COM#
; COM file is loaded at CS:0100h
org 10h
; ********************************
; * Program: ASCIICONV.ASM *
; ********************************
include 'emu8086.inc'