I have a one problem, I don't know how to get step by step index from db:C here is my code:
Morse:
mov DPTR, #Text ; Point to the beginning of the text
mov A, R0 ;offset to acc
NextChar:
movc A, @A+DPTR ; Load a character from the text into register A
cjne A, #2Eh, EndProgram ;check for dot
cjne A, #20h, WordSpace ;check for space
cjne A, #00h, CharLoop ; Check if the character is not null (end of text)
jmp EndProgram ; Otherwise, move to the next character in the text !!!!!!!!HOW TO CHECK IF IT NULL!!!!!!!!!!!
CharLoop:
orl A, #20h
clr C ;clear C flag after orl
subb A, #61h
mov DPTR, #ASCII_TO_MORSE_TABLE
movc A, @A+DPTR
;mov R4, A ; R4 = Code MORSE
inc R0; ; counter chars at Text
mov R2, #00h ; counter dot\dash in char
jmp DotORDash
DotORDash:
; here at A,B,R4 I have for example "--.-!"
; How here load to A just first char from, A,B,R4?
movc A, @A+DPTR
inc R2 ; "which char morse ++"
cjne A, #21h, Morse; if r4 == "!" jmp Morse
cjne A, #2Dh, DASH; if r4 == "-" call DASH
cjne A, #2Eh, DOT; if r4 == "." call DOT
jmp Morse
ASCII_TO_MORSE_TABLE:db '.-!', '-...!', '-.-.!', '-..!', '.!', '..-.!', '--.!', '....!', '..!', '.---!', '-.-!', '.-..!', '--!', '-.!', '---!', '.--.!', '--.-!', '.-.!', '...!', '-!', '..-!', '...-!', '.--!', '-..-!', '-.--!', '--..!', '-----!', '.----!', '..---!', '...--!', '....-!', '.....!', '-....!', '--...!', '---..!', ' ----.!'
; | a | | b | | c | | d | |e| | f | | g | | h | | i | | j | | k | | l | | m | | n | | o | | p | | q | | r | | s | | t | | u | | v | | w | | x | | y | | z | | 0 | | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 |
So the main problem for me its how at DotORDash get step by step chars, for example I have at B,A,R4 this value: '.-!', how I can at DotORDash get step by step these values?
The code is written on the fly, it has not been compiled, its task is to show the algorithm for finding the beginning of the morse code for any alpha character.
First of all, you need to understand how the
cjneinstruction works. Subsequently, it is necessary to realize that this is not about any database manipulations (please remove thedatabaseandindexingtags), but about linear searching of text strings with using a pointer.The rest should be clear from the source text itself.