BBC BASIC for Windows
Programming >> Assembly Language Programming >> Returning values from ASM functions http://bb4w.conforums.com/index.cgi?board=assembler&action=display&num=1279396578 Returning values from ASM functions
Post by David Williams on Jul 17th, 2010, 7:56pm
I'm a bit embarrassed to have to ask, but...
I quite often - nearly always, in fact - push all registers onto the stack at the beginning of a routine:
Code:
.routine
pushad ; preserve registers
(do stuff)
popad ; restore registers
ret
But I find that when I need to return a value in EAX, I do this:
Code:
.routine
pushad
(do some stuff...)
(put some value in EAX)
mov [^temp], eax
popad
mov eax, [^temp]
ret
Is there a neater way to return a value in EAX without stashing the return value in a temporary memory location first?
Thanks.
David. Re: Returning values from ASM functions
Post by admin on Jul 17th, 2010, 9:53pm