Pages

Thursday, April 7, 2011

UMPS: 7 segmen display - countdown

; sample program using UMPS assembler
; count down on 7 - segments display
; type: command cathode

; start
org 00h

mov dptr,#data
again: movc a,@a+dptr ; assume value a=00, concanate
jz stop
mov p1,a
inc dptr
clr a
acall delay
sjmp again

stop: sjmp stop


; look up table
; db-define byte (assembler instruction)
data: db 0efh, 0ffh, 87h, 0fdh, 0edh, 0e6h, 0cfh, 0dbh, 086h, 0bfh, 00


delay: mov r2,#2

count: mov r1,#0ffh ; maximum value into r0 register (8 bits)

rcoun: mov r0,#0ffh

; use delay to make it visible on target hardware.
; if run it on simulator, it'll take longer time

repeat: djnz r0, repeat ; compare for 255 times
djnz r1, rcoun ; to add more times loop
djnz r2, count

ret

end

No comments:

Post a Comment