Can someone explain to me why this code returns 1 instead 0?
(I tried to find some topic about this but too much collected results with keyword ProcedureReturn)
As there is no value after ProcedureReturn, I expected 0 to be returned.
This is the first time I've been faced with this situation in 20 years....
Last edited by boddhi on Sun May 12, 2024 1:42 am, edited 1 time in total.
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
This is an important behaviour meant to ease usage of inline assembly for the ASM backend, where the content of EAX/RAX is used accordingly as return value.
Without this, you'd have to MOV your result from ASM into a PB variable and then return the variable separately, which is inconvenient and a bit wasteful if it's already present in EAX/RAX.
Mindphazer wrote: Sat May 11, 2024 11:31 pm
That's weird. On MacOS, your code returns 0 as expected (PB 6.10)
But on Windows, it returns 1 (PB 6.10 too)
For the C-backend it will return a zero-value instead, so this is indeed a source of variation between backends, but is allowed per the "undefined behaviour" disclaimer.
; If Not Test:ProcedureReturn:EndIf
CMP byte [rsp+48],0
JE No0
XOR rax,rax
JMP Ok0
No0:
MOV rax,1
Ok0:
AND rax,rax
JE _EndIf2
JMP _EndProcedure1
_EndIf2:
@r-i-v-e-r
Thanks for your explanation.
And now that you say it, I actually have a vague memory of having read this somewhere a very very long time ago (C-backend didn't exist yet!).
Bad news, I will have to make sure on all my codes that there are no hidden defects in them.
@juergenkulow
Cool, but I don't understand anything in assembler coding!
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...