Assembly Language Stack and Subroutines
Assembly Language Stack and Subroutines
- Read the following program and answer the questions given below:
1 LXI SP, 0400H
2 LXI B, 2055H
3 LXI H, 22FFH
4 LXI D, 2090H
5 PUSH H
6 PUSH B
7 MOV A, L
….
20 POP H
- What is stored in the stack pointer register after the execution of Line 1?
- What is the memory location of the stack where the first byte is stored?
- What is stored in memory location 03FEH when line 5 (PUSH H) is executed?
- After the execution of line 6 (PUSH B), what is the address in the stack pointer register, and what is stored in stack memory location 03FDH?
- Specify the contents of register pair HL after the execution of line 20 (POP H).
- Write a program to add the two Hex numbers 7A and 46 and to store the sum at memory location XX98H and the flag status at location xx97H
- Write a program to meet the following specifications:
- Initialize the stack pointer register at XX99H
- Clear the memory locations starting from XX90H to XX9FH
- Load register pairs, B, D, and H with data 0237H, 1242H, and 4087H, respectively
- Push the contents of the register pairs B, D, and H on the stack
- Execute the program and verify the memory locations from XX90H to XX9FH
- The following program has a subroutine located at location 2060H. Read the program and answer the questions given at the end of the program
2000 LXI SP, 20CDH
2003 LXI H, 0008H
2006 MVI B, 0fH
2008 CALL 2060H
200B OUT 01H
…. ……
…… ……
2060 PUSH H
2061 PUSH B
MVI B, 05H
LXI H, count
…. ……
POP B
POP H
RET
- When the execution of the CALL instruction located at 2008H-200AH is completed, list the contents stored at 20CCH and 20CBH, the contents of the program counter and the contents of the stack pointer register
- List the stack locations and their contents after the execution of the instructions PUSH H and PUSH B in the subroutine
- List the contents of the stack pointer register after the execution of the PUSH B located at 2061H
- List the contents of the stack pointer register after the execution of the RET instruction
