OSDev.org

The Place to Start for Operating System Developers
It is currently Fri May 26, 2017 7:00 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Printing a string directly to the video memory
PostPosted: Sun Dec 18, 2016 10:31 am 
Offline

Joined: Tue Aug 30, 2016 9:34 am
Posts: 15
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 !


Top
 Profile  
 
 Post subject: Re: Printing a string directly to the video memory
PostPosted: Sun Dec 18, 2016 10:34 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 2792
Location: Chichester, UK
Your WriteCharacter routine trashes SI, which is going to cause problems.


Top
 Profile  
 
 Post subject: Re: Printing a string directly to the video memory
PostPosted: Sun Dec 18, 2016 11:09 am 
Offline

Joined: Tue Aug 30, 2016 9:34 am
Posts: 15
I'm dumb.
Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group