Computer Architecture/컴퓨터구조[05]
[CA] Lecture #08
leziwn.cs
2023. 9. 25. 10:01
Unsigned Numbers
2s-Complement Signed Integers
Signed Negation
- 숫자 뒤집기
- +1
- 부호 붙이기
Sign Extension
- + --> 0
- - --> 1
Representing Instructions
: Assembly language --> Binary number
- RISC-V instructions: Encoded as 32-bit instruction words.
Hexadecimal
RISC-V R-format Instructions
- add destination, source 1, source 2
- sub destination, source 1, source 2
▶ function 7, function 3, opcode: Instruction 결정
▶ rd, rs1, rs2: $x0~$x31(32가지) --> 5-bit
R-format Example
RISC-V I-format Instructions
- addi destination, immediate(source)
- lw destination, immediate(source)
▶ rs1: source or base address
▶ immediate: constant operand or offset
- 2s-complement, sign extended (다른 부분은 모두 unsigned)
- 12 bits --> -2^11~(2^11-1)까지 표현 가능 (2048 bytes, 512 words)
I-format Example
RISC-V S-format Instructions
- SW source 2, immediate(source 1)
▶ rs1: base address
▶ rs2: source operand
▶ immediate: offset
- Split so that rs1 and rs2 fields always in the same place.
S-format Example
Summary: R, I and S Type Instructions
Machine Language
- Machine language: Binary representation used for communication within a computer system.
- Machine code: A sequence of such instructions.
- Instruction format: Layout of the instruction.
Example: Translation
Stored Program Computers
- Instructions represented in binary, just like data.
- Instructions and data stored in memory.
- Programs can operate on programs.
- Binary compatibility(호환성) allows compiled programs to work on different computers.
Example: Check Yourself