Searching \ for 'CBLOCK' 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/index.htm?key=cblock
Search entire site for: 'CBLOCK'.

Truncated match.
PICList Thread
'CBLOCK'
1997\03\18@162350 by Nishant Deshpande

flavicon
picon face
hi all,

can anyone tell me about CBLOCK? i've read what little is given
in the Microchip help note..

in one of the app notes there's this piece of code

CBLOCK 0x0C

       <lots of variables>

END



now what does the 0x0C mean? i first thought this is the number of
variables - 0x0C = 12 but there are 13 variables declared in there.

also from the microchip notes it says

"
to allocate RAM starting at location H'30' use an empty CBLOCK

CBLOCK H'30'
END

and then any subsequent CBLOCKS.

"

can anyone clarify?

thanks

nishant

1997\03\18@174254 by Antti Lukats

flavicon
face
At 09:21 PM 18/3/97 +0000, you wrote:
>hi all,
>
>can anyone tell me about CBLOCK? i've read what little is given
>in the Microchip help note..

below - lotsa variables starting at 0x0C

>CBLOCK 0x0C
>
>        <lots of variables>
>
>END

just adjust 'data segment pointer' to 0x30
like "dseg 0x30" for some other assemblers

>CBLOCK H'30'
>END


CBLOCK
myVariable,myVariable_1
ENDC

CBLOCK
myVariable_2
ENDC



will no allocate myVariable at 0x30 as by previous CBLOCK, did
set the pointer to 0x30

myVariable_2 at 0x32 as there were two bytes allocated by prev cblock

and notice CBLOCK..ENDC
not END!!!

antti

-- Silicon Studio Ltd.
-- http://www.sistudio.com

1997\03\18@180154 by Steve Hardy

flavicon
face
> From: Nishant Deshpande <spam_OUTnd4TakeThisOuTspamDOC.IC.AC.UK>
>
> can anyone tell me about CBLOCK? i've read what little is given
> in the Microchip help note..
>
> in one of the app notes there's this piece of code
>
> CBLOCK 0x0C
>
>         <lots of variables>
>
> END

   ^ Note: should be ENDC, not END.

>
>
>
> now what does the 0x0C mean? i first thought this is the number of
> variables - 0x0C = 12 but there are 13 variables declared in there.


The 0x0C is the starting RAM address of the block to be defined.
This is the first general purpose register in, e.g., the 16C84.
Note that CBLOCK is not limited to assigning ascending RAM
locations -- it is really equivalent to the following:

       CBLOCK  n       ; n is any number
       a               ; equivalent to a equ n
       b               ; equivalent to b equ n+1
       c               ; equivalent to c equ n+2
       ...
       z               ; equivalent to z equ n+25
       ENDC

which is a whole lot easier than

a       equ     n
b       equ     n+1

etc.


{Quote hidden}

If you use several CBLOCKs in sequence, then the assembler
'remembers' the last address that was generated by the
previous CBLOCK and continues from there (if you don't
put an explicit starting address on the next CBLOCK).  E.g.
if the above CBLOCK (my example) was followed by

       CBLOCK
       alpha           ; equivalent to n+26
       beta            ; equivalent to n+27
       ENDC

then the first symbol (alpha) is assigned the next number
after the last symbol in the previous CBLOCK.  If there
were no symbols in the previous CBLOCK (as in the Microchip
example) then the symbols will be assigned starting with
the CBLOCK 'starting address' e.g.

       CBLOCK  h'30'
       ENDC

       ... any code except CBLOCK

       CBLOCK
       alpha           ; equivalent to h'30'
       beta            ; equivalent to h'31'
       ENDC

Hope this makes it clearer.

Regards,
SJH
Canberra, Australia

1997\03\18@181846 by Harold Hallikainen

picon face
On Tue, 18 Mar 1997 21:21:08 +0000 Nishant Deshpande <.....nd4KILLspamspam@spam@DOC.IC.AC.UK>
writes:
>hi all,
>
>can anyone tell me about CBLOCK? i've read what little is given
>in the Microchip help note..
>
>in one of the app notes there's this piece of code
>
>CBLOCK 0x0C
>
>        <lots of variables>
>
>END
>
>
>
>now what does the 0x0C mean?


       It's the address to put the first byte of data at.


       Any subsequent cblocks that do not specify an address will use
the next consecutive address.  I use this a LOT to give a sort of
"encapsulation" by placing variables inside the subroutines that use
them.  It's a little like a static local variable, though they CAN be
accessed from outside (they're really global).  I've used this approach
from my early 6800 programming days instead of putting a tone of ram
allocation at the top of the program, then losing track of it.
       In naming variables inside routines, I include a portion of the
name of the routine in the name, hopefully making the name unique.  For
example, temp inside an A/D routine becomes adTemp, which distinguishes
it from pwmTemp.

Harold

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