Strange issue with loading Pointers of Structures
Posted: Sat Nov 15, 2025 3:54 pm
I want to load the Pointer of a Structure variable to a Register! The Structure Var can be a var.vector4 or *var.vector4
If I do this inside a Procedure it works with MOV for the *var and LEA for the var
But when I do the same from outside a Procedure I need MOV for both *var and var
here is the example
If I do this inside a Procedure it works with MOV for the *var and LEA for the var
But when I do the same from outside a Procedure I need MOV for both *var and var
here is the example
Code: Select all
EnableASM
EnableExplicit
; for calls from inside a procedure it's differnt: Structure Pointers with MOV and VAR with LEA
; for me this seems correct. But for calls from outside a Procedure we need MOV for both. See below!
Macro _VectorPointerToREG(_REG_, _vector_)
Debug SizeOf(_vector_)
CompilerIf SizeOf(_vector_)=SizeOf(Integer)
MOV _REG_, _vector_
CompilerElse
LEA _REG_, _vector_
CompilerEndIf
EndMacro
; why outside of a Procedrue it is always MOV? for Structure pointers and for var
Macro _VectorPointerToREG_outsidePorc(_REG_, _vector_)
MOV _REG_, _vector_
EndMacro
Macro DbgREG(_REG=RAX)
Define _dbgval_
MOV _dbgval_, _REG
Debug _dbgval_
EndMacro
Procedure vecTest(*vec.Vector4)
Protected mv.Vector4
Debug "inside Procedure"
Debug "mv"
_VectorPointerToREG(RAX, mv)
DbgREG()
Debug @ mv
Debug ""
Debug"*vec"
_VectorPointerToREG(RAX, *vec)
DbgREG()
Debug *vec
EndProcedure
Define v.Vector4
Define *pv.Vector4 = @v
Debug @v
Debug *pv
Debug @*pv
Debug""
vecTest(v)
Debug ""
Debug "outside Procedure"
Debug ""
Debug "v"
; _VectorPointerToREG_outsidePorc(RAX, v) ; Try this! It will cause an error
_VectorPointerToREG_outsidePorc(RAX, v)
DbgREG()
Debug @v
Debug ""
Debug "*pv"
_VectorPointerToREG_outsidePorc(RAX, *pv)
DbgREG()
Debug *pv