Lecture 5 Digital Computing Systems
Lecture 5 Digital Computing Systems
Not Easy!
Limited storage resources (memory and
registers)
No notion of types, it is the programmer
responsibility to use the correct instructions
Only go to control instructions
Amount of work done by an instruction is
smaller than a HLL instructions
Much longer to debug and much harder to
maintain
Difficult to think at that low level
Not portable
Device drivers
Interrupts
Some real-time embedded systems
etc...
The view/model
(registers and memory)
Assembly-Language
Instruction types
Data Types
the key difference between mediocre
and excellent programmers is whether
or not they know assembly language.
The Memory
Large number of locations
Each location has a fixed size width
(usually the width is 1 byte)
Collection of all locations is called
Text
Data
Direction of growth
At run-time
Stack
Why?
N---negative result
Z--- zero result
V--- overflow
C--- carry
other
Signed/unsigned integers
Floating point
Decimal (BCD)
characters
Instructions
Each assembly-level architecture has its
own group of instructions -> instruction
set
Instructions can be grouped into four
categories:
Data Transfer
Data Manipulation
Program Sequencing and Control
Trap/system call
Why MIPS?
Patterson and Hennessy use MIPS assembly language. Given the
overwhelming acceptance of their textbook as the standard, this
is already a strong argument.
RISC architectures actually are dominant.
It's best to teach a subject by going from the simple to the
complex. The MIPS R2000 instruction set architecture is
probably the simplest in existence for a real processor with a
significant market. In contrast, the Intel architecture, is
extremely complex.
Electrical and software engineers do, in fact, need to write
assembly-language programs for embedded processors. (e.g. HP
4000 laser printer, Nintendo, Sony playstation, etc.)
Other system integrators, such as router and telephone-switch
manufacturers, make use of embedded processors.
In all cases, these RISC architectures are extremely similar to
the MIPS R2000 architecture that Hennessy and Patterson use
throughout their text. A student who has learned the MIPS
R2000 instruction set is in a good position to write programs for
any embedded RISC processor.
http://www.cs.unibo.it/~solmi/teaching/arch_20022003/AssemblyLanguageProgDoc.pdf
(MIPS assembly Language Programmers Guide -> download it!)
http://logos.cs.uic.edu/366/notes/MIPS%20Quick%20Tutorial.htm
(A quick start on MIPS assembly -> look at it!)
Get Some books:
MIPS Assembly Language Programming
by Robert Britton. Published by Prentice Hall.
See MIPS Run
by Dominic Sweetman. Publisher: Morgan Kaufmann
Computer Structure
Keyboard,
Mouse
Computer
Processor
Control
(brain)
Datapath
Memory
Devices
(where
programs,
data
live when
running)
Input
Output
Disk
(where
programs,
data
live when
not running)
Display,
Printer
MIPS arithmetic
All instructions have 3 operands and order is fixed (destination
first)
Example:
C code:
a=b+c
MIPS code:
add a, b, c
MIPS arithmetic
Design Principle: simplicity favors regularity.
Of course this complicates some things...
C code: a = b + c + d;
MIPS code:
add a, b, c
add a, a, d
Operands must be registers,
Only 32 registers provided
Each register contains 32 bits
Design Principle: smaller is faster.
10
11
12
13
14
Meaning:
$t0 = Memory[$s3+24]
15
16
Memory Organization
Viewed as a large, single-dimension array, with an address.
A memory address is an index into the array
"Byte addressing" means that the index points to a byte of
memory.
0
8 bits of data
8 bits of data
8 bits of data
8 bits of data
8 bits of data
8 bits of data
8 bits of data
...
17
Memory Organization
Bytes
Instructions
Load and store instructions
Example:
C code:
A[12] = h + A[8];
MIPS code:
lw $t0, 32($s3)
add $t0, $s2, $t0
sw $t0, 48($s3)
number
Cant write:
18
Summary
MIPS
Instruction
Meaning
19
ori = OR immediate
20
21
22
23
24
25
26
27
28
(Section 2.8)
29
30