Here are the errors that appear when compiling:

sergey@COMPUTER:~/Рабочий стол/myOS_8.0T$ make mykernel.bin as --32 -o interruptstubs.o interruptstubs.s interruptstubs.s: Assembler messages: interruptstubs.s: Warning: конец файла не в конце строки; вставлен символ новой строки interruptstubs.s:8: Error: junk at end of line, first unrecognized character is `:' interruptstubs.s:27: Error: bad register name `%0x00+IRQ_BASE' interruptstubs.s:28: Error: bad register name `%0x01+IRQ_BASE' Makefile:12: ошибка выполнения рецепта для цели «interruptstubs.o» make: *** [interruptstubs.o] Ошибка 1 sergey@COMPUTER:~/Рабочий стол/myOS_8.0T$ 

and here is the source:

 .set IRQ_BASE, 0x20 .section .text .extern _ZN16InterruptManager15handleInterruptEhj .global _ZN16InterruptManager22IgnoreInterruptRequestEv: .macro HandleException num .global _ZN16InterruptManager16HandleException\num\()Ev _ZN16InterruptManager15HandleException\num\()Ev: movb %\num, (interruptnumber) jmp int_bottom .endm .macro HandleInterruptRequest num .global _ZN16InterruptManager26HandleInterruptRequest\num\()Ev _ZN16InterruptManager26HandleInterruptRequest\num\()Ev: movb %\num + IRQ_BASE, (interruptnumber) jmp int_bottom .endm HandleInterruptRequest 0x00 HandleInterruptRequest 0x01 int_bottom: pusha pushl %ds pushl %es pushl %fs pushl %gs pushl %esp push (interruptnumber) call _Z15handleInterrupthj # addl $5, %esp movl %eax, %esp popl %gs popl %fs popl %es popl %ds popa _ZN16InterruptManager22IgnoreInterruptRequestEv: iret .data interruptnumber: .byte 0 

Cpp file:

 #include "interrupts.h" void printf(char* str); InterruptManager::GateDescriptor InterruptManager::InterruptDescriptorTable[256]; void InterruptManager::SetInterruptDescriptorTableEntry( uint8_t interruptNumber, uint16_t codeSegmentSelectorOffset, void (*handler)(), uint8_t DescriptorPrivilegeLevel, uint8_t DescriptorType) { const uint8_t IDT_DESC_PRESENT = 0x80; InterruptDescriptorTable[interruptNumber].handlerAddressLowBits = ((uint32_t)handler) & 0xFFFF; InterruptDescriptorTable[interruptNumber].handlerAddressHighBits = (((uint32_t)handler) >> 16) & 0xFFFF; InterruptDescriptorTable[interruptNumber].gdt_codeSegmentSelector = codeSegmentSelectorOffset; InterruptDescriptorTable[interruptNumber].access = IDT_DESC_PRESENT | DescriptorType | ((DescriptorPrivilegeLevel&3) << 5); InterruptDescriptorTable[interruptNumber].reserved = 0; } InterruptManager::InterruptManager(GlobalDescriptorTable* gdt) { uint16_t CodeSegment = gdt->CodeSegmentSelector(); const uint8_t IDT_INTERRUPT_GATE = 0xE; for(uint16_t i = 0; i < 256; i++) SetInterruptDescriptorTableEntry(i, CodeSegment, &IgnoreInterruptRequest, 0, IDT_INTERRUPT_GATE); SetInterruptDescriptorTableEntry(0x20, CodeSegment, &HandleInterruptRequest0x00, 0, IDT_INTERRUPT_GATE); SetInterruptDescriptorTableEntry(0x21, CodeSegment, &HandleInterruptRequest0x01, 0, IDT_INTERRUPT_GATE); InterruptDescriptorTablePointer idt; idt.size = 256 * sizeof(GateDescriptor) - 1; idt.base = (uint32_t)InterruptDescriptorTable; asm volatile("lidt %0" : : "m" (idt)); } InterruptManager::~InterruptManager() { } void InterruptManager::Activate() { asm("sti"); } uint32_t InterruptManager::handleInterrupt(uint8_t interruptNumber, uint32_t esp) { printf(" INTERRUPT"); return esp; } 

File h:

 #ifndef __INTERRUPTS_H #define __INTERRUPTS_H #include "types.h" #include "port.h" #include "gdt.h" class InterruptManager { protected: struct GateDescriptor { uint16_t handlerAddressLowBits; uint16_t gdt_codeSegmentSelector; uint8_t reserved; uint8_t access; uint16_t handlerAddressHighBits; } __attribute__((packed)); static GateDescriptor InterruptDescriptorTable[256]; struct InterruptDescriptorTablePointer { uint16_t size; uint32_t base; } __attribute__((packed)); static void SetInterruptDescriptorTableEntry( uint8_t interruptNumber, uint16_t codeSegmentSelectorOffset, void (*handler)(), uint8_t DescriptorPrivilegeLevel, uint8_t DescriptorType ); public: InterruptManager(GlobalDescriptorTable* gdt); ~InterruptManager(); void Activate(); static uint32_t handleInterrupt(uint8_t interruptNumber, uint32_t esp); static void IgnoreInterruptRequest(); static void HandleInterruptRequest0x00(); static void HandleInterruptRequest0x01(); }; #endif 

Here is the latest update of error messages:

 sergey@COMPUTER:~/Рабочий стол/myOS_8.0T$ make mykernel.bin as --32 -o interruptstubs.o interruptstubs.s interruptstubs.s: Assembler messages: interruptstubs.s: Warning: конец файла не в конце строки; вставлен символ новой строки interruptstubs.s:22: Error: bad register name `%0x20+IRQ_BASE' interruptstubs.s:23: Error: bad register name `%0x21+IRQ_BASE' Makefile:12: ошибка выполнения рецепта для цели «interruptstubs.o» make: *** [interruptstubs.o] Ошибка 1 sergey@COMPUTER:~/Рабочий стол/myOS_8.0T$ 

What is my mistake, please tell me, thanks in advance

  • What did you mean by movb %\num + IRQ_BASE, (interruptnumber) mov commands should operate with at least one register. there is no register here. And even if %\num suddenly turns out to be a register, then movb eax+IRQ_BASE, x cannot be the same, register names cannot be added with anything. If there was a reference to an address contained in the register, then where the square brackets are Mike
  • @Mike please tell me where there should be square brackets, please give an example - Sergey
  • First, tell me what you want to do. Square brackets are needed when you are going to put the value at the address located in the register. But you basically have no register there. So maybe you need something completely different - Mike
  • This file prints a message from the cpp file in a place with a kernel which is also written on cpp but this is not a boot loader there is a short work with interruptions if everything works well then a message from kernel.cpp should come out and from this cpp file I published - Sergey
  • one
    On video tutorials, you still do not learn anything. We must read the technical literature, understand the principles of the processor. Examine the assembler. After that, you can try to write something, at least knowing what you are doing. The likelihood that something will work as it should after the video tutorial is very small and even if it works, but you will not understand every line written, there will be no good for you from this - Mike

1 answer 1

Look at line number 8:

 .global _ZN16InterruptManager22IgnoreInterruptRequestEv: 

Look at the error message:

 interruptstubs.s:8: Error: junk at end of line, first unrecognized character is `:' 

You are told that at the end of the line declaration of a global symbol, a colon is not needed.

  • This is the only mistake, but what about IRQ_BASE - Sergey
  • Now I will try as you advise @zed - Sergey
  • @ Sergey I can not say anything about the remaining errors. - zed
  • Thanks @zed I corrected the error about the colon, it disappeared - Sergey