welove8051
Full Member level 6
change movc with mov. other changes you can easily do by yourself
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Org 00H
data_one equ P3
data_ten equ P2
IPIN EQU P1.0
DPIN EQU P1.1
Mynumber Equ 30H
main_prog:
CALL INIT
AGAIN:
AG2: JB IPIN,AG1
CALL DELAY1 ;debounce
JB IPIN,AG1
JNB IPIN,$ ;wait till switch release
INC MYNUMBER
mov a,mynumber
cjne a,#100,pq1
mov mynumber,#0
pq1:
call bcd ;diaplay data
AG1: JB DPIN,AG2
CALL DELAY1
JB DPIN,AG2
JNB DPIN,$
clr mynumber
mov a,#0C0H
cjne a,#0C0H,pq2
mov mynumber,#00
pq2:
call bcd
JMP AGAIN
INIT:
MOV data_ten,#0C0H
MOV data_one,#0c0H
mov Mynumber,#0
mov p1,#255 ;set port 1 as input BY . IT SHOULD BE 1
RET
DELAY1: MOV R4,#255
DJNZ R4,$
RET
BCD: Mov A,Mynumber
Mov B,#10
Div AB
mov dptr,#seg_conv
MOVC A,@A+DPTR ; MOVE DATA @A+DPTR IN A
mov data_ten, A
mov A,B
mov dptr,#seg_conv
MOVC A,@A+DPTR ; MOVE DATA @A+DPTR IN A
mov data_one, A
Ret
delay: MOV R5,#0ffh
MOV R6,#0ffH
MOV R7,#2
delay_loop: DJNZ R5,delay_loop
DJNZ R6,delay_loop
DJNZ R7,delay_loop
RET
Seg_conv:
DB 0C0H ; 0
DB 0F9H ; 1
DB 0A4H ; 2
DB 0B0H ; 3
DB 099H ; 4
DB 092H ; 5
DB 082H ; 6
DB 0F8H ; 7
DB 080H ; 8
DB 090H ; 9
END