i was writing a simple bootloader in assembly and testing it on qemu. i needed an idt and wrote a function to make entries. idk what is wrong here- please check-
makeidt:
;privilage level in cl
;index to a gdt entry in ax
;handler function pointer in edx
;put 0x01 in ch to make this interrupt active
;the table entry would be given in eax:edx
mov bx, dx ; the first part
shl ebx, 16
mov bl, cl
shl ax, 3 ; else, bx would be overwriten
or bx, ax ; selector in gdt
mov [answerh], ebx ; high part made
shr edx, 16
mov ebx, 0xe
shl ebx, 3
or bl , cl
shl ebx, 1
or bl, ch
shl ebx, 16
mov bx, dx
mov eax, [answerh]
ret
intcode:
call myfunct
iret
answerh dd 0
idtdesc:
idtlen dw 100h
dd idt
idt:
i called this function like this-
mov edx, intcode
mov ax, 2
mov ch, 1
mov cl, 3
call makeidt
mov [idt], eax
mov [idt+4], edx
lidt [idtdesc]
mov ebx, string
sti
int 0
cli
myfunct is working fine when called from somewhere else.. but the machine restarts again and again after encountering this block why?? btw i am in 32 bit protected mode.