Using registers and stacks for input/output
Guys, I have a fundamental question about using stacks and registers. I will give a simple example.
I have a function that takes no arguments and returns a status of 1 or 0 in $R0
Inside this function, I am going to use
2 registers, $R1, $R2 (So I push them on stack, so that
my caller does not get messed up should he be using the
same registers)
Now I want to return the vaule in $R0 to the caller.
So should I be calling Exch on $R0 first thing in the code. Here is what I think my code should be:
Function MyFunction
Exch $R0
Push $R1
Push $R2
;Use $R1, $R2 etc.
;Now put the value in $R0
StrCpy $R0 "whatever"
Pop $R2 ;In reverse order
Pop $R1
Exch $R0 ; Is that correct?
FunctionEnd
Also, if I call another function MyFunction2, which takes, e.g. a single input,
I could use any of $R1, $R2 by pushing it on stack again ? Does that make sense?