Found 475 Articles for 8085

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

Program branch group in 8051

Arjun Thakur
Updated on 27-Jun-2020 12:56:44

4K+ Views

In 8051 Microcontroller there is 17 different instructions under the Logical Group. In total there are 46 opcodes. These instructions do not affect the flag bits but the CJNE affects the CY flag. In these instructions, the 11-bit address and 16-bit addresses are used.In the following table, we will see the Mnemonics, Lengths, Execution Time in terms of the machine cycle, Number of Opcodes etc.MnemonicsByte CountExecutionTimeOpcode CountACALL addr11228LCALL addr16321RET121RETI121AJMP addr11228LJMP addr16321SJMP rel221JMP @A+DPTR121JZ rel221JNZ rel221CJNE A, a8, rel321CJNE A, #d8, rel321CJNE Rn, #d8, rel328CJNE @Ri, #d8, rel322DJNE Rn, rel228DJNZ a8, rel321NOP111ExamplesSr.NoInstruction & Description1LJMP LABELThis is an example of LJMP addr16. ... Read More

Bit-processing group in 8051

Chandu yadav
Updated on 27-Jun-2020 13:04:59

3K+ Views

In 8051 Microcontroller there is 17 different instructions under the Logical Group. In total there are 17 opcodes. The Carry Flag (CY) acts like the single-bit accumulator in different bit processing instructions.In the following table, we will see the Mnemonics, Lengths, Execution Time in terms of the machine cycle, Number of Opcodes etc.MnemonicsByte CountExecution TimeOpcode CountCLR C111CLR bit211SETB C111SETB bit211CPL C111CPL bit211ANL C, bit221ANL C, /bit221ORL C, bit221ORL C, /bit221MOV C, bit211MOV bit, C221JC rel221JNC rel221JB bit, rel321JNB bit, rel321JBC bit, rel321ExamplesSr.No Instruction & Description1CLR CThis instruction is used to clear the carry flag to 0.2SETB 0D5HThis instruction of type SETB ... Read More

Logical Group in 8051

George John
Updated on 27-Jun-2020 13:06:59

5K+ Views

In 8051 Microcontroller there is 25 different instructions under the Logical Group. In total there are 49 opcodes. The Carry Flag (CY) affects only by instruction RRC and RLC.In the following table, we will see the Mnemonics, Lengths, Execution Time in terms of the machine cycle, Number of Opcodes etc.MnemonicsByte CountExecutionTimeOpcode CountANL A, Rn118ANL A, a8211ANL A, @Ri112ANL A, #d8211ANL a8, A211ANL a8, #d8321ORL A, Rn118ORL A, a8211ORL A, @Ri112ORL A, #d8211ORL a8, A211ORL a8, #d8321XRL A, Rn118XRL A, a8211XRL A, @Ri112XRL A, #d8211XRL a8, A211XRL a8, #d8321CLR A111CPL A111RL A111RLC A111RR A111RRC A111SWAP A111ExamplesSr.NoInstruction & Description1ANL A, R5This is ... Read More

Advertisements