Trying to write a puts like subroutine in assembly but failing miserably. I'm using BIOS calls only (I.E. I'm not running another operating system).
The code is using Intel syntax.
What I have so far is:
;
[BITS 32]
[GLOBAL hello_world_asm]
;
; a very basic puts function without the return
;
puts:
; preserve the registers we are about to trample
push eax
push ebx
loop:
lodsb ; load our next character
or al, al ; cmp al, 0
jz end ; jump if 0
mov ah, 0x0E ; write character and attribute to screen
mov bh, 0x00 ; display page 1
mov bl, 0x15 ; what colour the font should be (white)
int 0x10 ; call the BIOS to put our letter on screen
jmp loop
end:
; get those registers back
pop ebx
pop eax
ret ; return to the caller
;
;
;
hello_world_asm:
mov esi, strHW ; point esi to our hello world string
call puts ; call our puts function
ret ; return to the caller
SECTION .data
strHW db "Hello world!", 0x00
I'm using GRUB to load the base code which works fine as I've managed to reboot the system.
If anyone can advise without giving me the answer that'd be great, I've been following some guides I've found but I don't think it's all sunk in yet.