TM103 Chapter 4
TM103 Chapter 4
MARIE:
An Introduction to a Simple Computer
In addition, you will learn how the Instruction Set Architecture (ISA) plays the role
of an interface between the software and Hardware. Mainly, you will have a look
at MARIE, which has a very simple, yet powerful, instruction set.
Introduction
• CPU Basics and Organization
• The Bus
• Clocks
• The Input/Output Subsystem
• Memory Organization and Addressing
• Interrupts
Marie
Instruction processing
A simple program
Extending our ISA
November 27, 2023 TM103 - Arab Open University 4
Introduction
• A Memory stores
both data and
program instructions
(both binary!)
• The CPU fetches,
decodes, and
executes program
instructions
sequentially
3. Execute Instruction 1
• Execute the Instruction 2
Instruction 3
instruction Instruction 3
results in Result
registers or
…
memory …
…
Instruction N
The two principal parts of the CPU are the Datapath and the
Control unit.
– Datapath - consists of an arithmetic-logic unit (ALU) and network of
storage units (registers) that are interconnected by a data bus that is
also connected to main memory.
– Control Unit - responsible for sequencing the operations and making
sure the correct data is in the correct place at the correct time.
Registers hold data that can be readily accessed by the CPU. They are places
to store a wide variety of data (Numerical data, Addresses, Control
information,..). They are located on the processor so information can be
accessed very quickly
– The control unit directly accesses data inside the registers
The control unit (CU) determines which actions to carry out according to
the values in a program counter register and a status register.
• It fetches and decodes sequentially the instructions stocked in the
main memory.
• It27,also
November 2023 monitors the execution of these
TM103 - Arab Open Universityinstructions and the transfer
13
of all information.
Computer Buses and Clocks
The CPU communicates with the other components via a Bus. Moreover, and
in order to maintain synchronization of the activities, the computer contains
at least one clock.
Buses:
A Bus is a set of wires that simultaneously convey a single bit along each line
(parallel movement). It connects multiple subsystems within the system.
Multipoint Bus
Clocks:
Every computer contains at least one clock that synchronizes the activities
of its components.
The CPU requires a fixed number of clock ticks to execute each
instruction.
Moreover, instruction performance is often measured in clock cycles
instead of seconds.
The clock frequency, measured in megahertz or gigahertz, determines the
speed with which all operations are carried out.
Byte addressable: Each byte has its own address (each memory row
contains 8 bits only)
Word addressable: Each word has a unique address (each memory row
contains one word that can be larger than 8 bits).
Now, how many addresses, and how many address bits do we have in a
given memory?
Example 2: How many bits would you need to address a 2M × 32 memory if:
a) The memory is byte-addressable?
b) The memory is word-addressable?
Solution:
a) There are 2M × 4 bytes (recall that 32 bits =4 bytes), which equals
21 * 220* 22 bytes = 223 bytes. Hence, 23 bits are needed for an
address.
b) There are 2M words (32 bits are considered as 1 word, since the
memory is word addressable), which equals 21 × 220 words = 221
words. Hence, 21 bits are required for an address.
Access is more efficient when memory is organized into banks of chips with
the addresses interleaved across the chips.
The best way to explain how memory is organized, is found in the following
example.
Example: How to build a 32Kx16 word addressable RAM memory with only
2Kx8 RAM chips.
Introduction
MARIE
• Introduction
• The Architecture
• Registers and Buses
• The Instruction Set Architecture
• Register Transfer Notation
Instruction processing
A simple program
Extending our ISA
November 27, 2023 TM103 - Arab Open University 24
MARIE – Introduction
We are now familiar with computer components but how these are
connected together? How these work together?
Leonardo Da Vinci once said:
“When you wish to produce a result by means of an instrument, do not allow yourself
to complicate it”
In this part we will use a MARIE, A Machine Architecture that is Really
Intuitive and Easy.
A very simple architecture, MARIE, and its ISA are presented to allow you to
gain a full understanding of the basic architectural organization involved in
program execution.
MARIE exhibits the classical von Neumann design and includes a program
counter, an accumulator, an instruction register, 4096 bytes of memory, and
two addressing modes. Assembly language programming is introduced to
reinforce the concepts of instruction format, instruction mode, data format,
and control that are presented earlier.
November 27, 2023 TM103 - Arab Open University 25
MARIE – Architecture, Registers, and Buses
Architecture
The MARIE architecture is shown in the figure below:
Registers
Buses
MARIE cannot transfer data or instructions into or out of registers
without a bus.
In MARIE, we assume a common bus scheme
The registers are interconnected. They are also connected with main
memory through a common data bus.
A unique number that is set on the control lines whenever that device is
required to carry out an operation identifies each device on the bus.
Memorize
this table!
AC x y z Input Output
Initial Value 5 10 2 0
Load x 10 10 2 0
Store y 10 10 10 0
Add x 20 10 10 0
Subt y 10 10 10 0
Input 3 10 10 0 3
Skipcond 800 3 10 10 0
Jump finish 3 10 10 0
Store z 3 10 10 3
Add y 13 10 10 3
finish, Output 13 10 10 3 13
Halt
November 27, 2023 TM103 - Arab Open University 34
The Instruction Set Architecture (ISA)
The leftmost four bits, 0011, are equal to 3, which is the Add instruction.
The address bits indicate address 00E in hex (or 14 in decimal). This
means that the order will be given to go to main memory, get the data
value at address 00E, and add this value to the AC.
The new value in the AC would then be the sum of the old value of the
AC and the data fetched from address 00E.
Bits 11 and 10 (say b11b10) in the address field specify the condition to
be tested:
- b11b10 = 00: The CPU tests if AC < 0
- b11b10 = 01: The CPU tests if AC = 0
- b11b10 = 10: The CPU tests if AC > 0
In figure 4.11, we see that the opcode is 8 and b11b10 (bits 11 and 10)are 01,
meaning that the next instruction will be skipped if the value in the AC is
equal to zero.
In general, we use:
- SKIPCOND 000 which means skip the next instruction if the AC <0.
- SKIPCOND 400 which means skip the next instruction if the AC =0.
- SKIPCOND 800 which means skip the next instruction if the AC >0.
Note that 000, 400 and 800 are in base 16. They are equivalent to 12 bits
(Address part).
November 27, 2023 TM103 - Arab Open University 38
Register Transfer Notation
Skipcond
if IR[11–10] = 00 then {if bits 10 and 11 in the IR are
both 0}
Machine Cycle
It is worth mentioning that MARIE, like any other computer architecture, follows the
basic machine cycle: the fetch, decode, and execute cycle.
Introduction
MARIE
Instruction processing
A simple program
Extending our ISA
The table below shows a program written in assembly language for MARIE
What does this program do?
This program simply adds to numbers and stores the result in the main memory.
- It loads the value stored at the location address 10416 into AC (the value is
002316 = 3510)
- It adds this value to the value stored at the location address 105 16 (the value is
FFE916 = (-23)10)
- Stores the sum into the location address 10616.
So, what 27,
November will be stored in the location
2023 address
TM103 - Arab 10616?
Open University 46
A simple program
Now, let us discover what happens during each “Fetch, decode, execute” cycle.
The tables below show the effect of each instruction on the registers:
• Load 104:
• Add 105:
• Store 106:
The first of these is the origination directive, ORG. The ORG directive controls the
starting address of your program. If you do not include an ORG directive in your
code, the first address of your program is automatically 000h.
The other three directives enable you to put constants in your program as decimal
(DEC), octal (OCT), and hexadecimal (HEX) numbers.
Introduction
MARIE
Instruction processing
A simple program
Extending our ISA
Memorize
this table!
Exercise:
1. Write a program that calculates 2X + Y - Z where
X, Y, Z are three different numbers in three
different memory locations. Store the result in
the main memory and display it.
2. Implement your code in MARIE simulator.
3. Check if you have errors.
4. Correct your errors and run your program.