;Prints the BCD number stored in p2 and p0 in seven
printBCD:
mov a,r6
jz m1
jnz m2
m2:
setb p2.4
mov dptr, #table7seg
mov a,R7
anl a,#0fh
movc a,@a+dptr
mov P0, a
mov a, R7
mov dptr, #table7seg1
swap a
anl a,#0fh
movc a,@a+dptr
mov P2, a
m1:
clr p2.4
mov dptr, #table7seg
mov a,R7
anl a,#0fh
movc a,@a+dptr
mov P0, a
mov a, R7
mov dptr, #table7seg1
swap a
anl a,#0fh
movc a,@a+dptr
mov P2, a
ret
;This table is used to convert a number to its 7-segment representation
;The bits are connected as follow: e,g,f,x,a,b,d,c
table7seg:
db 01010000B ; 0
db 11111010B ; 1
db 00110001B ; 2
db 10110000B ; 3
db 10011010B ; 4
db 10010100B ; 5
db 00010100B ; 6
db 11110010B ; 7
db 00010000B ; 8
db 10010000B ; 9
table7seg1:
db 00010010B ; 0
db 01011111B ; 1
db 10010100B ; 2
db 00010101B ; 3
db 01011001B ; 4
db 00110001B ; 5
db 00110000B ; 6
db 01010111B ; 7
db 00010000B ; 8
db 00010001B ; 9
2007-02-21
12:19:34
·
1 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design