LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 07-09-2011, 08:01 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,276

Rep: Reputation: 49
Initializing the SS register (Intel architecture) in as.


Kernel 2.6.21.5, slackware 12.0
as 2.17

Hi:
[I am speaking here about 80x86 processors, with their segment registers SS, DS, CS, ES.]

In a source file for as, I wrote
Code:
.section   _STACK
         .rept   4096
         .word   0
         .endr
Now, in the .text section, I want to initialize SS, the stack segment, to point to the _STACK section. In other assemblers, there was a special section for the stack, and the linker cared about initializing SS. Here I use a common section for the stack. For a segment such as DS, I could write
mov ax,_DATA
mov ds,ax

But I don't think mov ax,_STACK would do with as/ls. So the question is: how do I initialize SS?
 
Old 07-10-2011, 11:36 AM   #2
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 217

Rep: Reputation: 21
The next question is :
Why do you want to initialize a stack?
- Are you programming the kernel? - because only that can do it (setup SS framework before switching to PM ).
- Or do you mean to allocate some bytes on the heap with ENTER ? (that can ld make for you in section bss)

Think about that you are in PM.
 
Old 07-10-2011, 12:12 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,276

Original Poster
Rep: Reputation: 49
Not programming the kernel. Rather the second thing you said. But I've learned in linux the flat memory model is used. So both assembler and linker assume flat memory. I am wondering now about SP. I presume the linker will take care of it. Thanks for your reply.
 
Old 07-29-2011, 07:14 PM   #4
TimothyEBaldwin
Member
 
Registered: Mar 2009
Posts: 249

Rep: Reputation: 27
Stack sections are not used in Linux, the kernel initialises CS, DS, ES, SS and ESP to suitable values before starting an executable. ESP is set to a somewhat random value near the top of address space.
 
1 members found this post helpful.
Old 07-31-2011, 01:56 AM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,276

Original Poster
Rep: Reputation: 49
Thank you very much for this valuable information. Regards.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
debian 5.0 for intel x86 architecture means 32 bit OS ? duperret Linux - Newbie 1 02-22-2010 04:26 AM
What is purpose of PID register in PowerPC architecture? shreshtha General 3 02-15-2010 08:37 PM
LXer: Initializing Memory Efficiently on Power Architecture Platforms LXer Syndicated Linux News 0 05-25-2006 08:54 PM
intel architecture dnlds work for athlon? mkuoppala Linux - Newbie 1 08-31-2003 04:10 AM
Solaris on Intel architecture subhasis_ray Solaris / OpenSolaris 3 05-02-2002 03:12 PM


All times are GMT -5. The time now is 12:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration