Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Calling a TABLE by using Indirect Addressing

Status
Not open for further replies.

Suraj143

Active Member
Hi I want to call a TABLE by using indirect addressing. Now I’m doing like this.

Code:
	movlw 	01h
	movwf	11h	;GP register
	movlw	02h
	movwf	12h	;GP register

So if there is more registers I want to write more.

I can clear the GP registers using indirect addressing like below.

Code:
	movlw	11h
	movwf	FSR
	clrf	INDF
	incf	FSR,f
	btfss	FSR,7
	goto	$-3
	goto	NEXT

But how I call a TABLE to move all literal values to appropriate registers? (My literal values are in the table)

Thanks a lot
 
Last edited:
Hi thanks for your reply doesn’t it need a jump value for TABLE?

Another problem if my last GP register is 15h how to detect that.

It means the tables last value must move to this last GP register.
I have only 5 GP registers they are 11h,12h,13h,14h,15h
So after moving last literal value to 15h it must do other work.

How to detect the last 15h register?

Thanks a lot
 
Are you trying to read a table from program memory into RAM?
Code:
 [LEFT] table addwf PC,f
       retlw [data] ;is the normal way to read a table on a 14bit PIC core.[/LEFT]
you call it with

Code:
    call table ;(where W is the pointer to the table)
 
Last edited:
Ok thanks but how I detect the last value has reached that is 15h?

After moving the last literal value in the table to 15h I want to do other work.

So how can I detect the 15h GP register?
 
Is this Correct

Code:
	movlw	11h
	movwf	FSR
LOOP	call    table
	movwf   INDF
	incf	FSR,f
	[B]btfss	FSR,4[/B]
	goto	LOOP
	goto	EXIT
 
If there is below 8 GP registers its ok. If there is 10 registers how can I detect the last GP register?

Btfss FSR,???
 
No, not only 8 general purpose register. Up to 256 general purpose register maximum.
For example, after incf FSR, f
Code:
movf     FSR, w
xorlw     0x1b       ;if you start with 11h and you have 10 GP register,
                         ;the last one will be 1ah
btfss     STATUS, Z
goto      NEXT
goto      exit
 
Wow that’s great man that’s the one I need. So I can put your code into my program.

Thanks a lot

You are excellent
 
So here is the final coding moved table values to GP registers from 11h to 15h.

Code:
	movlw	11h
	movwf	FSR
LOOP	call    table
	movwf   INDF
	incf	FSR,f
	movf    FSR, w
	xorlw   16h     ;test if it is 16h GP register?
	btfss   STATUS, Z
	goto    LOOP
	goto    exit
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top