🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: LEA vs OFFSET

#94
From: assassin17
Date: Mon, 05 Apr 1999 00:00
41 lines
3334 bytes

> people have discouraged the use of OFFSET because of a flaw in MASM mode (w/o
> simplified segments) where it returns offsets relative to the start of a
> segment, even if that segment is in a group.  instead, they recommend LEA.
> however, LEA seems to have the same problem, unless "ASSUME ds:GROUPX" (where
> GROUPX is the group the segment belongs to) is added to the program.  on the
> other hand, ASSUME seems to have *no* effect at all when OFFSET is used.  why
> is this the case?  i'm not sure why ASSUME alters one but not the other.  i
> also noticed that ASSUME in conjunction with LEA doesn't generate the segment
> overrides like it does with accessing variables' *values* (e.g. "mov
> ax,[dataword]").  overall, i don't fully understand what defines how ASSUME
> works in these different situations.  any explanations would be greatly
> appreciated..

hrm.. i'll flaunt my skills by replying to my own message.  according to the
TASM help file, ASSUME "Specifies the segment register (segmentreg) that will
be used to calculate the effective addresses for all labels and variables
defined under a given segment or group name (name)."  OFFSET is apparently
not the same thing as effective address.  Also, ASSUME has the same effect on
accessing the *values* of grouped variables as it does on LEA - it adjusts
their location with respect to the group if the segment register in ASSUME is
pointing to the group.	However, no segment override is generated with LEA
because it is not *needed*; the variable isn't actually being accessed.  And
a clarification: "ASSUME ds:GROUPX" doesn't have to be used, it can be
"ASSUME es:GROUPX" or any other segment register.

Gee, it might be a good idea to read the help file and think things over
BEFORE posting. :/

> also, i have a more general question about LEA vs OFFSET with respect to
> performance.  is "LEA ax,variable" definitely slower than "MOV ax,OFFSET
> variable"?  and is LEA generally recommended for more complicated effective
> addresses like [variable+bx+3]?

yes. yes.

-Assassin

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    
Technical Details
Message-ID: <7eahpp$7qc$1@autumn.news.rcn.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7e80lk$t67$7@autumn.news.rcn.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f7d8d,d0115f46d75d9fff
X-Google-Attributes: gidf7d8d,public
X-Google-Thread: 114917,d0115f46d75d9fff
X-Google-Attributes: gid114917,public
X-Google-Thread: feaef,f7796ad84b4f992f
X-Google-Attributes: gidfeaef,public
From: assassin17@rocketmail.com
Subject: Re: LEA vs OFFSET
Date: 1999/04/05
Message-ID: <7eahpp$7qc$1@autumn.news.rcn.net>
X-Deja-AN: 462880355
Approved: <johnfine@erols.com>
References: <7e80lk$t67$7@autumn.news.rcn.net>
X-Authentication-Warning: backdraft.philabs.research.philips.com: smap set sender to <news@dejanews.com> using -f
X-Http-User-Agent: Mozilla/4.08 [en] (Win95; I)
X-Mozilla-Status: 0801
X-Complaints-To: abuse@rcn.com
X-Trace: PeBSg5UdxRrJp2wm26uQ2e2YFzDkxQooqZRe9sq/AHY=
X-Http-Proxy: 1.0 x6.dejanews.com:80 (Squid/1.1.22) for client 206.68.208.233
Organization: Deja News - The Leader in Internet Discussion
X-Article-Creation-Date: Mon Apr 05 13:20:23 1999 GMT
NNTP-Posting-Date: 5 Apr 1999 14:36:41 GMT
Newsgroups: comp.lang.asm.x86,alt.lang.asm,borland.public.tasm