SECTION 6.1: ARITHMETIC INSTRUCTIONS
1. In multiplication of two bytes in the 8051, we must place one byte in register and the other in register
2. In unsigned byte-by-byte multiplication, the product will be placed in register(s) ____________
3. Is this a valid 8051 instruction? "MUL A, Rl". Explain your answer.
4. In byte/byte division, the numerator must be placed in _____ register and the denominator in ___ register
5. In unsigned byte/byte division, the quotient will be placed in ____ register and the remainder in _____ register
6. Is this a valid 8051 instruction? "DIV A, Rl". Explain your answer.
7. The instruction "ADD A, source" places the sum in ____________
8. Why is the following ADD instruction illegal?
"ADD Rl, R2"
9. Rewrite the instruction above in correct form.
10. The instruction "ADDC A, source" places the sum in ________
11. Find the value of the A and CY flags in each of the following.
(a) MOV A, #4FH
(b) MOV A, #9CH
12. Show how the CPU would subtract 05H from 43H.
13. If CY= 1, A= 95H, and B = 4FH prior to the execution of "SUBB A, B", what will be the contents of A after the subtraction?
1. A, B
2. A, B
3. No. We must use registers A and B for this operation.
4. A, B
5. A, B
6. No. We must use registers A and B for this operation.
7. A, the accumulator
8. No. We must use registers A and B for this operation.
9. MOV A, Rl
10. A, the accumulator
11. (a) A= 00 and CY= 1 (b) A= FF and CY= 0
12. 43H = 0100 0011 and -O5H (in 2's complement ) 0100 0011 if both added then
the result is 3EH = 0011 1110
13. A = 95H - 4FH - 1 = 45H
SECTION 6.2: SIGNED NUMBER CONCEPTS AND ARITHMETIC OPERATIONS
1. In an 8-bit operand, bit ___ is used for the sign bit.
2. Convert -16H to its 2's complement representation.
3. The range of byte-sized signed operands is -_____to + ______
4. Show +9 and -9 in binary.
5. Explain the difference between a carry and an overflow.
2. 16H is 00010110 in binary and its 2's complement is 1110 1010 or -16H = EA in hex.
3. -128 to +127
4. +9 = 00001001 and -9 = 11110111 or F7 in hex.
5. An overflow is a carry into the sign bit (D7), but the carry is a carry out of register (D7).
SECTION 6.3: LOGIC AND COMPARE INSTRUCTIONS
1. Find the content of register A after the following code in each case.
(a) MOV A, #37H
(b) MOV A, #37H
(c) MOV A, #37H
2. To mask certain bits of the accumulator we must ANL it with ______
3. To set certain bits of the accumulator to 1 we must ORL it with _______
4. XRing an operand with itself results in __________
5. True or false. The CJNE instruction alters the contents of its operands.
6. What value must R4 have in order for the following instruction not to jump?
7. Find the contents of register A after execution of the following code.
1. (a) 02 (b) FFH (c) FDH
4. All zeros
SECTION 6.4: ROTATE INSTRUCTION AND DATA SERIALIZATION
1. What is the value of register A after each of the following instructions?
MOV A, #25H
2. What is the value of register A after each of the following instructions?
MOV A, #A2H
3. What is the value of register A after each of the following instructions?
4. Why does "RLC Rl" give an error in the 8051?
5. What is in register A after the execution of the following code?
MOV A, #85H
6. Find the status of the CY flag after the following code.
ADD A, #OFFH
7. Find the status of the CY flag after the following code.
8. Find the status of the CY flag after the following code.
9. Show how to save the status of P2.7 in RAM bit location 31.
10. Show how to move the status of RAM bit location 09 to Pl.4.
4. Because all the rotate instructions work with the accumulator only
6. CY= 0
7. CY= 1
8. CY= 1
9. MOV C, P2. 7 ; save status of P2. 7 on CY
MOV 31,C ;save carry in RAM bit location 06
10. MOV C, 9 ;save status of RAM bit 09 in CY
MOV Pl.4,C ;save carry in Pl.4
SECTION 6.5: BCD, ASCII, AND OTHER APPLICATION PROGRAMS
1. For the following decimal numbers, give the packed BCD and unpacked BCD representations.
2. Show the binary and hex formats for "76" and its BCD version.
3. Does the register A have BCD data after the following instruction is executed?
4. 67H in BCD when converted to ASCII is H and H.
5. Does the following convert unpacked BCD in register A to ASCII?
6. The checksum byte method is used to test data integrity in (RAM, ROM).
7. Find the checksum byte for the following hex values: 88H, 99H, AAH, BBH, CCH, DDH
8. True or false. If we add all the bytes, including
1. (a) 15H = 0001 0101 packed BCD, 0000 0001,0000 0101 unpacked BCD
(b) 99H = 10011001 packed BCD, 00001001,0000 1001 unpacked BCD
2. 3736H = 00110111 00110110B and in BCD we have 76H = 0111 OllOB
3. No. We need to write it 54H (with the H) or 01010100B to make it in BCD. The value 54 without the "H" is interpreted as 36H by the assembler.
5. Yes, since A= 39H
7. 88H + 99H + AAH + BBH + CCH + DDH = 42FH. Dropping the carries we have 2FH, and its 2's complement is DlH.