eli5 what makes a ARM Cpu different from a x64 cpu ? why can’t apps from x64 run on ARM or vice versa


eli5 what makes a ARM Cpu different from a x64 cpu ? why can’t apps from x64 run on ARM or vice versa

In: 1

It’s a different architecture so the instructions don’t match. x64 bit instructions won’t run (natively) on 64bit ARM chips. It is possible to translate and emulate however by emulating instruction sets the chip won’t perform as well as a chip that understand the instruction set natively. My explanation is simplified, but it gives a picture of how it works. It’s like having someone who only speaks Spanish having a conversation with someone who only speaks English. ARM use RISC and x64 use CISC.

Every CPU has a set of instructions that it understands. Stuff like add, multiply, compare, etc.

ARM and x86 are basically two lists of those instructions. So if a program is made for x86 and you try to run it on ARM, the CPU will receive an instruction it either doesn’t know or interprets as a different one than it’s supposed to, so the program will very quickly fail.

You can search Wikipedia for “x86 instruction listings” if you would like to see the actual instructions and what they do.

Imagine you and I want to have a chat where you give me a recipe.

We can only converse in numbers, however.

So we decide to come up with a code that maybe “instruction 1” is “pour”, 2 is “whisk”, 3 is “cover with foil”, and so on. And we also have codes for locations, so maybe 1 is “the bowl”, 2 is “the oven”, and so on.

That works fine while we both use the same codes for instructions. And while we have the same set of instructions at all (e.g. maybe you have a code “parboil” but I don’t know what that means). But what if your code for 1 is “pour” and my code for 1 is “flame-grill”? It’s all going to go wrong.

Intel and ARM and MIPS and Z80 and all kinds of chips have historically used different codes, for different reasons and in different ways. Some chips are designed to kind the number of codes to an absolute minimum (Reduced Instruction Set Computers – RISC) and others have far more codes for all kinds of things that are rarely used. Some chips have thousands of storage locations (registers – a bit like the bowl / oven examples above) they can use in calculations, others keep it to just a few and move things around a lot more, reusing the same bowls over and over for performance reasons.

As time has gone by, Intel has kept the same codes that they were using 40 years ago, and ARM have done similarly, and they’ve both expanded with new codes when processors gained new abilities – but those codes are inherently different and the designs very different too.

So an ARM program is talking entirely different codes to an Intel program and they can’t understand each other. The job of formulating that code for any particular program is the job of a compiler, and you can “compile to ARM” or “compile to Intel” or whatever else, but the final result is a program that only runs on one type of machine.

They use a different instruction set, but what that means requires a little more explanation.

CPUs are made of a lot of very simple circuits – they’re made of two specific circuits, called AND gates and NOT gates. Everything a computer does can be done by chaining these two circuits together, but some things also require a fast pulse of electricity, which comes from the “clock” – just pulses of electricity at regular intervals.

You can combine this into more complex circuits to do different things. You can make an adder, for example, that adds two numbers of a given length (4 bits or 8 bits or 16bits, etc). If I make a 4 bit adder, I can add larger numbers, by first reducing them to 4 bit constituents, and then adding those and recombining them. Or, I can make an 8 bit adder. If my CPU is likely to encounter a lot of numbers larger than 4 bits, the second option is probably more efficient.

Now let’s talk multiplication. A computer can multiply numbers even if all it can do is compare numbers, add numbers, and count. I can multiply 5 * 3 by initializing some result (0), then if the second number is greater than 0, I add the first number to the result (0+5=5) and subtract one from the second number (3-1=2), then go back to the step where I checked if it was greater than zero, and repeat until it is no longer greater than zero. Step 2: (0+5+5=10) (3-1-1=1). Step 3: (0+5+5+5=15) (3-1-1-1=0 : stop) result is 15.
I could put a circuit on the cpu that multiplies numbers, or I could make you do that by using the add, count, and compare operations. If I expect you to be multiplying a lot, the former is more efficient, otherwise the second might be better. If I make you multiply the long way, then telling my CPU to perform a multiplication won’t do any good.

A CPU can run any software with only a handful of instructions. Again, at it’s root, a CPU is actually just two operations: AND and NOT. But I can make it better by “hardwiring” more complex tasks that are likely to come up a lot, instead of making you get the same results by combining other instructions. x86 and ARM make different decisions about what instructions are hardwired into the CPU, versus making you get the same results by combining other instructions.

the most ELI5 explanation is that they can do the same things but speak different languages