Preserving EBX register
Posted: Sun Apr 26, 2015 5:15 pm
I've got this procedure where I need an extra register besides eax, ecx and edx. ebx seems to be good for the task, but I can't seem to be able to preserve it. For example consider the following code:
If the push and pop parts are commented, the result comes out ok. What is the safe way to use ebx?
Code: Select all
Procedure myproc(bbb.l)
CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
!push rbx
CompilerElse
!push ebx
CompilerEndIf
;bbb + 1
!mov ebx, dword [p.v_bbb]
!inc ebx
!mov dword [p.v_bbb], ebx
CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
!pop rbx
CompilerElse
!pop ebx
CompilerEndIf
ProcedureReturn bbb
EndProcedure
n = myproc(5) ;should return 6
Debug n