I am programming a boot loader, the boot sector has already handed over to the second stage. From now on, I am programming in C instead of programming everything in x86 assembly. My final goal is to make something simpler than u-boot but something that can look at the multiboot header and launch the kernel. Most of the operation are done in real mode.
I am struggling with this piece of code. I aim at waiting a key stroke and getting the corresponding ASCII char that was pressed.
#include "keyboard.h"
char keyboard_getc(void)
{
char user_input;
wait_keystroke:
__asm__ __volatile__ goto ("clc;"
"movb %[bios_service], %%ah;"
"int $0x16;"
"jnc %l[wait_keystroke];"
"movb %%al, %[char_input]"
: [char_input] "=rm" (user_input)
: [bios_service] "r" (0x00)
: "%ax", "cc"
: wait_keystroke
);
return user_input;
}
The compiler is insulting me as below :
i386-elf-gcc -std=c99 -DDEBUG -O1 -c -g -march=i386 -m16 -ffreestanding -Wall -W -I../inc -o keyboard.o keyboard.c
keyboard.c: In function ‘keyboard_getc’:
keyboard.c:13:34: error: expected ‘:’ before ‘[’ token
: [char_input] "=rm" (user_input)
^
keyboard.c:7:1: warning: label ‘wait_keystroke’ defined but not used [-Wunused-label]
wait_keystroke:
^
make: *** [keyboard.o] Error 1
I tried to follow this documentation https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html but I didn't find the answer.
Does somebody have an idea why ?