flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Roman 26 Sep 2019, 08:25
My question how right write proc for 64 bit programs ?
|
|||
![]() |
|
revolution 26 Sep 2019, 08:33
When you use invoke to call a procedure the values of the first four parameters are in registers and are not placed into memory. This is how the MS 64-bit calling convention works.
So you can do this: Code: proc HiMsgB name:qword mov [name],rcx ;"name" is a memory address so you can store the value of rcx here invoke MessageBox,0,[name],0,0 ;work fine ret Code: proc HiMsgB name:qword invoke MessageBox,0,rcx,0,0 ;use rcx directly if you don't need the value later ret Code: proc HiMsgB name:qword invoke MessageBox,0,[name],0,0 ;[name] has not been initialised yet, it is just a placeholder ret |
|||
![]() |
|
ProMiNick 26 Sep 2019, 09:25
Thou could accept that in 64 bit there is no calls with less than 4 parameters.
We allways could define (or skip) any of rcx,rdx,r8,r9. In current case passing parameter to rcx only for later moving it to edx - is stupid. Code: proc HiMsgB ;dummy,name invoke MessageBox,0,rdx,0,0 ret endp Code: invoke HiMsg,rcx,'Hi ! World !' |
|||
![]() |
|
Roman 26 Sep 2019, 10:02
Thanks to all
|
|||
![]() |
|
Roman 26 Sep 2019, 11:11
What about dll for 64 bits ?
what are the nuances ? |
|||
![]() |
|
revolution 26 Sep 2019, 11:15
For DLLs and EXEs the calling conventions are the same when you are interfacing with the OS.
For internal calls between your own functions you can do whatever you want. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.