简体   繁体   中英

Assembly - modifying stack contents

How do I modify stack memory chunk in assembly?

I thought of one way, which is:

POP EAX
ADD EAX, 5
PUSH EAX

Is there a shorter more efficient way of doing this?

You can address the value on the stack directly with a memory operand, as in

add dword [esp], 5

or

add qword [rsp], 5

if you are targeting 64 bit; in 16 bit mode, instead, sp -based addressing is not available .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM