Page 1 of 2
minor (about new way to reference function veriables ...)
Posted: Tue May 23, 2006 11:41 am
by Psychophanta
Error here

:
Code: Select all
Procedure a(var.l)
!mov eax,p.v_var ; <- not allowed :(
EndProcedure
v.l=34
a(v)
Posted: Tue May 23, 2006 12:20 pm
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.
Posted: Tue May 23, 2006 12:24 pm
by El_Choni
You can use LEA EAX, [p.v_var]
Posted: Tue May 23, 2006 12:38 pm
by Psychophanta
Thanx,
El_Choni, i already knew that, but thanx anyway.

Posted: Tue May 23, 2006 3:42 pm
by Trond
Code: Select all
Procedure test()
Static a
!mov [p.v_a], 4
EndProcedure
test()
Posted: Tue May 23, 2006 3:48 pm
by Psychophanta
Trond wrote:Code: Select all
Procedure test()
Static a
!mov [p.v_a], 4
EndProcedure
test()
Good one

Posted: Tue May 23, 2006 3:50 pm
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.
Posted: Tue May 23, 2006 3:52 pm
by Psychophanta
Well, anyway, how can access to a static variable via ASM ??
Posted: Tue May 23, 2006 3:58 pm
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.
Posted: Tue May 23, 2006 4:02 pm
by Psychophanta
Thanks once more, freak

Posted: Tue May 23, 2006 4:19 pm
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.
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.
Posted: Tue May 23, 2006 4:25 pm
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.
Posted: Tue May 23, 2006 6:09 pm
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.
Posted: Tue May 23, 2006 6:22 pm
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.
Posted: Tue May 23, 2006 6:38 pm
by netmaestro
Then I demand that this missing syntax error check is acknowledged without further discussion
Good luck with that one. And keep treating the team like they're newbies, too, they like that.