MIDTERM HELL ULTRA PAIN Flashcards

1
Q

What is RAM?

A

Volatile Memory: Data is lost when the power is turned off.
Read/Write: Both reading and writing operations are allowed.
Primary Memory: Used to store data and programs currently in use.

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

What is ROM?

A

Non-Volatile Memory: Retains data even when the power is off.
Read-Only: Cannot be modified easily or at all by the user.
Stored Programs: Contains essential programs for booting and operating the computer (firmware).

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

What is the CPU?

A

Central Processing Unit: The brain of the computer that performs computations and controls other components.

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

What is memory?

A

Data and Instruction Storage: Stores data and instructions for the CPU.
Types Included: Includes both RAM and ROM.

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

What are I/O Devices?

A

Input/Output Communication: Allows communication between the computer and the outside world.
Examples: Keyboard, mouse, monitor, printer.

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

What is the data bus?

A

Carries Data: Transmits actual data between CPU and other components.
Bidirectional: Data can flow both to and from the CPU.
Width (Number of Lines): Determines how much data can be transferred at once (e.g., 8-bit, 16-bit, 32-bit, 64-bit).

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

What is the address bus?

A

Carries Addresses: Transmits the addresses of memory locations where data should be read or written.

Unidirectional: Typically only sends addresses from the CPU to memory or I/O devices.

Width: Determines the maximum amount of memory the CPU can address.

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

What is the control bus?

A

Carries Control Signals: Sends control instructions (like read or write signals) from the CPU to other components.

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

What is the ALU?

A

Arithmetic Logic Unit: Performs all arithmetic and logical operations (addition, subtraction, AND, OR, NOT).

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

What is Pipelining?

A

Overlapping Phases:
While one instruction is being executed, the next instruction is fetched simultaneously.

Division of CPU: Divides the CPU into the Execution Unit (EU) and Bus Interface Unit (BIU).

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

What is the bus interface unit?

A

Function:
1. Fetches instructions from memory.
2. Reads/writes data.
3. Calculates addresses.

Instruction Queue: A buffer that stores prefetched instructions so the EU doesn’t have to wait.

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

What is the Execution Unit (EU)?

A

Function: Executes instructions provided by the Bus Interface Unit (BIU).

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

What are registers?

A

High-Speed Storage: Small storage locations within the CPU that operate at high speeds.

Usage: Hold data, addresses, and control information temporarily during instruction execution.

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

What are the 5 register categories?

A

General-Purpose Registers
Segment Registers
Pointer and Index Registers
Instruction Pointer (IP)
Flags Register

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

What are the general-purpose registers?

A

Versatile Usage: Used for arithmetic operations, data manipulation, and addressing.

Access: Each can be accessed as a 16-bit register or as two separate 8-bit registers.

Ax (Accumulator Register)
Bx (Base Register)
Cx (Count Register)
Dx (Data Register)

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

What does the Ax (Accumulator Register) do?

A

Usage: Preferred for arithmetic, logic, and data transfer operations.

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

What does the Bx (Base Register) do?

A

Usage: Often holds base addresses in memory addressing.

Utility: Useful in indexed addressing modes.

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

What does the Cx (Count Register) do?

A

Usage:
1.) Primarily used as a loop counter in iterative operations.
2.) Used in shift and rotate instructions to specify the number of bits to shift/rotate.

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

What does the Dx (Data Register) do?

A

Usage:
1.) Used in I/O operations.
2.) Utilized for extended precision arithmetic.

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

What are the segment registers?

A

Function: Hold the addresses of segments in memory.

Memory Model: The 8088/8086 uses a segmented memory model, dividing memory into segments of up to 64 KB.

CS (Code Segment Register)
DS (Data Segment Register)
SS (Stack Segment Register)
ES (Extra Segment Register)

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

What does the CS (Code Segment Register) do?

A

Usage: Points to the segment containing the current program instructions.

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

What does the DS (Data Segment Register) do?

A

Usage: Points to the segment where data variables are stored.

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

What does the SS (Stack Segment Register) do?

A

Usage: Points to the segment containing the stack.

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

What does the ES (Extra Segment Register) do?

A

Usage: Provides an additional data segment for certain string and memory operations.

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

