far and near?

S

Stone Lan

Maybe this is a question,which is about far and near.

I remember that I learn far and near in real mode of X86,but seems
that they have the application in protect mode.Can anybody give me
some instances where the keyword of far and near is applied?

Many thanks.
 
E

Emmanuel Delahaye

Stone Lan avait énoncé :
I remember that I learn far and near in real mode of X86,but seems
that they have the application in protect mode.Can anybody give me
some instances where the keyword of far and near is applied?

Dunno. These keywords doesn't belong to the C-language. You should ask
on a newsgroup dedicated to your platform.
 
K

Keith Thompson

Stone Lan said:
Maybe this is a question,which is about far and near.

I remember that I learn far and near in real mode of X86,but seems
that they have the application in protect mode.Can anybody give me
some instances where the keyword of far and near is applied?

Many thanks.

This is question 19.40d in the latest version of the C FAQ, but it
hasn't appeared in the HTML version yet.

19.40d: What are "near" and "far" pointers?

A: These days, they're pretty much obsolete; they're definitely
system-specific. If you really need to know, see a DOS- or
Windows-specific programming reference.

The C FAQ is at <http://www.eskimo.com/~scs/C-faq/faq.html>. You can
get a compressed copy of the latest plain text version at
<ftp://ftp.eskimo.com/u/s/scs/C-faq/faq.gz>.
 
J

Jussi Jumppanen

Stone said:
Maybe this is a question,which is about far and near.

I remember that I learn far and near in real mode of X86,but seems
that they have the application in protect mode.Can anybody give me
some instances where the keyword of far and near is applied?

Never. These keywords are pretty much obsolete.

They date back to the segmented memory models of the early
Intel 8088, 8086, 80286, 80386 chips and the then 16/32 bit
MS-DOS and Windows operating systems.

Since then the Intel chips have moved to full 32 and 64 bit
and Windows now uses a flat 32 bit memory model.

Jussi Jumppanen
Author of: Zeus for Windows (New version 3.93 out now)
"The C/C++, Cobol, Java, HTML, Python, PHP, Perl programmer's editor"
Home Page: http://www.zeusedit.com
 
R

roman ziak

Stone Lan said:
Maybe this is a question,which is about far and near.

I remember that I learn far and near in real mode of X86,but seems
that they have the application in protect mode.Can anybody give me
some instances where the keyword of far and near is applied?

Many thanks.

Because modern OS' use flat memory model, these extensions are believed
to be obsoleted.

People tend to forget that even modern PC (IA32 platform) implements
and uses not only 32-bit (classic near) but also 48-bit pointers.
Even on Windows: certain OS data structures are addressed through
FS and GS selector registers.

Instances: embedded programming.

Roman
 
D

Dan Pop

In said:
Maybe this is a question,which is about far and near.

But you're not sure...
I remember that I learn far and near in real mode of X86,but seems
that they have the application in protect mode.Can anybody give me
some instances where the keyword of far and near is applied?

far and near are NOT and have NEVER been keywords of the C programming
language. They were merely extensions used by certain implementations
for the 16-bit members of the 80x86 family. The best newsgroup for
discussing them is, probably, comp.os.msdos.programmer.

However, if you're not interested in 16-bit programming on the 80x86,
you can safely forget everything you knew about them.

Dan
 
T

Thomas Matthews

Stone said:
Maybe this is a question,which is about far and near.

I remember that I learn far and near in real mode of X86,but seems
that they have the application in protect mode.Can anybody give me
some instances where the keyword of far and near is applied?

Many thanks.
[Off-Topic]
The near pointer is a pointer that has a smaller range than
that of a far pointer. The far pointer required more memory
and instructions to use, but it could be used to access
a larger memory space.

The idea stems from relative and absolute addressing. In the
early days of 8 bit processors, processors would use 8-bit
signed values as offsets relative to the program counter
to designate addresses. Anything farther required 16 bits,
or two fetches. Thus acessing things closer was always
faster and required less code & memory.

For more information use your favorite internet search
engine with these keywords:
segmented architecture microprocessor


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
D

Dan Pop

In said:
Stone said:
Maybe this is a question,which is about far and near.

I remember that I learn far and near in real mode of X86,but seems
that they have the application in protect mode.Can anybody give me
some instances where the keyword of far and near is applied?
[Off-Topic]

The near pointer is a pointer that has a smaller range than
that of a far pointer. The far pointer required more memory
and instructions to use, but it could be used to access
a larger memory space.

Not only off-topic, but incorrect, too: both near and far pointers could
be used to access up to 64 KB of memory, they had exactly the same range,
because the segment part of a far pointer was fixed. To get pointer
arithmetic to work on all 32 bits of a pointer, you needed a huge pointer.
They were slower, but they didn't expose the programmer to the segmented
nature of the architecture: using a long index, you could scan the whole
address space of the machine in a purely linear manner (the compiler took
care of the dirty details).

The difference between a near pointer and a far pointer was that the
near pointer could cover the 64 KB of the default (code or data) segment
while the far pointer could cover 64 KB anywhere in the machine's address
space. Pointer comparisons between far pointers have always been a gray
area (I believe it was common to assume same segment and only examine the
offsets).
The idea stems from relative and absolute addressing. In the
early days of 8 bit processors, processors would use 8-bit
signed values as offsets relative to the program counter
to designate addresses. Anything farther required 16 bits,
or two fetches. Thus acessing things closer was always
faster and required less code & memory.

This is entirely unrelated to 8086 and near vs far pointers.

Please ignore any kind of questions, topical or not, when you have no
correct output to provide.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top