1

I built an assembly program using mpasm for the pic 10f322, and I want the program to read off all characters in my TABLE: by placing these values back into my WREG. When my code executes, it is suppose to read off the value stored in register FSR and fetch the value stored at the address pointed to. This FSR value then increments to get the next character. However, when I run the program, the pointer is incrementing correctly but the code is grabbing junk values since there doesn't seem to be any values stored in memory. Why are my directives not working?

            org     0x0000
            FSR     Equ     0x04
            INDF    Equ     0x00
    START
            movlw   TABLE
            movwf   FSR     ; move w value int address FSR
    Loop:   movf    INDF, 0 ; move character pointed in table back to w reg
            incf    FSR     ; increment incfg
            goto    Loop
    TABLE:
            db    "HELLO"
            db    "Man"

    END

I don't want data to be stored in program memory. Instead I would like to put data in data memory. Are there assembly directives that allow me to do this easily like DB? My assembler is MPASM.

4

1 回答 1

3

您不能通过和寄存器访问代码存储器,这两个寄存器旨在访问数据存储器。改用查找表:FSRINDF

        movlw  1                ;Read second byte in Table
        movwf  TableIndex       ;Store index
        call   ReadLookupTable  ;Perform table read
        ...


ReadLookupTable   
        movlw  high Table
        movwf  PCLATH
        movlw  low Table
        addwf  TableIndex, w       ;Add index to table pointer           
        movwf  PCL                 ;Perform computed jmp
Table   
        retlw 10 
        retlw 11
        ...
于 2013-06-08T14:22:28.203 回答