Board logo

Subject: 【水】【原创】【额是新手】一个int9中断示例,带注释! [Print This Page]

Author: dapro    Time: 2009-1-2 18:48     Subject: 【水】【原创】【额是新手】一个int9中断示例,带注释!



[Copy to clipboard]
CODE:
assume cs:code
data segment
dw 0,0
data ends
stack segment
db 128 dup(0)
stack ends
code segment
start:
mov ax,stack
mov ss,ax
mov sp,128

mov ax,data  
mov ds,ax

mov ax,0
mov es,ax       ;es save blackout vector

push es:[9*4]      ;number 9 blackout push it into stack this value it point offset address IP
pop ds:[0]       ;pop it into ds:[0]
push es:[9*4+2]      ;number 9 blackout and this value is point segment address CS
pop ds:[2]       ;pop it into ds:[2]  
          ;this operate save current blackout of number 9's address into ds:[0] and ds:[2]

mov word ptr es:[9*4],offset int9 ;install new int9 blackout
mov es:[9*4+2],cs
          ;this operate set new blackout of number 9's address
          ;the address is: 0:9*4=IP 0:9*4+2=CS

mov ax,0B800H      ;save display memory address
mov es,ax
mov ah,'a'

show:
mov es:[160*12+40*2],ah    ;display 'ah' at the middle of screen (character mode)
call cycle       ;call cycle sub program
inc ah        ; ah++
cmp ah,'z'       ; compare 'ah' with 'z'
jna show       ;if ah<=z jmp to show point

mov ax,0
mov es,ax

push ds:[0]
pop es:[9*4]      ;set 0:9*4=ds:[0] same as 0:[9*4]=system int9's CS
push ds:[2]   
pop es:[9*4+2]      ;0:[9*4+2]=ds:[2] ds:[2]= system int9's IP

mov ax,4c00h
int 21h

cycle:
push ax
push dx
mov dx,1000h
mov ax,0
sub1:         ;a large cycle 10000000h times
sub ax,1
sbb ax,0   
cmp ax,0
jne sub1
cmp dx,0
jne sub1
pop dx
pop ax
ret      ;return
;----------------- the followwing code is new int9 blackout--------------------
int9:
push ax
push bx
push es

in al,60h
pushf
pushf
pop bx
and bh,11111100B     ;set IF,TF to zero
push bx
popf
call dword ptr ds:[0]    ;call current int9

cmp al,1       ;compare al->1 the ESC scanf code is 01
jne int9ret       ;if al isn't equal with 01,jmp to int9ret

mov ax,0B800h
mov es,ax
inc byte ptr es:[160*12+40*2+1]  ;add 1 to change text property
int9ret:
pop es
pop dx
pop ax
iret        ;return int9 blackout

code ends
end start

顺便说下,我是新来的!
Author: softbug    Time: 2009-2-12 21:44

dos下用的 int 9 屏幕显示中断  现在几乎没用




Welcome to CnPack Forum (http://bbs.cnpack.org/) Powered by Discuz! 5.0.0