Assembly Language Flashcards

1
Q

What is assembly language?

A

A low-level programming language that uses mnemonic instructions specific to the processor’s architecture. It is not portable like high-level languages.

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

What are the two types of instruction sets in assembly language?

A

RISC (Reduced Instruction Set Computer): Simple instructions, single clock cycle execution, low energy consumption.
CISC (Complex Instruction Set Computer): Complex instructions, multiple clock cycles, higher efficiency with fewer lines of code.

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

What is immediate addressing?

A

The operand is a hardcoded value in the instruction (e.g., ADD #7 adds 7 to the accumulator). It is the fastest method since it doesn’t involve memory access.

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

What is direct addressing?

A

The operand specifies a memory location directly (e.g., ADD 7 adds the value at memory address 7). Requires fetching data from memory.

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

What is indirect addressing?

A

The operand refers to an intermediate memory location that holds the address of the actual data. Not part of the specification.

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

What are opcodes and operands?

A

Opcode: Specifies the operation to perform (e.g., ADD, MOV).
Operand: Specifies the data or memory location involved in the operation.

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

What does a typical instruction look like?

A

Instruction = Opcode + Operand
Example: LDR R1, #5 loads the value 5 into register R1.

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

What are some common assembly instructions in the AQA set?

A

LDR Rd, <memory>: Load value from memory to register.
STR Rd, <memory>: Store value from register to memory.
ADD Rd, Rn, <operand2>: Add operand2 to value in Rn, store in Rd.
SUB Rd, Rn, <operand2>: Subtract operand2 from value in Rn, store in Rd.
B <label>: Branch to the instruction at label.
HALT: Stop program execution.</label></operand2></operand2></memory></memory>

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

How do you perform addition in assembly?

A

Input two numbers into registers.
Use the ADD instruction to add them.
Output the result and halt.
Example:
INP R0
INP R1
ADD R2, R0, R1
OUT R2
HALT

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

How is multiplication performed without a MUL instruction?

A

Repeated addition. Add the first operand to itself as many times as specified by the second operand using a loop.

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

How is division performed without a DIV instruction?

A

Repeated subtraction. Subtract the divisor from the dividend until the result is 0 or negative. The number of subtractions equals the quotient.

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

How does assembly handle conditional branching?

A

By comparing values using CMP and branching based on the result (e.g., BEQ for equal, BGT for greater than).

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

How do you implement a loop in assembly?

A

Use a branch instruction to jump back to the loop start until a condition is met.
Example: Countdown loop:

MOV R0, #10
LOOP: OUT R0
SUB R0, R0, #1
CMP R0, #0
BNE LOOP
HALT

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

How do you validate input in assembly?

A

Use a loop to repeatedly request input until it meets the condition. Example: Entering a number > 100.

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

How is a Fibonacci sequence implemented in assembly?

A

Use three registers to hold the last two numbers and their sum. Update the registers iteratively.

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

What is the fetch-execute cycle in assembly programming?

A

The CPU fetches instructions from memory, decodes them, and executes them in sequence.

17
Q

Why is assembly language considered non-portable?

A

It is processor-specific and depends on the architecture’s instruction set.