msach@5: msach@5: //Assembly code takes the return addr off the stack and saves msach@5: // into the singleton. The first field in the singleton is the msach@5: // "endInstrAddr" field, and the return addr is at 0x4(%ebp) msach@5: .globl asm_save_ret_to_singleton msach@5: asm_save_ret_to_singleton: msach@5: movl 0x4(%ebp), %eax #get ret address, ebp is the same as in the calling function msach@5: movl 0x4(%esp), %edx #get argument(singletonPtrAddr) from stack msach@5: movl %eax, (%edx) #write ret addr to endInstrAddr field msach@5: ret msach@5: msach@5: msach@5: //Assembly code changes the return addr on the stack to the one msach@5: // saved into the singleton by the end-singleton-fn msach@5: //The stack's return addr is at 0x4(%%ebp) msach@5: .globl asm_write_ret_from_singleton msach@5: asm_write_ret_from_singleton: msach@5: movl 0x4(%esp), %edx #get singleton addr from stack msach@5: movl (%edx), %eax #get endInstrAddr field msach@5: movl %eax, 0x4(%ebp) #write return addr to the stack of the caller msach@5: ret msach@5: msach@5: