v86

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.
Post Reply
Tom

v86

Post by Tom »

Hello, I just discovered that I didn't get v86 mode set :(. I have a bootsector, loads the asm kernel ( the tutorial code ), it loads it at 1000h.

I know it executes "cli" but I don't know if anything else executes.

it tries sets "cli" then Pmode, then v86.

I know it doesn't get to the v86 ( it freezes before then )because the numlock doesn't work:(

the code's too big to show, but is anything I said there bad for v86?

Thank you
Tom

Re:v86

Post by Tom »

ok.....if I use "[segment .text]" in my asm kernel that loads after the bootsector, will it effect anything? and do I have to use "org 0x1000"

I'm not in DOS so will the segment effect anything?
Tom

Re:v86

Post by Tom »

hello ( i'm using this same topic because a browser bug won't let me make new ones :o )

I can't load my idt because it reboots my computer :( ???

here is the code, did I do anything wrong?:

idt32 dw exc0, 8, 08e00h, 0
dw exc1, 8, 08e00h, 0
dw exc2, 8, 08e00h, 0
dw exc3, 8, 08e00h, 0
dw exc4, 8, 08e00h, 0
dw exc5, 8, 08e00h, 0
dw exc6, 8, 08e00h, 0
dw exc7, 8, 08e00h, 0
dw exc8, 8, 08e00h, 0
dw exc9, 8, 08e00h, 0
dw exca, 8, 08e00h, 0
dw excb, 8, 08e00h, 0
dw excc, 8, 08e00h, 0
dw v86gen, 8, 08e00h, 0
dw exce, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw irq0, 8, 08e00h, 0
dw irq1, 8, 08e00h, 0
dw irq2, 8, 08e00h, 0
dw irq3, 8, 08e00h, 0
dw irq4, 8, 08e00h, 0
dw irq5, 8, 08e00h, 0
dw irq6, 8, 08e00h, 0
dw irq7, 8, 08e00h, 0
dw irq8, 8, 08e00h, 0
dw irq9, 8, 08e00h, 0
dw irqa, 8, 08e00h, 0
dw irqb, 8, 08e00h, 0
dw irqc, 8, 08e00h, 0
dw irqd, 8, 08e00h, 0
dw irqe, 8, 08e00h, 0
dw irqf, 8, 08e00h, 0
dw callv86sys, 8, 8e00h, 0
gdt32a dw 037h, gdt32,0
idt32a dw 187h, idt32,0


and here is my code for lidt:

lidt [cs:idt32a]

thank you
Whatever5k

Re:v86

Post by Whatever5k »

You have something like
dw excp1
in your code. I think you can't do this because excp1 ist 32-bit and dw only 16-bit.
Tom

Re:v86

Post by Tom »

I think you ment exc1 not "exc(p)1"

exc1:
push ax
mov al,1
jmp irq

irq0: ; Do IRQs
push ax
mov al,8
jmp short irq
irq1:
push ax
mov al,9
jmp short irq
irq2:
push ax
mov al,0ah
jmp short irq
irq3:
push ax
mov al,0bh
jmp short irq
irq4:
push ax
mov al,0ch
jmp short irq
irq5:
push ax
mov al,0dh
jmp short irq
irq6:
push ax
mov al,0eh
jmp short irq
irq7:
push ax
mov al,0fh
jmp short irq
irq8:
push ax
mov al,70h
jmp short irq
irq9:
push ax
mov al,71h
jmp short irq
irqa:
push ax
mov al,72h
jmp short irq
irqb:
push ax
mov al,73h
jmp short irq
irqc:
push ax
mov al,74h
jmp short irq
irqd:
push ax
mov al,75h
jmp short irq
irqe:
push ax
mov al,76h
jmp short irq
irqf:
push ax
mov al,77h
irq:
test byte [esp+12],2
jnz short v86irq
push ds ; A real mode IRQ in protected mode
push ss
pop ds
int 30h
pop ds
pop ax
iretd
v86irq: ; An IRQ from V86 mode
mov [ss:v86irqnum],al
pop ax
pushad
mov dl,[ss:v86irqnum]
jmp v86int
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:v86

Post by Pype.Clicker »

i think whatever is right: you store your 32-bits offsets (exc*) right into your IDT datas, but under the form of 16 bits words. The problem is that no loader will be able to relocate this properly. Either the linker will complain about this (if you select a relocatable output), or the assembler.
worse possible behaviour is that it compiles and drops the 16 high bits of the address (for instance if you have [ORG 0x10000] in your code, then if exc1 == 0x12345, then the effective IDT address will be 0x00012345 & 0x0000ffff == 0x00002345. I think you now understand why it can easily reboot your PC ...
Tom

Re:v86

Post by Tom »

I don't use org in my code, my bootloader crashes when I do.

my bootloader loads my asm kernel at 0x1000, does that cause problems? ( forget about why I do that, I know the bootloader works ).
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:v86

Post by Pype.Clicker »

without any ORG, i guess your CS and DS segment both start at 0x1000:0. in that case, IDT32a should contain idt32+0x10000. If this is not the case, then you'll fall back in the previous problem .
_Tom

Re:v86

Post by _Tom »

still reboots
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:v86

Post by Pype.Clicker »

i'm not sure this is the problem, but you should know that some exception push a error code on the stack and that this error code is to be removed by your handler before calling IRETD.

so, i'm not sure it's a good idea to call irq from exc... and especially, its not a good idea to call a real mode handler for a protected mode exception (even for division by zero or debug trap ...)
Tom

Re:v86

Post by Tom »

To Whatever5k... I saw you had a working IDT, could I see the full code? ( is an IDT a v86 moniter? )
Post Reply