This BIOS.WriteCharacterWithAttribute function 09h does not advance the cursor. You can use the BIOS.Teletype function 0Eh for that purpose.
Since the BIOS.WriteCharacterWithAttribute function 09h uses the CX
register for a repetition count, it will be best to not use CX
for a loop counter. Below code use DI
. This code also avoids using the LOOP
instruction which is infamous for being slow! See Why is LOOP so slow?.
;print screen
mov di, 45
mov si, -1
mov cx, 1 ; Repetition count
mov bx, 0034h ; DisplayPage 0, Color RedOnCyan
TheLoop:
inc si
mov al, msg3[si]
mov ah, 09h
int 10h
mov ah, 0Eh
int 10h
dec di
jnz TheLoop
It is possible to use the offset SI
by which we address the characters as our loop counter. In a string that has 45 characters, the very last character will be at offset 44, so that's the value we need to have reached at loop exit:
;print screen
mov si, -1
mov cx, 1 ; Repetition count
mov bx, 0034h ; DisplayPage 0, Color RedOnCyan
TheLoop:
inc si
mov al, msg3[si]
mov ah, 09h
int 10h
mov ah, 0Eh
int 10h
cmp si, 44
jne TheLoop
One further improvement would start the offset SI
at 0, using the one byte shorter encoding of xor si, si
. This influences the way we need to check for the loop exit!
;print screen
xor si, si
mov cx, 1 ; Repetition count
mov bx, 0034h ; DisplayPage 0, Color RedOnCyan
TheLoop:
mov al, msg3[si]
mov ah, 09h
int 10h
mov ah, 0Eh
int 10h
inc si
cmp si, 45
jb TheLoop
And instead of using a fixed count for the string length, you could also easily use a string terminator like zero.
;print screen
xor si, si
mov cx, 1 ; Repetition count
mov bx, 0034h ; DisplayPage 0, Color RedOnCyan
TheLoop:
mov al, msg3[si]
test al, al
jz Done
mov ah, 09h
int 10h
mov ah, 0Eh
int 10h
inc si
jmp TheLoop
Done:
...
msg3 db "-- WELCOME TO E-VOTING MANAGEMENT SYSTEM --", 0