CGuts350 2023-12-07 23:32 采纳率: 33.3%
浏览 18
已结题

汇编语言/8086,I/O译码电路哪里有问题

这个电路哪里有问题,I/O译码出的信号有问题但是找不出来。代码如下

A8255 EQU  0000H
B8255 EQU  0002H
C8255 EQU  0004H
CTR8255 EQU  0006H

CH0 EQU  0200H
CTR8253 EQU  0206H

AD245 EQU  0100H       ;     74LS245地址

CODE SEGMENT  'CODE'
    ASSUME DS:DATA,CS:CODE,SS:SSEG
START:MOV  AX,SSEG
       MOV SS,AX
       MOV  AX,TOP
       MOV  SP,AX
       MOV  AX,DATA
       MOV  DS,AX
         
       CLI
       MOV  AX,0
       MOV  ES,AX
       MOV  BX,2*4
       MOV  AX,OFFSET  INTR_KEY
       MOV WORD PTR  ES:[BX],AX
       MOV  AX,SEG INTR_KEY
       MOV WORD PTR  ES:[BX+2],AX

       STI

       MOV AX,DATA
       MOV ES,AX

       MOV AL,89H
       MOV DX,CTR8255
       OUT DX,AL
RUN:
       CALL RUNNING
       JMP RUN

INTR_KEY PROC
       PUSH AX
       PUSH BX
       PUSHF
       CALL KEY
       TEST AL,01H
       JZ K1
       TEST AL,02H
       JZ K2
       TEST AL,04H
       JZ K3
K1:    MOV KEYST,1
       JMP FIN
K2:    MOV KEYST,2
       INC PAUSEKEY
       JMP FIN
K3:    MOV KEYST,3
       JMP FIN
FIN:   POPF
       POP BX
       POP AX
       IRET
INTR_KEY ENDP

RUNNING PROC
AGAIN:    CMP KEYST,1
    JZ T1
    CMP KEYST,2
    JZ T2
    CMP KEYST,3
    JZ T3
    JMP E0
T1:    CALL TIME
    JMP E0
T2:    TEST PAUSEKEY,1
    JZ T1
    JMP E0
T3:    CALL RESET
E0:    CALL DISP
    RET
RUNNING ENDP

TIME PROC
    PUSH AX
    PUSH SI
    LEA SI,TIMEBUF
    MOV AX,[SI]
    INC AH
    CMP AH,100
    JZ S1
    MOV [SI],AH
    JMP S5
S1:MOV AH,0
   MOV [SI],AH
   MOV AH,[SI+1]
   INC AH
   CMP AH,60
   JZ S2
   MOV [SI+1],AH
   JMP S5
S2:MOV AH,0
   MOV [SI+1],AH
   MOV AH,[SI+2]
   INC AH
   CMP AH,60
   JZ S3
   MOV [SI+2],AH
   JMP S5
S3:MOV AH,0
   MOV [SI+2],AH
   MOV AH,[SI+3]
   INC AH
   CMP AH,24
   JZ S4
   MOV [SI+3],AH
   JMP S5
S4:MOV AL,0
   LEA DI,TIMEBUF
   MOV CX,4
   CLD
   REP STOSB
   
S5:CALL DIGIT
   CALL DELAY8253
   POP SI
   POP AX
   RET
TIME ENDP

DIGIT PROC
   PUSH AX
   PUSH BX
   PUSH CX
   PUSH SI
   PUSH DI
   MOV BL,4
   LEA DI,LEDBUF
   LEA SI,TIMEBUF
NEXT:LODSB
   MOV AH,0
   MOV CL,10
   DIV CL
   XCHG AH,AL
   STOSB
   MOV AL,AH
   STOSB
   DEC BL
   JNZ NEXT
   POP DI
   POP SI
   POP CX
   POP BX
   POP AX
   RET
DIGIT ENDP

DISP PROC
   PUSH AX
   PUSH BX
   PUSH CX
   PUSH DX
   PUSH SI
   LEA BX,LEDTAB
   LEA SI,LEDBUF
   MOV CX,8
   MOV AH,7FH
LOOP1:
   MOV AL,[SI]
   XLAT
   MOV DX,A8255
   OUT DX,AL
   MOV AL,AH
   MOV DX,B8255
   OUT DX,AL
   CALL DELAY
   ROR AH,1
   INC SI
   CALL CLRLED
   LOOP LOOP1
   POP SI
   POP DX
   POP CX
   POP BX
   POP AX
   RET
DISP ENDP

CLRLED PROC
   PUSH AX
   PUSH DX
   MOV AL,0FFH
   MOV DX,B8255
   OUT DX,AL
   POP DX
   POP AX
   RET
CLRLED ENDP

DELAY8253 PROC
   PUSH AX
   PUSH DX
   MOV DX,CTR8253
   MOV AL,10H;计数器0方式0
   OUT DX,AL
   MOV DX,CH0
   MOV AX,100;1600
   OUT DX,AL

   MOV AL,AH
   OUT DX,AL
   MOV DX,AD245
W1:   IN AL,DX
   TEST AL,01H
   JZ W1
   POP DX
   POP AX
   RET
DELAY8253 ENDP

DELAY PROC
    PUSH CX
    MOV CX,50
WAIT1:    LOOP WAIT1
    POP CX
    RET
DELAY ENDP

RESET PROC
   PUSH AX
   PUSH CX
   PUSH DI
   MOV AL,0
   LEA DI,TIMEBUF
   MOV CX,13
   CLD
   REP STOSB
   POP DI
   POP CX
   POP AX

   RET;;;


RESET ENDP

KEY PROC
    MOV DX,C8255
    IN AL,DX
    RET
KEY ENDP

CODE ENDS

DATA SEGMENT
  LEDTAB DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H
         DB 7FH,6FH,77H,7CH,39H,5EH,79H,71H
  TIMEBUF DB 0,0,0,0
  LEDBUF DB 0,0,0,0,0,0,0,0
  PAUSEKEY DB 0
  KEYST DB 0
DATA ENDS

SSEG SEGMENT PARA STACK 'STACK'
    SDAT DB 1000 DUP(?)
    TOP EQU LENGTH SDAT
SSEG ENDS
    END START

img

  • 写回答

2条回答 默认 最新

  • CGuts350 2023-12-08 13:52
    关注

    已经解决,

    img


    检查这个地方的总线,发现中间连了条细线,删除掉重新用总线连接就好了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 12月16日
  • 已采纳回答 12月8日
  • 创建了问题 12月7日

悬赏问题

  • ¥15 onlyoffice编辑完后立即下载,下载的不是最新编辑的文档
  • ¥15 求caverdock使用教程
  • ¥15 Coze智能助手搭建过程中的问题请教
  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决
  • ¥15 前端vue CryptoJS Aes CBC加密后端java解密
  • ¥15 python随机森林对两个excel表格读取,shap报错
  • ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
  • ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。