Test 4 Assmebly Language and Computer Architecture

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/80

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

81 Terms

1
New cards

Immediate addressing


MOV R1, #10   
loads the constant 10 into R1

2
New cards

Direct addressing

LOAD R2, 0x3000    loads the word stored at memory location 0x3000 into R2

3
New cards

Indirect addressing

LOAD R1, @0x200 if location 0x200 contains the pointer 0x500 @0x200 loads the value stored at 0x500

4
New cards

Register addressing

ADD R1, R2, R3 adds R2 and R3 and places the result in R1

5
New cards

Register-indirect addressing

LOAD R3, (R6)   loads the value found at the memory address stored in R6

6
New cards

Displacement addressing

LOAD R4, 12(R14)  computes the effective address as
BaseRegister + ConstantOffset. loads the value at address R14 + 12, often used to access a parameter relative to a frame pointer

7
New cards

Stack addressing

POP R4 PUSH R1

8
New cards

IF

Instruction Fetch
Fetch the instruction from instruction memory.

9
New cards

ID

Instruction Decode / Register Read
Decode instruction and read source registers

10
New cards

EX

Execute / Address Calculation

Perform ALU operations or compute memory address.

11
New cards

MEM

Memory Access

Access data memory for loads and stores.

12
New cards

WB

Write Back

Write results into the register file.

13
New cards

5 stage pipeline

IF, ID, EX, MEM, WB

14
New cards

data hazard

occurs when instructions need to use a value that has not yet been produced by a previous instruction, leading to a data dependency conflict

15
New cards

structural hazard

a conflict in computer architecture where two instructions attempt to use the same hardware resource at the same time, causing a stall in the pipeline

16
New cards

RAW (Read after write)

a data dependency where an instruction attempts to read a value from a register before a previous instruction has finished writing to

17
New cards

WAR (Write-After-Read hazard)

arises when an instruction attempts to write to a register before a preceding instruction has finished reading its value from that same register. In a strictly in-order, simple pipeline, this hazard is less likely

18
New cards

WAW (write-after-write)

occurs when two instructions write to the same register, but their execution order is different from the intended program order. This is a problem because if a later instruction writes to a register before an earlier instruction, the first instruction's result is overwritten

19
New cards

ALU-ALU Data Dependency

a specific type of Read After Write (RAW) data hazard in a pipelined processor, where one instruction's Arithmetic Logic Unit (ALU) operation depends on the result of the ALU operation of a preceding instruction

20
New cards

Control Hazard (Branch)

occurs in a pipelined processor when a branch instruction disrupts the normal sequential flow of execution, forcing the pipeline to wait to know the correct next instruction

21
New cards

Data Hazard (Load-Use)

pipeline hazard where an instruction immediately following a load instruction tries to use the data that was just loaded before the load operation has completed

22
New cards

Structural Hazard (Single Memory Port)

a type of pipeline hazard that occurs when two or more instructions simultaneously need to access the same memory port, which can only handle one request at a time

23
New cards

Mixed Hazards (Data + Control)

refers to the combination of data and control hazards, which are performance issues in a pipelined processor

24
New cards

What property must be preserved when reordering instructions

program semantics or the correct result/observable behavior of the single-threaded program. This is achieved by ensuring that all data dependencies and control dependencies between instructions are maintained

25
New cards

Data Fowarding

the process of sending data directly from one part of a system to another, bypassing intermediate steps to improve performance

26
New cards

Flush instructions

means to empty the pipeline of instructions that have been fetched but are no longer needed, which is a common response to mispredicted branches or data dependencies

27
New cards

Little endian

a byte order where the least significant byte of a multibyte data value is stored at the lowest memory address

28
New cards

Big endian

the most significant byte (the one with the highest value) is stored at the lowest memory address, making it the first in a sequence

29
New cards

principle of locality of reference

the observation that when a program accesses a memory location, it is likely to access that same location and nearby locations again in the near future

30
New cards

Temporal Locality (Locality in Time)

If a memory location is accessed, it is likely to be accessed again soon

31
New cards

Spatial Locality (Locality in Space)

If a memory location is accessed, it is likely that nearby memory locations will be accessed soon

32
New cards

Cache Hit

The data requested by the CPU is found in the cache. This is a fast and efficient outcome.

The CPU asks for the value at address 0x1000, and that address's data is already stored in a cache line. The cache provides the data immediately

33
New cards

Cache Miss

The data requested by the CPU is not found in the cache. The CPU must then wait for the data to be fetched from the slower main memory, which incurs a significant performance penalty

The program accesses a new variable for the very first time. The CPU looks for it in the cache, doesn't find it (a miss), and must load it from RAM into the cache

34
New cards

Compulsory Miss (Cold Miss)

Occurs when a piece of data is accessed for the very first time. It is impossible to avoid these misses because the data has never been in the cache before

35
New cards

Capacity Miss

Occurs when the cache is not large enough to hold all the data needed by the program

36
New cards

Conflict Miss

