Page 1 of 1

Video memory and Real Mode ?

Posted: Fri Aug 17, 2007 9:15 am
by R2_
Is it possible to write to address 0x0b800 (text/video memory) on real mode ? or do I need to switch to protected mode ?
Thanks in advance :D

Posted: Fri Aug 17, 2007 9:30 am
by Gizmo
yes

use

Code: Select all

mov byte [B800h:0], 'a'
where B800h is the segment and offset is 0
because in real mode addresses are segment shifted left 4 bits + offset
shifting left 4 bits is the same thing as multiplying by 10h (16 in decimal)
800h shifted left by 4 becomes B8000h + offset 0
(B800h*10h)+0h=B8000h

Code: Select all

mov ds, B800h
mov byte [0], 'a'
^same thing as above

Posted: Fri Aug 17, 2007 10:08 am
by R2_
Gizmo wrote:yes

use

Code: Select all

mov byte [B800h:0], 'a'
where B800h is the segment and offset is 0
because in real mode addresses are segment shifted left 4 bits + offset
shifting left 4 bits is the same thing as multiplying by 10h (16 in decimal)
800h shifted left by 4 becomes B8000h + offset 0
(B800h*10h)+0h=B8000h

Code: Select all

mov ds, B800h
mov byte [0], 'a'
^same thing as above
Ah, thanks :P I knew It was simple but the kernels I have previously coded were already in pmode + I used C. Im attempting to make a real mode OS (Don't care much about the memory limits). So far I managed to make bootsector load the kernel and save itself to HDD.

Edit: after trying that code it says:
error: invalid segment override

the same error I got when I was trying
mov B800h, 'c'

Posted: Fri Aug 17, 2007 10:53 am
by Dex
Try

Code: Select all

	mov ax,0xB800
	mov es,ax
	mov byte [es:0],'a'

Posted: Fri Aug 17, 2007 11:39 am
by R2_
Dex wrote:Try

Code: Select all

	mov ax,0xB800
	mov es,ax
	mov byte [es:0],'a'
ye thats what I tried in the first place and it did compile but I don't see the character even after adding the attribute byte

Code: Select all

mov ax,0xB800
	mov es,ax
	mov byte [es:0],'a'
mov ax,0xB800
	mov es,ax
	mov byte [es:1],07h
Ill try to see if the info is on video memory and then I'll report back here and ask again.

btw Dex terrific job you've done with DexOS

edit: hehe.. im such an idiot my original code or the one Dex posted was working but I missed it on the screen.. I need to get myself some glasses eh ?

Thanks guys.

Posted: Fri Aug 17, 2007 5:03 pm
by Dex
I have done that myself :lol: and thanks for comment on DexOS.
As a side note, i written a small realmode OS, as a OS tut, it's open source and fully commented, it a basic Dos clone, that can run some old Dos games.
The idea is everyone that leans from it, can add another int 21h function, or it may help you with your OS.
Its called MiniDos you can get it here: http://board.flatassembler.net/topic.php?t=5275&start=0

Posted: Fri Aug 17, 2007 5:11 pm
by R2_
Dex wrote:I have done that myself :lol: and thanks for comment on DexOS.
As a side note, i written a small realmode OS, as a OS tut, it's open source and fully commented, it a basic Dos clone, that can run some old Dos games.
The idea is everyone that leans from it, can add another int 21h function, or it may help you with your OS.
Its called MiniDos you can get it here: http://board.flatassembler.net/topic.php?t=5275&start=0
Ye that will definitely come in useful... A DOS clone is exactly what Im attempting to write but I failed to find any source code (not that I looked for more than 10 minutes, I'll admit to that) that might tell me how the internal workings tick on DOS.

Thanks again.