About the barebones tutorial

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
xtricman
Posts: 16
Joined: Wed Mar 12, 2014 9:52 pm

About the barebones tutorial

Post by xtricman »

Why can we write to 0xB8000,Isn't the code segment is read-only?
User avatar
Bender
Member
Member
Posts: 449
Joined: Wed Aug 21, 2013 3:53 am
Libera.chat IRC: bender|
Location: Asia, Singapore

Re: About the barebones tutorial

Post by Bender »

So you mean 0xB8000 is a code segment? Hmmm..... :roll:
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: About the barebones tutorial

Post by Combuster »

xtricman wrote:Isn't the code segment is read-only?
Why do you think you're actually using the code segment for a data access?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: About the barebones tutorial

Post by SpyderTL »

0xb8000 is the default screen buffer memory address. It contains character and color information. There is no code there, only data.
xtricman
Posts: 16
Joined: Wed Mar 12, 2014 9:52 pm

Re: About the barebones tutorial

Post by xtricman »

Combuster wrote:Why do you think you're actually using the code segment for a data access?
OK,but how can I know where's data where's code? At first I think when I use reference to memory like C pointer or assembly (%eax)it's using the %DS register by default, and when I use pop or push instruction it's using %SS as the selector, but when I use " movl $32 $start" and debug the kernel, I found it also worked.My code at start is overwrited .Why?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: About the barebones tutorial

Post by Combuster »

OK,but how can I know where's data where's code?
It's always where you left it. It just appears to be a mess because you aren't conciously aware of where you left it.

Memory may be used for everything, it it can only hold one thing at a time. You can't turn a plot of land into both an apartment complex and a park at the same time.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: About the barebones tutorial

Post by sortie »

Your linker script decides where the various sections end up as segments (ELF segments, not x86 hardware segments).

Inspect your ELF kernel with tools such as objdump and readelf.
Post Reply