Date: Tue, 25 Jan 2000 17:51:31 -0600 (CST) From: Ryan Thompson <freebsd@sasknow.com> To: Greg Lehey <grog@lemis.com> Cc: Sam Hays <sam@ecofl.com>, freebsd-questions@FreeBSD.ORG Subject: Re: C question Message-ID: <Pine.BSF.4.10.10001251741510.36926-100000@sasknow.com> In-Reply-To: <20000126095750.D43103@freebie.lemis.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 26 Jan 2000, Greg Lehey wrote: > On Tuesday, 25 January 2000 at 15:03:04 -0600, Sam Hays wrote: > > Out of curiosity, > > what is the difference between NEAR and FAR in C/C++? please don't respond > > w/ a damned man page =] thanx > > These are non-standard extensions used on some architectures with two > different pointer lengths. 'near' is a shorter pointer which can't > address the entire address space. 'far' is a longer pointer which > (normally) can address the entire address space, but which takes up > more space itself. > > Greg And, on most (if not all) architectures, FAR pointers require a different branching instruction (usually involving additional clock cycles, and multiple instructions in the case of conditional branches, as a far jump address can not normally be stored in an opcode operand field--on modern machines they are a fixed width in bits, generally 32 or 64.. And far jump addresses are generally 32 or 64 bits :-). So, unless your compiler is smart about optimizing near/far jumps, you may be slighly penalized if you use FAR addressing when it isn't necessary. Near addresses are signed, and use addressing relative to the current address pointer in memory. (And, as such, can go backwards or forwards). Far addresses are unsigned, and specify an absolute (or nearly absolute) address in memory. By "nearly absolute", unless you're storing the jump address in a register and using a "jump register"-style opcode (in the hardware, that is :-), the entire jump address won't fit in the opcode field. So, as Greg mentioned, the entire address may still not fit. The implementation will generally get around this by "borrowing" the necessary high bits from the current address pointer. But... I sense that I'm getting far afield of your original question.. So I'll just stop now :-) -- Ryan Thompson <ryan@sasknow.com> 50% Owner, Sysadmin SaskNow Technologies http://www.sasknow.com #106-380 3120 8th St E Saskatoon, SK S7H 0W2 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.10001251741510.36926-100000>