minor (about new way to reference function veriables ...)

Just starting out? Need help? Post your questions and find answers here.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

minor (about new way to reference function veriables ...)

Post by Psychophanta »

Error here :cry: :

Code: Select all

Procedure a(var.l) 
 !mov eax,p.v_var ; <- not allowed  :(
EndProcedure
v.l=34
a(v)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

It is because the p.v_var gets defined as ESP+X where X is the position of the
variable on the stack.
It is not a direct label, as the global variables are.

This sort of notation is valid in [] only, not with MOV.
quidquid Latine dictum sit altum videtur
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

You can use LEA EAX, [p.v_var]
El_Choni
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Thanx,
El_Choni, i already knew that, but thanx anyway.
:)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Code: Select all

Procedure test()
  Static a
  !mov [p.v_a], 4
EndProcedure

test()
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Trond wrote:

Code: Select all

Procedure test()
  Static a
  !mov [p.v_a], 4
EndProcedure

test()
Good one :?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Psychophanta wrote:
Trond wrote:

Code: Select all

Procedure test()
  Static a
  !mov [p.v_a], 4
EndProcedure

test()
Good one :?
Fred just told me to look at the generated asm as if it wasn't a bug. But since it doesn't work as described in the manual I'd say it is.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Well, anyway, how can access to a static variable via ASM ??
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Code: Select all

Procedure test()
  Static a
  !mov [s_test.v_a], 4
EndProcedure

test()
The commented compiler output shows it all, if you are too lazy to look at it, we can't help you...

Static variables are not on the stack but on a fixed location, like globals, so all the
p.v_var stuff is not needed there.
quidquid Latine dictum sit altum videtur
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Thanks once more, freak :oops:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

freak wrote:

Code: Select all

Procedure test()
  Static a
  !mov [s_test.v_a], 4
EndProcedure

test()
The commented compiler output shows it all, if you are too lazy to look at it, we can't help you...

Static variables are not on the stack but on a fixed location, like globals, so all the
p.v_var stuff is not needed there.
It's not about being lazy. :evil: I know how to reference them. But when PureBasic does not act as described in the manual, then I consider it a bug. The manual is the only reference point I have on how PureBasic should work. I could be really mean and file everything I think is wrong as a bug, but I am looking at the only official guide on how things should be, and when things aren't like they are described in the only official guide, then I say it's a bug.

If your definition of a bug is different, please tell me, but I doubt I will be convinced to take another opinion that if the program doesn't work as described in the manual it's a bug.
- It's possible to pass directly an assembly line to the assembler without being processed by the compiler by using the '!' character at the line start. This allow to have a full access to the assembler directives. When using this, it's possible to reference the local variables using the notation 'p.v_variablename' for a regular variable or 'p.p_variablename' for a pointer
Static allows to create a local persistent variable in a Procedure even if the same variable has been declared as Global in the main program.
  • Static creates a local variable, this is clearly written in the manual.
  • It should be possible to reference local variables that are not pointers in inline asm using the notation p.v_variablename. This is also clearly written in the manual.
  • The program does not behave like the manual describes.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

reference the local variables using the notation 'p.v_variablename' for a regular variable
Static variable is not a regular variable. So then the manual is correct. Only it omits how to access to static variable, nothing more, so then no bug.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Psychophanta wrote:
reference the local variables using the notation 'p.v_variablename' for a regular variable
Static variable is not a regular variable. So then the manual is correct. Only it omits how to access to static variable, nothing more, so then no bug.
Then I demand that this missing syntax error check is acknowledged without further discussion:

Code: Select all

Procedure Test()
  Protected Apple
  !mov dword [p.v_Apple], 4
EndProcedure

Test()
A protected variable is not a regular variable, either. I interpreted "regular" as opposed to "pointer". If "regular" was opposed to Static, Protected and Shared, then there is an error when the code works with Protected. It "regular" was opposed to Static and Shared, but NOT Protected, then I suggest that we drop the manual since we're expected to read the minds of the author of it anyways and people who are able to do that won't need the manual.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

1-. Static is far different then Protected and Shared.
2-. Manual is written in english, which is a human language, it is not written in 0s and 1s.

I am really glad to see the manual like that, because never before was so complete.

Anyway, i insist it would include that info about Static vars managed in ASM.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Then I demand that this missing syntax error check is acknowledged without further discussion
:lol: :lol: :lol:
Good luck with that one. And keep treating the team like they're newbies, too, they like that.
BERESHEIT
Locked