问题– 8255与8085微处理器接口,并编写一个汇编程序,该程序确定端口A和端口B内容的相加并将结果存储在端口C中。
例子 –
算法 –
- 构造控制字寄存器
- 从端口A和端口B输入数据
- 添加端口A和端口B的内容
- 在端口C中显示结果
程序 –
Mnemonics | Comments | ||
---|---|---|---|
MVI A, 90 | A ← 92 | ||
OUT 83 | Control Register ← A | ||
IN 80 | A ← Port A; | ||
MOV B, A | B ← A; | ||
IN 81 | A ← Port B; | ||
ADD B | A ← A+B; | OUT 82 | Port C ← A |
RET | Return |
解释 –
- MVI A,92表示控制寄存器的值为92。
D7=1 as it is in I/O mode. D6=0 & D5=0 as Poet A is in m0 mode. D4=1 as Port A is taking input. D3=0 & D0=0 as Port C is not taking part. D2=0 as mode of Port B is m0. D1=1as Port B is taking the input.
- OUT 83将A的值放入端口控制寄存器的端口号83H中。
- IN 80从80H输入,这是端口A的端口号。
- MOV B,A将A寄存器的内容复制到B寄存器。
- IN 81接受输入feom 81H,它是端口B的端口号。
- ADD B将A寄存器和B寄存器的内容相加。
- OUT 82在81H中显示结果,它是端口C的端口号。
- RET回报