Page 1 of 1

Printing a string directly to the video memory

Posted: Sun Dec 18, 2016 10:31 am
by leosa99
Hi !
I made a function to print the SI register on the screen directly through the video memory.
It's weird but this function only write the first character ...

Code: Select all

writeCharacterToVideoMemoryFunc: ; al=character ah=attributes cx=offset(byte)
mov esi, 0xB8000
add si, cx
mov byte [esi], al
mov byte [esi+1], ah
ret

writeSIToVideoMemory: ; cx=offset
mov al, [si]
cmp al, 0
je end
mov ah, 00001111b
call writeCharacterToVideoMemoryFunc
inc si
add cx, 2d ; inc cx 2 times
jmp writeSIToVideoMemory
end:
ret
I call it with this code :

Code: Select all

mov si, MSG
mov cx, 40d
call writeSIToVideoMemory
jmp $

MSG: db "OK !", 0
I run it in protected mode.
Thanks !

Re: Printing a string directly to the video memory

Posted: Sun Dec 18, 2016 10:34 am
by iansjack
Your WriteCharacter routine trashes SI, which is going to cause problems.

Re: Printing a string directly to the video memory

Posted: Sun Dec 18, 2016 11:09 am
by leosa99
I'm dumb.
Thanks