Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Pointless instruction?

Name: Anonymous 2010-04-26 13:49

What does this x86 assembler instruction do?

lea  eax, [eax+0]

AFAIK this has no effect. Then what the hell did GCC generate this for? (in /O3 mode!)

Name: Anonymous 2010-04-26 13:55

It loads the address of eax into eax?

Name: Anonymous 2010-04-26 13:56

what the hell does lea do anyways? i tried to find out but i never got any good explenation.

Name: Anonymous 2010-04-26 14:11

>>3
LEA calculates a stack address when that address is not a constant, e.g, position "EBP − 8" on the stack.  LEA does not read memory; it merely performs an address calculation.

For example, you couldn't use:
MOV EAX, EBP - 8
because EBP - 8 is an expression.  You use:
LEA EAX, [EBP - 8]
which is also equivalent to:
MOV EAX, EBP
SUB EAX, 8

however, LEA is faster than the MOV...SUB method.

Name: Anonymous 2010-04-26 14:14

>>1
In what context did GCC produce this?

Name: Anonymous 2010-04-26 14:21

>>5
your moms cock

Name: Anonymous 2010-04-26 15:20

Have you read your ``Intel® 64 and IA-32 Architectures Optimization Reference Manual'' §3.4.1.5 and §3.5.1.8 today?

Name: Anonymous 2010-04-26 15:33

The amount of wrong in this thread leaves me with little faith for programming. If it weren't for >>7, I'd be left with none.<

Name: Anonymous 2010-04-26 16:00

>>8
If there's something wrong in this thread that you see, then WORK TO FIX IT.  Stop being lazy.

Name: Anonymous 2010-04-26 16:13

It will calculate the star rating of the eax, replacing it with a value that is rounded to the nearest .25

Name: Anonymous 2010-04-26 16:13

>>9
Great advice, RMS RICHARD STALLMAN

Name: Anonymous 2010-04-26 16:17

>>10
That sucks. What I want is round to half a star any values which end in (0.3)..(0.7).

Name: Anonymous 2010-04-26 17:29

ROUND MY ANUS

Name: Anonymous 2010-04-26 17:35

>>12
Why not (.25) .. (.75)?

Name: Anonymous 2010-04-26 18:13

I could never figure out how lea is supposed to work either.  I'm hoping >>4 is speaking the truths.

Name: Anonymous 2010-04-26 18:53

This is equivalent to a nop. MSVC's compiler generates it too instead of alignment before loops. I always assumed it was either alignment/nops or it was used to help the branch prediction technology (the same way on RISC, you put nops after jumps).

Name: Anonymous 2010-04-26 18:55

>>15
LEA is pretty simple
LEA REG1,[REG2*M+REG3+OFFSET]
is just
REG1=REG2*M+REG3+OFFSET.
where M=1,2,4.

Name: Anonymous 2010-04-26 18:56

Then what the hell did GCC generate this for?
Behold, the imperfections of compiler-generated code.

MSVC and ICC tends to be a little better though.

Name: >>17 2010-04-26 18:58

The name LEA itself is a bit misleading, since it's often used for multiplication purposes(optimization) and other simple math.
The reason it's called Load Effective Address is because a common usage is to have OFFSET or REG3(in that example), be a pointer to an array, while REG2 would be an index, and M represents the size of the element. So for example,
given, int array[100]; to write array[i] in asm, you would just do lea reg,[array+i*4] , where i some general purpose register, and array is another register or hardcoded offset to array.

Name: >>17 2010-04-26 19:00

dammit, that would be &array[i] not array[i]. Of course, if you wanted to do array[i], just substitute lea for mov in that example.

Name: Anonymous 2010-04-26 19:40

>>18
Behold, the imperfections of compiler-generated code.
SLASHDOT-QUALITY COMMENT

Name: Anonymous 2010-04-27 3:09

are there any compilers out there that dont suck?

Name: Anonymous 2010-04-27 3:16

>>22
For C? You're joking, right?

Name: Anonymous 2010-04-27 8:42

ITT people don't understand why compilers might want to use nops in -O3 because they don't know how computers work.

Name: Anonymous 2010-04-27 9:08

Leah culver my eax you were waiting for it

Name: Anonymous 2010-04-27 10:12

>>24
They want their optimizations optimized away, even if it means running at less than half speed.

Name: Anonymous 2010-04-27 10:32

???????????????? ????????????
????????????????????????????????????????????????????????????????????????????????

Name: britneyspears 2010-05-17 1:18

Name: Anonymous 2010-12-09 3:04

Name: Anonymous 2010-12-20 20:34

Name: Anonymous 2013-09-01 10:26


It was about Hikikomori as long as Misaki didn't show up.

Name: Anonymous 2013-09-01 11:11


I remember reading and watching a documentary about Project Orion a few years ago, and it really amazed me how close they came to launching a manned rocket to Saturn. If anyone doesn't know what Orion is, see: http://en.wikipedia.org/wiki/Project_Orion_%28nuclear_propulsion%29

Don't change these.
Name: Email:
Entire Thread Thread List