Hi, why this code didnt work? It supposed to interrupt and print a 'a' on the screen.
thanks
mov ax, 0x07c0
mov ds, ax
mov ax, 0x07c0 ;selector
mov [36], word ax
lea ax, [isr] ;offset
mov [38], word ax
mov [12], word 255 ; lidt limit
mov [14], word 0 ; start of idt
mov [16], word 0
lidt [12]
int 9 ; interrupt
jmp $
isr:
mov ax, 0xb800
mov ds, ax
mov [0x0000], byte 0x61 ;print 'a'
mov [0x0001], byte 01110010b
isr
Re: isr
The current data segment that is being used is 0x7c0, but the ivt is at address 0. You need to use a null segment when writing the interrupt entry in the ivt in order for your code to work.Hi, i dont understood combuster.
Also, your use of LIDT is error prone here and not needed.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: isr
I do the following and the computer resets:
mov ax, word 0x0000
mov ds, ax
mov ax, 0x07c0
mov [36], word ax
lea ax, [isr]
mov [38], word ax
int9
jmp $
isr:
mov ax, 0xb800
mov ds, ax
mov [0x0000], byte 0x61
mov [0x0001], byte 01110010b
jmp $
mov ax, word 0x0000
mov ds, ax
mov ax, 0x07c0
mov [36], word ax
lea ax, [isr]
mov [38], word ax
int9
jmp $
isr:
mov ax, 0xb800
mov ds, ax
mov [0x0000], byte 0x61
mov [0x0001], byte 01110010b
jmp $
Re: isr
It should be
The point is that in real mode, a far address is specified as a segment-offset pair, and the offset goes to [address+0], segment goes to [address+2].
Code: Select all
mov ax, 0x07c0
mov [9*4+2], word ax
lea ax, [isr]
mov [9*4+0], word ax