-
code
Hello to everybody,
I hope someone could help me in my school problem.
I am using development board EASY 8051A.
My task is to write a code in assembler.
" Find a word from the list and send to serial port"
Can somebody help me with a code or when can I find similar code.
Many thanks.
ciao ciao
-
Re: code
Did your course not give you the tools you need to complete this? Surely they taught you how to search strings and such.. ?
chem
-
Re: code
No tools, just to write a code in assembler.
Create a list of words (just few words, 3 or 4 words).
Compare a word that you type against that list.
If the word matches send the output to serial port.
If thewrd not match send 00 to serial port.
I will appreciate your help and thank you in advance.
cheers
Tonny
-
Re: code
How much instruction have you had in writing assembly code? How much code have you written?
Finding the word is fairly simple - point a register to the start of the list. Compare the first letter of the word in the buffer (where you put the word that was typed) with the letter at the pointer. If they match, increment both by 1 and check the next letter. Loop until the end of the word.
If they don't match, move the pointer to the start of the next word in the list, move the buffer pointer to the beginning of the buffer, and do it again.
If you end up with no match, send 00. If you end with a match, send the buffer.
It's been a long time, so I don't even recall if the 8051 has an internal serial port or bit banger, or if you're talking to something on the board, so I can't help you too much with the serial output part, except to say that you just send one letter after another to the port until you reach the end of the word.
-
Re: code
Hello there,
This is the code (below) that I did but itworks only with characters.
I needd to create a list of words (just few words).
Compare a word that you type against that list.
If the word matches send the output to serial port.
If thewrd not match send 00 to serial port.
I can not mke to crete this code.
ORG 0000H
LJMP MAIN
ORG 0023H
LJMP KERKO
ORG 0030H
;;;;;;;;;;;;;;;;;
MAIN:
;;;;;;;;;;;;;;;;;
MOV R0,#20H ;ADDRESS OF WRITE POINTER IN BUFER_C
MOV R1,#20H ;ADDRESS OF READ POINTER IN BUFER_C
MOV R4,#00H ;CHARACTER NUMERAITOR IN BUFER_C
LCALL SERIAL_INIT
PRITJE: LJMP PRITJE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;
SERIAL_INIT:
;;;;;;;;;;;;;;;;
MOV A,PCON
SETB ACC.7
MOV PCON,A ;SMOD=1
MOV SCON,#52H ;ENABLE TI, MODE 1
MOV TMOD,#20H ;TIMER 1, MODE 2, 8-BIT AUTO RELOAD MODE
MOV TH1,#-35 ;1200 BPS AUTO RELOAD VALUE
SETB EA ;GLOBAL INTERRUPT ENABLE
SETB ES ;SERIAL INTERRUPT ENABLE
SETB PS ;HIGH PRIORITY FOR SERIAL INTERRUPTS
SETB TR1 ;START TIMER
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;TRANSMETIMI I NJE KARAKTERI NE BAFER (SERIAL PORT)
;;;;;;;;;;;;;;;;
OUTCHAR:
;;;;;;;;;;;;;;;;
JNB TI,$
CLR TI
MOV SBUF,A
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;READ FROM SERIAL PORT
;;;;;;;;;;;;;;;;
KERKO:
;;;;;;;;;;;;;;;;
JNB RI,DALJA
CLR RI
MOV B,SBUF
MOV DPTR,#LISTA
MOV R0,#00H
MOV A,'W'
RPT: CJNE A,#00H,VAZHDO
MOV DPTR,#MESAZHI2
LCALL MESAZHI
DALJA: RETI
VAZHDO: MOV A,R0
MOVC A,@A+DPTR
CJNE A,B,VAZHDO1
MOV DPTR,#MESAZHI1
LCALL MESAZHI
MOV A,B
LCALL OUTCHAR
LJMP DALJA
VAZHDO1:INC R0
LJMP RPT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;
MESAZHI:
;;;;;;;;;
MOV A,#0AH
LCALL OUTCHAR
MOV A,#0DH
LCALL OUTCHAR
MOV R1,#00H
RPT1: CJNE A,#00H,VAZHD2
RET
VAZHD2: MOV A,R1
MOVC A,@A+DPTR
LCALL OUTCHAR
INC R1
LJMP RPT1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LISTA: DB 'A','B','C','D','E','F','G','H','I',00H
MESAZHI1: DB ' CHARACTER IS FOUND : ',00H
MESAZHI2: DB ' THIS CHARACTER DOESN'T EXIST ',00H
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
END
Many thanks for help
cheers
Tonny