Hardware Software Interface - Lecture03-Isa
Hardware Software Interface - Lecture03-Isa
CISC vs RISC
CISC
Assembly programming HLL features as instruction
Small # registers, memory not that slow memory
operands
Code size must be small variable length
Backward compatibility complexity increases
RISC
Compilers Simple instructions
Large # registers, memory much slower than processor
load store architecture
Simple and fast decoding fixed length, fixed format
Integer Arithmetic
+
*
/
%
add
sub
mul
div
rem
Relational
<
<=
>
>=
==
!=
slt,
sle,
sgt,
sge,
seq
sne
sltu
sleu
sgtu
sgeu
C operator
Comparison
Reverse
Branch
==
seq
bnez
!=
seq
beqz
<
slt, sltu
bnez
>=
slt, sltu
beqz
>
slt, sltu
bnez
<=
slt, sltu
beqz
Operators continued
Bit-wise logic
|
&
^
~
or
and
xor
not
Boolean
||
&&
(src1 != 0 or src2 != 0)
(src1 != 0 and src2 != 0)
Shifts
>>
>>
<<
(signed)
(unsigned)
shift-right-arithmetic
shift-right-logical
shift-left-logical
Operand Types
Usually based on scalar types in C
Type modifier
C type declarator
Machine type
unsigned
int, long
uint32
unsigned
short
uint16
unsigned
char
uint8
unsigned
long long
uint64
signed
int
int32
signed
short
int16
signed
char
int8
signed
long long
int64
boolean
uint1
float
float32
double
float64
&<type_specifier>
uint32
R1 = R2 + R3
2:
R1 = R1 + R2
1:
+R1
r1, [address]
r2, r1
r1, r3
r4, r2
# this is simply a re-use of r1, but the value of r1 had to be copied
into r2
Absolute
Normally used for function call and return
But not all function addresses are compile-time constants, so jump to contents of
register is also necessary
Load/Store addresses
Relative
Absolute
Arithmetic operands
Small numbers, representable in 5 10 bits are common
Branch offsets
10 bits catches most branch distances
10
lw
store
half-word
word
sw
signed unsigned
lh
byte
lhu
half-word
sh
byte
sb
signed unsigned
lb
lbu
11
Addressing mode
Displacement
39
17
Immediate
Register
Scaled
55
32
TeX
16
0
1
spice
24
6
gcc
11
Indirect
43
10
20
30
40
50
60
H&P
Fig. 2.7
12
Register + offset
Generic form for accessing via pointers
Multi-dimensional arrays require address calculations
PC relative addresses
Useful for locating commonly-used constants in a pool of
constants located in the .text section
13
14
J-type (jump)
jump instructions with a 26 bit address
Inf3 Computer Architecture - 2011-2012
15
5bits
5bits
5bits
5bits
6bits
opcode
regrs
regrt
regrd
shamt
funct
add
$1, $2, $3
special
$2
$3
sll
$4, $5, 16
special
$5
$4
$1
add
16
sll
16
5bits
5bits
opcode
regrs
regrt
lw
$1, offset($2)
lw
$2
$1
beq
beq
$4
$5
addi
addi
$2
$1
0xfff6
16bits
immediatevalue/addr
address offset
17
call func
26bits
address
call
18
ISA Guidelines
19