Experiment 4
Experiment 4
Experiment 4
Submitted by Submitted to
4.2 Objectives
1. To know how to PUSH and POP instruction work
2. To do the all arithmetic operations using PROCEDURE in same program.
4.3 Theory
PUSH Instruction:
To add a new word to the stack, we PUSH it on, The syntax iş,
𝑃𝑈𝑆𝐻 𝑆𝑜𝑢𝑟𝑐𝑒
Where source is a 16-bit register or memory word. For example,
𝑃𝑈𝑆𝐻 𝐴𝑋
Execution of PUSH causes the following to happen:
1. SP is decreased by 2.
2. A copy of the source content is moved to the address specified by SS:SP. The source
is unchanged.
POP Instruction:
To remove the top item from the stack, we POP it. The syntax is
𝑃𝑂𝑃 𝐷𝑒𝑠𝑡𝑖𝑛𝑎𝑡𝑖𝑜𝑛
where destination is a 16-bit register (except IP) or memory word. For example,
𝑃𝑂𝑃 𝐵𝑋
Executing of POP causes this to happen:
1. The content of SS:SP (the top of the stack) is moved to the destination.
2. SP is increased by 2.
ADD1 PROC
; Perform addition
MOV AX, 345H ; Load 345H into AX
MOV BX, 30H ; Load 30H into BX
ADD AX, BX ; Add AX and BX, store result in AX
RET ; Return
ADD1 ENDP
SUB1 PROC
; Perform subtraction
MOV AX, 345H ; Load 345H into AX
MOV BX, 30H ; Load 30H into BX
SUB AX, BX ; Subtract BX from AX, store result in AX
RET ; Return
SUB1 ENDP
MUL1 PROC
; Perform multiplication
MOV AX, 345H ; Load 345H into AX
MOV BX, 30H ; Load 30H into BX
MUL BX ; Multiply AX and BX, store result in AX
RET ; Return
MUL1 ENDP
DIV1 PROC
; Perform division
MOV AX, 345H ; Load 345H into AX
MOV BX, 30H ; Load 30H into BX
DIV BX ; Divide AX by BX, store quotient in AX
RET ; Return
DIV1 ENDP
4.7 Discussion and Conclusion
The objective of this experiment was to gain a comprehensive understanding of PUSH and
POP operations. The PUSH instruction was employed to transfer data from the AX register
to the stack, while the POP instruction facilitated the retrieval of data from the stack to the
BX register. The memory location of the stack segment was meticulously observed, and it
was found to align precisely with the theoretical expectations.In conclusion, this
experiment was conducted successfully, and the objectives were met with exemplary
results, further enhancing our comprehension of these fundamental assembly language
operations.