All of lore.kernel.org
 help / color / mirror / Atom feed
* Segment override and lldt instruction
@ 2007-05-30 22:31 A D
  2007-05-31  0:45 ` Frank Kotler
  0 siblings, 1 reply; 7+ messages in thread
From: A D @ 2007-05-30 22:31 UTC (permalink / raw)
  To: linux-assembly

Hi! I have couple of questions regarding gnu assembly. I've heard the word
segment override. Where segment register can be manually overriden. so how 
can i
override say ds register? can segment register be overriden to my preferred
memory address location?

mov $0xf800, %ax
mov %ax, %es
mov %ds, %bx

But I get segmentation fault error. How can i do it without error?

Also I was looking at the function of lldt instruction. The manual says 
that:
"The source operand (a general-purpose register or a memory location)
contains a segment selector that points to a local descriptor table (LDT)."

How can one make segment selector point to ldt?

Thanks for your time.

_________________________________________________________________
New Windows Live Hotmail is here. Upgrade for free and get a better look. 
www.newhotmail.ca?icid=WLHMENCA150


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Segment override and lldt instruction
  2007-05-30 22:31 Segment override and lldt instruction A D
@ 2007-05-31  0:45 ` Frank Kotler
  2007-05-31  1:21   ` A D
  2007-06-04 23:52   ` Hendrik Visage
  0 siblings, 2 replies; 7+ messages in thread
From: Frank Kotler @ 2007-05-31  0:45 UTC (permalink / raw)
  To: A D; +Cc: linux-assembly

A D wrote:
> Hi! I have couple of questions regarding gnu assembly. I've heard the word
> segment override. Where segment register can be manually overriden. so 
> how can i
> override say ds register? can segment register be overriden to my preferred
> memory address location?
> 
> mov $0xf800, %ax
> mov %ax, %es
> mov %ds, %bx
> 
> But I get segmentation fault error. How can i do it without error?

Use a valid selector. You appear to have "heard about" some 16=bit real 
mode stuff that is not true in protected mode. Take a look here:

http://my.execpc.com/~geezer/johnfine/segments.htm

In "Linux assembly", there is no reason you'd *want* to use a segment 
override, or alter a segment register.

> 
> Also I was looking at the function of lldt instruction. The manual says 
> that:
> "The source operand (a general-purpose register or a memory location)
> contains a segment selector that points to a local descriptor table (LDT)."
> 
> How can one make segment selector point to ldt?

