• Aucun résultat trouvé

IFIDN, IFIDNI

Dans le document Turbo AssemblefB> (Page 111-119)

Sample Directive Mode directive operates in

IFIDN, IFIDNI

IFIDN,IFIDNI Ideal, MASM

Function Starts conditional assembly block; enabled if arguments are identical Syntax IFIDN <argumentl>,<argument2>

Remarks You usually use IFION inside a macro. It tests whether its two arguments are identical character strings. Either of the arguments can be macro dummy arguments that will have real arguments to the macro call that was substituted before performing the comparison. If the two strings are identical, the statements within the conditional block are assembled. The two strings are compared on a character-by-character basis; case is significant. If you want case to be ignored, use the IFIONI directive.

Use the ENOIF directive to terminate the conditional assembly block.

See also ELSE, ENDIF, IF, IF1, IF2, IFB, IFOEF, IFDIF, IFOIFI, IFE, IFIDNI, IFNB, IFNOEF

Example RDWR MACRO BUF, RWMODE mov ax,BUF

IFIDN <RWMODE>,<READ>

call ReadIt ENDIF

IFIDN <RWMODE>,<WRITE>

call WriteIt ENDIF

ENDM

IFNB Ideal, MASM

Function Starts conditional assembly block, enabled if argument is nonblank Syntax IFNB <argument>

Remarks If argument is nonblank, the statements within the conditional block are assembled. Use IFNB to test whether a macro was called with a real argument to replace the specified dummy argument.

You must always surround the argument to be tested with angle brackets

« ».

Use the ENDIF directive to terminate the conditional assembly block.

See also ELSE, ENOIF, IF, IF1, IF2, IFB, IFDEF, IFDIF, IFDIFI, IFE, IFION, IFIONI, IFNDEF

Example PopRegs MACRO REG!, REG2

IFNB <REG1>

pop REG1 ENDIF IFNB <REG2>

pop REG2 ENDIF ENDM

IFNB

IFNDEF Ideal, MASM

Function Starts conditional assembly block; enabled if symbol is not defined Syntax IFNDEF symbol

Remarks If symbol has not yet been defined in the source file, the statements within the conditional block are assembled.

Use the ENDIF directive to terminate the conditional assembly block.

See also ELSE, ENDIF,IF, IF1, IF2, IFB, IFDEF, IFDIF, IFDIFI, IFE, IFIDN, IFIDNI, IFNB Example IFNDEF BufSize

%INCL

BufSize EQU 128 ENDIF

;define buffer size if not defined

Function Allows listing of include files Syntax %INCL

Ideal, MASM

Remarks Use O/OINCL after a O/ONOINCL directive has turned off listing of INCLUDE files. This is the default INCLUDE file listing mode.

See also O/ONOINCL Example %INCL

INCLUDE DEFS.INC ;contents appear in listing

INCLUDE

INCLUDE Ideal, MASM

Function Includes source code from another file

Syntax Ideal mode:

INCLUDE II filename"

MASMmode:

INCLUDE filename

Remarks filename is a source file containing assembler statements. Turbo Assembler assembles all statements in the included file before continuing to assemble the current file.

filename uses the normal DOS file-naming conventions, where you can enter an optional drive, optional directory, file name, and optional extension. If you don't provide an extension, .ASM is presumed.

If filename does not include a directory or drive name, Turbo Debugger first searches for the file in any directories specified by the II command-line option and then in the current directory.

You can nest INCLUDE directives as deep as you want.

Notice that in Ideal mode, you must surround the filename with quotes.

Example ; MASM mode INCLUDE MYMACS.INC

;Ideal mode INCLUDE "DEFS.INC"

;include MACRO definitions

;include EQU definitions

INCLUDELIB Ideal, MASM

Function Tells the linker to include a library

Syntax Ideal mode:

INCLUDELIB II fil ename"

MASMmode:

INCLUDELIB filename

Remarks filename is the name of the library that you want the linker to include at link time. If you don't supply an extension with filename, the linker assumes .LIB.

Use INCLUDELIB when you know that the source file will always need to use routines in the specified library. That way you don't have to

remember to specify the library name in the linker commands.

INCLUDELIB

Notice that in Ideal mode, you must surround the filename with quotes.

Example INCLUDELIB diskio ;includes DISKIO.LIB

INSTR Ideal, MASM51

