A scalar data item represents a numeric quantity that may be increased or decreased in magnitude as a single unit. Thus, an Initializer expression for a scalar data item must be coded such that it resolves to a single scalar value. See the section on Scalar-Initializer-ExpressionType for the syntax and semantics of such expressions.
The old-style allocation directives (DB, DW, DD, DF, DQ, and DT) are supported in all assembler emulation modes, but for modes other than M510, the Scalar-TypeName keywords should be used instead.
When the Scalar-TypeName keywords are used instead of the old-style allocation directives, the assembler has full knowledge of the data types of the variables being created. This allows the assembler to make more intelligent code generation decisions, and it enables the assembler to correctly describe the variable in the symbolic debugging information that it generates for the source level debugger. Scalar-TypeNames may not be used as allocation directives in the M510 mode.
To allocate an uninitialized scalar data item, use the Indeterminate-Value-Alias ($) in the Initializer field.
┌─────────┬────────────────────┬────────────────────────────────────────┐ │Type Name│Data Type │Initializer Description │ ├─────────┼────────────────────┼────────────────────────────────────────┤ │DB, BYTE,│Allocates 8-bit │Each Initializer must be in the range │ │or SBYTE │(byte) values. │from 0 to 255 (unsigned) for a DB or │ │ │ │BYTE directive, and from -128 to 127 │ │ │ │(signed) for a SBYTE directive. │ ├─────────┼────────────────────┼────────────────────────────────────────┤ │DW, WORD,│Allocates 16-bit │Each Initializer must be in the range │ │or SWORD │(word) values. │from 0 to 65535 (unsigned) for a DW or │ │ │ │WORD directive, and from -32768 to 32767│ │ │ │(signed) for a SWORD directive. │ ├─────────┼────────────────────┼────────────────────────────────────────┤ │DD, │Allocates 32-bit │If the Initializer is an integer, each │ │DWORD, or│(double-word) │must be in the range from 0 to │ │SDWORD │values. │4,294,967,295 (unsigned) for a DD or │ │ │ │DWORD directive, and from -2,147,483,648│ │ │ │to 2,147,483,647 (signed) for a SDWORD │ │ │ │directive. If the DD directive is being│ │ │ │used, an Initializer may also resolve to│ │ │ │a 32-bit Floating-Point-ExpressionType. │ ├─────────┼────────────────────┼────────────────────────────────────────┤ │DF or │Allocates 48-bit │Each Initializer typically specifies the│ │FWORD │(6-byte far-word) │full address of a 32-bit far code or │ │ │values. │data label, but normal 32-bit integer │ │ │ │values may also be used. The processor │ │ │ │does not support 48-bit integer │ │ │ │operations, thus the assembler does │ │ │ │support 48-bit integer precision when │ │ │ │initializing such variables. These │ │ │ │directives are typically only useful for│ │ │ │defining pointer variables for use on │ │ │ │32-bit processors. │ ├─────────┼────────────────────┼────────────────────────────────────────┤ │DQ or │Allocates 64-bit │Both DQ and QWORD allow an integer │ │QWORD │(quad-word) values. │Initializer with 64-bit (8-byte) │ │ │ │precision. If the DQ directive is being│ │ │ │used, the Initializer field may resolve │ │ │ │to a 64-bit │ │ │ │Floating-Point-ExpressionType. │ ├─────────┼────────────────────┼────────────────────────────────────────┤ │DT or │Allocates 80-bit │Both DT and TBYTE allow an integer │ │TBYTE │(10-byte) values │Initializer with 80-bit (10-byte) │ │ │ │precision. If the DT directive is being│ │ │ │used, the Initializer field may resolve │ │ │ │to a 80-bit │ │ │ │Floating-Point-ExpressionType. │ ├─────────┼────────────────────┼────────────────────────────────────────┤ │REAL4, │Allocates real │Each Initializer must resolve to a │ │REAL8, or│(floating-point) │Floating-Point-ExpressionType. The │ │REAL10 │values of a specific│assembler converts the floating-point │ │ │size (4 bytes, 8 │literal to the IEEE format appropriate │ │ │bytes, or 10 bytes).│for the type of variable being │ │ │ │allocated. │ └─────────┴────────────────────┴────────────────────────────────────────┘
Examples
Here are some examples of scalar initialization:
; Allocate some integer variables uint8 BYTE 0, 255 ; min, max values for unsigned byte sint8 SBYTE -128, 127 ; min, max values for signed byte USHORT_T TYPEDEF WORD ; Define a typedef alias for WORD ushort USHORT_T 0, 0FFFFh ; and use it as allocation type name ; Some things to know about string-literal initializers char BYTE "a" ; a single BYTE value (061h) is_int WORD "ab" ; a single WORD value (06162h) this_too DWORD "abcd" ; a single DWORD value (061626364h) too_long WORD "abcd" ; error, expression too big for a word string BYTE "string", 0 ; but strings can allocate many bytes ; Integers, pointers, and old-style initializations PDWORD_T TYPEDEF PTR DWORD ; First, define a pointer type ulong DWORD 0, 0FFFFFFFFh ; min, max values for unsigned dword pulong PDWORD_T OFFSET ulong ; pointer to the ulong variable old_style DD 1.314 ; old style, floats are accepted new_int SDWORD 1.314 ; new style, error-must use integers new_real REAL4 1314 ; new style, error-must use floats ; Allocate some real numbers using decimal floating-point literals float_f REAL4 123.45 ; 4-byte IEEE real double_f REAL8 98.7654E1 ; 8-byte IEEE real longdbl_f REAL10 1000.0E-2 ;10-byte IEEE real ; The same values using hexdecimal floating-point literals float_h REAL4 42F6E666r ; 4-byte IEEE real double_h REAL8 408EDD3B645A1CACr ; 8-byte IEEE real longdbl_h REAL10 4002A000000000000000r ;10-byte IEEE real