On Monday 14 April 2003 09:45 am, John Nall wrote about the 18F452: > I understand that there are three separate storage areas: program > memory, data memory, and a small bit of EEPROM memory. It is my > understanding from the datasheet that all of the instructions which > move data to or from storage (that is, the instructions which > involve "f") strictly operate to or from data memory (RAM). Yes. > It also appears to me that to pre-allocate storage in assembler > language, that one uses the CBLOCK directive, which will allocate > storage in data memory, No. CBLOCK doesn't allocate anything. Instead, it defines a block of (sequential, generally) numeric constants. Some people used to use these constants to define RAM addresses. However, this doesn't generally mix well with the generation of relocatable object files, which is probably what you want to do. Read the MPASM manual chapter 6 "Using MPASM to Create Relocatable Objects". What you do for RAM is this: * use UDATA, UDATA_ACS, UDATA_OVR, UDATA_SHR, or IDATA to specify the section you want to put your RAM into. * use DB, DW, or DATA to define initialized RAM * use the RES command to reserve bytes (uninitialized). > and/or use DA, DATA, DB or DW to > pre-allocate storage in program memory. Yes. ROM works similarly to RAM; it's just that the section names are different (and there's usually no point in reserving bytes in ROM). You use the CODE section directive instead. > How does one read/write the data allocated in data memory? The > only way that I see is to use the table read/write instructions. > Is there another way? By data memory you mean RAM/file registers? You use the file register commands, or use the FSR* registers and indirect access. In Flash: If you use the DT directive, you get a series of RETLW instructions. You can do an indexed jump into the resultant table, and get a byte back in W. Otherwise you use the TBLRD instruction to read these tables. To write them you have to go through a special sequence involving erasing, using TBLWT, and initiating a write. See the data sheet in the section on flash memory. > How does one pre-allocate storage in EEPROM memory. Is this what > the DE directive is for? And same question as to how to read/write > it. You read and write EEPROM using the EEADR and EEDATA (and EECON* for writing). Look in the datasheet under "Data EEPROM". -- Ned Konz http://bike-nomad.com GPG key ID: BEEA7EFE -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.