/*
Compilation: ansifa
NSIs not only provides the variable $0 ~ $9, $ R0 ~ $ R9 is used to store text and stacks,
Some numbers or characters can be temporarily stored in the stack through the push and pop stack operations.
The following is a simple example:
The implementation function is to protect the value of a variable.
*/
Setcompressor/solid lzma
Setcompress force
Xpstyle on
OUTFILE "AAA. EXE"
Name "AAA"
Section
Strcpy $0 10; assign 10 to $0
MessageBox mb_ OK '"$0-the value is assigned "'
Push $0; push 10 to the stack
Strcpy $0 5
MessageBox mb_ OK '"$0-the value is" strcpy $0 5 "assigned. The 10 variable $0 has already overwritten "'
Pop $0; pop the number of stacks (10) to $0.
MessageBox mb_ OK '"$0-this is the stack pop-up "'
Sectionend
/*
Okay. I have read the example. What does it mean to protect the value of the variable?
The $0 value is an unknown number X and X, and is set to the original state,
However, you may want to use the $0 variable for some reasons,
However, the $0 x may be used later, so before starting to use $0, put $0 with push $0 into the stack.
Pop $0 after use, so that $0 remains unchanged before and after use.
$0 = 'aaa' ---- this is the original state
... ---- MiddleCode
Push $0 ---- start to use $0 and change its value
Strcpy $0 5 --- now changed $0. If no Pushpop is available, the previous 'aaa' will definitely not be found.
...... ---- Intermediate code
Pop $0 ---- restore the original value after $0 is used.
At this time, $0 is like a temporary call without the above. It continues the original state.
MessageBox mb_ OK '$ 0' ---- display 'aaa'
...... ---- Intermediate code */