Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 288
airplaneman19 Avatar asked Mar 06 '26 08:03

airplaneman19


2 Answers

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.

like image 52
Christian Stieber Avatar answered Mar 07 '26 22:03

Christian Stieber


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.

like image 21
Earlz Avatar answered Mar 07 '26 21:03

Earlz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!