Found 558 Articles for Microprocessor

8051 Program to Divide two 8 Bit numbers

George John
Updated on 27-Jun-2020 12:48:19

8K+ Views

Now we will see another arithmetic operation. The divide operation to divide two 8-bit numbers using this 8051 microcontroller. The register A and B will be used in this operation. No other registers can be used for division. The result of the division has two parts. The quotient part and the remainder part. Register A will hold Quotient, and register B will hold Remainder.We are taking two number0EH and 03H at location 20H and 21H, After dividing the result will be stored at location 30H and 31H.  AddressValue...20H0EH21H03H...30H00H31H00H...ProgramMOV R0, #20H;set source address 20H to R0 MOV R1, #30H;set destination address ... Read More

8051 Program to Multiply two 8 Bit numbers

Ankith Reddy
Updated on 27-Jun-2020 12:50:12

16K+ Views

Now we will try to multiply two 8-bit numbers using this 8051 microcontroller. The register A and B will be used for multiplication. No other registers can be used for multiplication. The result of the multiplication may exceed the 8-bit size. So the higher order byte is stored at register B, and lower order byte will be in the Accumulator A after multiplication.We are taking two number FFH and FFH at location 20H and 21H, After multiplying the result will be stored at location 30H and 31H.  AddressValue...20HFFH21HFFH...30H00H31H00H...Program        MOV R0, #20H;set source address 20H to R0   ... Read More

8051 Program to Subtract two 8 Bit numbers

Arjun Thakur
Updated on 27-Jun-2020 12:50:36

10K+ Views

Here we will see how to subtract two 8-bit numbers using this microcontroller. The register A(Accumulator) is used as one operand in the operations. There are seven registers R0 – R7 in different register banks. We can use any of them as the second operand.We are taking two number73H and BDH at location 20H and 21H, After subtracting the result will be stored at location 30H and 31H.  AddressValue...20H73H21HBDH...30H00H31H00H...ProgramMOVR0, #20H;set source address 20H to R0 MOVR1, #30H;set destination address 30H to R1 MOVA, @R0;take the value from source to register A MOVR5, A; Move the value from A to ... Read More

8051 Program to Add two 8 Bit numbers

Chandu yadav
Updated on 31-Oct-2023 02:58:32

26K+ Views

Intel 8051 is an 8-bit microcontroller. It has many powerful instructions and IO accessing techniques. In this section, we will see one of the simplest program using 8051.Here we will add two8-bit numbers using this microcontroller. The register A(Accumulator) is used as one operand in the operations. There are seven registers R0 – R7 in different register banks. We can use any of them as the second operand.We are taking two number 5FH and D8H at location 20H and 21H, After adding them, the result will be stored at location 30H and 31H.  AddressValue...20H5FH21HD8H...30H00H31H00H...ProgramMOVR0, #20H;set source address 20H to R0 ... Read More

Conversion of four-digit hex to ASCII in 8051

George John
Updated on 27-Jun-2020 12:53:30

457 Views

We have already seen how to convert Hexadecimal digit to its ASCII equivalent. In this section, we will see how to convert two-byte (4-digit) Hexadecimal number to ASCII. Each nibble of these numbers is converted to its ASCII value.We are using one subroutine to convert a hexadecimal digit to ASCII. In this program, we are calling the subroutine multiple times.In the memory, we are storing 2-byte Hexadecimal number at location 20H and 21H. After converted ASCII values are stored at location 30H to 33H.The hexadecimal number is 2FA9H. The ASCII equivalent is 32 46 41 39.AddressValue...20H2FH21HA9H...30H00H31H00H32H00H33H00H...Program        MOVR0, ... Read More

Bit manipulation program in 8051

Ankith Reddy
Updated on 27-Jun-2020 12:54:00

4K+ Views

In this section, we will see some bit manipulation operation using 8051. The 8051 supports some operations on different bits of an 8-bit number. The operations are like complementing, setting to 1, moving, ANDing, ORing etc.In this example, we are taking a number AEH from location 10H, then after performing following bit related operations on that data, we are just storing the result at location 30H.The bit related operations that will be performed on that data, are as follows −Complement bit b2Move b5to b4OR b0and complement of b1 and store to C (b7)Set b6Reset bit b3Input is AEHBitPositionb7b6b5b4b3b2b1b0Value10101110OutputBitPositionb7b6b5b4b3b2b1b0Value01110010The output will be ... Read More

Hex to ASCII conversion in 8051

Arjun Thakur
Updated on 27-Jun-2020 12:54:14

5K+ Views

Now we will see how to convert Hexadecimal number to its ASCII equivalent using 8051. This program can convert 0-9 and A-F to its ASCII value. We know that the ASCII of number 00H is 30H (48D), and ASCII of 09H is39H (57D). So all other numbers are in the range 30H to 39H. The ASCII value of 0AH is 41H (65D) and ASCII of 0FH is 46H (70D), so all other alphabets (B, C, D, E) are in the range 41H to 46H.Here we are providing hexadecimal digit at memory location 20H, The ASCII equivalent is storing at location 30H.AddressValue...20H0EH21H...ProgramMOVR0, ... Read More

BCD to binary conversion in 8051

Chandu yadav
Updated on 27-Jun-2020 12:54:30

3K+ Views

In this problem, we will see how to convert 8-bit BCD number to its Binary (Hexadecimal)equivalent. The BCD number is stored at location 20H. After converting, the results will be stored at 30H.So let us assume the data is D5H. The program converts the binary value ofD5H to BCD value 213D.AddressValue...20H9421H...Program   MOVR0, #20H; Initialize the address of the data    MOVA, @R0;Get the data from an address, which is stored in R0    MOVR2, A; Store the content of A into R2        CLRA;Clear the content of A to 00H    MOVR3, #00H LOOP:   ADDA, #01H;increment A ... Read More

Binary to BCD conversion in 8051

George John
Updated on 27-Jun-2020 12:54:47

3K+ Views

In this problem, we will see how to convert an 8-bit binary number to its BCD equivalent. The binary number is stored at location 20H. After converting, the results will be stored at 30H and 31H. The 30H will hold the MS portion, and 31H will hold the LS portion. So let us assume the data is D5H. The program converts the binary value of D5H to BCD value 213D.AddressValue...20HD521H...ProgramMOVR1, #20H;Takethe address 20H into R1 MOVA, @R1;Takethe data into Acc MOVB, #0AH;LoadB with AH = 10D DIVAB ;DivideA with B MOVR5, B;Storethe remainder MOVB, #0AH;LoadB with AH = 10D DIVAB ;DivideA ... Read More

Shift a multi-byte BCD number to the right in 8051

Ankith Reddy
Updated on 27-Jun-2020 12:55:03

283 Views

Here we will see a problem to shift some multi-byte BCD number to the right. The BCD numbers are shifted by two digits (8-bit). Let us consider a four-byte BCD number (45 86 02 78) is stored at location 20H, 21H, 22H, 23H. The address 10H holds the number of bytes of the whole BCD number. So after executing this code, the contents will be shifted to the right and 20H will hold 00H.AddressValue...20H4521H8622H0223H78...Program        CLRA;Clear the Register A         MOVR2, 10H;TakeByte Count         INCR2;Increase R2 for loop         MOVR1, ... Read More

Advertisements