riscv_assembly (1)

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/137

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.

138 Terms

1
New cards

What does RISC-V stand for?

Reduced Instruction Set Computer - Five.

2
New cards

What are the four types of contents in assembly source code?

Comment, Directive, Label, CPU Instruction.

3
New cards

What symbol indicates a comment in assembly code?

A pound sign '#'.

4
New cards

What is the purpose of the .data directive?

It indicates the section for global, initialized variables.

5
New cards

What is the meaning of BSS in an executable?

Block Started by Symbol - it contains uninitialized variables.

6
New cards

What is a key characteristic of RISC-V architecture?

It is a load/store architecture.

7
New cards

What are the register names in RISC-V?

Registers can be referred by position (e.g., x0-x31) or function (e.g., a0 for argument) .

8
New cards

What does the 'add' instruction do in RISC-V assembly?

It adds two registers and stores the result in a destination register.

9
New cards

What does the 'li' pseudo-instruction do?

Loads an immediate value into a register.

10
New cards

What section of an executable contains CPU instructions?

The text section.

11
New cards

How is a global label made visible to the linker?

.global directive.

12
New cards

What is the result of the 'sub' instruction in RISC-V?

It subtracts the second source register from the first and stores the result in the destination register.

13
New cards

What instruction type is 'addi'?

I-type instruction.

14
New cards

What does the 'jal' instruction do?

It performs a jump and link; saving the return address.

15
New cards

What registers are considered saved registers (callee-saved)?

Registers x8, x9, x18 - x27.

16
New cards

What information does 'beq' instruction check?

It checks if two registers are equal and performs a jump if they are.

17
New cards

What type of instruction is 'lw'?

Load word instruction.

18
New cards

In RISC-V, how is floating point addition performed?

Using instructions like 'fadd.s' or 'fadd.d'.

19
New cards

What does the 'fsw' instruction do?

It stores a float from a register to memory.

20
New cards

What does the 'slt' instruction accomplish?

Sets the destination register to 1 if rs1 is less than rs2.

21
New cards

What is the purpose of using 'ecall' in RISC-V?

To invoke a service.

22
New cards

Which registers are used for function arguments?

Registers a0 to a7.

23
New cards

What does the .asciz directive do?

Creates a null-terminated ASCII string.

24
New cards

How are branch instructions like 'bne' structured in RISC-V?

They check conditions and jump to a label based on the comparison.

25
New cards

What is the result of the 'or' instruction?

Performs a bitwise OR operation between two registers.

26
New cards

How many bits wide are RISC-V registers?

64 bits.

27
New cards

What does 'fneg.s' do?

Negates a single-precision floating-point value.

28
New cards

What kind of notation does the 'mul' instruction use?

R-type notation.

29
New cards

What instruction type is used to load a byte?

Load byte instruction (lb).

30
New cards

What service number needs to be stored in which register for making an ecall?

Service number in register a7.

31
New cards

What is the assembly code directive to create a byte value?

.byte directive.

32
New cards

What does the instruction 'jalr' do?

Jumps to an address held in a register.

33
New cards

What does .bss stand for in assembly?

Block Started by Symbol; it contains uninitialized variables.

34
New cards

What is one benefit of using RISC instruction set?

It simplifies the design of the CPU.

35
New cards

Which register is hardwired to zero in RISC-V?

Register x0.

36
New cards

How is the instruction 'div' categorized?

R-type instruction.

37
New cards

What does the 'ret' instruction accomplish in RISC-V?

Returns from a subroutine.

38
New cards

What function do the 'a' registers (a0-a7) serve in function calls?

They are used for passing function arguments.

39
New cards

What does 'srl' instruction perform?

Performs a logical right shift.

40
New cards

What registers are considered temporary registers (caller-saved)?

Registers t0 - t6.

41
New cards

Give an example of an immediate value instruction.

addi rd, rs, imm.

42
New cards

What does the 'srai' instruction do?

Performs an arithmetic right shift.

43
New cards

What is the outcome of the 'rem' instruction?

Calculates the remainder of the division of two registers.

44
New cards

What do floating-point instructions use in their operation?

They operate on float values stored in registers.

45
New cards

What does 'li' do when used with an immediate large number?

Loads a large constant directly into a register.

46
New cards

What kind of instruction is 'xori'?

I-type logical immediate instruction.

47
New cards

What method do the jump and link instructions use?

PC-relative addressing.

48
New cards

What purpose do assembler directives serve?

They provide instructions to the assembler.

49
New cards

For which architecture is RISC-V designed?

It is designed for reduced instruction set computing.

50
New cards

How does the instruction 'lbu' differ from 'lb'?

'lbu' loads an unsigned byte.

51
New cards

What is the instruction to load a double-precision float from memory?

fld instruction.

52
New cards

Name two types of floating point data types in RISC-V.

Single (S) and Double (D).

53
New cards

What is the distinction between 'blt' and 'bge'?

'blt' jumps if less than, 'bge' jumps if greater than or equal.

54
New cards

What does 'sltu' indicate in its operation?

