Does every processor use the same instruction set?

Asked

Viewed 778 times

8

I was researching about machine language, but everything I found on the Internet is very little and only theoretical so I wanted to know if it is possible to create a simple program in machine language.

1 answer

11


What you’ll find out there is theoretical, practice is to do, so do it, but how will you do it without knowing the theory? Unless you’re referencing the practice as the cake recipes that some post, it doesn’t teach anyone. Maybe in that area you don’t really find this kind of thing, because anyone who wants to get into it knows that recipes are useless.

Machine language itself has not been programmed for several decades. People program in Assembly which is an easier representation for humans, but which has a direct relationship with the processor’s instructions. This assembly code is mounted to the machine code through a Assembler that looks like a compiler, but much simpler.

In fact even Assembly today is used at rare times, usually to make bootstrap operating systems and other environments, some very specific points in some drivers, the creation of backends compilers and some very specific optimizations. Today it is rare for human to produce machine code better than compilers do.

Each processor family (x86, ARM, MIPS, etc.) has a specific instruction set. Even processors of the same family vary. New generations have new instructions and eventually cease to have instructions that no longer make sense, though rarely happen. Each processor also has its own way of writing assembly code. Although Assembly is an abstraction for humans, there is a culture of its own on top of each processor.

Not only should the assembly be specific to each type of processor, but there are also differences between the assembly languages of different assembler suppliers (for the X86 processor it is common to use the basic syntax of Intel or AT&T more the assembler syntax). Assembly must be specific to what is called Instruction set.

If you already know how to program in C, write a simple code that only does one thing and have it compiled for Assembly. There you will see how the code at a high level transforms into a low level. Do this with a lot of things that you are curious about, experiment. And then start making your own codes.

To Wikipedia is a good start to the first steps to understand the subject. As you learn the basics, you can go to other articles there or on the pages. Then you will have better conditions to do research and ask specific questions here.

If you really want to learn, look for books. Things on the internet help, but they don’t replace books. A good start and book indication. This other one is well suited. The processor manual will help.

I am passing everything in English because obviously learning Assembly without knowing English does not match.

Ah, programming in Assembly is absurdly more difficult than finding information on the internet on the subject. So I advise you to reevaluate if you are prepared for it at this time. But his attitude is commendable, before there were more people wanting to learn the whole.

  • Thank you very much for the answer, I just wanted to have the experience of programming in machine language and see how it works closer. I read some things on wikipedia and about what you said about the cake recipe, I just wanted to see what a machine code was like even if I understood little thing, Thanks man, it was hard to find someone who really "manjava" the subject.

Browser other questions tagged

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