• Aucun résultat trouvé

IS THE VALUE SHR DX,CL ;FIELD TO LOW-ORDER

Dans le document About This Book (Page 130-142)

Conditional Pseudo-ops

ENDM Remarks

9 IS THE VALUE SHR DX,CL ;FIELD TO LOW-ORDER

BITS OF REGISTER, OX IS NOW EQUAL TO THE VALUE OF FIELD Y

MOV CL,WIDTH Y ;GET NUMBER OF BITS IN FIELD 4 IS THE VALUE The WIDTH of Y equals 4.

Purpose

The assembler repeats the block of statements between REPT and

EN OM the number of times in the expression entry.

Format

REPT expression

ENDM Remarks

If the expression entry contains any external or undefined terms, an error is produced.

The REPT-ENOM block does not have to be within a macro definition.

Example

This example produces a series of ordered bytes up to a paragraph boundary.

DSEG SEGMENT

SYM 0

REPT 16

;;CHECK FOR PARA BOUNDARY

IF ($-DSEG) MOD 16 EO 0 EXITM

ENDIF

SYM SYM + 1

DB SYM ENDM

3-82

SEGMENT

Purpose

At run time, each instruction and each variable of your program lies within some segment. Use the SEGMENT pseudo-op to define all code-producing instructions as being within a segment. Your assembly module can be a part of a segment, a whole segment, parts of several segments, several whole segments, or a combination of these.

Format

segname SEGMENT [align-type][combine-type] [I class I]

segname ENDS Remarks

The assembler assigns the symbol entry for a segment attribute of an align-type entry, a combine-type, and a character string defining 'class' (if present); the assembler also keeps the length of the segment.

Note: If you specify two or three attributes, separate them with a space.

The align-type entry can be PARA, BYTE, WORD, or PAGE. The definition of these types are:

PARA (Default): This align-type specifies that the segment begin on

boundary (an address divisible by 256 and whose two least-significant hexadecimal digits are equal to OOH).

The combine-type entry can be PUBLIC, COMMON, AT expression, STACK,

or no entry (which defaults to not combinable). The definitions for these types are:

PUBLIC: This combine-type specifies that this segment is con-nected to others of the same name when linked.

COMMON: This combine-type specifies that this segment and all other segments of the same name that are linked together begin at the same address, and thus overlap. The length of a linked

COMMON is the maximum of the linked segments.

AT expression: This combine-type specifies that this segment is located at the 16-bit paragraph number evaluated from a given expression. The expression can be any valid constant; however, it cannot be a forward reference. You cannot use the AT

expression to force loading of code at a fixed address; rather, it permits you to define labels or variables at fixed offsets within fixed areas of memory, such as Read Only Memory or the vector space in low memory. No code is produced for this segment.

STACK: This combine-type specifies that this segment is part of the run-time stack segment, called last-in, first-out (LIFO) using the assembler instructions such as: PUSH, POP, CALL, INT, IRET, POPF, PUSHF, and RET. If you are writing the application to be an .EXE

file, a STACK segment is required; if a .COM file, a STACK segment should not be assembled. The linker issues a warning message if no STACK segment is defined. Ignore that linker warning message if you are converting the application from an .EXE file to a .COM file.

MEMORY: This combine-type, although recognized by the assem-bler, cannot be used with the linker and should not be used in your code. If used, it is treated as PUBLIC.

The 'class' entry is the name (must be enclosed in single quotes) used to group segments at link time.

You can nest segment definitions. When segments are nested, the assembler acts as if they are not nested and processes them by attaching the second part of the split segment to the first. When the 3-84

assembler detects the ENDS pseudo-op, the assembler takes up the next segment, completes it, and continues. Overlapping segments are not permitted.

Example

The following example combines logical segments into a physical segment:

In module A-SEGA SEGMENT PUBLIC

ASSUME CS:SEGA

SEGA ENDS

In module 8-SEGA SEGMENT PUBLIC

ASSUME CS:SEGA

· (Note: LINK adds this

· segment to same named

· segment in module A) SEGA ENDS

Nesting of Segments:

CSEG SEGMENT

MOV AX,BX DSEG SEGMENT

Pl DW 6 DSEG ENDS

(CSEG continues

...

)

Purpose

.SEQ tells the assembler to arrange the segments in the object file in the order they appear in the source file.

Format .SEQ Remarks

.SEQ cancels the / A option or .ALPHA pseudo-op.

Example .SEQ

DATA SEGMENT

DATA ENDS CODE SEGMENT

