home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / system / source / a64_thunk.asm < prev    next >
Encoding:
Assembly Source File  |  2009-09-14  |  1.1 KB  |  59 lines

  1.     segment    .text
  2.         
  3.         global    VDMethodToFunctionThunk64
  4. proc_frame    VDMethodToFunctionThunk64
  5.         ;prolog
  6.         db            48h                ;emit REX prefix -- first instruction must be two bytes for hot patching
  7.         push        rbp
  8.         [pushreg    rbp]
  9.         
  10.         mov            rbp, rsp        ;create stack pointer
  11.         [setframe    rbp, 0]
  12.         
  13.         mov            [rbp+16], rcx    ;save arg1
  14.         [savereg    rcx, 0]
  15.         
  16.         mov            [rbp+24], rdx    ;save arg2
  17.         [savereg    rcx, 8]
  18.  
  19.         mov            [rbp+32], r8    ;save arg3
  20.         [savereg    rcx, 16]
  21.  
  22.         mov            [rbp+40], r9    ;save arg4
  23.         [savereg    rcx, 24]
  24.         
  25. end_prolog
  26.                 
  27.         ;re-copy arguments 4 and up
  28.         mov            ecx, [rax+24]
  29.         or            ecx, ecx
  30.         jz            .argsdone
  31.         lea            rdx, [rcx+48-8]
  32. .argsloop:
  33.         push        qword [rsp+rdx]
  34.         sub            ecx, 8
  35.         jnz            .argsloop
  36. .argsdone:
  37.         
  38.         ;load 'this' pointer
  39.         mov            rcx, [rax+16]
  40.         
  41.         ;reload arguments 1-3
  42.         mov            rdx, [rbp+16]
  43.         mov            r8, [rbp+24]
  44.         mov            r9, [rbp+32]
  45.         
  46.         ;reserve argument 1-4 space on stack
  47.         sub            rsp, 32
  48.         
  49.         ;call function
  50.         call        qword [rax+8]
  51.         
  52.         ;epilog
  53.         lea            rsp, [rbp]        ;pop off stack frame and any additional arg space
  54.         pop            rbp                ;restore base pointer
  55.         ret                            ;all done
  56. endproc_frame
  57.  
  58.         end
  59.