Page 1 of 1
How to access a 'Static' variable with inline assembly?
Posted: Fri May 11, 2018 8:40 am
by Mijikai
How can i change the content of 'Address' with inline assembly?
Code:
Code: Select all
;PB x64 v.5.62
Procedure.i TestFnc()
Static Address.i
!mov qword[p.v_Address],123;<- does not work for 'Static' !
Debug Address
EndProcedure
TestFnc()
Re: How to access a 'Static' variable with inline assembly?
Posted: Fri May 11, 2018 8:46 am
by Fred
If you want to look that, the best is to generate the assembly code with the commandline compiler (--commented switch) and look how it is named. You will save a lot of time when using inline ASM.
Re: How to access a 'Static' variable with inline assembly?
Posted: Fri May 11, 2018 9:19 am
by Mijikai
Fred wrote:If you want to look that, the best is to generate the assembly code with the commandline compiler (--commented switch) and look how it is named. You will save a lot of time when using inline ASM.
Thanks
Heres how it works:
I found something im curious about:
If we have a Procedure that does not return a value PB does this:
However if we return a value it looks like this:
Code: Select all
...
jmp @f
xor rax,rax
@@:
add rsp,28
ret
why is the
jmp & xor even in there ?
Re: How to access a 'Static' variable with inline assembly?
Posted: Fri May 11, 2018 9:28 am
by wilbert
Mijikai wrote:How can i change the content of 'Address' with inline assembly?
You could do it like this
Code: Select all
;PB x64 v.5.62
Procedure.i TestFnc()
Static Address.i
Protected *Address = @Address
!mov rdx, [p.p_Address]
!mov qword [rdx],123
Debug Address
EndProcedure
TestFnc()
It does produce a bit of additional code and therefore is slightly slower but it does have the advantage that the reference to *Address (local variable) stays the same.
The reference to a static value changes when the procedure is included in a module.
Re: How to access a 'Static' variable with inline assembly?
Posted: Fri May 11, 2018 10:34 am
by Mijikai
wilbert wrote:...
Code: Select all
;PB x64 v.5.62
Procedure.i TestFnc()
Static Address.i
Protected *Address = @Address
!mov rdx, [p.p_Address]
!mov qword [rdx],123
Debug Address
EndProcedure
TestFnc()
It does produce a bit of additional code and therefore is slightly slower but it does have the advantage that the reference to *Address (local variable) stays the same.
The reference to a static value changes when the procedure is included in a module.
Thanks, i didnt think of that way
Re: How to access a 'Static' variable with inline assembly?
Posted: Fri May 11, 2018 2:46 pm
by CELTIC88
Mijikai wrote:...
I found something im curious about:
If we have a Procedure that does not return a value PB does this:
However if we return a value it looks like this:
Code: Select all
...
jmp @f
xor rax,rax
@@:
add rsp,28
ret
why is the
jmp & xor even in there ?
so that "PB" can be adapted to any scenario
"is complex process!"
but you can optimize that.