Page 1 of 1
[Implemented] Assembly symbols for procedure local variables
Posted: Wed Sep 22, 2004 10:44 pm
by tinman
Currently there are assembler symbols for the global variables (v_xxxx, p_xxxx, t_xxxx) but it would be nice if there were symbols for the local variables in a procedure.
Perhaps in the style of constants, in the style "v_<procedure name>_<variable name>" so that it would be possible to access the local variables from the stack in the form:
Code: Select all
Procedure foo(bar)
; x86
!MOV dword [esp + #v_foo_bar], 23 ; Or whatever the syntax would be for the assembler
; or this for 68k
move.l #23,v_foo_bar(a7)
; or something else for PPC
EndProcedure
It could even be optional if people aren't going to use it, but would like to keep the size of their commented asm files small.
Posted: Wed Sep 22, 2004 11:30 pm
by VPureBasic
Hi Tinman,
I hope thi will help you... That's the way I use it!
Code: Select all
;- All Arguments Declaration For Procedures
!Arg_00 = 0
!Arg_01 = 4
!Arg_02 = 8
; Etc...
Procedure MyProcedure( x.l )
;
!MOV dword Eax, [Esp+ Arg_00]
; For the first argument you can avoid it because
; PBasic store it in eax too
;
EndProcedure
Roger
Posted: Wed Sep 22, 2004 11:37 pm
by tinman
Hi Roger,
Thanks, I had not thought about doing that for the parameters.
However, it's not just for parameters, I'd like to be able to use it on variables declared inside the procedure as well. I know how to calculate the offsets, but it would be such a pain to have to change them each time I added or removed a variable :)
Posted: Thu Sep 23, 2004 2:56 am
by El_Choni
Just for the record, you can also do this with FASM:
Code: Select all
!arg0 equ [esp+0]
...
!mov eax, arg0
And it's probably easy to code a Fasm macro to put just arg0, arg1, etc, and get the corresponding argument value.
But why don't you just...
Code: Select all
Procedure DoItTheEasyWay(EasyWay)
SomeWay.l
SUB EasyWay, 3
MOV SomeWay, 5
INC EasyWay
ProcedureReturn EasyWay+SomeWay
EndProcedure
Debug DoItTheEasyWay(7)
Regards,
Posted: Thu Sep 23, 2004 3:21 am
by jack
I personally got into the habit of using the ‘!’ on all my inline statements,
Because PB don’t recognize all assembly mnemonics and secondly
You don’t have to worry about telling people to have inline asm enabled.
I vote for having a way to access local variables, as tinman suggested.

Posted: Thu Sep 23, 2004 9:17 am
by tinman
El_Choni wrote:But why don't you just...
Because I completely forgot you could do that :)