rajiv naravane
15th September 2006 20:35 UTC
Use of Registers
I have a general question about the usage of registers when I call a system function. To make it specific, here is a snipped of code:
;GetIndexName is my function that returns a string
; in $R0, so I pop it from $R0
Call GetIndexName
Pop $R0
; Asumme everything worked
;
;Now I copy this string to $1
StrCpy $1 $R0
;And pass it to WordFind library function,
;which gives me results in $0 (last argument)
${WordFind} $1 "-" "+1" $0
DetailPrint "After WordFind $0"
Here is the question: If WordFind function is internally using $R0, would the value I stored there originally get overwritten?
kichik
15th September 2006 21:14 UTC
Functions should and usually retain register values. It's done by keeping old values on the stack and popping them back when the function ends. All of the function in the header files, including WordFind do that. If they don't, it's a bug and you should report it.
rajiv naravane
15th September 2006 21:33 UTC
Thanks, sir, appreciate your help
rajiv naravane
15th September 2006 21:36 UTC
Thank your sir, for your prompt reply
rajiv naravane
15th September 2006 22:14 UTC
So what you are saying is, I do not have to worry about what registers these functions are using. They SHOULD do the right thing and when they retun, my old value in the register should be intact, right?
Animaether
16th September 2006 07:52 UTC
correct
and if they don't, report it as a bug to the author of the function / in the wiki page of the function / wherever is appropriate :)
rajiv naravane
16th September 2006 14:07 UTC
Thank you, appreciate your help