// Basic: a.sam // // int main() { // return 100; // } PUSHIMM 0 // space for return value of program (result of main()) PUSHFBR // save current FBR (starts at 0) PUSHIMM 1 // need to push 1 for FBR POPFBR // set FBR to 1 JSR main // invoke main and push next address on the stack POPFBR // reinstall old FBR STOP // end program main: // label of first command is function name ADDSP 0 // allocate local variables (params already taken care of!) PUSHIMM 100 // push value 100 to return STOREOFF -1 // store return value in return variable ADDSP 0 // pop off local variables JUMPIND // return to caller // Program area: // 0: PUSHIMM 0 // 1: PUSHFBR // 2: PUSHIMM 1 // 3: POPFBR // 4: JSR main //address:7 // 5: POPFBR // 6: STOP // 7: ADDSP 0 // 8: PUSHIMM 100 // 9: STOREOFF -1 // 10: ADDSP 0 // 11: JUMPIND