Instruction Word Formats, Addressing Modes
All instructions, regardless of the computer, must encode the same two things: A number of bits are
dedicated to encoding the instruction itself (called the operation code, or op code), and, if the instruction
manipulates data, a number of bits are dedicated to encoding the data (called the operand(s)).
Op codes. The op code part is simple. In our MARIE computer, the op code was always a four-bit binary
number. This meant that we were limited to 16 instructions. If we decided that we wanted more, we would
have had to move to 5 bits, giving us 32 instructions. Op codes are the same way on a real computer,
except that they have more than 16 instructions. If only one bit were devoted to the op code, we would be
limited to 2 instructions (0 and 1). If two bits were devoted to the op code, we would be allowed four
instructions (00, 01, 10, 11). Three bits gives us 8 op codes (000, 001, 010, 011, 100, 101, 110, 111), four
bits gives us 16 op codes, etc. In general, if we have n bits devoted to the op code, there will be 2
different instructions available in our instruction set.
Operands. The operand part is only slightly more complex. The complexity comes from the fact that
different instructions may require different numbers of operands. Some instructions require no operands
(or the operand may be implied in the instruction, without actually taking up any bits), some require a
single operand, some require two operands, and some require three operands.
MARIE was simple because it always had a 12-bit operand (although the 12 bits were sometimes ignored
as in the HALT instruction). And, in the ADD and SUBT instructions (which require two operands), the
second operand was implied -- it was the number in the accumulator. The destination (the place where
the answer goes) is also implied -- it was always the accumulator. Note that whenever a binary operation
(an operation that requires two operands) is performed, three "operands" are required: the two numbers
that the operation is being performed on, and the destination (you may not call this an operand, but it is
something that must be specified in the instruction).
Instruction Word Requirements and Constraints
Every instruction must have enough bits to specify the op code and the operands. Since most of today's
computers use 8-bit bytes, a common op code length is 8 bits. This gives 2
(256) different instructions
(and there are tricks that can be used to get around this, if more op codes are needed), which is a
reasonable number. The interesting part is determining how many bits to devote to the operands. Since