flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Macro to define REG as pointer [x64] |
Author |
|
revolution 03 Oct 2010, 06:47
Code: edi equ I_am_an_error lea rdi, [MyString] ... ... ... inc edi restore edi |
|||
03 Oct 2010, 06:47 |
|
edfed 03 Oct 2010, 13:08
Code: use64 edi equ rdi ... restore edi use32 rdi equ edi ... restore rdi but i just propose to avoid the errors by coding with care. like 16 bit and 32 bit regiters can be mixed, 64 and 32 can be too. the use of a 32 bit register as index in 64 bit can be used to limit the adress space. for example, if a 32 bit VM is running, and the 64 bit OS is filling it's adress space in 64 bit mode, then, it will need to do that with EDI instead of RDI, to wrap around the 4G adress space. |
|||
03 Oct 2010, 13:08 |
|
alorent 03 Oct 2010, 17:32
Thanks guys!
revolution, I'd like to use your solution but defining a macro like "assume_reg rdi:pointer" I have been trying to re-use the already defined "assume" macro, but I'm unable to make it work with my scarce knowledge about FASM macros. Any help in defining the "assume_reg" macro? Thanks in advance! |
|||
03 Oct 2010, 17:32 |
|
revolution 03 Oct 2010, 21:21
Code: macro assume_reg [stuff] { common match =RDI=:=POINTER,stuff \{ edi equ dont_use_me \} match =RDI=:=NOTHING,stuff \{ restore edi \} } |
|||
03 Oct 2010, 21:21 |
|
alorent 04 Oct 2010, 10:24
Thanks a lot revolution! You always here to help!
|
|||
04 Oct 2010, 10:24 |
|
bitRAKE 05 Oct 2010, 05:38
I like edfed's type of solution because many algorithms only require slight changes to work in both 32-bit and 64-bit. I often rename registers with VIRTUAL, to keep the name local to a procedure (avoid the need for restore). Unfortunately, this only works for indirect access.
Code: virtual at rbp .hWnd rq 1 end virtual mov [.hWnd],rcx ; kind of cool mov rcx,.hWnd ; ERROR Code: HINSTANCE = $10000 format PE64 GUI 5.0 at HINSTANCE |
|||
05 Oct 2010, 05:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.