[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Converting 6502 Asm to PIC
PIC Newbie <allenbsf6502@gmail.com> writes:
> Hi,
>
> I have written a small 6502 program to buzz the piezo with morse code
> message. I wish to make it onto a small PCB with a 12F629 mounted.
> It will be finally be fitted onto the back of my bicycle. But
> translating the 6502 to PIC asm, I was stuck on the first beginning
> of the program. I am sure there are some here who played with the
> PIC
> that might help. The code is as follows:
>
> ORG $800
>
> ;I am using LISA 2.5 by Randy Hyde
>
> JMP main
> MESSAGE STR 'APPLE 2 FOREVER'
>
> ;STR will generate the message in normal ASC with the number of
> ;characters as the first byte
>
> MAIN LDX #1 ;POINT TO FIRST ASC
> MESSLOOP:
> LDA MESSAGE,X
> CMP $32
> BNE CONV
> SPACE JSR INT_WORD_DLY ;DELAY 6 DOT ELEMENTS ~500MS
> CLC
> BCC SPACE_OK
> CONV JSR CONVERT ;CONVERT ALPHA-NUMERIC TO INDEX
> SPACE_OK:
> INX
> CPX #MESSAGE+1 ;END OF MESSAGE?
> BCC MESSLOOP
> RTS
>
> TIA,
>
> Allen
My PIC knowledge is rusty... does this help?
The PIC doesn't allow reading from the program flash, IIRC, so try this:
PCL = 2 ; register: program counter low
index = 32 ; RAM: character index
char = 33 ; RAM: current character code
clrf index ; starting index
messLoop:
call getChar ; get character from string
movwf char ; save character for output
xorlw ' ' ; is it a space?
btfsc STATUS,Z ; skip next instr if not
goto delay
call convert
next:
incf index
movlw lastChar-firstChar
subwf index,0
btfss STATUS,Z
goto messLoop
sleep ; or whatever you do when done.
delay:
call int_word_dly
goto next
getChar:
movf index,0 ; add index to PCL
addwf PCL ; indexed GOTO one of the next instrs
firstChar:
retlw 'A'
retlw 'P'
retlw 'P'
retlw 'L'
retlw 'E'
retlw ' '
retlw '2'
retlw ' '
retlw 'F'
retlw 'O'
retlw 'R'
retlw 'E'
retlw 'V'
retlw 'E'
retlw 'R'
lastChar:
retlw 0
nextChar:
convert: ; to be implemented...
int_word_dly:
; to be implemented
--
Jerry awanderin at yahoo dot ca