ftp.nice.ch/peanuts/GeneralData/Documents/dsp/DSPDoc.tar.gz#/DSPDoc/Fodder/AllocationMacros.txt

This is AllocationMacros.txt in view mode; [Download] [Up]

DSP MEMORY ALLOCATION (ASSEMBLY LOCATION-COUNTER MACROS)

The Location Counter (LC) macros, defined in DSPMACSRC/lc.asm and
DSPMACSRC/alloc.asm ('include'ed by DSPMACSRC/stdmacros) are designed
to simplify dsp memory allocation. They manage use of the ORG
directive of the DSP56000 assembler (cf. page 6-52 of the assembler
manual.)  The macros provide saving and restoring of the current LC,
and automatic sequential allocation of x, y, l, or p elements (with
error checking).  The macros insulate the user from system constants
delineating dsp memory boundaries, and they hide the presence of
shared external memory.  Finally, they hide the big hole in the dsp
address space from 512 to 8191 in the case of using 8K RAM chips (the
address-bit 13 must be high to enable the 8K RAMS).

The push_lc and pop_lc macros are self-explanatory.  They allow
dsp macros to conveniently save and restore any of the assembly
location counters.

For each memory space, there are two allocation macros, one for
internal (on-chip) memory allocation and one for external (on-chip)
memory allocation:
          
     new_xib name,count,value      ; allocate and init next internal x block
     new_xeb name,count,value      ; allocate and init next external x block

     new_yib name,count,value      ; allocate and init next internal y block
     new_yeb name,count,value      ; allocate and init next external y block

     new_lib name,count,hival,loval ; allocate and init next internal l block
     new_leb name,count,hival,loval ; allocate and init next external l block

where the arguments are as follows:

     'name'    is the symbol name whose value will become the address of 
               the first location of the allocated memory block,
     'count'   is the number of dsp words to be allocated (block length),
     'value'   is the 24-bit datum to be placed in each memory location,
     'hival'   is the 24-bit datum to be placed in the high-order word 
               (x portion) of each (long) memory location, and
     'loval'   is the 24-bit datum to be placed in the low-order word 
               (y portion) of each (long) memory location.

Memory spaces x, y, and p are allocated from the lowest available
address to the highest available address, while l memory is allocated
from the highest available address donward (since l memory is actually
the concatenation of x and y memory). If l memory overlaps with x or y
memory, an error message is produced.

If the value field is NOSET (a predefined constant which occupies more
than 24 bits), no initialization is performed (the DS directive is
used instead of the BSC directive).

Data in program memory must be allocated by the user.
(??? write new_pib et al?)

All allocation macros switch to p assembly upon exit. Specifically,
each allocation macro works as in the following (simplified) example:

 new_xib   macro name,count,value ; allocate & initialize next internal x block
 cur_lc    set @lcv(R)            ; save current location counter
           org_xis xi_lc          ; switch to xi ram location counter
 name      bsc count,value        ; allocate and initialize data storage
 xi_lc     set @lcv(R)            ; update xi next-free-word pointer
           org p:cur_lc           ; assume we came from p memory
           endm

For convenience, the following macros are defined to allocate single
words:
          
     new_xi name,value        ; allocate and init next internal x word
     new_xe name,value        ; allocate and init next external x word

     new_yi name,value        ; allocate and init next internal y word
     new_ye name,value        ; allocate and init next external y word

     new_li name,hival,loval  ; allocate and init next internal l word
     new_le name,hival,loval  ; allocate and init next external l word

Finally, there is a set of "constrained" block allocation calls new_xicb,
new_yicb, etc., which place the allocated block at an address compatible
with modulo addressing of a length 'count' table (i.e., the low-order k
bits of the start address are 0, where k is the smallest integer greater
than or equal to the log-base-2 of count). Note that the intervening 
storage locations are lost. (!!! <Define pointers for skipped storage
so that user can use them if necessary>)



These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.