home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l224 / 1.img / MANUAL.ZIP / UPDATE.DOC < prev   
Encoding:
Text File  |  1990-10-29  |  19.8 KB  |  528 lines

  1.  
  2.                 TURBO ASSEMBLER 2.0 NEW FEATURES
  3.                 --------------------------------
  4.  
  5.   Borland's Turbo Assembler 2.0 is now a multi-pass assembler that has 
  6.   forward-reference resolution, assembly speeds of up to 48,000 lines per 
  7.   minute, MASM compatibility, and an optional Ideal mode extended syntax.
  8.  
  9.   In addition to all the features of version 1.0, Turbo Assembler 2.0 offers 
  10.   you these:
  11.  
  12.     o PUBLICDLL statement
  13.     o Multiple pass capability - NOP removal
  14.     o CALL extensions
  15.     o PUSH, POP instruction extensions
  16.     o COMM extension
  17.     o Generalized line-continuation character
  18.     o Language-specific procedures, extrns, publics
  19.     o New MODEL identifiers - WINDOWS
  20.     o Virtual segments
  21.     o QASM Compatibility Additions
  22.     o 486 instruction support
  23.     o New TASM 2.0 error messages
  24.     o CODEPTR type
  25.     o RETCODE instruction
  26.     o SMART/NOSMART directives
  27.     o Overlay object code
  28.  
  29.  
  30.   PUBLICDLL Statement
  31.  --------------------
  32.   The PUBLICDLL directive lets you define program labels and procedures to 
  33.   be dynamic link entry points as well as publicizing them to your other 
  34.   modules, which allows you to build dynamic link libraries in assembly code.
  35.   For example,
  36.  
  37.            PUBLICDLL XYPROC       ;make procedure XYPROC
  38.     XYPROC PROC NEAR              ;accessible as dynamic
  39.                                   ;link entry point
  40.  
  41.   The syntax for PUBLICDLL follows:
  42.  
  43.     PUBLICDLL [language] symbol [,[language] symbol]...}
  44.  
  45.   symbol is published in the object file as a dynamic link entry point so 
  46.   that it can be accessed by programs under OS/2. This statement is used 
  47.   only to help build an OS/2 dynamic link library. If you don't make a 
  48.   symbol public, it can only be accessed from the current source file.
  49.  
  50.   In most cases, you declare only PROC labels to be PUBLICDLL. Other program
  51.   labels, data variable names, and numeric constants defined with EQU can 
  52.   also be declared to be PUBLICDLL.
  53.  
  54.   The optional language specifier causes any language-specific conventions 
  55.   to be applied to the symbol name. For instance, using the C language 
  56.   specifier would cause the symbol name to be preceded by an underscore 
  57.   character when published in the object file. Valid language specifiers 
  58.   are C, PASCAL, BASIC, FORTRAN, PROLOG, and NOLANGUAGE.
  59.  
  60.   COMM, EXTRN, GLOBAL, and PUBLIC are related instructions.
  61.  
  62.  
  63.   Multiple Pass Capability: NOP Removal
  64.   -------------------------------------
  65.   Turbo Assembler 2.0 can pass over your source code more than once either 
  66.   for compatibility with some of MASM's pass-dependent constructions or to 
  67.   remove NOP instructions that were added to the code because of forward 
  68.   references. This feature is enabled by the command-line switch /m#, where #
  69.   is the maximum number of passes allowed. Turbo Assembler automatically 
  70.   assesses the need to perform extra passes up to the maximum that you specify.
  71.  
  72.   The command-line switch /m sets the maximum number of assembly passes:
  73.  
  74.     /M[npasses]
  75.  
  76.   For maximum compatibility with MASM, two passes (/m2) should be used. If you
  77.    don't specify the number of passes, a default of five is used.
  78.  
  79.   TASM 2.0's new multiple pass capability enhances compatibility with MASM in 
  80.   the following areas:
  81.  
  82.     1) Any construction that generates a "Pass-dependent construction" 
  83.        warning in TASM 1.0. These include constructions containing the IF2 
  84.        directive, and some constructions with IFDEF or IFNDEF. If the /m 
  85.        option is enabled, Turbo Assembler will assemble this module correctly
  86.        but will not optimize the code by removing NOPs, no matter how many
  87.        passes are allowed. The warning "Module is pass dependent-compatibility
  88.        pass was done" is displayed if this occurs.
  89.  
  90.     2) Forward-referenced macros.
  91.  
  92.   The NOP-squishing capability also enhances the use of other TASM features, 
  93.   namely the JUMPS mode of operation. For example,
  94.  
  95.       jumps
  96.               jnz foobar
  97.       foobar:
  98.  
  99.   Under TASM 1.0, the JNZ generates 3 NOPs, because FOOBAR is 
  100.   forward-referenced. With the /m switch enabled in TASM 2.0, these NOPs 
  101.   are eliminated: The JUMPS mode can be enabled with no wasteful NOPs being
  102.   generated.
  103.  
  104.   Usually, two passes are sufficient to squish out all NOPs. Occasionally, 
  105.   however, more passes may be required. If you need better compilation speed,
  106.   place the correct overrides everywhere so that a single pass will produce 
  107.   optimal code.
  108.  
  109.  
  110.   CALL Extensions
  111.   ---------------
  112.   The CALL instruction has been extended in Turbo Assembler to allow 
  113.   high-level language routines to be called in a language-independent manner.
  114.   Any CALL instruction can now specify a language and an argument list for 
  115.   the routine being called. Turbo Assembler automatically generates the 
  116.   necessary stack setup and cleanup code required to pass the arguments to 
  117.   a high-level routine written in the specified language. The syntax is as
  118.   follows:
  119.  
  120.     CALL <destination> <optional language>,
  121.          <first argument>,<second argument>,...
  122.  
  123.   For example,
  124.  
  125.     call far ptr abc pascal,      ax dx,word ptr wordval
  126.  
  127.   This example generates a far call to the Pascal-style routine ABC, which 
  128.   takes two arguments: a DWORD and a WORD. The DWORD argument is considered 
  129.   to be in AX and DX, and the WORD argument is assumed to be in WORDVAL.
  130.  
  131.   If the optional language is not specified, the current default language 
  132.   is assumed.
  133.  
  134.   Formerly, to call a higher-level language routine, the arguments needed to
  135.   be explicitly PUSHed onto the stack, and the stack needed to be explicitly 
  136.   adjusted (after the call) depending on the language. The new CALL 
  137.   extensions save you the tedium of doing all this explicitly.
  138.  
  139.  
  140.   PUSH, POP Instruction Extensions
  141.   --------------------------------
  142.   The PUSH and POP instructions have been extended in Turbo Assembler to 
  143.   allow more than one argument to appear in a single PUSH or POP instruction.
  144.   For example,
  145.  
  146.     push ax dx       ;equivalent to PUSH AX then PUSH DX
  147.     pop  dx ax       ;equivalent to POP DX then POP AX
  148.  
  149.   In addition, the PUSH instruction allows constant arguments even when 
  150.   generating code for the 8086 processor. Such instructions are replaced in 
  151.   the object code by a 10-byte sequence that simulates the 80186/286/386 
  152.   PUSH immediate value instruction.
  153.  
  154.  
  155.   COMM Extension
  156.   --------------
  157.   The COMM directive has been extended to allow the array element size and 
  158.   the array element count to be selected independently of each other for FAR
  159.   communal variables. This supports Turbo C++'s inline code generation, and
  160.   can be used advantageously by a native assembly language programmer. The 
  161.   syntax is as follows:
  162.  
  163.     COMM FAR <id>{[<array element size multiplier>]}:<basic element
  164.              size>{:<array count>}
  165.  
  166.   For example, this code fragment reserves an array of size 410: 10 elements 
  167.   each of size 41 bytes:
  168.  
  169.     COMM FAR ABC[41]:BYTE:10
  170.  
  171.  
  172.   Generalized Line-continuation Character
  173.   ---------------------------------------
  174.   In TASM 2.0, a line-continuation feature has been added that works in TASM's
  175.   Ideal mode and is available even when the MASM 5.1 mode is off. A backslash 
  176.   (\) can be placed almost anywhere as a line-continuation character. It 
  177.   cannot be used to break up strings or identifiers. Its meaning is "read the
  178.   next line in at this point and continue processing." It can thus be used in
  179.   a natural way without losing the ability to comment each line as desired. For
  180.   example,
  181.  
  182.     foo mystructure  \    ;Start of structure fill.
  183.     <0               \    ;Zero value is first.
  184.     1,               \    ;One value.
  185.     2>                    ;Two value and end of structure.
  186.  
  187.   There are contexts where the line-continuation character is not recognized.
  188.   In general, it isn't recognized in any context where characters are treated
  189.   as text rather than identifiers, numbers, or strings, or in MASM mode when 
  190.   the line continuation is used in the first two symbols in the statement. 
  191.   For example,
  192.  
  193.     ifdif <123\>,<456\>
  194.  
  195.   does not recognize the two enclosed line-continuation characters.
  196.  
  197.     comment \
  198.     :
  199.  
  200.   begins a comment block, but does not define a near symbol
  201.   called COMMENT.
  202.  
  203.   The line-continuation character is also not recognized inside of macro 
  204.   definitions. It is recognized, however, when the macro is expanded.
  205.  
  206.  
  207.   Additional Display
  208.   -------------------
  209.   TASM 2.0 displays the number of passes as well as the error and warning 
  210.   counts and remaining space. This allows you to assess the amount of work 
  211.   TASM is putting into the compilation process.
  212.  
  213.  
  214.   Language-specific Procedures, Extrns, Publics, Calls
  215.   -----------------------------------------------------
  216.   TASM 2.0 allows procedures, publics, extrns, and calls to be overridden 
  217.   with a language specifier. This causes wide flexibility in writing assembler
  218.   code that interfaces with multiple language models. The MODEL statement has
  219.   also been extended.
  220.  
  221.   Here are some syntax examples:
  222.  
  223.     <procname> PROC {<language modifier>} {<language>} {NEAR | FAR}
  224.                                                           {args and uses}
  225.     EXTRN {<language>} <symbol>:<distance>, {<language>} 
  226.                                                   <symbol>:<distance>,...
  227.     PUBLIC {<language>} <symbol>, ...
  228.     COMM {<language>} <symbol>:<distance>, ...
  229.     GLOBAL {<language>} <symbol>:<distance>, ...
  230.     PUBLICDLL {<language>} <symbol>, ...
  231.     CALL <procname> {{<language>}, {args}}
  232.     .MODEL {<model modifier>} <model> {<module name>} {, 
  233.         {<language modifier>} <language> {, <language modifier> } }
  234.  
  235.    Here's the syntax for the IDEAL mode PROC statement:
  236.  
  237.     PROC {<language modifier>} {<language>} <procname> {NEAR | FAR}
  238.                                                           {args and uses}
  239.  
  240.     Legal models are TINY, SMALL, MEDIUM, COMPACT, LARGE, and HUGE.
  241.     Note that TPASCAL is also a legal model.
  242.  
  243.     Legal model modifiers are
  244.  
  245.     o FARSTACK (Selects model where SS is not assumed to be in DGROUP)
  246.  
  247.     o NEARSTACK (Selects model where SS is in DGROUP. This is the default)
  248.  
  249.     Legal languages are NOLANGUAGE, C, PASCAL, BASIC, FORTRAN, and PROLOG.
  250.  
  251.     Legal language modifiers are
  252.  
  253.     o NORMAL (Selects normal procedure entry/exit sequences)
  254.  
  255.     o WINDOWS (Selects MSWindows procedure entry/exit sequences)
  256.  
  257.   You don't need the .MODEL statement to make use of any of these language 
  258.   specifiers; the .MODEL statement simply serves to set the default language.
  259.  
  260.  
  261.   New MODEL Identifiers: WINDOWS
  262.   ------------------------------
  263.   Here is a description of the model modifier SS_NE_DS and the language 
  264.   modifiers NORMAL and WINDOWS.
  265.       
  266.   The model modifier can precede any use of a model keyword. This only happens
  267.   in the .MODEL statement. For example,
  268.       
  269.      .MODEL SS_NE_DS LARGE   ;Equivalent to TC's default large model
  270.       
  271.   This modifier causes SS to be assumed to NOTHING and the stack, if any, to 
  272.   not be part of DGROUP.
  273.       
  274.   The language modifiers can precede any use of a language keyword. A language
  275.   keyword can be used in any of the following places:
  276.  
  277.   .MODEL, EXTRN, GLOBAL, PUBLIC, PUBLICDLL, COMM, PROC, CALL.
  278.  
  279.   A language modifier affects the type of stack frame that's generated for 
  280.   procedure entry and exit. When used in EXTRN, GLOBAL, PUBLIC, PUBLICDLL, 
  281.   COMM, and CALL, a language modifier is allowed but will have no effect.
  282.  
  283.   The stack frames actually generated for each modifier are as follows:
  284.       
  285.     NORMAL: ;No entry/exit sequence generated if no args or locals.
  286.             ;8086 version (186 version uses ENTER/LEAVE).
  287.             push bp
  288.             mov bp,sp
  289.             sub sp,local_size       ;If any locals.
  290.             <push uses registers>
  291.             ...
  292.             <pop uses registers>
  293.             mov sp,bp               ;If any locals.
  294.             pop bp
  295.             ret
  296.  
  297.   WINDOWS: push ds
  298.            pop ax
  299.            xchg ax,ax
  300.            inc bp
  301.            push bp
  302.            mov bp,sp
  303.            push ds
  304.            mov ds,ax
  305.            sub sp,local_size       ;If any locals.
  306.            <push uses registers>
  307.            ...
  308.            <pop uses registers>
  309.            sub bp,2                ;If any locals.
  310.            mov sp,bp               ;If any locals.
  311.            pop ds
  312.            pop bp
  313.            dec bp
  314.            ret
  315.  
  316.   Here's an example:
  317.  
  318.     .MODEL large,windows pascal
  319.     .code
  320.  
  321.     foo proc
  322.     arg abc:word,def:word
  323.             xor ax,ax       ;Generates FAR WINDOWS PASCAL sequences.
  324.             ret
  325.     endp
  326.  
  327.     foo proc normal c
  328.     arg ghi:word,jkl:word
  329.             xor ax,ax       ;Generates FAR NORMAL C sequences.
  330.             ret
  331.     endp
  332.  
  333.  
  334.   VIRTUAL Segments
  335.   ----------------
  336.   A new keyword VIRTUAL has been added to the SEGMENT
  337.   statement. VIRTUAL defines a special kind of segment
  338.   that will be treated as a common area and attached to
  339.   another segment at link time.
  340.  
  341.     <segname> SEGMENT VIRTUAL   ;In MASM mode.
  342.     ...
  343.     ENDS
  344.  
  345.     SEGMENT <segname> VIRTUAL   ;In Ideal mode.
  346.     ...
  347.     ENDS
  348.  
  349.   In TASM, the VIRTUAL segment is assumed to be attached to the enclosing 
  350.   segment. The VIRTUAL segment also inherits its attributes from the 
  351.   enclosing segment.
  352.  
  353.   A VIRTUAL segment is treated as normal except that it is considered part of
  354.   its parent segment for the purposes of ASSUMEs.
  355.  
  356.   The linker treats virtual segments as a common area that will be combined 
  357.   across modules. This permits static data that comes into many modules from
  358.   include files to be shared.
  359.  
  360.  
  361.   QASM Compatibility Additions
  362.   ----------------------------
  363.   TASM 2.0 has new and modified directives to support source code
  364.   for QASM:
  365.  
  366.   .STARTUP and STARTUPCODE
  367.      These commands generate startup code for the particular model in effect 
  368.      at the time. These also define the near label @@Startup and cause the 
  369.      END statement at the end of the module to generate the equivalent of 
  370.     'END @@Startup'. Note that only the 'STARTUPCODE' directive is available
  371.      in IDEAL mode.
  372.  
  373.   .MODEL and MODEL
  374.      It is now possible to select a third field in the .MODEL statement to 
  375.      specify the stack association with DGROUP: NEARSTACK or FARSTACK. 
  376.      For example, .MODEL SMALL,C,FARSTACK would specify that the stack not be 
  377.      included in DGROUP. This capability is already provided in TASM through 
  378.      the language modifiers of the same name. The additional field is provided
  379.      only for MASM compatibility.
  380.  
  381.   Two new predefined variables have been added:
  382.  
  383.     Startup: Defined by the .STARTUP and STARTUPCODE directives.
  384.  
  385.     @Model: An integer representing the model currently in effect.
  386.             0 = TINY   1 = SMALL    2 = COMPACT    3 = MEDIUM
  387.             4 = LARGE  5 = HUGE
  388.  
  389.  
  390.   486 Instruction Support
  391.   -----------------------
  392.   The following directives have been added to TASM 2.0 to support the 
  393.   Intel 486 microprocessor:
  394.  
  395.   .486,.486c (Masm mode only)
  396.  
  397.   P486N: Enables assembly of non-protected instructions for the 486 processor.
  398.  
  399.   .486p (Masm mode only)
  400.  
  401.   P486: Enables assembly of protected instructions for the 486 processor.
  402.  
  403.   BSWAP <32-bit register>: 486 byte swap instruction. 
  404.   XADD <r/m>,<reg>: 486 exchange and add instruction.
  405.   CMPXCHG <r/m>,<reg>: 486 compare and exchange instruction.
  406.   INVD: 486 invalidate data cache instruction.
  407.   WBINVD: 486 write back and invalidate data cache inst.
  408.   INVLPG <memptr>: 486 invalidate TLB entry for address inst.
  409.  
  410.   The following test registers have also been added:
  411.  
  412.   TR3,TR4,TR5
  413.  
  414.  
  415.   New TASM 2.0 Error Messages
  416.   ---------------------------
  417.   TASM 2.0 reports several new error messages:
  418.  
  419.   Global type doesn't match symbol type
  420.     This warning is given when a symbol is declared using the GLOBAL 
  421.     statement and is also defined in the same module, but the type specified 
  422.     in the GLOBAL and the actual type of the symbol don't agree.
  423.  
  424.   Illegal segment address
  425.     This error appears if an address greater than 65,535 is specified as a 
  426.     constant segment address; for example,
  427.  
  428.        FOO SEGMENT AT 12345h
  429.  
  430.   Module is pass-dependent--compatibility pass was done.
  431.     This warning occurs if a pass-dependent construction was encountered and 
  432.     the /m command-line switch was specified. A MASM-compatible pass was done.
  433.  
  434.   Near jump or call to different CS
  435.     This error occurs if the user attempts to perform a NEAR CALL or JMP to a 
  436.     symbol that's defined in an area where CS is assumed to a different segment.
  437.  
  438.   Only one startup sequence allowed
  439.     This error appears if you have more than one .STARTUP or STARTUPCODE 
  440.     statement in a module.
  441.  
  442.   Smart code generation must be enabled
  443.     Certain special features of code generation require SMART code generation 
  444.     to be enabled. These include PUSH of a pointer, POP of a pointer, and PUSH
  445.     of a constant (8086 only).
  446.  
  447.   Text macro expansion exceeds maximum line length
  448.     This error occurs when expansion of a text macro causes the maximum 
  449.     allowable line length to be exceeded.
  450.  
  451.   USES has no effect without language
  452.     This warning appears if you specify a USES statement when no language is
  453.     in effect.
  454.  
  455.  
  456.   CODEPTR Type
  457.   ------------
  458.  
  459.   CODEPTR returns the default procedure address size depending on the current
  460.   model (WORD for models with NEAR code; DWORD for models with FAR code). 
  461.   CODEPTR can be used wherever DATAPTR is used. Here is its syntax:
  462.  
  463.     CODEPTR expression
  464.  
  465.  
  466.   RETCODE Instruction
  467.   -------------------
  468.   The RETCODE instruction is exactly equivalent to RETN or RETF, depending on 
  469.   the specified model. RETCODE syntax follows:
  470.  
  471.   RETCODE {<expression>}
  472.  
  473.   RETCODE is available in both MASM and Ideal modes.
  474.  
  475.  
  476.   SMART/NOSMART
  477.   -------------
  478.   The SMART/NOSMART directives control the generation of optimized object code.
  479.   These are the areas that the SMART  and NOSMART directives apply to:
  480.  
  481.     1) OR, AND, or XOR of a signed immediate byte
  482.     2) PUSH <constant>
  483.     3) PUSH <large pointer>
  484.        POP <large pointer>
  485.     4) CALL <far address in same segment>
  486.     5) JMP <far address in same segment>
  487.     6) LEA <constant effective address>
  488.  
  489.   The default condition is SMART enabled. When SMART is enabled, a qualifying
  490.   FAR jump will be replaced by a NEAR or a SHORT jump. Also, when SMART is 
  491.   enabled, a qualifying FAR call will be replaced by a PUSH CS instruction 
  492.   and a NEAR call. 
  493.  
  494.   When NOSMART is  selected, the following code generation changes occur:
  495.  
  496.     a) AND, OR, XOR of an immediate word value are no longer done using the 
  497.        signed-extended immediate byte version of these instructions where 
  498.        possible, but rather the longer immediate word version that MASM uses.
  499.  
  500.     b) PUSH of a constant value on the 8086 processor using the special 
  501.        10-byte code sequence (which preserves all registers and flags) is 
  502.        not allowed.
  503.  
  504.     c) PUSH and POP of a DWORD memory variable (or PWORD variable on a 386) 
  505.       are not allowed.
  506.  
  507.     d) Far JMPs and CALLs within the same segment are no longer optimized by 
  508.        replacing the FAR JMP or CALL with the NEAR version.
  509.  
  510.     e) LEA instructions that refer to a constant effective address will no 
  511.        longer be converted to the equivalent MOV operations.
  512.  
  513.   For maximum MASM compatibility, you must select NOSMART and QUIRKS.
  514.  
  515.   Overlay Object Code
  516.   -------------------
  517.   The /o commmand-line option
  518.  
  519.   Function   Generates overlay code
  520.  
  521.   Syntax     {/o}
  522.  
  523.   Remarks    Turbo Assembler 2.0 supports overlays. Specifying the /o switch 
  524.              on the command line causes overlay-compatible fixups to be 
  525.              generated. When this switch is used, 386 references to USE32 
  526.              segments should not be made since they won't link properly.
  527.  
  528.