Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __asm__(
- ".code16gcc;"
- "call dosmain;"
- "mov $0x4C, %AH;"
- "int $0x21;"
- );
- void print(char *str)
- {
- __asm__(
- "mov $0x09, %%ah;"
- "int $0x21;"
- : // no output
- : "d"(str)
- : "ah"
- );
- }
- void dosmain()
- {
- // DOS system call expects strings to be terminated by $.
- print("Hello world$");
- }
- OUTPUT_FORMAT(binary)
- SECTIONS
- {
- . = 0x0100;
- .text :
- {
- *(.text);
- }
- .data :
- {
- *(.data);
- *(.bss);
- *(.rodata);
- }
- _heap = ALIGN(4);
- }
- gcc -fno-pie -Os -nostdlib -ffreestanding -m16 -march=i386
- -Wl,--nmagic,--script=simple_dos.ld simple_dos.c -o simple_dos.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement