flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > 64bit - proc or invoke problem?

Author
Thread Post new topic Reply to topic
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Been working in 64bit windows for a while and did a dis-assembly of one of my executables and noticed that there some instructions in either the proc or invoke that I don't think are needed.

a sample is here (The instructions I'm talking about have a ?- in front of them):
Code:
        push    rbp                                     ; 00402000 _ 55
        mov     rbp, rsp                                ; 00402001 _ 48: 89. E5
        sub     rsp, 416                                ; 00402004 _ 48: 81. EC, 000001A0
        sub     rsp, 32                                 ; 0040200B _ 48: 83. EC, 20
        lea     rcx, [rbp-1A0H]                         ; 0040200F _ 48: 8D. 8D, FFFFFE60
        mov     rdx, 0                                  ; 00402016 _ 48: C7. C2, 00000000
        mov     r8, 80                                  ; 0040201D _ 49: C7. C0, 00000050
        call    near [rel imp_memset]                   ; 00402024 _ FF. 15, 000020E6(rel)
        ?-add     rsp, 32                                 ; 0040202A _ 48: 83. C4, 20
        ?-sub     rsp, 32                                 ; 0040202E _ 48: 83. EC, 20
        mov     rcx, ?_003                              ; 00402032 _ 48: C7. C1, 0040105C(d)
        call    near [rel imp_InitCommonControlsEx]     ; 00402039 _ FF. 15, 00002371(rel)
        ?-add     rsp, 32                                 ; 0040203F _ 48: 83. C4, 20
        ?-sub     rsp, 32                                 ; 00402043 _ 48: 83. EC, 20
        mov     rcx, 0                                  ; 00402047 _ 48: C7. C1, 00000000
        call    near [rel imp_GetModuleHandleA]         ; 0040204E _ FF. 15, 0000210C(rel)
        ?-add     rsp, 32                                 ; 00402054 _ 48: 83. C4, 20
        mov     qword [rbp-188H], rax                   ; 00402058 _ 48: 89. 85, FFFFFE78
        mov     qword [rel ?_002], rax                  ; 0040205F _ 48: 89. 05, FFFFEFD2(rel)
        mov     dword [rbp-1A0H], 80                    ; 00402066 _ C7. 85, FFFFFE60, 00000050
        mov     qword [rbp-180H], 0                     ; 00402070 _ 48: C7. 85, FFFFFE80, 00000000
        mov     qword [rbp-158H], 0                     ; 0040207B _ 48: C7. 85, FFFFFEA8, 00000000
        ?-sub     rsp, 32                                 ; 00402086 _ 48: 83. EC, 20
        mov     rcx, 0                                  ; 0040208A _ 48: C7. C1, 00000000
        mov     rdx, 32512                              ; 00402091 _ 48: C7. C2, 00007F00
        call    near [rel imp_LoadCursorA]              ; 00402098 _ FF. 15, 0000218A(rel)
        add     rsp, 32                                 ; 0040209E _ 48: 83. C4, 20
    

_________________
Gimme a sledge hammer! I'LL FIX IT!
Post 03 Jan 2012, 02:02
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7801
Location: Kraków, Poland
Tomasz Grysztar
Use "frame" macro to get rid of them. See documentation of 64-bit procedure macroinstructions.
Post 03 Jan 2012, 10:26
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Tomasz Grysztar wrote:
Use "frame" macro to get rid of them. See documentation of 64-bit procedure macroinstructions.


Yeh, that worked, thanks.
But, why isn't this feature automatic?

_________________
Gimme a sledge hammer! I'LL FIX IT!
Post 03 Jan 2012, 14:38
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7801
Location: Kraków, Poland
Tomasz Grysztar
Documentation wrote:
They should be used to enclose a block, inside which the RSP register is not altered between the procedure calls (...)
These macros have to be used knowingly.

PS Also see the part about "static_rsp_prologue" family of macros, you may find them useful.
Post 03 Jan 2012, 15:13
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Quote:
PS Also see them part about "static_rsp_prologue" family of macros, you may find them useful.


Yeh, putting these three lines (below) at the end of the proc64.inc file removes the added instructions and doesn't require the frame/endf macros. Thanks a lot, I feel better about the code output now. Very Happy
Code:
  prologue@proc equ static_rsp_prologue
  epilogue@proc equ static_rsp_epilogue
  close@proc equ static_rsp_close    
Post 03 Jan 2012, 21:10
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.