Created
January 19, 2017 16:59
-
-
Save davidejones/233abdd393add4ff157c9b565c76821b to your computer and use it in GitHub Desktop.
mingw gcc dos compile (thanks to http://nullprogram.com/blog/2014/12/09/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| asm (".code16gcc\n" | |
| "call dosmain\n" | |
| "mov $0x4C,%ah\n" | |
| "int $0x21\n"); | |
| static void print(char *string) | |
| { | |
| asm volatile ("mov $0x09, %%ah\n" | |
| "int $0x21\n" | |
| : /* no output */ | |
| : "d"(string) | |
| : "ah"); | |
| } | |
| int dosmain(void) | |
| { | |
| print("Hello, World!\n$"); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CFLAGS = -std=gnu99 -Wall -Wextra -Os -nostdlib -m32 -march=i386 \ | |
| -Wno-unused-function \ | |
| -ffreestanding -fomit-frame-pointer -fwrapv -fno-strict-aliasing \ | |
| -fno-leading-underscore \ | |
| -Wl,--nmagic,-static,-Tmingw.com.ld | |
| all: | |
| gcc $(CFLAGS) -o hello.o hello.c | |
| objcopy -O binary hello.o hello.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SECTIONS | |
| { | |
| . = 0x0100; | |
| .text : | |
| { | |
| *(.text); | |
| } | |
| .data : | |
| { | |
| *(.data); | |
| *(.bss); | |
| *(.rodata); | |
| } | |
| _heap = ALIGN(4); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No problem!