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.
;**********************ssbootloader.s**********************;
; The second stage bootloader
BITS 16
section .data
greeting db 'Bootloader has loaded', 13, 10, 0
section .text
global ssblstart
ssblstart:
; set up stack pointer
mov ax, 0x7BFF
mov sp, ax
mov bp, sp
mov si, greeting
call printString
hlt
printString:
lodsb ; Load character of string
or al, al ; Check to see if al is zero
jz psreturn
mov ah, 0x13
int 0x10
jmp printString
psreturn:
ret
It compiles fine, but when linked I get the error " In function `ssblstart':
ssbootloader.s:(.text+0x8): relocation truncated to fit: R_386_16 against `.data' "
When I comment out the mov si, greeting it links fine. I checked around, and it seems that most of the time when there is this problem it's because someone is using 32 bit code in 16 bit mode, or visa-versa. This is all 16 bit code though...
To be precise, its caused by people using 32-bit addresses in real mode. Your linker is just saying you're stupid because you're using an address that's not between 0 and 64KB and thus won't fit in a 16-bit register. Fix that.
You might want to assemble directly to a binary instead of using LD in the process, which might help you get rid of unneeded complexity.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]