📄 3-8.asm
字号:
stack segment
db 256 dup(0)
top label word
stack ends
;****************************************************************************************
data segment
count dw 1
flag db 0
msg db 'The bell is mask!',0dh,0ah,'Enter any key to return',0ah,0dh,'$'
msg1 db 'The bell is ringing!',0dh,0ah,'$'
oldcsc dw ?
oldipc dw ?
oldcs9 dw ?
oldip9 dw ?
data ends
;******************************************************************************************
code segment
assume cs:code,ds:data,ss:stack
main proc far
start:
mov ax, stack
mov ss, ax
mov ax,data
mov ds,ax
begin:
mov ah,35h
mov al,09h
int 21h
mov oldcs9,es
mov oldip9,bx
push ds
mov dx, seg kbint
mov ds, dx
mov dx, offset kbint
mov al, 09h
mov ah, 25h
int 21h
pop ds
mov ah, 35h
mov al, 1ch
int 21h
mov oldipc, bx
mov oldcsc, es
push ds
mov dx, seg ring
mov ds, dx
mov dx, offset ring
mov al, 1ch
mov ah, 25h
int 21h
pop ds
in al,21h
and al,11111100b
out 21h,al
sti
mov cx,10
delay1:
mov di,08fffh
delay2:
mov si,0ffffh
delay3:
dec si
jnz delay3
dec di
jnz delay2
dec cx
jnz delay1
cli
push ds
mov dx, oldipc
mov ax, oldcsc
mov ds, ax
mov al, 1ch
mov ah, 25h
int 21h
pop ds
push ds
mov dx, oldip9
mov ax, oldcs9
mov ds, ax
mov al, 09h
mov ah, 25h
int 21h
pop ds
sti
mov ax,4c00h
int 21h
main endp
;....................................................................
ring proc near
push ds
push ax
push cx
push dx
mov ax,data
mov ds,ax
sti
dec count
jnz exit
mov dx,offset msg1
mov ah,09h
int 21h
mov dx,1000h
in al,61h
and al,0fch
sound:
xor al,02
out 61h,al
mov cx,8000h
wait1:
loop wait1
dec dx
jne sound
mov count,91
exit:
cli
pop dx
pop cx
pop ax
pop ds
sti
iret
ring endp
;..........................................................................
kbint proc far
push ax
in al,60h
push ax
in al,61h
or al,80h
out 61h,al
in al,61h
and al,7fh
out 61h,al
pop ax
test al,80h
jnz inkret
xor flag,1
cmp flag,1
je process1
process2:
in al,21h
and al,11111110b
out 21h,al
jmp inkret
process1:
in al,21h
or al,01h
out 21h,al
call display
mov al,20h
out 20h,al
sti
again:
cmp flag,1
je again
inkret:
mov al,20h
out 20h,al
sti
pop ax
iret
kbint endp
;.......................................................................................
display proc near
push dx
mov dx,offset msg
mov ah,09h
int 21h
pop dx
ret
display endp
;......................................................................................
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -