Assembly Language and Machine Code

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

1/47

flashcard set

Earn XP

Description and Tags

These flashcards cover key topics and concepts related to assembly language and machine code as presented in the lecture notes.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

48 Terms

1
New cards

What does Assembly Language represent?

Assembly language represents low-level programming instructions corresponding to machine code.

2
New cards

What operation does the Control Unit perform based on the opcode value?

The Control Unit sends signals to the datapath.

3
New cards

What two types of instructions are crucial in assembly programming?

Machine code instructions and assembly language instructions.

4
New cards

How are the first 6 bits of a machine code instruction used?

They are used to extract the opcode.

5
New cards

What is the role of the instruction register in a processor?

It sends instruction components to the processor.

6
New cards

What is the assembly language instruction for adding registers $t1 and $t2 and storing the result in $t3?

add $t3, $t1, $t2.

7
New cards

What does R-type stand for in MIPS instructions?

R-type stands for register-type instructions, where all inputs and outputs are registers.

8
New cards

What special purpose does register $0 serve in MIPS architecture?

Register $0 always has the value 0.

9
New cards

What are I-type instructions characterized by?

I-type instructions include a constant value encoded in the last 16 bits of the instruction.

10
New cards

What does the J-type instruction do?

J-type instructions jump to a memory location encoded in the last 26 bits.

11
New cards

What should the value in the immediate field of I-type instructions represent?

A constant value or address offset.

12
New cards

What is the significance of function codes in R-type instructions?

Function codes specify the operation performed, with an opcode of 000000.

13
New cards

What registers are reserved for the OS kernel in MIPS architecture?

Registers $26-$27 are reserved for the OS kernel.

14
New cards

What memory alignment is required for word accesses in MIPS?

Word accesses must be word-aligned, meaning addresses must be divisible by 4.

15
New cards

What does the term 'branch instruction' refer to?

A branch instruction allows the program to jump to a different section of code based on a condition.

16
New cards

Which special MIPS register stores the return address for function calls?

Register $31 stores the return address.

17
New cards

What is the purpose of the stack in relation to function calls?

The stack is used to store return addresses and local variables to manage function calls.

18
New cards

What differentiates caller-saved registers from callee-saved registers?

Caller-saved registers must be saved by the caller, while callee-saved registers must be saved by the callee.

19
New cards

How do interrupts differ from exceptions?

Interrupts are external events requiring attention, while exceptions are internal errors raised by the processor.

20
New cards

What type of values are passed to functions when using caller-conventions?

Values are passed through registers (if fewer than four) or pushed onto the stack.

21
New cards

What happens when a nested function call occurs?

The current value of $ra must be saved onto the stack before making another call.

22
New cards

Which instruction is used to load an immediate into a register?

The lui instruction is used to load an immediate.

23
New cards

What instructions are generally used to handle input and output operations in MIPS?

Input and output operations are typically handled via syscall instructions.

24
New cards

Which instruction do you use to return from a subroutine?

The jr $ra instruction is used to return from a subroutine.

25
New cards

What is the meaning of the opcode 001000?

The opcode 001000 indicates an add immediate (addi) instruction.

26
New cards

What does a 'trap' instruction do in MIPS?

The trap instruction sends system calls to the operating system.

27
New cards

What do offset values do in memory accesses?

Offset values specify the address relative to a base address for accessing memory.

28
New cards

In MIPS, how are variables stored in memory sections?

Variables are stored in .data (for data values) and .text (for instruction values) sections.

29
New cards

How do you represent an array in assembly?

Arrays are declared in consecutive memory locations, and the base address is the address of the first element.

30
New cards

What is the main component used to perform multiplication in MIPS?

The hi and lo registers are used to store results of multiplication.

31
New cards

What is Big Endian in data storage?

Big Endian stores the most significant byte at the lowest memory address.

32
New cards

What is Little Endian in data storage?

Little Endian stores the least significant byte at the lowest memory address.

33
New cards

What is the opcode for branch if equal (beq)?

The opcode for beq is 000100.

34
New cards

What is the function of the stack pointer ($sp)?

The stack pointer points to the last element pushed onto the stack.

35
New cards

What does the instruction 'lw $t0, 0($s0)' do?

This instruction loads a word from the address specified by $s0 into register $t0.

36
New cards

What is the format used for memory load/store instructions in MIPS?

The format is: opcode rs rt immediate.

37
New cards

What is a pseudo-instruction in assembly language?

A pseudo-instruction simplifies the programming process, translating into one or more real MIPS instructions.

38
New cards

How can an 'if statement' be represented in assembly language?

If statements are typically represented via conditional branch instructions like beq and bne.

39
New cards

Why can MIPS be described as RISC architecture?

MIPS architecture is RISC because it uses a small set of simple, optimized instructions.

40
New cards

What identifies the start of a function in assembly code?

The start of a function is indicated by a label for the first line of the function.

41
New cards

What is the purpose of storing values onto the stack?

Values are stored on the stack for preservation during function calls.

42
New cards

What does the instruction 'sw $t0, 0($s1)' do?

This instruction stores the word in $t0 into memory at the address given by $s1.

43
New cards

What is the primary role of the assembler in MIPS?

The assembler translates assembly code into machine code.

44
New cards

What occurs during a syscall instruction?

The syscall instruction transfers control to the operating system to handle requests.

45
New cards

What is the typical structure of machine code instructions in MIPS?

Machine code instructions in MIPS are 32 bits long.

46
New cards

What does the instruction 'jal main' do?

The instruction 'jal main' jumps to the function 'main' and stores the return address in $ra.

47
New cards

What typically happens when a function completes execution in assembly?

The return address is used to jump back to the line following the function call.

48
New cards

What mechanism allows MIPS to support recursive function calls?

The use of the stack allows MIPS to save state and handle recursion.