• Aucun résultat trouvé

Simple data directives

Dans le document TUrbo Assembler" (Page 143-146)

You can define data with the DB, OW, DO, OQ, OF, OP, or OT directives. These directives define different sizes of simple data, as shown in the following table.

Table 12.1 Data size directives

DB Define byte-siZe data.

DW Define ward-size data:

DD Define daubleward-size data.

DQ Define quadward-size data.

DF Define 48-bit 80386 far-painter-size (6 byte) data.

DP Define 48-bit 80386 far-painter-size (6 byte) data.

DT Define tenbyte (lO-byte) size data.

Note Data is always stored in memory low value before high value.

The syntax of the value field for each of these directive differs, based on the capability of each data size to represent certain quantities. (For example, it's never appropriate to interpret byte data as a floating-point number.)

DB (byte) values can be

• A constant expression that has a value between -128 and 255 (signed bytes range from -128 to +127; unsigned byte values are from 0 to 255). .

• An 8-bit relative expression using the HIGH or LOW operators.

• A character string of one or more characters, using standard quoted string format. In this case, multiple bytes are defined, one for each character in the string.

OW (word) values can be

• A constant expression that has a value between -32,768 and 65,535 (signed words range from -32,768 to 32,767; unsigned word values are from 0 to 65,535).

• A relative expression that requires 16 bits or fewer, (including an offset in a 16-bit segment, or a segment or group value).

• A one or two-byte string in standard quoted string format.

DO (doubleword) values can be

• A constant expression that has a value between -2,147,483,648 and 4,294,967,295 (when the 80386 is selected), or-32,768 and 65,535 otherwise.

• A relative expression or address that requires 32 bits or fewer (when the 80386 is selected), 16 bits or fewer for any other processor. /

• A relative address expression consisting of a 16-bit segment and a 16-bit offset.

134 T u r boA sse m b I e r Use r J s G u ide

• A string of up to four bytes in length, using standard quoted string format.

• A short (32-bit) floating-point number.

DQ (quadword) values can be

• A constant expression that has a value between --':2,147,483,648 and 4,294,967,295 (when the 80386 is selected), or -32,768 and 65,535 otherwise.

• A relative expression or address that requires 32 bits or fewer (when the 80386 is selected), or 16 bits or fewer for any other processor.

• A positive or negative constant that has a value between _263 and 264-1 (signed quadwords range in value from _263 to 263-1; unsigned quadwords have values from

o

to 264-1).

• A string of up to 8 bytes in length, using standard quoted string format.

.• A long (64-bit) floating-point number.

DF, DP (80386 48-bit far pointer) values can be

• A constant expression that has a value between -2,147,483,648 and 4,294,967,295 (when the 80386 is selected), or -32,768 and 65,535 otherwise.

• A relative expression or address that requires 32 bits or fewer (when the 80386 is selected), or 16 bits or fewer for any other processor.

• A relative address expression consisting of a 16-bit segment and a 32-bit offset.

• A positive or negative constant that has a value between -:-247 and 248-1 (signed 6-byte values range in value from _247 to 247-1; unsigned 6-byte values have values from 0 to 248-1).

• A string of up to 6 bytes in length, in standard quoted string format.

DT values can be

• A constant expression that has a value between -2,147,483,648 and 4,294,967,295 (when the 80386 is selected), or -32,768 and 65,535 otherwise.

• A relative expression or address that requires 32 bits or fewer (when the 80386 is selected), or 16 bits or fewer for any other processor.

• A positive or negative constant that has a value between _279 and 28°-1 (signed tenbytes range in value from _279 to 279-1; unsigned tenbytes have values from 0 to 28°-I).

• A 10-byte temporary real formatted floating-point number.

• A string of up to 10 bytes in length, in standard quoted string format.

• A packed decimal constant 'that has a value between 0 and 99,999,999,999,999,999,999.

Numerical and string constants for the simple data allocation directives differ in some cases from those found in standard Turbo Assembler expressions. For example, the DB, DP, DQ, and DT directives accept quoted strings that are longer than those accepted within an expression.

C hap t e r 1 2, A II 0 cat i n 9 d a t.a 135

Quoted strings are delimited either by single quotes(') or double quotes ("). Inside of a string, two delimiters together indicate that the delimiter character should be part of the string. For example,

'what','s up doc?'

represents the following characters:

what's up doc?

You can have floating-point numbers as the value field for the DD, DQ, and DT directives. Here are some examples of floating-point numbers:

1.0EjO ;Stands for 1.0 x 1030 2.56E-21 ;Stands for 2.56 x 10-21 1.28E+5 ;Stands for 1.28 x 105 0.025 ;Stands for .025

Turbo Assembler recognizes these floating-point numbers because they contain a'.' after a leading digit. These rules are relaxed somewhat in MASM mode. For example,

DD lE30 ;L~gal MASM mode floating point value!

DD .123 ;Legal in MASM mode only.

Note For clarity, we recommend using the form with the leading digit and the decimal point.

Turbo Assembler also allows encoded real numbers for the DD, DQ, and DT directives.

An encoded real number is a hexadecimal number of exactly

a

certain length. A suffix of R indicates that the number will be interpreted as an encoded real number. The length of the number must fill the required field (plus one digit if the leading digit is a zero); for example,

DD 12345678r ;Legal number DD 012345678r ;Legal number

DD 1234567r ;Illegal number (too short)

The other suffix values (D, H, 0, Q, and B) function similarly to those found on numbers in normal expressions.

Some of the simple data allocation directives treat other numerical constant values specially. For-example, if you don't specify radix for a value in the DT directive, Turbo Assembler uses binary coded decimal (BCD) encoding. The other directives assume a decimal value, as follows:

DD 1234 DT 1234

;Decimal

;BCD

The default radix (that the RADIX directive specifies) is not applied for the DD, DQ, and DT directives if a value is a simple positive or negative constant. For example,

RADIX 16 DW 1234 DD 1234

;1234 hexidecimal

;1234 decimal

Chapter 5 details numerical constants and the RADIX directive.

136 T u r boA sse m b Ie r Use r' s G u ide

Dans le document TUrbo Assembler" (Page 143-146)

Documents relatifs