Re: [Tuxnes-devel] more help w/ asm
Brought to you by:
tmmm
From: Rigel <ri...@an...> - 2001-04-11 22:17:57
|
-- On Wed, 11 Apr 2001 16:51:44 Jim Ursetto wrote: >At 03:40pm on 2001 April 11, Rigel did write: >> I was wrong, then, because I meant load into ebx the value at the mem location held in edi. > >> So if I say, >> leal 4(%ebx),%edi >> then I mean (in C), >> edi = ebx + 4 > >Exactly. With lea you can do a mul, add, AND a shl (by >2,4,or 8) correction here. I think you mean a mult by 2, 4, or 8 (which is really shl by 1, 2, 3). I only mention this because I confuse the two all the time... >in only one instruction, but it can also be >used to just do a single mov, add, or shl. lea is a >special instruction that performs all address >computations, then moves this address result into a >register. > >For example, > leal 4(%ebp,%ebx,2),%edi >does (in C) > edi = ebp + ebx*2 + 4; > >What you want is movl (%edi), %ebx. This is like saying ebx = *edi. >This is also equivalent to movl 0(%edi), %ebx -- the 0 is superfluous. > >In intel syntax, > lea eax, [ebx] == mov eax, ebx. > >You may just be confused by the AT&T syntax, but here are some resources: > all right, I think I've got it (all) figured out now (haha). I understood mov all along (promise), just not lea. I do like Intel syntax much better though, as it's a little more like other *real* (RISC) assembly languages. This whole gaffe of mine just illustrates another reason I don't like x86 asm, which is that the instructions are misnamed. I would have called lea, cea, for calculate effective addr. or maybe just wpos for weird piece of sh**. I'll definitely look up that Art of Assembly stuff. It should be a good reference. Okay, with the zero and sign flag (edi) you just give it the latest result from the ALU, right? But what about the carry flag (ebp) ? do I just set it to 1 if there was a carry involved in the most recent instruction? Thanks much, Rigel Who needs Cupid? Matchmaker.com is the place to meet somebody. FREE Two-week Trial Membership at http://www.matchmaker.com/home?rs=200015 |