Stony Brook Modula-2 archive
Data Expressions
Data types
The debugger works with all of the data types you work with in Modula-2 or Ada95. However, the debugger uses only a few data types when evaluating expressions:
- When evaluating integer type expressions, the debugger always uses an internal signed data type with precision equal to or better than the highest precision integer type available in any Stony Brook language (for the target platform).
- When evaluating real type expressions, the debugger always uses an internal floating point type with precision equal to or better than the highest precision floating point type available in any Stony Brook language (for the target platform).
- When evaluating Set and Boolean type expressions, the debugger handles them as they are handled in Modula-2, except that set operators +, -, /, and * are allowed only on sets no more than eighty elements.
Operands are automatically converted to these types when evaluating expressions.
Operands
The following is a list of all operand types, with examples.
Simple variables
Format: | [module.]variablename | Definition: | Variables can be: Local variables of the current procedure Global variables visible in the module containing the current procedure Global variables of other modules if qualified with the module name. | Examples: | NumVars ScreenStuff.NumVars |
Subscripted variables
Format: | variable[expression {,expression}]{[expression,expression]} | Definition: | variable must refer to an array or string type variable. The variable is subscripted by the expressions contained in the square brackets. When debugging an Ada95 program the parentheses can also be used to subscript arrays. | Examples: | Vector[2] Matrix[i, j] Matrix[i][j] Matrix(i, j) Ada95 |
Enumeration names
Format: | name | Definition: | Enumeration names are compatible with unsigned integers. Name can be any enumeration name. | Example: | CopyAll |
Array slices
Format: | variable[expression..expression] | Definition: | An array slice refers to a sub-array of the array variable: that is, to a smaller array consisting of the components between the two expressions. | Example: | MenuData[start[i]..end[i]] |
Pointer dereferences
Format: | variable^ | Definition: | Pointer dereferences refer to the data pointed to by a pointer variable. | Examples: | RecPointer^.Pointer Table[i]^ |
Field selectors
Format: | variable.fieldname | Definition: | Field selectors refer to the fields of record and object type variables. | Example: | RecPointer^.name |
Registers
Format: | @registermnemonic | Definition: | Registers are considered to be of type WORD and can be modified. Use these register names on IA-32: EAX EBX ECX EDX ESP EBP ESI EDI AX BX CX DX SP BP IS DI ES CS SS DS FS GS IP FL On RISC processors use r0..r31 for integer registers. f0..f31 for floating point registers. | Examples: | @EAX @CS @BX @r5 |
CPU Flag Masks
Format: | !flagmnemonic (IA-32 only) | Definition: | Use these flag names: CF = Carry PF = Parity AF = Auxiliary carry ZF = Zero SF = Sign TF = Trap IF = Interrupt DF = Direction OF = Overflow The flag masks contain a numeric value which corresponds with the flag position within the flag register. These values are generally useful for setting, clearing, or toggling the flags. | Examples: | FL := FL BOR !CF (* Set Carry flag *) FL := FL BAND (BNOT !DF) (* Clear Direction flag *) FL := FL BXOR (BNOT !PF) (* Toggle Parity flag *) |
Public symbols in Modula-2
Format: | %publicname | Definition: | Public symbols are names that are defined as public in object modules. In Modula-2, the variables and procedures declared in Definition modules are declared as public. This form is useful for referring to global variables in modules that you have not compiled with symbolic debug information. The public symbol name declared in Modula-2 is: ModuleName_SymbolName Hint: If no type information is available the symbol should be coerced to the correct type. Generally, this format is never used in favor of including and using symbolic debug information. | Example: | %SYSTEM_PrefixSeg, %MyModule_MProcedure:MyType |
Public symbols in Ada95
Format: | %publicname | Definition: | Public symbols are names that are defined as public in object modules. In Ada95, the variables and procedures declared in library Package specification modules are declared as public. This form is useful for referring to global variables in modules that you have not compiled with symbolic debug information. The public symbol name declared in Ada95 is: ModuleName_SymbolName Note: For Ada95 procedures the compiler uses additional information in the public symbol name for handling procedure overloading. Hint: If no type information is available the symbol should be coerced to the correct type. Generally, this format is never used in favor of including and using symbolic debug information. | Example: | %SYSTEM_PrefixSeg, %MyModule_MProcedure:MyType |
Absolute addresses
Format: | [[segment:]offset] where: segment and offset are expressions. segment is only applicable to IA-32 processors. segment is optional and is assumed to be @DS if not supplied. On IA-32. If the offset uses @EBP (@BP) or @ESP (@SP), @SS is assumed for the segment. | Definition: | The absolute location specified is the result of the expression. If no type is supplied, a memory hex dump window is displayed. | Examples: | [1FFEH] (@DS assumed here) [@EBP+4] (@SS assumed here) [@ES:@BX+@SI+0FFFEH] [@r5] |
Signed and unsigned integer constants
Format: | [-]digit {digit}[|B|O|H] | Definition: | Decimal constants are represented the same as they are in Modula-2. You can optionally use a radix letter after a number: B for binary O for octal H for hexadecimal. Hexadecimal numbers must, however, start with a digit. | Examples: | 1 25 -15 1011B 0FFFFH |
Floating point constants
Format: | [-]digit. {digit}[E[-]digit {digit} | Definition: | Floating point constants are interpreted the same as they are in Modula-2 programs. | Examples: | 1.5 6E-10 -0.3 |
String constants
Format: | ["string"|'string'] | Definition: | String constants specify literal strings. | Examples: | "this is a string" 'this is a "quoted" string' |
Character constants
Format: | ["char"|'char'] | Definition: | String constants containing a single character are treated as character types. | Example: | 'A' |
Parentheses
Format: | (expression) | Definition: | Parenthesized expressions allow you to override the normal precedence of operators. The expression enclosed in parentheses is fully evaluated before being used as an operand. | Example: | (Count1 + Count2) * Size |
Operators
Operators specify operations on operands or expressions. Operator precedencedetermines which operators are evaluated first in an expression. The orderof operator precedence is:
Unary | : NOT | MulOperator | : =, /, DIV, MOD, AND, BAND | AddOperator | : +, -, OR, BOR, BXOR | Relation | : +, #, <>, <, <=, >, >=, IN |
The following is a list of the operators, including format, examples, and somediscussion.
Relational operators: =, #, <>, /=, <, >, <=, >=
Format: | expression op expression Results in a value of type BOOLEAN. | Definition: | #, <> and /= all mean not equal. All types except structured types are allowed with the following exceptions and restrictions: Both sides of the expression must be compatible types. Only =, #, /= and <> are implemented for strings, and the string must be 80 characters or less. < and > are not defined for Modula-2 SETs. | Examples: | Count = 25 Count >= MaxCount name = "Norman" |
NOT operator
Format: | NOT expression | Definition: | BOOLEAN expressions are the only allowed types. | Examples: | NOT done NOT (Count = 1) |
IN operator
Format: | expression IN expression | Definition: | Set test INCLUSION operator. Results in a value of type BOOLEAN. | Examples: | CopyAll IN Attributes number IN LottoNums |
AND, OR operators
Format: | expression op expression | Definition: | BOOLEAN and signed and unsigned integers are the only allowed types. If the expression is of type BOOLEAN, a Boolean evaluation is performed and a Boolean result is returned. If the expressions are integer types, a bitwise operation is performed. | Examples: | (Card = 1) AND (Int = -1) Cursor AND CursorType |
BAND, BOR, BXOR operators
Format: | expression op expression | Definition: | BOOLEAN and signed and unsigned integers are the only allowed types. A bitwise AND, OR, XOR operation is performed. | Examples: | (Card = 1) BAND (Int = -1) Cursor BXOR CursorType |
Operators +, -, *, /, DIV, MOD, REM
Format: | expression op expression | Definition: | All types except structured types are allowed. SET types must have 80 or less elements (10 bytes). | Examples: | x * 25 - 3 Set1 / Set2 (XOR operation) |
Overriding data types
You can override the type of any variable, public symbol, or absolute address,to make it any defined type.
The format is:
[variable|symbol|address]:typespec
where typespec is:
[TypeName|POINTER TO TypeName|ARRAY OF TypeName]
The TypeName is scoped according to the current procedure and module.
For example:
card:Integer
[@ES:@BX]:POINTER TO MyRec
[0]:ARRAY OF ADDRESS
Built-in data type names
The following standard type names are built into the debugger.
Type | Description | SBYTE | Signed BYTE | UBYTE | Unsigned BYTE | SWORD | Signed WORD (16-bit) | UWORD | Unsigned WORD | SDWORD | Signed DWORD (32-bit) | UDWORD | Unsigned DWORD | SQWORD | Signed QWORD (64-bit) | (REAL, SINGLE) | 32-bit IEEE Floating Point value | (LONGREAL, DOUBLE) | 64 Bit IEEE Floating Point value | BOOLEAN | 8 Bit BOOLEAN value | WORDBOOL | 16-bit BOOLEAN value | LONGBOOL | 32-bit BOOLEAN value | ACHAR | 8-bit Character | UCHAR | 16-bit UNICODE character | ASCIIZ | Generic NUL terminated string | ASCIIZU | Generic NUL terminated UNICODE string | STRING | "Pascal" length byte string | ADDRESS | Address Type | COMPLEX | 32-bit Modula-2 complex number | LONGCOMPLEX | 64-bit Modula-2 complex number | WINMESSAGE | Windows formatted message. This type looks at the ordinal value and display the Windows WM_xxx constant name if it exists. |
You can also use any type name from your program if it is in a module that wascompiled with symbolic debug information enabled.
Note: The language predefined TYPEs (such as INTEGER, WORD,...) will bedefined (by the debug information) in modules where they are used.
© Norman Black, Stony Brook Software. Reproduced with permission.
|