interrupt 33

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
mobruan
Member
Member
Posts: 71
Joined: Thu Oct 09, 2008 8:25 am
Location: Rio de Janeiro - Brazil

interrupt 33

Post 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
CodeCat
Member
Member
Posts: 158
Joined: Tue Sep 23, 2008 1:45 pm
Location: Eindhoven, Netherlands

Re: interrupt 33

Post by CodeCat »

Explain 'didn't work' please.
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: interrupt 33

Post 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)
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
mobruan
Member
Member
Posts: 71
Joined: Thu Oct 09, 2008 8:25 am
Location: Rio de Janeiro - Brazil

Re: interrupt 33

Post by mobruan »

to CodeCat:
the code supposed to print a 'A', in pm mode, when key in the keyboard was pressed. And it didnt.
mobruan
Member
Member
Posts: 71
Joined: Thu Oct 09, 2008 8:25 am
Location: Rio de Janeiro - Brazil

Re: interrupt 33

Post 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.
User avatar
Walling
Member
Member
Posts: 158
Joined: Mon Dec 04, 2006 6:06 am
Location: Berlin, Germany

Re: interrupt 33

Post 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.
User avatar
Walling
Member
Member
Posts: 158
Joined: Mon Dec 04, 2006 6:06 am
Location: Berlin, Germany

Re: interrupt 33

Post by Walling »

Oh, and please use [code]..[/code] tags in your posts.
mobruan
Member
Member
Posts: 71
Joined: Thu Oct 09, 2008 8:25 am
Location: Rio de Janeiro - Brazil

Re: interrupt 33

Post 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!
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

Re: interrupt 33

Post 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.
Gizmic OS
Currently - Busy with FAT12 driver and VFS
mobruan
Member
Member
Posts: 71
Joined: Thu Oct 09, 2008 8:25 am
Location: Rio de Janeiro - Brazil

Re: interrupt 33

Post by mobruan »

Hi, i put the sti instruction in my code and the computer resets...
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: interrupt 33

Post by Combuster »

Triple fault.
More info needed.
Bochs dump missing.

Seriously, you're making a complete fool of yourself with these questions.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
mobruan
Member
Member
Posts: 71
Joined: Thu Oct 09, 2008 8:25 am
Location: Rio de Janeiro - Brazil

Re: interrupt 33

Post 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.
User avatar
Walling
Member
Member
Posts: 158
Joined: Mon Dec 04, 2006 6:06 am
Location: Berlin, Germany

Re: interrupt 33

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