Docsity

Lec for class to learn things, Summaries of Computer Engineering and Programming

Partial preview of the text

Download Lec for class to learn things and more Summaries Computer Engineering and Programming in PDF only on Docsity!

SJSU

SAN JOSÉ STATE

UNIVERSITY

Lecture 2.

Processor Instruction Set

Architecture & Language (2)

Haonan Wang

Reference: CMPE 140, Hyeran Jeon CMPE 140, Donald Hung

CMPE 140

Computer Architecture & Design

A Brief Review

  • One line of HLL can involve: 1. Load operand values from memory to registers 2. Do computation on registers 3. Move the results from register to memory

2

Arithmetic operations add, sub, mult, div, … Logical operations shift, and, or, xor, … Conditional operations jump, branch on condition, …

Data load operations move, load data, …

Data store operations move, store data, …

About MIPS Assembly

  • CPUs use their own assembly languages
    • Assembly language of ARM, Pentium, Opteron… are all different
  • MIPS Assembly Features
    • Very similar to ARM Assembly
    • One of the earliest RISC architectures that used pipelined instruction processing
  • Developed by MIPS Technologies
    • Now maintained by Wave Computing
    • Various generations
      • MIPS I~V
      • MIPS32 (32-bit processor)
      • MIPS64 (64-bit processor)
      • microMIPS.. 4

MIPS Processor Organization

5

Memory

CPU

$ ... $

Integer Registers

Arithmetic Unit

Multiply Divide

Lo Hi (^) Coprocessor 1 (FPU)

$ ...

$

Floating -point

Arithmetic Unit

Coprocessor 0 (Traps and Memory)

VAddr Cause Status EPC

32 bit 32~64bit

Our Focus

Registers

MIPS Data Sizes

  • Integer: 3 Sizes Defined
    • Byte (B)
      • 8-bits
    • Halfword (H)
      • 16-bits = 2 bytes
    • Word (W)
      • 32-bits = 4 bytes

7

  • Floating-point: 2 Sizes Defined
    • Single (S)
      • 32-bits = 4 bytes
    • Double (D)
      • 64-bits = 8 bytes
      • For a 32-bit data bus, a double needs 2 memory reads

Your Thoughts

8

When storing a series of bytes data in the

memory, how it can be uniquely identified

and therefore retrievable?

Endian-ness

  • Endian-ness refers to the two alternate methods of ordering the bytes in a

larger unit (word, long, etc.)

  • Big-Endian: IBM, SPARC, Motorola
    • Most Significant byte (MSB) is put at the starting (low) address
  • Little-Endian: Intel, DEC
    • Least Significant byte (LSB) is put at the starting (low) address
  • Supporting both
    • MIPS, PowerPC, ARM

The longword value:

Big-Endian Little-Endian

0 x 1 2 3 4 5 6 7 8 can be stored differently

78

0x

56

0x01 34 0x

12

0x03 12

0x

34

0x01 56 0x

78

0x

10

Memory Characteristics & Assumptions

  • Half-word and Word data are addressed with lowest byte address

among the bytes in the data

  • Addresses from left to right follows the same order as addresses from top

to bottom

  • We will use Little-Endian for MIPS in this course

11

7C 12 F3 3B

… 0x

0x 0x

Logical Word-Oriented View

Memory Organization Example 2

Example: If the memory layout in MIPS is given like below

The half-word value in address

0x0000 is ( )

0x0001 is ( )

0x0002 is ( )

The word value in address

0x0002 is ( )

0x0004 is ( )

13

7C 12 F3 3B

… 0x

0x 0x

Logical Word-Oriented View

0xF33B Incorrect addressing 0x7C

Incorrect addressing 0x8E

Tips to Remember Endianness

14

Looks normal (same as writing order) when address is from low to high

Looks strange here But same as writing order when address is from high to low

word value:

Little-Endian

0 x 1 2 3 4 5 6 7 8

78

0x

56

0x02 34 0x

12

0x00 12

0x

34

0x01 56 0x

78

0x

… 0x

0x

Logical Word-Oriented View

Basic Instruction Formats

  • Example: Format with 3 registers

add $4, $3, $2 # $4 = $3 + $

16

Register File

If $2 and $3 have integer values 3 and 2 each,

$4 will have ( 5 ) after executing this instruction

R-Type Instructions

  • We call the instructions that use three registers as R-type Instructions
    • 2 registers as source, 1 register for result
  • Examples:
    • sub Rd, Rs, Rt # Rd = Rs – Rt
    • mul Rd, Rs, Rt # Rd = Rs ***** Rt
    • and Rd, Rs, Rt # Rd = Rs & Rt
    • or Rd, Rs, Rt # Rd = Rs | Rt
    • xor Rd, Rs, Rt # Rd = Rs ^ Rt
    • slt Rd, Rs, Rt # if (Rs < Rt) Rd = 1 ; else Rd = 0 ;
    • many more

17

Replace Rd, Rs, Rt

with actual registers

Instructions Using Immediate Value

  • What if you want to use an immediate value?
    • E.g. i = i + 1; // add immediate value 1 to i

addi Rt, Rs, imm # Rt = Rs + imm

19

Command (operation)

Destination Register (stores calculation result)

Source Register (stores operand value)

Immediate operand (stores immediate operand value)

Instructions Using Immediate Value

  • Example: Instruction format with immediate value

addi $4, $3, 1 # $4 = $3 + 1

20

Register File

If $3 has integer value 2,

$4 will have ( 3 ) after executing this instruction