home *** CD-ROM | disk | FTP | other *** search
-
- TP&Asm Integrated Compile-Time Assembler Version 2.0
- TP&Asm-M Memory Mode Assembly Language Development Tool Version 2.0
-
- Copyright (c) 1989 Richard W. Prescott
- All Rights Reserved
-
- ═══════ Built-In Assembly Language Support for Turbo Pascal Compilers ═══════
-
- All brand and product names mentioned herein are trademarks or registered
- trademarks of their respective holders.
-
- ┌─────────────────────────────────────────────────────────────────────┐
- │ This file contains detailed reference information to enable you to │
- │ make effective use of the TP&Asm assembly environment. For general │
- │ information on getting started please see the file README. │
- └─────────────────────────────────────────────────────────────────────┘
-
-
- The following topics are described below:
-
- 8. Error Messages
- 9. Trouble Shooting
-
-
- The following additional topics are covered in the separate file
- TP&ASM.REF:
-
- 1. Command Line Options
- 2. The Assemble Statement
- 3. The Asm Statement
- 4. The Internal Statement
- 5. General Assembler Syntax
- 6. TP&Asm-specific Options
- 7. Supported Mnemonics
-
-
-
-
- 8. Error Messages
-
- The following is an alphabetical listing of all syntax error
- messages generated by the current version of TP&Asm, together with
- very brief explanations of messages which are not self-explanitory.
- All assembler syntax errors use error number 200.
-
-
-
- [Symbol] Must be declared FORWARD or in INTERFACE
- INTERNAL Assembly PROCs must be defined in your Pascal Code
-
- "Dd $" Not Permitted
-
- "Proc/Function + Offset" Not Allowed
- The Turbo linker does not permit reference to Pascal Procedures
- and Functions with non-zero numeric offsets.
-
- (INTERNAL) Cannot refer to parameters/result by name
- (INTERNAL) Proc definition expected
-
- (WARNING) Altered BP May Prevent Local Variable Access
- (WARNING) Altered Ds May Prevent Access to Turbo VARs
- (WARNING) Altered Seg May Prevent Access to Turbo VARs
- Ss and Bp must be restored before referencing Local variables and
- parameters by name. Ds must be restored before referencing Global
- variables and Typed Constants by name.
-
- (WARNING) ES may be undefined
- You have explicitly or implicitly (via a String mnemonic) used the
- Es register without initializing it.
-
- (WARNING) May Require Segment Override
- TP&Asm will use the default segment for indexed memory references
- which do not contain a named variable offset. The default segment
- is Ss for references involving the Bp register, and Ds for all
- others.
-
- (WARNING) Possible invalid operand or forward reference
-
- Assembler Symbol Overflow
- You have attempted to define more than 4K of symbols in the
- current Assembly block or Internal PROC. Break into smaller
- blocks or convert some code or data labels to Pascal using
- LABEL and VAR statements.
-
- Bad Identifier Character
- Bad Identifier Start
- TP&Asm Code and Data labels may contain only alphanumeric
- characters and the special characters @, _, $, and ?. They
- must begin with a letter, @, or _.
-
- Base or Index Register Required
- When Presumptions are disabled you must supply a proper index
- register (usually [Bp]) to reference local VARs.
-
- BY requires Byte operand
- Byte operand required
-
- Cannot Call Short
- The processor does not support a two byte Call instruction
-
- Cannot DUP Address Reference
- Cannot DUP Forward Reference
-
- Cannot EQUate to Assembly Variable
- Cannot EQUate to Forward Symbol
- Cannot EQUate to Pascal Symbol
- Operands to EQU must be numeric expressions or indexed memory
- references.
-
- Cannot Nest Far Procs
- All Assemble PROCs and nested INTERNAL PROCs must be NEAR.
-
- Cannot nest address reference
- Cannot Nest Memory Reference
- Cannot Nest Pascal Symbols
- Parentheses may contain ONLY constants and numeric expressions.
-
- Cannot Pop CS
-
- Code Label Duplicates Pascal Symbol
- Since TP&Asm allows forward references to Code labels, Code labels
- must be unique from all Pascal symbols. Data labels may redefine
- Pascal symbols (within the current Assemble/Internal statement).
-
- Colon or data size specifier required
- Code labels require ':' or 'PROC'. Data labels require a data
- definition directive (DB, DW, DD, EQU) or size qualifier (B, W,
- Byte Ptr, etc).
-
- CsData MUST be First Code in Unit
- A Procedure or Function BEGIN block has preceded the CsData
- statement. The CsData statement, if used, must be the first
- code block in the program or unit.
-
- Data Name expected
- Labels are required in Data Segment data allocation statements
-
- Duplicate Label
- Empty quote
- ENDP Expected
-
- EQUate to CODE Symbol not supported
- Operands to EQU must be numeric expressions or indexed memory
- references.
-
- Error In Define Data
-
- Error in IF statement
- A conditional statement in an (Assembly) Inline directive/MACRO
- generated no code or exceeded 127 bytes.
-
- Error In Jump Statement
- The operand to a Call or Jmp must be a single Pascal or Assembly
- label, a single Pascal Procedure or Function identifier, or a
- variable or memory expression.
-
- Error in Mnemonic
- Invalid symbol found in mnemonic field
-
- Full record specification required
- References to record components must be prefixed by a valid
- Record Variable or TYPE qualifier, as discussed in the notes
- to the section on General Assembler Syntax.
-
- Incorrect Syntax
- When the 'Offset' qualifier is used, the DESTINATION operand
- must be a Register; 'Mov Var1,Offset Var2' is not permitted.
-
- INTERNAL Identifier required before NewLine
- You must specify a unique Pascal identifier on the same line as
- the keyword 'Internal'. See sample file INTERNAL.PAS.
-
- Invalid Absolute CSeg Reference in Assembly MACRO
- Inline Directives must not make direct reference to code or data
- labels except in Direct control transfer instructions.
-
- Invalid Absolute CSeg Reference
- Location counter ($) references and data type references to code
- and data labels are permitted only in the FIRST code block within
- any program or unit. Location counter ($) references are not
- permitted in Jumps or EQUates, nor in (Assembly) Inline directive/
- MACROS. Note: THIS MESSAGE MAY INDICATE AN UNDEFINED PASCAL
- SYMBOL. If the undefined symbol is a forward referenced ASSEMBLY
- symbol, move the code to the FIRST Proc/Function in the Program or
- Unit.
-
- Invalid Address Reference
- You have specified a sum or difference of symbol names that does
- not resolve to a valid address, displacement, or pure constant.
- NOTE: Mov Ax,PasVar1+PasVar2 is not valid because it instructs the
- assembler to place MemW[Dseg: OFS(PasVar1) +OFS(PasVar2)] into Ax.
- ( Instead you must: Mov Ax,PasVar1 and then: Add AX,PasVar2 ).
- Please consult a reference on assembly language programming.
-
- Invalid Base Specification [BX] + (implicit) [BP]
- Disable presumptions to use [BX] in place of the presumed [BP]
- indexing for local variables. (an Ss override will then be
- required, as the processor default segment for [Bx] is Ds).
-
- Invalid BIT Syntax
- Example: Or Dx,Bit 6 ; same as Or Dx,64
-
- Invalid Byte/Word Combination
- Use B or W to override defined variable size:
- Mov Al,B IntegerVar
- Mov Ax,Word Ptr ByteVar
-
- Invalid Byte/Word/Dword Combination
- You have attempted to use a DWord POINTER as a Byte or Word VALUE,
- or the reverse. (Remember that VAR parameters are DWord Pointers).
- Use B, W, or D to override defined variable size.
-
- Invalid Code Reference
- Within the FIRST code block, expressions of the form
- "label1-label2+numeric offset"
- are permitted, where the labels are code or data labels within the
- current assemble statement.
-
- Invalid Conditional Transfer to Proc/Function
- Pascal Procedure and Function identifiers are not permitted as
- operands to conditional jumps and loops.
-
- Invalid define string operation
- Arithmetic is not permitted on DB strings with length >= 2.
-
- Invalid Final Jump or Forward Reference
- TP&Asm does not permit the LAST statement in an (Assembly) Inline
- directive/MACRO to be a zero displacement jump or forward
- reference.
-
- Invalid Forward Absolute CSeg Reference
- THIS MESSAGE MAY INDICATE AN UNDEFINED PASCAL SYMBOL. If the
- undefined symbol is a forward referenced Assembly symbol, move
- the code to the FIRST Proc/Function in the Program or Unit.
-
- Invalid Forward Reference in ASM Statement
- Forward reference to undefined labels is not permitted in an
- ASM statement.
-
- Invalid Forward Symbol
- Assembly Data labels cannot be forward referenced. Forward
- Reference to Code labels is permitted only in the FIRST code
- block in a Program or Unit.
-
- Invalid IF Condition
- Invalid IF Syntax
- Example: IF A Xor Cx,Cx ; Valid conditions are formed by removing
- the 'J' from any conditional jump mnemonic EXCEPT jCXZ.
-
-
- Invalid Indirect Option
- Invalid Indirect Register
- Indexed memory expressions can combine one base (Bx OR Bp), one
- index (Si OR Di), and a numeric or symbolic offset. In addition,
- a segment override and a memory size qualifier may be specified.
- Examples: Inc B Es:[Bx+Di+SymName+2] ; Shl SymName[Si],1 ; etc.
-
- Invalid Jmp Specification
-
- Invalid Label or Proc/Function in Memory Reference
- Pascal Labels and Procedure and Function identifiers are not
- permitted in memory expressions.
-
- Invalid memory operation
- Arithmetic on memory references is limited to addition and
- subtraction. Four function arithmetic is supported for constants
- and numeric expressions only.
-
- Invalid Numeric Format
-
- Invalid Offset to Pascal Proc/Function Reference
- The Turbo linker does not permit reference to Pascal Procedures
- and Functions with non-zero numeric offsets.
-
- Invalid operand
- Invalid operand combination
- Invalid operand or forward reference
- Please see USAGE.PAS for examples of valid operands for the given
- mnemonic and/or consult an assembly language reference.
-
- Invalid prefix combination
- The processor does not support LOCK + repeat prefix
-
- Invalid Proc/Function Call in Assembly MACRO
- Inline Directives cannot make direct calls to Pascal Procedures
- and Functions. Indirect calls are permitted.
-
- Invalid quoted operand
- Quoted operands used as constants in numeric expressions must have
- length 1 or 2. Example: Add Al,'A'-1; Quoted WORD operands have
- most significant CHAR first, thus: Mov Ax,'Ax'; puts 'x' in AL.
- Note that DB 'ab'; and DW 'ba'; BOTH store the 'a' first since
- Word data is stored in 'Byte-reverse' format.
-
- Invalid Reference in Assembly MACRO
- Inline Directives must not make direct reference to code or data
- labels except in Direct control transfer instructions.
-
- Invalid Reference to Pascal Label
- Pascal labels may not be referenced in data manipulation
- instructions. For example, "Mov Bx,Offset PasLabel" is not
- permitted. "Mov Bx,Offset AsmLabel" is permitted in the FIRST
- code block of a Program or Unit.
-
- Invalid Relocatable Reference in Assembly MACRO
- Inline Directives cannot make reference to Pascal Procedure
- and Function offsets. VAR and (Typed) CONST offsets are
- permitted.
-
- Invalid SEG Syntax
- Only "SEG DATA" is permitted.
-
- Invalid Segment Operation
- Segment registers are allowed as operands to PUSH, POP, and MOV.
-
- Invalid Shift Count
- The 8086/88 processor supports only 'shift by 1' and 'shift by CL'
- TP&Asm supports 'shift by n' by coding repeated shifts. The shift
- count n must be in [1..15]. NOTE: This coding convenience OFTEN
- generates longer and slower code than a shift using CL.
-
- Invalid statement in CsData
- CsData permits only data allocation statements: Db, Dw, and Dd.
-
- Invalid Symbol
- Possible invalid forward data reference
-
- Invalid syntax
- A colon is not permitted within parentheses.
-
- Invalid TP&Asm Directive
- The combination ;# is reserved for TP&Asm directives.
-
- Invalid use of > or <
- > and < may be used only as prefixes to valid Pascal symbols or
- (> only) a valid Assembly code label.
-
- Invalid Use of String Prefix
- Only string mnemonics allow repeat prefixes.
-
- Invalid use of Type Qualifier
- Record TYPE qualifiers must be followed by a "." and a valid
- component for the given TYPE, with no embedded spaces.
-
- Invalid use of Unit Qualifier
- UnitName qualifiers must be followed by a "." and a Global
- Pascal identifier from the appropriate Unit, with no embedded
- spaces.
-
- Label or Proc/Function Reference Required
- The operand to a Direct Call or Jmp must be a single Pascal
- or Assembly label or a single Pascal Procedure or Function
- identifier.
-
- MemArray Reference Not Supported
-
- Memory operand required
- LEA, LDS, and LES require the source operand to be a memory
- expression.
-
- Mismatched Parentheses
-
- Multiple Memory Reference
- The processor does not support memory to memory operations.
- Note however that Movsb and Cmpsb are effectively memory to memory
- versions of Mov and Cmp.
-
- Multiple Prefix
- Multiple Segment Override
- Multiple Segment Prefix
- Conflicting multiple prefix specifications is an error. (TP&Asm
- supports Segment+Repeat prefix combinations, however, by coding
- an appropriate loop).
-
- Multiple segments not allowed
- Assemble allows at most one (optional) Segment statement.
- Internal allows one (optional) Data Segment and one (required)
- Code segment. DSeg and CSeg are acceptable synonyms for "Data"
- and "Code".
-
- Nested BY Not Allowed
- Nested DUP not allowed
- Nested IFs not allowed
-
- Nesting limit exceeded
- TP&Asm supports 5 levels of parentheses.
-
- No Code Assembled
- An Assemble statement or Internal PROC generated no output code.
-
- Output Line Code Limit Exceeded
- A single assembly source line is limited to 28 bytes of output
- code and/or 5 relocatable references. Long DB strings should be
- broken or declared in Pascal. Push, Pop, Dw, etc, with repeated
- operands may (very rarely) need to be coded with fewer repeats on
- a single line. (Total output for the entire assembly is NOT
- LIMITED).
-
- Parentheses not allowed in memory expressions
-
- PAS Statement Invalid in INTERNAL
- The PAS statement is not permitted within Internal PROCs.
-
- PortArray Reference Not Supported
-
- Proc Model does not match prior definition
- You have used PROC NEAR in an Internal statement but the Pascal
- declaration was FAR (or the reverse).
-
- Quotes MisMatch
-
- Record Component Expected
-
- Reserved Word Error
-
- Short Jump Out Of Range
- Conditional jumps in (Assembly) Inline directive/MACROs are
- limited to about 127 bytes forward or back.
-
- Specify CMPSB or CMPSW
- Specify LODSB or LODSW
- Specify MOVSB or MOVSW
- Specify SCASB or SCASW
- Specify STOSB or STOSW
- Specify Word Or Byte
-
- SysFunc Reference Not Supported
- SysProc Reference Not Supported
- Non-standard System Proc/Functions cannot be called from assembly
- language.
-
- TP&Asm: Memory Mode Version cannot Compile to Disk
- Unrecognized Mnemonic
-
- Unresolved Reference to [Symbol]
- A reference was made to a symbol that was never defined in Pascal
- or Assembly. Forward reference to assembly labels which are not
- defined in a Pascal LABEL statement must be resolved within the
- current Assemble statement or Internal PROC.
-
- Unsupported ORG Value
- TP&Asm ignores ORG except to report an error if the specified
- value is not 0 or $100.
-
- Unsupported Radix Value
- TP&Asm supports Radix 10 and Radix 16.
-
- Unsupported Reserved Word
-
-
-
- 9. Trouble Shooting
-
-
- Examining the TP&Asm Assembly.
-
- The utility program EXAMINE.EXE in the archive TP-XMN is provided
- to facilitate verification that the TP&Asm Assembler has correctly
- assembled your assembly source code. When used in conjunction with
- DEBUG.COM (on your DOS disk) it generates a "side by side" display
- of each Pascal or assembly source statement together with its
- corresponding DEBUG disassembly. The disassembly you see is the
- same as you would get if you simply used DEBUG.COM to directly
- disassemble the compiled EXE file. By displaying each piece of the
- disassembly alongside the corresponding assembly source statement,
- it is a simple matter to compare the two to verify proper assembly.
- Command line options permit you to limit the output to a range
- containing the assembly code, and to direct the output to the
- screen, printer, or a file.
-
- EXAMINE.EXE requires a compiled EXE file and a MAP file as produced
- by Turbo/TPC Version 5.0 or Turbo/TPC Version 4.0 together with
- TPMAP. Please refer to the file EXAMINE.DOC in the archive TP-XMN
- (or on your distribution disk) for instructions on how to use
- EXAMINE.EXE.
-
- Full source code to EXAMINE.EXE is provided to registered users of
- TP&Asm.
-
- The TP&Asm assembly may also be examined using a symbolic debugger
- such as the Turbo Debugger. Since TP&Asm is fully integrated with
- Turbo Pascal, MAP files produced with both Version 4.0 and 5.0
- compilers contain Line Number detail for all assembly sections
- (Except [Assembly] Inline Directive/MACROs), permitting source level
- debugging in any MAP-file compatible debugger.
-
-
- Trouble Shooting Using a Debugger.
-
- Turbo Pascal Version 5.0 provides an integrated debugger within the
- Integrated Development Environment. Since Built-in assembly support
- was not anticipated, however, the integrated debugger provides no
- means of monitoring the state of the CPU registers and flags.
- TP&Asm/TP&Asm-M provides support for monitoring and modifying the
- CPU registers and flags through the Unit ASMWATCH which is provided
- on the distribution disk and in the archive TP-ASM.
-
-
- Version 5.0 Users: Using ASMWATCH.
-
- With Turbo Version 5.0, you can trace (F7 Trace into, F4 Go to
- cursor, etc) your assembly code in the turbo integrated debugger.
- The unit ASMWATCH.TPU defines the record variable CPU which
- permits you to Watch, Evaluate, and Modify the state of all CPU
- registers and Flags as you Trace. Simply include the statement
- "Uses ASMWATCH;" at the start of your program.
-
- The details of the ASMWATCH interface section are given below.
- The following is a series of sample Watch expressions which are
- particularly useful. These watch expressions may be copied into
- your source files to simplify setting the Watches - simply place
- the cursor in column 1, Hit <Ctrl><F7>, and cursor right to get
- the entire Watch Expression.
-
- CPU.CsIp,p - Segment:Offset of the current instruction
- CPU.CsIp^,m - Hex Dump beginning at current instruction
- CPU.Flags-On - Current state of CPU Flags
- CPU.SsSp,P - Segment:Offset of the Stack Pointer
- W(CPU.SsSp^),$ - Memory Dump at current Stack Pointer
- CPU,$R - Lists all register names and contents
- CPU.Si,$ (etc) - List contents of any Byte or Word Register
-
- In these expressions, Pointers, Words, and Bytes are displayed in
- Hexidecimal. The CPU Flags are displayed as a Pascal Set, eg:
-
- [C,P,A,Z,S,I,D]
-
- where:
-
- C = Carry [Bit 0]
- P = Parity [Bit 2]
- A = Auxiliary [Bit 4]
- Z = Zero [Bit 6]
- S = Sign [Bit 7]
- T = Trace [Bit 8]
- I = Interrupts [Bit 9]
- D = Direction [Bit 10]
- O = Overflow [Bit 11]
-
- The set "On" is defined to be the set of "Don't Care" bits in the
- CPU Flags Word. It can be used as in the sample above to supress
- the display of these "Don't Care" Flags.
-
- To Modify a CPU Register:
-
- 1) Hit <Ctrl><F4>, type (for example): CPU.AX,$
- and press <Enter>. The current value of the Ax
- register will appear in the Result Box.
-
- 2) Move the cursor to the New value Box, type
- (for example): $1234 and press <Enter>.
- The value of Ax will change to $1234.
-
- 3) Again in the New value Box, type: CPU.BX
- and press <Enter>. You have accomplished
- the immediate instruction "Mov Ax,Bx".
-
- To Modify the CPU Flags:
-
- 1) Hit <Ctrl><F4>, type: CPU.Flags
- and press <Enter>. The current state of the
- CPU Flags (including the "Don't Care" bits)
- will appear in the Result Box.
-
- 2) Move the cursor to the New value Box, and
- type (for example):
- CPU.Flags - [Z] - to Clear the Zero Flag
- CPU.Flags + [C] - to Set the Carry Flag
-
-
-
- Type Definitions from ASMWATCH.TPU
- (The variable CPU above is of type CPUType):
-
- TYPE FgBits = (C,X1,P,X3,A,X5,Z,S,T,I,D,O,X12,X13,X14,X15);
- Const On = [X1,X3,X5,X12..X15];
- TYPE W = ARRAY[0..32] OF WORD;
-
- TYPE CPUType = RECORD
- Case Integer OF
- 1: (Ax,Bx,Cx,Dx,Bp,Si,Di,Ds,Es,Ip,Cs,Fg,Sp,Ss :Word);
- 2: (Al,Ah,Bl,Bh,Cl,Ch,Dl,Dh : Byte);
- 3: (dum18 :Array[1..18] of byte;
- CsIp : Pointer;
- Flags : Set of FgBits;
- SsSp : Pointer;);
- END;
-
-
- Source code for the Unit AsmWatch is available upon request to
- registered users of TP&Asm or TP&Asm-M.
-
-
-
- Version 4.0 Users: Making do with DEBUG.
-
- Version 4.0 users can use DEBUG or another external assembler from
- within the Integrated Environment. The idea is to run Turbo within
- the debugger and place an "Int 3" instruction in the source code
- which will be trapped by the debugger when your source program is
- Run in memory.
-
- For this technique it is ESSENTIAL that you run the debugger from
- TP&Asm (as shown below) rather than the other way around. The
- following examples illustrate the proper syntax:
-
- TPAM d turbo <-- to use DEBUG.COM
- - OR -
- TPAM <debugger> turbo.exe <-- to use an alternate Debugger
-
- (TPA can of course be used in place of TPAM, above)
-
- Note:
-
- Some debuggers take certain liberties with the operating system
- that can interfere with the proper operation of TP&Asm. If you
- experience difficulty with this technique, try using the standard
- debugger DEBUG.COM on your DOS system disk.
-
- Once inside the Editor environment, insert an INT 3 (Trap to
- External debugger) into the Assemble/Internal statement under
- examination, as shown in the example below:
-
-
- PROCEDURE Test(VAR SourceString,DestString: St80; Count: Byte);
- Assemble
- Int 3 ;--> Trap to External debugger
- Mov Cx,Count
- Lds Si,SourceString
- Les Di,DestString
- Rep Movsb
- <etc>
-
-
- Before continuing: save, Save, SAVE ANY CHANGES!
-
- Now Run in Memory. The debugger will Trap and display the Int 3
- instruction.
-
- At this point you can:
- - display the disassembly to verify TP&Asm's assembly - OR -
- - skip past the Int 3 (or patch it from Hex CC to Hex 90 (Nop) ),
- and then trace your assembly code instruction by instruction.
-
- Please refer to the instructions provided with your debugger for
- information on how to disassemble, trace, and restart your runtime
- code.
-
- If your assembly code has serious errors as discovered in the
- process of tracing, it may not be possible to restart with a 'g'
- instruction and return to the editor. In that case you may need
- to Quit 'q' from the debugger, which will effectively ABORT turbo
- without saving. Assuming that you heeded the call to Save, Save,
- Save, above, this presents no problem - and you can now return to
- the editor environment armed with the knowledge (from the trace)
- necessary to fix your assembly code (and retest).
-