Machine code
Next: The fetch-decode-obey cycle
Up: No Title
Previous: What's in a computer?
Back: to main list of student notes
Program instructions are represented as numbers in memory. Each type of
computer has its own way of encoding these: its own machine code.
Example. I'll use this in the next section.
- 41xx. ``Clear''. Store zero in memory location xx.
- 42xx. ``Read''. Read a number typed at the keyboard and store it
in the accumulator. The value of xx is ignored.
- 43xx. ``Print''. Display on the screen the number in memory
location xx.
- 44xx. ``Load''. Copy into the accumulator, the number in memory
location xx.
- 45xx. ``Load''. Copy from the accumulator into the number in
memory location xx.
- 46xx. ``Add''. Add the accumulator to the number in memory
location xx.
- 47xx. ``Goto''. Copy xx into the program counter.
- 48xx. ``Jump if zero''. If the accumulator is zero, then copy xx
into the program counter, otherwise do nothing.
- ``Stop''. Stop.
In this example, I've allocated the first two decimal digits for the
instruction part, and the last two for the ``operand'' - an address or
data value needed by some instructions. When decoding the instruction,
the processor has to split the first two digits off from the last two.
This would be easy if it worked in decimal. However, no processors do,
and an actual machine code would rely on a binary representation. For
example, the first five binary digits might be reserved for the
instruction part. I'm using decimal only because it's easier.
Next: The fetch-decode-obey cycle
Up: No Title
Previous: What's in a computer?
Back: to main list of student notes
Jocelyn Ireson-Paine
Wed Feb 14 23:46:11 GMT 1996