Computer Organization and Design PPT02
Computer Organization and Design PPT02
Computer
Xin Zeng, Associate Professor Dept.
of Information and Communication
Tongji University
Email: [email protected]
2.1 Computer Hierarchy Levels
Language understood by
the computer’s hardware:
machine language(0101..)
Usually discussed in terms
of assembly language
2
Some concepts
3
MIPS assembly language
4
2.2 Operations of the computer
hardware
5
6
7
8
9
2.3 Operands of the computer
hardware
Operands must be from a limited number
of Registers;
Register: a special location built directly
in hardware, actually inside of the CPU.
With a size of 32 bits = length of a word
Byte = 8 bits
10
11
2.3 Operands of the computer
hardware
Memory operands
Only a small amount of data is kept in
registers
Large data structures (like array) are kept in
the memory
Data transfer function: A command that
moves data between memory and
register
12
2.3 Operands of the computer
hardware
To access a word in memory, the
instruction must supply the memory
address
Address: a value used to denote the
location of a specific data elements in a
memory array.
Load a word
14
8 is a offset
$s3 is a base register
15
Alignment restriction: in MIPS, words
must start at addresses that are
multiples of 4.
16
Big-Endian and Little-Endian Formats
In a byte-addressable machine, two choices for the order in which
the bytes are stored in memory: most significant byte at lowest
address, referred to as big-endian, or least significant byte stored at
lowest address, referred to as little-endian
17
The "most significant" byte is
the one for the largest powers
of two: 231, ..., 224. The "least
significant" byte is the one for
the smallest powers of two:
27, ..., 20.
32-bit pattern 0x12345678 is
at address 0x00400000. The
most significant byte is 0x12;
the least significant is 0x78.
18
Store a word
19
20
Constant or Immediate operands
21
Constant or Immediate operands
22
2.4 Representing instruction in
the computer
Decimal number: base 10 number
Binary number: base 2 number
Hexadecimal number: base 16 number
23
24
Signed and Unsigned
Numbers
Unsigned numbers
25
Signed and Unsigned
Numbers
Signed numbers?
where to put the sign?
example:
0001 = 1ten ?
1001 = -1ten ?
26
Signed and Unsigned
Numbers
Let's answer another question:
27
Signed and Unsigned
Numbers
Signed numbers:
28
Signed and Unsigned
Numbers
29
Signed and Unsigned
Numbers
30
Signed and Unsigned
Numbers
31
Signed and Unsigned
Numbers
32
2.4 Representing instruction in
the computer
33
Field: each of these segment
0 (first segment)and 32 (last segment) (two
fields in combination) tell the computer
perform addition
17 = $s1, 18 = $s2, 8 = $t0
The fifth field is unused
34
MIPS instruction is 32 bit long
Equal to the length of word
35
R-type or R-format
37
38
Ref: https://blog.csdn.net/ben_chong/article/details/51794093
39
In binary:
40
2.5 Logic operations
REMEMBER:
Shamt = 4: stand for the shift
amount
0 in both op and funct fileds
rd = $t2
rt = $s0
rs = 0 is unused
42
AND: bit-by-bit operation that leaves 1 in the
result if both bits of the operands are 1.
43
or: bit-by-bit operation that leaves 1 in the
result if either operand is 1.
=
44
NOT: a logic bit-by-bit operation with one
operand that inverts the bits, i.e., it replace
every 1 with 0, and every 0 with 1;
NOR: A logic bit-by-bit operation with two
operands that calculates the NOT of the OR of
the two operands. ($t3 = 0)
45
Review
46
2.6 Instruction for making
decisions
47
flow chart:
48
49
Loops
50
51
52
More conditional operations
53
Unconditional jump instructions
j
Unconditionally jumps to the instruction at the
specified address
j exit # jump to the statement labeled by exit
jr
Jumps to the address contained in the specified
register
jr $ra # goto address $ra
54
55