Search this site

Arithmetic, Logic Instructions, and Programs - Unit 6 - Review Questions & Answers from 8051 Microcontrollers & Embedded Systems by Mazidi

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   

        ADD A,#OBlH  

    (b) MOV A, #9CH

         ADD A,#63H 

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? 

Answers: 

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 

ADD A,R2 

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. 

Answers: 

1. D7 

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 

         ANL A,#OCAH

    (b) MOV A, #37H 

        ORL A,#OCAH

    (c) MOV A, #37H

          XRL A,#OCAH 

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? 

    CJNE R4,#53,0VER 

7. Find the contents of register A after execution of the following code. 

    CLR A

    ORL A,#99H

    CPL A 

Answers: 

1. (a) 02 (b) FFH (c) FDH 

2. Zeros

3. One

4. All zeros

5. False

6. #53

7. 66H 


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

RR A 

RR A 

RR A 

RR A 

2. What is the value of register A after each of the following instructions? 

MOV A, #A2H

RL A 

RL A 

RL A 

RL A 

3. What is the value of register A after each of the following instructions? 

CLR A

SETB C 

RRC A

SETB C

RRC A 

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

SWAP A

ANL A,#OFOH 

6. Find the status of the CY flag after the following code. 

CLR A

ADD A, #OFFH

JNC OVER 

CPL C

OVER: 

7. Find the status of the CY flag after the following code. 

OVER: 

CLR C

JNC OVER

SETB C 

8. Find the status of the CY flag after the following code. 

OVER: 

CLR C

JC OVER

CPL C 

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. 

Answers: 

1. 52H 

2. 2AH

3. COH

4. Because all the rotate instructions work with the accumulator only 

5. SOH

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.

(a)lS (b)99 

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? 

MOV A,#54 

4. 67H in BCD when converted to ASCII is H and H.

5. Does the following convert unpacked BCD in register A to ASCII? 

MOV A,#09

ADD A,#30H 

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 

Answers: 

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.

4. 36H,37H 

5. Yes, since A= 39H

6. ROM 

7. 88H + 99H + AAH + BBH + CCH + DDH = 42FH. Dropping the carries we have 2FH, and its 2's complement is DlH. 

8. False 



No comments:

Post a Comment