Arithmetic Instructions Flashcards

(20 cards)

1
Q

What are the key arithmetic instruction categories in 8086?

A

“1. Addition: ADD, ADC. 2. Subtraction: SUB, SBB. 3. Increment/Decrement: INC, DEC. 4. Multiplication: MUL, IMUL. 5. Division: DIV, IDIV. 6. Convert: CBW, CWD.”

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

What is the difference between ADD and ADC?

A

ADD: Adds two operands. ADC: Adds two operands + carry flag (CF). Example: ADC AX, BXAX = AX + BX + CF. Used for multi-byte addition.”

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

How does SUB work in 8086?

A

SUB destination, source: Subtracts source from destination using 2’s complement. Example: SUB AL, BHAL = AL - BH. Affects all flags (CF, ZF, SF, etc.).”

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

What is the purpose of SBB?

A

Subtract with Borrow: SBB destination, sourcedestination = destination - source - CF. Used for multi-byte subtraction. Example: SBB BX, CX.”

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

How do INC and DEC affect flags?

A

INC/DEC modify all flags except CF. Example: INC CX increments CX by 1; DEC [SI] decrements memory at SI by 1.”

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

What does CMP do?

A

Compare: Subtracts source from destination and updates flags without storing the result. Example: CMP AX, 18 → Flags indicate if AX >, <, or = 18.”

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

How is MUL different from IMUL?

A

MUL: Unsigned multiplication. IMUL: Signed multiplication. Example: MUL BL (AL * BL → AX). IMUL BX (AX * BX → DX:AX).”

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

What happens during MUL BL?

A

“AL (8-bit) * BL (8-bit) → 16-bit result in AX. CF/OF = 1 if upper half (AH) ≠ 0. Example: MUL BL → AX = AL * BL.”

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

How does DIV handle division?

A

DIV divisor: Unsigned division. Byte form: AX / divisor → AL (quotient), AH (remainder). Word form: (DX:AX) / divisor → AX (quotient), DX (remainder). Example: DIV BL divides AX by BL.”

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

What is a divide overflow?

A

“Occurs when the quotient exceeds the capacity of AL/AX. Example: Dividing FFFFH by 1 → quotient FFFFH > AX capacity → program terminates with ‘Divide Overflow’.”

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

What do CBW and CWD do?

A

CBW: Converts byte (AL) to word (AX) by sign extension. CWD: Converts word (AX) to double word (DX:AX). Example: CBW extends AL (80h) to AX (FF80h).”

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

How do flags behave for MUL vs. IMUL?

A

MUL: CF/OF = 1 if upper half ≠ 0. IMUL: CF/OF = 1 if upper half ≠ sign extension. Example: IMUL BX (signed) sets CF/OF based on sign consistency.”

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

What happens in IDIV BX with DX:AX = FFFFFFFBh?

A

“Signed division: FFFFFFFBh (-5) ÷ BX (2) → AX = -2 (FFFEh), DX = -1 (FFFFh). CF/OF = 0 if result fits.”

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

What is the syntax for MOV AL, 80H followed by CBW?

A

CBW converts AL (80h) to AX (FF80h) for signed operations. Example: Prepares AL for division by sign-extending to AX.”

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

How to evaluate z = x + (y + n)/M in assembly?

A

“For unsigned numbers:
1. MOV AL, Y
2. MUL N
3. DIV M
4. ADD AX, X
5. MOV Z, AX
For signed, use CBW, IMUL, IDIV.”

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

What are the flag results after INC AL (AL = FFh)?

A

“AL becomes 00h. Flags: ZF = 1 (result zero), SF = 0 (positive), CF unchanged (remains 0).”

17
Q

How does IMUL handle AX=1 and BX=FFFFh?

A

IMUL BX: Treats BX as -1 (signed). Result: AX = -1 (FFFFh), DX = FFFFh (sign extension). CF/OF = 0.”

18
Q

What is the result of DIV BH if AX=0005h and BH=FFh?

A

DIV BH: AL = 00h (quotient 0), AH = 05h (remainder 5). IDIV BH: AL = FBh (-5), AH = 00h (remainder 0).”

19
Q

Why use CLC before ADC?

A

“Clears CF to avoid unintended carry from previous operations. Example: CLCADC CX, [BX] adds CX, [BX], and CF=0.”

20
Q

What is the purpose of ORG 0010h?

A

Origin directive: Sets the next data/code offset to 0010h. Example: ORG 0010h → DATA4 starts at 0010h.