Occurs in set-associative or direct-mapped caches when multiple memory blocks map to the same cache set (or line)

37
New cards

What is the purpose of a tag in a cache line?

uniquely identify which specific block of main memory is currently stored in that cache line

38
New cards

L1 Cache

The smallest and fastest, built directly into the CPU core

39
New cards

L2 Cache

Larger and slower than L1, but still much faster than RAM

40
New cards

L3 Cache

The largest and slowest of the CPU caches (but still faster than RAM). It is shared among all the cores on a CPU chip

41
New cards

Unified Cache (Mixed Cache)

A single cache stores both instructions (the program code) and data (the variables the code operates on)

42
New cards

Split Cache (Harvard Architecture within the CPU)

There are two separate caches:

  • L1 Instruction Cache (I-cache): Only stores instructions.

  • L1 Data Cache (D-cache): Only stores data

43
New cards

Why do deeper pipelines require more aggressive caching strategies?

to break down instruction execution into more, smaller stages. This allows for higher clock speeds.

44
New cards

how direct-mapped caching works

the simplest cache structure. Each block of main memory can be placed in exactly one specific cache line

45
New cards

Direct-Mapped

Each memory block maps to exactly one cache line

46
New cards

Fully Associative

Any memory block can be placed in any cache line

47
New cards

Set-Associative

Each memory block maps to exactly one set, but can be placed in any line within that set

48
New cards

How does increasing associativity affect cache hit rate and hardware cost?

because it reduces conflict misses by giving a memory block more possible locations to reside in the cache and increases hardware cost and complexity

49
New cards

Number of Cache Lines

(Total Cache Size) / (Block Size)

50
New cards

What fields make up a memory address in a direct-mapped cache?

Tag, Index, Block offset

51
New cards

Index

The middle bits. Used to select which specific cache line to look in

52
New cards

Block Offset

The least significant bits. Used to find the specific byte within a cache block

53
New cards

In a 2-way set-associative cache, when both blocks in a set are full, what does the replacement policy do?

evict to make room for the new block

54
New cards

LRU (Least Recently Used)

Evicts the block that has not been accessed for the longest time

55
New cards

FIFO (First-In, First-Out)

Evicts the block that has been in the cache the longest, regardless of how recently it was used

56
New cards

random replacement

Evicts a randomly selected block from the set. It is very simple and cheap to implement in hardware

57
New cards

Write-Through caches

When the CPU writes to the cache, the data is immediately written to both the cache block and the main memory

58
New cards

write-back caches

When the CPU writes to the cache, the data is only written to the cache block. The main memory is updated only when this modified ("dirty") block is evicted from the cache

59
New cards

What problem does a write buffer solve in a write-through cache?

solves the performance problem of write-through caches

60
New cards

Average Memory Access Time (AMAT)

Hit Time + (Miss Rate × Miss Penalty)

61
New cards

Hit Time

Time to access the cache on a hit.

62
New cards

Miss Rate

The fraction of accesses that are misses (1 - Hit Rate)

63
New cards

Miss Penalty

The additional time required to fetch a block from the next level of the memory hierarchy on a miss

64
New cards

How can block size affect performance?

Can reduce compulsory misses because you prefetch useful data

and

Can increase the number of conflict and capacity misses

65
New cards

Cache Coherence

the problem and set of solutions that ensure all caches in a multiprocessor system (like a multicore CPU) have a consistent view of shared memory

66
New cards

Index Bits

log₂(Number of Lines)

67
New cards

Offset Bits

log₂(Block Size)

68
New cards

Tag Bits

Address Size - Index Bits - Offset Bits

69
New cards

Number of Sets

Number of Lines / Associativity

70
New cards

Effective Miss Penalty

L2 Hit Time + (L2 Miss Rate × L2 Miss Penalty)

71
New cards

why register addressing does not involve any memory access

operands are already located within the Central Processing Unit (CPU)

72
New cards

when is indirect addressing is preferable

when dealing with large datasets, dynamic memory, and pointers

73
New cards

When is Immediate addressing is more efficient than register-indirect addressing

when the value is a constant that is part of the instruction itself

74
New cards
75
New cards

why a load-use data hazard typically requires at least one stall

 because a load instruction has to retrieve the data from memory

76
New cards

Why are WAR (Write After Read) and WAW (Write After Write) hazards normally impossible in a simple in-order 5-stage RISC pipeline

because instructions are executed in order in a RISC pipeline

77
New cards

1. LW R1, 0(R2)  

2. ADD R3, R1, R4

Data Hazard(Load use) / RAW hazard

78
New cards

1. LW R1, 0(R2) 

2. SW R3, 4(R2) 

3. ADD R4, R5, R6

Which stages of which instructions will compete for memory access?

 stages of 1 and 2; both need access to the same memory R

79
New cards

When is the branch outcome known in a 5-stage pipeline?

It’s known in the execution stage

80
New cards

 branch delay slot scheduling

an instruction is placed in the instruction immediately following a branch

81
New cards

branch

an instruction that alters the sequential flow of execution