我必须使用(主要)16位汇编语言创建一个类似于屏幕的矩阵,我们必须能够让键盘和鼠标都使用中断来结束程序。我已经让鼠标中断工作,但键盘似乎没有工作。怎么了?
.model small
.486
.stack 100h
.data
seed DWORD 12345678h
X DW 0
Y dW 0
V db 0
.code
MyInt proc
CLI
mov ah,0
mov al, V
int 10h
mov ax, 4C00h
int 21h
STI
iret
MyInt endp
getRand PROC
call LongRandom
mov dx,0
mov cx,80
div cx
mov si,dx
mov ax,si
add si,ax
ret
getRand endp
Move proc
mov bx,si
add bx,3680
shft:
mov ax, es:[bx]
add bx,160
mov es:[bx],ax
sub bx,320
cmp bx,si
jge shft
ret
MOve endp
LongRandom proc
mov eax,343FDh
mul seed
XOR edx,edx
add eax, 269EC3h
mov seed, eax
ret
LongRandom ENDP
Busywait proc
mov ecx, 07FFFFFFh
L2: dec ecx
cmp ecx,1
jge L2
ret
Busywait endp
Create proc
call Longrandom
push ax
mov dx,0
mov cx,5
div cx
pop ax
cmp dx,4
jne T2
cmp al,38h
je T4
jmp T5
T4: mov ah,00000101b
mov es:[si],ax
jmp T3
T5: mov ah,00001010b
mov es:[si],ax
jmp T3
T2: mov dx,20h
mov es:[si],dx
T3: ret
create endp
main proc
mov ax, @data
mov ds, ax
mov ah,0Fh
int 10h
mov V,al
mov ax, 0B800h
mov es, ax
; Here is the bulk of my interrupts.
mov ah,0
mov al,3
int 10h
push ds
mov ax,@code
mov ds,ax
mov ah,25
mov al,9
mov dx, offset myInt
int 21h
pop ds
mov ax,3
int 33h
mov X, cx
mov Y, dx
; This is the end of the interrupts (I believe).
L1: cmp x,cx
jne exit
cmp y,dx
jne exit
cmp bx,0
jne exit
push bx
push cx
push dx
call getRand
call Move
call Busywait
call create
pop dx
pop cx
pop bx
mov ax,3
int 33h
jmp L1
exit:
mov ah,0
mov al, V
int 10h
mov ax, 4C00H
int 21h
main endp
end main
以下是我在L1
循环中添加中断的尝试:
pop dx
pop cx
pop bx
mov ax,3
int 33h
mov al,9
; mov dx, offset myInt ?
int 21h
这可以解决这个问题吗?