我需要编写一个驻留程序,它将控制台输出写入文件。为此,我必须知道DOS用于将其输出打印到控制台的中断和函数,以重写此中断。但我无法在任何地方找到它。
答案 0 :(得分:1)
此类问题的规范参考曾是Ralf Brown的中断名单。
这是INT21h,subfunction 09h"将字符串写入标准输出"。
重定向(在这种情况下链接)中断并不简单。准备崩溃。
同情编辑。要正确链接,从0:xxxx读取int21h的向量并存储它(2个字,段:偏移量)
old_dosint dd ?
mov ax, 0
mov es, ax
les bx, es:[21h * 4]
mov word ptr [old_dosint], bx
mov word ptr [old_dosint + 2], es
然后保存自己的ISR,称之为myisr,进入向量(首先禁用ints):
cli
mov ax, 0
mov es, ax
mov es:[21h * 4], offset myisr
mov es:[(21h * 4) + 2], cs
sti
你的isr会链:
myisr:
cmp ah, 09h
jne myisrexit
....etc....
myisrexit:
jmp dword ptr cs:[old_dosint]
答案 1 :(得分:1)
在最后一步中,DOS使用TELETYPE OUTPUT将其输出打印到控制台: RBIL-> inter61a.zip-> INTERRUP.A
--------V-100E-------------------------------
INT 10 - VIDEO - TELETYPE OUTPUT
AH = 0Eh
AL = character to write
BH = page number
BL = foreground color (graphics modes only)
Return: nothing
Desc: display a character on the screen, advancing the cursor and scrolling
the screen as necessary
Notes: characters 07h (BEL), 08h (BS), 0Ah (LF), and 0Dh (CR) are interpreted
and do the expected things
IBM PC ROMs dated 1981/4/24 and 1981/10/19 require that BH be the same
as the current active page
BUG: if the write causes the screen to scroll, BP is destroyed by BIOSes
for which AH=06h destroys BP
SeeAlso: AH=02h,AH=06h,AH=0Ah
这是另一种设置和获取中断向量的方法: RBIL-> inter61b.zip-> INTERRUP.F
--------D-2125-------------------------------
INT 21 - DOS 1+ - SET INTERRUPT VECTOR
AH = 25h
AL = interrupt number
DS:DX -> new interrupt handler
Notes: this function is preferred over direct modification of the interrupt
vector table
some DOS extenders place an API on this function, as it is not
directly meaningful in protected mode
under DR DOS 5.0-6.0, this function does not use any of the
DOS-internal stacks and may thus be called at any time; however,
under Novell DOS 7.0 - DR-DOS 7.02, this function was not reentrant.
Since 1998/05/29, DR-DOS 7.03 no longer uses any internal stacks and
tests for this function much earlier, to allow a minimal stack usage
of just two words in addition to the IRET frame, allowing it to be
called from INT 21h functions, specificially device drivers. This
fixes the MCS SMB client
Novell NetWare (except the new DOS Requester) monitors the offset of
any INT 24 set, and if equal to the value at startup, substitutes
its own handler to allow handling of network errors; this introduces
the potential bug that any program whose INT 24 handler offset
happens to be the same as COMMAND.COM's will not have its INT 24
handler installed
SeeAlso: AX=2501h,AH=35h
--------D-2135-------------------------------
INT 21 - DOS 2+ - GET INTERRUPT VECTOR
AH = 35h
AL = interrupt number
Return: ES:BX -> current interrupt handler
Note: under DR DOS 5.0+, this function does not use any of the DOS-internal
stacks and may thus be called at any time
SeeAlso: AH=25h,AX=2503h
ISR结束的一点变化:
myisr:
....etc....
DB 0EAh ; jmp far
old_dosint DW ?, ?
编辑: RBIL-> inter61b.zip-> INTERRUP.F
--------D-2109-------------------------------
INT 21 - DOS 1+ - WRITE STRING TO STANDARD OUTPUT
AH = 09h
DS:DX -> '$'-terminated string
Return: AL = 24h (the '$' terminating the string, despite official docs which
state that nothing is returned) (at least DOS 2.1-7.0 and
NWDOS)
Notes: ^C/^Break are checked, and INT 23 is called if either pressed
standard output is always the screen under DOS 1.x, but may be
redirected under DOS 2+
under the FlashTek X-32 DOS extender, the pointer is in DS:EDX
SeeAlso: AH=02h,AH=06h"OUTPUT"
示例:
STRING DB "Hello","$"
mov ah,9
lea dx,STRING
int 21h