==============================+============================== func.c- int dog(int x) { int y; y = 666; return y; } void main() { int a, b; b = 777; a = b; a = dog(b); } ==============================+============================== func.tm * C- compiler version C-F07 * Author: Robert B. Heckendorn * Adapted from backend built in 2001: Jorge Williams * Aug 19, 2007 * BEGIN function input 1: ST 3,-1(1) Store return address 2: IN 2,2,2 Grab int input 3: LD 3,-1(1) Load return address 4: LD 1,0(1) Adjust fp 5: LDA 7,0(3) Return * END of function input * BEGIN function output 6: ST 3,-1(1) Store return address 7: LD 3,-2(1) Load parameter 8: OUT 3,3,3 Output integer 9: LDC 2,0(6) Set return to 0 10: LD 3,-1(1) Load return address 11: LD 1,0(1) Adjust fp 12: LDA 7,0(3) Return * END of function output * BEGIN function inputb 13: ST 3,-1(1) Store return address 14: INB 2,2,2 Grab bool input 15: LD 3,-1(1) Load return address 16: LD 1,0(1) Adjust fp 17: LDA 7,0(3) Return * END of function inputb * BEGIN function outputb 18: ST 3,-1(1) Store return address 19: LD 3,-2(1) Load parameter 20: OUTB 3,3,3 Output bool 21: LDC 2,0(6) Set return to 0 22: LD 3,-1(1) Load return address 23: LD 1,0(1) Adjust fp 24: LDA 7,0(3) Return * END of function outputb * BEGIN function outnl 25: ST 3,-1(1) Store return address 26: OUTNL 3,3,3 Output a newline 27: LD 3,-1(1) Load return address 28: LD 1,0(1) Adjust fp 29: LDA 7,0(3) Return * END of function outnl * BEGIN function dog 30: ST 3,-1(1) Store return address. * BEGIN compound statement 31: LDC 3,666(6) Load constant 32: ST 3,-3(1) Store variable y * RETURN 33: LD 3,-3(1) Load variable y 34: LDA 2,0(3) Copy result to rt register 35: LD 3,-1(1) Load return address 36: LD 1,0(1) Adjust fp 37: LDA 7,0(3) Return * END compound statement * Add standard closing in case there is no return statement 38: LDC 2,0(6) Set return value to 0 39: LD 3,-1(1) Load return address 40: LD 1,0(1) Adjust fp 41: LDA 7,0(3) Return * END of function dog * BEGIN function main 42: ST 3,-1(1) Store return address. * BEGIN compound statement 43: LDC 3,777(6) Load constant 44: ST 3,-3(1) Store variable b 45: LD 3,-3(1) Load variable b 46: ST 3,-2(1) Store variable a 47: ST 1,-4(1) Store old fp in ghost frame 48: LD 3,-3(1) Load variable b 49: ST 3,-6(1) Store parameter 50: LDA 1,-4(1) Load address of new frame 51: LDA 3,1(7) Return address in ac 52: LDA 7,-23(7) call dog 53: LDA 3,0(2) Save the result in ac 54: ST 3,-2(1) Store variable a * END compound statement * Add standard closing in case there is no return statement 55: LDC 2,0(6) Set return value to 0 56: LD 3,-1(1) Load return address 57: LD 1,0(1) Adjust fp 58: LDA 7,0(3) Return * END of function main 0: LDA 7,58(7) Jump to init * BEGIN Init 59: LD 0,0(0) Set the global pointer * BEGIN init of global array sizes * END init of global array sizes 60: LDA 1,0(0) set first frame at end of globals 61: ST 1,0(1) store old fp (point to self) 62: LDA 3,1(7) Return address in ac 63: LDA 7,-22(7) Jump to main 64: HALT 0,0,0 DONE! * END Init ==============================+============================== funca.c- int goat[16]; int dog(int x[]) { int a, b; int y[11]; y[3] = 666; x[3] = 666; *y; *x; return y[3]; } void main() { int a[22]; b[8] = 777; goat[8] = 777; *b; a[7] = b[7]; a[19] = dog(b); } ==============================+============================== funca.tm * C- compiler version C-F07 * Author: Robert B. Heckendorn * Adapted from backend built in 2001: Jorge Williams * Aug 19, 2007 * BEGIN function input 1: ST 3,-1(1) Store return address 2: IN 2,2,2 Grab int input 3: LD 3,-1(1) Load return address 4: LD 1,0(1) Adjust fp 5: LDA 7,0(3) Return * END of function input * BEGIN function output 6: ST 3,-1(1) Store return address 7: LD 3,-2(1) Load parameter 8: OUT 3,3,3 Output integer 9: LDC 2,0(6) Set return to 0 10: LD 3,-1(1) Load return address 11: LD 1,0(1) Adjust fp 12: LDA 7,0(3) Return * END of function output * BEGIN function inputb 13: ST 3,-1(1) Store return address 14: INB 2,2,2 Grab bool input 15: LD 3,-1(1) Load return address 16: LD 1,0(1) Adjust fp 17: LDA 7,0(3) Return * END of function inputb * BEGIN function outputb 18: ST 3,-1(1) Store return address 19: LD 3,-2(1) Load parameter 20: OUTB 3,3,3 Output bool 21: LDC 2,0(6) Set return to 0 22: LD 3,-1(1) Load return address 23: LD 1,0(1) Adjust fp 24: LDA 7,0(3) Return * END of function outputb * BEGIN function outnl 25: ST 3,-1(1) Store return address 26: OUTNL 3,3,3 Output a newline 27: LD 3,-1(1) Load return address 28: LD 1,0(1) Adjust fp 29: LDA 7,0(3) Return * END of function outnl * BEGIN function dog 30: ST 3,-1(1) Store return address. * BEGIN compound statement 31: LDC 3,11(6) load size of array y 32: ST 3,-3(1) save size of array y 33: LDC 3,3(6) Load constant 34: ST 3,-15(1) Save index 35: LDC 3,666(6) Load constant 36: LD 4,-15(1) Restore index 37: LDA 5,-4(1) Load address of base of array y 38: SUB 5,5,4 Compute offset of value 39: ST 3,0(5) Store variable y 40: LDC 3,3(6) Load constant 41: ST 3,-15(1) Save index 42: LDC 3,666(6) Load constant 43: LD 4,-15(1) Restore index 44: LD 5,-2(1) Load address of base of array x 45: SUB 5,5,4 Compute offset of value 46: ST 3,0(5) Store variable x 47: LDA 3,-4(1) Load address of base of array y 48: LD 3,1(3) Load size 49: LD 3,-2(1) Load address of base of array x 50: LD 3,1(3) Load size * RETURN 51: LDC 3,3(6) Load constant 52: LDA 4,-4(1) Load address of base of array y 53: SUB 3,4,3 Compute offset of value 54: LD 3,0(3) Load the value 55: LDA 2,0(3) Copy result to rt register 56: LD 3,-1(1) Load return address 57: LD 1,0(1) Adjust fp 58: LDA 7,0(3) Return * END compound statement * Add standard closing in case there is no return statement 59: LDC 2,0(6) Set return value to 0 60: LD 3,-1(1) Load return address 61: LD 1,0(1) Adjust fp 62: LDA 7,0(3) Return * END of function dog * BEGIN function main 63: ST 3,-1(1) Store return address. * BEGIN compound statement 64: LDC 3,22(6) load size of array a 65: ST 3,-2(1) save size of array a 66: LDC 3,33(6) load size of array b 67: ST 3,-25(1) save size of array b 68: LDC 3,8(6) Load constant 69: ST 3,-59(1) Save index 70: LDC 3,777(6) Load constant 71: LD 4,-59(1) Restore index 72: LDA 5,-26(1) Load address of base of array b 73: SUB 5,5,4 Compute offset of value 74: ST 3,0(5) Store variable b 75: LDC 3,8(6) Load constant 76: ST 3,-59(1) Save index 77: LDC 3,777(6) Load constant 78: LD 4,-59(1) Restore index 79: LDA 5,-1(0) Load address of base of array goat 80: SUB 5,5,4 Compute offset of value 81: ST 3,0(5) Store variable goat 82: LDA 3,-26(1) Load address of base of array b 83: LD 3,1(3) Load size 84: LDC 3,7(6) Load constant 85: ST 3,-59(1) Save index 86: LDC 3,7(6) Load constant 87: LDA 4,-26(1) Load address of base of array b 88: SUB 3,4,3 Compute offset of value 89: LD 3,0(3) Load the value 90: LD 4,-59(1) Restore index 91: LDA 5,-3(1) Load address of base of array a 92: SUB 5,5,4 Compute offset of value 93: ST 3,0(5) Store variable a 94: LDC 3,19(6) Load constant 95: ST 3,-59(1) Save index 96: ST 1,-60(1) Store old fp in ghost frame 97: LDA 3,-26(1) Load address of base of array b 98: ST 3,-62(1) Store parameter 99: LDA 1,-60(1) Load address of new frame 100: LDA 3,1(7) Return address in ac 101: LDA 7,-72(7) call dog 102: LDA 3,0(2) Save the result in ac 103: LD 4,-59(1) Restore index 104: LDA 5,-3(1) Load address of base of array a 105: SUB 5,5,4 Compute offset of value 106: ST 3,0(5) Store variable a * END compound statement * Add standard closing in case there is no return statement 107: LDC 2,0(6) Set return value to 0 108: LD 3,-1(1) Load return address 109: LD 1,0(1) Adjust fp 110: LDA 7,0(3) Return * END of function main 0: LDA 7,110(7) Jump to init * BEGIN Init 111: LD 0,0(0) Set the global pointer * BEGIN init of global array sizes 112: LDC 3,16(6) load size of array goat 113: ST 3,0(0) save size of array goat * END init of global array sizes 114: LDA 1,-17(0) set first frame at end of globals 115: ST 1,0(1) store old fp (point to self) 116: LDA 3,1(7) Return address in ac 117: LDA 7,-55(7) Jump to main 118: HALT 0,0,0 DONE! * END Init ==============================+============================== funcaa.c- void cat(int z[]) { *z; z[7]; } void dog(int x[]) { int y[23]; *x; *y; y[7] = 666; cat(x); cat(y); } void main() { int a[17]; a[7] = 444; dog(a); } ==============================+============================== funcaa.tm * C- compiler version C-F07 * Author: Robert B. Heckendorn * Adapted from backend built in 2001: Jorge Williams * Aug 19, 2007 * BEGIN function input 1: ST 3,-1(1) Store return address 2: IN 2,2,2 Grab int input 3: LD 3,-1(1) Load return address 4: LD 1,0(1) Adjust fp 5: LDA 7,0(3) Return * END of function input * BEGIN function output 6: ST 3,-1(1) Store return address 7: LD 3,-2(1) Load parameter 8: OUT 3,3,3 Output integer 9: LDC 2,0(6) Set return to 0 10: LD 3,-1(1) Load return address 11: LD 1,0(1) Adjust fp 12: LDA 7,0(3) Return * END of function output * BEGIN function inputb 13: ST 3,-1(1) Store return address 14: INB 2,2,2 Grab bool input 15: LD 3,-1(1) Load return address 16: LD 1,0(1) Adjust fp 17: LDA 7,0(3) Return * END of function inputb * BEGIN function outputb 18: ST 3,-1(1) Store return address 19: LD 3,-2(1) Load parameter 20: OUTB 3,3,3 Output bool 21: LDC 2,0(6) Set return to 0 22: LD 3,-1(1) Load return address 23: LD 1,0(1) Adjust fp 24: LDA 7,0(3) Return * END of function outputb * BEGIN function outnl 25: ST 3,-1(1) Store return address 26: OUTNL 3,3,3 Output a newline 27: LD 3,-1(1) Load return address 28: LD 1,0(1) Adjust fp 29: LDA 7,0(3) Return * END of function outnl * BEGIN function cat 30: ST 3,-1(1) Store return address. * BEGIN compound statement 31: LD 3,-2(1) Load address of base of array z 32: LD 3,1(3) Load size 33: LDC 3,7(6) Load constant 34: LD 4,-2(1) Load address of base of array z 35: SUB 3,4,3 Compute offset of value 36: LD 3,0(3) Load the value * END compound statement * Add standard closing in case there is no return statement 37: LDC 2,0(6) Set return value to 0 38: LD 3,-1(1) Load return address 39: LD 1,0(1) Adjust fp 40: LDA 7,0(3) Return * END of function cat * BEGIN function dog 41: ST 3,-1(1) Store return address. * BEGIN compound statement 42: LDC 3,23(6) load size of array y 43: ST 3,-3(1) save size of array y 44: LD 3,-2(1) Load address of base of array x 45: LD 3,1(3) Load size 46: LDA 3,-4(1) Load address of base of array y 47: LD 3,1(3) Load size 48: LDC 3,7(6) Load constant 49: ST 3,-27(1) Save index 50: LDC 3,666(6) Load constant 51: LD 4,-27(1) Restore index 52: LDA 5,-4(1) Load address of base of array y 53: SUB 5,5,4 Compute offset of value 54: ST 3,0(5) Store variable y 55: ST 1,-27(1) Store old fp in ghost frame 56: LD 3,-2(1) Load address of base of array x 57: ST 3,-29(1) Store parameter 58: LDA 1,-27(1) Load address of new frame 59: LDA 3,1(7) Return address in ac 60: LDA 7,-31(7) call cat 61: LDA 3,0(2) Save the result in ac 62: ST 1,-27(1) Store old fp in ghost frame 63: LDA 3,-4(1) Load address of base of array y 64: ST 3,-29(1) Store parameter 65: LDA 1,-27(1) Load address of new frame 66: LDA 3,1(7) Return address in ac 67: LDA 7,-38(7) call cat 68: LDA 3,0(2) Save the result in ac * END compound statement * Add standard closing in case there is no return statement 69: LDC 2,0(6) Set return value to 0 70: LD 3,-1(1) Load return address 71: LD 1,0(1) Adjust fp 72: LDA 7,0(3) Return * END of function dog * BEGIN function main 73: ST 3,-1(1) Store return address. * BEGIN compound statement 74: LDC 3,17(6) load size of array a 75: ST 3,-2(1) save size of array a 76: LDC 3,7(6) Load constant 77: ST 3,-20(1) Save index 78: LDC 3,444(6) Load constant 79: LD 4,-20(1) Restore index 80: LDA 5,-3(1) Load address of base of array a 81: SUB 5,5,4 Compute offset of value 82: ST 3,0(5) Store variable a 83: ST 1,-20(1) Store old fp in ghost frame 84: LDA 3,-3(1) Load address of base of array a 85: ST 3,-22(1) Store parameter 86: LDA 1,-20(1) Load address of new frame 87: LDA 3,1(7) Return address in ac 88: LDA 7,-48(7) call dog 89: LDA 3,0(2) Save the result in ac * END compound statement * Add standard closing in case there is no return statement 90: LDC 2,0(6) Set return value to 0 91: LD 3,-1(1) Load return address 92: LD 1,0(1) Adjust fp 93: LDA 7,0(3) Return * END of function main 0: LDA 7,93(7) Jump to init * BEGIN Init 94: LD 0,0(0) Set the global pointer * BEGIN init of global array sizes * END init of global array sizes 95: LDA 1,0(0) set first frame at end of globals 96: ST 1,0(1) store old fp (point to self) 97: LDA 3,1(7) Return address in ac 98: LDA 7,-26(7) Jump to main 99: HALT 0,0,0 DONE! * END Init