XR3X

Jump to content


Photo

My second x86 masm application


  • You cannot start a new topic
  • Please log in to reply
3 replies to this topic

#1 testacc

testacc

    Intermediate Member

  • Loyalist
  • 247 posts
Contributor

Posted 07 April 2014 - 02:16 PM

Not sure if this belongs here or at the general discussion... Mods move if necessary.

 

I watched yesterday some tutorials, and today some more..

The video's I've been watching are from this guy:

Please Login or Register to see this Hidden Content

and I'm going to get a book from library when I get there...

 

I used visual studio 2010 as the IDE/Compiler.

 

Please tell me what you would do differently and if there's any bad habits, I'd like to know.

It's my second application, first application was a messagebox so I extended it a bit.

 

Please don't vomit if it looks weird, but tell me what I should do the differently :)

Please Login or Register to see this Hidden Content

I like to space things so I can read it myself. The comments also looked fine on VS but the HH code tags might mess it up a little.



#2 iCode

iCode

    Advanced Member

  • Loyalist
  • 390 posts

Posted 07 April 2014 - 08:48 PM

the lea instruction doesn't need to be used to copy the address into eax and eax then pushed onto the stack. Instead of this:

Please Login or Register to see this Hidden Content

Try this:

Please Login or Register to see this Hidden Content

The brackets mean you are working directly with the variable's address rather than the variable itself. Should cut your application size nearly in half right there lol.


Edited by iCode, 07 April 2014 - 08:48 PM.


#3 testacc

testacc

    Intermediate Member

  • Loyalist
  • 247 posts
Contributor

Posted 07 April 2014 - 09:19 PM

iCode, on 07 Apr 2014 - 7:48 PM, said:

the lea instruction doesn't need to be used to copy the address into eax and eax then pushed onto the stack. Instead of this:

Please Login or Register to see this Hidden Content

Try this:

Please Login or Register to see this Hidden Content

The brackets mean you are working directly with the variable's address rather than the variable itself. Should cut your application size nearly in half right there lol.

 

Thanks for your feedback ;D I will do that tomorrow when I get on my main PC. Anything other that I should improve, in that code?



#4 Tigerass

Tigerass

    Member

  • Loyalist
  • 709 posts
  • LocationNorthern Syria
Contributor

Posted 07 April 2014 - 10:23 PM

Write the app with an c compiler and analyze the output. Try to compile with maximum speed and another one with Minimum size option.
C compiled code will never be that clean than an handwritten asm programm, so it depends on what you want to gain to give you some tips.
If you want well readable code your programm looks ok.

I think the compiler will instead of pushing an 0 xor some register and push it.
Also i think he will save the address of the messagebox in some register and do something like call esi.
I don't like the .elseif etc. statements. If you are an beginner i would not use them.