[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting 6502 Asm to PIC



On Nov 25, 1:49 pm, Jerry <awande...@yahoo.ca> wrote:
> PIC Newbie <allenbsf6...@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- Hide quoted text -
>
> - Show quoted text -

Hi Jerry,

The program that you wrote is exactly what I wanted.  I hate the PIC
Mnemonics.  It was so hard to use and unfriendly.  If only 6502 has a
PIC-like microcontroller with a 6502 engine, I would not have use the
PIC.

It seems your PIC knowledge is not rusty at all.  Do assembler
programmers treat all the CPU the same, ie someone who started with
6502 can easily learn 8086 or Z800 or 68030 in a short time?

I do most of my 6502 on Applewin and the micro KIM from Briel and the
65c02 SBC-2 from Daryl.  If I save enough money I'll get the SBC-3 to
learn 65816 and Apple I from Briel.  The Apple IIe and IIgs I got from
eBay were all upstairs in my store-room.

Thanks again Jerry for your help,

Allen