I must be tired & missing the obvious.

but does masm have have a straight-forward & compact notation for returning arbitrarilly sized values (small structure actually) on the stack?

or am i going to have to do it the old fashioned way...
- caller adds n to esp
- callee fills the structure using appropriately tweaked negative offsets to ebp
- caller can pop (or reference) saved data making sure esp is balanced
there are many variants on the above. i can do it but i'll bet masm do it better
Posted on 2001-09-15 21:53:27 by rafe
The typical method in MASM is to pass the memory address to the structure on the stack to the PROC that modifies it. I know of no shortcut way to adjust the stack, but here is a quick attempt at a macro. :)
;Need to correct the stack after this macro!

FancyProc MACRO Proceedure:REQ,Structure:REQ,args:VARARG
sub esp, SIZEOF Structure
mov eax, esp
invoke Proceedure, eax, args
Posted on 2001-09-16 00:08:42 by bitRAKE

Bitrake is right, about all you can return from a procedure is a register. Just pass the address of the structure you need modified and write the code to modify it within the procedure.

mov eax, lpRct ; <= the structure address
; -- ---------------------------------
; modify the members of the structure
; -----------------------------------
mov (RECT PTR ).left, 10
mov (RECT PTR ).top, 12
mov (RECT PTR ).right, 14
mov (RECT PTR ).bottom, 16

You can set a return value if you need it for any other purpose and return it in EAX like normal.


Posted on 2001-09-16 01:32:54 by hutch--
both methods will do what i need & are a bit more elegant than what i was floundering at. now i gotta go kick myself b/c i forgot good ole "call by reference". doh! bad brain

& Hutch, I like the notation tip too. i was doing the equivalent of
mov RECT.left, 10 ;;a bit more obtuse than your notation.

thanks to both

Posted on 2001-09-16 15:51:10 by rafe