I'm trying to define a permanent IDT record (interrupt descriptor table) in NASM , and for this I need to transfer the high word of the double word address to the data table, which is not allowed until the link time. Is there any way to do this?
Here is the interrupt handler:
;;; Interrupt 3 (breakpoint) handler. For now, just poke the screen and halt. align 8 int3: mov [0xb8000],dword '* * ' hlt
And here is the IDT record that refers to it. The most significant and least significant offset words should be stored separately and non-contiguously:
;; Interrupt 3 - breakpoint dw int3 ; offset (low) <---- WORKS dw codesel ; code selector db 0 ; unused db 0b10001111 ; present, ring 0, 32-bit trap gate dw int3 >> 16 ; offset (high) <---- ASSEMBLY ERROR
NASM correctly forces LD to issue the low word of the int3 address, but the high word is not executed during build with this error:
pgm.asm: 240: error: the shift operator can only be applied to scalar values
NASM will not do math with a value that is not defined before the reference time. I understand, but I need a way around this. I could:
- find int3 absolutely
- Build IDT at runtime, not at build time
I will probably end up building an IDT at runtime, but it would be nice to know if there is a way to get the assembler / linker to output a high address word into the data table that is not resolved before the link time.
Features:
- NASM 2.20.01 1
- NASM
aout output format - LD version 2.22
- 32-bit mode (NASM "bits 32" directive issued)
1 This is probably a typo; the latest version in my distribution today is 2.12.01. The latest version of nasm, available at the time of this writing, was 2.10.01.
Wayne conrad
source share