Mano Tutorial Introduction

An Introduction to Programming Mano's Basic Computer

Dr. M. Moris Mano describes a basic computer in his textbook, Computer System Architecture, 3rd edition, 1993.

This computer is a toy computer, but serves to present many of the basic concepts behind all digital computers and gives us a good platform to study some key features of assembly language programming.

The sample programs I have included in this tutorial can be assembled and executed using My Computer Simulator.

Links:

Here is a simplified diagram of Mano's computer, emphasizing the elements of the computer that are directly accessible to an assembly language programmer.

Schematic of assembly language registers
Control signals:
  • PC - increment, load, clear
  • Memory - read, write, address
  • E - complement, clear
  • AC - increment, load, clear
  • OUTR - load
ALU (arithmetic and logic unit) operations:
  • AND memory and AC
  • ADD memory and AC with carry to E
  • select Memory
  • select INPR
  • complement AC
  • shift left AC and E
  • shift right AC and E

The purpose of the assembler is to turn assembly language code into machine language. The elements of an assembly language program are:

Addressing Modes:

Mano's basic computer uses only two addressing modes - direct and indirect.

In direct addressing, the 12-bit value in the instruction is used as the address of the memory location whose value will be set or from which the value will be retrieved.

In indirect addressing, the 12-bit value in the instruction is the address of a memory location, and the value at that address will then be used to access that actual memory location used in the instruction.

For example:

      SETPCSTART 100 // optional, default is first ORG
      ORG 100
      LDA MEM1      // direct   - loads  33 into AC
      LDA MEM2      // direct   - loads 202 into AC, the value at MEM2, which is LOC1
      LDA MEM2 I    // indirect - loads  99 into AC, the value at LOC1, LOC1 being the location MEM2 points at
      HLT

      ORG 200
MEM1  HEX 33
MEM2  HEX LOC1 // puts the value 202, the location of the symbol LOC1, into this location
LOC1  HEX 99

Overview of the Instruction Set

To make his computer fairly simple, Mano provides a rather small number of instructions, and to make the circuitry needed to interpret those instructions relatively simple, the hex code for each instruction is carefully chosen and the instructions are formed into a few groups - memory, register and input/output. Also, the entire computer is based on 16-bit words, and the memory is limited to 4096 words, corresponding to 12-bit addresses. He has also chosen the instruction format to consist of 4 bits of primary code, defining the instruction, leaving 12 bits for addressing the memory for the instructions in the memory group. For those instructions in the register and input/output groups, the 12 bits are simply used to select the instruction. You can see these patterns by looking at the instruction table below, or the programmer card.

Mano's computer uses an accumulator-oriented architecture, so the output of the ALU is sent only the AC register (the accumulator). The AC register may be loaded from the memory, from an input register (INPR), from a few operations on the value in the AC and the memory, and the value of the AC may be sent to the memory. 

The arithmetic and logical operations available in Mano's computer are rather limited:

Amazingly enough, all other arithmetic and logical operations can be implemented using only this set of operations. For example -

The first equation uses one of DeMorgan's laws. The second equation is true because we are using 16-bit 2's complement to represent positive and negative numbers in this machine.

Methods of transferring control to an instruction other than the next instruction in the memory, are rather limited. They are:

Description of Instructions Table:

The instruction set, with a mnemonic for each instruction, a short description of the effect of the instruction, a symbolic representation in a register transfer language of the instruction, and a figure showing the elements of the computer that are involved in executing the instruction.

Type
Symbol
click on the link
to see examples
Hex code
blue - direct
yellow - indirect
Description
Register Transfer Language
PC <-- PC + 1 first
M[xxx]
- direct address
M[M[xxx]] - indirect address
Data Flow
Memory
AND
0xxx
8xxx
AND memory word with AC
AC <-- AC and M[xxx]
or M[M[xxx]]
AND
ADD
1xxx
9xxx
ADD memory word with AC
AC <-- AC + M[xxx]
or M[M[xxx]]
ADD
LDA
2xxx
Axxx
Load AC from memory word
AC <-- M[xxx]
or M[M[xxx]]

STA
3xxx
Bxxx
Store AC to memory word
M[xxx] <-- AC
or M[M[xxx]]

BUN
4xxx
Cxxx
Branch unconditionally
PC <-- M[xxx]
or M[M[xxx]]