What are the Pointer and Index Registers?

A

Function: Used for memory addressing and manipulating data within memory segments.

Pointer Registers:

SP (Stack Pointer)
BP (Base Pointer)

Index Registers:

SI (Source Index Register)
DI (Destination Index Register)

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

What does the SP (Stack Pointer) register do?

A

Function:
1.) Automatically adjusted during stack operations.
2.) Points to the last value pushed onto the stack (top of stack).

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

What does the BP (Base Pointer) register do?

A

Usage: Often used to access parameters and local variables within the stack.

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

What does the SI (Source Index Register) do?

A

Usage: Used in string operations as the source pointer.

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

What does the DI (Destination Index Register) do?

A

Usage: Used in string operations as the destination pointer.

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

What is the Instruction Pointer (IP) Register?

A

Function: Holds the offset address (within the code segment) of the next instruction to be executed. Automatically updated after each instruction fetch.

Usage: The combination of CS (segment) and IP (offset) gives the complete address of the instruction.

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

What is the Flags Register?

A

Description: A 16-bit register that indicates the status of the CPU and the outcome of arithmetic and logical operations.

Flags Included:
Carry Flag (CF)
Zero Flag (ZF)
Sign Flag (SF)
Overflow Flag (OF)
Parity Flag (PF)
Auxiliary Carry Flag (AF)

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

What is the Carry Flag (CF)?

A

Condition: Set if an arithmetic operation generates a carry out of the most significant bit (for addition) or borrow into the most significant bit (for subtraction).

Usage: Used to detect unsigned arithmetic overflows.

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

What is the Zero Flag (ZF)?

A

Condition: Set if the result of an operation is zero.

Usage: Often used in branching instructions or loops.

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

What is the Sign Flag (SF)?

A

Description: Reflects the most significant bit of the result (the sign bit).
Condition: Set if the result is negative (in two’s complement representation).

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

What is the Overflow Flag (OF)?

A

Condition: Set if there is a signed overflow.

Usage: Used to detect errors in signed arithmetic operations.

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

What is the Parity Flag (PF)?

A

Condition: Set if the number of set bits in the least significant byte of the result is even.

Usage: Used for error detection in communication.

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

What is the Auxiliary Carry Flag (AF)?

A

Condition: Set if there is a carry or borrow between the lower and upper nibble (4-bit halves) of an 8-bit operand.

Usage: Important for Binary-Coded Decimal (BCD) arithmetic operations.

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

What are the three components of an assembly language instruction?

A

Mnemonic: A symbolic name representing a machine language instruction.

Operands: Data items that the instruction manipulates.
Comments: Provide explanations or annotations.

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

What is the Code Segment?

A

Storage: Stores the executable instructions of a program.
CPU Interaction: The CPU fetches instructions from the code segment during execution.

Registers Involved: CS (Code Segment Register), IP (Instruction Pointer)

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

What is the Data Segment?

A

Storage: Stores data to be processed by the program.

Registers Used: DS (Data Segment Register)

Offset Registers:
1.) Base Register (BX)
2.) Source Index (SI)
3.) Destination Index (DI)

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

What is the Stack Segment?

A

Definition: A stack is a region of memory used for temporary storage of data during program execution.

Purpose: Provides additional storage space for the CPU beyond its internal registers, which are limited in number.
Registers Involved:
1.) SS (Stack Segment Register)
2.) SP (Stack Pointer Register)
3.) BP (Base Pointer Register)

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

What is the physical address?

A

Definition: The actual address placed on the address bus by the CPU.

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

What is the logical address?

A

Composition: Consists of a segment value and an offset value.

Format: Segment:Offset

44
Q

What is the offset address?

A

Definition: Specifies the distance from the beginning of the segment

45
Q

What is BIOS?

A

Functions:
1.) Initializes hardware during the boot process.
2.) Provides low-level hardware control routines.

Access: Programs and DOS can access BIOS routines via interrupts.

46
Q

What is DOS (Disk Operating System)?

A

Functions:
1.) Manages files, memory, and devices by loading programs into RAM.
2.) Provides a layer between application programs and hardware.

47
Q

How does the stack grow in memory?

A

