Instructions: Language of The Computer: Omputer Rganization and Esign
Instructions: Language of The Computer: Omputer Rganization and Esign
Instructions: Language of The Computer: Omputer Rganization and Esign
Edition
The Hardware/Software Interface
Chapter 2
Instructions: Language
of the Computer
§2.1 Introduction
Instruction Set
◼ The repertoire of instructions of a
computer
◼ Different computers have different
instruction sets
◼ But with many aspects in common
◼ Early computers had very simple
instruction sets
◼ Simplified implementation
◼ Many modern computers also have simple
instruction sets
op rs rt rd sa funct
R format
op rs rt immediate
I format
op jump target
J format
§2.2 Operations of the Computer Hardware
Arithmetic Operations
◼ Add and subtract, three operands
◼ Two sources and one destination
add a, b, c # a gets b + c
◼ All arithmetic operations have this form
◼ Design Principle 1: Simplicity favors
regularity
◼ Regularity makes implementation simpler
◼ Simplicity enables higher performance at
lower cost
◼ Example: ECA86420
◼ 1110 1100 1010 1000 0110 0100 0010 0000
◼ Instruction fields
◼ op: operation code (opcode)
◼ rs: first source register number
◼ rt: second source register number
◼ rd: destination register number
◼ shamt: shift amount (00000 for now)
◼ funct: function code (extends opcode)
0 17 18 8 0 32 decimal
000000100011001001000000001000002 = 0232402016
op rs rt constant or address
6 bits 5 bits 5 bits 16 bits
◼ Result in $v0
◼ Result in $v0
◼ i in $s0
lhi $s0, 61 0000 0000 0111 1101 0000 0000 0000 0000
ori $s0, $s0, 2304 0000 0000 0111 1101 0000 1001 0000 0000
op rs rt constant or address
6 bits 5 bits 5 bits 16 bits
◼ PC-relative addressing
◼ Target address = PC + offset × 4
◼ PC already incremented by 4 by this time
Chapter 2 — Instructions: Language of the Computer — 54
Jump Addressing
◼ Jump (j and jal) targets could be
anywhere in text segment
◼ Encode full address in instruction
op address
6 bits 26 bits
Static linking
Simple portable
instruction set for
the JVM
Compiles
Interprets
bytecodes of
bytecodes
“hot” methods
into native
code for host
machine
1.5
0.5
0
C/none C/O1 C/O2 C/O3 Java/int Java/JIT
1.5
0.5
0
C/none C/O1 C/O2 C/O3 Java/int Java/JIT
2000
1500
1000
500
0
C/none C/O1 C/O2 C/O3 Java/int Java/JIT