AT&T Assembly - Setup all 256 entries in IDT

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
teodori
Member
Member
Posts: 103
Joined: Wed Nov 14, 2012 4:55 pm

AT&T Assembly - Setup all 256 entries in IDT

Post by teodori »

Hello,
is there a simple way of creating a IDT with 256 elements in AT&T assembly?
For example like this:

Code: Select all

idt:
	.fill 256, 8, 0			# IDT is uninitialized 256 x 8 Byte with 0
idt_end:

idtptr:
	.word (idt_end - idt - 1)
	.long (idt + 0x0500)
and then:

Code: Select all

SetupIdt:
	lea idt, %edi				# Load Effective Address of IDT
	movw $256, %cx			# Setup Counter
SetupNextIdtEntry:
	lea DefIsr, %ax			# Load Effective Address of Default ISR
	movw %ax, (%di)
	movw $0x0008, %ax
	movw %ax, 2(%di)
	movb $0x00, %al
	movb %al, 4(%di)
	movb $0xae, %al
	movb %al, 5(%di)
	movw $0x0000, %ax
	movw %ax, 6(%di)
	addw $8, %di
	decw %cx
	cmpw $0, %cx
	jne SetupNextIdtEntry
	lidt idtptr					# Load Interrupt Descriptor Table
	ret

DefIsr:
	call kisr
	iret
Well this not really good this leaves a empty space of 256x8 Bytes in my code?
Hm or perhaps I should push the addresses of the GDT and IDT to my kernel so I can use C language?

I want to avoid this:

Code: Select all

idt:
	# ISR 000
	.word ISR000
	.word 0x0008
	.byte 0x00
	.byte 0xae
	.word 0x0000
.........
	# ISR 255
	.word ISR255
	.word 0x0008
	.byte 0x00
	.byte 0xae
	.word 0x0000
idt_end:

idtptr:
	.word (idt_end - idt - 1)
	.long (idt + 0x0500)
Thank you
teodori
Member
Member
Posts: 103
Joined: Wed Nov 14, 2012 4:55 pm

Re: AT&T Assembly - Setup all 256 entries in IDT

Post by teodori »

Ok found a workaround I use repeat:

Code: Select all

idt:
	.rept 256
	.word DefIsr
	.word 0x0008
	.byte 0x00
	.byte 0xae
	.word 0x0000
	.endr
idt_end:

idtptr:
	.word (idt_end - idt - 1)
	.long (idt + 0x0500)
Post Reply