Midterm1 Sol
Midterm1 Sol
Midterm1 Sol
OSU ECE473/573
Winter 2002
Dr. Shiue
Name: __________________________________
1. (a) Assume the register A has packed BCD (59H), write a program to convert packed
BCD to two ASCII numbers and place them in R2 and R6. (hint: using ANL, ORL,
SWAP) and (b) make a “list file” consisting of line number, ROM locations, Opcodes,
and Instructions. (The program starts at 0000H) (20 points)
2. Read and test P1 to see whether it has the value A3H. If it does, clear 5 RAM locations
starting at RAM address 78H; otherwise, convert 23H to decimal. (20 points)
3. (a) Write a program to get the x value (ranging from 0 to 9) from P1 and send x2+x+1
to ACC continuously using indexed addressing mode, and (b) what is the state of the P
bit in the PSW after execution of each iteration. (20 points)
MC Bytes Opcodes
SUB: MOV R0, #20H 1 2 78H, 20H
Loop: MOV @R0, #0 1 2 76H, 00H
INC R0 1 1 08H
CJNE R0, #80H, Loop 2 3 B8H, 80H, FAH
RET 2 1 22H
Shown as above.
Shown as above.
(e) How long does this subroutine take to execute? (assume 12MHz operation)
5. Find the results at points (1), (2), and (3) in the following code (5 points)
MOV A, #-128
ADD A, #-2
MOV R1, A
MOV A, #-2
ADD A, #-5
MOV R2, A
MOV A, #7
ADD A, #18
MOV R3, A
7. Find the time delay for the delay subroutine shown below, if the system frequency is
12MHz. (10 points)
[Others]
Delay: MOV R1, #100
Back: MOV R2, #200
Again: MOV R3, #300
Here: NOP 1+2=3
NOP
DJNZ R3, Here
DJNZ R2, Again
DJNZ R1, Back
RET