Design an 8051 system where a button is connected to P00 eig
Design an 8051 system where a button is connected to P0.0, eight switches connected to P1, and four 7SEG-BCD displays connected to P2 (lower part) and P3 (higher part). Your system should start with value 0000 displayed on the displays. Whenever the user presses the button, your system adds the value given on P1 (in Packed BCD format) to the displayed value and the new result is displayed. Your button should give ZERO when not pressed and ONE when pressed.
Solution
ORG 000H ///// starting of address
START: MOV A,#00001001B ///// base of accumulator
MOV B,A
MOV R1,#0AH ///// R1 initialized as counter
LABEL: MOV A,B
INC A
MOV B,A
MOVC A,@A+PC ////add the byte in A to the program counters address and move the @A+PC value into A
MOV P1,A
ACALL DELAY ///// call the delay function
DEC R1 ////// R1 is decremented
MOV A,R1 /////register R1 moved to Accumulator
JZ START ////Check A for zero and jumps to START
SJMP LABEL
///// initialization of digit drive pattern
DB 3FH
DB 06H
DB 5BH
DB 4FH
DB 66H
DB 6DH
DB 7DH
DB 07H
DB 7FH
DB 6FH
DELAY: MOV R5,#05H
WAIT2: MOV R4,#00H
WAIT3: MOV R3,#00H
WAIT4: DJNZ R3,WAIT4
DJNZ R4,WAIT3
DJNZ R5,WAIT2
RET
END ////end of the program