"lldt ax" or "lldt [mem]" (16-bits)... I guess. But why? The limit is 
0xffffffff and the base is 0. (Windows uses fs in a way that might be 
"interesting"..._

If you're developing your own OS (using Linux), starting from a 
bootsector - or GRUB - these instructions might be useful, but for 
"Linux assembly", forget that segment registers exist! (and be glad! :)

Best,
Frank


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Segment override and lldt instruction
  2007-05-31  0:45 ` Frank Kotler
@ 2007-05-31  1:21   ` A D
  2007-06-04 23:52   ` Hendrik Visage
  1 sibling, 0 replies; 7+ messages in thread
From: A D @ 2007-05-31  1:21 UTC (permalink / raw)
  To: fbkotler; +Cc: linux-assembly




>Frank Kotler wrote:
>>A D wrote:
>>Hi! I have couple of questions regarding gnu assembly. I've heard the word
>>segment override. Where segment register can be manually overriden. so how 
>>can i
>>override say ds register? can segment register be overriden to my 
>>preferred
>>memory address location?
>>
>>mov $0xf800, %ax
>>mov %ax, %es
>>mov %ds, %bx
>>
>>But I get segmentation fault error. How can i do it without error?
>
>Use a valid selector. You appear to have "heard about" some 16=bit real 
>mode stuff that is not true in protected mode. Take a look here:
>
>http://my.execpc.com/~geezer/johnfine/segments.htm
>
>In "Linux assembly", there is no reason you'd *want* to use a segment 
>override, or alter a segment register.
>
>>
>>Also I was looking at the function of lldt instruction. The manual says 
>>that:
>>"The source operand (a general-purpose register or a memory location)
>>contains a segment selector that points to a local descriptor table 
>>(LDT)."
>>
>>How can one make segment selector point to ldt?
>
>"lldt ax" or "lldt [mem]" (16-bits)... I guess. But why? The limit is 
>0xffffffff and the base is 0. (Windows uses fs in a way that might be 
>"interesting"..._
>
>If you're developing your own OS (using Linux), starting from a bootsector 
>- or GRUB - these instructions might be useful, but for "Linux assembly", 
>forget that segment registers exist! (and be glad! :)
>
>Best,
>Frank
>

Thanks Frank. I was just curious how these things work. Thanks for your
pointer.

_________________________________________________________________
Windows Live Hotmail. Now with better security, storage and features.  
www.newhotmail.ca?icid=WLHMENCA149


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Segment override and lldt instruction
  2007-05-31  0:45 ` Frank Kotler
  2007-05-31  1:21   ` A D
@ 2007-06-04 23:52   ` Hendrik Visage
  2007-06-11  0:33     ` A D
  1 sibling, 1 reply; 7+ messages in thread
From: Hendrik Visage @ 2007-06-04 23:52 UTC (permalink / raw)
  To: Frank Kotler; +Cc: A D, linux-assembly

On 5/31/07, Frank Kotler <fbkotler@verizon.net> wrote:
> A D wrote:
> > Hi! I have couple of questions regarding gnu assembly. I've heard the word
> > segment override. Where segment register can be manually overriden. so
<snip>
> > But I get segmentation fault error. How can i do it without error?
>
> Use a valid selector. You appear to have "heard about" some 16=bit real
> mode stuff that is not true in protected mode. Take a look here:
>
> http://my.execpc.com/~geezer/johnfine/segments.htm

Nice technical discussions ;)

> In "Linux assembly", there is no reason you'd *want* to use a segment
> override, or alter a segment register.

Not while your program and/or data space  fits in 4GB of memory space ;)

Okay, a "perhaps" easier explanation on the differences between
protected and real mode segment registers (Strange I don't recall this
term in SPARC assembly...)

In Realmode, a segment register basically points to the "bottom"/base
of a 2^16 address space. The actuall address is/was calculated as
Segment register*4+register. This does allow for fancy/interesting
wrap around sitautions at the top of memory.

In Protected mode, the Segment Registers are misnommers to be bland,
they should be called Descriptor Table Indeces... ie. the memory
mapping info in inthe Descriptor Table, the Segment REgister just
points to the entry inside the Descriptor table.

-- 
Hendrik Visage

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Segment override and lldt instruction
  2007-06-04 23:52   ` Hendrik Visage
@ 2007-06-11  0:33     ` A D
  2007-06-11  1:14       ` Frank Kotler
  2007-06-11  5:30       ` Brian Raiter
  0 siblings, 2 replies; 7+ messages in thread
From: A D @ 2007-06-11  0:33 UTC (permalink / raw)
  To: hvjunk, fbkotler; +Cc: linux-assembly

>>Frank Kotler wrote:
>>In "Linux assembly", there is no reason you'd *want* to use a segment
>>override, or alter a segment register.
>
>Hendrik Visage wrote:
>Not while your program and/or data space  fits in 4GB of memory space ;)

So please correct my understanding if i'm wrong: it is not possible
or necessary to override segment register in protected mode but one can do
the same thing in real mode. right? So if answer is yes, and if more than 
4GB
of memory space is needed for a program how will segmentation register go
beyond 4gig without override?

_________________________________________________________________
Windows Live Hotmail. Even hotter than before. Get a better look now. 
www.newhotmail.ca?icid=WLHMENCA148


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Segment override and lldt instruction
  2007-06-11  0:33     ` A D
@ 2007-06-11  1:14       ` Frank Kotler
  2007-06-11  5:30       ` Brian Raiter
  1 sibling, 0 replies; 7+ messages in thread
From: Frank Kotler @ 2007-06-11  1:14 UTC (permalink / raw)
  To: A D; +Cc: hvjunk, linux-assembly

A D wrote:
>>> Frank Kotler wrote:
>>> In "Linux assembly", there is no reason you'd *want* to use a segment
>>> override, or alter a segment register.
>>
>>
>> Hendrik Visage wrote:
>> Not while your program and/or data space  fits in 4GB of memory space ;)
> 
> 
> So please correct my understanding if i'm wrong: it is not possible
> or necessary to override segment register in protected mode but one can do
> the same thing in real mode. right?

Right. (In Windows, you might want to do [fs:somevalue] - Windows uses 
fs for "thread local storage"(???) - a descriptor that does *not* have a 
base of 0, and limit is... 64k-1(???)... I think)

> So if answer is yes, and if more 
> than 4GB
> of memory space is needed for a program how will segmentation register go
> beyond 4gig without override?

Dunno. I'll leave that one to Hendrik. :)

Best,
Frank


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Segment override and lldt instruction
  2007-06-11  0:33     ` A D
  2007-06-11  1:14       ` Frank Kotler
@ 2007-06-11  5:30       ` Brian Raiter
  1 sibling, 0 replies; 7+ messages in thread
From: Brian Raiter @ 2007-06-11  5:30 UTC (permalink / raw)
  To: linux-assembly

> So if answer is yes, and if more than 4GB of memory space is needed
> for a program how will segmentation register go beyond 4gig without
> override?

A single process cannot access more than 4GB in 32-bit Linux. Period.
If you need more than 4GB, then you should be using 64-bit Linux.

b

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-06-11  5:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-30 22:31 Segment override and lldt instruction A D
2007-05-31  0:45 ` Frank Kotler
2007-05-31  1:21   ` A D
2007-06-04 23:52   ` Hendrik Visage
2007-06-11  0:33     ` A D
2007-06-11  1:14       ` Frank Kotler
2007-06-11  5:30       ` Brian Raiter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.