NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

ORG 0
acall CONFIGURE_LCD

KEYBOARD_LOOP:

ACALL GET_INPUT ;Get input from user and put into specific RAM location
ACALL CONTROL ;Using the operator, determine which operation will be applied
sjmp KEYBOARD_LOOP

GET_INPUT:
ACALL KEYBOARD
PUSH ACC ;Save the first input, we will clear screen now
ACALL SET_SCREEN ;Prepare screen
POP ACC ;Get all input, print and save into specific registers
ACALL SEND_DATA
ANL A, #0FH
MOV R0, A
ACALL KEYBOARD
ACALL SEND_DATA
ANL A, #0FH
MOV R1, A
ACALL KEYBOARD
ACALL SEND_DATA
MOV R5, A
ACALL KEYBOARD
ACALL SEND_DATA
ANL A, #0FH
MOV R2, A
ACALL KEYBOARD
ACALL SEND_DATA
ANL A, #0FH
MOV R3, A
ACALL KEYBOARD
ACALL SEND_DATA
mov a, #0C0H ;After all input is done, move to next line
acall SEND_COMMAND
RET

SET_SCREEN:
mov a, #01H ;Clear Screen
acall SEND_COMMAND
mov a, #80H ;Move to first line
acall SEND_COMMAND
RET

CONTROL: ;This controls which arithmetic operation will be done
MOV A, R5 ;Uses arithmetic operator as input
CJNE A, #'+', NOT_SUM
ACALL SUM_PRO ;Summing procedure + Print
SJMP EXIT
NOT_SUM: CJNE A, #'-', NOT_SUB
ACALL SUB_PRO ;Subtracting procedure + Print
SJMP EXIT
NOT_SUB: CJNE A, #'*', NOT_MUL
ACALL MUL_PRO ;Multiply procedure + Print
SJMP EXIT
NOT_MUL: CJNE A, #'/', NOT_DIV
ACALL DIV_PRO ;Division Procedure + Print
SJMP EXIT
NOT_DIV:
ACALL ERR_MSG ;If operator is not recognized, print error message
EXIT: RET

SUM_PRO:
MOV A, R2 ;Convert BCD numbers into binary for simple operation
MOV B, #10
MUL AB
ADD A, R3
MOV R4, A
MOV A, R0
MOV B, #10
MUL AB
ADD A, R1
ADD A, R4 ;Summation Operation
MOV B, #100 ;Convert into ASCII characters and print
DIV AB
ADD A, #30H
ACALL SEND_DATA
MOV A,B
MOV B, #10
DIV AB
ADD A, #30H
ACALL SEND_DATA
MOV A,B
ADD A, #30H
ACALL SEND_DATA
RET
SUB_PRO:
MOV A, R2 ;Convert BCD numbers into binary for simple operation
MOV B, #10
MUL AB
ADD A, R3
MOV R4, A
MOV A, R0
MOV B, #10
MUL AB
ADD A, R1
CLR C
SUBB A, R4 ;Do subtraction
JNC NO_SIGN ;Check if there is a borrow
CPL A ;If there is, convert result into pos. number
INC A
PUSH ACC
MOV A, #'-' ;Print minus sign
ACALL SEND_DATA
POP ACC
NO_SIGN:
MOV B, #10 ;Get decimal digits from binary, then print
DIV AB
ADD A, #30H
ACALL SEND_DATA
MOV A, B
ADD A, #30H
ACALL SEND_DATA
RET
MUL_PRO:
MOV A, R1 ;Do digit multiplications
MOV B, R3
MUL AB
MOV R4,A
MOV A, R0
MOV B, R3
MUL AB
MOV R5,A
MOV A, R1
MOV B, R2
MUL AB
MOV R6, A
MOV A, R0
MOV B, R2
MUL AB
MOV R7, A
MOV A, R4 ;Sum and generate unpacked bcd
MOV B, #10
DIV AB
MOV R3, B
ADD A, R5
ADD A, R6
MOV B, #10
DIV AB
MOV R2, B
ADD A, R7
MOV B, #10
DIV AB
MOV R1, B
ADD A, #30H ;Convert into ascii and print
ACALL SEND_DATA
MOV A, R1
ADD A, #30H
ACALL SEND_DATA
MOV A, R2
ADD A, #30H
ACALL SEND_DATA
MOV A, R3
ADD A, #30H
ACALL SEND_DATA
RET
DIV_PRO:
MOV A, R2 ;Convert BCD Digits into 2 hexadecimal number
MOV B, #10
MUL AB
ADD A, R3
MOV R4, A
MOV A, R0
MOV B, #10
MUL AB
ADD A, R1
MOV B, R4
DIV AB ;Do division operation
PUSH B ;Save reaminder
MOV B, #10 ;Get the first digit of result
DIV AB
ADD A, #30H ;Print first digit
ACALL SEND_DATA
MOV A, B
ADD A, #30H ;Print second digit
ACALL SEND_DATA
MOV A, #'.' ;Print . character
ACALL SEND_DATA
POP B ;Get remainder from stacl
MOV A, B
MOV B, #10 ;Multiplt remainder with 10
MUL AB
MOV B, R4 ;Divide the reminder and print result
DIV AB
ADD A, #30H
ACALL SEND_DATA
RET
ERR_MSG:
MOV A, R5
ACALL SEND_DATA
RET