Direction: Downwards, from higher to lower memory addresses.

48
Q

What is a push operation?

A

Function: Saves data onto the stack.

Process:
1.) Decrement SP by the size of the data.
2.) Store the data at the memory location pointed to by SS:SP.

49
Q

What is a Pop Operation?

A

Function: Retrieves data from the stack.

Process:
1.) Load data from the memory location pointed to by SS:SP.
2.) Increment SP by the size of the data.

50
Q

What is Register Addressing Mode?

A

Definition: Both the source and destination operands are registers within the CPU.

Example: movw %dx, %bx

51
Q

What is Immediate Addressing Mode?

A

Definition: The operand is a constant value.

Example: movw $0x2550, %ax

52
Q

What is Direct Addressing Mode?

A

Definition: The operand resides in memory, and its offset address is specified directly within the instruction.

Example: movb 0x2400, %dl

53
Q

What is Register Indirect Addressing Mode?

A

Definition: The operand’s memory address is held in a register.

Example: movb (%bx), %al

54
Q

What is Based Relative Addressing Mode?

A

Definition: Combines a base register with a displacement to calculate the effective address.

Base Registers: %bx and %bp.

Example: movw 10(%bx), %cx

55
Q

What is Indexed Relative Addressing Mode?

A

Definition: Uses an index register with a displacement to calculate the effective address.

Index Registers: %si and %di.

Example: movw 5(%si), %dx

56
Q

What is Based Indexed Relative Addressing Mode?

A

Definition: Combines a base register, an index register, and a displacement to calculate the effective address.

Base Registers: %bx and %bp

Index Registers: %si and %di

Example: movb 8(%bx,%di), %cl

57
Q

What are procedures?

A

Definition: Blocks of code designed to perform specific tasks.

Defining a Procedure:
1.) Start: Label the beginning of the procedure.
2.) End: Place a return instruction at the end (e.g., ret).

58
Q

What is the Main Entry Point?

A

Unix-like Systems: _start is used as the entry point.

59
Q

What is a near jump/call?

A

Definition: A jump/call when the target address is within the same code segment.

Effect: Only the Instruction Pointer (IP) register is updated.

60
Q

What are FAR Jumps and Calls?

A

Definition: Used when the target address is in a different code segment.

Effect: Both the Code Segment (CS) and Instruction Pointer (IP) registers are updated.

61
Q

What is a JE / JZ (Jump if Equal / Jump if Zero) jump?

A

Description: Jumps to label if the zero flag is set, indicating equality.

62
Q

What is a JNE / JNZ (Jump if Not Equal / Jump if Not Zero) jump?

A

Description: Jumps to label if the zero flag is not set, indicating inequality.

63
Q

What is a JG / JNLE (Jump if Greater / Jump if Not Less or Equal) jump?

A

Description: Jumps if the first operand is greater than the second (signed).

64
Q

What is a JL / JNGE (Jump if Less / Jump if Not Greater or Equal) jump?

A

Description: Jumps if the first operand is less than the second (signed).

65
Q

What is a JGE / JNL (Jump if Greater or Equal / Jump if Not Less) jump?

A

Description: Jumps if the first operand is greater than or equal to the second (signed).

66
Q

What is a JLE / JNG (Jump if Less or Equal / Jump if Not Greater) jump?

A

Description: Jumps if the first operand is less than or equal to the second (signed).

67
Q

What is a JA / JNBE (Jump if Above / Jump if Not Below or Equal) jump?

A

Description: Jumps if the first operand is greater than the second (unsigned).

68
Q

What is a JB / JNAE (Jump if Below / Jump if Not Above or Equal) jump?

A

Description: Jumps if the first operand is less than the second (unsigned).

69
Q

What is a JAE / JNB (Jump if Above or Equal / Jump if Not Below) jump?

A

Description: Jumps if the first operand is greater than or equal to the second (unsigned).

70
Q

What is a JBE / JNA (Jump if Below or Equal / Jump if Not Above) jump?

A

Description: Jumps if the first operand is less than or equal to the second (unsigned).

71
Q

What is a JC (Jump if Carry) jump?

A

Description: Jumps if the carry flag is set.

72
Q

What is a JNC (Jump if No Carry) jump?