CODE ENDS

Segment DATA will precede segment CODE in the object module.

3-86

.SFCOND

Purpose

.SFCOND suppresses the listing of false conditional blocks.

Format .SFCOND Remarks

.SFCOND does not have an operand. End the state caused by .SFCOND

either by issuing .TFCOND (which reverts to the default state con-cerning listing of false conditionals but with the default state rede-fined as being in the opposite state) or by issuing .LFCOND (which forces the listing of false conditionals).

Note: See the discussion of false conditional blocks in Chapter 2,

"Getting Started," in this book for detail.

Purpose

The STRUC pseudo-op is like the RECORD pseudo-op except that STRUC

has a multi-byte capability. Reserving memory for and initializing the values in a STRUC block is the same as for the RECORD pseudo-op.

Format

structurename STRUC

[fieldnames] (a DEFINE pseudo-op) exp

structurename ENDS Remarks

The structurename itself becomes a pseudo-op that reserves memory. Inside the STRUC-ENDS block, DB, OW, DO, DQ, and DT

pseudo-ops can reserve space. It is not necessary for a data field defined within a STRUC to have a variable name. Any labels on a

DEFINE pseudo-op inside the STRUC-ENDS block become the fieldnames.

First values given in the STRUC-ENDS block are default values for the various fields. These values, or fields are of two types:

• Overridable

• Not overridable.

A simple field (a field with only one entry) can be overridden. A mul-tiple field (a field with more than one entry) cannot be overridden.

If the field contains a string, another string can override it. However, if the overriding string is shorter than the initial string, the assembler pads the space to the right with blanks. If the overriding string is longer, the assembler cuts off the extra characters.

3-88

The format that refers to an item defined within the STRUC-ENDS block (for example, an operand) is:

variable.field

where the variable represents a variable. The field entry represents a label given to a define data pseudo-op inside the STRUC-ENDS block.

(Code the period as shown.) The value of the field entry is the offset within the addressed structure.

You cannot use any pseudo-ops, except DB, DO, DQ, DT, and OW, within a STRUC-ENDS structure definition.

Note: A simple DO field initialized with 0 or any value other than "?"

cannot be overridden by an address; it can only be overridden by a constant value. You must initialize a DO field with "?" in a STRUC if you want to later override that DO field with an address. This differs from the previous version of the Macro Assembler, the IBM Personal Com-puter Macro Assembler Version 2.00, which did allow addresses to override DO fields regardless of how the field was initialized.

Example

;CANNOT BE OVERRIDDEN

;CANNOT BE OVERRIDDEN

;CAN BE OVERRIDDEN

Purpose

The SUBTTL pseudo-op specifies a subtitle listed on the line after the title on each page heading.

Format SUBTTL [text]

Remarks

The text entry is cut off after 60 characters. You can give any number of SUBTTLS in a program.

Subtitles are turned off unless the SUBTTL pseudo-op is used. To turn off subtitles again for a portion of the listing after the SUBTTL

pseudo-op is given, use another SUBTTL pseudo-op but with a null entry in the text string.

SUBTTL does not cause a skip to the top of the page.

SUBTTL is usually followed by PAGE.

3-90

.TFCOND

Purpose

The .TFCOND pseudo-op toggles the default setting that controls the listing of false conditionals, then sets the current condition to that of the new default, thus ending the effect of a .SFCOND or .LFCOND

pseudo-ops.

Format .TFCOND Remarks

The .TFCOND pseudo-op does not have an operand. The .TFCOND

pseudo-op sets the current and default setting to the non-default con-dition. If the Ix option is given on the MASM command line for a file that contains .TFCOND, the Ix option reverses the effect of the .TFCOND

pseudo-op.

Note: See the discussion of false conditional blocks in Chapter 2,

"Getting Started," in this book for details.

Purpose

The TITLE pseudo-op specifies a title to be listed on the second line of each page.

Format TITLE

text

Remarks

If more than one TITLE is given, an error results. The fi rst six charac-ters of the title are used as the module name unless a NAME

pseudo-op is used. If you do not use a NAME or TITLE pseudo-op, the module name defaults to "A".

If a TITLE is not given, or if any of the six characters of the TITLE text are not valid in a name field, the TITLE is not used for the name.

The TITLE pseudo-op is placed in the source file to control the format-ting and the prinformat-ting of the lisformat-ting file produced during assembly.

The

text

entry is limited to 60 characters.

3-92

Dans le document About This Book (Page 130-142)

Documents relatifs