首页 > 解决方案 > RTC 只发送一次中断信号

问题描述

我对 RTC + CMOS(实时时钟)有一个小问题,更准确地说是摩托罗拉 MC146818A。程序执行的任务是以等于 1 秒的固定时间间隔显示字母“A”。所以我正确设置了寄存器A和寄存器B的位,事实是我截取的子程序只激活了一次,我不明白为什么。这是代码:

这是函数的模块:

_text SEGMENT PARA PUBLIC 
    
  farjmp  09C0h, _start

  times    db     0h 

 mount_rtc_subroutine PROC NEAR 

    push    ax
    push    es 

    xor     ax, ax 
    mov     es, ax 

    ;I mask the line of break n0 of the slave PIC
    in      al, 0A1h 
    or      al, 01h 
    out     0A1h, al

    ;memorize in the IVT the SEG: OFF components of the 
    ;first instruction of my service subroutine
    mov     WORD PTR es:[1C0h], _rtc_subroutine 
    mov     WORD PTR es:[1C2h], 09C0h 

    mov     al, 0Ah 
    out     70h, al 
    mov     al, 2Fh 
    out     71h, al

    mov     al, 0Bh 
    out     70h, al 
    mov     al,  42h 
    out     71h, al 

    ;active the break line n0 of the slave PIC 
    in      al, 0A1h 
    and     al, 0FEh
    out     0A1h, al

    pop     es 
    pop     ax 
    ret

 mount_rtc_subroutine ENDP 

_rtc_subroutine:
   push    ax
   push    bx

   mov     bx, OFFSET times 

   cmp     BYTE PTR [bx], 0h 
   jne     _write

   inc    BYTE PTR [bx]
   jmp     _EOI 

   _write: mov     ax, 0F41h 
           stosw
           mov    WORD PTR [bx], 0h

   _EOI: mov     al, 20h 
         out     0A0h, al 
         out     20h, al 

   pop     bx
   pop     ax
   iret    

_text ENDS 

主要模块:

farjmp MACRO segm, off

   db  0EAh
   dw  off
   dw  segm

ENDM 

INCLUDE rtc_sub

_text SEGMENT PARA PUBLIC 

_start:
    mov    ax, 09C0h  
    mov    ds, ax 
    mov    ss, ax
    mov    sp, 0FFFFh 
    mov    ax, 0B800h
    mov    es, ax 

    call   mount_rtc_subroutine

    jmp $

_text ENDS 
     END _start

我没有发现任何问题,但仍然存在。你认为是什么问题?

标签: assemblyx86x86-16masm

解决方案


问题是在服务子程序结束时读取RTC的寄存器C失败,这样RTC就不允许发送任何隐蔽的中断信号,导致中断管理器没有被激活。

添加此说明:

mov  al, 0Ch
out  70h, al
in   al, 71h

推荐阅读