'80387 instructions aren't allowed' when compiling ISR

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
pyd1
Posts: 1
Joined: Sat Apr 25, 2020 5:13 am

'80387 instructions aren't allowed' when compiling ISR

Post by pyd1 »

I tried to create an ISR using the GCC attribute, but it doesn't work. This is the code:

Code: Select all

#include <stdint.h>

struct interrupt_frame {
    uint16_t ip;
    uint16_t cs;
    uint16_t flags;
    uint16_t sp;
    uint16_t ss;
} __attribute__((packed));

__attribute__((interrupt)) void irq0(struct interrupt_frame* frame)
{
}
But when I compile it, GCC throws an error:

Code: Select all

$ i686-elf-gcc -ffreestanding -c handler.c -o handler.o
handler.c: In function 'irq0':
handler.c:12:1: sorry, unimplemented: 80387 instructions aren't allowed in an interrupt service routine
   12 | {
      | ^
When I tried to search online, I couldn't find any examples using the GCC attribute, and I could not find any mentions of this error. What am I doing wrong? Is it even possible?
Thanks!
Octocontrabass
Member
Member
Posts: 5575
Joined: Mon Mar 25, 2013 7:01 pm

Re: '80387 instructions aren't allowed' when compiling ISR

Post by Octocontrabass »

Since GCC doesn’t preserve SSE, MMX nor x87 states, the GCC option -mgeneral-regs-only should be used to compile interrupt and exception handlers.
From the GCC manual.

I don't think that interrupt_frame struct is correct. Why are all of its members uint16_t instead of uint32_t?
Post Reply