Global declarations.public language label... ; For TASM and MASM
or
public label language... ; for WASM
The label declared by the directive PUBLIC, becomes the program available to
another modules. So, it is possible to declare names of procedures, variables
and the constants determined by the directive EQU. The optional operand of
language (C, PASCAL, BASIC, FORTRAN, SYSCALL or STDCALL) specifies
that the label will be caused from the module written in the corresponding
language, and if necessary changes it (for example, adds _ before the first
symbol of a label).
commdist language label:type... ; for TASM
comm language distlabel:type... ; for TASM
commdistlabel:type language... ; for WASM
The directive COMM describes the general variable. Such variables are available
from all modules, and their placement in the program is defined at a configuration
stage.
Obligatory arguments of the directive COMM a label (actually a name of the
general variable) and type (BYTE, WORD, DWORD, FWORD, QWORD, TBYTE
or a structure name). The optional operand specifies "distance" (NEAR or FAR),
whether there is a variable in group of segments of DGROUP (the near variable,
for access is enough shift) or out of these segments (the distant variable, for
access is required the segment address). For models of memory of TINY,
SMALL and COMPACT by default value of this operand is accepted to NEAR.
And at last, the operand "language" works to similarly same operand for PUBLIC.
extrn language label:type... ; for MASM and TASM
extrnlabel:type language... ; for WASM
Describes label defined in other module (by means of PUBLIC). The type (BYTE,
WORD, DWORD, FWORD, QWORD, TBYTE, the name of structure, FAR,
NEAR, ABS) has to correspond to label type in that module where it was
established (the ABS type is used for constants from other modules determined
by the directive EQU). The optional operand of language works as well as for the
directive PUBLIC.
global language label:type... ; for MASM and TASM
globallabel:type language... ; for WASM
The directive GLOBAL works, as PUBLIC and EXTRN at the same time. When
the specified label is in the same module, it becomes available to other modules
as though the directive PUBLIC was executed. If the label isn't described it is
considered external and the action similar to action of the directive EXTRN is
carriedout.
33. Conditional assembling. Expressions
At the majority of programming languages there are the commands, allowing to
ignore this or that site of the program depending on performance of conditions,
for example: in language C it is carried out by preprocessor commands #if, #ifdef,
#ifndef, etc. The assembler too gives such opportunity.
if expression
endif
If value of expression zero (lie), all site of the program between IF and ENDIF
is ignored. The directive IF can be combined with ELSE and ELSEIF also:
if expression
else
endif
If value of expression zero, is assembled a program site from ELSE to ENDIF,
otherwise from IF to ELSE.
if expression1
elseif expression2
elseif expression3
else
...
endif
So, if, for example, expression 2 isn't equal to zero, the program site between the
first and second directive ELSEIF will be assembled. If all three expressions are
equal to zero, the fragment from ELSE to ENDIF is assembled. This structure of
directives can be used in that specific case similar to operators of switch/case of
languages of high level, if expressions checks of some constant on equality.
Except the general directives IF and ELSEIF assemblers support a set of special
commands, each of which checks a special condition:
IF1/ELSEIF1 if the assembler carries out the first pass of assembling;
IF2/ELSEIF2 if the assembler carries out the second pass of assembling (often doesn't
work at modern assemblers);
IFE expression/ELSEIFE expression if expression is equal to zero (in a false manner);
IFDEF label/ELSEIFDEF label if a label is defined;
IFNDEF label/ELSEIFNDEF label if a label isn't defined;
IFB <argument>/ELSEIFB <argument> if value of argument a gap (these and all
following directives are used in macrodefinitions for check of parameters);
IFNB <argument>/ELSEIFNB <argument> if value of argument not a gap (it is used in macrodefinitions for check of the given parameters);
IFDIF <arg1>, <arg2>/ELSEIFDIF <arg1>, <arg2> if arguments differ (with distinction of capital and small letters);
IFDIFI <arg1>, <arg2>/ELSEIFDIFI <arg1>, <arg2> if arguments differ (without distinction of capital and small letters);
IFIDN <arg1>, <arg2>/ELSEIFIDN <arg1>, <arg2> if arguments are identical (with distinction of capital and small letters);
IFIDNI <arg1>, <arg2>/ELSEIFIDNI <arg1>, <arg2> if arguments are identical (without distinction of capital and small letters).
Expression is a set of numbers, labels or the strings connected with each
other by operators.
Operator <> (angular brackets). The part of expression concluded in angular
brackets, isn't calculated, and applied as a string of symbols, for example:
message1 equ <foobar>
Operator () (parentheses). The part of expression concluded in parentheses, is
calculated first of all.
mov al, 2*(3+4); mov al, 14
Arithmetic operators: + (plus), (minus), * (multiplication), / (integer division),
MOD (remainder of division). They carry out the corresponding arithmetic
actions.
mov al, 90 mod 7; mov al, 6
Besides, the unary minus concerns to arithmetic operators - a minus which put
before a negative number.
Logical operators: AND, NOT, OR, XOR (excluding OR), SHL (shift to the left),
SHR (shift to the right). These operators carry out the corresponding logical
actions.
mov ax, 1234h AND 4321h; mov ax, 0220h
Operators of comparison: EQ (equally), GE (it is more or equally), is (more) than
GT, LE (it is less or equally), is (less) than LT, NE (not equally). The result of
action of each of these operators unit if the condition is satisfied, and zero if
isn't carried out.
.errnz $ gt 65535 ;If the address more than 64 KB a
mistake
Operators of addressing:
SEG expression the segment address;
OFFSET expression shift;
THIS type the current address (MASM and TASM);
The PTR type expression type redefinition;
LARGE expression 32-bit shift (TASM and WASM);
SMALL expression 16-bit shift (TASM and WASM);
SHORT expression 8-bit shift.
Date: 2015-01-29; view: 1040
|