[Implemented] Assembly symbols for procedure local variables

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

[Implemented] Assembly symbols for procedure local variables

Post 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.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
VPureBasic
User
User
Posts: 59
Joined: Fri Apr 25, 2003 6:09 pm
Location: Quebec - Canada

Post 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
Everything is possible with PureBASIC... All you're missing is imagination!
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post 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 :)
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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,
El_Choni
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post 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. :)
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

El_Choni wrote:But why don't you just...
Because I completely forgot you could do that :)
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Post Reply