Super Prev Next

Expressions

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 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.


Super Prev Next

Constants


Super Prev Next

Whole constants

    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.


Super Prev Next

Real constants

    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.


Super Prev Next

Boolean constants

    BooleanConst = "TRUE" | "FALSE"


Super Prev Next

Character constants

    CharConst = "'" character "'" |
                OctalConst "C"

A character constant is a single character enclosed in apostrophes:

'!' ''' 'X'


Super Prev Next

CPU registers

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


Super Prev Next

Referencing program entities

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


Super Prev Next

Operators


Super Prev Next

Unary operators

Operator For operand type Denotes
+ numeric
- numeric negation
NOT whole bit-wise complement (32-bit)
boolean logical complement


Super Prev Next

Binary operators

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.


Super Prev Next

Comparison operators

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


Super Prev Next

Built-in functions


Super Prev Next

ADR - address of a memory object

ADR "(" Designator ")"

Returns the address of the memory object designated by Designator.

    ADR(ArrayOfRecords)
    ADR(ArrayOfRecords[6])
    ADR(ArrayOfRecords[6].FirstField)


Super Prev Next

SIZE - size of a memory object

SIZE "(" Designator ")"

Returns the size of the memory object designated by Designator.

Examples:

    SIZE(ArrayOfRecords)
    SIZE(ArrayOfRecords[6])
    SIZE(ArrayOfRecords[6].FirstField)


Super Prev Next

LOW - low index of an array

LOW "(" Array ")"

Returns the low index of an array designated by Array.

LOW(ArrayOfRecords)


Super Prev Next

HIGH - high index of an array

HIGH "(" Array ")"

Returns the high index of an array designated by Array.

HIGH(ArrayOfRecords)


Super Prev Next

@PASS - number of passes for breakpoint

@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.


Super Prev Next

@ARG - access to command-line arguments

@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.


Super Prev Next

Type casting

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