Analysis of Answer to Checkpoint 10.3 in Assembly Language

“Assembly Language”, 3rd Edition by Wang Shuang

Chapter 10: CALL and RET Instructions

Checkpoint 10.3 (Page 193)

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 9A 09 00 00 10 call far ptr s

1000:8 40 inc ax

1000:9 58 s: pop ax

add ax, ax

pop bx

add ax, bx

————————-

Reference Answer

Analysis Explanation: First, the instruction call far ptr s reads the buffer and before execution, the previous IP value is 0008H, and the CS value is 1000H (if unclear, refer to the analysis of Checkpoint 10.2).

Secondly, when executing call far ptr, the current CS and IP are pushed onto the stack, which means the values 1000H and 0008H are pushed onto the stack, and then it jumps to the label s to execute. At this point, popping will take 08H from the stack, and then popping will take 1000H from the stack.

Based on the above analysis, the value of ax after the instruction execution should be 08H + 08H + 1000H = 1010H .

Leave a Comment