comparison VPThread.s @ 8:a2ff41577ecb

Version 0
author Merten Sach <msach@mailbox.tu-berlin.de>
date Mon, 11 Jul 2011 18:08:44 +0200
parents f36e9ab2e030
children
comparison
equal deleted inserted replaced
0:a5baeb36202c 1:86903585e1eb
2 //Assembly code takes the return addr off the stack and saves 2 //Assembly code takes the return addr off the stack and saves
3 // into the singleton. The first field in the singleton is the 3 // into the singleton. The first field in the singleton is the
4 // "endInstrAddr" field, and the return addr is at 0x4(%ebp) 4 // "endInstrAddr" field, and the return addr is at 0x4(%ebp)
5 .globl asm_save_ret_to_singleton 5 .globl asm_save_ret_to_singleton
6 asm_save_ret_to_singleton: 6 asm_save_ret_to_singleton:
7 movl 0x4(%ebp), %eax #get ret address, ebp is the same as in the calling function 7 movq 0x8(%rbp), %rax #get ret address, ebp is the same as in the calling function
8 movl 0x4(%esp), %edx #get argument(singletonPtrAddr) from stack 8 movq %rax, (%rdi) #write ret addr to endInstrAddr field
9 movl %eax, (%edx) #write ret addr to endInstrAddr field
10 ret 9 ret
11 10
12 11
13 //Assembly code changes the return addr on the stack to the one 12 //Assembly code changes the return addr on the stack to the one
14 // saved into the singleton by the end-singleton-fn 13 // saved into the singleton by the end-singleton-fn
15 //The stack's return addr is at 0x4(%%ebp) 14 //The stack's return addr is at 0x4(%%ebp)
16 .globl asm_write_ret_from_singleton 15 .globl asm_write_ret_from_singleton
17 asm_write_ret_from_singleton: 16 asm_write_ret_from_singleton:
18 movl 0x4(%esp), %edx #get singleton addr from stack 17 movq (%rdi), %rax #get endInstrAddr field
19 movl (%edx), %eax #get endInstrAddr field 18 movq %rax, 0x8(%rbp) #write return addr to the stack of the caller
20 movl %eax, 0x4(%ebp) #write return addr to the stack of the caller
21 ret 19 ret
22 20
23 21