XD accepts expressions in various places. For instance, an expression may be added to the Watches window, used in a conditional breakpoint, and even entered as an initial counter value.
The expression syntax in XD closely matches Modula-2 syntax, with the following additions and exceptions:
Type "<" Expression ">"
designates an object of type Type residing at address to which Expression evaluates (see Type casting).
Type compatibility rules are much more relaxed in comparison with Modula-2. Also, implicit type conversions are performed under certain circumstances.
Set and complex types are not currently supported.
A designatoris an expression which denotes a memory object (in other words, represents an lvalue). In some places XD expects a designator to be used.
WholeConst = DecimalConst | HexConst
DecimalConst = Digit { Digit }
HexConst = Digit { HexDigit } "H" |
"0" ("x"|"X") HexDigit { HexDigit }
Digit = "0" | "1" | "2" | "3" | "4" |
"5" | "6" | "7" | ""8 | "9"
HexDigit = Digit |
"a" | "b" | "c" | "d" | "e" | "f" |
"A" | "B" | "C" | "D" | "E" | "F"
A decimal constant is a sequence of decimal digits '0'..'9'. A hexadecimal constant is a secuence of hexadecimal digits '0'..'9', 'a'..'f', 'A'..'F', either prefixed with "0x" or "0X", or postfixed with "H". Examples:
0x05074 13H 1342
The debugger stores a whole constant in 4 bytes of memory, so the maximum value of a whole constant is 0FFFFFFFFH.
RealConst = DecimalConst "." [ DecimalConst ] [ "e" | "E" [ "+" | "-" ] DecimalConst ]
A whole decimal constant immediately followed by the period, is considered to be a whole part of a real constant. The period, in turn, may be followed by another whole decimal constant representing a fixed part. Finally, an exponent may be specified by adding the "E" or "e" character and an exponent value with an optional sign.
1. 3.14 0.1234E-10
Real constants are stored in 10 bytes format.
BooleanConst = "TRUE" | "FALSE"
CharConst = "'" character "'" | OctalConst "C"
A character constant is a single character enclosed in apostrophes:
'!' ''' 'X'
You may use names of CPU registers in expressions, prefixing their names with "@".
The debugger recognizes the following register names:
EAX, AX, AL, AH, EBX, BX, BL, BH, ECX, CX, CL, CH, EDX, DX, DL, DH ESI, SI, EDI, DI ESP, SP, EBP, BP EIP CS, SS, DS, ES, GS, FS EFL
It is possible to reference a named program entity in an expression, provided that the executable contains debug information for that entity. You may use in expressions identifiers of global and local variables and procedures, types, and enumeration type elements. In addition, it is possible to reference DLL publics.
Entities are referenced by their identifiers. In Modula-2 and Oberon-2, a program may contain more than one entity with the given identifier in different scopes. By default, the debugger starts searching for an entity in the scope of the current procedure (i.e. the procedure in which the execution point is placed) and then goes up to the scope of the compilation module which contains that procedure. Therefore, it may be necessary to qualify an entity name:
QualIdent = [ [ Component "$" ] Module "." ] { Proc "::" } Name
| Operator | For operand type | Denotes |
| + | numeric | |
| - | numeric | negation |
| NOT | whole | bit-wise complement (32-bit) |
| boolean | logical complement |
| Operator | For operand types | Denotes |
| + | numeric | addition |
| - | numeric | subtraction |
| address | difference | |
| * | numeric | multiplication |
| / | numeric | division |
| DIV | whole | division |
| MOD | whole | modulus |
| REM | whole | modulus |
| AND & | whole | bit-wise AND (32-bit) |
| boolean | logical conjunction | |
| OR | | whole | bit-wise OR (32-bit) |
| boolean | logical inclusive disjunction | |
| XOR | whole | bit-wise XOR (32-bit) |
| boolean | logical exclusive disjunction |
It is also possible to add whole numbers to and subtract from addresses.
| Operator | For operand types | Tests if the first is |
| = | scalar | equal |
| # | scalar | not equal |
| < | ordinal or real | less than |
| <= | ordinal or real | less than or equal |
| > | ordinal or real | greater than |
| >= | ordinal or real | greater than or equal |
ADR "(" Designator ")"
Returns the address of the memory object designated by Designator.
ADR(ArrayOfRecords) ADR(ArrayOfRecords[6]) ADR(ArrayOfRecords[6].FirstField)
SIZE "(" Designator ")"
Returns the size of the memory object designated by Designator.
Examples:
SIZE(ArrayOfRecords) SIZE(ArrayOfRecords[6]) SIZE(ArrayOfRecords[6].FirstField)
LOW "(" Array ")"
Returns the low index of an array designated by Array.
LOW(ArrayOfRecords)
HIGH "(" Array ")"
Returns the high index of an array designated by Array.
HIGH(ArrayOfRecords)
@PASS "(" Name | Number ")"
Returns the number of passes for the breakpoint identified by Name or Number (see BREAK - Install an event handler). Batch mode only.
@ARG "(" n ")"
Returns n-th command-line argument specified after control file name. Batch mode only.
For instance, if the breakat.xd file contains the following statements:
LOAD @ARG(1) BREAK B, PROC, @ARG(2),, Dialog START QUIT Dialog DIALOG STOP
and XD is launched as
xd /b breakat myprog M.P
it will load the program myprog, establish a breakpoint at the body of the procedure P from module M, execute the program up to that breakpoint and switch to the dislog mode.
Type "(" Designator ")"
This kind of type casting allows you to treat a memory object designated by Designator as if it had type Type. Type can be any type defined in your program and present in its debug information, or one of the predefined types.
CARD8(File.result)
PrintModes.MODE(PrintModeBox^.selected)
Type "<" Expression ">"
The result is a memory object residing at address Expression and having type Type.
The result of Expression must be compatible with the address type.
ADDRESS<ADR(result)>
DataBase.ArrayCardinal<ADR(Array2DimInteger[3])>
| Name | Type | Size |
| BYTE8 | unsigned integer | 1 |
| BYTE16 | unsigned integer | 2 |
| BYTE32 | unsigned integer | 4 |
| INT8 | signed integer | 1 |
| INT16 | signed integer | 2 |
| INT32 | signed integer | 4 |
| CARD8 | unsigned integer | 1 |
| CARD16 | unsigned integer | 2 |
| CARD32 | unsigned integer | 4 |
| REAL | real | 4 |
| LONGREAL | real | 8 |
| LONGLONGREAL | real | 10 |
| COMPLEX | complex | 8 |
| LONGCOMPLEX | complex | 16 |
| BOOL8 | boolean | 1 |
| BOOL16 | boolean | 2 |
| BOOL32 | boolean | 4 |
| CHAR8 | character | 1 |
| SET8 | bitset | 1 |
| SET16 | bitset | 2 |
| SET32 | bitset | 4 |
| ADDRESS | address | 4 |