Compare commits

..

No commits in common. "73611cde09c842afd2085a6ac92090f5cc852e45" and "a816b63ffe0e95aea1890e23fe11052f96f790f7" have entirely different histories.

3 changed files with 9 additions and 10 deletions

View File

@ -1,12 +1,12 @@
SRCS = boot.c SRCS = boot.c
LDFLAGS = -flto -T linker.ld -nostdlib LDFLAGS = -melf_i386 -nostdlib --oformat binary -T linker.ld
CFLAGS = -flto -ffreestanding -fno-builtin -fno-pie -Wall -std=c2x -m16 -nostdlib -Os -nostartfiles -r CFLAGS = -fno-pie -Wall -std=c2x -m16 -nostdlib -Os -nostartfiles
%.o: %.c %.o: %.c
$(CC) $^ -o $@ $(CFLAGS) $(CC) $(CFLAGS) $^ -c -o $@
all: $(SRCS:.c=.o) all: $(SRCS:.c=.o)
$(CC) $(LDFLAGS) -o bin $^ $(LD) $(LDFLAGS) -o bin $^
clean: clean:
$(RM) $(SRCS:.c=.o) bin $(RM) $(SRCS:.c=.o) bin

8
boot.c
View File

@ -1,5 +1,5 @@
inline void putchar(char); void putchar(char);
inline void write(char*); void write(char*);
void _start(void) { void _start(void) {
write("Hello World!\r\n\0"); write("Hello World!\r\n\0");
@ -7,12 +7,12 @@ void _start(void) {
; ;
} }
inline void write(char *out) { void write(char *out) {
for (char *i = out; *i != 0; i++) for (char *i = out; *i != 0; i++)
putchar(*i); putchar(*i);
} }
inline void putchar(char out) { void putchar(char out) {
__asm__ volatile ( __asm__ volatile (
"movb $0x0e, %%ah;" "movb $0x0e, %%ah;"
"movb %0, %%al;" "movb %0, %%al;"

View File

@ -1,10 +1,9 @@
ENTRY (_start) ENTRY (_start)
OUTPUT_FORMAT (binary) OUTPUT_FORMAT (binary)
OUTPUT_ARCH(i386)
SECTIONS SECTIONS
{ {
. = 0x7c00; . = 0x7c00;
.text : { .text : { boot.o(.text)
*(.text) *(.text)
} }
.rodata : { *(.rodata) .rodata : { *(.rodata)