Computer Architecture Fundamentals: MIPS & Memory Concepts
Memory Data Interpretation and Endianness
An array of 10 unsigned integers is stored in memory. Each integer occupies 3 bytes. The data, stored in little-endian format from low address to high, is:
7D21F05BE3FA665531540A6BCA73AB714750AF050A2F395F71CC0CC367AB
Problem: What is the unsigned integer in decimal read from memory if element 9 is read in big-endian format? (The first element is element 0.)
Segmentation of 3-Byte Integers
The 10 unsigned integers, each 3 bytes (6 hexadecimal digits), are segmented as follows:
7D21F05BE3FA665531540A6BCA73AB714750AF050A2F395F71CC0CC367AB
Locating Element 9
Element 9 is C367AB.
Converting to Big-Endian Format
The data C367AB is currently in little-endian format, meaning the least significant byte (LSB) is at the lowest address and the most significant byte (MSB) is at the highest address. To convert to big-endian, we reverse the byte order:
- Little-endian:
C3(LSB)67AB(MSB) - Big-endian:
AB(MSB)67C3(LSB)
Decimal Conversion
Converting the big-endian hexadecimal number AB67C3 to decimal:
AB67C3 (hex) = 11,233,219 (decimal)
Answer: 11233219
MIPS Instruction Encoding: The div Instruction
Instruction: div $t0, $t6
This instruction divides the value in register $t0 by the value in register $t6. The quotient is stored in the LO register and the remainder in the HI register.
MIPS R-Format Fields for div
- Opcode: For R-format instructions like
div, the opcode is0(000000in 6 bits). - RS (Source Register 1):
$t0corresponds to register 8 (01000in 5 bits). - RT (Source Register 2):
$t6corresponds to register 14 (01110in 5 bits). - RD (Destination Register): The
divinstruction does not write to a general-purpose register directly, so this field is0(00000in 5 bits). - Shamt (Shift Amount): Not used for
div, so this field is0(00000in 5 bits). - Funct (Function Code): The
divfunction code is0x1A(011010in 6 bits).
Answer (in the order: opcode, funct, rs, rt, rd): 000000,011010,01000,01110,00000
MIPS Instruction Decoding: The subu Instruction
Problem: Suppose the opcode of a MIPS instruction is 0 (decimal), the funct code is 100011 (binary), and the remaining machine code is ca140 (hexadecimal), from high-order bit to low-order bit. What is the instruction? When showing the registers, use names (e.g., $t0, $s2) instead of indices (e.g., $8, $17).
Step 1: Identify the Instruction Type
The funct code 100011 corresponds to the subu (Subtract Unsigned) instruction. Since the opcode is 0, this confirms it is an R-format instruction.
Step 2: Convert Remaining Hexadecimal Code to Binary
The remaining machine code is ca140 (hexadecimal). Converting each hexadecimal character to its 4-bit binary equivalent:
C=1100A=10101=00014=01000=0000
Concatenating these gives the 20-bit binary string: 11001010000101000000.
Step 3: Parse the Binary Machine Code into R-Format Fields
For R-format instructions, the fields are arranged as: opcode (6 bits) | rs (5 bits) | rt (5 bits) | rd (5 bits) | shamt (5 bits) | funct (6 bits).
Given the opcode is 000000 and funct is 100011, the 20-bit remaining code (11001010000101000000) represents rs, rt, rd, and shamt.
| Field | Bits 31-26 | Bits 25-21 | Bits 20-16 | Bits 15-11 | Bits 10-6 | Bits 5-0 |
|---|---|---|---|---|---|---|
| Name | Opcode | RS | RT | RD | Shamt | Funct |
| Binary Value | 000000 | 11001 | 01000 | 01010 | 00000 | 100011 |
Step 4: Convert Register Field Values to Decimal
rs=11001(binary) =25(decimal)rt=01000(binary) =8(decimal)rd=01010(binary) =10(decimal)
Step 5: Map Register Numbers to MIPS Register Names
Using the MIPS register conventions:
- Register
25=$t9 - Register
8=$t0 - Register
10=$t2
Step 6: Construct the MIPS Instruction
The subu instruction format is subu rd, rs, rt.
Answer: subu $t2, $t9, $t0
Computer Systems Concepts: True or False Statements
Evaluate the following statements. True statements are marked with [TRUE], and false statements include a brief explanation.
- [TRUE] The execution of programs is controlled by operating systems.
- [TRUE] Both the data path and control units in a CPU are implemented by digital circuits which consist of gates and wires.
- Random access storage is slower than sequential access storage. (False: Random access memory (RAM) is significantly faster than sequential access storage like tape drives.)
- [TRUE] Theoretically, a program, no matter how large it is, can be written entirely in an assembly language.
- [TRUE] A network card is both an input and output device.
- On a multi-core CPU, the cores share the same ALU. (False: Each core within a multi-core CPU typically has its own Arithmetic Logic Unit (ALU).)
- [TRUE] Modern computers can solve more complex problems with greater power efficiency and optimized memory usage compared to previous generations.
- CPU hardware can fully detect and exploit the parallelism in software. (False: Fully detecting and exploiting software parallelism is a complex challenge, often requiring compiler optimizations or explicit parallel programming.)
- [TRUE] Audio cards can be connected to a computer through PCI, which augments the system bus.
- [TRUE] Multithreaded applications can spread threads across multiple cores for increased throughput.
- [TRUE] Nowadays, computers are often considered to be in the fifth generation of electronic computers.
- Every wafer contains multiple dies, and a single die can contain multiple cores. (False: A single die can indeed contain multiple cores, meaning not every die has only one core, and a 4-core CPU does not necessarily require 4 separate dies.)
- Any program running on 8 CPUs at the same time can run 8 times as fast. (False: Parallel speedup is rarely linear due to factors like communication overhead, synchronization, and Amdahl’s Law.)
- The first generation of electronic computers were built with vacuum tubes, and the next three generations of electronic computers were built with transistors. (False: Only the second generation was primarily defined by discrete transistors; subsequent generations (third and fourth) were characterized by integrated circuits and microprocessors, respectively.)
