On Fri, 19 Sep 1997 08:31:26 -0700 Andre Abelian writes: >2. the way I understood about cblock is it is automatic equation that >compiler >will find empty location and use it. let say I am using simple table >code when >I use cblock it doesn=92t work when I use manual way like xxxx equ > xxx >works ok. Could you tell me when should I use Cblock instraction. the >way I use it > > cblock 0x00 > test > endc > I don't see cblock as an "automatic equation compiler that finds an empty location and uses it." The assembler DOES evaluate an expression after the cblock command to determine the RAM address to put the assign the first label to. I think your code above should work, assigning test to RAM address zero (which is the INDF register on the 16c74A, the PIC I'm most familiar with). Here's a typical cblock code fragment of mine... cblock 0x20 ; reserve ram for save and restore context isrW ; Hold registers during ISR. isrW is also isrw! in bank 1 isrStatus isrFSR endc isrW1 equ 0xa0 SaveContext macro ; Save register context for isr. Swaps swap high and low halves of f with the result going either ; back to f or to w. Swap is used here because they affect no status bits. movwf isrW ; Save W swapf status,w ; get status in W (including bank select bits) swapping hi/lo halves bcf status,rp0 ; force to bank 0 movwf isrStatus ; and save swapped status movf fsr,0 ; Get fsr in w movwf isrFSR ; and save it endm RestoreContext macro movf isrFSR,0 ; get old fsr movwf fsr ; and restore it swapf isrStatus,w ; get old status (including bsr bits) in w, swapping back to normal movwf status ; restore it swapf isrw,1 ; swap halves in isrw making them backwards swapf isrw,0 ; swap back to forward and in W without affecting status endm Probably the most useful thing about cblock is that you don't have to give it an address. It will use the next address (one above the last one used in the previous cblock). This allows encapsulation of variables with the associated code. Not quite as good as true local variables (which would put them on the stack and release them when we exit the routine), but easier to follow than having a huge cblock somewhere that attempts to allocate RAM for the whole program, and better than a bunch of EQU statements that you are constantly changing when program changes are made (why doesn't Microchip use cblock in their math routines???). Here's a sample cblock used for encapsulation... ReadRamPort ; Read the Dallas Semiconductor DS1380. cblock ReadAddressLo ReadAddressHi ReadData endc bcf portc,4 ; Enable memory access bank1 clrf trisb ; Set port B for output bank0 movlw b'10101000' ; Set up for read iorwf ReadAddressHi,0 ; Set up high address lines movwf portb ; Send to chip bcf portc,3 ; Send low clock pulse bsf portc,3 movf ReadAddressLo,0 ; Get low address movwf portb bcf portc,3 ; Send low clock pulse bsf portc,3 bank1 decf trisb,1 ; Change port to input bank0 bcf portc,3 ; Clock low movf portb,0 ; Get ram data bsf portc,3 ; Clock high movwf ReadData ; Save result return Harold