A

Description: Jumps if the carry flag is not set.

73
Q

What is a JO (Jump if Overflow) jump?

A

Description: Jumps if the overflow flag is set.

74
Q

What is a JNO (Jump if No Overflow) jump?

A

Description: Jumps if the overflow flag is not set.

75
Q

What is a JS (Jump if Sign) jump?

A

Description: Jumps if the sign flag is set (negative result).

76
Q

What is a JNS (Jump if Not Sign) jump?

A

Description: Jumps if the sign flag is not set (non-negative result).

77
Q

What is a JP / JPE (Jump if Parity / Jump if Parity Even) jump?

A

Description: Jumps if the parity flag is set (even parity).

78
Q

What is a JNP / JPO (Jump if Not Parity / Jump if Parity Odd) jump?

A

Description: Jumps if the parity flag is not set (odd parity).

79
Q

What are all conditional jumps?

A

Description: Short jumps based on the evaluation of condition flags.

80
Q

What are call instructions?

A

Function: Used to invoke subroutines or procedures within your program.

Behavior: Similar to jumps but have additional functionality to enable returning to the point of origin after the subroutine completes.

81
Q

What is a near call?

A

Syntax: call label

Usage: When calling a procedure within the same code segment.
Return Mechanism: Only the IP is pushed onto the stack.

RET Instruction: The subroutine should end with a ret instruction to pop the return address back into the IP.

82
Q

What is a far call?

A

Syntax: call far label or call far ptr label

Usage: When calling a procedure in a different code segment.

Return Mechanism: Both the CS and IP are pushed onto the stack.

RET Instruction: The subroutine should end with a lret (far return) instruction to pop both CS and IP from the stack.

83
Q

How to add individual bytes or words while maintaining Carry?

A

Steps:
1.) Use an 8-bit register (e.g., %al) to accumulate the sum of bytes.
2.) Use another 8-bit register (e.g., %ah) to accumulate any carries.
3.) After each addition, check the Carry Flag (CF); if it’s set, increment the carry register.

84
Q

How to add multiple words while maintaining Carry?

A

Steps:
1.) Break down the numbers into lower and higher words or bytes.
2.) Clear the Carry Flag using the clc instruction before starting.
3.) Use ADD for the least significant chunk (LSB).
4.) Use ADC for subsequent chunks to include the carry from the previous addition.

85
Q

How does the x86 processor perform subtraction?

A

Steps:
1.) Invert all bits of the subtrahend (creating the 1’s complement).
2.) Add 1 to get the 2’s complement.
3.) Add the 2’s complement of the subtrahend to the minuend.
4.) Invert the Carry Flag (CF) after the operation.

86
Q

How to perform Byte × Byte Multiplication?

A

Operands:
1.) Multiplicand: Must be in the %al register.
2.) Multiplier: Can be a register or memory operand.

Result:
The product is stored in the %ax register.

87
Q

How to perform Word × Word Multiplication?

A

Operands:
1.) Multiplicand: Must be in the %ax register.
2.) Multiplier: Can be a register or memory operand.

Result:
1.) The 32-bit product is stored across %dx:%ax.
2.) %ax: Lower 16 bits of the result.
3.) %dx: Higher 16 bits of the result.

88
Q

How to perform Byte × Word Multiplication?

A

Operands:
1.) Multiplicand: Must be in the %al register (byte).
2.) Multiplier: Can be a word in a register or memory.

Preparation:
1.) %ah must be zeroed before the multiplication to correctly interpret %al as a word-sized value.

Result:
1.)The product is stored in %dx:%ax.

89
Q

How to perform Byte ÷ Byte Division?

A

Numerator:
— Must be in the %ax register, with %ah cleared to zero.

Divisor:
— Can be a register or memory operand.

Result:
— Quotient: Stored in %al.
— Remainder: Stored in %ah.

90
Q

How to perform Word ÷ Word Division?

A

Numerator:
— Must be in the %dx:%ax register pair.
— %dx must be cleared to zero if the numerator fits in %ax.

Divisor:
— Can be a register or memory operand.

Result:
— Quotient: Stored in %ax.
— Remainder: Stored in %dx.

91
Q

