Here is my code:
Code: Select all
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
; The Multiboot header (in NASM syntax)
align 4
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd CHECKSUM
section .data
BootMessage db "Booting ....", 0
BootMessageLength equ $ - BootMessage
section .text
global _start
_start:
xor ax, ax
mov es, ax
mov ds, ax
mov ss, ax
mov bp, BootMessage
mov cx, BootMessageLength
mov ax, 01301h
mov bx, 000Eh
mov dl, 0
int 10h
jmp $
Code: Select all
nasm -f elf -o kernel.o kernel.s
ld -s -Ttext 0x30400 -o kernel.elf kernel.o
kernel.o(.text+0x15): In function '_start':
kernel.s:relocation truncated to fit:R_386_16 against '.data'
Then, I change the link command to this:
Code: Select all
nasm -f elf -o kernel.o kernel.s
ld -s -Ttext 0 -o kernel.elf kernel.o
I copy the elf file to floppy, ready to use grub to load it to memory.
Here is the grub command I use:
Code: Select all
root (fd0)
kernel /boot.elf
Error 7: Loading below 1MB is not supported.
I am so confusing about these.
Why can not use the flag '-Ttext 0x30400' when I link the program?
Why grub say 'Loading below 1MB is not supported'?
Please help me. Thanks.
[Edit by AJ - Code Tags Added]