;The code is to display the 26 characters in the ;center of the screen.When ESC is pressed,the character ;change color. ;INT 9 is replaced by my program. ;by: double; date:2009-09-26; ver:0.1 assume cs:codesg,ds:datasg,ss:stacksg datasg segment dw 0,0 datasg ends stacksg segment db 128 dup (0) stacksg ends codesg segment start: mov ax,datasg mov ds,ax mov ax,stacksg mov ss,ax mov sp,128 mov ax,0 mov es,ax push es:[4 * 9] pop ds:[0] push es:[4 * 9 + 2] pop ds:[2] cli mov word ptr es:[4 * 9],offset int9 mov es:[4 * 9 + 2],cs sti ; here display the character a~z. call display ; here restore the orignal int 9. ; so, when the program terminates,keyboard input ; can work as before. mov ax,0 mov es,ax push ds:[0] pop es:[4 * 9] push ds:[2] pop es:[4 * 9 + 2] mov ax,4c00h int 21h display: push ax push es mov ax,0b800h mov es,ax mov ah,'a' s1: mov es:[160 * 12 + 2 * 40],ah call delay inc ah cmp ah,'z' jna s1 pop es pop ax ret delay: ;The delay function is used just to make it ;change slower, so people can see the ;changement. push ax push dx mov ax,0 mov dx,1000h s2: sub ax,1 sbb dx,0 cmp ax,0 jne s2 cmp dx,0 jne s2 pop dx pop ax ret int9: ;This segment is used to simulate the BIOS INT 9. ;The INT progress is: ;1. Get INT number.(In this example,the number is 9.) ;2. Pushf ;3. IF = TF = 0 ;4. push cs ;5. push ip ;6. (ip) = (4 * N(9)),(cs) = (4 * N(9) + 2) ; what i should do in this simulation is just pushf ; The other work is done by original INT 9 program. push ax push bx push es in al,60h ;get key`s scan code, and store it in al. pushf call dword ptr ds:[0] cmp al,1 ;ESC`s scan code is '1' jne ok mov ax,0b800h mov es,ax ;when ESC is pressed, the color option of the character ;increass by 1. inc byte ptr es:[160 * 12 + 2 * 40 + 1] ok: pop es pop bx pop ax iret codesg ends end start