It is possible in PowerBASIC to write your own procedure within an existing Sub, Function, Method, or Property by manually coding the stack entry and exit. This is a complicated area of assembler coding where it is very easy to crash the entire operating system if the code is not written correctly. For example:
! CALL procname
' Other PowerBASIC code here
! JMP label ; Jump over the procedure
procname:
! PUSH EBP ; Preserve base pointer
! MOV EBP, ESP ; Stack pointer into EBP
' Write your assembler code here
! MOV ESP, EBP ; Restore stack pointer
! POP EBP ; Restore base pointer
! RET
label:
...
' Other PowerBASIC code here
There are other methods of preserving both ESP and EBP depending on personal taste and calling conventions, but you must save and restore the states of both registers if you choose to use a procedure of this type. It is very important to note that ESP and EBP must always be preserved if they are to be altered, regardless of relative position of Inline Assembler code to BASIC statements.
See Also
Saving Registers at the Procedure level