perfectypf 发表于 2008-7-3 15:12

8253 8259A 定时产生中断的程序,有点问题。。。

cw8253        equ 43h   ;8253控制字端口
t08253        equ 40h                ;8253定时器0端口
num                 equ 2e9ch        ;11932=n=10ms*1.1932Mhz=10*1193.2
ou8259        equ 20h   ;8259A偶地址
ji8259        equ 21h                ;8259A奇地址

data        segment
second db ?
minute db ?
hour   db ?
countsec db 00h
SPACES DB "   ","$"
data        ends

code         segment
        assume cs:code,ds:data
       
start:  
                                mov ax,data
                                mov ds,ax
                               
                                cli                                                        
                                call init8253            ;初始化8253
                                                                 
                                push ds                  ;改中断服务程序地址
                                mov ax,seg interupt
                                mov ds,ax
                                lea dx,interupt
                                mov ah,25h
                                mov al,08h
;                          mov ax,2508h
                          int 21h
                          nop
                          nop        
                          pop ds  

        mov ah,02h
                                mov dl,'2'
                                int 21h
                                                               
;                                call init8259  ;初始化8259
                                sti

        mov ah,02h
                                mov dl,'2'
                                int 21h

l2:                        mov ah,06h                    ;直接控制台读写
                          mov dl,0ffh                   ;输入
                          int 21h
                          cmp al,' '                               
                                jnz l2             ;space key to quit loop
                                                                                               
                                mov ah,4ch
                                int 21h
                               
init8253 proc             ;///////initialize8253
                                mov bx,num                       
                                mov        al,36h         ;00110110 选择计数器0;先读低8位,后读高8位;方式3;二进制输入
                                out cw8253,al                                                ;将控制字36h输入控制字寄存器
                                mov        al,bl                                        ;计数值低字节9c
                                                                     ;计数器0端口
                                out t08253,al                        ;写入低字节
                                mov        al,bh                                        ;写高字节
                                out t08253,al                        ;///////
                                ret
init8253 endp

init8259 proc                                                  ;initialize8259A
                                mov al,00010011b        ;上升沿触发;不使用ICW3;使用ICW4
                                out ou8259,al                                        ;写入ICW1               
                                mov al,00001000b  ;IRQ0向量号 08h
                                out ji8259,al       ;写入ICW2
                                mov al,00000001b  ;普通全嵌套;非缓冲;正常结束;8086
                                out ji8259,al                                ;写入ICW4
                                mov al,11111110b  ;只开放IRQ0
                                out ji8259,al                                ;写入OCW1
                                ret
init8259 endp

interupt proc                                                               
                                mov ah,02h        ;输出1 调试。。
                                mov dl,'1'
                                int 21h  
                                 
              mov al,20h     ;发eoi
                                out 20h,al   
                                                                                                  
                    iret               
interupt endp
                                                                                   
code        ends
end start
               
哪位能帮忙调试下啊,好像在改中断向量的地方出问题了。。。
谢谢


页: [1]

编程论坛