8051 microcontroller programming:Tutorial-Generating sequences-(0*1,1*2,2*3,......(n-1)*n)

Generating a particular is some of the common needs for a programmer.
Let us see how a sequence can be generated.
Consider the sequence-0*1,1*2,2*3,3*4,..................,(n-1)*n, where is the input.
PROGRAM:
  ORG 00H
  MOV DPTR,#2000H
  MOVX A,@DPTR
  MOV R0,A 
  MOV A,#00H
  MOV R1,A
LOOP: MOV A,R1
  MOV B,A
  INC A
  MOV R1,A
  MUL AB
  INC DPTR
  MOVX @DPTR,A
  DJNZ R0,LOOP
  END

Comments

Post a Comment

Popular posts from this blog

8051 microcontroller programming:Tutorial-Fibonacci series in assembly with Keil

8051 microcontroller programming: Interfacing with push button and displaying the button pressed using Keil