So hello:3
I have already tried many things, and looked at many things, but I can't implement any way to read a value from my data table character by character
here code:
I have already tried many things, and looked at many things, but I can't implement any way to read a value from my data table character by character
here code:
error:
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 is error, i cant understand how to get char from A(rn A = '....!' where "!" have to be end and i go to next char)
; R4, A = "--.-!"
; Somehow load to A a first char and so on
mov A, #R2
inc R2 ; "wich char morse ++"
; cjne work with this
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
Table:
Text: db 'Hello world!'
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 |