|
主题 : : 实验15代码和注释 [待解决] |
回复[ 1次 ]
点击[ 620次 ] | |
|
|
|
|
[帖 主]
[ 发表时间:2011-01-26 19:53 ]
[引用]
[回复]
[ top ] | |
荣誉值:0
信誉值:0
注册日期:2011-01-02 12:37 |
assume cs:code
code segment
old:
dw 0, 0 ;用于保存原中断地址
color:
push es
push ax
push bx
push cx
in al, 60h
cmp al, 1eh + 80h
jne def
mov ax, 0b800h
mov es, ax
xor bx, bx
mov cx, 4000
s:
mov byte ptr es:[bx], 'A'
inc bx
mov byte ptr es:[bx], 1100b
inc bx
loop s
def:
pushf
call dword ptr cs:[200h]
pop cx
pop bx
pop ax
pop es
iret
main:
xor ax, ax ;保存原中断
mov es, ax
mov ax, es:[9 * 4]
mov cs:[0], ax
mov ax, es:[9 * 4 + 2]
mov cs:[2], ax
mov ax, cs ;安装新中断代码
mov ds, ax
mov di, 200h
mov si, offset old
mov cx, offset main - offset old
cld
rep movsb
cli ;更改中断
mov word ptr es:[9 * 4], 204h
mov word ptr es:[9 * 4 + 2], 0
sti
mov ax, 4c00h ;退出
int 21h
code ends
end main | | |
|
|
|
|
[第1楼]
[ 回复时间:2013-05-13 17:24 ]
[引用]
[回复]
[ top ] | |
荣誉值:0
信誉值:0
注册日期:2011-01-02 12:37 |
assume cs:code, ss:stack
stack segment
db 080h dup (0)
stack ends
code segment
start:
mov ax, stack
mov ss, ax
mov sp, 080h
push cs
pop ds
mov si, offset new_int9
xor ax, ax
mov es, ax
mov di, 0204h
mov cx, offset new_int9_end - offset new_int9
cld
rep movsb
push es:[9 * 4].0
pop es:[0200h].0
push es:[9 * 4].2
pop es:[0200h].2
cli
mov word ptr es:[9 * 4].0, 0204h
mov word ptr es:[9 * 4].2, 0h
sti
mov ax, 04c00h
int 021h
new_int9:
push ds
push ax
push si
in al, 060h
pushf
call dword ptr cs:[0200h]
cmp al, 09eh
jne new_int9_exit
mov ax, 0b800h
mov ds, ax
xor si, si
new_int9_again:
mov byte ptr ds:[si].0, 'A'
add si, 2
cmp si, 0fa0h
jb new_int9_again
new_int9_exit:
pop si
pop ax
pop ds
iret
new_int9_end:
nop
code ends
end start | | |
|