8051 basics

38
LAB MANUAL 1. 8-BIT MULTIPLICATION AND DIVISION AIM: To write an assembly language program to (i) Multiply two 8-bit numbers (ii) Divide two 8-bit numbers APPARATUS REQUIRED: 8085 Kit and Power supply ALGORITHM: 8-BIT MULTIPLICATION: 1. Initialize a register for carry. 2. Get the two input data (multiplier and multiplicand) from memory locations. 3. Clear accumulator for repeated addition and have multiplier as count. 4. Add multiplicand with accumulator content. 5. Check for carry. If carry =1, goto next step, else goto step 7. 6. Increment the carry register. 7. Decrement the count. 8. Check for count. If count=0, goto next step, else goto step 4. 9. Store the result and carry in memory locations. 10. Stop program execution. PROGRAM: Addres s Opcod e Label Mnemonic s Comments 4101 MVI C,00 Move immediate 00 to C register 4102

Upload: api-19951707

Post on 16-Nov-2014

129 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: 8051 Basics

LAB MANUAL

1. 8-BIT MULTIPLICATION AND DIVISION

AIM:

To write an assembly language program to(i) Multiply two 8-bit numbers(ii) Divide two 8-bit numbers

APPARATUS REQUIRED:

8085 Kit and Power supply

ALGORITHM:

8-BIT MULTIPLICATION:

1. Initialize a register for carry.2. Get the two input data (multiplier and multiplicand) from memory locations.3. Clear accumulator for repeated addition and have multiplier as count.4. Add multiplicand with accumulator content.5. Check for carry. If carry =1, goto next step, else goto step 7.6. Increment the carry register.7. Decrement the count.8. Check for count. If count=0, goto next step, else goto step 4.9. Store the result and carry in memory locations.10. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments4101 MVI C,00 Move immediate 00 to C register41024103 LDA 4500 Load accumulator with the content of 4104 Address 450041054106 MOV B,A Move the content of B-register to

Accumulator4107 LDA 4501 Load accumulator with the content of 4108 Address 45014109410A MOV D,A Move the content of D-register to

Accumulator410B XRA A X-OR the content of accumulator410C L2 ADD B Add the content of B register to

accumulator content

Page 2: 8051 Basics

410D JNC L1 Jump if no carry to label location L1410E410F4110 INR C Increment C register4111 L1 DCR D Decrenent D register4112 JNZ L2 Jump on no zero to label location L2411341144115 STA 4503 Store accumulator content to address

4503411641174118 MOV A,C Move the content of C-register to

Accumulator4119 STA 4504 Store accumulator content to address

4504411A411B411C HLT Halt the program execution

ALGORITHM:

8-BIT DIVISION:

1. Initialize a register for quotient.2. Get the two input data (divisor and dividend) from memory locations.3. Compare divisor and dividend.4. Check for carry, if set goto step 8, else to next step. 5. Subtract divisor from dividend.6. Increment the quotient register.7. Go to step 3.8. Store the remainder and quotient in memory locations.9. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments4101 MVI C,00 Move immediate 00 to C register41024103 LDA 4500 Load accumulator with the content of 4104 Address 450041054106 MOV B,A Move the content of B-register to

Accumulator4107 LDA 4501 Load accumulator with the content of

Page 3: 8051 Basics

4108 Address 45014109410A L2 CMP B Compare B register content to

accumulator content410B JC L1 Jump on carry to label location L2410C410D410E SUB B Subtract the content of B register from

accumulator content410F INR C Increment C register4110 JMP L2 Jump to label location L2411141124113 L1 STA 4503 Store accumulator content to address

4503411441154116 MOV A,C Move the content of C-register to

Accumulator4117 STA 4504 Store accumulator content to address

450441184119411A HLT Halt the program execution

PROCEDURE:

1. Key in the opcodes. 2. Give the input data at specified memory locations.3. Execute the program.4. Check the results at specified output locations.

OBSERVATION :

8-bit Multiplication Address DataInput 4500 08

4501 03Output 4503 18 (Product LSB)

4504 00 (Carry MSB)

8-bit Division Address DataInput 4500 08

4501 03Output 4503 02 (Remainder)

4504 02 (Quotient)

Page 4: 8051 Basics

Result:

Thus the assembly language programs for 8-bit multiplication and division are written, executed and the results are verified.

Page 5: 8051 Basics

2. 16-BIT ADDITION AND SUBTRACTION

AIM:

To write an assembly language program to(i) Add two 16-bit numbers(ii) Subtract two 16-bit numbers

APPARATUS REQUIRED:

8085 Kit and Power supply

16-BIT ADDITION:

ALGORITHM:

1. Clear a register for carry.2. Get the LSBs of two 16-bit data.3. Add the LSBs and Store the result in memory location.4. Get the MSBs of two 16-bit data.5. Add the MSBs with carry of LSBs.6. Check for carry. If carry =1, goto next step, else goto step 7.7. Increment the carry register8. Store the result (MSBs sum) and carry in memory locations.9. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments4101 MVI C,00 Move immediate 00 to C register41024103 LHLD 4500 Load HL registers with the contents of

Address 4500, 4501410441054106 MOV B,L Move the content of L-register to B

register4107 LHLD 4502 Load HL registers with the contents of

Address 4502, 450341084109410A MOV A,L Move the content of L-register to

Accumulator.

Page 6: 8051 Basics

410B ADD B Add B register content to accumulator content

410C STA 4600 Store accumulator content to address 4600

410D410E410F MOV A,H Move the content of H-register to

Accumulator4110 ADC D Add with carry, D register content to

accumulator content4111 JNC L1 Jump on no carry to label location L2411241134114 INR C Increment C register4115 L1 STA 4601 Store accumulator content to address

4601411641174118 MOV A,C Move the content of C-register to

Accumulator4119 STA 4602 Store accumulator content to address

4602411A411B411C HLT Halt the program execution

16-BIT SUBTRACTION:

ALGORITHM:

1. Clear a register for carry.2. Get the LSBs of two 16-bit data.3. Subtract the LSBs and Store the result in memory location.4. Get the MSBs of two 16-bit data.5. Subtract the MSBs with borrow.6. Check for carry (borrow). If carry =1, goto next step, else goto step 7.7. Increment the carry register8. Store the result (MSBs difference) and carry in memory locations.9. Stop program execution.

Page 7: 8051 Basics

PROGRAM:

Address Opcode Label Mnemonics Comments4101 MVI C,00 Move immediate 00 to C register41024103 LHLD 4500 Load HL registers with the contents of4104 Address 4500, 450141054106 MOV B,L Move the content of L-register to B

register4107 MOV D,H Move the content of H-register to D

register.4108 LHLD 4502 Load HL registers with the contents of4109 Address 4502, 4503410A410B MOV A,L Move the content of L-register to

Accumulator410C SUB B Subtract B register content from

accumulator content410D STA 4600 Store accumulator content to address

4600410E410F4110 MOV A,H Move the content of H-register to

Accumulator4111 SBB D Subtract with borrow,D register content

from accumulator content4112 JNC L1 Jump on no carry to label location L2411341144115 INR C Increment C register4116 L1 STA 4601 Store accumulator content to address

4601411741184119 MOV A,C Move the content of C-register to

Accumulator411A STA 4602 Store accumulator content to address

4602411B411C411D HLT Halt the program execution

Page 8: 8051 Basics

PROCEDURE:

1. Key in the opcodes. 2. Give the input data at specified memory locations.3. Execute the program.4. Check the results at specified output locations.

OBSERVATION :

16-bit Addition Address DataInput 4500 08

4501 034502 044503 07

Output 4600 0C ( LSB Sum)4601 0A ( MSB Sum)4602 00 ( Carry)

16-bit Subtraction Address DataInput 4500 08

4501 0A4502 094504 0B

Output 4600 014601 014602 00

Result:

Thus the assembly language programs for 16-bit addition and subtraction are written, executed and the results are verified.

Page 9: 8051 Basics

3. 16-BIT MULTIPLICATION AND DIVISION

AIM:

To write an assembly language program (i) to multiply two 16-bit numbers and(ii) to divide two 16-bit numbers

APPARATUS REQUIRED:

8085 Kit and Power supply

ALGORITHM:

16-BIT MULTIPLICATION:

1. Initialize a register pair for carry.2. Get the two 16-bit input data (multiplier and multiplicand) directly in register

pairs.3. Clear HL register pair for repeated addition and have multiplier as count.4. Add multiplicand with HL register pair content.5. Check for carry. If carry =1, goto next step, else goto step 7.6. Increment the carry register.7. Decrement the 16-bit count (Multiplier).8. Check for count. If count=0, goto next step, else goto step 4.9. Store the result and carry in memory locations.10. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments4101 LXI B,0000 Load immediate 0000 to BC register pair410241034104 LHLD 4500 Load HL registers with the contents of

Address 4500, 4501410541064107 SPHL Move the content of HL-registers to

stack pointer register.4108 LHLD 4502 Load HL registers with the contents of

Address 4502, 45034109410A410B XCHG Exchange the contents of HL and DE

Page 10: 8051 Basics

register pairs410C LXI H,0000 Load immediate 0000 to HL register pair410D410E410F L2 DAD SP Add the content of stack pointer register

to HL register pair4110 JNC L1 Jump on no carry to label location L1411141124113 INX B Increment BC register pair4114 L1 DCX D Decrement DE register pair4115 MOV A,E Move the content of E-register to

Accumulator4116 ORA D Logigally OR the content of D register to

accumulator4117 JNZ L2 Jump on no zero to label location L241184119411A SHLD 4600 Store the contents of HL registers to

address 4600,4601411B411C411D MOV L,C Move the content of C-register to L

register411E MOV H,B Move the content of B-register to H

register411F SHLD 4602 Store the contents of HL registers to

address 4602,4603412041214122 HLT Halt the program execution

16-BIT DIVISION:

ALGORITHM:

1. Initialize a register pair for quotient.2. Get the two 16-bit data (in HL pair and in a register pair).3. Save HL pair’s content to stack.4. Subtract the LSBs and Store the result in L-register.5. Subtract the MSBs with borrow.6. Check for carry (borrow). If carry =1, goto step 9, else goto next step.7. Increment the register pair for quotient.8. Store the result of subtraction in H-register. Goto step 3.

Page 11: 8051 Basics

9. Store the Stack register content (Remainder) and quotient in memory locations.

10. Stop program execution

PROGRAM:

Address Opcode Label Mnemonics Comments4101 LXI D,0000 Load immediate 0000 to DE register pair410241034104 LHLD 4500 Load HL registers with the contents of

Address 4500, 4501410541064107 LXI B, 16-

bit dataLoad immediate 16-bit data to BC register pair

41084109410A SPHL Move the content of HL-registers to

stack pointer register.410B MOV A.L410C SUB C Load immediate 0000 to HL register pair410D MOV L,A Move the content of L-register to B

register410E MOV A,H410F L2 SBB B Add the content of stack pointer register

to HL register pair4110 JC L1 Jump on no carry to label location L1411141124113 INX D Increment BC register pair4114 L1 MOV H,A Decrement DE register pair4115 JMP L2 Move the content of E-register to

Accumulator4116 Logigally OR the content of D register to

accumulator4117 Jump on no zero to label location L24118 LXI H,00004119411A Store the contents of HL registers to

address 4600,4601411B DAD SP411C SHLD 4600 Store the contents of HL registers to

address 4600,4601411D

Page 12: 8051 Basics

411E Move the content of B-register to H register

411F XCHG Exchange the contents of HL and DE register pairs

4120 SHLD 4602 Store the contents of HL registers to address 4602,4603

412141224123 HLT Halt the program execution

PROCEDURE:

1. Key in the opcodes. 2. Give the input data at specified memory locations.3. Execute the program.4. Check the results at specified output locations.

OBSERVATION :

16-bit Multiplication Address DataInput 4500 24(LSB1)

4501 5A(MSB1)4502 C2(LSB2)4503 47(MSB2)

Output 4600 48(LSB Product)4601 4B(LSB Product)4602 44(MSB Product)4603 19(MSB Product)

Result:

Thus the assembly language program for 16-bit multiplication is written, executed and the results are verified.

Page 13: 8051 Basics

4. DECIMAL ARITHMETIC AND BIT MANIPULATION

AIM:

To write an assembly language program to (i) Add and subtract two numbers of 2 digit (8-bit) BCD data.(ii) Perform bit manipulation using logical instructions

APPARATUS REQUIRED:

8085 Kit and Power supply

BCD ADDITION:

ALGORITHM:

1. Initialize a register for carry.2. Get the two input data.(One data in accumulator and another in register)3. Add the two data.4. Restore the result in BCD.5. Check for carry. If carry =1, goto next step, else goto step 7.6. Increment the carry register.7. Store the result and carry in memory locations.8. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments4101 MVI C,00 Move immediate 00 to C register41024103 LDA 4500 Load Accumulator with the content of

Address 4500410441054106 MOV B,A Move the content of accumulator to B

register4107 LDA 4501 Load Accumulator with the content of

Address 450141084109

Page 14: 8051 Basics

410A ADD B Add B register content to accumulator content

410B DAA Decimal Adjust Accumulator410C JNC L1 Jump on no carry to label location L1410D410E410F INR C Increment C register4110 L1 STA 4601 Store accumulator content to address

4601411141124113 MOV A,C Move the content of C-register to

Accumulator4114 STA 4602 Store accumulator content to address

4602411541164117 HLT Halt the program execution

BCD SUBTRACTION:

ALGORITHM:

1. Get the two input data.(Minuend in accumulator and Subtrahend in one register)

2. Take the 10’s complement of Subtrahend.3. Add the two data.4. Restore the result in BCD.5. Store the result memory.6. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments4101 LDA 4500 Load Accumulator with the content of

Address 4500410241034104 MOV B,A Move the content of accumulator to B

register4105 MVI A,99 Move immediate 00 to A register4106

Page 15: 8051 Basics

4107 SUB B Subtract the content of B-register from Accumulator content

4108 INR A Increment A register content4109 MOV B,A Move the content of accumulator to B

registe410A LDA 4501 Load Accumulator with the content of

Address 4501410B410C410D ADD B Add B register content to accumulator

content410E DAA Decimal Adjust Accumulator410F STA 4601 Store accumulator content to address

4601411041114112 HLT Halt the program execution

BIT MANIPULATION: (CONVERTING BCD DATA TO BINARY NUMBER)

ALGORITHM:

1. Get the BCD data in one register.2. Mask the Units number (lower nibble) and get the ten’s number in a register.3. Clear accumulator.4. Load the count 10 in a register.5. Add the Ten’s number to accumulator.6. Decrement count.7. Check for zero. if count=0, goto next step else goto step 5.8. Save the product in a register.9. Mask the ten’s number (upper nibble) of BCD data.10. Add the units number in the above step to the product in step 8.11. Store the binary value.12. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments4101 LDA 4500 Load accumulator with the content of

Address 450041024103

Page 16: 8051 Basics

4104 MOV E,A Move the content of Accumulator to E register

4105 ANI F0 AND immediate F0, with the content of accumulator

41064107 RLC Rotate accumulator left to carry4108 RLC Rotate accumulator left to carry4109 RLC Rotate accumulator left to carry410A RLC Rotate accumulator left to carry410B MOV B,A Move the content of Accumulator to B

register410C XRA A X-OR the content of accumulator410D MVI C,0A Move immediate 0A to C register410E410F L1 ADD B Add the content of B register to

accumulator content4110 DCR C Decrement C register4111 JNZ L1 Jump on no zero to label location L1411241134114 MOV B,A Move the content of Accumulator to B

register4115 MOV A,E Move the content of E register to

Accumulator 4116 ANI 0F AND immediate 0F, with the content of

accumulator4117 ADD B Add the content of B register to

accumulator content4118 STA 4501 Store accumulator content to address

45014119411A411B HLT Halt the program execution

PROCEDURE:

1. Key in the opcodes. 2. Give the input data at specified memory locations.3. Execute the program.4. Check the results at specified output locations.

Page 17: 8051 Basics

OBSERVATION :

BCD Addition Address DataInput 4500 24

4501 55Output 4601 79

4602 00

BCD Subtraction Address DataInput 4500 24

4501 55Output 4601 31

Bit Manipulation(BCD to Binary Conversion)

Address Data

Input 4500 45(BCD)Output 4501 2D(Binary)

Result:

Thus the assembly language programs for BCD Addition, BCD Subtraction and Bit manipulation (BCD to Binary conversion) are written, executed and the results are verified.

Page 18: 8051 Basics

5. CODE CONVERSION

AIM:

To write an assembly language program to (i) Convert 8-bit Binary data to ASCII code(ii) Convert ASCII code to Binary number

APPARATUS REQUIRED:

8085 Kit and Power supply

BINARY TO ASCII:

ALGORITHM:

1. Get the data in a register.2. Mask the upper nibble of binary (Hex) data.3. Call subroutine CODE to get ASCII code of the lower nibble and store in a

memory.4. Mask the lower nibble of binary(Hex) input data.5. Rotate upper nibble to lower nibble position.6. Call subroutine CODE to get ASCII code of the upper nibble and store in a

memory.7. Stop.

ALGORITHM FOR SUBROUTINE “CODE”:

1. Compare the nibble in Accumulator with 0A(Hex).2. If Carry=1, goto step 4, else goto next step.3. Add 07(Hex) to the nibble in Accumulator.4. Add 30(Hex) to the nibble in Accumulator.5. Return to main program.

FLOWCHART:

Page 19: 8051 Basics

PROGRAM:

Address Opcode Label Mnemonics Comments4101 LDA 4200 Load accumulator with the content of

Address 4200410241034104 MOV B,A Move the content of Accumulator to B

register4105 ANI 0F AND immediate 0F, with the content of

accumulator4106

CALL Code Call the Subroutine labeled “Code”

STA 4201 Store accumulator content to address 4201

Page 20: 8051 Basics

MOV A,B Move the content of B register to accumulator

ANI F0 AND immediate F0, with the content of accumulator

4107 RLC Rotate accumulator left to carry4108 RLC Rotate accumulator left to carry4109 RLC Rotate accumulator left to carry410A RLC Rotate accumulator left to carry410B CALL Code Call the Subroutine labeled “Code”410C410D410E STA 4202 Store accumulator content to address

4202410F41104111 HLT Halt the program execution

41124113 Code: CPI 0A Compare immediate 0a with the content

of accumulator41144115 JC L1 Jump on carry to label location L14116 ADI 07 ADD immediate 07, with the content of

accumulator41174118 L1 ADI 30 ADD immediate 30, with the content of

accumulator4119411A RET Return to main programOBSERVATION :

Binary(HEX) to ASCII Address DataInput 4200 E4(HEX)Output 4201 34(ASCII Code for 4)

4202 45(ASCII code for E)Result:

Thus the assembly language programs for the code conversion (Binary to ASCII and ASCII to Binary) are written, executed and the results are verified.

VIVA QUESTIONS:

1. What is the difference between RLC and RAL?

Page 21: 8051 Basics

2. What are machine control instructions?3. How many machine cycles are required for STA 4500?4. What is T-State?5. What are I/O related instructions?

MATRIX MULTIPLICATION

AIM:

To write an assembly language program to reform matrix multiplication using 8086.

ALGORITHM:

1. Define the segments and the data for two matrices ant their size using the respective assembler directives.

2. Get the offset addresses of Matrix 1 & 2 in corresponding index registers.3. Clear Accumulator and Lower byte of flag register.4. Multiply the elements of corresponding row and column in sequence, for matrix

multiplication using loop.5. Store the result and stop execution.

FLOWCHART:

Page 22: 8051 Basics

PROGRAM:

ASSUME CS: CODE, DS: DATADATA SEGMENTROCOL EQU 03HMAT1 DB 05H, 09H, 0AH,03H, 02H, 07H, 03H, 00H, 09HMAT2 DB 09H, 07H, 02H, 01H, 00H, 0DH, 07H, 06H, 02HPMAT3 DW 09H DUP (?)DATA ENDSCODE SEGMENTSTART : MOV AX, DATA

MOV DS, AXMOV CH, ROCOLMOV BX, OFFSET PMAT3MOV SI, OFFSET MAT1

NEXTROW: MOV DI, OFFSET MAT2MOV CL, ROCOL

NEXTCOL: MOV DL, ROCOLMOV BP, 0000H

Page 23: 8051 Basics

MOV AX, 0000HSAHF

NEXT_ELE: MOV AL, [SI]MUL BYTE PTR [DI]ADD BP, AXINC SIADD DI, 03DEC DLJNZ NEXT_ELESUB DI, 08SUB SI, 03MOV [BX], BPADD BX, 02DEC CLJNZ NEXTCOLADD SI, 03DEC CHJNZ NEXTROWMOV AH, 4CHINT 21H

CODE ENDSEND START

PROCEDURE:

1. Type the program in editor pad.2. Copy it to MASM assembler software.3. Assemble the program, check for errors.4. Run the program and check the result.5. Or transfer the program to kit and execute. Verify the result.

RESULT:

The program for performing 3x3 matrix multiplication is written, executed and the result is verified.

Page 24: 8051 Basics

INTERFACING KEYBOARD/DISPLAY CONTROLLER TO 8085

AIM:To interface Keyboard/Display controller(8279) with 8085 processor and to

display a particular string.

ALGORITHM: (To display the string “HELLO”)

1. Form the look up table.2. Move the control word to accumulator and out it through control register.3. Get the letters one by one from memory and out it.4. Check whether all letters are displayed. If not, display next character.5. Stop of program.

FLOWCHART:

Page 25: 8051 Basics

PROGRAM:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS4500 21 LXI H, 4600 Load immediate HL register

pair with 46004501 004502 464503 3E MVI A, 10 Move immediate 10 to

accumulator4504 904505 D3 OUT 01 Out it through CR4506 014507 7E L1 MOV A,M Move memory content to

accumulator4508 D3 OUT 00 Out it through 8279 port4509 00450A 23 INX H Increment HL register pair450B 7D MOV A,L Move the content of L

register to accumulator450C FE CPI 06 Compare immediate with 06450D 06450E C2 JNZ L1 Jump on no zero to label

location L1450F 074510 814511 76 HLT Halt the process

PROCEDURE:

1. Key in the opcodes.2. Give the input data from look up table at the specified memory locations.3. Execute the program and verify the character display.

Result:

The Keyboard/Display controller is interfaced with 8085 and the character display is verified.

Page 26: 8051 Basics

SIMPLE ARITHMETIC OPERATIONS USING 8051

AIM:

To write an assembly language program to (i) add two 8-bit numbers (ii) subtract two 8-bit numbers (iii) multiply two 8-bit numbers (iv) divide two 8-bit numbers.

APPARATUS REQUIRED:

8051 Microcontroller Kit and Power Supply

ALGORITHM:

8-BIT ADDITION:1. Clear carry flag.2. Get the first data in accumulator.3. Add the second data with that of accumulator.4. Store the result in a memory location.5. Stop execution.

Flowchart:

PROGRAM:

ADDRESS OPCODES MNEMONICS COMMENTS4100 C3 CLR C4101 74 MOV A, #DATA14102 344103 24 ADDC A, #DATA24104 784105 90 MOV DPTR, #41504106 414107 504108 F0 MOVX @DPTR, A4109 80 L1: SJUMP L1410A FE

ALGORITHM:

8-BIT SUBTRACTION:1. Clear carry Flag.2. Get the first data in accumulator.

Page 27: 8051 Basics

3. Subtract the second data from that of accumulator.4. Store the result in a memory location.5. Stop execution.6.

FLOCHART:

PROGRAM:

ADDRESS OPCODES MNEMONICS COMMENTS4100 C3 CLR C4101 74 MOV A, #DATA14102 344103 94 SUBB A, #DATA24104 244105 90 MOV DPTR, #45004106 454107 004108 F0 MOVX @DPTR, A4109 80 L1: SJUMP L1410A FE

ALGORITHM:

8-BIT MULTIPLICATION:1. Get the first data in accumulator.2. Get the second data in B register.3. Multiply the two data.4. Store the result in a memory location.5. Stop execution.

FLOWCHART:

PROGRAM:

ADDRESS OPCODES MNEMONICS COMMENTS4100 74 MOV A, #DATA14101 0A4102 75 MOV B, #DATA24103 F04104 884105 A4 MUL AB4106 90 MOV DPTR, #41504107 41

Page 28: 8051 Basics

4107 504108 F0 MOVX @DPTR, A4109 A3 INC DPTR410A E5 MOV A,B410B F0410C F0 MOVX @DPTR,A410D 80 L1: SJUMP L1410E FE

ALGORITHM:

8-BIT DIVISION:

1. Get the first data (dividend) in accumulator.2. Get the second data (Divisor) in B register.3. Divide the two data.4. Store the result in a memory location.5. Stop execution.

FLOWCHART:

PROGRAM:

ADDRESS OPCODES MNEMONICS COMMENTS4100 74 MOV A, #DATA14101 654102 75 MOV B, #DATA24103 F04104 084105 84 DIV AB4106 90 MOV DPTR, #41504107 414107 504108 F0 MOVX @DPTR, A4109 A3 INC DPTR410A E5 MOV A,B410B F0410C F0 MOVX @DPTR,A410D 80 L1: SJUMP L1410E FE

Page 29: 8051 Basics

PROCEDURE:

1. Enter the opcodes and data.2. Execute the program and verify the results at specified memory locations.

OBSERVATION:

RESULT:

The assemble language programs for addition, subtraction, multiplication and division operation are written, executed and the results are verified.