Declaring Union Variable Blocks in PSoC® 1 Assembly Language - KBA91675

Version: **

 

Question:

In PSoC® 1, how can Union variable blocks (variables occupying the same memory location) be declared in assembly language?

 

Answer:

Location of two RAM areas in the same memory location is possible using the "OVR" (Overlap) keyword in "AREA" directives. 

The following content describes the "OVR" keyword. Note that this content is reproduced from page 76 of the "ImageCraft Assembly Language Guide" available in "PSoC Designer Help > Documentation > Compiler and Programming Documents > Assembly Language User Guide." This is available at the link: http://www.cypress.com/file/44746/download.

OVR – Specifies that sequential AREAs start at the same address. This is a union of the AREAs. The total size of the AREA directive is the size of the largest area.

The following example demonstrates how the areas of two RAM variable groups "areavar1" and "areavar2" can be mapped to the same memory location: 

AREA areavar1(RAM, REL, OVR) 
VAR1:     blk 32 ;     RAM storage 
area areavar2(RAM, rel, con)
VAR2_INITIAL:      blk 5 
VAR2_FINAL:        blk 1 

Because areavar1 and areavar2 occupy overlapping memory locations, "VAR2_FINAL" is mapped to the same RAM location as "VAR1+5".