# Need help in making my own little experiment in EdSim51

#### p3nny

Joined Jul 22, 2022
1
Hi! I am currently in college and taking up a course which requires us to use EdSim51 Simulator and we were tasked to think of our own experiment.
So what I thought of was a Binary Indentifier
How does it work?
Basically all there is to it is when you press a key in the keypad, it will reflect on the SSD, then the 8bit binary of the decimal value that the user pressed on the keypad would appear at the LCD and the LED would also show the 8bit binary value but in the means of light.
Where am I?
I am now at the part where the key I pressed on the keypad is reflecting in the SSD, I am now stuck because on certain numbers such as 8 and 5, the LCD shows the message "Error! Function set not called." I want to get rid of that (if possible) and input in the LCD.

Here is my code so far:
Code:
ORG 0000H
MAIN:

CLR P0.3
CALL ONETWOTHREE
JB F0, DONE

CLR P0.2
CALL FOURFIVESIX
JB F0, DONE

CLR P0.1
CALL SEVENEIGHTNINE
JB F0, DONE

CLR P0.0
CALL ZERO
JB F0, DONE

JMP MAIN

DONE:

JMP \$

ZERO:

JNB P0.5, KEYZERO

SEVENEIGHTNINE:

JNB P0.4, KEYNINE
JNB P0.5, KEYEIGHT
JNB P0.6, KEYSEVEN

FOURFIVESIX:

JNB P0.4, KEYSIX
JNB P0.5, KEYFIVE
JNB P0.6, KEYFOUR

ONETWOTHREE:

JNB P0.4, KEYTHREE
JNB P0.5, KEYTWO
JNB P0.6, KEYONE

KEYTHREE:

SETB F0
MOV R7, #10110000B
MOV P1, R7
RET

KEYTWO:

SETB F0
MOV R7, #10100100B
MOV P1, R7
RET

KEYONE:

SETB F0
MOV R7, #11111001B
MOV P1, R7
RET

KEYSIX:

SETB F0
MOV R7, #10000011B
MOV P1, R7
RET

KEYFIVE:

SETB F0
MOV R7, #10010010B
MOV P1, R7
RET

KEYFOUR:

SETB F0
MOV R7, #10011001B
MOV P1, R7
RET

KEYNINE:

SETB F0
MOV R7, #10011000B
MOV P1, R7
RET

KEYEIGHT:

SETB F0
MOV R7, #10000000B
MOV P1, R7
RET

KEYSEVEN:

SETB F0
MOV R7, #11111000B
MOV P1, R7
RET

KEYZERO:

SETB F0
MOV R7, #111000000B
MOV P1, R7
RET

END

#### MrChips

Joined Oct 2, 2009
26,790
Welcome to AAC!

Before you start writing code you should always draw a flowchart.
It will make coding at lot easier.

#### MrChips

Joined Oct 2, 2009
26,790
If you examine your subsections they all do the same thing except for one parameter. Think code efficiency. How can you combine them all into one subroutine?

#### MrChips

Joined Oct 2, 2009
26,790
A basic program flow would begin like this:

As with most embedded systems, the program never ends. Thus we would modify the program flow to this: