307 ACTIVITY 13: Interpreting Machine Language Instructions

WHY:

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.

LEARNING OBJECTIVES:

  1. Discover how to read and interpret machine language instructions.
  2. Discover how to translate an assembly language instruction into machine language.
  3. Begin to appreciate the ingenuity of the early stored program pioneers who wrote everything in machine language.

CRITERIA:

  1. Quality of the answers to the Critical Thinking Questions.
  2. Ability to translate assembly language to and from machine language.

INFORMATION:

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

RESOURCES:

  1. Pages 179-193 in Scragg
  2. 30 minutes

PLAN:

  1. Choose roles if you have not already done so.
  2. Look over the model.
  3. Answer the critical thinking questions.

MODEL:

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

CRITICAL THINKING QUESTIONS:

These will be provided in class.


CPSC 307 Activity 13 -- Revised 3/6/99

Return to the List of Activities