外中断
关于DOS-box是否真的操作硬件和内存的疑惑
DOSBox is a DOS-emulator
that uses the SDL-library
which makes DOSBox very easy to port to different platforms. DOSBox has already been ported to many different platforms, such as Windows, BeOS, Linux, MacOS X…
Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.
It is used by video playback software, emulators, and popular games including Valve’s award winning catalog and many Humble Bundle games.
SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. Support for other platforms may be found in the source code.
SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python.
为什么有这个疑惑呢?
在之前的实验中,我们在中断向量表0000:0200至0000:02FF的部分增添了新的0号中断例程,并且修改了0号表项的入口地址,这样做,是不是影响了后续的程序呢?后面的程序是不是也会同样会收到影响呢?
好像是没有的,因为后面程序在div指令溢出后
总是跑到一个循环里出不来
难道每次模拟的时候都会初始化??也不是没有可能
通过本次实验的效果来看的话,上面的这个猜想是对的,也就是说DOS-box在每次重新打开的时候都会初始化,但是如果你不关闭这个DOS环境的话,它还是会影响下面的
实验
安装一个新的int 9中断例程
功能: 在DOS下,按下‘A’键后,除非不再松开,如果松开就显示全屏的A,其他键照常使用
思路
- 编写新的int 9 中断例程
- 保存原有的int 9 地址
- 安装新的int 9 中断例程
感觉整个章节的思路比较有借鉴意义,当我没有不太想重新写一个函数,但是又要改善原有函数的功能的话,可以在新函数中去调用原函数,以屏蔽掉繁琐的步骤,更好的完善自己改善的功能。
代码
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,0b800h
; mov es,ax
; mov ah,'a'
; s:
; mov es:[160*12+40*2],ah
; call delay
; inc ah
; cmp ah,'z'
; jna s
mov ax,4c00h
int 21h
int9:
push ax
push bx
push cx
push es
in al,60h
pushf
call dword ptr cs:[200h]
cmp al,1eh+80h
je printA
jmp int9ret
printA:
;if loose A
mov ax,0b800h
mov es,ax
mov bx,0
mov cx,2000
s2:
mov byte ptr es:[bx],'A'
add bx,2
loop s2
int9ret:
pop es
pop cx
pop bx
pop ax
iret
int9end:
nop
code ends
end start
效果
得先运行程序,然后在按下a就会有全屏A的效果了