2

I wrote simple Hello word program with masm32. But then when I try to disassemble it with IDA and I am getting much bigger output (I won't write it there because it would take to much space). And I don't get it why it's different. How to run the disasembled code?

1
  • I might be wrong but the bigger output should be a consequence to the fact the disassembly contains more info like the address of each instruction. Commented May 26, 2012 at 9:39

1 Answer 1

2

This is normal. Compilation is a "lossy" process, which means that if you compile code and then decompile it, you're not guaranteed to get exactly the same thing out that you originally put in. The same thing applies to assembly language. When you assemble and link the code, it's a one-way process.

This is why programmers save the original source code, rather than just trying to decompile their binaries when they want to fix bugs.

Sign up to request clarification or add additional context in comments.

10 Comments

You don't compile assembly, you assemble and link it. Consider that for each opcode there's a corresponding binary value, so you don't have optimization typical of compiled (a.k.a. high level) languages.
You see I have a task to disaseble a example .exe and then run run it with the output code
Didn't mean to suggest there was any optimization occurring. I updated the answer to address terminology pedantry.
Not to be annoying, but it's not just pedantry. Compiling and assembling are two rather different operations: a compiler modifies the structure of the code you write; instead, assembly has a 1:1 ratio to machine code (binary). It's a relevant difference, because when you disassemble ASM code you'll get exactly what you wrote (except for addresses and offset values, but their size doesn't change anyway).
No, you don't. That's not guaranteed. It's more likely than with a compiler, sure, but you are not guaranteed to get the same thing from your disassembler that you passed to your assembler. That's the whole point. Not all assembly instructions are translated 1:1 to machine instructions.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.