Archive: Use of Registers


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?


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.


Thanks, sir, appreciate your help


Thank your sir, for your prompt reply


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?


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 :)


Thank you, appreciate your help