Naked STRPTR in assembler :)
MACRO Sptr( pString, retPtr)
! push ebx
! lea ebx, pString
! mov edi, dword ptr [ebx]
! pop ebx
! mov retPtr, edi
END MACRO
...
LOCAL s AS STRING, R AS DWORD
S = "STRPTR"
SPTR (S,R)
? STR$(R)
Using stackless function may replace macro and increase readability of the code.
Hi Aslan
This can be simplified to
MACRO Sptr( pString, retPtr)
! mov eax,pString
! mov retPtr,eax
END MACRO
Charles
and this is really short.
Nice!
While I have not peeked into PB compiled code, I believe VARPTR() and STRPTR() are not functions but generate inline instructions.
A simple VARPTR translates to
lea eax,var
whereas STRPTR becomes
mov eax,var
Then assigning the result to a local variable would be something like:
mov [ebp-8],eax
Charles
That would be true for pure scalar variables. But that couldn't account for variables which require multiple operations to locate. Arrays, pointer targets, Threaded, Instance...
Bob Zale
PowerBASIC Inc.