From owner-freebsd-questions Tue Jan 25 15:51:13 2000 Delivered-To: freebsd-questions@freebsd.org Received: from sasknow.com (h139-142-245-96.ss.fiberone.net [139.142.245.96]) by hub.freebsd.org (Postfix) with ESMTP id AF55515006 for ; Tue, 25 Jan 2000 15:51:09 -0800 (PST) (envelope-from freebsd@sasknow.com) Received: from localhost (freebsd@localhost) by sasknow.com (8.9.3/8.9.3) with ESMTP id RAA37057; Tue, 25 Jan 2000 17:51:31 -0600 (CST) (envelope-from freebsd@sasknow.com) Date: Tue, 25 Jan 2000 17:51:31 -0600 (CST) From: Ryan Thompson To: Greg Lehey Cc: Sam Hays , freebsd-questions@FreeBSD.ORG Subject: Re: C question In-Reply-To: <20000126095750.D43103@freebie.lemis.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 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