Saturday, April 30, 2016

8051 Program – bcd up counter 8bit

; bcd up counter 8bit
; counts from 0 to 99
ORG 0H
MAIN:
LCALL COUNT
SJMP MAIN
COUNT:
MOV A,#0H ;move 0 to a
up: MOV P0,A ;move data from a to port0
ACALL delay ;call delay routine
INC A ;increment a
DA A ;decimal adjust accumulator after addition
CJNE A,#100,up ;compare a with 100, if not equal, jump to location up
RET
;delay routine
delay:
MOV R1,#0FFH ;move 0ffh to r1
l3: MOV R2,#0FFH ;move 0ffh to r2
l2: MOV R3,#0FFH ;move 0ffh to r3
l1: DJNZ R1,l1 ;decrement r1, repeat till r1=0
DJNZ R3,l2 ;decrement r3,repeat l2 till r3=0
DJNZ R2,l3 ;decrement r2, repeat l3 till r2=0
RET
END



Related topics:
8051 Program - up counter 8bit   |   8051 Program - down counter 8bit   |   8051 Program - bcd down counter 8bit   |   8051 Program - bcd up and down counters   |   8051 Program - hex up and down counters   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

2 comments: