I have been learning how to write bootable programs in assembly x86 in real mode for a couple weeks, but I wasn't able to make any big progress, sice I could't find on my own any free good course in bare metal programming for x86 cpu-s in assembly. Therefore I am attempting to learn through trial and error, but the more I try the more I go wrong. Today I was trying to understand how to handle stack and how to build a function in real mode using AT&T assemby, and I wrote this code, thinking it made sense:
.code16
.global init
# PRINT SI
print:
push %bp
mov %sp, %bp
sub $16, %sp
pusha
mov $0xe, %ah
print_char:
lodsb
cmp $0, %al
je print_end
int $0x10
jmp print_char
print_end:
popa
mov %bp, %sp
pop %bp
ret
init:
mov $msg, %si
call print
hlt
msg: .asciz "Test number one..."
.fill 510-(.-print), 1, 0
.word 0xaa55
It should print "Test number one..." on the screen, but using qemu it prints just "S" on the screen, like this:
Can someone figure out where did I go wrong and why?