A record type creates a template for data with the sizes and, optionally, the initial values for bit fields in the record, but it does not allocate memory space for the record.
The RECORD directive declares a record type for an 8-bit, 16-bit, or 32-bit record that contains one or more bit fields. The maximum size is based on the expression word size. See OPTION EXPR16 and OPTION EXPR32 in Section 1.3.2. The syntax is
recordname RECORD field[[,field]]...
The field declares the name, width, and initial value for the field. The syntax for each field is:
fieldname:width[[=expression]]
Global labels, macro names, and record field names must all be unique, but record field names can have the same names as structure field names or global labels. Width is the number of bits in the field, and expression is a constant giving the initial (or default) value for the field. Record definitions can span more than one line if the continued lines end with commas.
If expression is given, it declares the initial value for the field. The assembler generates an error message if an initial value is too large for the width of its field.
Summary: The assembler shifts bits in a record to the right if all bits are not used.
The first field in the declaration always goes into the most significant bits of the record. Subsequent fields are placed to the right in the succeeding bits. If the fields do not total exactly 8, 16, or 32 bits as appropriate, the entire record is shifted right, so the last bit of the last field is the lowest bit of the record. Unused bits in the high end of the record are initialized to 0.
The following example creates a byte record type color having four fields: blink, back, intense, and fore. The contents of the record type are shown after the example. Since no initial values are given, all bits are set to 0. Note that this is only a template maintained by the assembler. No data is created.
COLOR RECORD blink:1, back:3, intense:1, fore:3
The next example creates a record type cw having six fields. Each record declared with this type occupies 16 bits of memory. Initial (default) values are given for each field. They can be used when data is declared for the record. The bit diagram after the example shows the contents of the record type.
CW RECORD r1:3=0, ic:1=0, rc:2=0, pc:2=3, r2:2=1, masks:6=63