Searching \ for 'Programming Questions..' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devprogs.htm?key=programming
Search entire site for: 'Programming Questions..'.

Truncated match.
PICList Thread
'Programming Questions..'
1997\05\16@080410 by Nishant Deshpande

flavicon
picon face
hi all,

a couple of quick questions...

1> when i use 'retlw TRUE/FALSE'- how does one commonly check
       what happened after the return? do you check the LSB of W
       i.e. btfss      W,0

       i've been doing this but feeling a bit doubtful- esp as
       the parallax simulator shows values such as 91h etc.. in
       W after the return- i'd expect 00h or 01h



2> using CBLOCK -

i define my registers using CBLOCK in bank0- but now i have
a 40 byte buffer i want to use- this i define in BANK1 (as it's
not 'like' the other registers...

now i'm getting into a mess trying to keep track of where i put
which CBLOCK- i.e. either i have to define the CBLOCK in bank1
last, or i have to give an address to the next CBLOCK- which i
don't want to calculate...

what's usually done in these cases?

thanks

nishant

1997\05\16@091708 by Andy Kunz

flavicon
face
At 12:51 PM 5/16/97 +0100, you wrote:
>hi all,
>
>a couple of quick questions...
>
>1> when i use 'retlw TRUE/FALSE'- how does one commonly check
>        what happened after the return? do you check the LSB of W
>        i.e. btfss      W,0

Does that even assemble?

I use
       call    routine
       xorlw   FALSE
       btfss   Z
       goto    WasTrue
WasFalse
       ...

WasTrue
       ...

routine
       ...
       retlw   FALSE
       ...
       retlw   TRUE

Another way I've done it is to have:

FLAGS   ds      1
RETFLG  equ     FLAGS.0

       call    routine
       btfsc   RETFLG
       goto    WasTrue
WasFalse
       ...

WasTrue
       ...

routine
       bcf     RETFLG          ; Default to FALSE
       ...
       ...
       return                  ; No change if false return needed
       ...
       bsf     RETFLG          ; Flag TRUE state
       return

This costs a little, but makes coding simpler sometimes.  Multiple routines
can use RETFLG, just so long as you keep track of who owns it at any
particular time.


> now i'm getting into a mess trying to keep track of where i put
> which CBLOCK- i.e. either i have to define the CBLOCK in bank1
> last, or i have to give an address to the next CBLOCK- which i
> don't want to calculate...
>
> what's usually done in these cases?

I would use a different assembler, that doesn't support CBLOCKs.

Andy

==================================================================
Andy Kunz - Montana Design - 409 S 6th St - Phillipsburg, NJ 08865
         Hardware & Software for Industry & R/C Hobbies
       "Go fast, turn right, and keep the wet side down!"
==================================================================

1997\05\16@093556 by myke predko

flavicon
face
nishant asked:
>1> when i use 'retlw TRUE/FALSE'- how does one commonly check
>        what happened after the return? do you check the LSB of W
>        i.e. btfss      W,0
>
>        i've been doing this but feeling a bit doubtful- esp as
>        the parallax simulator shows values such as 91h etc.. in
>        W after the return- i'd expect 00h or 01h

"W" in MPASM is defined as "0".  So, this instruction works out to:

 btfss  0, 0                   ;  Check Bit Zero of Register 0

And, "0" in the register set is actually, "INDF", so the instruction
actually is:

 btfss  INDF, 0

Which is checking Bit 0 of the Register pointed to by FSR (which isn't what
you want to do at all).

For your true/false, why don't you define them as 1/0, respectively?  That
way, you can use:

 iorlw  0
 btfss  STATUS, Z

which is equivalent to what I think you want to do with "btfss W, 0".

Another way of doing this is to use a bit flag somewhere.  This can be in a
register somewhere or use the carry flag of the STATUS register which is
only updated be addition/subtraction/rotate instructions.

{Quote hidden}

When you say "buffer", what exactly do you mean by it?  If it's any array,
stack or something similar, I define it exactly the same way, and use "FSR"
to access it.

What I try to do is put directly accessible variables in Bank 0 and buffers
(which tend to be indirectly accessed) into Bank 1.


Good Luck,

myke

"My ancestors didn't spend millions of years clawing their way to the top of
the food chain, just so I could become a vegetarian"

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...