Skip to content

Instantly share code, notes, and snippets.

@sciguyryan
Last active June 3, 2020 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sciguyryan/258be7cb9f46c4a9554f3172b8806ce2 to your computer and use it in GitHub Desktop.
Save sciguyryan/258be7cb9f46c4a9554f3172b8806ce2 to your computer and use it in GitHub Desktop.
Nested Subroutines
push $0xAAA ; Should remain in place once the stack is restored
push $0xC ; TESTER Argument 3
push $0xB ; TESTER Argument 2
push $0xA ; TESTER Argument 1
push $3 ; The number of arguments for the subroutine
call !TESTER
mov $0x123, R1
hlt
TESTER:
mov $0x34, &FP, R3
mov $0x30, &FP, R2
mov $0x2C, &FP, R1
add R1, R2
add R3, AC
push $0xCC ; TESTER2 Argument 3
push $0xBB ; TESTER2 Argument 2
push $0xAA ; TESTER2 Argument 1
push $3 ; The number of arguments for the subroutine
call !TESTER2
ret ; return to main
TESTER2:
mov $0x34, &FP, R3
mov $0x30, &FP, R2
mov $0x2C, &FP, R1
add R1, R2
add R3, AC
ret ; return to TESTER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment