Jump to content
xisto Community
Sign in to follow this  
qwijibow

Leal .... What The Hell Is This Instruction ? ATT 32bit x86

Recommended Posts

< 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 :lol:
< / 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.

void funtction1() {	int A = 10;	A += 66;}

compiles to...

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

Share this post


Link to post
Share on other sites

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:

funtction1:1.	pushl	%ebp	#2.	movl	%esp, %ebp	#,3.	subl	$4, %esp	#,4.	movl	$10, -4(%ebp)	#, A5.	leal	-4(%ebp), %eax	#, tmp59	THIS LINE !!!6.	addl	$66, (%eax)	#, A7.	leave8.	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 :lol: 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 :lol:


Cheers,


MC

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.