1、试题一 流水灯控制:开关 K1 向下按,从左至右依次点亮 8 个发光二极管;开关 K1 向上按, 8 个发光二极管从右至左依次点亮。 要求: 画出 8255相关的系统硬件电路; 写出相应的汇编程序。 ORG 1000H CODE SEGMENT ASSUME CS:CODE START: MOV AL,82H ;A 组方式 0, A口输出, B组方式 0输入 MOV DX,0FF2BH OUT DX,AL ;8255初始化 MOV DX,0FF29H ;读 B 口状态 IN AL,DX TEST AL,01H JNZ NEXT1 MOV AL,FEH MOV DX,0FF28H NEXT: O
2、UT DX,AL ;点亮 L1 CALL DELAY ROL AL,01H JMP NEXT MOV AL,07FH MOV DX,0FF28H NEXT1: OUT DX,AL 点亮 L7 CALL DELAY ROR AL,01H JMP NEXT1 JMP START DELAY PROC PUSH CX MOV CX,01FFFH D: LOOP D POP CX RET DELAY ENDP CODE ENDS END START 试题二 液晶显示:在 LCD液晶显示屏上显示自己的姓名。 要求: 画出流程图; 写出相应的汇编程序。 code segment assume cs:cod
3、e org 1000h start:jmp start3 tab DB 00H 00H 3FH F8H 21H 08H 21H 08H 2FH E8H 21H 08H 21H 08H 3FH F8H; DB 20H 08H 27H C8H 24H 48H 24H 48H 27H C8H 40H 08H 40H 28H 80H 10H;“周 “,0 DB 00H 00H 00H FCH 7CH 84H 44H 84H 44H 84H 44H FCH 7CH 84H 44H 84H; DB 44H 84H 44H FCH 7CH 84H 44H 84H 01H 04H 01H 04H 02H 14
4、H 04H 08H;“明 “,1 start3: mov dx,0ff2bh mov al,80h out dx,al lea si,tab mov dx,0ff2ah mov al,30h out dx,al mov dx,0ff28h mov al,00111111b out dx,al call late mov dx,0ff2ah mov al,10h out dx,al mov dx,0ff28h mov al,11000000b out dx,al call late mov ch,4 mov bl,10111000b start0:mov cl,32 mov dx,0ff2ah
5、mov al,10h out dx,al mov dx,0ff28h mov al,bl out dx,al call late mov dx,0ff28h mov al,01000000b out dx,al call late start1:mov dx,0ff2ah mov al,11h out dx,al mov al,si mov dx,0ff28h out dx,al call late inc si dec cl cmp cl,00h jnz start1 inc bl dec ch cmp ch,00h jnz start0 jmp $ late: mov dx,0ff2bh
6、mov al,05h out dx,al mov al,04h out dx,al ret code ends end start DATA SEGMENT ORG 1000H ;- 文字 : 陈 - ;- 宋体 12; 此字体下对应的点阵为:宽 x 高 =16x16 - DATA1 DB 00H,02H,02H,02H,02H,41H,02H,81H,0F2H,7FH,8AH,00H,46H,04H,00H,03H DB 0E0H,40H,00H,80H,0FFH,7FH,00H,00H,20H,00H,0C0H,00H,00H,07H,00H,00H ;- 文字 : 沁 - ;- 宋体 1
7、2; 此字体下对应的点阵为:宽 x 高 =16x16 - DATA2 DB 40H,20H,44H,12H,54H,4AH,65H,82H,0C6H,7FH,64H,02H,54H,0AH,44H,92H DB 00H,60H,0FCH,1FH,44H,00H,44H,00H,0C4H,0FFH,42H,00H,40H,00H,00H,00H DATA3 DB 02H,00H,02H,00H,0F2H,0FFH,12H,01H,12H,46H,12H,80H,0F2H,7FH,02H,00H DB 0F2H,0FFH,12H,01H,12H,46H,12H,80H,0F2H,7FH,02H,0
8、0H,02H,00H,00H,00H DATA ENDS ; CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX ;8255 初始化 MOVDX,0FF2BH MOVAL,10000000B OUT DX,AL ;选全屏 MOVDX,0FF2BH MOVAL,00001001B ;CS1-1 OUT DX,AL MOVAL,00001011B ;CS2-1 OUT DX,AL ;开显示 MOVAL,00000000B ;RS-0 OUT DX,AL MOVAL,00000010B ;R/W-0 OUT DX,AL M
9、OVDX,0FF28H ;A MOVAL,00111111B OUT DX,AL ;E 下降沿 MOVDX,0FF2BH MOVAL,00000101B OUT DX,AL MOVAL,00000100B OUT DX,AL ;选左屏 MOVAL,00001001B ;CS1-1 OUT DX,AL MOVAL,00001010B ;CS2-0 OUT DX,AL ;设置行 MOV AL,00000000B ;RS-0 OUT DX,AL MOV AL,00000010B ;R/W-0 OUT DX,AL MOV DX,0FF28H ;A MOV AL,11000000B OUT DX,AL
10、;E 下降沿 MOV DX,0FF2BH MOV AL,00000101B OUT DX,AL MOV AL,00000100B OUT DX,AL ;设置页 MOV AL,00000000B ;RS-0 OUT DX,AL MOV AL,00000010B ;R/W-0 OUT DX,AL MOV BL,10111000B MOV DX,0FF28H ;A MOV AL,10111000B OUT DX,AL ;E 下降沿 MOV DX,0FF2BH MOV AL,00000101B OUT DX,AL MOV AL,00000100B OUT DX,AL ;设置列 LEA SI, DATA
11、1 MOV DI,6 LEI: MOV DX,0FF2BH MOVAL,00000000B ;RS-0 OUT DX,AL MOV AL,00000010B ;R/W-0 OUT DX,AL MOV DX,0FF28H MOV AL,01000000B ;A OUT DX,AL ;E 下降沿 MOV DX,0FF2BH MOV AL,00000101B OUT DX,AL MOVAL,00000100B OUT DX,AL ;输出数 MOV CX,16 SHURU: MOVAL,00000001B ;RS-1 OUT DX,AL MOVAL,00000010B ;R/W-0 OUT DX,AL ;SI-A MOVDX,0FF28H ;逐字显示 MOVAL,SI OUT DX,AL ;E 下降沿 MOVDX,0FF2BH MOVAL,00000101B OUT DX,AL MOVAL,00000100B OUT DX,AL INC SI