EE 308
Exam 1
February 13, 1998
|
Name: |
|
You may use any of the Motorola data books. No calculators allowed. Show all work. Partial credit will be given. No credit will be given if an answer appears with no supporting work.
|
(a) |
|
ACCA |
N |
Z |
V |
C |
|
ldaa #0x7c |
7c |
0 |
0 |
0 |
0 |
|
|
adaa #0x84 |
00 |
0 |
1 |
0 |
1 |
|
(b) |
|
ACCA |
N |
Z |
V |
C |
|
ldaa #0xa7 |
a7 |
1 |
0 |
0 |
0 |
|
|
adaa #0x95 |
3c |
0 |
0 |
1 |
1 |
|
(c) |
|
ACCA |
N |
Z |
V |
C |
|
ldaa #0x3e |
3e |
0 |
0 |
0 |
0 |
|
|
adaa #0x6d |
ab |
1 |
0 |
1 |
0 |
|
(d) |
|
ACCA |
N |
Z |
V |
C |
|
ldaa #0x6e |
6e |
0 |
0 |
0 |
0 |
|
|
suba #0x92 |
dc |
1 |
0 |
1 |
1 |
|
(e) |
|
ACCA |
N |
Z |
V |
C |
|
ldaa #0x00 |
00 |
0 |
1 |
0 |
0 |
|
|
suba #0x92 |
6e |
0 |
0 |
0 |
1 |
|
Hex |
Unsigned Decimal |
Signed Decimal |
|
|
(a) |
27 |
39 |
39 |
|
(b) |
AC |
172 |
-84 |
|
(d) |
7F |
127 |
127 |
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
|
|
0100 |
8E |
01 |
2F |
CE |
00 |
10 |
DC |
23 |
3C |
BD |
01 |
1A |
38 |
20 |
F4 |
DE |
|
0110 |
20 |
EC |
02 |
BD |
01 |
1E |
96 |
2C |
C6 |
1A |
94 |
10 |
8B |
0C |
88 |
AA |
|
0120 |
39 |
FE |
12 |
34 |
CC |
33 |
44 |
5C |
E7 |
0A |
B6 |
FF |
E2 |
B7 |
E0 |
15 |
|
Starting Address |
Op Code |
Operand |
Addressing Mode |
|
|
0x0100 |
lds |
#0x012F |
IMM |
|
|
(a) |
0x0103 |
ldx |
#0x0010 |
IMM |
|
(b) |
0x0106 |
ldd |
*0x23 |
DIR |
|
(c) |
0x0108 |
pshx |
INH |
|
|
(d) |
0x0109 |
jsr |
0x011A |
EXT |
|
(e) |
0x010C |
bra |
-12 |
REL |
|
(f) |
0x010D |
pulx |
INH |
|
|
0x010F |
ldx |
*0x20 |
DIR |
|
Instruction |
A |
B |
D |
X |
Y |
SP |
Cycles |
|
|
00 |
00 |
0000 |
0000 |
0000 |
0127 |
|||
|
(a) |
ldx #0x0125 |
0125 |
3 |
|||||
|
(b) |
ldd 0x0125 |
33 |
44 |
3344 |
5 |
|||
|
(c) |
addb 4,x |
4E |
334E |
4 |
||||
|
(d) |
eora #0x55 |
66 |
664E |
2 |
||||
|
(e) |
puly |
E70A |
0129 |
6 |
||||
|
(f) |
rts |
012B |
5 |
jsr 0x0125
Before the instruction is executed assume the program counter is 0x0100 and the stack pointer is 0x01FF.
The address of the next instruction (0x0103) will be pushed onto the stack – 0x03 will go into memory location 0x01FF, and 0x01 will go into memory location 0x01FE. The stack pointer will be decremented by two to 0x01FD. The program counter will be loaded with the new instruction address 0x0125.
START PROGRAM
IF K1 < K2
THEN PORTB = 0
ELSE PORTB = 127
ENDIF
END PROGRAM
Make sure this is a complete assembly language program – be sure to include
.org statements, etc. Make sure the program will be placed in the HC11’s RAM. K1 and K2 should be located at 0x1010 and 0x1012 respectively.Special things to look for: 16-bit registers should be used for K1 and K2. Branches should be done with unsigned instructions (e.g.,
blo or bhs).
One way:
K1 = 0x1010
K2 = 0x1012
PORTB = 0x1004
.area CODE (ABS)
.org 0x0100
ldx K1
cpx K2
blo l1
ldaa #127
staa PORTB
bra l2
l1: clr PORTB
l2: swi
Another way:
PORTB = 0x1004
.area CODE (ABS)
.org 0x0100
ldd K1
cpd K2
blo l1
ldaa #127
staa PORTB
bra l2
l1: clr PORTB
l2: swi
.area DATA (ABS)
.org 0x1010
K1 .ds 2
D2 .ds 2