OSDev.org
https://forum.osdev.org/

Printing a string directly to the video memory
https://forum.osdev.org/viewtopic.php?f=13&t=31090
Page 1 of 1

Author:  leosa99 [ Sun Dec 18, 2016 10:31 am ]
Post subject:  Printing a string directly to the video memory

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:
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:
mov si, MSG
mov cx, 40d
call writeSIToVideoMemory
jmp $

MSG: db "OK !", 0

I run it in protected mode.
Thanks !

Author:  iansjack [ Sun Dec 18, 2016 10:34 am ]
Post subject:  Re: Printing a string directly to the video memory

Your WriteCharacter routine trashes SI, which is going to cause problems.

Author:  leosa99 [ Sun Dec 18, 2016 11:09 am ]
Post subject:  Re: Printing a string directly to the video memory

I'm dumb.
Thanks

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/