3 Cmpe140 Isa2 S17
3 Cmpe140 Isa2 S17
3 Cmpe140 Isa2 S17
Donald Hung
(www.sjsu.edu/people/donald.hung/)
Professor
Computer Engineering Department
San Jose State University
[Partially adopted from Harris & Harris’ Digital Design and Computer Architecture]
CMPE140 Instruction Set Architecture & Language (2).1 Donald Hung, © 2017
Computer Hardware Structural Abstraction
The processor (CPU) is the core of a computer.
PLB
Arbiter Processor Local Bus (PLB)
OPB
Arbiter On-Chip Peripheral Bus (OPB)
CMPE140 Instruction Set Architecture & Language (2).2 Donald Hung, © 2017
Memory
Computers use memories to store information:
Instructions – form the program to be executed
Data – operands needed by the program
Why not just use registers?
Too expensive for the amount of information
needs to be stored
Recall: registers – fast but expensive
memories – slow but cheap
CMPE140 Instruction Set Architecture & Language (2).3 Donald Hung, © 2017
Memory Access
CMPE140 Instruction Set Architecture & Language (2).4 Donald Hung, © 2017
Memory Access (continued)
The MIPS uses a special-purpose register
named PC (program counter) for IM access
(read only)
- the PC’s content is the physical address of a memory
location (in the IM) where the current instruction is
stored
CMPE140 Instruction Set Architecture & Language (2).6 Donald Hung, © 2017
“Word Addressable” and “Byte Addressable” Memories
CMPE140 Instruction Set Architecture & Language (2).7 Donald Hung, © 2017
Big-Endian and Little-Endian Memory
How to store wide data in memory
Little-endian: byte numbers start at the little end, i.e., the
lowest address stores the LSB
Big-endian: byte numbers start at the big end, i.e., the
lowest address stores the MSB
Big-Endian Little-Endian
Byte Word Byte
Address Address Address
C D E F C F E D C
8 9 A B 8 B A 9 8
4 5 6 7 4 7 6 5 4
0 1 2 3 0 3 2 1 0
MSB LSB MSB LSB
CMPE140 Instruction Set Architecture & Language (2).8 Donald Hung, © 2017
MIPS Load Instructions
CMPE140 Instruction Set Architecture & Language (2).9 Donald Hung, © 2017
MIPS Store Instructions
CMPE140 Instruction Set Architecture & Language (2).10 Donald Hung, © 2017
MIPS Endianess
CMPE140 Instruction Set Architecture & Language (2).11 Donald Hung, © 2017
Data Alignment in Memory
CMPE140 Instruction Set Architecture & Language (2).12 Donald Hung, © 2017
Big- and Little-Endian Example
• Suppose $t0 initially contains 0x23456789. After the
following program is run on a big-endian system, what
value does $s0 contain? In a little-endian system?
sw $t0, 0($0)
lb $s0, 1($0)
Big-Endian Little-Endian
Word
Byte Address 0 1 2 3 Address 3 2 1 0 Byte Address
Data Value 23 45 67 89 0 23 45 67 89 Data Value
MSB LSB MSB LSB
Answer:
Big-endian: 0x00000045; Little-endian: 0x00000067
CMPE140 Instruction Set Architecture & Language (2).13 Donald Hung, © 2017