How do machines interpret binary files?

I was just thinking how machines interpret binary code? As far as I understand, your code turns into 1 and 0, so the machine can understand them, but how do they do it? Is this plain text for binary translation?

+5
source share
3 answers

Firstly, “binary” does not mean what you think it means (any data on the computer, including the text is already binary, it’s just the way we decide to display and process is different).

Secondly, compilation is not a simple conversion to funny characters (if that were the case, we do not need different compilers for different languages). To have some understanding of machine code, you need to understand the architecture it is aimed at. There are many computer architectures; your computer is just one of them. This is a very broad question and requires a clear understanding of computer architecture.

I will show an example of MIPS instructions. If you're interested, you can read and get some factual knowledge about the subject, try the links at the end of my post.

MIPS is a popular introductory subject, as its training format is one of the most digestible. MIPS instructions are 32 bits wide. There are three kinds of instructions in MIPS: "R", "I" and "J". We will go through the "I" instructions.

(32 ), , . "I" :

|------|-----|-----|----------------|
 opcode   rs    rt    immediate
   6      5     5     16               (the numbers show how wide are each part)

:

  • opcode , (: , , ). ( "R" "J" ) 6- , .
  • rs rt - , , 32- . MIPS 32 , . , , .
  • - . , " " , .

, :

001000 00001 00010 0000000000000011

, . :

  • : 001000 addi " ".
  • rs: 00001 1 , , 1 rs.
  • rd: 00010 2 , , rs.
  • : 0000000000000011 3 .

addi : , rs, . rd. , , rd 3 + 2 = 5.

, , . , , , runnable.

MIPS :

+12

, . , . , - . .

.

0

Think of it this way. You have 8 power switches, each of which has either off (0) or on (1). The computer will see all 8 switches as 1. This now looks like a combination. Each character on the keyboard has a combination.

0
source

All Articles