airplaneman19
airplaneman19

Reputation: 1159

Assembly Newlines

I've written a simple bootloader in Assembly (NASM syntax), however when I run it in QEMU, the newlines show up like this:

enter image description here

This is my code:

Is there a way to stop 0Ah from pushing the lines forward?

.loop_top:

mov si, text_string ; Put string position into SI
call print_string   ; Call our string-printing routine

loop .loop_top

jmp $           ; Jump here - infinite loop!


text_string db "This is my cool new OS!", 0Ah, 0

Upvotes: 2

Views: 1759

Answers (2)

Earlz
Earlz

Reputation: 63915

I believe that sending a \r will make the cursor return to the left side of the screen. So, you should use \r\n or something similar to make new lines.

I'm not sure without more details. I'm not for sure how your print_string procedure is implemented. If implemented by BIOS calls, such as by cycling through the string using int 0x10, AH=0x0E, then the above solution will work, or you can do something like using int 0x10, AH=0x03 to adjust the cursor position manually.

Upvotes: 2

Christian Stieber
Christian Stieber

Reputation: 12496

Well, obviously :-) your "print_string" subroutine takes the 0x0a seriously -- it's called "LF", and it does just that, advances to the next line.

My guess is that using 0x0a 0x0d will do the trick.

Upvotes: 12

Related Questions