HiveBrain v1.2.0
Get Started
← Back to all entries
patternMajor

What does machine code actually look like while being run?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
whilewhatlooklikebeingcodeactuallydoesmachinerun

Problem

When machine code is actually being executed by hardware and the CPU, what does it look like?

Would it look like binary, as in instructions being represented by ones and zeros, or would it be something made up of hexadecimal digits where opcodes are bytes presented as hex numbers which can be broken back down into binary numbers, like bytecode?

Solution

The best answer I can give is, it doesn't really "look" like anything. The instruction currently being executed by the CPU is represented by a series of wires, some of which have a high voltage, some of which have a low voltage.

You can interpret the high and low voltages as zeroes and ones, but you can equally well interpret groups of high and low voltages as hexadecimal digits, or as an assembly instruction like ADD $0 $1 (which is closest to how the CPU interprets it). These numbers and mnemonics themselves are conveniences for humans to read; internally, it's nothing but voltages on wires.

Out of these options, binary is "closest to the metal", in that the zeroes and ones map directly to the high and low voltages on the wires. But none of the others are incorrect, and they're frequently more useful: there's a reason people look at hex-dumps of executables, but almost never binary-dumps.

Context

StackExchange Computer Science Q#93372, answer score: 38

Revisions (0)

No revisions yet.