IDT problem, using fasm.

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
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

IDT problem, using fasm.

Post by kmtdk »

HI
i have a problem defining the isr address, in my idt, using fasm
i have tryed the wiki; I_CANT_GET_MY_INTERRUPTS_TO_WORK, or something in that maner-
Does anyone know how to split the adress in 2.
eksemple:

Code: Select all

Dw isr1
dw 0x8
db 0
db 010001110b
dw isr1
KMT dk
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: IDT problem, using fasm.

Post by Korona »

Most assemblers / object code file formats cannot do relocations that involve bitwise operations (my own object code file format can do it :P). Insert the ISR addresses at runtime. If the address is known at assemble-time you could try something like
dw isr1 >> 16
dw isr1 & 0xFFFF ; EDIT: must be 0xFFFF
Last edited by Korona on Fri Aug 01, 2008 5:24 am, edited 1 time in total.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: IDT problem, using fasm.

Post by kmtdk »

well
i have tried that, that is why im asking here :lol:
but thx anyway ..


KMT dk
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
brickhead20
Member
Member
Posts: 38
Joined: Mon Mar 24, 2008 4:17 pm

Re: IDT problem, using fasm.

Post by brickhead20 »

Perhaps with the second one you should try:

dw isr1 & 0xFFFF ?

What exactly are the errors that you get if you try something like this?

Best wishes,
Richard
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: IDT problem, using fasm.

Post by Korona »

The problem is that the address of the label "isr1" is not known until the object file is linked (unless you use the org directive).
Most object file formats do not support bitwise "and" and "shift-right" relocation (they only support relative and absolute relocations) so most assemblers won't allow you to use bitwise operations on labels.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: IDT problem, using fasm.

Post by kmtdk »

The error i get is : Error: extra characters on line.
but im going to test if it works with "or" insted..

test result:

if im using "or" insted of "&" it dont say anything
if im using shl insted of "<<" 16 it dont say anything

However i have not tested if it is currect
but i will..


KMT dk
Last edited by kmtdk on Fri Aug 01, 2008 5:35 am, edited 1 time in total.
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
brickhead20
Member
Member
Posts: 38
Joined: Mon Mar 24, 2008 4:17 pm

Re: IDT problem, using fasm.

Post by brickhead20 »

Yeah I figured.

It makes sense then to do it at runtime.

I just wondered what the errors were, since that might help suggest a clever way around it. Perhaps thats just wishful thinking.

Might there be a way to do this using a link script? Just a thought. For example could we get the link script to take the symbol isr1, and say define:

isr1h = (isr1 & 0xFFFF);
isr1l = (isr1 >> 16);

then in the assembly file:

Dw isr1h
...
dw isr1l

Just a guess, I would take a look at ld's manual, but I have some things to do. I might take a look later.

This might just be wishful thinking. ld supports these operations I think, but I still don't know if what has been said will work.

There is probably a simpler way.

Best wishes,
Richard

EDIT: Assuming you are using ld :P
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: IDT problem, using fasm.

Post by kmtdk »

well
now, i maded a mistake
it is supossed to be shr and shl
the new error is value out of range.
but i have currectede it.
the sulution is:
dw isr1 shr 16

dw (isr1 shr 32)shl 16

sorry for the worng results ...

KMT dk
the next test; im working on it..
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: IDT problem, using fasm.

Post by kmtdk »

Now i got the address to work
it seems that even if you tell fasm to use 32 bits, it uses 64 at compiletime.
reason: i had to shl the address by 0x30, to get rid of the "high" part.
a eksempel of a idt entry in fasm, with currect addressing will look like this:

Code: Select all

                    dw   ((isr1 shl 0x30) shr 0x30) ;the address; the low part
                    dw   0x8  ; selector
                    db   0 ; the always 0
                    db   010001110b ; the type
                    dw  (isr1 shr 0x10)       ; the address; the high part
KMT dk
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
Post Reply