Maker Pro
Maker Pro

??declare statements in MPLAB

N

Neil W.Fisk

Jan 1, 1970
0
Hello Everyone

Some of the declare statements are unclear in MPLAB, some programmers
from PIClist use them but I'am unsure what they mean.

MPlab doesn't have any this information in the help
section using CBLOCK,and ENDC.
The macros seem straight forward on how their used.
My question is, what is the proper format or layout for this
command statement CBLOCK,and ENDC and how do you know which label is
used in relation to the address location in the code?

Can anyone give an example of this and the relation to
the address location in PIC micro for me?

Thanks
Neil
 
T

Thomas C. Sefranek

Jan 1, 1970
0
Neil W.Fisk said:
Hello Everyone

Some of the declare statements are unclear in MPLAB, some programmers
from PIClist use them but I'am unsure what they mean.

MPlab doesn't have any this information in the help
section using CBLOCK,and ENDC.
The macros seem straight forward on how their used.
My question is, what is the proper format or layout for this
command statement CBLOCK,and ENDC and how do you know which label is
used in relation to the address location in the code?

Can anyone give an example of this and the relation to
the address location in PIC micro for me?

Thanks
Neil

;***************************************************************************
*********
; Filename: Variable.inc
*
; Date: 03-04-2003 *
;
*
;
*
; Author: Thomas C. Sefranek
*
; Company: NeuroPhysics Corporation
*
; 900 Mount Laurel Circle
*
; Shirley, Massachussetts 01464
*
;
*
;***************************************************************************
*********
;
;***************** Register (Memory) allocations VARIABLE DEFINITIONS
***************
; Registers for the Interupt_Handler (IRQ_Handler)
CBLOCK 0x20
W_SAVE ; Reserve 1 byte of RAM for IRQ Working register.
STATUS_SAVE ; Reserve 1 byte of RAM for IRQ STATUS register.
FSR_SAVE ; Reserve 1 byte of RAM for IRQ FSR register.
;
; Registers for STATE Machines
FIFO_STATE ; Reserve 1 byte of RAM for the OUTput FIFO STATE register.
PARSE_STATE ; Reserve 1 byte of RAM for PARSE character STATE register.
HALT_STATE ; Reserve 1 byte of RAM for the HALT STATE register.
;
LED_ARG ; Reserve 1 byte of RAM for the LED ARGument register.
LED_SHADOW ; Reserve 1 byte of RAM for the LED SHADOW register.
BLINK_RATE_0 ; Reserve 1 byte of RAM for the LED 0 BLINK register.
BLINK_RATE_1 ; Reserve 1 byte of RAM for the LED 1 BLINK register.
BLINK_RATE_2 ; Reserve 1 byte of RAM for the LED 2 BLINK register.
BLINK_RATE_3 ; Reserve 1 byte of RAM for the LED 3 BLINK register.
BLINK_RATE_4 ; Reserve 1 byte of RAM for the LED 4 BLINK register.
BLINK_RATE_5 ; Reserve 1 byte of RAM for the LED 5 BLINK register.
BLINK_RATE_6 ; Reserve 1 byte of RAM for the LED 6 BLINK register.
BLINK_RATE_7 ; Reserve 1 byte of RAM for the LED 7 BLINK register.
BLINK_LED ; Reserve 1 byte of RAM for the BLINK LED register.
TEMP_CHR ; Reserve RAM for the TEMPorary storage of the character.
PASS_CHAR ; Reserve RAM for the Input storage of a character.
PARSE_CHAR ; Reserve 1 byte of RAM for the PARSEd CHARacter register.
ADJ_CHAR ; Reserve 1 byte of RAM for the ADJust CHARacter register.
TEMP_BYTE ; Reserve 1 byte of RAM for the TEMPorary BYTE register.
STRING_PTR ; Reserve 1 byte of RAM for the STRING PoinTeR register.
OUT_FIFO_IN_PTR ; Reserve 1 byte of RAM for the OUTput FIFO input pointer.
OUT_FIFO_OUT_PTR ; Reserve 1 byte of RAM for the OUTput FIFO output pointer.
OUT_FIFO_START ; Reserve 1 byte of RAM for the OUTput FIFO STARTing pointer.
OUT_FIFO:64 ; Reserve 64 bytes for the OUTput First In First Out buffer.
OUT_FIFO_END ; Reserve 1 byte of RAM for the OUTput FIFO ENDing pointer.
ENDC
;
;****************** Page 1 Register allocations VARIABLE DEFINITIONS
**********
; Registers for the Input FIFO.
CBLOCK 0xA0
IN_FIFO_STATE ; Reserve 1 byte of RAM for the INput FIFO STATE register.
IN_TEMP_CHR ; Reserve RAM for the IN TEMPorary storage of the character.
IN_STRING_PTR ; Reserve 1 byte of RAM for the IN STRING PoinTeR register.
I_STRING:24 ; Reserve 24 bytes of RAM for the INput STRING.
;
IN_FIFO_IN_PTR ; Reserve 1 byte of RAM for the INput FIFO input pointer.
IN_FIFO_OUT_PTR ; Reserve 1 byte of RAM for the INput FIFO output pointer.
IN_FIFO_START ; Reserve 1 byte of RAM for the INput FIFO STARTing pointer.
IN_FIFO:64 ; Reserve 64 bytes for the INput First In First Out buffer.
IN_FIFO_END ; Reserve 1 byte of RAM for the INput FIFO ENDing pointer.
ENDC
;***************************************************************************
***
;
 
