accessing segments

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
sancho1980
Member
Member
Posts: 199
Joined: Fri Jul 13, 2007 6:37 am
Location: Stuttgart/Germany
Contact:

accessing segments

Post by sancho1980 »

hi

i have a simple question: ive now written some code that boots the pc, switches over to protected mode and then jumps to some other code writen in c...before jumping there i loaded the ds register with a segment descriptor pointing to b8000 so that when in my c code i do something like

Code: Select all

char *video=0;

*video='A'
the letter A is displayed in the upper left corner. but of course there are 3 more segment registers (es, fs, gs) that *could* be used for video memory instead of having main data register ds point to video memory...is there any way at all to specify in c that for this or that particular memory reference another data register be used, so i can make use of all the 4 data registers without having to refer to assembly???

thanks

martin
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Well the simple answer is no. GCC assumes that all segment registers are the same and that they are all have a base of zero IIRC.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re: accessing segments

Post by Candy »

sancho1980 wrote:is there any way at all to specify in c that for this or that particular memory reference another data register be used, so i can make use of all the 4 data registers without having to refer to assembly???
C is a platform-independant language. It does not allow for paging nor for segmentation. Paging is wrt this transparent, but segmentation just isn't going to work. There is a part-hack called __thread that allows something like this but I haven't looked into what's generated and/or whether it even works. I think it's FS or GS based access to variables but I'm not quite sure how they're allocated.
Post Reply