Function Returns the position of one string inside another string Syntax name INSTR [start, J stringl, string2

Remarks name is assigned a value that is the position of the first instance of string2 in stringl. The first character in stringl has a position of one. If string2 does not appear anywhere within stringl, a value of

a

is returned.

See also CATSTR, SIZESTR, SUBSTR

Example COMMAPOS INSTR <aaa, bbb>, <, > ;COMMAPOS :: 4

IRP Ideal, MASM

Function Repeats a block of statements with string substitution Syntax IRP parameter, <argl [, arg2J •.• >

statements ENDM

Remarks The statements within the repeat block are assembled once for each argument in the list enclosed in angle brackets. The list may contain as many arguments as you want. The arguments may be any text, such as symbols, strings, numbers, and so on. Each time the block is assembled, the next argument in the list is substituted for any instance of parameter in the enclosed statements.

You must always surround the argument list with angle brackets « », and arguments must be separated by commas. Use the ENDM directive to end the repeat block.

You can use IRP both inside and outside of macros.

See also IRPC, REPT

Example IRP reg, <ax, bx, ex, dx>

push reg ENDM

IRPC

IRPC Ideal, MASM

Function Repeats a block of statements with character substitution

Syntax IRPC parameter, string statements

ENDM

Remarks The statements within the repeat block are assembled once for each character in string. The string may contain as many characters as you want. Each time the block is assembled, the next character in the list is substituted for any instances of parameter in the enclosed statements.

Use the ENDM directive to end the repeat block.

You can use IRPC both inside and outside of macros.

See also IRP, REPT Example IRPC LUCKY, 1379

DB LUCKY ;allocate a lucky number ENDM

This creates 4 bytes of data containing the values 1,3,7, and 9.

JUMPS Ideal, MASM

Function Enables stretching of conditional jumps to near or far addresses

Syntax JUMPS

Remarks JUMPS causes Turbo Assembler to look at the destination address of a conditional jump instruction, and if it is too far away to reach with the short displacement that these instructions use, it generates a conditional jump of the opposite sense around an ordinary jump instruction to the desired target address. For example,

jne xyz

becomes

je @@A jrnp xyz

@@a:

If the destination address is forward-referenced, you should use the NEAR or FAR operator to tell Turbo Assembler how much space to allocate for the jump instruction. If you don't do this, inefficient code may be

JUMPS

generated, due to the nature of single-pass assembly. You can use the multi-pass capability of Turbo Assembler (via the 1m command-line switch) to force the most efficient code to be generated, but it may lengthen the assembly process, depending on the number of passes required. Therefore, it's recommended that you use the NEAR or FAR operator in the first place.

This directive has the same effect as using the IJJUMPS command-line option.

See also NOJ UM PS

Example JUMPS ;enable jump stretching jne SHORT @A jcan reach A

@@A:

LABEL Ideal, MASM

Function Defines a symbol with a specified type Syntax Ideal mode:

LABEL name type MASMmode:

name LABEL type

Remarks name is a symbol that you have not previously defined in the source file.

type describes the size of the symbol and whether it refers to code or data.

It can be one of the following:

See also

II NEAR, FAR, or PROC. PROC is the same as either NEAR or FAR, depending on the memory set using the MODEL directive

• BYTE, WORD, DATAPTR, CODEPTR, DWORD, FWORD, PWORD, aWORD, TBYTE, or a structure name

The label will only be accessible from within the current source file, unless you use the PUBLIC directive to make it accessible from other source files.

NotiCe that in Ideal mode, name comes after the LABEL directive.

Use LABEL to access different-sized items than those in the data structure;

see the example that follows.

Example WORDS LABEL WORD jaccess "BYTES" as WORDS BYTES DB 64 DUP (0)

mov WORDS[2],1 ;write WORD of 1

.LALL

.LALL MASM

Function Enables listing of macro expansions Syntax . LALL

See also %MACS

.LFCOND MASM

Function Shows all statements in conditional blocks in the listing Syn tax . LFCOND

Remarks .LFCOND enables the listing of false conditional blocks in assembly listings . . LFCOND is not affected by the IX option.

See also %CONDS

%LINUM Ideal, MASM

Function Sets the width of the line-number field in listing file Syntax %LlNUM size

Remarks %LiNUM allows you to set how many columns the line numbers take up in the listing file. size must be a constant. If you want to make your listing as narrow as possible, you can reduce the width of this field. Also, if your source file contains more than 9,999 lines, you can increase the width of this field so that the line numbers are not truncated.

The default width for this field is 4 columns.

Example %LlNUM 5 iallows up to line 99999

%LIST Ideal, MASM

Function Shows source lines in the listing Syntax %LIST

Remarks %LlST reverses the effect of a %NOLIST directive that caused all listing output to be suspended.

,LIST

0/0 LI ST

This is the default listing mode; normally, all source lines are placed in the listing output file.

See also .LlST, %NOLlST, .XLlST Example %LIST

jrnp xyz ithis line always listed

Function Shows source lines in the listing Syntax .LIST

See also %LlST Example .XLIST

INCLUDE MORE. INC .LIST

iturn off listing

;turn on listing

MASM

LOCAL Ideal, MASM

Function Defines local variables for macros and procedures Syntax In macros:

LOCAL symbol [,symbol] •••

In procedures:

LOCAL name: type [: count] [, name: type [:count]] ••• [=symbol]

Remarks LOCAL can be used both inside macro definitions started with the MACRO directive and within procedures defined with PROC. It behaves slightly differently depending on where it is used.

Within a macro definition, LOCAL defines temporary symbol names that are replaced by new unique symbol names each time the macro is expanded. The unique names take the form of ??number, where number is hexadecimal and starts at 0000 and goes up to FFFF.

Within a procedure, LOCAL defines names that access stack locations as negative offsets relative to the BP register. The first local variable starts at BP (type X count). If you end the argument list with an equal sign (=) and a symbol, that symbol will be equated to the total size of the local symbol block in bytes. You can then use this value to make room on the stack for the local variables.

Dans le document Turbo AssemblefB> (Page 111-119)

Documents relatifs