Assembly Flashcards

1
Q

What decides how much work each instruction performs in an assembly setting?

A

The ISA.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How many bytes does each RISC-V instruction have?

A

4.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

TRUE/FALSE: Despite different instructions in RISC-V having different purposes, each instruction has the same encoding structure.

A

FALSE. Each TYPE of instruction has an instruction set with the same encoding, but different parameters may be used for each.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is R-Type encoding? Where do parameters come from, and where does output go?

A

Arithmetic. Register to register.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is I-Type encoding? Where do parameters come from, and where does output go?

A

Immediate arithmetic. Register and immediate to register.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is S-Type encoding? Where do parameters come from, and where does output go?

A

Load/Store. Memory to register and register to memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is SB-Type (or B-Type) encoding? Where do parameters come from, and where does output go?

A

Branching. Register or immediate to Program counter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is UJ-Type (or J-Type) encoding? Where do parameters come from, and where does output go?

A

Jump and Link. Register or immediate to Program counter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is U-Type encoding? Where do parameters come from, and where does output go?

A

Load Upper immediate. Immediate to register.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How many bits are used in B-type encoding for where to jump to? Which bits? Note that 5 bits are used for rs2, 5 bits are used for rs1, 3 bits are used for funct3, and 7 bits are used for the opcode.

A

12 bits are used for B-Type (gotten by 32 - total of others), and the bits used are 1:12 from 0:31. This is because the last two bits don’t actually matter in jumping (since you’ll only ever jump to a whole byte), and therefore dropping 0 is fine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Suppose I want to save the immediate value 0xffffffff into register x3. What instructions would I need, in what order?

A

1 instruction (if running on code):
Addi -1 (written as 0xfff but converted automatically by the processor to carry the negative) plus x0 to x3.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why do most instructions in RISC-V use 12-bits to store immediate values?

A

Performance, benchmarking.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How many bytes does each x86 instruction have?

A

It varies. CISC is variable-width encoding.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What rule must each instruction, RISC or CISC, follow?

A

The longest one must be shorter than the clock period.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly