Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Leal .... What The Hell Is This Instruction ?, AT&T 32bit x86
qwijibow
post Apr 17 2006, 09:27 PM
Post #1


Way Out Of Control - You need a life :)
Group Icon

Group: Members
Posts: 1,366
Joined: 14-September 04
From: Nottingham England
Member No.: 570




< pointless angry ranblings. >
Their are a million on-line assembly tutorials...

every single one the same...

stick the write system call number into eax, the std-out number into ebx, a string into ecx, and a string length to edx, and interput 0x80.

HELLO world.... now you are an assembly expert..

Im going to kill the next person i see who rites such an empty tutorial smile.gif
< / pointless angry ranblings >


Righty...

Im looking for a list of assembly instrucions, and maybe a line or two of comment to show their meaning..

i can guess most of them, but leal keps showing up in my test programs ( tutorials are all utterly usless, so im compiling c code, and making gcc dump the assembly code )

what does leal do ?

thanks.

e.g.

CODE

void funtction1() {

    int A = 10;
    A += 66;
}


compiles to...

CODE

funtction1:
    pushl    %ebp    #
    movl    %esp, %ebp    #,
    subl    $4, %esp    #,
    movl    $10, -4(%ebp)    #, A
    leal    -4(%ebp), %eax    #, tmp59    THIS LINE !!!
    addl    $66, (%eax)    #, A
    leave
    ret


i understand nmostly everything,,, EXCEPT leal

Go to the top of the page
 
+Quote Post
mastercomputers
post Apr 18 2006, 02:20 AM
Post #2


PESTICIDAL MANIAC
Group Icon

Group: Members
Posts: 626
Joined: 1-September 04
From: Auckland, New Zealand
Member No.: 27



I'll try and explain it, but I don't think I can make a good explanation.

LEA is Load Effective Address, it's basically a direct pipeline to the address you want to do calculations on without affecting any flags, or the need of pushing and popping flags. It's also used in repetitve things, in your code I'll try to explain:

CODE
funtction1:
1.    pushl    %ebp    #
2.    movl    %esp, %ebp    #,
3.    subl    $4, %esp    #,
4.    movl    $10, -4(%ebp)    #, A
5.    leal    -4(%ebp), %eax    #, tmp59    THIS LINE !!!
6.    addl    $66, (%eax)    #, A
7.    leave
8.    ret


1. push ebp
2. copy stack pointer to ebp
3. make space on stack for local data
4. put value 10 in A (this would be the address A has now)
5. load address of A into EAX (similar to a pointer)
6. add 66 to A
... don't think you need to know the rest

So hopefully that explains it, remember in some circumstances when doing calculations, like adding, subtracting, etc you affect different flags, in this way, you aren't affecting any flags and are performing the calculations directly to it. Useful for repetitive work.

What I find is, usually what is before LEA instructions, is what LEA will mimic, and what is after LEA is what it will do. You could have just worked out everything and pushed the results at the end, but I guess this way is better/faster, etc.

By the way, I wrote an empty Hello, World tutorial too tongue.gif but I could have made it more informative I agree. I wrote a tutorial here once on Assembly and it was quite packed but unfortunately, it disappeared and I think that it's no longer is here, nor did I have a backup copy of it, it was basic but explained how to go about using all the information Linux provides you with so you could do simple things like writing and reading, etc which would have helped people understand Shellcoding that's for sure tongue.gif


Cheers,


MC
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. X86: Assembler AT&T Or Intel Mode?(0)


 



- Lo-Fi Version Time is now: 11th October 2008 - 03:43 AM