【发布时间】:2019-11-29 17:18:35
【问题描述】:
我正在尝试编写一个汇编语言程序,它将:
- 使用中断,
- 当定时器中断 7 个滴答后在屏幕上打印“Hello world”字符串,并且
- 终止后继续居住。
我尝试使用中断在屏幕上打印字符串。如何实现计时器中断以在计数器中经过 7 个滴答时打印字符串,并使其在终止后驻留。
; program that will print a string by hooking timer interrupt
[org 0x0100]
jmp start
tickcount: dw 0
message: db 'Hello world'
printmsg: mov ah, 0x13 ; service 13 - print string
mov bl, 7 ; normal attribute
mov dx, 0x0100 ; row 1 column 0
mov cx, 11 ; length of string
push cs
pop es ; segment of string
mov bp, message ; offset of string
int 0x10 ; call BIOS video service
timer: push ax
inc word [cs:tickcount] ; increment tick count
push word [cs:tickcount]
call printmsg ; print string on 7 ticks
mov al, 0x20
out 0x20, al ; end of interrupt
pop ax
iret ; return from interrupt
start: xor ax, ax
mov es, ax ; point es to IVT base
cli ; disable interrupts
mov word[es:8*4], timer ; store offset at n*4
mov [es:8*4+2], cs ; store segment at n*4+2
sti ; enable interrupts
mov dx, start ; end of resident portion
add dx, 15 ; round up to next para
mov cl, 4
shr dx, cl ; number of paras
mov ax, 0x3100 ; terminate and stay resident
int 0x21
执行时,程序不会在屏幕上显示字符串并且光标会冻结。
【问题讨论】:
-
这是你必须在时钟滴答数等于你的身份证最后一位数字后打印你的学生证的作业吗?
-
是的,我已经解决了。 :)
标签: assembly timer dos interrupt x86-16