Does conversion from assembly language to Binary language take place during decode stage in a processor?

0

I am newbie to computer science and here's what I think goes on in the FDEW cycle in a processor,
1.Fetch the instruction in assembly language
2.Decode to Binary language
3.Perform execution
4.Write to memory

But I am confused about what happens in a compiler and interpreter. Doesn't the compiler translate to binary language? If so why is a decode stage needed to convert to binary code? I think I am getting it wrong. Please help me to better understand the concepts.

sham

Posted 2019-02-19T13:48:16.583

Reputation: 3

Answers

0

Yes, the compiler does "translate to binary"... to put a long story short, there is a number assigned to each (quite simple) operation. That's the binary opcode (generated by the compiler for a specific CPU type). It also has an assembly language representation - which is more a kind of intermediate human-readable symbolic notation, and not intended for execution at all.

In the execution phase, there is a sequence of processor-internal steps to do in order to execute each command. The most obvious part is to enable/disable certain "data pathways" for each step - e.g. for "connecting" some register content to the input ports of the arithmetic-logic unit (a.k.a ALU, which does computations like "addition" by employing a laarge combinational logic network), or connecting the ALU output port to a register input. Which even might be the same register from where one of the operands came.

You see, there (often) are multiple internal "microcode" steps to perform for each binary/assembly language command. That's what "decode/execute" do: they take the binary instruction word, look up a sequence of appropriate internal steps (which just open/close the gates accordingly, like a clockwork), and execute them.

jvb

Posted 2019-02-19T13:48:16.583

Reputation: 1 697

0

Assembly language is a human readable form of machine code. A compiler converts assembly language to the true machine code for execution on the processor.

What you pass to the CPU is not assembly but is compiled machine code.

Where you might be mistaking an extra conversion step is with the concepts of the CPU architecture, x86 or x86-64, with the actual CPU core microarchitecture. The microarchitecture is the real code or instructions that are executable by the raw core hardware, the x86 architecture wraps around that core and is converted to instructions the core understands.

Modern CPUs have very different cores and instruction sets to the processors that they were created from and in a lot of cases the old instructions were slow or could be improved on in some way or another.

Wrapping a core microarchitecture in a platform architecture allows you to realise improvements in the cores without exposing changes to the platform. It gives us a common and relatively unchanging platform while the actual execution steps taken can be wildly different.

The steps you see are

  1. Compiler: converts human readable instructions (assembly, C, etc.) To machine code
  2. CPU fetches machine code to execute
  3. CPU dispatcher rewrites architecture instructions to microarch instructions
  4. Instructions execute

On an old CPU which was designed with the same core and platform architectures step 3 would be skipped.

Mokubai

Posted 2019-02-19T13:48:16.583

Reputation: 64 434