I want to create a print function i x86 Assembly(NASM)to print a string to the terminal without using any OS(i.e. without any syscall).
I wrote the following code so far:
main.asm
[org 0x7c00] ; load our boot sector here
%include "print_function.asm" ; the print function is declared outside this file
mov bx, msg ; mov the message to BX
call print ; call the print function
jmp $ ; hang
msg:
db "Hello World!", 0 ; our string
times 510-($-$$) db 0 ; padding
dw 0xaa55 ; magic number
print_function.asm
print:
pusha ; push all register to the stack before anything lese
mov ah, 0x0e ; tty mode
int 0x10 ; print to the screen(with an interrupt)
popa ; pop all the values
ret ; return to the caller
The problem is that when i open run the binary file it prints a character('U') and nothing more.
So what is the problem with this code?
And what can i do to fix it?