T

The Real Andy

Jan 1, 1970
0
Neil W.Fisk said:
Hello Everyone

Some of the declare statements are unclear in MPLAB, some programmers
from PIClist use them but I'am unsure what they mean.

MPlab doesn't have any this information in the help
section using CBLOCK,and ENDC.
The macros seem straight forward on how their used.
My question is, what is the proper format or layout for this
command statement CBLOCK,and ENDC and how do you know which label is
used in relation to the address location in the code?

Can anyone give an example of this and the relation to
the address location in PIC micro for me?

The CBLOCK directive is used to declare consecutive registers in memory.
ENDC signals the assembler to stop allocating memory.

For Example,

CBLOCK 0x20 ;start allocating memory from adress 0x20

register1
register2
register3
register4

ENDC ;end of registerer declarations.

The above piece of code will allocate the label 'register1' to byte0x20,
register2 to byte 0x21 etc.

It saves you having to explicity define every register, for example to do
the above piece of code with defines would be like this:

#define register1 0x20
#define register2 0x21
#define register3 0x22
#define register4 0x23

Both pieces of code do the exact same thing, ie, that is to allocate a
number to a label but the first example is much easier and neater to code.
The first piece of code is also easier to maitain.

PS. All this information is listed in the MPASM users guide.
 
R

Robert C Monsen

Jan 1, 1970
0
Neil W.Fisk said:
Hello Everyone

Some of the declare statements are unclear in MPLAB, some programmers
from PIClist use them but I'am unsure what they mean.

MPlab doesn't have any this information in the help
section using CBLOCK,and ENDC.
The macros seem straight forward on how their used.
My question is, what is the proper format or layout for this
command statement CBLOCK,and ENDC and how do you know which label is
used in relation to the address location in the code?

Can anyone give an example of this and the relation to
the address location in PIC micro for me?

Thanks
Neil

IN MPLAB, go to the 'help' menu, select "Topics..."

Now, select "MPASM Assembler". Under the 'reference' tab, there is a section
on compiler directives. They are all described (badly) under there.

Here is an example of the usage of cblock:

cblock 0x20
name1
name2
name3
endc

This will cause the assember to replace name1 with 0x20, name2 with 0x21,
and name3 with 0x22. If the 0x20 is left off, it starts at 0x20, so if you
only have one in a single file project, you can leave it off.

You get into trouble with cblock if you use multiple files; in that case,
you must coordinate the start offsets so you don't overwrite variables
declared in other files.

If, instead of using cblock, you use relocatable objects (which is also
described in the manual) you can do this without worrying about conflicts
between files. I find this simpler and much less error prone.

Regards,
Bob Monsen
 
N

Neil W.Fisk

Jan 1, 1970
0
The Real Andy said:
The CBLOCK directive is used to declare consecutive registers in memory.
ENDC signals the assembler to stop allocating memory.

For Example,

CBLOCK 0x20 ;start allocating memory from adress 0x20

register1
register2
register3
register4

ENDC ;end of registerer declarations.

The above piece of code will allocate the label 'register1' to byte0x20,
register2 to byte 0x21 etc.

It saves you having to explicity define every register, for example to do
the above piece of code with defines would be like this:

#define register1 0x20
#define register2 0x21
#define register3 0x22
#define register4 0x23

Both pieces of code do the exact same thing, ie, that is to allocate a
number to a label but the first example is much easier and neater to code.
The first piece of code is also easier to maitain.

PS. All this information is listed in the MPASM users guide.

Thanks for your help Andy!!, I couldn't find it anywhere, Mplab has a
very extensive help menu, I probably wouldn't of found it.
-Neil
 
Top