How does it work and what is the syntax of the machine code?

Asked

Viewed 1,565 times

3

I need to understand how the machine code works, for example, the statements of the instructions and how it can become readable like Assembly, where I can see instruction like mov, "interpret". Additionally, why did they make these symbols? I can’t name anything.

For an idea, I compiled a simple code into an Assembly compiler that opens a message box saying something.

Converted from hexadecimal to text by MS Windows notepad:

Executável

  • What do you mean "how does it work?"? Be more specific in your question. Was this code written in Assembly? So it wasn’t compiled, and so there’s no point in talking about decompilation.

  • @bigown If he’s like this it’s because it’s compiled, right? Full of symbols. That’s not Assembly and I was specific, but it came from Assembly!

  • Assembly is not machine code, machine code is composed of 0s and 1s, and the size of the word varies, it depends on the architecture of the processor.

  • @But it’s been said that he is. I’m being fooled by the way...

  • @Theprohands Assembly is an assembly language to make machine code readable to human, and it also varies for each type of processor, depends on the family of processors, each family already has its instructions already defined in Assembly.

  • 1

    I don’t know if what you want to learn is machine code or Assembly.

  • @Theprohands no, compilation is something else. Some things that might help you: http://answall.com/q/104814/101, http://answall.com/q/101691/101 and http://answall.com/q/77070/101. If you think someone taught you wrong, you might want to put it where you saw it. And it wasn’t specific, the doubt is very general. You don’t know what you really want to know. Unless you’re asking us to write a chapter in a book about how codes work, then the question really doesn’t fit. If you’re more specific, you can save her.

  • Others that may help: http://answall.com/q/91775/101, http://answall.com/q/109886/101, http://answall.com/q/102452/101

  • 1

    I repeat, there is no assembly compiler. There is Assembler, i.e., assembler. There is even a compiler (if you can call it macros for assembly, but there is something else.

  • @Yes, I get it. I mean, the machine code is Assembly. It’s always said that I’m not specific, but I wanted to know what each symbol means, so I asked. Anyway, I found what I was looking for, hardly. The older 16-year-olds up seem to want to hide Assembly and its documentation so no one else can learn, amazingly.

  • 1

    No. Machine code is one thing, Assembly is another. Oh, you want a complete manual of that. There are books with more than 1000 pages that show that. That’s nothing specific. Yeah, there must be a conspiracy of over 16 years.

  • @bigown Books completely impossible to find, as always. Do not quote much on these symbols, so I get confused.

  • You can use Ollydbg to perform this reverse engineering.

  • @Laerte What I would do is what these tools do, although for another type of project without using these tools.

Show 9 more comments

1 answer

6


Trying to answer superficially, this is a file in a certain format, as well as there are database formats, texts, spreadsheets, images, etc. This is a format that the operating system recognizes and knows what to do with the content inside. It contains instructions on how to put the relevant content in memory. It also has the instructions and static data of the application. One can understand this as a "textion" that some component will know how to deal with. It is not a plain text because it allows extra characters that are not present in texts, so it is called binary.

The operating system will tell the processor that it must execute the instructions contained there (within its internal scheduling system) and it will "interpret" those characters to decide what to do within it.

Some architectures have instructions of fixed size and others of variable size. Each character or character set indicates which instruction is to be executed and which "operands" are to be used in this operation. The processor will process the bits of these operands (if any) or some register or other thing previously defined by the instruction. Then it goes to the next instruction - eventually an instruction can change which one is next (deviation). In most operating systems this occurs until a previously defined signaling returns control to the operating system.

This can be best seen in How a computer understands binary code?.

It’s much more complex than that, but I’m already stretching. The important thing is that each character of these indicates something that the processor knows what to do. In the background the characters are numbers according to the extended ASCII table - it is shown so because it can make it easier to read something that is being interpreted as a common text (after all it was used a text editor), it is possible to see in other ways, you can even see their bits, each one chooses how he wants to visualize.

A code written in high-level language can be compiled to generate this, or a code in Assembly can be assembled. There is a 1:1 direct relationship between the Assembly instructions and these characters (set). Therefore the machine code can be easily converted to the approximate raw assembly that generated it (far from being readable) by a Desmontador. Assembly is an "easier" code for a human to read - even because it has comments, machine code is easier for the computer.

A suitable utility to view binary code is the objdump or dumpbin.

The links in the comments help to give a better idea of the subject.

  • When you say a language of "high level" do you mean "language with more access to the system"? (yes, I know it doesn’t matter the syntax, but the compiler) Is it possible to generate those symbols to generate an executable file (for example) without typing them? PS::: I think that almost the same day that I made the question was doing something wrong with some reference on Wikipedia that although might be right. There are references of instructions and its hexadecimal character, I could sense symbols there.

  • http://answall.com/q/57309/101 I think you assume things that don’t make sense. I couldn’t understand your doubt there. Anyway, it seems to be a new question, so open a new one. You see how it wasn’t specific.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.