2
votes

I'm a little confused at how instructions are handled internally by a computer.

There are two "things" that handle instructions internally: the assembler, and the control unit.

For example, a pseudo-mips instruction may be passed to the assembler, which deconstructs it into the corresponding sets of true-op mips instructions, and then, I presume, passes those instructions one by one into the control unit for decoding.

So that's how MIPS instructions -- whether they be pseudo or true-op -- get handled.

But what about a machine instruction? Is this just input to control unit? Does the assembler have anything to do with it? How exactly do the machine instructions differ from the assembly instructions?

2
The computer does not contain an assembler. An assembler converts assembly code to machine code which is then executed in the CPU, which is typically broken down into functional units like an arithmetic/logic unit, etc.David Hoelzer

2 Answers

11
votes

Machine code or machine language is a set of instructions executed directly by a computer's central processing unit. Each instruction performs a very specific task, such as a load, a jump, or an ALU operation on a unit of data in a CPU register or memory. Every program directly executed by a CPU is made up of a series of such instructions.it contains just 1 and 0's

An assembly language, is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture's machine code instructions[*] .Assembly language is converted into executable machine code by a utility program referred to as an assembler. That machine code is machine language. The conversion process is referred to as assembly, or assembling the source code.

[*]basically you can understand this line as in machine language all it is composes of 0's and 1's and it is not very useful while reading. and it is really very hard to understand 0's and 1's in a very large sequence in real life. so make things easier, assembly language came into existence. it is just one level above the machine language. it is just a substitution of sets of 0's and 1's in human readable format.

for example let us assume 000 represents addition in machine language. and 0001 represents number 1. and 0010 represents number 3. and together it becomes 00000010010 that is too hard to understand.. so to make it easier you can say that in assembly

000 -> add
0001 -> some_integer1
0010 -> some_integer2

and you can write

add some_integer1,some_integer2 ;

now it is easier to read. and finally the assembler will convert this assembly code[add some_integer1,someinteger2;] into machine code[00000010010] which cpu can execute directly making computer happy to get the instruction in his own language. thus assembly is for us. and machine language is for machine..:-)

To read more about assembly language.. visit here and For machine language. visit here

2
votes

The machine instructions are just bits, 1s and 0s that are input to the computer to generate the output. The assembly instructions is just code written in assembly that is translated in machine code(1s and 0s) and is later used by the computer. To be cleared: The assembly language is a language that one uses to interact with the computer, much like other languages. Assembly is translated directly into machine code, which is the only kind of instruction that the computer understands. The computer uses the machine code to process the information, and each code handles specific tasks. The computer does not understand assembly, or c, or C++ directly, it has to be translated into machine code first.