SMALL Ideal (386 code generation only), MASM
Function Sets an expression's offset size to 16 bits Syntax small expression
Remarks expression is any expression or operand. SMALL converts it into a 16-bit offset. You usually use this to remove ambiguity about the size of an operation. For example, if you have enabled the 80386 processor with the P3S6 directive,
jmp [DWORD PTR ABC]
can be interpreted as either a far call with a segment and 16-bit offset or a near call using a 32-bit offset. You can remove the ambiguity by using the SMALL directive:
jmp small [DWORD PTR ABC] i16-bit offset far call
In this example, SMALL appears outside the brackets, thereby affecting the interpretation of the DWORD read from memory. If SMALL appears inside the brackets, it determines the size of the address from which to read the operand, not the size of the operand once it is read from memory.
For example, CODE SEGMENT USE32
jmp small [small DWORD PTR XYZ]
means XYZ is a 4-byte pointer that's treated as a 16-bit offset and segment, and JMP indirect through that address, reading a near JMP target address that is also a 16-bit offset.
By combining the LARGE and SMALL operators, both inside and outside brackets, you can effect any combination of an indirect JMP or CALL from a 16- or 32-bit segment to a 16- or 32-bit segment. LARGE and SMALL can also be used with other ambiguous instructions, such as LlDT and LGDT.
See also LARGE
SYMTVPE
SYMTYPE Ideal
Function Returns a byte describing a symbol
Syntax SYMTYPE <expression>
Remarks SYMTYPE functions very similarly to .TYPE, with one minor difference: If expression contains an undefined symbol, SYMTYPE returns an error, unlike .TYPE.
See also .TYPE
TBYTE Ideal
Function Forces expression to be IO-byte size
Syntax TBYTE expression
Remarks expression must be an address. The result is an expression that points to the same memory address but always has TBVTE size, regardless of the original size of expression.
You usually use TBVTE to define the size of a forward-referenced expression, or to explicitly state the size of a register indirect expression from which the size cannot be determined.
To perform this function in MASM mode, you must use the PTR directive preceded by the TBVTE type.
See also PTR
Example fld [TBYTE bxl ; sizeless indirect fst [TBYTE Xl ;forward reference X DT 0
THIS Ideal, MASM
Function Creates an operand whose address is the current segment and location counter
Syntax THIS type
Remarks type describes the size of the operand and whether it refers to code or data. It can be one of the following:
THIS
• NEAR, FAR, or PROe (PROe is the same as either NEAR or FAR, depending on the memory set using the MODEL directive)
• BYTE, WORD, DATAPTR, eODEPTR, DWORD, FWORD, PWORD, QWORD, TBYTE, or a structure name
You usually use this operator to build EQU and
=
statements.Example ptrl EQU THIS WORD ; same as following statement ptr2 LABEL WORD
,TYPE MASM
Function Returns a byte describing a symbol Syntax . TYPE name
Remarks name is a symbol that mayor may not be defined in the source file . . TYPE returns a byte that describes the symbol with the following fields:
Bit Description
o Program relative symbol 1 Data relative symbol 2 Constant
3 Direct addressing mode 4 Is a register
5 Symbol is defined 7 Symbol is external
If bits 2 and 3 are both zero, the expression uses register indirection (like [BX1, and so on).
If .TYPE returns zero, the expression contained an undefined symbol.
.TYPE is usually used in macros to determine how to process different kinds of arguments.
See also SYMTYPE
Example IF (.TYPE ABC) AND 3 ASSUME ds:SEG abc mov ax,SEG abc mov ds,ax ENDIF
;is it segment-relative?
TYPE
NPE Ideal, MASM
Function Returns a number indicating the size or type of symbol
Syntax TYPE expression
Remarks TYPE returns one of the following values, based on the type of expression:
BYTE 1
Function Removes type information from an expression
Syntax UNKNOWN expression
Remarks expression is an address. The result is the same expression, but with its type (BYTE, WORD, and so on) removed.
Use UNKNOWN to force yourself to explicitly mention a size whenever you want to reference a location. This is useful if you want to treat the location as a type of union, allowing the storage of many different data types. Incorrectly then, if you define another name without an explicit size
UNKNOWN
to reference the location, the assembler can't use the original data allocation size.
You can also use an address with UNKNOWN size much like you would use register indirect memory-referencing for one operand, and pin down the size of the operation by using a register for the other operand. By defining a name as UNKNOWN, you can use it exactly as you would an anonymous register expression such as [BX].
To perform this function in MASM mode, you must use the PTR directive preceded by the BYTE type.
See also PTR Example . DATA
workbuf DT 0
workptr EQU UNKNOWN WORKBUF .CODE
Function Returns the wid th in bits of a field in a record Syntax WIDTH recordfieldname
WIDTH record
Remarks recordfieldname is the name of any field name in a previously defined record. WIDTH returns a value of the number of bits in the record that recordfieldname occupies.
record is the name of a previously defined record. WIDTH returns a value of the total number of bits for all the fields in the record.
See also MASK
Example ;Macro determines maximum value for a field maxval MACRO FIELDNAME
value=2
REPT WIDTH FIELDNAME - 1 value = value * 2;
ENDM
WORD
value = value - 1 ENDM
WORD Ideal
Function Forces expression to be word size Syntax WORD expression
Remarks expression must be an address. The result is an expression that points to the same memory address but always has WORD size, regardless of the original size of expression.
You usually use WORD to define the size of a forward-referenced expression, or to explicitly state the size of a register indirect expression from which the size cannot be determined.
To perform this function in MASM mode, you must use the PTR directive preceded with the WORD type.
See also PTR
Example mov [WORD bxl,l iword immediate move mov [WORD Xl,l iforward reference X DW 0
XOR Ideal, MASM
Function Bitwise logical exclusive OR Syntax expressionl XOR expression2
Remarks XOR performs a bit-by-bit logical exclusive OR of each bit in expressionl and expression2. The result has a 1 in any bit position that had a 1 in one expression but not in the other, and a 0 in all other bit positions.
See also AND, NOT, OR
Example mov al,ll110000b XOR llOOOOllb iAL = OOllOOl1b