Microprocessor Articles - Page 40 of 52

Binary to BCD conversion in 8051

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

4K+ 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

428 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

5K+ 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

4K+ 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

7K+ 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

Arithmetic group in 8051

Ankith Reddy
Updated on 27-Jun-2020 13:07:25

13K+ Views

In 8051 Microcontroller there are 24 different instructions under the Arithmetic Group. In total there are 64 opcodes. The Carry Flag (CY), Auxiliary Carry (AC)and Overflow flag (OV) are affected based on the result of ADD, ADDC, SUBB  etc. instructions. The multiple and divide instructions clear the Carry flag, and also does not affect the AC flag. After execution of multiplication, the OV flag will be 1 when the result is greater than FFH. Otherwise, it is 0. Similarly, after division OV flag is 1 when the content of B is 00H before division, otherwise it is 0. The DA ... Read More

Data transfer group in 8051

Arjun Thakur
Updated on 27-Jun-2020 13:08:12

14K+ Views

In 8051 Microcontroller there is 28 different instructions under the Data Transfer Group. In total there are 79 opcodes. The flags are not affected by using the data transfer instructions, but the P (Parity) flag may change if the value of A register is changed using Data Transfer Instruction. Similarly, when a data is transferred to the PSW register, the flags will change.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 CountMOV A, Rn118MOV A, a8211MOV A, @Ri112MOV A, #d8211MOV Rn, A118MOV Rn, a8228MOV Rn, ... Read More

Instruction set of 8051

Chandu yadav
Updated on 27-Jun-2020 13:10:26

27K+ Views

The instructions of 8051 Microcontroller can be classified into five different groups. These groups are like belowData Transfer GroupArithmetic GroupLogical GroupProgram Branch GroupBit Processing GroupThis Bit-Processing group is also known as Boolean Variable Manipulation.Like 8085, some instruction has two operands. The first operand is the Destination, and the second operator is Source.In the following examples, you will get some notations. The notations are like −Rn = Any register from R0to R7 Ri = Either R0 or R1 d8 = Any 8-bit immediate data (00H to FFH) d16 = 16-bit immediate data a8 = 8-bit address bit = 8-bit address of ... Read More

Addressing modes of 8051

George John
Updated on 31-Oct-2023 04:34:24

202K+ Views

In this section, we will see different addressing modes of the 8051 microcontrollers. In 8051 there are 1-byte, 2-byte instructions and very few 3-byte instructions are present. The opcodes are 8-bit long. As the opcodes are 8-bit data, there are 256 possibilities. Among 256, 255 opcodes are implemented.The clock frequency is12MHz, so 64 instruction types are executed in just 1 µs, and rest are just 2 µs. The Multiplication and Division operations take 4 µsto to execute.In 8051 There are six types of addressing modes. Immediate AddressingModeRegister AddressingModeDirect AddressingModeRegister IndirectAddressing ModeIndexed AddressingModeImplied AddressingModeImmediate addressing modeIn this Immediate Addressing Mode, the data ... Read More

Programmer's view of 8051

Ankith Reddy
Updated on 27-Jun-2020 13:11:32

3K+ Views

Now let us see the internal registers, memory and other details from the Programmer’s point of view.There are these componentsEight registers(8-bit) R0 to R7Register A and B.These are also 8-bit registersPSW, Stack Pointer(SP), four ports (P0 to P3). These are also 8-bitDPTR register of 16-bit. This is divided into two 8-bit registers, these are DPH and DPLData RAM from location 08H to 7FHProgram memory from location 0000H to FFFFHProgram Counter (PC) of 16-bit

Advertisements