Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

calculator

Status
Not open for further replies.

chinmay7

New Member
hi
i am doing project on microcontroller in which i have to make a 89C51 based BCD calculator with LCD and keypad...the problem is that the program which i have has lots of errors....can u plz suggest me a program for my project
 
Last edited:
this is the prog that i have got...the delay1 routine is missin...can someone suggest me how to modify the program..

kcode0 equ 300h
kcode1 equ 305h
kcode2 equ 30ah
kcode3 equ 30fh
ORG 0000h
rs bit p0.0
rw bit p0.0
en bit p0.2

acall load
;num1 display
mov a,#’n’
acall display
mov a,#'u'
acall display
mov a,#'m'
acall display
mov a,#'1'
acall display
mov a,#':'
acall display
mov a,#06h
acall command
jmp disp1
command:acall delay
mov P3,a
clr p0.0
clr p0.1
setb P0.2
clr P0.2
ret
ready:clr P0.2
mov P3,#00fh
clr P0.2
setb P0.1
acall delay
wait:clr P0.2
setb P0.2
jb P3.7,wait
clr P0.2
ret
display:acall ready
mov P3,a
setb P0.0
clr P0.1
setb P0.2
clr P0.2
ret
load:mov a,#38h
acall command
mov a,#0eh
acall command
mov a,#01h
acall command
mov a,06h
acall command
ret
delay:MOV R3,#50h
HERE2:MOV R4,#255h
HERE:DJNZ R4,HERE
DJNZ R3,HERE2
RET

;display num1:--
disp:acall keyscan
mov b,a
add a,#30h
acall display
mov a,b
add a ,#00h
da a

proceed:aca;; keyscan
cjne a,#35h,proceed

;display op:--
acall delay
acall load
mov a,#'o'
acall display
mov a,#'p'
acall display
mov a,#':'
acall display
mov a,#06h
acall command
;display operand
acall keyscan
mov r0,a
acall display
proceed1:acall keyscan
cjne a,#35h,proceed1

;display num2:
acall delay
acall load
mov a,#'n'
acall display
mov a,#'u'
acall display
mov a,#'m'
acall display
mov a,#'2'
acall display
mov a,#':'
acall display
mov a,#06h
acall command
;display second operand
acall keyscan
mov r1,a
add a,#30h
acall display
proceed2:acall keyscan
cjne a,#35h,proceed2

mov a,r1
add a,#00h
da a
;result:
acall delay
acall load
mov a,#'r'
acall display
mov a,#'e'
acall display
mov a,#'s'
acall display
mov a,#':'
acall display
mov a,#06h
acall command
;arithematic
cjne r0,#2bh,subt
mov a,r1
add a,b
da a
acall load
jmp last
bcd:
mov r6,a
anl a,#0f0h
swap a
add a,#30h
mov r7,a
mov a,r6
anl a,#0fh
add a,#30h
mov r6,a
mov a,r7
acall display
mov a,r6
acall display

proceed3:acall keyscan
cjne a,#35h,proceed3

ret

subt:cjne r0,#2dh,mult
mov a,b
clr psw.7
subb a,r1
jnc continue
mov a,r1
clr psw.7
subb a,b
mov b,a
mov a,#2dh
acall display
mov a,b
;acall bcd
;jmp last
continue:acall bcd
jmp last
mult:cjne r0,#2ah,divi
check:mov a,b
cjne a,#00h,ahead
mov a,#00h
acall bcd
jmp last
ahead:cjne r1,#00h,ahead1
mov a,#00h
acall bcd
jmp last
ahead1:mov a,r1
dec b
mov r2,b
cjne r2,#00h,loop2
mov a,r1
acall bcd
loop2:add a,r1
da a
djnz b,loop2

acall bcd
jmp last
divi:cjne r0,#2fh,range
cjne r1,#00h,check2
mov a,#'i'
acall display
mov a,#'n'
acall display
mov a,#'f'
acall display
mov a,#06h
acall command
proceed7:acall keyscan
cjne a,#35h,proceed7
jmp last
range:jmp last
check2:mov a,b
cjne a,#00h,check3
acall bcd
jmp last
check3:mov a,b
clr psw.7
subb a,r1
jnc goahead
mov a,#'e'
acall display
proceed6:acall keyscan
cjne a,#35h,proceed6
jmp last
goahead:mov a,b
mov b,r1
inc r1
mov r5,#00h
loop3:inc r5
clr psw.7
mov r6,a
subb a,b

jnc loop3
dec r5

mov a,#'q'
acall display
mov a,#':'
acall display
mov a,r5
add a,#30h
acall display
mov a,#00h
acall display
mov a,#'r'
acall display
mov a,#':'
acall display
mov a,r6
add a,#30h
acall display
proceed4:acall keyscan
cjne a,#35h,proceed4
jmp last
keyscan:
mov P2,#00ffh
K1:mov P1,#0000h
mov a,P2
anl a,00001111b
cjne a,#00001111b,K2
jmp K1
K2:acall delay1
mov a,P2
anl a,#00001111b
cjne a,#00001111b,over
sjmp K2
over:acall delay1
mov a,P2
org kcode0
db 00h
db 01h
db 02h
db 2bh
org kcode1
db 03h
db 04h
db 05h
db 2dh
org kcode2
db 06h
db 07h
db 08h
db 2ah
org kcode3
db 35h
db 09h
db 35h
db 2fh
last:
END
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top