It performs a set less than unsigned.

55
New cards

What registers are affected by ‘ecall’ when making a system call?

The registers 'a7' and possibly others - like 'a0', 'a1', etc. for arguments.

56
New cards

What is the difference in addressing between 'la' (non-PIC) and 'la' (PIC)?

Non-PIC uses absolute addresses, PIC uses position-independent addressing.

57
New cards

What does 'nop' stand for?

No operation instruction.

58
New cards

How are logical shifts structured in RISC-V instructions?

Using shifter instructions like 'sll' or 'srl'.

59
New cards

Which type of registers are used for return addresses?

Return address register (ra - x1).

60
New cards

Explain what 'fmul.s' does.

Multiplies two single-precision floating point numbers.

61
New cards

What is the general format for RISC-V assembly instructions?

, , .
62
New cards

What is meant by 'ecall' in system programming?

It is a way to request services from the operating system.

63
New cards

How does RISC-V handle immediate values larger than the 12-bit limit?

It uses load immediate (li) and instructions like 'auipc' to get around the limit.

64
New cards

What does 'jalr ra, offset(rs1)' accomplish specifically?

It jumps to address in rs1 plus an offset and saves the return address in 'ra'.

65
New cards

How does RISC-V treat data alignment in memory?

Data must be aligned according to its size (e.g., 4 bytes for words).

66
New cards

What does the 'snez' instruction do?

Sets the destination register to 1 if the source register is not zero.

67
New cards

What is the instruction for storing a word in memory?

sw instruction.

68
New cards

What represents a 4-byte value in assembly?

The '.word' directive.

69
New cards

What is a stack pointer used for?

It points to the top of the stack in memory.

70
New cards

Define the term 'global pointer' in RISC-V context.

It is a pointer (gp - x3) used for accessing global variables.

71
New cards

How are comparisons performed using branch instructions?

They evaluate conditions between registers and determine control flow.

72
New cards

Give an example of a logic operation in RISC-V.

and, or, xor.

73
New cards

What is the data section of executable used for?

To store initialized static variables.

74
New cards

What does the instruction ‘cmd’ refer to in RISC-V?

Ensure to replace it with the correct system call or command using ecall or similar.

75
New cards

Differentiate 'signed' and 'unsigned' operations in RISC-V assembly.

Signed operations consider negative values, while unsigned do not.

76
New cards

What addresses does the 'auipc' instruction deal with?

It computes PC-relative addresses.

77
New cards

How does 'sw' differ from 'sd' in terms of data type?

'sw' stores a word (4 bytes), 'sd' stores a double word (8 bytes).

78
New cards

Summarize how services are invoked in RISC-V assembly code.

Service numbers are placed in a specified register, then 'ecall' is executed.

79
New cards

What prefix denotes a global label in an assembly file?

.global.

80
New cards

Identify the role of the stack in RISC-V programs.

It stores local variables and function call information.

81
New cards

Describe the two types of conditional branches in RISC-V assemblies.

Equal (beq) and Not Equal (bne) branches.

82
New cards

Explain the significance of the zero register (x0).

It is always zero, cannot be modified, used for instruction purposes.

83
New cards

Why is register x1 important in RISC-V?

It is used for storing the return addresses.

84
New cards

Mention one reason why RISC-V is gaining popularity.

Its open standard and support for custom extensions.

85
New cards

Summarize what the instruction ‘addi’ does in simple terms.

Adds an immediate value to a register.

86
New cards

How are multi-purpose registers denoted in RISC-V?

They are often referred by m* naming (example: a0-a7).

87
New cards

What role do labels play in assembly code?

They provide named locations in the code for jumps and branches.

88
New cards

Explain how floating points are identified in instructions.

By suffixing instruction with '.s' for single and '.d' for double.

89
New cards

What instruction do you use to perform a logical AND in RISC-V?

The AND instruction.

90
New cards

Highlight a feature of RISC-V relating to its assembly language simplicity.

Limited instruction set with straightforward syntax.

91
New cards

What does 'lhu' signify in memory operations?

Load unsigned halfword.

92
New cards

How does 'bge' differ from 'blt'?

'bge' checks if greater than or equal, while 'blt' checks for less than.

93
New cards

What instruction format do RISC-V use for loading integers?

I-type instruction.

94
New cards

How is the result of a floating-point multiplication structured?

Using the fmul.s or fmul.d instruction.

95
New cards

Explain the purpose of immediate values in RISC-V assembly.

They provide constants directly usable in instructions.

96
New cards

How is conditional logic structured in assembly compared to high-level programming?

More explicit with branch instructions.

97
New cards

Mention a difference in how RISC-V handles function calls compared to other architectures.

It uses a caller/callee convention with specific register usage.

98
New cards

What does the abbreviation 'FP' signify in context of RISC-V savings?

Floating Point.

99
New cards

List a reason for why the RISC-V architecture allows extensibility.

It is open-source and designed for custom applications.

100
New cards

Mention the role of the Global Pointer (gp) in assembly programming.

It provides access to global data.