Video memory and Real Mode ?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
R2_
Member
Member
Posts: 50
Joined: Sat Dec 02, 2006 3:27 pm

Video memory and Real Mode ?

Post 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
Gizmo
Member
Member
Posts: 41
Joined: Fri Aug 03, 2007 3:41 am

Post 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
R2_
Member
Member
Posts: 50
Joined: Sat Dec 02, 2006 3:27 pm

Post 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'
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Try

Code: Select all

	mov ax,0xB800
	mov es,ax
	mov byte [es:0],'a'
R2_
Member
Member
Posts: 50
Joined: Sat Dec 02, 2006 3:27 pm

Post 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.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post 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
R2_
Member
Member
Posts: 50
Joined: Sat Dec 02, 2006 3:27 pm

Post 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.
Post Reply