Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I'm creating a little 16bit operating system (With CLI, of course). Now I'm starting to work with other programs that kernel can run. I think I must set up IVT before that, so I followed the tutorial here (http://wiki.osdev.org/Real_mode_assembly_IV), but I get stuck about instruction 6: "Move your handler's segment into [es:bx]". How do I do that?
Hanz wrote:I'm creating a little 16bit operating system (With CLI, of course). Now I'm starting to work with other programs that kernel can run. I think I must set up IVT before that, so I followed the tutorial here (http://wiki.osdev.org/Real_mode_assembly_IV), but I get stuck about instruction 6: "Move your handler's segment into [es:bx]". How do I do that?
%define INT_NUMBER 0x70
%define CODE_SEG 0x1234 ;Change to whatever code segment your code uses
push ax ;(probably avoidable)
push es ;(probably avoidable)
xor ax,ax ;AX = 0 (probably avoidable)
mov es,ax ;ES = 0 (probably avoidable)
mov word [es:INT_NUMBER*4], inthandler
mov word [es:INT_NUMBER*4+4], CODE_SEG
pop es ;(probably avoidable)
pop ax ;(probably avoidable)
Note that it's likely you've got a segment register that is zero anyway (even if it's CS or SS - it doesn't matter); and if you do you can reduce the code above down to 2 instructions.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
[BITS 16]
[ORG 0x1000]
jmp main
%define INT_NUMBER 0x70
%define CODE_SEG 0x1000
inthandler:
cmp ah,0
je .type0
; Error with interrupt
call Panic
cli
hlt
.type0:
call DumpRegisters
iret
main:
cli
push cs ; set DS=CS
pop ds
sti
; set up inthandler
push ax
push es
xor ax,ax
mov es,ax
mov word [es:INT_NUMBER*4], inthandler
mov word [es:INT_NUMBER*4+4], CODE_SEG
pop es
pop ax
I still can't get what I'm doing wrong.
Thanks for help in advance.
I am not still very comfortable with this. Did you change your CODE_SEG? Otherwise your int handler is at 0x1000:0x1002 and that does not make sense if your kernel is at 0x00001000. Please make sure that you fully understand the difference.