NO

Author Topic: GoAsm  (Read 2168 times)

Grincheux

  • Guest
GoAsm
« on: April 19, 2021, 06:22:02 PM »
Quote
Calling procedures outside the stack frame - use of USEDATA...ENDUsub-menu[/size]You may prefer to keep the frame itself compact and call [/size]outside[/size] the frame to help the readability of your code. You can do this and still maintain access to the parameters and local data within the frame by using the USEDATA statement followed by the name of the frame concerned. For example, the WM_PAINT message in the frame above might call this procedure:-
PAINT: USEDATA WndProc INVOKE BeginPaint, [hwnd],ADDR lpPaint     ;get in eax the DC to use MOV [hDC],EAX INVOKE Ellipse, [hDC],[lpPaint.rcPaint.left],   \ [lpPaint.rcPaint.top] ,   \ [lpPaint.rcPaint.right],  \ [lpPaint.rcPaint.bottom] INVOKE EndPaint, [hwnd],ADDR lpPaint XOR EAX,EAX RET ENDU 
[/size]Here the procedure PAINT is using local data in the FRAME called WndProc. All the code above is outside the FRAME...ENDF envelope.[/size]You can also use USEDATA to access local data in other USEDATA..ENDU areas.Just make sure that USEDATA is used later in the source script than any parameters and local data declarations that it relies on. This is because GoAsm is a one pass assembler and it needs to find the position of that earlier data.If a procedure which is called from a FRAME or a USEDATA area does not need to access any of the parameters, local data, or locally defined words, then it need not have its own USEDATA statement.[/b][/color][/size][/size]More than one exit point or procedure within a USEDATA...ENDU areaJust as when using FRAME...ENDF, you can have as many return points from the USEDATA procedure using RET as you like. Each one will produce the correct epilogue code which is run when leaving the USEDATA area. However, this also means that if you have additional procedures within the USEDATA area you must be careful to use RETN ("normal" RET) to avoid creating epilogue code for those.Only the first USEDATA procedure ought to be called from outside the USEDATA..ENDU area. This is because the correct code to access the stack will only be set up for this first procedure.