To further muddy this up.... I like to use CBLOCKs to allocate 'enum' style names. A primary example of this is bit positions in a flags byte: FLAGS RES 1 CBLOCK 0 FLAG_Happy FLAG_Dopey FLAG_Doc FLAG_Sleepy ENDC or command codes: CBLOCK CMD_Start CMD_COPY CMD_FETCH CMD_STORE CMD_End ; Dummy endmark ENDC CMD_Count = CMD_End - CMD_Min Bob Ammerman RAm Systems ----- Original Message ----- From: "Olin Lathrop" To: "Microcontroller discussion list - Public." Sent: Monday, January 24, 2005 6:26 PM Subject: Re: [PIC] Equates or CBlock? > Andrew Warren wrote: >> I guess... But as long as EQU and CBLOCK can be used in a >> program that also uses RES, the block isn't really "allocated"; >> it's just protected from reuse by other RES directives, in the >> same way that registers named using CBLOCK can be kept from >> being renamed by other CBLOCK directives. > > The RAM is truly allocated by the linker, and that only happens when you > use > RES. Of course there is nothing preventing you from creating a symbol > that > happens to have the value of a RAM address, but that has nothing to do > with > allocating the RAM. This is the distinction between RES on one hand, and > CBLOCK and EQU on the other. The only reason there is any confusion is > because valid RAM addresses also happen to be integer values that can have > other meanings. > > For example, the assembler can't prevent you from doing something > boneheaded > like: > > bkcnt equ h'20' ;number of buckets left to fill > > because there is no way to tell this inappropriate useage from an > appropriate one such as: > > buckets equ h'20' ;number of buckets in each tray > > And by the way, one CBLOCK statement does not prevent other CBLOCK > statements from assigning the same values to different symbols. Each > CBLOCK > merely assigns sequential values to a list of symbols. It has absolutely > nothing to do with RAM allocation. > >> This is in contrast to what I think of as "real" allocation... >> Which would be the sort of thing you see in high-level >> languages, where (generally speaking) once a variable name is >> declared/used, other variable names will never be assigned to >> the same RAM. > > But that is exactly what RES does. It is not possible to RES the same > memory location twice. > > > ***************************************************************** > Embed Inc, embedded system specialists in Littleton Massachusetts > (978) 742-9014, http://www.embedinc.com > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist