diff VPThread.s @ 5:f36e9ab2e030

separated asm singleton routines
author Merten Sach <msach@mailbox.tu-berlin.de>
date Mon, 06 Jun 2011 18:30:00 +0200
parents
children ce4ad44fcc23
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/VPThread.s	Mon Jun 06 18:30:00 2011 +0200
     1.3 @@ -0,0 +1,23 @@
     1.4 +
     1.5 +//Assembly code takes the return addr off the stack and saves
     1.6 +// into the singleton.  The first field in the singleton is the
     1.7 +// "endInstrAddr" field, and the return addr is at 0x4(%ebp)
     1.8 +.globl asm_save_ret_to_singleton
     1.9 +asm_save_ret_to_singleton:
    1.10 +    movl 0x4(%ebp),     %eax   #get ret address, ebp is the same as in the calling function
    1.11 +    movl 0x4(%esp),     %edx   #get argument(singletonPtrAddr) from stack
    1.12 +    movl      %eax,     (%edx) #write ret addr to endInstrAddr field
    1.13 +    ret
    1.14 +
    1.15 +
    1.16 +//Assembly code changes the return addr on the stack to the one
    1.17 +// saved into the singleton by the end-singleton-fn
    1.18 +//The stack's return addr is at 0x4(%%ebp)
    1.19 +.globl asm_write_ret_from_singleton
    1.20 +asm_write_ret_from_singleton:
    1.21 +    movl 0x4(%esp),    %edx  #get singleton addr from stack
    1.22 +    movl    (%edx),    %eax  #get endInstrAddr field
    1.23 +    movl      %eax,    0x4(%ebp) #write return addr to the stack of the caller
    1.24 +    ret
    1.25 +
    1.26 +