Author Topic: Stupid question to ask  (Read 10325 times)

Offline Inventrix

  • New Member
  • Posts: 1
Stupid question to ask
« on: April 14, 2012, 03:49:56 PM »
Hello All,

I'm newbie on NASM. I'm trying to understand the 64 bit system.
I saw that we have AX,EAX,RAX. 16bits,32bits,64bits.

I find es. What is the 64bits of that.
I try to find information about it but could not.

What I tried to achieve is a full 64 bits. I may not understand correctly the process because I tried to used only R!! command. No AX or ES or EAX.
It maybe not possible.

Thanks for helping me sort this out.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Stupid question to ask
« Reply #1 on: April 15, 2012, 12:13:50 AM »
It's not a stupid question. Fortunately, the answer is good news.

cs, ds, es, and on 386+, fs and gs are "segment registers" - different instructions from "general purpose registers". They are 16-bit registers, in all cases. In combination with an "offset", they form a complete address.

In real mode, the value in a segment register is multiplied by 16 (shifted left 4 bits) and added to an offset to form a complete address.

The CPU is switched to protected mode by setting bit 0 in the "control register", cr0. At this point, the rules change. The value in a segment register serves as an index into a table of descriptors. One of the fields in these descriptors is the "base", which is added to an offset to form a complete address. In any OS you're likely to encounter, the "base" is zero, so the offset is the address. There's an exception to this: fs is used for "thread local storage". Worry about that when you get to it. :)

Unless you're writing your own OS, the OS will have done this for you. You don't need to mess with segment registers - probably not even allowed to! Segment registers still exist, and they're still 16-bit registers, but (unless you're writing your own OS) you can forget that they exist. Trust me, that's "good news"!

Best,
Frank