next up previous contents
Next: Memory Organization Up: Data Representation Previous: Representing Characters

Representing Programs

Just as groups of bits can be used to represent numbers, they can also be used to represent instructions for a computer to perform. Unlike the two's complement notation for integers, which is a standard representation used by nearly all computers, the representation of instructions, and even the set of instructions, varies widely from one type of computer to another.

The MIPS architecture, which is the focus of later chapters in this document, uses a relatively simple and straightforward representation. Each instruction is exactly 32 bits in length, and consists of several bit fields, as depicted in figure C.6.

  
Figure C.6: MIPS R2000 Instruction Formats

The first six bits (reading from the left, or high-order bits) of each instruction are called the op field. The op field determines whether the instruction is a register, immediate, or jump instruction, and how the rest of the instruction should be interpreted. Depending on what the op is, parts of the rest of the instruction may represent the names of registers, constant memory addresses, 16-bit integers, or other additional qualifiers for the op.

If the op field is 0, then the instruction is a register instruction, which generally perform an arithmetic or logical operations. The funct field specifies the operation to perform, while the reg1 and reg2 represent the registers to use as operands, and the des field represents the register in which to store the result. For example, the 32-bit hexadecimal number 0x02918020 represents, in the MIPS instruction set, the operation of adding the contents of registers 20 and 17 and placing the result in register 16.



If the op field is not 0, then the instruction may be either an immediate or jump instruction, depending on the value of the op field.



Dan Ellard
Mon Jul 21 22:30:59 EDT 1997