News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

INVOKE changes flags in x64

Started by Yuri, February 01, 2012, 02:58:27 AM

Previous topic - Next topic

Yuri

Not a big deal, but I thought it might be worth asking. My problem with the x64 invoke is that I am used to signalling success or failure of the called function by clearing or setting the carry flag (got this idea from the manual). But in x64 mode it is no longer possible because GoAsm puts ADD RSP after the call and thereby clears CF. Could this operation be realized using LEA so that the flags were untouched?

LEA is a bit longer code, but if I have to always use RAX for reporting success/failure of the call, I probably lose more than I gain in this respect. Also, zero in RAX is a valid result sometimes, so you have to invent some other failure marker or use another register, and when using this function later, you have to recall how it reports failure. With CF there is nothing to recall.

qWord

hi,
you can also use rcx,rdx,r8,r9,r10 and r11 for returning information about functions result.(?)
FPU in a trice: SmplMath
It's that simple!

Yuri

Hi, qWord

Yes, I can, but using the carry flag seems much simpler and I am used to it already. Recently I was converting a couple of my 32-bit programs to switchable x86/x64 code and I had to go through all the functions to change the way they reported success and failure, and also through all the places where they were called. I couldn't say I liked that. The CF method seems much more convenient and unambiguous.

Actually in switchable code I can't use the new registers (r8, etc), and I already use R/ECX and R/EDX for returning additional data from some functions. So I can't restrict one of them to the role that CF used to play.

dedndave

LEA sounds like the way to go   :U

donkey

I agree that LEA should be used in this case, it will also make the FLAGS keyword useful once again (USES FLAGS is not effective with the X64 invoke).

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

wjr

I have forwarded the LEA revision of INVOKE to Jeremy to be incorporated into the upcoming GoAsm Version 0.57.

Yuri

Thanks, Wayne. It's great GoAsm is under development again. :8)