News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Printing with SI - how is it done??

Started by gladi8r, April 19, 2008, 09:53:55 AM

Previous topic - Next topic

gladi8r

I was just wondering... How might you print text to the screen with the si register? I'm not sure how to do it.
Thanks.
--Gladi8r

MichaelW

Posting a question twice will not help you get an answer. Your original question made no sense. Interrupt 10h, function 0 is for setting the video mode, not displaying on the screen, and the BIOS video functions that display on the screen do not use SI.

If you must use a BIOS display function, I suggest the Teletype Output function (AH = 0Eh) because it takes care of advancing the cursor and scrolling the screen, and will treat CR and LF as control characters:

http://www.ctyme.com/intr/rb-0106.htm

For indirect memory operands in 16-bit code only four registers are allowed, BP, BX, SI, and DI. To load the address of a message defined in the data section into SI you can use:

mov si, offset message

You can call the function in a loop, passing one character of the message in each loop. The function expects the character to write in AL. Assuming that SI has the address of the message, you can copy the addressed character to AL and advance SI to the next character with:

mov al, [si]
inc si

Or with the single instruction:

lodsb

You need some way to know when you have reached the end of the message. One common method would be to add a null byte to the end of the message:

message db "hello",13,10,0

You could then test the value loaded into AL and exit the loop when you reach the null.
eschew obfuscation