Solutions to Exam 1
| | 68 + 57 | C5 + 7B | 23 + 4E | D3 + A4 | 00 - 6D |
| Answer | BF | 40 | 71 | 77 | 93 |
| Carry (Borrow) | No | Yes | No | Yes | Yes |
| Overflow | Yes | No | No | Yes | No |
| 0 1 2 3 4 5 6 7 8 9 A B C D E F
-----|---------------------------------------------------------------
0000 | 14 00 B7 23 B4 18 30 18 8F FE 22 02 5C E7 03 26
0010 | 0F CC 0D 10 8E 01 FF DE 20 EC 02 BD 00 1E 3C 96
0020 | 00 08 1A 94 10 18 38 39 A2 38 9A 05 F2 20 A5 ED
Show what will be in the registers (in hex) after each of the instructions.
If the instruction does not change a register, you may leave that entry blank.
| Instruction | A | B | D | X | Y | SP | Addressing Mode |
| 00 | 00 | 0000 | 0000 | 0000 | 0000 | ||
| lds #0x1ff | 01FF | IMM | |||||
| ldx 0x0020 | 0008 | EXT | |||||
| ldd 02,x | 22 | 02 | 2202 | IND | |||
| jsr 0x011e | 01FD | EXT | |||||
| pshx | 01FB | INH | |||||
| ldaa *0x002c | F2 | F202 | DIR | ||||
| ldab #0x1a | 1A | F21A | IMM | ||||
| anda 0x0010 | 02 | 021A | EXT | ||||
| puly | 0008 | 01FD | INH | ||||
| rts | 01FF | INH |
1 ;
2 .title EE 308 Exam 1
0004 3 LEN = 0x04
4
5 .area DATA (ABS)
6 .org 0x20
0020 0A (a) 7 val1: .db 10
0021 C2 00 8 val2: .dw 0xc200
0023 F0 9 .db 0b11110000
0024 10 table: .ds LEN
0028 (b) F6 (c) 11 count: .db -10
12
13 .area CODE (ABS)
14 .org 0x0100
0100 DE 21 (d) 15 start: ldx *val2
0102 CC (e) 33 44 16 ldd #0x3344
0105 5C 17 incb
0106 E7 04 (f) 18 stab LEN,x
0108 (g) 96 23 (h) 19 ldaa *(val2+2)
010A B7 (i) 00 24 20 staa table
010D 7C 00 28 21 inc count (j)
0110 3F 22 last: swi
ASxxxx Assembler V01.50 (Motorola 6811), page 1.
EE 308 Exam 1
Symbol Table
LEN = 0004
1 count 0028
2 last 0110 (k)
2 start 0100
1 table (l) 0024
1 val1 0020
1 val2 0021
(a) 0A (b) 0028 (c) F6 (d) 21
(e) CC (f) E7 04 (g) 0108 (h) 23
(i) B7 (j) count (k) 0110 (l) table
Here is a flowchart:
Here is a program to implement the flowchart:
PORTB = 0x1004
PORTC = 0x1003
PROG = 0x0100
STACK = 0x01ff
SET_POINT = 72
;
.area CODE (ABS)
.org PROG
lds #STACK ;load stack pointer
loop: jsr control_temp ;execute temp control routine
bra loop ;repeat
control_temp: psha ;save ACC A
ldaa PORTC ;read Port C
cmpa #SET_POINT ;compare to set point
blo heat_on ;too cold; turn heat on
heat_off: ldaa PORTB ;too hot, turn heat off
anda #0b11110111 ;clear bit 3 of Port B
staa PORTB
bra done ;
heat_on: ldaa PORTB ;turn heat on
oraa #0b00001000 ;set bit 3 of Port B
staa PORTB
done: pula ;restore ACC A
rts ;all done