11
Ноя
2021

i386-elf-gcc ошибка assembler

Простейший код:

void main() {
    char* vidmem = (char*)0xb8000;
    *vidmem = "X";
}

Компилирую строкой

i386-elf-gcc -ffreestanding -с ./c/kernel.c -o ./kernel.с

И тут ошибка:

C:/Users/aga/AppData/Local/Temp/cczCv3fT.s: Assembler messages:
C:/Users/aga/AppData/Local/Temp/cczCv3fT.s:7: Warning: .type pseudo-op used outside of .def/.endef: ignored.
C:/Users/aga/AppData/Local/Temp/cczCv3fT.s:7: Error: junk at end of line, first unrecognized character is `m'
C:/Users/aga/AppData/Local/Temp/cczCv3fT.s:11: Error: invalid instruction suffix for `push'
C:/Users/aga/AppData/Local/Temp/cczCv3fT.s:29: Warning: .size pseudo-op used outside of .def/.endef: ignored.
C:/Users/aga/AppData/Local/Temp/cczCv3fT.s:29: Error: junk at end of line, first unrecognized character is `m'

Я посмотрел что генерирует компилятор:

    .file   "kernel.c"
    .section    .rodata
.LC0:
    .string "X"
    .text
    .globl  main
    .type   main, @function
main:
.LFB0:
    .cfi_startproc
    pushl   %ebp
    .cfi_def_cfa_offset 8
    .cfi_offset 5, -8
    movl    %esp, %ebp
    .cfi_def_cfa_register 5
    subl    $16, %esp
    movl    $753664, -4(%ebp)
    movl    $.LC0, %eax
    movb    %al, %dl
    movl    -4(%ebp), %eax
    movb    %dl, (%eax)
    nop
    leave
    .cfi_restore 5
    .cfi_def_cfa 4, 4
    ret
    .cfi_endproc
.LFE0:
    .size   main, .-main
    .ident  "GCC: (GNU) 5.2.0"

Источник: https://ru.stackoverflow.com/questions/1348439/i386-elf-gcc-%D0%BE%D1%88%D0%B8%D0%B1%D0%BA%D0%B0-assembler

Тебе может это понравится...

Добавить комментарий