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.
; print - print a string
print:
.loop
<----- ROFFLEZ WTF ----->
mov ah,0x0E
int 0x10
<----- If not end of string ----->
jz .loop
ret
db "Hello World"
I need help with this routine. I suppose there's some example kernel that has this routine? I don't want to just copy it though....don't learn anything that way.
;PARAMETERS: char* Txt{SI}
;ALTERED REGISTERS: SI
PrintChars:
push ax
push bx
;Show character using Teletype BIOS function
mov ah,0Eh ; This number is the number of the function in the BIOS to run.
mov bh,0h ; Page number (???)
mov bl,07h ; Text attribute (Background and Foreground colour) 07=Grey on Black
.PrintNextChar:
lodsb ;Load next byte from pointer in SI into AL then advance SI by 1
or al, al
JZ .Return
int 10h ; Call the BIOS video interrupt.
jmp .PrintNextChar ; Put it into a coninuous loop to load characters and show them
.Return:
pop bx ;Restore registers and return
pop ax
ret
You should be able to work this out reasonably easily, but an example of its use is:
I like implementing my functions so that they don't alter the core registers [AX,BX,CX,DX] unless it's returning a value since it makes it easier to recycle code.
I think how they're altered should be immediately obvious via the MOV operations.