init.asm:
Code: Select all
global init
; some useful macro values
FLAGS equ 0 ; this is the multiboot 'flag' field
MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header
CHECKSUM equ -(MAGIC + FLAGS); checksum required
STACKSIZE equ 0x4000 ; 16 KiB for stack
section .text
align 4
; setting multiboot header
multiboot_header:
dd MAGIC
dd FLAGS
dd CHECKSUM
init:
hlt ;It was code calling kernel here.
jmp init
section .bss
align 4
stack:
resb STACKSIZE ; reserve stack space
Code: Select all
#!/bin/bash
nasm -f elf32 init.asm -o init.o
x86_64-elf-ld -T init.ld init.o -o init.bin -nostdlib -melf_i386
mkdir iso
cd iso
mkdir boot
cd boot
mkdir grub
cd ..
cd ..
cp init.bin iso/boot/grub
rm init.bin
cd iso
cd boot
cd grub
touch grub.cfg
printf "menuentry \'MY OS\' {\nmultiboot /boot/grub/init.bin\n}" > grub.cfg
cd ..
cd ..
cd ..
grub-mkrescue -o init.iso iso
rm -r iso
Code: Select all
nasm -f elf64 init.asm -o init.o
x86_64-elf-ld -T init.ld init.o -o init.bin -nostdlib
Code: Select all
nasm -f elf32 init.asm -o init.o
x86_64-elf-ld -T init.ld init.o -o init.bin -nostdlib -melf_i386
Code: Select all
qemu-system-x86_64 -hda init.iso