SUPER SIMPLE CPU - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

SUPER SIMPLE CPU

Description:

The program counter (PC) (contains the address. of the next instruction to be executed) ... Set the Program Counter to a value given by the operand. ... – PowerPoint PPT presentation

Number of Views:646
Avg rating:3.0/5.0
Slides: 24
Provided by: Jon5101
Category:
Tags: cpu | simple | super | register

less

Transcript and Presenter's Notes

Title: SUPER SIMPLE CPU


1
SUPER SIMPLE CPU
2
Super Simple CPU
  • A hypothetical machine designed to contain the
    important features of real computers that we want
    to illustrate

3
Features in Super Simple CPU
4
Features in Super Simple CPU
  • The memory unit is made up of 16 cells.
  • Each cell consists of 16 bits (2 bytes)
  • Registers/Status Bits
  • The program counter (PC) (contains the address
    of the next instruction to be executed)
  • The instruction register (IR) (contains a copy
    of the instruction being executed)
  • The accumulator (ACC register)

5
Instruction Format
  • Instructions consist of 16 bits.
  • The first 4 bits are operation code (opcode). It
    specifies which instruction is to be carried out.
  • The rest of bits represent an operand.

opcode operand
0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15
6
Opcodes
  • Binary Mnemonic Short
    Explanation
  • 1111 STP Stop the
    computer
  • 0001 ADD Add
    accumulator to operand
  • 0010 SUB Subtract
    operand from accumulator
  • 0011 LOD Load memory
    cell into accumulator
  • 0100 LDI Load
    immediate into accumulator
  • 0101 STO Store
    accumulator into memory cell
  • 0110 INP Input value
    and store into accumulator
  • 0111 OUT Output the
    value from accumulator
  • 1000 JMP Jump to
    instruction
  • 1001 JNG Jump to
    instruction if accumulatorlt0
  • 1010 JZR Jump to
    instruction if accumulator0

7
Operands
  • The operand can be many different things
    depending upon which opcode it is used with.
  • It is the address of a memory cell, used by ADD,
    SUB, LOD, STO
  • It is 12-bit constant used by LDI
  • Jumping instructions JMP, JNG, JZR use 12-bit
    operand as the value of PC.

8
ADD Operation
opcode operand address of
data
0 0 0 1 0 0 0 0 0 0 0 0 1
0 1 0
0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15
  • Add a value stored at memory address given by the
    operand to the current value stored at the
    accumulator.
  • The sum is stored at the accumulator.

9
SUB Operation
opcode operand address of
data
0 0 1 0 0 0 0 0 0 0 0 0 1
0 1 0
0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15
  • Subtract a value stored at memory address given
    by the operand from the current value stored at
    the accumulator.
  • The result is stored at the accumulator.

10
LOD Operation
opcode operand address of
data
0 0 1 1 0 0 0 0 0 0 0 0 1
0 1 0
0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15
  • Load a value stored at memory address given by
    the operand to the accumulator.

11
STO Operation
opcode operand address of
data
0 1 0 1 0 0 0 0 0 0 0 0 1
0 1 0
0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15
  • Store a value at the accumulator to memory
    address given by the operand.

12
LDI Operation
opcode operand value
0 1 0 0 0 0 0 0 0 0 0 0 1
0 1 0
0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15
  • Load to the accumulator a value given by the
    operand.

13
JMP Operation
opcode operand address of
instruction
1 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0
0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15
  • Set the Program Counter to a value given by the
    operand.
  • Next instruction to execute is stored at the
    address given by the operand.

14
JNG Operation
opcode operand address of
instruction
1 0 0 1 0 0 0 0 0 0 0 0 0
0 1 0
0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15
  • Set the Program Counter to a value given by the
    operand only if the current value of the
    accumulator is negative.
  • Otherwise the next instruction will be executed.

15
JZR Operation
opcode operand address of
instruction
1 0 1 0 0 0 0 0 0 0 0 0 0
0 1 0
0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15
  • Set the Program Counter to a value given by the
    operand only if the current value of the
    accumulator is zero.
  • Otherwise the next instruction will be executed.

16
A Program Example
17
Difficulties of Machine Language
  • Writing and reading binary numbers is error prone
    and difficult.
  • Remembering operations as binary numbers is
    unintuitive.
  • Converting data and addresses to binary form is
    not fun.
  • Numeric addresses make it difficult to modify
    programs.

18
Assembly Language
  • There is one assembly language instruction per
    machine language instruction.
  • Mnemonic codes are used instead of opcodes.
  • Memory addresses are encoded symbolically using
    identifiers.
  • Pseudo-operations do not create machine
    instructions.
  • NUM DAT 0 instructs the assembler to change
    the decimal 0 into binary, store it to a memory
    cell, and associate identifier NUM to the address
    of this cell.

19
Mnemonic Codes
  • Binary Mnemonic Short
    Explanation
  • 1111 STP Stop the
    computer
  • 0001 ADD Add
    accumulator to operand
  • 0010 SUB Subtract
    operand from accumulator
  • 0011 LOD Load memory
    cell into accumulator
  • 0100 LDI Load
    immediate into accumulator
  • 0101 STO Store
    accumulator into memory cell
  • 0110 INP Input value
    and store into accumulator
  • 0111 OUT Output the
    value from accumulator
  • 1000 JMP Jump to
    instruction
  • 1001 JNG Jump to
    instruction if accumulatorlt0
  • 1010 JZR Jump to
    instruction if accumulator0

20
Program Example
21
Example 1
INP STO A
INP STO B INP
STO C LOD A ADD B
SUB C OUT
STP A DAT 0 B DAT 0 C
DAT 0
  • 1) Input three numbers a,b, and c.
  • 2) Compute ab-c and output the result.

22
Example 2
INP STO X
INP STO Y SUB X
JZR FIRST LDI 1
ADD Y STO Y OUT
JMP END FIRST LDI 3 ADD X
STO X END LOD X OUT
STP X DAT 0 Y DAT 0
  • Input x and y
  • If x y then
  • add 3 to x
  • else
  • add 1 to y
  • output y
  • output x

if xy JUMP
23
Example 3
Input 100 numbers Compute their sum Output the
result
START LDI 100 SUB COUNT
JNG END INP
ADD SUM STO SUM
LDI 1 ADD COUNT
STO COUNT JMP
START END LOD SUM
OUT STP COUNT DAT 1 SUM
DAT 0
Need another number?
if count gt 100 then done
Initialize count to 1 And sum to 0
Write a Comment
User Comments (0)
About PowerShow.com