> From: Nishant Deshpande <spam_OUTnd4TakeThisOuTDOC.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}>
> 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.
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