CONFIGURE_LCD: ;THIS SUBROUTINE SENDS THE INITIALIZATION COMMANDS TO THE LCD
mov a, #38H ;TWO LINES, 5X7 MATRIX
acall SEND_COMMAND
mov a, #0FH ;DISPLAY ON, CURSOR BLINKING
acall SEND_COMMAND
mov a, #06H ;INCREMENT CURSOR (SHIFT CURSOR TO RIGHT)
acall SEND_COMMAND
mov a, #01H ;CLEAR DISPLAY SCREEN
acall SEND_COMMAND
mov a, #80H ;FORCE CURSOR TO BEGINNING OF THE FIRST LINE
acall SEND_COMMAND
ret

SEND_COMMAND:
mov p2, a ;THE COMMAND IS STORED IN A, SEND IT TO LCD
clr p3.5 ;RS=0 BEFORE SENDING COMMAND
clr p3.6 ;R/W=0 TO WRITE
setb p3.7 ;SEND A HIGH TO LOW SIGNAL TO ENABLE PIN
acall DELAY
clr p3.7
ret


SEND_DATA:
mov p2, a ;SEND THE DATA STORED IN A TO LCD
setb p3.5 ;RS=1 BEFORE SENDING DATA
clr p3.6 ;R/W=0 TO WRITE
setb p3.7 ;SEND A HIGH TO LOW SIGNAL TO ENABLE PIN
acall DELAY
clr p3.7
ret

DELAY:
push 0
push 1
mov r0, #50
DELAY_OUTER_LOOP:
mov r1, #250
djnz r1, $
djnz r0, DELAY_OUTER_LOOP
pop 1
pop 0
ret


KEYBOARD: ;takes the key pressed from the keyboard and puts it to A
mov P0, #0ffh ;makes P0 input
K1:
mov P1, #0 ;ground all rows
mov A, P0
anl A, #00001111B
cjne A, #00001111B, K1
K2:
acall DELAY
mov A, P0
anl A, #00001111B
cjne A, #00001111B, KB_OVER
sjmp K2
KB_OVER:
acall DELAY
mov A, P0
anl A, #00001111B
cjne A, #00001111B, KB_OVER1
sjmp K2
KB_OVER1:
mov P1, #11111110B
mov A, P0
anl A, #00001111B
cjne A, #00001111B, ROW_0
mov P1, #11111101B
mov A, P0
anl A, #00001111B
cjne A, #00001111B, ROW_1
mov P1, #11111011B
mov A, P0
anl A, #00001111B
cjne A, #00001111B, ROW_2
mov P1, #11110111B
mov A, P0
anl A, #00001111B
cjne A, #00001111B, ROW_3
ljmp K2

ROW_0:
mov DPTR, #KCODE0
sjmp KB_FIND
ROW_1:
mov DPTR, #KCODE1
sjmp KB_FIND
ROW_2:
mov DPTR, #KCODE2
sjmp KB_FIND
ROW_3:
mov DPTR, #KCODE3
KB_FIND:
rrc A
jnc KB_MATCH
inc DPTR
sjmp KB_FIND
KB_MATCH:
clr A
movc A, @A+DPTR ; get ASCII code from the table
ret

;ASCII look-up table
KCODE0: DB '1', '2', '3', '+'
KCODE1: DB '4', '5', '6', '-'
KCODE2: DB '7', '8', '9', '*'
KCODE3: DB '$', '0', '=', '/'

END


     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.