🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.asm.x86
Article #52

Re: Absolute addresses, relative addresses

#52
From: hp
Date: Tue, 26 Aug 2003 14:13
61 lines
4002 bytes
Eric Minso wrote:

> Hello,
> 
> I would like to know a bit more about the use of absolute addresses
> and relative addresses.
> 
> I have read that Windows DLL have a relocation table : this table is

quite common, other dll models have those tables,too.
they are required because i86 cpu-s (and others) do not provide a sufficient
set of operations to efficiently supporting relocatable code w.o. those
tables (as for instance, the 680xx processors do).

> needed to correct each absolute addresse in the DLL file because you
> can't assume the memory location where DLL while be loaded. But, why
> don't only use relative addresses ? (because it's not possible, I
> guess)
> 
> In fact, my questions are :
> 
> In which cases can you use relative addresses ?

at any known, constant displacement, e.g. usually not w. different dll-s.

> In which cases must you use absolute addresses ?

memory mapped port access, memory ranges which are dedicated to some static
program, by convention, #the# video memory, etc...

> In which cases can you choose ? (and which choice is better ? (i.e.
> for speed...))

direct (abs) is faster - with x86-s. relocating required once, at startup,
thus even code which could be programmed w. reg and displacement might
become faster executing.

> 
> Tell me if I am wrong : you can use relative addresses only inside a
> code section, and each time you reference another section, you must
> use absolute addresses. Is it right ?

depends on execution model and on what your 'section' is.

> 
> A last question before leaving :-)
> 
> This instruction :
> mov [ ebp + cst ], val
> (with 'ebp' initialised with loading address, and 'cst' initialised
> with offset) can solve the absolute addresses problem, so where is the
> trap ?

right. but, number of available registers is the 'trap'.
i86 cpu-s have no pc-rel subroutine call which complicates the code and can
slow down a program, considerably

hp
-- 
>>> hp -at- lxhp -dot- in-berlin -dot- de <<<
linux,asm,forth http://www.lxhp.in-berlin.de
Technical Details
Message-ID: <bifme4$fh$1@news.eusc.inter.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!news.crayne.org!clax86!robomod!not-for-mail
References: <7db38e60.0308250121.6135ebc1@posting.google.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f7d8d,44f17f79ebe31523
X-Google-Attributes: gidf7d8d,public
X-Google-Thread: 114917,44f17f79ebe31523
X-Google-Attributes: gid114917,public
X-Google-Thread: 1093da,44f17f79ebe31523
X-Google-Attributes: gid1093da,public
X-Google-Thread: feaef,44f17f79ebe31523
X-Google-Attributes: gidfeaef,public
X-Google-ArrivalTime: 2003-08-26 10:56:16 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!news.crayne.org!clax86!robomod!not-for-mail
From: hp <phpr@snafu.de>
Newsgroups: comp.lang.asm.x86,alt.lang.asm,alt.os.assembly,borland.public.tasm
Subject: Re: Absolute addresses, relative addresses
Approved: CLAX86 Moderators <ccrayne@crayne.org>
Followup-To: comp.lang.asm.x86
Date: Tue, 26 Aug 2003 15:13:01 +0100
Organization: Lux1
Message-ID: <bifme4$fh$1@news.eusc.inter.net>
X-CLAX86-Policy: http://www.pacificsites.com/~ccrayne/clax86.html
X-CLAX86-Faq: http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.asm.x86.html
X-CLAX86-Info-1: Send submissions to comp-lang-asm-x86@moderators.isc.org
X-CLAX86-Info-2: Send technical complaints to    ccrayne@crayne.org
X-CLAX86-Info-3: Send complaints about policy to ccrayne@crayne.org
X-Comment: moderators do not necessarily agree or disagree with this article.
References: <7db38e60.0308250121.6135ebc1@posting.google.com>
Reply-To: phpr@snafu.de
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
X-MailScanner-Information: Please contact the ISP for more information
X-MailScanner: Found to be clean
X-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (score=-2,
 required 4, EMAIL_ATTRIBUTION -0.50, QUOTED_EMAIL_TEXT -0.48,
 REFERENCES -0.50, REPLY_WITH_QUOTES -0.50)
X-UIDL: kJD!!QD2!!MjC"!6RF!!
X-Complaints-To: abuse@supernews.com
Lines: 63