C Funcitons from Assembly
Posted: Sat Aug 13, 2011 3:57 am
Hi,
I'm calling a C function from an assembly interrupt handler.
The interrupt handler looks like this:
Which jumps to a default handler:
Which calls a C function:
So far this works just fine. However, if I try to do something like printf("%d", isr), the system crashes.
Is this somehow related to the data in isr is being popped from the stack, or is there more likely something wrong with my printf function?
I have not yet remapped the PIC, and I have not enabled hardware interrupts. It will print '6' a lot before crashing, so it looks like it's generating interrupt 6 (invalid opcode)...
Thankyou
I'm calling a C function from an assembly interrupt handler.
The interrupt handler looks like this:
Code: Select all
_isr4:
cli
push byte 0 ; Error code
push byte 4 ; Interrupt number
jmp isrhandler
Code: Select all
isrhandler:
mov eax, _isr
call eax
add esp, 8
iret
Code: Select all
void isr(ubyte isr, ubyte err) {
printf ("Interrupt %c", isr + 48);
}
Is this somehow related to the data in isr is being popped from the stack, or is there more likely something wrong with my printf function?
I have not yet remapped the PIC, and I have not enabled hardware interrupts. It will print '6' a lot before crashing, so it looks like it's generating interrupt 6 (invalid opcode)...
Thankyou