Oyvind Kaurstad wrote:
{Quote hidden}>
> > I have a problem that's always the same: I have a pgm in assembler,
> >with several routines that I am calling (PIC16C84). To test my LCD I am
> >sending a small text and I am calling the caracters with retlw.
> >Depending on the position of this routine, I sometimes have nothing on
> >the screen. I never understood "long calls", can somebody explain me
> >what's happening? Thanks
>
> There is no such thing as "long calls" in the '84.
>
> When using the call instruction the entire 13 bit program counter (PC)
> is pushed onto the stack, and since the '84 only has 1 k program
> memory this is sufficient for the program to return correctly.
>
> However, if you're using the retlw instruction and an offset
> to create tables you'll have to be careful when manipulating
> the PC. If your table looks like this...
>
> table
> addwf PCL,1
> retlw '0'
> retlw '1'
> retlw ...
> retlw...
>
> ..then you will get into trouble if the table crosses a 256 byte boundary in
> the
> program memory. For instance, if the addwf instruction is at memory location
> 0x0FF and your offset (in the W register) is 0x01 (ie you want the
> ascii value of 1 returned) what will happen?
>
> The PCL (8 bit) will roll over to 0x00 and the progam will continue executing
> from the beginning again. (If your call to the table originated from
> within the first 256 bytes of the program memory.)
>
> To correct this you'll either have to make sure that your table does not
> cross any boundaries or do an extended computation of the offset including
> the PCLATH...
>
> This is explained in the Microchip application note AN556. Take a look at it.
>
> Hope this helps.
>
> If I've written anything wrong I hope some of the gurus on the list will
> correct me.
>
> And while I'm at it, writing tables using retlw's can be a tedious business,
> especially if the tables grow large.
>
> There is another method, but it looks a bit strange...
>
> I'm using this syntax:
>
> dw "4T4e4s4t"
>
> this is equal to
>
> retlw 'T'
> retlw 'e'
> retlw 's'
> retlw 't'
>
> Is there a better way?
>
> -Xyvind
--
I am using DT "Test", assembling into retlw `T`
retlw 'e' ...
_____________
\ / David BALDWIN
\ ALCATEL / Design engineer
\TELECOM/
\ / SdM (Societe de Microelectronique)
\ /
\ / B.P. 4205 Phone : +32 (0)71 442932
V B-6000 Charleroi Fax : +32 (0)71 442905
(Belgium) spam_OUTbaldwinTakeThisOuT
etca.alcatel.be