I am a little novice in assembler programming but I have a little homework that requires a lot of reflection, I have to modify the interrupt subroutine, for example when I call int21h, I want to display a message HELLO WORD,or when I want to do a division by 0,I want to display the number 5 for example, so I know the all segrment of vector interrupt is CS:0000 and offset is 0084(for int21h) and Is it requested to when I want call int21, I want my microprocessor execute another program that can be found in [0700:1200] , so I need to change the content 0000:0084 (the adress of int 21 ); I tried A idea is mov [0000],0700 mov [0084],1200
but unfortunately doesn't work there is my example
org 100
mov dx,000
push ds
mov ds,dx
lea bx,qwert
mov [0084h],1500h
int 21h hlt
org 1200
jmp qwert
pa equ 20h
pb equ 22h`
pc equ 24h
regcontrol equ 26h
tab db 3fh,06h,5bh,4FH,66H,6Dh,7dh,07h,7fh,6fh
com equ 90h
qwert:
mov ax,com
out regcontrol,ax
debut:
mov al,0FFH
OUT pc,al
call tempo
mov al,00h
out pc,al
call tempo
jmp debut
ret
proc tempo
mov cx,7fffh
ici:nop
nop
nop
nop
nop
nop
loop ici
ret
endp
so , what I want is when to I execute int21h , i want to this interruption go directly to execute the program qwerty , the program qwerty is founded in 0700:0112 ( I use emu 8086) , but int 21h goes directly to f400:1500.
I hope you understand me and sorry for my bad english
答案 0 :(得分:2)
现在我完整地阅读了你的问题......有些事情可能值得回答:
所以我知道向量中断的所有分段是CS:0000,偏移量是0084(对于int21h)
这混淆了几件事。 cs
是寄存器,与ip
一起存储下一个要执行的指令的地址(cs:ip
)。虽然您在开始时使用自己的代码cs = 0700h
,但直到您通过int 21h
跳转到其他位置。
中断向量表(包含中断处理例程的地址)在内存中从0000:0000
地址开始。
表中的每个条目都包含四个字节,因此21h
的偏移量为21h*4 = 84h
(不是84,但是84h == 132)。
单个条目的四个字节是例程的segment:offset
地址,偏移部分存储为第一个字,段部分是第二个字(0:86h
)。您的原始代码只设置偏移部分,但不设置段,这就是它跳转到F400h:1500h
的原因,您没有更改原始DOS处理程序的旧F400h
。
...所以我需要更改内容0000:0084(int 21的地址);
是(虽然您想要修改21h,因此地址为84h,但即使对于小数值,您的句子也是如此,如果您想要更改int 15h
,则地址0000:0084
将是正确的)。
我试过了一个想法是mov [0000],0700 mov,1200
没有。 mov [0000],0700
会修改ds:0000
处的内存。重新阅读一些解释什么段:x86 16b实模式中的偏移意味着(物理地址=段* 16 +偏移)。
因此当int 21h
向量位于(所有数字将从此处为六进制)0000:0084
时,这意味着它位于物理内存地址0000 * 10 + 0084 = 00084
。地址0000:0000
是int 0
的矢量。
如果你看到0000:0084
,那不是两个偏移(修改[0000]和[0084]),而是那个指向值的第一个字节的单个内存地址。并且存储32位segment:offset
值意味着将16b偏移部分写入+0和+1的字节,将16b的段值写入+2和+3字节。
因此,如果旧的int 21h
处理程序是F400:DEAD
,那么地址0000:0084
的内存包含四个字节:AD DE 00 F4
。在调试器中使用内存视图来查看中断表及其初始内容。来自问题的原始代码会将其修改为00 15 00 F4
,然后int 21h
会跳转到该地址(F400:1500
)。