ARITHMETIC AND LOGIC INSTRUCTIONS:QUESTIONS AND PROBLEMS.

QUESTIONS AND PROBLEMS

1. Select an ADD instruction that will:

(a) add BX to AX

(b) add 12H to AL

(c) add EDI and EBP

(d) add 22H to CX

(e) add the data addressed by SI to AL

(f) add CX to the data stored at memory location FROG

(g) add 234H to RCX

2. What is wrong with the ADD RCX,AX instruction?

3. Is it possible to add CX to DS with the ADD instruction?

4. If AX = 1001H and DX = 20FFH, list the sum and the contents of each flag register bit (C, A, S, Z, and O) after the ADD AX,DX instruction executes.

5. Develop a short sequence of instructions that adds AL, BL, CL, DL, and AH. Save the sum in the DH register.

6. Develop a short sequence of instructions that adds AX, BX, CX, DX, and SP. Save the sum in the DI register.

7. Develop a short sequence of instructions that adds ECX, EDX, and ESI. Save the sum in the EDI register.

8. Develop a short sequence of instructions that adds RCX, RDX, and RSI. Save the sum in the R12 register.

9. Select an instruction that adds BX to DX, and also adds the contents of the carry flag (C) to the result.

10. Choose an instruction that adds 1 to the contents of the SP register.

11. What is wrong with the INC [BX] instruction?

12. Select a SUB instruction that will:

(a) subtract BX from CX

(b) subtract 0EEH from DH

(c) subtract DI from SI

(d) subtract 3322H from EBP

(e) subtract the data address by SI from CH

(f) subtract the data stored 10 words after the location addressed by SI from DX

(g) subtract AL from memory location FROG

(h) subtract R9 from R10

13. If DL = 0F3H and BH = 72H, list the difference after BH is subtracted from DL and show the contents of the flag register bits.

14. Write a short sequence of instructions that subtracts the numbers in DI, SI, and BP from the AX register. Store the difference in register BX.

15. Choose an instruction that subtracts 1 from register EBX.

16. Explain what the SBB [DI–4],DX instruction accomplishes.

17. Explain the difference between the SUB and CMP instruction.

18. When two 8-bit numbers are multiplied, where is the product found?

19. When two 16-bit numbers are multiplied, what two registers hold the product? Show the reg- isters that contain the most and least significant portions of the product.

20. When two numbers multiply, what happens to the O and C flag bits?

21. Where is the product stored for the MUL EDI instruction?

22. Write a sequence of instructions that cube the 8-bit number found in DL. Load DL with a 5 initially, and make sure that your result is a l6-bit number.

23. What is the difference between the IMUL and MUL instructions?

24. Describe the operation of the IMUL BX,DX,100H instruction.

25. When 8-bit numbers are divided, in which register is the dividend found?

26. When l6-bit numbers are divided, in which register is the quotient found?

27. When 64-bit numbers are divided, in which register is the quotient found?

28. What errors are detected during a division?

29. Explain the difference between the IDIV and DIV instructions.

30. Where is the remainder found after an 8-bit division?

31. Where is the quotient found after a 64-bit division?

32. Write a short sequence of instructions that divides the number in BL by the number in CL and then multiplies the result by 2. The final answer must be a 16-bit number stored in the DX register.

33. Which instructions are used with BCD arithmetic operations?

34. Explain how the AAM instruction converts from binary to BCD.

35. Which instructions are used with ASCII arithmetic operations?

36. Develop a sequence of instructions that converts the unsigned number in AX (values of 0–65535) into a 5-digit BCD number stored in memory, beginning at the location addressed by the BX register in the data segment. Note that the most significant character is stored first and no attempt is made to blank leading zeros.

37. Develop a sequence of instructions that adds the 8-digit BCD number in AX and BX to the 8-digit BCD number in CX and DX. (AX and CX are the most significant registers. The result must be found in CX and DX after the addition.)

38. Does the AAM instruction function in the 64-bit mode?

39. Select an AND instruction that will:

(a) AND BX with DX and save the result in BX

(b) AND 0EAH with DH

(c) AND DI with BP and save the result in DI

(d) AND 1122H with EAX

(e) AND the data addressed by BP with CX and save the result in memory

(f) AND the data stored in four words before the location addressed by SI with DX and save the result in DX

(g) AND AL with memory location WHAT and save the result at location WHAT

40. Develop a short sequence of instructions that clears (0) the three leftmost bits of DH without changing the remainder of DH and stores the result in BH.

41. Select an OR instruction that will:

(a) OR BL with AH and save the result in AH

(b) OR 88H with ECX

(c) OR DX with SI and save the result in SI

(d) OR 1122H with BP

(e) OR the data addressed by RBX with RCX and save the result in memory

(f ) OR the data stored 40 bytes after the location addressed by BP with AL and save the result in AL

(g) OR AH with memory location WHEN and save the result in WHEN

42. Develop a short sequence of instructions that sets (1) the rightmost 5 bits of DI without changing the remaining bits of DI. Save the results in SI.

43. Select the XOR instruction that will:

(a) XOR BH with AH and save the result in AH

(b) XOR 99H with CL

(c) XOR DX with DI and save the result in DX

(d) XOR lA23H with RSP

Leave a comment

Your email address will not be published. Required fields are marked *