Page 1 of 1

IDT problem, using fasm.

Posted: Fri Aug 01, 2008 3:05 am
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

Re: IDT problem, using fasm.

Posted: Fri Aug 01, 2008 3:42 am
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

Re: IDT problem, using fasm.

Posted: Fri Aug 01, 2008 3:57 am
by kmtdk
well
i have tried that, that is why im asking here :lol:
but thx anyway ..


KMT dk

Re: IDT problem, using fasm.

Posted: Fri Aug 01, 2008 5:16 am
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

Re: IDT problem, using fasm.

Posted: Fri Aug 01, 2008 5:24 am
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.

Re: IDT problem, using fasm.

Posted: Fri Aug 01, 2008 5:30 am
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

Re: IDT problem, using fasm.

Posted: Fri Aug 01, 2008 5:35 am
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

Re: IDT problem, using fasm.

Posted: Fri Aug 01, 2008 5:47 am
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..

Re: IDT problem, using fasm.

Posted: Fri Aug 01, 2008 2:17 pm
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