|
The computer instruction has a instruction format that is different for each type of computer
But all computer instructions can be sub-divided into 3 parts:
|
Let me show you a concrete example: suppose a computer instruction consist of 4 bytes (= 32 bits):
1 computer instruction: 4 bytes (= 32 bits) <-------------------------------------------------------------> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Then:
|
For example:
1 computer instruction: 4 bytes (= 32 bits) <-------------------------------------------------------------> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <-----------> <-------> <------------------> <-----------------> opcode dest source1 source2 |
In fact, the bits that encode the various part need not be contiguous.
But there is always a logical scheme to encode the various parts.
The logical scheme to encode the opcode, source operands and destinations varies from computer to computer.
For example:
Operation Opcode ------------- -------- Move 0000 Add 0001 Subtract 0010 Multiply 0011 Divide 0100 ... ... (and so on) |
Again, each computer has its own encoding scheme and it is not important to memorize the encoding.
It's enough that you know there is a systematic way to encode the operation code.
Again, each computer CPU has its own way to encode the operand information
The encoding technique is not part of the CS 255 material - all you need to know is each computer CPU has its own systematic way to encode where the operands are located
Also, the same encoding technique is used to encode the destination
And I only do it to satisfy your curiosity - and not to discuss encoding technique in general.