Instructions:
Language of the Computer
Constant
-
Kebanyakan constant adalah kecil
-
16-bit immediate adalah mencukupi
-
constant
kecil kerap digunakan(50% daripada operan)
-
e.g.
·
A = A + 5;
·
B = B + 1;
·
C = C - 18;
-
Jadi, dalam kebanyakan program, constant akan dimuatkan dalam 16 bit
yang diperuntukkan bagi immediate field
-
Design
Principle: Make the common case fast
– Common case: constant is small
–Hanya perlu menggunakan satu arahan
dalam common case
Untuk constant yang besar
-
Kita dapat memuatkan 32-bit ke dalam register
-
Mesti guna dua instuction, new "load
upper immediate" instruction
-
For
the occasional 32-bit constant
lui
rt, constant
·
Copies
16-bit constant to left 16 bits of rt
·
Clears
right 16 bits of rt to 0
Branch addressing
-
Arahan
cabang adalah dinyatakan
·
Opcode,
two registers, target address
-
Most branch targets are near branch
-
Formats:
-
dapat
menentukan register (seperti LW dan Sw) dan menambah ia untuk menangani
·
penggunaan
Instruction Address Register (PC =
program counter)
·
Kebanyakan
branch adalah local (principle of locality)
PC-relative
addressing
-
Immediate field adalah 16 bit tetapi kita perlu address yang 32 bit
-
Obtain address using PC-relative
addressing
·
On branch, new PC = PC + immediate field in branch
instruction
·
Actually, new PC = (PC + 4) +
immediate field in branch instruction
Jump addressing
-
Jump
(j and jal) targets could be anywhere in text segment
·
Encode
full address in instruction
-
J format ada 26
bits dalam address field
-
Untuk
mendapatkan 32 bits
·
Anggapkan
bahawa jump address adalah word address
·
26
+ 2 (least significant bits) = 28
·
Get 4 most significant bits from PC
·
4 + 26 + 2 = 32
·
Hanya
boleh jump antara 2^28= 256 MB block of addresses
- (Pseudo)Direct
jump addressing
·
Target
address = PC31…28 : (address × 4)
No comments:
Post a Comment