MAKE CURRENTLY DOESNT COMPILE I WILL FIX LATER :3333

This commit is contained in:
Conzer 2024-12-02 16:29:12 -05:00
parent d08f4dc2f5
commit d23b4d9c6c
5 changed files with 57 additions and 2 deletions

3
.gitignore vendored
View file

@ -1,2 +1,5 @@
badloader.img
baddos.img
kernel_entry.o
kernel.o
kernel.bin

12
Makefile Normal file
View file

@ -0,0 +1,12 @@
all: bootloader baddos
bootloader:
nasm -f bin main.asm -o badloader.img
kernel:
nasm -f elf kernel_entry.asm -o kernel_entry.o
gcc -m16 -ffreestanding -c kernel.c -o kernel.o
ld -m elf_i386 -T linker.ld --oformat binary kernel_entry.o kernel.o -o kernel.bin
baddos: bootloader kernel
cat badloader.img kernel.bin > baddos.img
clean:
rm -f *.o *.img *.bin

View file

@ -11,7 +11,7 @@ void print(const char* str) {
}
}
void main() {
void kernel_main() {
print("Welcome to BadDOS!\r\n");
print("type something or die:\r\n");
@ -21,4 +21,25 @@ void main() {
print_char(c);
if (c == '\r') print("\r\n");
}
}
char get_char() {
char c;
__asm__ __volatile__(
"mov ah, 0x00;"
"int 0x16;"
"mov %[char], al;"
: [char] "=r" (c)
);
return c;
}
void print_char(char c) {
__asm__ __volatile__(
"mov ah, 0x0E;"
"mov al, %[char];"
"int 0x10;"
:
: [char] "r" (c)
);
}

View file

@ -1,7 +1,11 @@
; wait, WHAT? we have a bad DOS now????? This is absurd! You can't just add a SECOND project into the FIRST project.
[BITS 16]
[ORG 0x7E00]
[GLOBAL start]
[EXTERN kernel_main]
start:
cli

15
linker.ld Normal file
View file

@ -0,0 +1,15 @@
SECTIONS {
. = 0x7E00;
.text : {
*(.text)
}
.data : {
*(.data)
}
.bss : {
*(.bss)
}
}