Page 1 of 1

interrupt 33

Posted: Fri Oct 17, 2008 8:00 am
by mobruan
why this code didnt work?

Code: Select all

org 0x7c00

section .text

bits 16

mov ax, word 0x0000
mov ds, ax

cli
lgdt [gdt]
mov eax,cr0
or al,0x01
mov cr0,eax

jmp 8:pm

jmp $


bits 32
pm:

mov ax, 8*2
mov ds,ax

mov  eax, isr              
mov  [idt33 + 0], ax 
shr  eax, 16
mov  [idt33 + 6], ax 
lidt [idt]

mov al, byte 00010001b        ;pic
out 0x20, al

mov al, byte 00100000b         ;pic remap to 0x20
out 0x21, al

mov al, byte 00000100b
out 0x21, al

mov al, byte 00000001b
out 0x21, al

jmp $
jmp $         ;quando volta da isr

isr:
mov [0xb8000], byte 'A'
mov [0xb8001], byte 0x17

iret

jmp $

section .data
gdt:
dw gdt_end - gdt_begin - 1
dd gdt_begin

gdt_begin:
gdt0:
 limit1 dw 0
 base1  dw 0
 base2  db 0
 type   db 0
 limit2 db 0
 base3  db 0

gdt1:
 dw 0xffff
 dw 0x0000
 db 0x00
 db 0x9a
 db 0xcf
 db 0x00

gdt2:
 dw 0xffff
 dw 0x0000
 db 0x00
 db 0x92
 db 0xcf
 db 0x00 
gdt_end:

idt:
dw idt_end - idt_begin - 1
dd idt_begin

idt_begin:
idt0:
 offset1 dw 0
 selector dw 0x8
 misc db 0
 present db 0x8e
 offset2 dw 0
.
.
.
idt33:
 offset1 dw 0
 selector dw 0x8
 misc db 0
 present db 0x8e
 offset2 dw 0

idt_end:
edit by mystran: added code tags

Re: interrupt 33

Posted: Fri Oct 17, 2008 9:55 am
by CodeCat
Explain 'didn't work' please.

Re: interrupt 33

Posted: Fri Oct 17, 2008 10:11 am
by i586coder
hummm,i guess,....,you want to make mouse driver

ok, in most cases your problem around:
idt33 pointer

what you mean in this code :!:
mobruan wrote:

Code: Select all

idt33:
offset1 dw 0
selector dw 0x8
misc db 0
present db 0x8e
offset2 dw 0
note: when you entered PM all real mode interrupts will disable,also there is no int 0x33
when you presnet's as OS you need to code your own :idea:
8)

Re: interrupt 33

Posted: Fri Oct 17, 2008 12:21 pm
by mobruan
to CodeCat:
the code supposed to print a 'A', in pm mode, when key in the keyboard was pressed. And it didnt.

Re: interrupt 33

Posted: Fri Oct 17, 2008 12:23 pm
by mobruan
to AhmadTayseerDajani:
this is a interrupt descriptor. The IDT is composed of interrupt descriptors, wich in turn point to a code segment and a offset in this.

Re: interrupt 33

Posted: Fri Oct 17, 2008 1:33 pm
by Walling
A few questions:
  • How did you assemble and link your code?
  • How did you test it?
  • What happened, when you tested it? (since the 'A' didn't appear something else must have happened)
The "org 0x7c00" makes me think you are trying to develop a MBR (boot sector). If that is case read up on that. As a starter you need the signature. Also read up on using sections, because they only work well together with a linker script and some object format like ELF. The MBR is usually a flat binary.

Re: interrupt 33

Posted: Fri Oct 17, 2008 1:40 pm
by Walling
Oh, and please use [code]..[/code] tags in your posts.

Re: interrupt 33

Posted: Fri Oct 17, 2008 1:41 pm
by mobruan
Hi, i tested it as a bootstrap code. Because running upper windows i cant test it, or i dont know how to test it.
I ran the code with a software interrupt and it worked(int 33).
And for the fellows, i change my programming style.
Cheers,
today is friday!

Re: interrupt 33

Posted: Fri Oct 17, 2008 10:31 pm
by System123
Here are the reasons. You never enabled interrupts which means an IRQ never fires which in turn means the Interrupt handler never fires. I take it you remapped the pic correctly. I would suggest that you create a general stub that pushes the registers to the stack and then puts the segment registers to kernel space. ie: 0x10 Then call the handler and finally pop the old registers, reset the segment regs, clear the stack and then iret.

Re: interrupt 33

Posted: Tue Oct 21, 2008 8:16 am
by mobruan
Hi, i put the sti instruction in my code and the computer resets...

Re: interrupt 33

Posted: Tue Oct 21, 2008 10:18 am
by Combuster
Triple fault.
More info needed.
Bochs dump missing.

Seriously, you're making a complete fool of yourself with these questions.

Re: interrupt 33

Posted: Tue Oct 21, 2008 10:55 am
by mobruan
How do i suppose to learn?
On teory all is fine, but in the pratice its totally diferent...
Thanks

If anyone has the code to generate a keyboard interrupt in protected mode i appreciate.

Re: interrupt 33

Posted: Tue Oct 21, 2008 11:23 am
by Walling
mobruan wrote:If anyone has the code to generate a keyboard interrupt in protected mode i appreciate.
You have to create that code yourself. What is the fun in OSDev'ing if you get all the code served?
mobruan wrote:How do i suppose to learn?
You experiment, write some code, try it out, delete it all, start over, read some specs, go to the wiki and read, write some more code, try it out, start over, browse the net, write some more code, try it out, ask a question that show you really tried, get an answer, try it out, write some more code, continue to a new area of your kernel/bootloader, etc.

For me it is a lot about making experiments. And reading specs, when it didn't work as I expected.