Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
#!/bin/bash
nasm -f bin boot.asm -o boot.bin
gcc -m32 -c -ffreestanding main.c -o main.o
gcc -m32 -c -ffreestanding video.c -o video.o
# Link files to kernel.elf using GCC rather than LD
gcc -m32 -Tlink.ld -fno-PIE -nostartfiles main.o video.o -o kernel.elf
objcopy -R .note -R .comment -S -O binary kernel.elf kernel.bin
# Make disk image size of 1.44MiB floppy
dd if=/dev/zero of=disk.img bs=1024 count=1440
dd if=boot.bin of=disk.img conv=notrunc
dd if=kernel.bin of=disk.img seek=1 conv=notrunc
This should compile each individual file, link them to an executable called kernel.elf and that executable is converted into a binary file call kernel.bin. I also simplify creating a disk image (I chose a nominal floppy disk size of 1.44MiB). Bootloader in first sector and kernel starting in second sector.
It works fine with qemu but the problem with printing is still there. Am I setting up the stack incorrectly?
As I stated in a previous comment the real mode stack code you are asking about looks fine. Can you show us C code with a string that doesn't print properly? Also remember that writing to video memory directly a string of 2000 characters will stop at 2000 and there is no automatic screen scrolling like you'd get with the BIOS. You'd have to code that yourself.
MichaelPetch wrote:As I stated in a previous comment the real mode stack code you are asking about looks fine. Can you show us C code with a string that doesn't print properly? Also remember that writing to video memory directly a string of 2000 characters will stop at 2000 and there is no automatic screen scrolling like you'd get with the BIOS. You'd have to code that yourself.
It seems to work now! I didn't change AL back to 0x0A (I set it back to 0x02). Thank you all for the support =D