NSIs stack push and pop usage details)

Source: Internet
Author: User
Tags stack pop

/*
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 */

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.