|
NGASM 8086/8088 Assembler v1.4 Beta 2 NGASM 8086/8088 Assembler v1.4 Beta 2 supports three basic data declaration directives, a directive for declaring structure templates and a directive for declaring EQUates (5 in total). The not-counted one is the COMMENT directive. They are listed below with example declarations. The DB directive The DW directive The DD directive The STRUCT (or STRUC) and ENDS directives (counted as one) The EQU Directive The COMMENT directive (not counted) Data declaration directives:
NGASM 8086/8088 Assembler v1.4 Beta 2 supports the STRUCT (or STRUC) and ENDS directives to define a structure template for grouping data items. The STRUCT (or STRUC) directive The ENDS directive The STRUCT or STRUC directive tells the assembler that a user defined uninitialized data structure follows. The uninitialized data structure consists of a combination of the three supported data types viz. DB, DW, and DD. The uninitialized data structure specifies the labels (names) for the elements in the structure and the elements' data types. The labels serve as zero-based offsets into the structure. The first element's offset for any structure is 0. A structure element is referenced with the base and/or index registers by applying the "+" operator before the element's name. A Structure ends with the ENDS directive (meaning END of Structure). Syntax STRUCT Structure_element_name element_data_type ? . . . . . . . . . ENDS (OR) STRUC Structure_element_name element_data_type ? . . . . . . . . . ENDS Declaration example: STRUCT Byte1 DB ? Byte2 DB ? Word1 DW ? Word2 DW ? Dword1 DW ? Dword2 DW ?ENDS Use of STRUCT: Apart from grouping data items, the STRUCT directive enables you to change the order of items in the structure when, say, you reform a file header (of yours) and shuffle the data items there. Shuffle the data items in the file header and reformat the sequence of data declaration in the STRUCT and off you go. No change in the code you wrote that processes the file header is necessary unless you inserted an extra data element that needs to be processed too in your code. The EQU Directive The EQU (EQUate) directive declares a symbolic name for a value. The value can be in the range 0 through 65535 and it can be another EQUate declared anywhere above or below. The following operators can also be used to declare an EQUate: THIS BYTE THIS WORD THIS DWORD $. A variable - declared with a DB, DW, or DD directive - has an address and has space reserved at that address for it in the .COM file. But an EQUate does not have an address or space reserved for it in the .COM file. Syntax label EQU value label is a symbolic name (not a nametag for a memory location as in the case of variables) and is compulsory. The symbolic name represents the value specified. value is the value that is used to replace the symbolic name wherever it is found in the assembly source code file during assembly time (not when the program is run). When an immediate value (Imm16) or $ or another EQUate is the value specified, that value is used to replace the symbolic name wherever it is found. When the EQUate is declared using THIS BYTE, THIS WORD, and THIS DWORD, it behaves like a variable of type byte, word, or doubleword respectively and its offset address is used to replace the symbolic name wherever the symbolic name is found in the assembly source code file.Example:
a_byte EQU THIS BYTE
DB 10
a_word EQU THIS WORD
DW 1000
a_dword EQU THIS DWORD
DD 4294967295
BufferSize EQU 1024
buffer DB 1024 DUP(0)
bufend_ptr EQU $ ;actually points to the next byte after the
;1024th byte in buffer.
The COMMENT directive The COMMENT directive is useful for writing multi-line comments anywhere in the source code file. Usually a multi-line comment should start with the COMMENT directive. A delimiter character is placed one or more space characters after the COMMENT directive; a second instance of the same delimiter character ends the whole comment. All texts between the identical delimiter characters are ignored together with everything else on the last line of comment. Examples showing multi-line comments:
COMMENT 'This comment
runs across two lines'
COMMENT ^ This comment occupies
three lines
^
COMMENT 'This comment ends in this line itself'
|
|