简体   繁体   中英

16-bit C code compiled with GCC

How do I compile 16-bit C code with GCC? I am trying to write a flat bootloader that just writes "Hello World!" to the computer and halts.

int main(int argc, char** argv)
{
    char* value = "Hello World!";
    __asm
    {
        mov si, value
    loop:
        lodsb
        cmp al, 0
    halt:
        je halt
        mov bx, 0x0007 ; Black BG, White TXT
        mov ah, 0x0E   ; Teletype output
        int 0x10
        jmp loop
    }
 }

You don't. You can't. GCC doesn't generate 16-bit x86 code.

Use Open Watcom C/C++ or the ancient Turbo C++ (v 1.01 is freely available online).

It is possible to write 16 bit boot-loader , kernel in c . You need to put .code16 or .code16gcc at the top of the file to tell the compiler to generate 16 bit object file .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM