Menu

push rbp

habran
2013-02-12
2013-04-20
  • habran

    habran - 2013-02-12

    Hi Japheth,
    I would like to write some functions without "push rbp" because they are unnecessary in some cases EG:

    xmemcpy:
    ;000000014004DA78  push        rbp  
    ;000000014004DA79  mov         rbp,rsp 
    000000014004DA7C  mov         rax,rcx 
    000000014004DA7F  cmp         rcx,rdx 
    000000014004DA82  je          xmemcpy+25h (14004DA9Dh) 
    000000014004DA84  test        r8,r8 
    000000014004DA87  je          xmemcpy+25h (14004DA9Dh) 
    000000014004DA89  mov         r9b,byte ptr [rdx] 
    000000014004DA8C  mov         byte ptr [rcx],r9b 
    000000014004DA8F  add         rcx,1 
    000000014004DA93  add         rdx,1 
    000000014004DA97  sub         r8,1 
    000000014004DA9B  jne         xmemcpy+11h (14004DA89h) 
    ;000000014004DA9D  leave 
               
    000000014004DA9E  ret
    

    Is it possible to do that?

     
  • japheth

    japheth - 2013-02-12

    > Is it possible to do that?

    I hope so - the directives OPTION PROLOGUE/EPILOGUE are still implemented in 64-bit mode.

     
  • habran

    habran - 2013-02-13

    thanks Japheth
    after little bit of struggle I found the way to use it here is example:

    ;//--------------------------------------------------
    option win64:0
    OPTION PROLOGUE:NONE 
    OPTION EPILOGUE:NONE
    xmemcpy PROC dest:QWORD,src :QWORD, count:UINT_PTR
            mov     rax, rcx
            cmp     rcx, rdx
            jz      aexit
            test    r8, r8
            jz      short aexit
    @@:     mov     r9b, [rdx]
            mov     [rcx], r9b
            add     rcx, 1
            add     rdx, 1
            sub     r8, 1
            jnz     @b
    aexit:  ret
    xmemcpy ENDP
    OPTION PROLOGUE:PrologueDef
    OPTION EPILOGUE:EpilogueDef
    ;//--------------------------------------------------
    option win64:3
    option frame:auto
    

    and this is what I get commpiled:

    xmemcpy:
    000000014004DA78  mov         rax,rcx 
    000000014004DA7B  cmp         rcx,rdx 
    000000014004DA7E  je          xmemcpy+21h (14004DA99h) 
    000000014004DA80  test        r8,r8 
    000000014004DA83  je          xmemcpy+21h (14004DA99h) 
    000000014004DA85  mov         r9b,byte ptr [rdx] 
    000000014004DA88  mov         byte ptr [rcx],r9b 
    000000014004DA8B  add         rcx,1 
    000000014004DA8F  add         rdx,1 
    000000014004DA93  sub         r8,1 
    000000014004DA97  jne         xmemcpy+0Dh (14004DA85h) 
    000000014004DA99  ret
    
     

Log in to post a comment.