How to perform Word ÷ Byte Division?

A

Numerator:
— Must be in the %ax register.

Divisor:
— Can be a register or memory operand (byte-sized).

Result:
— Quotient: Stored in %al.
— Remainder: Stored in %ah.

92
Q

How to perform Doubleword ÷ Word Division?

A

Numerator:
— Must be in the %dx:%ax register pair.
— %dx: High word of the numerator.
—- %ax: Low word of the numerator.

Divisor:
— Must be a word-sized register or memory operand.

Result:
— Quotient: Stored in %ax.
— Remainder: Stored in %dx.

93
Q

What is the AND instruction?

A

Function: Performs a bitwise logical AND operation between two operands.

Syntax: AND destination, source  ; destination = destination AND source

Usage:
— Masking Bits: Clearing specific bits in a register or memory location.

94
Q

What is the OR instruction?

A

Function: Performs a bitwise logical OR operation between two operands.

Syntax: OR destination, source  ; destination = destination OR source

Usage:
— Setting Bits: Forces specific bits to be 1.

95
Q

What is the XOR instruction?

A

Function: Performs a bitwise exclusive OR (XOR) operation between two operands.

Syntax: XOR destination, source  ; destination = destination XOR source

Usage:
— Clearing Registers: XORing a register with itself results in zero.
— Bit Toggling: Flips specific bits in a register or memory location.

96
Q

What is the shift instruction?

A

Function: Moves bits left or right within a register or memory location.

Types of Logical Shifts:
— Shift Left Logical (SHL): Shifts bits to the left.
— Shift Right Logical (SHR): Shifts bits to the right.

97
Q

What is the CMP Instruction?

A

Function: Compares two operands by performing a subtraction of the source operand from the destination operand (without storing the result).

Usage:
— Commonly used prior to conditional jumps.
— Sets up conditions for subsequent instructions.

Syntax: CMP destination, source  ; Compare destination with source

98
Q

What is unpacked BCD?

A

Definition: Each decimal digit is stored in the lower four bits of a byte.

Upper Bits: The upper four bits are typically set to zero.

99
Q

What is packed BCD?

A

Definition: Two decimal digits are stored within a single byte.

Bit Allocation:
— Higher Four Bits: Contain one digit.
— Lower Four Bits: Contain another digit.

100
Q

What about ASCII numbers?

A

Definition: upper four bits set to 0011.

101
Q

How to convert from ASCII to unpacked BCD?

A

Steps:
1.) Mask the Upper Four Bits: Perform a bitwise AND with 0x0F to clear the upper four bits.
2.) Result: The lower four bits remain, representing the BCD value.

102
Q

How to convert from ASCII to packed BCD?

A

Steps:

1) Convert ASCII to Unpacked BCD:
Mask the upper four bits by performing a bitwise AND with 0x0F to clear the upper four bits.

2.) Combine Two Unpacked BCD Digits into One Byte:
Shift the higher-order digit left by 4 bits.
Combine it with the lower-order digit using a bitwise OR.

103
Q

How to convert from packed BCD to ASCII?

A

Steps:

1.) Separate the Two BCD Digits:
Extract the upper nibble (higher-order digit) by shifting right by 4 bits.
Extract the lower nibble (lower-order digit) by masking with 0x0F.

2.) Convert Unpacked BCD to ASCII:
Add 0x30 to each unpacked BCD digit.

104
Q

How to convert from packed BCD to ASCII?

A

Steps:

1.) Separate the Two BCD Digits:
Extract the upper nibble (higher-order digit) by shifting right by 4 bits.
Extract the lower nibble (lower-order digit) by masking with 0x0F.

2.) Convert Unpacked BCD to ASCII:
Add 0x30 to each unpacked BCD digit.

105
Q

How does Decimal Adjust After Addition work?

A

Steps:

1.) Lower Nibble Adjustment:
If the lower nibble (bits 0-3) is greater than 9 or the Auxiliary Flag (AF) is set, DAA adds 0x06 to the lower nibble.

2.) Upper Nibble Adjustment:
If the upper nibble (bits 4-7) is greater than 9 or the Carry Flag (CF) is set, DAA adds 0x60 to adjust the upper nibble.