Analysis of Checkpoint 10.2 Answers in Assembly Language

“Assembly Language”, 3rd Edition by Wang Shuang

Chapter 10: CALL and RET Instructions

Checkpoint 10.2 (Page 192)

What is the value in ax after executing the following program?

Memory Address Machine Code Assembly Instruction

1000:0 b8 00 00 mov ax, 0

1000:3 e8 01 00 call s

1000:6 40 inc ax

1000:7 58 s: pop ax

————————-

Reference Answer

Analysis: In section 2.10 (Page 25 of the book) when discussing CS and IP, the instruction execution process is described: before executing after reading the instruction, the value of IP will increase (IP = IP + instruction length) to point to the next instruction. Therefore, before the execution of the call s instruction, the value of IP should be 6. When call is executed, the current IP is pushed onto the stack, which means the value 6 is pushed onto the stack, and then it jumps to the label s to execute. At this point, if pop is executed, it will pop the value 6 from the stack.

Based on the above analysis, the value of ax should be 6 , or written in hexadecimal as 0006H .

Leave a Comment