Skip to content

Instantly share code, notes, and snippets.

@pcyu16
Created July 3, 2010 07:08
Show Gist options
  • Select an option

  • Save pcyu16/462380 to your computer and use it in GitHub Desktop.

Select an option

Save pcyu16/462380 to your computer and use it in GitHub Desktop.
* Standard prelude:
0: LD 5,0(0) load maxaddress form dmem[0]
1: ST 0,0(0) clear dmem[0]
* End of standard prelude
2: LDA 3,0,5 reserved places for global variables
3: LDA 0,4(7) eax = return addr of main
4: LDC 2,1(2) pushl: push return addr of main
5: SUB 3,3,2 pushl
6: ST 0,0(3) pushl
7: LDA 7,1(7) jump to main
8: HALT 0,0,0
* function start
9: LDC 2,1(2) backup ebp: push ebp
10: SUB 3,3,2 backup ebp
11: ST 4,0(3) backup ebp
12: LDC 2,0(2) new base: set new ebp
13: ADD 4,3,2 new base
14: LDA 3,0,3 reserved places for local variables
15: LDA 3,0,3 release places for local variables
16: LDC 2,0(2) erase local: restore esp
17: ADD 3,4,2 erase local
18: LD 4,0(3) restore ebp: pop ebp
19: LDC 2,1(2) restore ebp
20: ADD 3,3,2 restore ebp
21: LDC 2,1(2) ret: backup esp and load return address
22: ADD 3,3,2 ret
23: LD 7,-1(3) ret
* function end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment