Microprocessor Programs

Download Microprocessor Programs

Post on 02-Apr-2015

2.698 views

Category:

Documents

7 download

Embed Size (px)

TRANSCRIPT

<p>MICROPROCESSOR LABORATORY LIST OF EXPERIMENTSI. 8085 Programming 1. 2. 3. 4. 5. 6. 7. 8. Study of 8085 Microprocessor 8 bit Addition, Subtraction 8 bit Multiplication and Division. 16 bit Addition 16 bit Subtraction BCD to Hex Hex to BCD code conversion. Largest and smallest of a given set of numbers. Block Movement of Data. 50 Marks</p> <p>NOTE: Write Procedure in the record after algorithm: PROCEDURE: Entering the program in the kit, entering input in the kit, executing the program and observing the output (In your own words- Not as given here)RECORD NOTEBOOK / OBSERVATION WRITING FORMAT LEFT HAND SIDE (UNRULED) 1. SAMPLE INPUT AND OUTPUT 2. INPUT AND OUTPUT 3. DIAGRAM IF ANY REQUIRED(INSTRUCTED BY INCHARGE) (in record only) RIGHT HAND SIDE (RULED) 1</p> <p>23 4 5 6</p> <p>AIM APPARATUS REQUIRED ALGORITHM PROCEDURE PROGRAM RESULT</p> <p>1</p> <p>8085 PROGRAMMING 1. STUDY OF 8085 PROCESSOR Draw 8085 architecture diagram in the record</p> <p>WRITE ABOUT ARCHITECHTURE OF 8085 FOR 4 PAGES. (LEAVE FOUR FIVE PAGES FOR THIS STUDY)</p> <p>2</p> <p>2. 8-BIT ADDITION AND SUBTRACTION AIM: To write and execute an assembly language program to perform the addition and subtraction two eight bit numbers using 8085 kit. a) ADDITION ALGORITHM: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 : : : : : : : : : : Start. Clear C register for carry Load the first data from memory to accumulator and move it to B register. Load the second data from memory to accumulator. Add the content of B register to the accumulator. Check for carry. If carry = 1, go to step 7 else if carry =0, go to step 8. Increment the C register. Store the sum in memory Move the carry to accumulator and store in memory End Program</p> <p>PROGRAM: Memory Address 8000 8002 8005 8006 8009 800A 800D 800E 8011 8012 8015 Label Hex code 0E,00 3A, 00, 90 47 3A, 01, 90 80 D2, 0E, 80 0C 32, 00, 95 79 32, 01, 95 CF Mnemonics Opcode Operand MVI C,00 LDA 9000 MOV LDA ADD JNC INR STA MOV STA RST 1 B,A 9001 B 800E (L1) C 9500 A,C 9501 &amp;&amp; Comments Clear C register for carry Load the first data from memory to accumulator Move the data to B register. Load the second data from memory to accumulator. Add the content of B register to the accumulator. Check for carry. If carry = 1, increment carry register else if carry =0 store the result Increment the C register for carry Store the sum in memory Move the carry to accumulator Store Carry in memory End the program</p> <p>L1</p> <p>Note:RST 1 can be replaced by HLT also to terminate the program. Hex code for HLT is 76.</p> <p>3</p> <p>SAMPLE INPUT &amp; OUTPUT: Before Execution Memory Data Address 9000 AE Addend 9001 FD Augend b) SUBTRACTION: ALGORITHM: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 PROGRAM: Memory Address 8000 8002 8005 8006 8009 800A 800D 800E 800F 8010 8013 8014 8017 L1 Lab el Hex Code 0E, 00 3A, 00, 90 47 3A, 01, 90 90 D2, 0E, 80 0C 2F 3C 32, 01, 95 79 32, 02, 95 CF Mnemonics Opcod Operand e MVI C,00 LDA MOV LDA SUB JNC INR CMA INR STA MOV STA RST 1 9000 B,A 9001 B 800E (L1) C A 9501 A,C 9502 Comments C register is used as a carry counter and initiated Subtrahend is loaded in B register through Acc, Minuend is loaded in Acc. Subtraction is performed and the result is checked for carry. If carry is present carry counter is incremented If carry is present then the answer is in twos compliment form. So convert it in to original form Store the result in memory location 9501 Move the carry from c register to Acc and store it in memory location 9502 Program ends. : : : : : : : : : : Start. Clear C register to account for sign of the result. Load the subtrahend (the data to be subtracted) from memory to accumulator and move it to B register. Load the minuend from memory to accumulator. Subtract the content of B register from the content of the accumulator. Check for carry. If carry = 1, go to step 7 else if carry =0, go to step 8. Increment the C register. Complement the accumulator and add 01H. Store the difference in memory. Move the content of C register (sign bit) to accumulator and store in memory. End program</p> <p>4</p> <p>5</p> <p>SAMPLE INPUT &amp; OUTPUT:</p> <p>Before Execution Memory Data Address 9000 EF Subtrahend 9001 AF Minuend</p> <p>RESULT: An assembly language program to perform the addition and subtraction two eight bit numbers using 8085 kit is written and executed.</p> <p>6</p> <p>3. 8 BIT MULTIPLICATION AND DIVISION. AIM: To write and execute an assembly language program to perform the multiplication and division of two eight bit numbers using 8085 kit. a) MULTIPLICATION ALGORITHM: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 Step 11 Step 12 PROGRAM: Memory Address 8000 8002 8005 8006 8009 800A 800C 800D 8010 8011 8012 8015 8018 8019 8022 L2 Label Hex Code 16,00 3A,00,90 47 3A,01,90 4F 3E,00 80 D2,11,80 14 0D C2,0C,80 32,00,95 7A 32,01,95 CF Mnemonics Opcode Operand MVI D, 00 LDA MOV LDA MOV MVI ADD JNC INR DCR JNZ STA MOV STA RST 1 9000 B, A 9001 C, A A, 00 B L1 (8011) D C L2 (800C) 9500 A, D 9501 Comments D register is initiated and used as a carry counter The multiplier in memory location 9000 is moved to B register through Acc The multiplicand in memory location 9001 is moved to c register through Acc Acc is initiated for repeated addition In repeated addition carry is tested. If any carry is present then carry counter is incremented Repeated addition is tested for multiplicand times The result is stored in the memory location 9500 and 9501 Program ends : : : : : : : : : : : : Start. Clear Reg D for Carry Load 1st Number ( Multiplicand in Reg B through reg A Load 2nd Number ( Multiplier in Reg C through reg A Clear Reg A ( Accumulator) Now add content of Reg B with Reg A Check for Carry if carry NOT exists then skip next step Decrement 2nd number ( multiplier) in Reg C Check for Reg C for zero, If NOT zero go to step 6 Else continue Store the result ( product) in reg A into output memory address Store the Carry in Reg D into next output memory address End Program</p> <p>L1</p> <p>7</p> <p>SAMPLE INPUT &amp; OUTPUT: Before Execution Memory Address 4200 4201 Data EF AF Multiplicand Multiplier After Execution Memory Address 4202 4203 Data 61 A3 LSB of Product MSB of the Product</p> <p>d) DIVISION ALGORITHM: Step 1 : Step 2 : Step 3 : Step 4 : Step 5 : Step 6 : Step 7 : Step 8 : Step 9 : Step 10: Step 11 : PROGRAM: Memory Address 8000 8002 8005 8006 8009 800A 800D 800E 800F 8012 8015 8016 8019 L1 Label Hex Code 0E, 00 3A, 00, 90 47 3A, 01, 90 B8 DA, 12 ,80 90 0C C3, 09, 80 32, 00, 95 79 32, 01, 95 CF Mnemonics Opcode Operand MVI C,00 LDA 9000 MOV B,A LDA 9001 CMP B JC 8012 (L1) SUB INR JMP STA MOV STA RST 1 B C 8009 (L2) 9500 A,C 9501 CommentsClear C register to account for quotient</p> <p>Start. Clear C register to account for quotient. Load the divisor in accumulator and move it to B register. Load the dividend in the accumulator. Check whether divisor is less than dividend. If divisor is less than dividend, go to step 9, else go to next step. Subtract the content of B register from accumulator. Increment the content of C register (quotient). Go to step 5. Store the content of accumulator (remainder) in memory. Move the content of C register (quotient) to accumulator and store in memory. End program.</p> <p>Load the divisor in accumulator and move it to B register.Load the dividend in the accumulator. Check whether divisor is less than dividend. If so quotient is zero. Devisor is the Remainder .Go and store the results Repeated subtraction starts.For each subtraction quotient register is incremented. This continues till the devisor becomes less than the devider The remainder is stored in memory location 9500</p> <p>L2</p> <p>Quotient is stored in the memory location through Acc Program Ends</p> <p>8</p> <p>9</p> <p>SAMPLE INPUT &amp; OUTPUT: Before Execution Memory Address 9000 9001 Data EF AF Divisor Dividend</p> <p>RESULT: An assembly language program to perform the multiplication and division of two eight bit numbers using 8085 is written and executed.</p> <p>10</p> <p>4. ADDITION OF TWO SIXTEEN BIT NUMBERS AIM: To write an assembly language program to perform the addition of two sixteen bit numbers. a) ADDITION ALGORITHM: Step 1 : Step 2 : Step 3 : Step 4 : Step 5 : Step 6 : Step 7 : Step 8 : Step 9 : Step 10: Step 11: PROGRAM: Memory Address 8000 8002 8005 8006 8009 800A 800D 800E 8011 8012 8015 Label Hex Code 0E, 00 2A, 00, 90 EB 2A, 02, 90 19 D2, 0E, 80 0C 22, 00, 95 79 32, 02, 95 CF Mnemonics Opcode Operand MVI C,00 LHLD 9000 XCHG LHLD 9002 DAD D JNC 800E (L1) INR C SHLD 9500 MOV STA RST 1 A,C 9502 Comments Initiate C register to store carry Load the first data in HL register pair and move it to DE register pair Load the second data in HL register pair (HL)(HL)+(DE) If carry occurs increment the carry counter Store the 16 bit addition result in the memory location starting form 9500 Move the carry to the memory location 9502 through the Accumulator Program ends Start. Clear C register for carry. Load the first data in HL register pair. Move the first data to DE register pair. Load the second data in HL register pair. Add the content of DE register pair to HL register pair. Check for carry. If carry = 1, go to step 8 else if carry =0, go to step 9. Increment the C register to account for carry. Store the sum in memory. Move the carry to accumulator and store in memory. End program.</p> <p>L1</p> <p>11</p> <p>SAMPLE INPUT &amp; OUTPUT: Before Execution Memory Address 9000 9001 9002 9003 Data CD AB AA AA Upper Byte (addend) Lower Byte (Addend) Upper Byte (Augend) Lower Byte (Augend) After Execution Memory Address 9500 9501 9502 Data 77 56 01 Lower Byte Sum Upper Byte Sum Carry</p> <p>RESULT: An assembly language program to perform addition of two 16-bit numbers using 8085 is written and executed.</p> <p>12</p> <p>5. SUBTRACTION OF TWO SIXTEEN BIT NUMBERS AIM: To write an assembly language program to perform the subtraction of two sixteen bit numbers. ALGORITHM: Step 1 : Step 2 : Step 3 : Step 4 : Step 5 : Step 6 : Step 7 : Step 8 : Step 9 : Step 10: Step 11: PROGRAM: Memory Address 8000 8003 8004 8007 8008 8009 800C 800D 800E 8011 Label Hex Code 2A, 00, 90 EB 2A, 02, 90 7B 95 32, 00, 95 7A 9C 32, 01, 95 CF Mnemonics Opcode Operand LHLD 9000 XCHG LHLD 9002 MOV A, E SUB STA MOV SBB STA RST 1 L 9500 A, D H 9501 Comments The 16 bit minuend is stored in the DE register pair through HL register pairThe subtrahend is stored in the HL register pair</p> <p>Start. Load the first data in HL register pair. Move the first data to DE register pair. Load the second data in HL register pair. Move the content of E to A. Subtract Content of L from A (Lower Bytes) Store the difference in the memory Move the content of D to A. Subtract Content of H from A with borrow (higher Bytes) Store the difference in the memory End program.</p> <p>The lower byte of the minuend is moved to the accumulatorThe lower byte of the subtrahend is subtracted from the accumulator contents</p> <p>The lower byte result is stored in the memory location 9500Higher byte of the minuend is moved to Acc.</p> <p>Higher byte of the subtrahend is subtracted with borrow The higher byte result is stored in the memory location 9501 Program Ends</p> <p>13</p> <p>SAMPLE INPUT &amp; OUTPUT: Before Execution Memory Address 9000 9001 9002 9003 Data CD AB AA AA Upper Byte (Subtrahend) Lower Byte (Subtrahend) Upper Byte (Minuend) Lower Byte (Minuend) After Execution Memory Address 9500 9501 Data 23 01 Lower Byte Difference Upper Byte Difference</p> <p>RESULT: An assembly language program to perform subtraction of two 16-bit numbers using 8085 is written and executed.</p> <p>14</p> <p>6. CONVERTING A BCD NUMBER TO HEX NUMBER AIM: To write an assembly language program to convert BCD number in memory to the equivalent HEX number using 8085. a) BCD TO HEX CONVERSION ALGORITHM: Step 1 : Step 2 : Step 3 : Step 4 : Step 5 : Step 6 : Step 7 : Step 8 : Step 9 : Step 10: Step 11: Step 12: Step 13: Step 15: Step 14: PROGRAM: Memory Address 8000 8003 8004 8006 8007 8008 8009 800A 800B 800D 800F 8010 8011 8014 8015 8016 8018 8019 801C Label Hex Code 3A, 00, 90 5F E6, 0F 0F 0F 0F 0F 47 3E,00 0E, 0A 80 OD C2, 0F, 80 47 E6, F0 80 32, 00, 95 CF Mnemonics Opcode Operand LDA 9000 MOV E, A ANI F0 RRC RRC RRC RRC MOV B, A MVI A,00 MVI C,0A ADD B DCR C JNZ 800F(L1) MOV B, A MOV ANI ADD STA RST A, E 0F B 9500 1 Comments Load the BCD number in Acc and copy it in E register. The first digit of the BCD is masked. By rotating four times the lower nibble and higher nibble are exchanged. ( that is the tens digit is bought to the Ones place) That is saved in the B register The accumulator is initiated and added with the B register contents continuously for ten times.(For this C register is stored with 0A and used as a counter The tens value is stored in the B register The BCD number is stored in the accumulator and the higher byte is masked to get the ones valueOnes value is added with the tens value</p> <p>Start Load the BCD number in accumulator (Reg A) Copy it to Reg E Mask the Lower Nibble of the BCD number Rotate it 4 times to move Upper nibble to lower nibble place Copy the number to Reg B Clear Reg A Copy number 0A in Reg C (Decimal number 10) Multiply the number in B by 10d Then move the product in Reg B Copy the original number in Reg E to Reg A Mask the Upper Nibble of the BCD Number Add the Number in Reg B with the number in Reg A The number is copied to a memory location End program.</p> <p>L1</p> <p>The resulting hexadecimal number is stored in the memory location 9500 The program ends</p> <p>15</p> <p>16</p> <p>SAMPLE INPUT &amp; OUTPUT: Before Execution Memory Data Address 9000 29 (BCD) After Execution Memory Data Address 9500 1D (HEX)</p> <p>RESULT: An assembly language program to convert the Binary coded decimal (BCD) into Hexadecimal number (HEX) has been written and executed using microprocessor 8085.</p> <p>17</p> <p>7. CONVERTING HEXADECIMAL NUMBER TO BCD NUMBER AIM: To write an assembly language program to convert HEX numbers in memory to the equivalent BCD number using 8085. ALGORITHM: Step 1 : Step 2 : Step 3 : Step 4 : Step 5 : Step 6 : Step 7 : Step 8 : Step 9 : Step 10: Step 11: Step 12: Step 13: Step 15: Step 14: Step 15: Step 16: Step 17: Start Clear Reg D and E to store tens and hundreds respectively Load the HEX number in accumulator (Reg A) Compare Hex number with 64h (100d)(Check for Hundreds) If carry , HEX </p>

Recommended

View more >