(Adapted from 10.6) Rewrite the PUSH and POP routines such that the stack on which they operate
holds elements that take up two memory locations each.
The problem assumes that each element of the value being pushed on the stack is 32-bits.
For the PUSH, assume bits [15:0] of that value to be pushed are in R0 and bits [31:16] are in R1.
For the POP, bits [15:0] will be popped into R0 and bits [31:16] will be popped into R1.
Also assume the lower order bits of the number being pused or popped are located in the smaller
address in memroy. For example if the two memory locations to be used to store the number are
x2FFF and x2FFE, bits [15:0] will be stored in x2FFE and [31:16] will be stored in x2FFF.
PUSH:
ADD R6, R6, #-2
STR R0, R6, #0
STR R1, R6, #1
POP:
LDR R0, R6, #0
LDR R1, R6, #1
ADD R6, R6, #2
•
Consider the following LC-3 assembly language program. Assumming that the memory locations
DATA get filled before the program executes, what is the relationship between the final values at
DATA and the initial values at DATA?
.ORIG
x3000
LEA
R0, DATA
AND
R1, R1, #0
ADD
R1, R1, #9
LOOP1
ADD
R2, R0, #0
ADD
R3, R1, #0
LOOP2
JSR
SUB1
ADD
R4, R4, #0
BRzp
LABEL
JSR
SUB2
LABEL
ADD
R2, R2, #1
ADD
R3, R3, #-1
BRp
LOOP2
ADD
R1, R1, #-1
BRp
LOOP1
HALT
DATA
.BLKW
#10
SUB1
LDR
R5, R2, #0
NOT
R5, R5
ADD
R5, R5, #1
LDR
R6, R2, #1
ADD
R4, R5, R6
RET
SUB2
LDR
R4, R2, #0
LDR
R5, R2, #1
STR
R4, R2, #1
STR
R5, R2, #0
RET
.END
The final values at DATA will be sorted in ascending order.
•
During the initiation of the interrupt service routine, the N, Z, and P condition codes are saved on the