home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / tp_asm.exe / TP&ASM2.REF < prev    next >
Encoding:
Text File  |  1989-07-31  |  25.8 KB  |  727 lines

  1.  
  2.   TP&Asm           Integrated Compile-Time Assembler          Version 2.2
  3.  
  4.                 Copyright (c) 1989  Richard W. Prescott
  5.                           All Rights Reserved
  6.  
  7. ═══════ Built-In Assembly Language Support for Turbo Pascal Compilers ═══════
  8.  
  9.  All brand and product names mentioned herein are trademarks or registered
  10.                 trademarks of their respective holders.
  11.  
  12.   ┌─────────────────────────────────────────────────────────────────────┐
  13.   │ This file contains detailed reference information to enable you to  │
  14.   │ make effective use of the TP&Asm assembly environment.  For general │
  15.   │ information on getting started please see the README file.          │
  16.   └─────────────────────────────────────────────────────────────────────┘
  17.  
  18.  
  19. The following topics are described below:
  20.  
  21.     8. Error Messages
  22.     9. Trouble Shooting
  23.  
  24.  
  25. The following additional topics are covered in the separate file
  26. TP&ASM.REF:
  27.  
  28.     1. Command Line Options
  29.     2. The Assemble Statement
  30.     3. The Asm Statement
  31.     4. The Internal Statement
  32.     5. General Assembler Syntax
  33.     6. TP&Asm-specific Options
  34.     7. Supported Mnemonics
  35.  
  36.  
  37. Information specific to the use of TP&Asm with Turbo Pascal 5.5 
  38. Objects and Methods can be found in the separate file TP&ASM.OOP.
  39.  
  40.  
  41.  
  42.  
  43. 8. Error Messages
  44.  
  45. The following is an alphabetical listing of all syntax error
  46. messages generated by the current version of TP&Asm, together with
  47. very brief explanations of messages which are not self-explanitory.
  48. All assembler syntax errors use error number 200.
  49.  
  50.  
  51.  
  52. [Symbol] Must be declared FORWARD or in INTERFACE
  53.   INTERNAL Assembly PROCs must be defined in your Pascal Code
  54.  
  55. "Dd $" Not Permitted
  56.  
  57. "Proc/Function + Offset" Not Allowed
  58.   The Turbo linker does not permit reference to Pascal Procedures
  59.   and Functions with non-zero numeric offsets.
  60.  
  61. (INTERNAL) Cannot refer to parameters/result by name
  62. (INTERNAL) Proc definition expected
  63.  
  64. (WARNING) Altered BP May Prevent Local Variable Access
  65. (WARNING) Altered Ds May Prevent Access to Turbo VARs
  66. (WARNING) Altered Seg May Prevent Access to Turbo VARs
  67.   Ss and Bp must be restored before referencing Local variables and
  68.   parameters by name.  Ds must be restored before referencing Global
  69.   variables and Typed Constants by name.
  70.  
  71. (WARNING) ES may be undefined
  72.   You have explicitly or implicitly (via a String mnemonic) used the
  73.   Es register without initializing it.
  74.  
  75. (WARNING) May Require Segment Override
  76.   TP&Asm will use the default segment for indexed memory references
  77.   which do not contain a named variable offset.  The default segment
  78.   is Ss for references involving the Bp register, and Ds for all
  79.   others.
  80.  
  81. (WARNING) Possible invalid operand or forward reference
  82.  
  83. Assembler Symbol Overflow
  84.   You have attempted to define more than 4K of symbols in the
  85.   current Assembly block or Internal PROC.  Break into smaller
  86.   blocks or convert some code or data labels to Pascal using
  87.   LABEL and VAR statements.
  88.  
  89. Bad Identifier Character
  90. Bad Identifier Start
  91.   TP&Asm Code and Data labels may contain only alphanumeric
  92.   characters and the special characters @, _, $, and ?.  They
  93.   must begin with a letter, @, or _.
  94.  
  95. Base or Index Register Required
  96.   When Presumptions are disabled you must supply a proper index
  97.   register (usually [Bp]) to reference local VARs.
  98.  
  99. BY requires Byte operand
  100. Byte operand required
  101.  
  102. Cannot Call Short
  103.   The processor does not support a two byte Call instruction
  104.  
  105. Cannot DUP Address Reference
  106. Cannot DUP Forward Reference
  107.  
  108. Cannot EQUate to Assembly Variable
  109. Cannot EQUate to Forward Symbol
  110. Cannot EQUate to Pascal Symbol
  111.   Operands to EQU must be numeric expressions or indexed memory
  112.   references.
  113.  
  114. Cannot Nest Far Procs
  115.   All Assemble PROCs and nested INTERNAL PROCs must be NEAR.
  116.  
  117. Cannot nest address reference
  118. Cannot Nest Memory Reference
  119. Cannot Nest Pascal Symbols
  120.   Parentheses may contain ONLY constants and numeric expressions.
  121.  
  122. Cannot Pop CS
  123.  
  124. Code Label Duplicates Pascal Symbol
  125.   Since TP&Asm allows forward references to Code labels, Code labels
  126.   must be unique from all Pascal symbols.  Data labels may redefine
  127.   Pascal symbols (within the current Assemble/Internal statement).
  128.  
  129. Colon or data size specifier required
  130.   Code labels require ':' or 'PROC'.  Data labels require a data
  131.   definition directive (DB, DW, DD, EQU) or size qualifier (B, W,
  132.   Byte Ptr, etc).
  133.  
  134. CsData MUST be First Code in Unit
  135.   A Procedure or Function BEGIN block has preceded the CsData
  136.   statement.  The CsData statement, if used, must be the first
  137.   code block in the program or unit.
  138.  
  139. Data Name expected
  140.   Labels are required in Data Segment data allocation statements
  141.  
  142. Duplicate Label
  143. Empty quote
  144. ENDP Expected
  145.  
  146. EQUate to CODE Symbol not supported
  147.   Operands to EQU must be numeric expressions or indexed memory
  148.   references.
  149.  
  150. Error In Define Data
  151.  
  152. Error in IF statement
  153.   A conditional statement in an (Assembly) Inline directive/MACRO
  154.   generated no code or exceeded 127 bytes.
  155.  
  156. Error In Jump Statement
  157.   The operand to a Call or Jmp must be a single Pascal or Assembly
  158.   label, a single Pascal Procedure or Function identifier, or a
  159.   variable or memory expression.
  160.  
  161. Error in Mnemonic
  162.   Invalid symbol found in mnemonic field
  163.  
  164. Full record specification required
  165.   References to record components must be prefixed by a valid
  166.   Record Variable or TYPE qualifier, as discussed in the notes
  167.   to the section on General Assembler Syntax.
  168.  
  169. Incorrect Syntax
  170.   When the 'Offset' qualifier is used, the DESTINATION operand
  171.   must be a Register;  'Mov Var1,Offset Var2' is not permitted.
  172.  
  173. INTERNAL Identifier required before NewLine
  174.   You must specify a unique Pascal identifier on the same line as
  175.   the keyword 'Internal'.  See sample file INTERNAL.PAS.
  176.  
  177. Invalid Absolute CSeg Reference in Assembly MACRO
  178.   Inline Directives must not make direct reference to code or data
  179.   labels except in Direct control transfer instructions.
  180.  
  181. Invalid Absolute CSeg Reference
  182.   Location counter ($) references and data type references to code
  183.   and data labels are permitted only in the FIRST code block within
  184.   any program or unit.  Location counter ($) references are not
  185.   permitted in Jumps or EQUates, nor in (Assembly) Inline directive/
  186.   MACROS.  Note: THIS MESSAGE MAY INDICATE AN UNDEFINED PASCAL
  187.   SYMBOL.  If the undefined symbol is a forward referenced ASSEMBLY
  188.   symbol, move the code to the FIRST Proc/Function in the Program or
  189.   Unit.
  190.  
  191. Invalid Address Reference
  192.   You have specified a sum or difference of symbol names that does
  193.   not resolve to a valid address, displacement, or pure constant.
  194.   NOTE: Mov Ax,PasVar1+PasVar2 is not valid because it instructs the
  195.   assembler to place MemW[Dseg: OFS(PasVar1) +OFS(PasVar2)] into Ax.
  196.   ( Instead you must: Mov Ax,PasVar1  and then: Add AX,PasVar2 ).
  197.   Please consult a reference on assembly language programming.
  198.  
  199. Invalid Base Specification [BX] + (implicit) [BP]
  200.   Disable presumptions to use [BX] in place of the presumed [BP]
  201.   indexing for local variables.  (an Ss override will then be
  202.   required, as the processor default segment for [Bx] is Ds).
  203.  
  204. Invalid BIT Syntax
  205.   Example:  Or Dx,Bit 6 ; same as Or Dx,64
  206.  
  207. Invalid Byte/Word Combination
  208.   Use B or W to override defined variable size:
  209.     Mov Al,B IntegerVar
  210.     Mov Ax,Word Ptr ByteVar
  211.  
  212. Invalid Byte/Word/Dword Combination
  213.   You have attempted to use a DWord POINTER as a Byte or Word VALUE,
  214.   or the reverse. (Remember that VAR parameters are DWord Pointers).
  215.   Use B, W, or D to override defined variable size.
  216.  
  217. Invalid Code Reference
  218.   Within the FIRST code block, expressions of the form
  219.     "label1-label2+numeric offset"
  220.   are permitted, where the labels are code or data labels within the
  221.   current assemble statement.
  222.  
  223. Invalid Conditional Transfer to Proc/Function
  224.   Pascal Procedure and Function identifiers are not permitted as
  225.   operands to conditional jumps and loops.
  226.  
  227. Invalid define string operation
  228.   Arithmetic is not permitted on DB strings with length >= 2.
  229.  
  230. Invalid Final Jump or Forward Reference
  231.   TP&Asm does not permit the LAST statement in an (Assembly) Inline
  232.   directive/MACRO to be a zero displacement jump or forward
  233.   reference.
  234.  
  235. Invalid Forward Absolute CSeg Reference
  236.   THIS MESSAGE MAY INDICATE AN UNDEFINED PASCAL SYMBOL.  If the
  237.   undefined symbol is a forward referenced Assembly symbol, move
  238.   the code to the FIRST Proc/Function in the Program or Unit.
  239.  
  240. Invalid Forward Reference in ASM Statement
  241.   Forward reference to undefined labels is not permitted in an
  242.   ASM statement.
  243.  
  244. Invalid Forward Symbol
  245.   Assembly Data labels cannot be forward referenced.  Forward
  246.   Reference to Code labels is permitted only in the FIRST code
  247.   block in a Program or Unit.
  248.  
  249. Invalid IF Condition
  250. Invalid IF Syntax
  251.   Example: IF A Xor Cx,Cx ;  Valid conditions are formed by removing
  252.   the 'J' from any conditional jump mnemonic EXCEPT jCXZ.
  253.  
  254.  
  255. Invalid Indirect Option
  256. Invalid Indirect Register
  257.   Indexed memory expressions can combine one base (Bx OR Bp), one
  258.   index (Si OR Di), and a numeric or symbolic offset.  In addition,
  259.   a segment override and a memory size qualifier may be specified.
  260.   Examples:  Inc B Es:[Bx+Di+SymName+2] ;  Shl SymName[Si],1 ;  etc.
  261.  
  262. Invalid Jmp Specification
  263.  
  264. Invalid Label or Proc/Function in Memory Reference
  265.   Pascal Labels and Procedure and Function identifiers are not
  266.   permitted in memory expressions.
  267.  
  268. Invalid memory operation
  269.   Arithmetic on memory references is limited to addition and
  270.   subtraction.  Four function arithmetic is supported for constants
  271.   and numeric expressions only.
  272.  
  273. Invalid Numeric Format
  274.  
  275. Invalid Offset to Pascal Proc/Function Reference
  276.   The Turbo linker does not permit reference to Pascal Procedures
  277.   and Functions with non-zero numeric offsets.
  278.  
  279. Invalid operand
  280. Invalid operand combination
  281. Invalid operand or forward reference
  282.   Please see USAGE.PAS for examples of valid operands for the given
  283.   mnemonic and/or consult an assembly language reference.
  284.  
  285. Invalid prefix combination
  286.   The processor does not support LOCK + repeat prefix
  287.  
  288. Invalid Proc/Function Call in Assembly MACRO
  289.   Inline Directives cannot make direct calls to Pascal Procedures
  290.   and Functions.  Indirect calls are permitted.
  291.  
  292. Invalid quoted operand
  293.   Quoted operands used as constants in numeric expressions must have
  294.   length 1 or 2.  Example: Add Al,'A'-1;  Quoted WORD operands have
  295.   most significant CHAR first, thus:  Mov Ax,'Ax';  puts 'x' in AL.
  296.   Note that  DB 'ab';  and  DW 'ba';  BOTH store the 'a' first since
  297.   Word data is stored in 'Byte-reverse' format.
  298.  
  299. Invalid Reference in Assembly MACRO
  300.   Inline Directives must not make direct reference to code or data
  301.   labels except in Direct control transfer instructions.
  302.  
  303. Invalid Reference to Pascal Label
  304.   Pascal labels may not be referenced in data manipulation
  305.   instructions.  For example, "Mov Bx,Offset PasLabel" is not
  306.   permitted.  "Mov Bx,Offset AsmLabel" is permitted in the FIRST
  307.   code block of a Program or Unit.
  308.  
  309. Invalid Relocatable Reference in Assembly MACRO
  310.   Inline Directives cannot make reference to Pascal Procedure
  311.   and Function offsets.  VAR and (Typed) CONST offsets are
  312.   permitted.
  313.  
  314. Invalid SEG Syntax
  315.   Only "SEG DATA" is permitted.
  316.  
  317. Invalid Segment Operation
  318.   Segment registers are allowed as operands to PUSH, POP, and MOV.
  319.  
  320. Invalid Shift Count
  321.   The 8086/88 processor supports only 'shift by 1' and 'shift by CL'
  322.   TP&Asm supports 'shift by n' by coding repeated shifts.  The shift
  323.   count n must be in [1..15].  NOTE: This coding convenience OFTEN
  324.   generates longer and slower code than a shift using CL.
  325.  
  326. Invalid statement in CsData
  327.   CsData permits only data allocation statements: Db, Dw, and Dd.
  328.  
  329. Invalid Symbol
  330.   Possible invalid forward data reference
  331.  
  332. Invalid syntax
  333.   A colon is not permitted within parentheses.
  334.  
  335. Invalid TP&Asm Directive
  336.   The combination ;# is reserved for TP&Asm directives.
  337.  
  338. Invalid use of > or <
  339.   > and < may be used only as prefixes to valid Pascal symbols or
  340.   (> only) a valid Assembly code label.
  341.  
  342. Invalid Use of String Prefix
  343.   Only string mnemonics allow repeat prefixes.
  344.  
  345. Invalid use of Type Qualifier
  346.   Record TYPE qualifiers must be followed by a "." and a valid
  347.   component for the given TYPE, with no embedded spaces.
  348.  
  349. Invalid use of Unit Qualifier
  350.   UnitName qualifiers must be followed by a "." and a Global
  351.   Pascal identifier from the appropriate Unit, with no embedded
  352.   spaces.
  353.  
  354. Label or Proc/Function Reference Required
  355.   The operand to a Direct Call or Jmp must be a single Pascal
  356.   or Assembly label or a single Pascal Procedure or Function
  357.   identifier.
  358.  
  359. Memory operand required
  360.   LEA, LDS, and LES require the source operand to be a memory
  361.   expression.
  362.  
  363. Mismatched Parentheses
  364.  
  365. Multiple Memory Reference
  366.   The processor does not support memory to memory operations.
  367.   Note however that Movsb and Cmpsb are effectively memory to memory
  368.   versions of Mov and Cmp.
  369.  
  370. Multiple Prefix
  371. Multiple Segment Override
  372. Multiple Segment Prefix
  373.   Conflicting multiple prefix specifications is an error.  (TP&Asm
  374.   supports Segment+Repeat prefix combinations, however, by coding
  375.   an appropriate loop).
  376.  
  377. Multiple segments not allowed
  378.   Assemble allows at most one (optional) Segment statement.
  379.   Internal allows one (optional) Data Segment and one (required)
  380.   Code segment.  DSeg and CSeg are acceptable synonyms for "Data"
  381.   and "Code".
  382.  
  383. Nested BY Not Allowed
  384. Nested DUP not allowed
  385. Nested IFs not allowed
  386.  
  387. Nesting limit exceeded
  388.   TP&Asm supports 5 levels of parentheses.
  389.  
  390. No Code Assembled
  391.   An Assemble statement or Internal PROC generated no output code.
  392.  
  393. Non-accessible System Unit identifier
  394.   Port Array, Mem Array, and Non-standard System Proc/Functions 
  395.   cannot be referenced from assembly language.
  396.  
  397. Object has no Virtual Methods
  398.   You have attempted to reference ObjectName.VMT for an object 
  399.   which has no virtual method table, or you have incorrectly used
  400.   "InstanceName.VMT" in place of "ObjectName.VMT".
  401.  
  402. Output Line Code Limit Exceeded
  403.   A single assembly source line is limited to 28 bytes of output
  404.   code and/or 5 relocatable references.  Long DB strings should be
  405.   broken or declared in Pascal.  Push, Pop, Dw, etc, with repeated
  406.   operands may (very rarely) need to be coded with fewer repeats on
  407.   a single line.  (Total output for the entire assembly is NOT
  408.   LIMITED).
  409.  
  410. Parentheses not allowed in memory expressions
  411.  
  412. PAS Statement Invalid in INTERNAL
  413.   The PAS statement is not permitted within Internal PROCs.
  414.  
  415. Proc Model does not match prior definition
  416.   You have used PROC NEAR in an Internal statement but the Pascal
  417.   declaration was FAR (or the reverse).
  418.  
  419. Quotes MisMatch
  420.  
  421. Record/Object Component Expected
  422.  
  423. Reserved Word Error
  424.  
  425. Short Jump Out Of Range
  426.   Conditional jumps in (Assembly) Inline directive/MACROs are
  427.   limited to about 127 bytes forward or back.
  428.  
  429. Specify CMPSB or CMPSW
  430. Specify LODSB or LODSW
  431. Specify MOVSB or MOVSW
  432. Specify SCASB or SCASW
  433. Specify STOSB or STOSW
  434. Specify Word Or Byte
  435.  
  436. Unrecognized Mnemonic
  437.  
  438. Unresolved Reference to [Symbol]
  439.   A reference was made to a symbol that was never defined in Pascal
  440.   or Assembly.  Forward reference to assembly labels which are not
  441.   defined in a Pascal LABEL statement must be resolved within the
  442.   current Assemble statement or Internal PROC.
  443.  
  444. Unsupported ORG Value
  445.   TP&Asm ignores ORG except to report an error if the specified
  446.   value is not 0 or $100.
  447.  
  448. Unsupported Radix Value
  449.   TP&Asm supports Radix 10 and Radix 16.
  450.  
  451. Unsupported Reserved Word
  452.  
  453.  
  454.  
  455. 9. Trouble Shooting
  456.  
  457.  
  458. Examining the TP&Asm Assembly.
  459.  
  460. The utility program EXAMINE.EXE in the archive TP-XMN is provided
  461. to facilitate verification that the TP&Asm Assembler has correctly
  462. assembled your assembly source code.  When used in conjunction with
  463. DEBUG.COM (on your DOS disk) it generates a "side by side" display
  464. of each Pascal or assembly source statement together with its
  465. corresponding DEBUG disassembly.  The disassembly you see is the
  466. same as you would get if you simply used DEBUG.COM to directly
  467. disassemble the compiled EXE file.  By displaying each piece of the
  468. disassembly alongside the corresponding assembly source statement,
  469. it is a simple matter to compare the two to verify proper assembly.
  470. Command line options permit you to limit the output to a range
  471. containing the assembly code, and to direct the output to the
  472. screen, printer, or a file.
  473.  
  474. EXAMINE.EXE requires a compiled EXE file and a MAP file as produced
  475. by Turbo/TPC Version 4.0 or above.  (Version 4.0 users must also run
  476. TPMAP).  Please refer to the file EXAMINE.DOC in the archive TP-XMN
  477. (or on your distribution disk) for instructions on how to use
  478. EXAMINE.EXE.
  479.  
  480. Full source code to EXAMINE.EXE is provided to registered users of
  481. TP&Asm.
  482.  
  483. The TP&Asm assembly may also be examined using a symbolic debugger
  484. such as the Turbo Debugger.  Since TP&Asm is fully integrated with
  485. Turbo Pascal, MAP files produced with versions 4.0 and above of the
  486. compiler contain full Line Number detail for all assembly sections
  487. (Except [Assembly] Inline Directive/MACROs), permitting source level
  488. debugging in any MAP-file compatible debugger.
  489.  
  490.  
  491. Trouble Shooting Using a Debugger.
  492.  
  493. Turbo Pascal Versions 5.0 and above provide an integrated debugger 
  494. within the Integrated Development Environment.  Since Built-in 
  495. assembly support was not anticipated, however, the integrated debugger 
  496. provides no means of monitoring the state of the CPU registers and 
  497. flags.  TP&Asm provides support for monitoring and modifying the CPU 
  498. registers and flags through the Unit(s) WCHMGR5x which are provided 
  499. on the distribution disk and in the archive TP-ASM.
  500.  
  501.  
  502. Version 5.x Users: Using WCHMGR5x.
  503.  
  504. With Turbo Version 5.x, you can trace (F7 Trace into, F4 Go to
  505. cursor, etc) your assembly code in the turbo integrated debugger.
  506. The units  WCHMGR5x.TPU  define the record variable CPU which
  507. permits you to Watch, Evaluate, and Modify the state of all CPU
  508. registers and Flags as you Trace.  Simply include one of the 
  509. following statements:
  510.  
  511.    Uses WCHMGR50;   {- if you are using Turbo Version 5.0 -}
  512.    Uses WCHMGR55;   {- if you are using Turbo Version 5.5 -}
  513.  
  514. at the start of your program.  If your program uses other units,
  515. these may be specified before or after the Watch Manager Unit.
  516.  
  517. The details of the WCHMGR5x interface section are given below.
  518. The following is a series of sample Watch expressions which are
  519. particularly useful.  (These watch expressions can be set 
  520. automatically using the procedure AddWatch which is described 
  521. below.  This entire set of watch expressions can be established 
  522. automatically by calling the procedure SetAsmWatches).
  523.  
  524.  CPU.CsIp,p       - Segment:Offset of the current instruction
  525.  CPU.CsIp^,m      - Hex Dump beginning at current instruction
  526.  CPU.Flags-On     - Current state of CPU Flags
  527.  CPU.SsSp,P       - Segment:Offset of the Stack Pointer
  528.  W(CPU.SsSp^),$   - Memory Dump at current Stack Pointer
  529.  CPU,$R           - Lists all register names and contents
  530.  
  531. You can also watch the value of any single register:
  532.  
  533.  CPU.Si,$   (etc) - List contents of a Byte or Word Register
  534.  
  535. In these expressions, Pointers, Words, and Bytes are displayed in
  536. Hexidecimal.  The CPU Flags are displayed as a Pascal Set, eg:
  537.  
  538.    [C,P,A,Z,S,I,D]
  539.  
  540. where:
  541.  
  542.    C = Carry       [Bit 0]
  543.    P = Parity      [Bit 2]
  544.    A = Auxiliary   [Bit 4]
  545.    Z = Zero        [Bit 6]
  546.    S = Sign        [Bit 7]
  547.    T = Trace       [Bit 8]
  548.    I = Interrupts  [Bit 9]
  549.    D = Direction   [Bit 10]
  550.    O = Overflow    [Bit 11]
  551.  
  552. The set "On" is defined to be the set of "Don't Care" bits in the
  553. CPU Flags Word.  It can be used as in the sample above to supress
  554. the display of these "Don't Care" Flags.
  555.  
  556. To Modify a CPU Register:
  557.  
  558.    1) Hit <Ctrl><F4>, type (for example):  CPU.AX,$
  559.       and press <Enter>.  The current value of the Ax
  560.       register will appear in the Result Box.
  561.  
  562.    2) Move the cursor to the New value Box, type
  563.       (for example):  $1234   and press <Enter>.
  564.       The value of Ax will change to $1234.
  565.  
  566.    3) Again in the New value Box, type:  CPU.BX
  567.       and press <Enter>.  You have accomplished
  568.       the immediate instruction "Mov Ax,Bx".
  569.  
  570. To Modify the CPU Flags:
  571.  
  572.    1) Hit <Ctrl><F4>, type:   CPU.Flags
  573.       and press <Enter>.  The current state of the
  574.       CPU Flags (including the "Don't Care" bits)
  575.       will appear in the Result Box.
  576.  
  577.    2) Move the cursor to the New value Box, and
  578.       type (for example):
  579.         CPU.Flags - [Z]  - to Clear the Zero Flag
  580.         CPU.Flags + [C]  - to Set the Carry Flag
  581.  
  582.  
  583.  
  584. Type Definitions from WCHMGR5x.TPU
  585. (The variable CPU above is of type CPUType):
  586.  
  587. TYPE FgBits = (C,X1,P,X3,A,X5,Z,S,T,I,D,O,X12,X13,X14,X15);
  588. Const On = [X1,X3,X5,X12..X15];
  589. TYPE W = ARRAY[0..32] OF WORD;
  590.  
  591. TYPE CPUType = RECORD
  592.  Case Integer OF
  593.   1: (Ax,Bx,Cx,Dx,Bp,Si,Di,Ds,Es,Ip,Cs,Fg,Sp,Ss :Word);
  594.   2: (Al,Ah,Bl,Bh,Cl,Ch,Dl,Dh : Byte);
  595.   3: (dum18 :Array[1..18] of byte;
  596.       CsIp : Pointer;
  597.       Flags : Set of FgBits;
  598.       SsSp : Pointer;);
  599. END;
  600.  
  601.  
  602. The units WCHMGR5x.TPU also define four procedures and two functions
  603. which may be used to automatically set and clear watch expressions
  604. under program control as you trace your program in the Integrated
  605. Development Environment.  (You are still free to manually set and
  606. clear watches in addition to those being set automatically).  Using
  607. conditional compilation you can easily activate/deactivate the
  608. automatic watch control.
  609.  
  610. The interface definitions for the six routines are as follows:
  611.  
  612.        PROCEDURE AddWatch(WatchExpr: STRING);
  613.        PROCEDURE DelWatch(WatchExpr: STRING);
  614.        PROCEDURE ClrWatch;
  615.  
  616.        FUNCTION WatchCount: WORD;
  617.        FUNCTION WatchStr(WatchNo: WORD): STRING;
  618.  
  619.        PROCEDURE SetAsmWatches;
  620.  
  621. AddWatch adds the designated watch expression to the watch window
  622. with leading and trailing (but not intermediate) spaces removed.
  623. The new watch becomes the "current" (highlighted/bulleted) watch.
  624. Like the IDE menu commands, AddWatch permits multiple definitions
  625. of the same watch expression.  If there is a possibility that a
  626. watch may already be defined, call DelWatch before AddWatch to
  627. prevent an additional copy from being generated.  AddWatch is
  628. equivalent to the menu command "Break/Add watch".
  629.  
  630. Example:
  631.   AddWatch('CPU.CsIp,p'); {Segment:Offset of the current instruction}
  632.  
  633. DelWatch searches for the designated watch expression, and, if
  634. found, deletes it from the watch window.  Case differences and
  635. leading/trailing spaces are ignored in searching for a match.
  636. Thus              DelWatch(' GLOBALVAR  ');
  637. will clear the watch set by
  638.                    AddWatch('GlobalVar');
  639. If the deleted watch was the "current" watch, the next older watch
  640. becomes "current".  Otherwise, the "current" watch is unchanged.
  641. If multiple copies of the same watch expression are defined,
  642. DelWatch will delete the oldest copy.  DelWatch is an extension
  643. of the menu command "Break/Delete watch".
  644.  
  645. ClrWatch clears all watch expressions from the watch window.  It
  646. is equivalent to the menu command "Break/Remove all watches".
  647.  
  648. WatchCount returns the current number of watches defined.  There
  649. is no IDE equivalent.
  650.  
  651. WatchStr returns the watch expression corresponding to the parameter
  652. WatchNo (numbered from oldest to most recent).  There is no IDE
  653. equivalent.
  654.  
  655. Example:
  656.   DelWatch(WatchStr(WatchCount)); {delete the most recent watch}
  657.  
  658. SetAsmWatches clears all current watches and then calls AddWatch to 
  659. establish a set of six useful assembly level watch expressions.
  660.  
  661.  
  662. Source code for the Unit(s) WchMgr5x is included with the TP&Asm
  663. Version 2.2 registration diskette.
  664.  
  665.  
  666.  
  667. Version 4.0 Users: Making do with DEBUG.
  668.  
  669. Version 4.0 users can use DEBUG or another external assembler from
  670. within the Integrated Environment.  The idea is to run Turbo within
  671. the debugger and place an "Int 3" instruction in the source code
  672. which will be trapped by the debugger when your source program is
  673. Run in memory.
  674.  
  675. For this technique it is ESSENTIAL that you run the debugger from
  676. TP&Asm (as shown below) rather than the other way around.  The
  677. following examples illustrate the proper syntax:
  678.  
  679. tpa d turbo                <-- to use DEBUG.COM
  680. - OR -
  681. tpa <debugger> turbo.exe   <-- to use an alternate Debugger
  682.  
  683. Note:
  684.  
  685. Some debuggers take certain liberties with the operating system
  686. that can interfere with the proper operation of TP&Asm.  If you
  687. experience difficulty with this technique, try using the standard
  688. debugger DEBUG.COM on your DOS system disk.
  689.  
  690. Once inside the Editor environment, insert an INT 3 (Trap to
  691. External debugger) into the Assemble/Internal statement under
  692. examination, as shown in the example below:
  693.  
  694.  
  695. PROCEDURE Test(VAR SourceString,DestString: St80; Count: Byte);
  696. Assemble
  697. Int 3   ;--> Trap to External debugger
  698. Mov Cx,Count
  699. Lds Si,SourceString
  700. Les Di,DestString
  701. Rep Movsb
  702. <etc>
  703.  
  704.  
  705. Before continuing: save, Save, SAVE ANY CHANGES!
  706.  
  707. Now Run in Memory.  The debugger will Trap and display the Int 3
  708. instruction.
  709.  
  710. At this point you can:
  711.  - display the disassembly to verify TP&Asm's assembly  - OR -
  712.  - skip past the Int 3 (or patch it from Hex CC to Hex 90 (Nop) ),
  713.    and then trace your assembly code instruction by instruction.
  714.  
  715. Please refer to the instructions provided with your debugger for
  716. information on how to disassemble, trace, and restart your runtime
  717. code.
  718.  
  719. If your assembly code has serious errors as discovered in the
  720. process of tracing, it may not be possible to restart with a 'g'
  721. instruction and return to the editor.  In that case you may need
  722. to Quit 'q' from the debugger, which will effectively ABORT turbo
  723. without saving.  Assuming that you heeded the call to Save, Save,
  724. Save, above, this presents no problem - and you can now return to
  725. the editor environment armed with the knowledge (from the trace)
  726. necessary to fix your assembly code (and retest).
  727.