Once you have declared a record type, you can define record variables of that type. For each variable, memory is allocated to the object file in the format declared by the type. The syntax is <$I<< \ra (angle brackets);records>
[[name]]recordname<[[initializer[[,initializer]]...]] > <$IAngle brackets (<< \ra);records>
[[name]]recordname{[[initializer[[,initializer]]...]] }
[[name]]recordname constant DUP ( [[initializer[[,initializer]]...]] )
The recordname is the name of a record type that was previously declared by using the RECORD directive.
A fieldlist for each field in the record can be a list of integers, character constants, or expressions that correspond to a value compatible with the size of the field. Curly braces or angle brackets are required even if no initial value is given.
If you use the DUP operator (see Section 5.1.1, “Declaring and Referencing Arrays”) to initialize multiple record variables, only the angle brackets and initial values, if given, need to be enclosed in parentheses. For example, you can define an array of record variables with
xmas COLOR 50 DUP ( <1, 2, 0, 4> )
You do not have to initialize all fields in a record. If an initial value is blank, the assembler automatically stores the default initial value of the field. If there is no default value, the assembler clears each bit in the field.
The definition in the example below creates a variable named warning whose type is given by the record type color. The initial values of the fields in the variable are set to the values given in the record definition. The initial values override any default record values, had any been given in the declaration.
COLOR RECORD blink:1,back:3,intense:1,fore:3 ; Record
; declaration
warning COLOR <1, 0, 1, 4> ; Record
; definition
The SIZEOF and TYPE operators applied to a record name return the number of bytes used by the record. SIZEOF for a record variable returns the number of bytes used by the variable. You cannot use LENGTHOF with record types, but you can with the variables of that type. LENGTHOF returns the number of items in an initializer. The record can be used as an operand. The value of the operand is a bit mask of the defined record. This example illustrates these points.
; Record definition
; 9 bits stored in 2 bytes
RGBCOLOR RECORD red:3, green:3, blue:3
mov ax, RGBCOLOR ; Equivalent to "mov ax,
; 01FFh"
; mov ax, LENGTHOF RGBCOLOR ; Illegal since LENGTHOF can
; apply only to data label
mov ax, SIZEOF RGBCOLOR ; Equivalent to "mov ax, 2"
mov ax, TYPE RGBCOLOR ; Equivalent to "mov ax, 2"
; Record instance
; 8 bits stored in 1 byte
RGBCOLOR2 RECORD red:3, green:3, blue:2
rgb RGBCOLOR2 <1, 1, 1> ; Initialize to 025h
mov ax, RGBCOLOR2 ; Equivalent to "mov ax,
; 00FFhh"
mov ax, LENGTHOF rgb ; Equivalent to "mov ax, 1"
mov ax, SIZEOF rgb ; Equivalent to "mov ax, 1"
mov ax, TYPE rgb ; Equivalent to "mov ax, 1"