BSA
5xxx
Dxxx
Branch and save return address
M[xxx] <-- PC
 ^ or M[M[xxx]]
PC <-- M[xxx] + 1
        ^ or M[M[xxx]]
BUN
ISZ
6xxx
Exxx
Increment and skip if 0
Does not involve AC
M[xxx] <-- M[xxx] + 1
 ^ or M[M[xxx]] ^
if (M[xxx] = 0) then PC <-- PC + 1

      ^ or M[M[xxx]]
ISZ
Register
CLA
7800
Clear AC
AC <-- 0
CLA
CLE
7400
Clear E
E <-- 0
CLE
CMA
7200
Complement AC
AC <-- not AC (1's complement)
CMA
CME
7100
Complement E
E <-- not E
CME
CIR
7080
Right circular shift AC and E
AC (0-14) <-- AC (1-15)
AC (15) <-- E
E <-- AC (0)
CIR
CIL
7040
Left circular shift AC and E
AC (1-15) <-- AC (0-14)
AC (0) <-- E
E <-- AC (15)
INC
7020
Increment AC
AC <-- AC + 1
INC
SPA
7010
Skip if AC is non-negative
if (AC(15) = 0) PC <-- PC + 1
SPA SNA SZA
SNA
7008
Skip if AC is negative
if (AC(15) = 1) PC <-- PC + 1
SZA
7004
Skip if AC is zero
if (AC = 0) PC <-- PC + 1
SZE
7002
Skip if E is zero if (E = 0) PC <-- PC + 1
SZE
HLT
7001
Halt computer
S <-- 0

Input/Output
INP
F800
Input character to AC
AC <-- INPR
INP
OUT
F400
Output character from AC
OUTR <-- AC
OUT
SKI
F200
Skip on input flag
1 means valid input is available
if (FGI = 1) PC <-- PC + 1

SKO
F100
Skip on output flag
1 means register is clear for new output
if (FGO = 1) PC <-- PC + 1

ION
F080
Interrupt on
IEN <--- 1

IOF
F040
Interrupt off
IEN <-- 0

Details of Mano's basic computer. 

This computer is defined in
Computer System Architecture, 3rd edition
by M. Morris Mano
Published by Prentice-Hall, c 1993
Chapter 5, pp 123-172.

Mano describes the assembly language for this computer in Chapter 6, pp 173-212.

His goal is to describe a computer as a set of flip-flops (D and JK mostly), connected through circuits of logic gates (AND, OR and NOT gates, mostly), using a clock to time the updates to the flip-flops. He also connects this architecture to the instruction set we have described above, and discusses the construction of the assembler, which will convert an assembly language program into machine code which can be executed on the basic computer.

Architecture (pg 157)

  1. A memory unit with 4096 words, 16 bits each
  2. Nine registers, with length in bits in parentheses: AR (12), PC (12), DR (16), AC (16), IR (16), TR (16), OUTR (8), INPR (8), and SC (4).
  3. Seven flip-flops:
    1. I (pg 126) interrupt enable
    2. S (pg 144) stop (0)/go (1)
    3. E (pg 131) carry-out bit from ALU
    4. R (pg 154) interrupt raised
    5. IEN (pg 153) interrupt enabled
    6. FGI (pg 151) input register available
    7. FGO (pg 152) output register available
  4. Two decoders: 3x8 operation decoder, 4x16 timing decoder
  5. A 16-bit common bus
  6. Control logic gates
  7. ALU connected to AC input

The instructions are presented on pg 133 - defined in detail on pg 159.

The extra registers, those not directly accessible to the machine language, are used to handle issues such as address calculation and instruction processing. These additional registers are required because Mano has chosen to limit the number of registers and to use a single memory for both instructions and data, which means that processing a machine instruction, the equivalent of an assembly language instruction, cannot be done in a single clock tick. A clock tick is the point at which the contents of the registers may be updated. For example, the ADD instruction requires a memory reference to get the instruction using the PC register as the address of the instruction, and then another memory access to get the actual data. If the instruction uses indirect addressing, then one more access to memory is required. Since the memory can only do one thing at a time, processing an instruction needs at least 3 clock ticks if we only consider these steps. In fact, there are a few more steps involved, but we really don't need to concern ourselves in this tutorial with that level of detail. Mano's text presents all the glorious details, for those who are interested.

Mano's Basic Computer - Data Flow