Skip to content

Instantly share code, notes, and snippets.

@yunchih
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save yunchih/10baedb980d8270fe5c4 to your computer and use it in GitHub Desktop.

Select an option

Save yunchih/10baedb980d8270fe5c4 to your computer and use it in GitHub Desktop.
; This is a sample TOY assembly language program
.DATA
foo 100
bar 200
.CODE
mov R1, 1 ; Initialize
mov R2, 1 ; Initialize
read R5 ; How many fibonacci number do you want?
loop:
print R1 ; Print to standard output
mov R3, R1 ; Move R1 into a temporary register R3
add R1, R2 ; add R2 to R1
mov R2, R3 ; Put R1 into R2
dec R5 ; Decrease index
jz done ; If the last operation dec yield zero, the program is done.
jmp loop ; Continue the loop
done:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment