|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这个实验我用了一个int 9ch中断,这个中断在测试每个选项的时候都是没等输入就进入选项了,但是测试综合选项的时候就没有反应。按什么都没有反应。
程序如下:
assume cs:code
stack segment
db 128 dup (0)
stack ends
code segment
start:
mov ax,stack
mov ss,ax
mov sp,128
push cs
pop ds
mov ax,0
mov es,ax
mov si,offset int9
mov di,204h
mov cx,offset int9end - offset int9
cld
rep movsb
push es:[9*4]
pop es:[200h]
push es:[9*4+2]
pop es:[202h]
cli
mov word ptr es:[9*4],204h
mov word ptr es:[9*4+2],0
sti
mov ax,4c00h
int 21h
int9:
push ax
push bx
push cx
push es
in al,60h
pushf
call dword ptr cs:[200h] ; 调用这个中断子程序
mov ah,al
; cmp ah,3
; ja sret
setscreen:
sub ah,01H
; mov al,02h
; mov ah,02h
cmp ah,0Ah ;比较,0的扫描码是0Bh,1~3是2~4,因为前面减1。
; cmp ah,0h
je do1
cmp ah,1
je do2
cmp ah,2
je do3
cmp ah,3
je do4
jmp short sret
do1:
call sub1
jmp short sret
do2:
call sub2
jmp short sret
do3:
call sub3
jmp short sret
do4:
call sub4
sret:
iret
;清屏
sub1:
push bx
push cx
push es
mov bx,0b800h
mov es,bx
mov bx,0
mov cx,2000
sub1s:
mov byte ptr es:[bx],' '
add bx,2
loop sub1s
pop es
pop cx
pop bx
ret ;sub1 ends
;设置前景色为绿色
sub2:
push bx
push cx
push es
mov bx,0b800h
mov es,bx
mov bx,1
mov cx,2000
sub2s: mov al,00000010b
and byte ptr es:[bx],11111000b
or es:[bx],al
add bx,2
loop sub2s
pop es
pop cx
pop bx
ret ;sub2 ends
;设置背景色为洋红色
sub3:
push bx
push cx
push es
mov cl,4
shl al,cl
mov bx,0b800h
mov es,bx
mov bx,1
mov cx,2000
sub3s: mov al,01010000b
and byte ptr es:[bx],10001111b
or es:[bx],al
add bx,2
loop sub3s
pop es
pop cx
pop bx
ret ; sub3 ends
;向上滚动一行
sub4:
push cx
push si
push di
push es
push ds
mov si,0b800h
mov es,si
mov ds,si
mov si,160
;
mov di,0
;
cld
mov cx,24;
sub4s:
push cx
mov cx,160
rep movsb ;传送
pop cx
loop sub4s
mov cx,80
mov si,0
sub4s1:
mov byte ptr es:[160*24+si],' '
;
add si,2
loop sub4s1
pop ds
pop es
pop di
pop si
pop cx
ret ;sub4 ends
int9ret:
pop es
pop cx
pop bx
pop ax
iret
int9end:
nop
code ends
end start
堆栈不平衡了,进入int9中断时push了那么多寄存器,中断返回时直接iret ???
还有,你能不能给标号取个有意义的名字?
do1 do2 do3 do4 sub1 sub2 sub3
do1是做什么的?
sub3呢?
后面我没看,现在只是中断能够正确返回
安装int9后,进入debug,按数字1 2 3 4屏幕背景会变化
assume cs:code
stack segment
db 128 dup (0)
stack ends
code segment
start:
mov ax, stack
mov ss, ax
mov sp, 128
push cs
pop ds
mov ax, 0
mov es, ax
mov si, offset int9
mov di, 204h
mov cx, offset int9end - offset int9
cld
rep movsb
push es:[9 * 4]
pop es:[200h]
push es:[9 * 4 + 2]
pop es:[202h]
cli
mov word ptr es:[9 * 4], 204h
mov word ptr es:[9 * 4 + 2], 0
sti
mov ax, 4c00h
int 21h
int9:
push ax
push bx
push cx
push es
in al, 60h
pushf
call dword ptr cs:[200h] ; 调用这个中断子程序
mov ah, al
setscreen:
sub ah, 01h
cmp ah, 0ah
je do1
cmp ah, 1
je do2
cmp ah, 2
je do3
cmp ah, 3
je do4
jmp short int9ret
do1:
call sub1
jmp short int9ret
do2:
call sub2
jmp short int9ret
do3:
call sub3
jmp short int9ret
do4:
call sub4
int9ret:
pop es
pop cx
pop bx
pop ax
iret
;清屏
sub1:
push bx
push cx
push es
mov bx,0b800h
mov es,bx
mov bx,0
mov cx,2000
sub1s:
mov byte ptr es:[bx],' '
add bx,2
loop sub1s
pop es
pop cx
pop bx
ret ;sub1 ends
;设置前景色为绿色
sub2:
push bx
push cx
push es
mov bx,0b800h
mov es,bx
mov bx,1
mov cx,2000
sub2s: mov al,00000010b
and byte ptr es:[bx],11111000b
or es:[bx],al
add bx,2
loop sub2s
pop es
pop cx
pop bx
ret ;sub2 ends
;设置背景色为洋红色
sub3:
push bx
push cx
push es
mov cl,4
shl al,cl
mov bx,0b800h
mov es,bx
mov bx,1
mov cx,2000
sub3s: mov al,01010000b
and byte ptr es:[bx],10001111b
or es:[bx],al
add bx,2
loop sub3s
pop es
pop cx
pop bx
ret ; sub3 ends
;向上滚动一行
sub4:
push cx
push si
push di
push es
push ds
mov si,0b800h
mov es,si
mov ds,si
mov si,160
mov di,0
;
cld
mov cx,24;
sub4s:
push cx
mov cx,160
rep movsb ;传送
pop cx
loop sub4s
mov cx,80
mov si,0
sub4s1:
mov byte ptr es:[160*24+si],' '
;
add si,2
loop sub4s1
pop ds
pop es
pop di
pop si
pop cx
ret ;sub4 ends
int9end:
nop
code ends
end start
|
|