Sunteți pe pagina 1din 12

Flow Chart:

PROGRAM (16-bit Addition): Address 4100 4101 4103 4105 4108 4109 410A 410C 410E 410F Opcode & Operand C3 74, Data1L 24, Data2L 90, 41, 50 F0 A3 74, Data1H 34, Data2H F0 80, FE HERE: Label Mnemonics CLR C MOV A, #DATA1 ADD A, #DATA2 MOV DPTR, #4150h MOVX @DPTR, A INC DPTR MOV A, #DATA1 ADDC A, #DATA2 MOVX @DPTR, A SJMP HERE Comments Clear carry Move Data1L to Acc Add Data2L with Acc Move content in 4500 to DPTR. Move data to DPTR location Increment DPTR Move Data1H to Acc Add Acc with Data2H & Carry Move from Acc to DPTR location End

EXP. NO:

14

Date:

TITLE:

PROGRAMMING ARITHMETIC, LOGICAL AND BIT MANIPULATION USING 8051

AIM: To write an assembly language program for the arithmetic, logical and bit manipulation using 8051.

APPARATUS REQUIRED: S.N o 1 2 Item Description 8051Micro Controller kit. Power Supply unit Qty 1 1

(A) ARITHMETIC OPERATION:

(I) 16 BIT ADDITION:

ALGORITHM: 1. Start the program. 2. Get the LSB of 1 and 2


st nd

operands.

3. Add the LSB of the two operands and store it in memory. 4. Get the MSB of 1 and 2nd operands. 5. Add the MSB and store the result in memory 6. Stop the program.
st

OUTPUT OF 16-BIT ADDITION:

INPUT Address 4102 4104 410B 410D Data

OUTPUT Address 4500 4501 Data

Flow Chart:

PROGRAM (8-bit Subtraction): Address 4100 4101 4103 4105 4108 4109 Opcode & Operand C3 74, Data1 94, Data2 90, 45, 00 FO 80, FE HERE: Label Mnemonics CLR C MOV A, #DATA1 SUBB A, #DATA2 MOV DPTR, #4500h MOVX @DPTR, A SJMP HERE Comments Clear carry Move data1 to acc Add data2 with acc Move 4500 to DPTR. Move Acc value to DPTR location End

(II) 8- BIT SUBTRACTION: ALGORITHM: 1. Start the program. 2. Clear the carry flag and load the first operand in accumulator. 3. Get the 2
nd

operand and subtract it from accumulator.

4. Store the result in memory. 5. Stop the program.

OUTPUT OF 8-BIT Subtraction without Carry:

INPUT Address 4102 4104 Data

OUTPUT Address 4500 Data

Flow Chart:

PROGRAM (8-bit Multiplication): Address 4100 4102 4105 4106 4109 410A 410B 410D 410E Opcode & Operand 74, Data1 75, F0, Data2 A4 90, 45, 00 FO A3 E5, F0 FO 80, FE HERE: Label Mnemonics MOV A, #DATA1 MOV B, #DATA2 MUL AB MOV DPTR, #4500h MOVX @DPTR, A INC DPTR MOV A, B MOVX @DPTR, A SJMP HERE Comments Move Data1 to Acc Move Data2 to Acc Multiply Acc and B Move 4500 to DPTR. Move Acc value to DPTR location INC DPTR Move B register value to Acc Move Acc value to DPTR location End

(III) 8-BIT MULTIPLICATION: ALGORITHM: 1. Start the program. 2. Load the 1


st

operand in A and 2

nd

operand in B.

3. Multiply A and B contents using MUL instruction. 4. Store the result in memory. 5. Stop the program.

OUTPUT OF 8-BIT Multiplication:

INPUT Address 4101 4104 Data

OUTPUT Address 4500 4501 Data

Flow Chart:

PROGRAM (8-Bit Division): Opcode & Operand 74, Data1 75, F0, Data2 84 90, 45, 00 FO A3 E5, F0 FO 80, FE HERE:

Address 4100 4102 4105 4106 4109 410A 410B 410D 410E

Label

Mnemonics MOV A, #DATA1 MOV B, #DATA1 DIV AB MOV DPTR, #4500h MOVX @DPTR, A INC DPTR MOV A, B MOVX @DPTR, A SJMP HERE

Comments Move Dividend to Acc Move Divisor to B Divide A by B Move 4500 to DPTR. Move Acc value to DPTR location Increment DPTR Move B-reg. value to Acc Store the result End

(IV) 8 BIT DIVISION: ALGORITHM: 1. Start the program. 2. Get 1 operand in A and 2
st nd

in B.

3. Divide A by B contents using division instruction. 4. Store the result in memory. 5. Stop the program.

OUTPUT OF 8-BIT Division: INPUT Address 4101 4104 Data OUTPUT Address 4500 (Quotient) 4501 (Remainder) Data

Flow Chart:

PROGRAM (OR): Address 4100 4102 4104 4107 4108 Opcode & Operand 74, Data1 44, Data2 90, 45, 00 FO 80, FE HERE Label Mnemonics MOV A, #DATA1 ORL A, #DATA2 MOV DPTR, #4500H MOVX @DPTR, A SJMP HERE Comments Move Data1 to Acc OR Acc and Data2 Move 4500 to DPTR. Store the result End

(B) LOGICAL OPERATION:

(I) OR OPERATION: ALGORITHM: 1. Start the program. 2. Load 1 3. Get 2


st

operand in Accumulator.
nd

nd

operand and perform OR between Acc and 2

Operand.

4. Store the result in memory. 5. Stop the program.

OUTPUT OF OR Operation: INPUT Address 4101 4103 Data OUTPUT Address 4500 Data

Flow Chart:

PROGRAM (AND): Opcode & Operand 74, Data1 54, Data2 90, 45, 00 FO 80, FE HERE:

Address 4100 4102 4104 4107 4108

Label

Mnemonics MOV A, #DATA1 ADL A, #DATA2 MOV DPTR, #4500H MOVX @DPTR, A SJMP HERE

Comments Move Data1 to Acc AND Acc and Data2 Move 4500 to DPTR. Store the result End

(II) AND OPERATION: ALGORITHM: 1. Start the program. 2. Get 1 operand in Accumulator. 3. Get 2
nd st

operand and perform AND accumulator content & 2

nd

operand

4. Store the result in memory. 5. Stop the program.

OUTPUT OF AND Operation: INPUT Address 4101 4103 Data OUTPUT Address 4500 Data

RESULT: Thus the programs involving arithmetic, logical and bit manipulation using 8051 are executed and its results are verified.

S-ar putea să vă placă și