This activity is designed to help you learn how to decode a GEM machine language instruction. This is the code that is actually executed by the computer. It is essential that you understand how a machine language instruction is put together in order to successfully design your final project which involves translating assembly language to machine language.
Each Machine Language Instruction is composed of 8 nibbles (hexadecimal digits) numbered 0 - 7 right to left.
bits nibble purpose Comment
28-31 7 opcode See table on page 183
24-25 6 size n n = 0 (byte); n=1 (short word);
n=2 (long word)
Note: number of bytes = 2^n
5 mode Each of the bits has a different
meaning
23 indirect indirect addressing if bit = 1
22 immediate immediate operand if bit = 1
21 direction RAM is destination if bit = 1
20 RAM has one RAM operand if bit = 1
16-18 4 for a reg operand, it is the register number
used in instruction (the destination
register if the instruction has 2 registers)
for a branch instruction, it is the
conditional jump code (See pa 191)
0-15 3 - 0 the address of the RAM operand
or the value of the immediate operand
or the number of the other register operand
Given the assembly language instruction SUB #2 => REG4 write the machine language equivalent:
nibble value reason
7 9 The code for SUB is 9 on pa 183
6 2 SUB is a long word instruction by default
5 5 = 0101 bit 23 = 0 since not indirect addressing (no pointer)
bit 22 = 1 since there is an immediate operand #2
bit 21 = 0 since the destination is a register REG4
bit 20 = 1 since #2 is considered a RAM operand
4 4 the register is REG4
0 - 3 0002 the immediate operand is 2
Thus the machine equivalent of SUB #2 => Reg4 is 92540002
Given the machine language instruction 11830005, write the assembly language equivalent
nibble value translation reason
7 1 Copy code on pa 183
6 1 short word 2^1 = 2 byte value being copied
5 1000 indirect address, not immediate operand, destin
is Register, 2 Register operands
4 3 one register is REG3. This is destination.
0 - 3 0005 other register is REG5. This holds address of operand
Thus the assembly language instruction is COPY:short REG5^ => REG3
These will be provided in class.
Return to the
List of Activities