Have a look at my older program on how to find a even number… ORG 000h MOV R0,#0Ah ; you can change this value to N numbers MOV R1,#00h ;operand MOV DPTR,#0Ah ;memory adress loop: INC R1 […]

# 8051

## 8051 code to use R4(LSB) and R5(MSB) as a single 16bit counter, and increment the pair untill number is FFFFh

Logic is too simple. For better understanding, I would suggest you something. Use a scientific calculator and in hex mode go on adding 0x01 each time. And then study my code. You will have a better understanding.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
ORG 000h MOV R4,#00h MOV R5,#00h main: INC R4 CJNE R4,#0FFh,main CJNE R5,#0FFh,end ; Observe this line carefully and think after it INC R5 MOV R4,#00h end: NOP END |

Enjoy coding…..XD

## 8051 code to use R4 (LSB) and R5(MSB) as a single 16-bit counter and decrement the pair until number is 0000h

The logic is easy. Go on decrementing LSB . Let me consider an example. let the number be 0xffff . this means 0xff in both R4 and R5 registers. go on decrementing R4(LSB).once it reaches 0x00,then decrement R5(MSB) which makes it 0xfe in R5. Then reset the value of R4 to 0xff and follow the […]

## 8051 Program to find 10 fibonacci numbers and store it an array.

Program to find 10 fibonacci numbers and store it an array. In this article let’s learn how to find fibonacci numbers and store it in an array. Basically fibonacci number is a series where each term is the sum of previous two numbers. Algorithm: 1)Store the memmory address in R0 and counter in R3. 2)Store […]

## 8051 code to find the number of positive numbers in an array .

I have posted how to find a number is positive or negative before…. Just check it. ORG 000h MOV DPTR,#0Ah ; an external address MOV RO,#0Ah ;array counter MOV R1,#0h […]

## 8051 ALP program to find number of negative numbers in an array

I have posted how to find a number is positive or negative before…. Just check it. ORG 000h MOV DPTR,#0Ah ; an external address MOV RO,#0Ah ;array counter MOV R1,#0h […]

## 8051 code to find a number is even or odd

A negative number has its msb as binary 1 …Hence we rotate the number through carry to the left and then decide upon the status of the carry flag. ORG 000h MOV A,#number ;The number to be checked for positive […]

## Half ascending and half descending code in 8051

8051 code to arrange the given numbers in half ascending and half descending order. In this article let’s see how to arrange a given array in half ascending and half descending. I think it’s weird to hear the word half ascending and half descending but it is interesting as well. Algorithm: 1) Store the length […]

## 8051 ALP code to find the number of odd numbers in an array

I have posted how to find a number is odd or nor before…. Just check it. ORG 000h MOV DPTR,#0Ah ; an external address MOV RO,#0Ah ;array counter MOV R1,#0h […]

## 8051 alp code to find the number of even numbers in an array.

I have posted how to find a number is even or nor before…. Just check it. ORG 000h MOV DPTR,#0Ah ; an external address MOV RO,#0Ah ;array counter MOV R1,#0h […]