home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / assembler / tasm / doc / TASM < prev    next >
Encoding:
Text File  |  1994-01-18  |  71.1 KB  |  1,684 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                          TASM USER'S MANUAL
  8.  
  9.  
  10.       TASM - A Table Driven Cross Assembler for the MSDOS* Environment
  11.  
  12.  
  13.  
  14.  
  15.  
  16.                            Thomas N. Anderson
  17.                      Speech Technology Incorporated
  18.                 837 Front Street South, Issaquah, WA   98027
  19.  
  20.  
  21.                              March, 1992
  22.                              Version 2.9
  23.  
  24. [Speech Technology Incorporated manufactures electronic devices to aid the
  25. visually impaired employing digital speech synthesis technology.]
  26.  
  27.  
  28. TASM software is Copyright (C) 1985-1992 by Speech Technology Incorporated.
  29. All rights reserved.
  30.  
  31. This document is Copyright (C) 1985-1992 by Speech Technology Incorporated.
  32. All rights reserved. Permission is granted to copy this document and related
  33. software except for the source code.  The source code, distributed to
  34. registered users, may be copied for the sole use of the registered user.
  35.  
  36.  
  37.  
  38.  
  39.  * MSDOS is a trademark of Microsoft Corporation.
  40.  
  41. TASM - Table Driven Assembler Version 2.9                              Page 2
  42.  
  43. TABLE OF CONTENTS
  44.  
  45. SECTION                                             PAGE
  46. ______________________________________________________________________
  47. INTRODUCTION                                           4
  48. INVOCATION                                             5
  49.  File Names                                            5
  50.  Option: a - Assembly Control                          6
  51.  Option: b - Binary Object Format                      7
  52.  Option: c - Contiguous Block Output                   7
  53.  Option: d - Define a Macro                            7
  54.  Option: e - Expand Source                             7
  55.  Option: f - Fill Memory                               7
  56.  Option: g - Object File Format                        7
  57.  Option: h - Hex Object Code Table                     7
  58.  Option: i - Ignore Case in Labels                     8
  59.  Option: l - Label Table                               8
  60.  Option: m - MOS Technology Object Format              8
  61.  Option: o - Set Number of Bytes per Object Record     8
  62.  Option: p - Page Listing File                         8
  63.  Option: q - Disable Listing File                      8
  64.  Option: r - Set Read Buffer Size                      8
  65.  Option: s - Enable Symbol File Generation             9
  66.  Option: t - Table Name                                9
  67.  Option: x - Enable Extended Instruction Set          10
  68.  Option: y - Enable Assembly Timing                   10
  69. ENVIRONMENT VARIABLES                                 11
  70.  TASMTABS                                             11
  71.  TASMOPTS                                             11
  72. EXIT CODES                                            11
  73. SOURCE FILE FORMAT                                    12
  74. EXPRESSIONS                                           13
  75.  Labels                                               13
  76.  Numeric Constants                                    13
  77.  Character Constants                                  14
  78.  String Constants                                     14
  79.  Location Counter Symbol                              14
  80.  Operators                                            15
  81. ASSEMBLER DIRECTIVES                                  17
  82.  ADDINSTR                                             17
  83.  AVSYM                                                17
  84.  BLOCK                                                17
  85.  BSEG/CSEG/DSEG/NSEG/XSEG                             17
  86.  BYTE                                                 17
  87.  CHK                                                  18
  88.  CODES/NOCODES                                        18
  89.  DB                                                   18
  90.  DW                                                   18
  91.  DEFINE                                               18
  92.  DEFCONT                                              19
  93.  EJECT                                                19
  94.  ELSE                                                 20
  95.  END                                                  20
  96.  ENDIF                                                20
  97.  EQU                                                  20
  98.  EXPORT                                               21
  99. TASM - Table Driven Assembler Version 2.9                              Page 3
  100.  
  101.  IFDEF                                                21
  102.  IFNDEF                                               21
  103.  IF                                                   22
  104.  INCLUDE                                              22
  105.  LIST/NOLIST                                          22
  106.  LOCALLABELCHAR                                       22
  107.  LSFIRST/MSFIRST                                      22
  108.  ORG                                                  22
  109.  PAGE/NOPAGE                                          23
  110.  SET                                                  23
  111.  SYM/AVSYM                                            23
  112.  TEXT                                                 24
  113.  TITLE                                                25
  114.  WORD                                                 26
  115. OBJECT FILE FORMATS                                   27
  116.  Intel Hex Object Format                              27
  117.  MOS Technology Hex Object Format                     28
  118.  Motorola Hex Object Format                           28
  119.  Binary Object Format                                 28
  120. LISTING FILE FORMAT                                   30
  121. PROM PROGRAMMING                                      31
  122. ERROR MESSAGES                                        32
  123. BUGS AND LIMITATIONS                                  35
  124.  
  125. APPENDIX A - ORDERING INFORMATION                     36
  126. TASM - Table Driven Assembler Version 2.9                              Page 4
  127.  
  128. INTRODUCTION
  129.  
  130.  
  131. TASM is a table driven cross assembler for the MS-DOS environment.  Assembly
  132. source code, written in the appropriate dialect (generally very close to the
  133. manufacturers assembly language), can be assembled with TASM, and the
  134. resulting object code transferred to the target microprocessor system via
  135. PROM or other mechanisms.
  136.  
  137. The current microprocessor families supported by TASM are:
  138.  
  139.         6502                       8048
  140.         6800/6801/68HC11           8051
  141.         6805                       8080/8085
  142.         TMS32010/TMS320C25         Z80
  143.         TMS7000
  144.  
  145. The user so inclined may build tables for other microprocessors. The
  146. descriptions of the various existing tables and instructions on building new
  147. tables are not in this document but can be found in the TASMTABS.DOC file on
  148. the TASM distribution disk.
  149.  
  150. TASM characteristics include:
  151.  
  152.   1.  Powerful expression parsing (17 operators).
  153.   2.  Supports a subset of the 'C' preprocessor commands.
  154.   3.  Macro capability (through use of DEFINE directive).
  155.   4.  Multiple statements per line.
  156.   5.  Four object file formats:
  157.           Intel hex, MOS Technology hex, Motorola hex, binary.
  158.   6.  Absolute code generation only.
  159.   7.  Source code available (in C).
  160.   8.  Uniform syntax  across  versions  for  different  target machines.
  161.   9.  Features in support of PROM programming (preset memory,
  162.           contiguous block).
  163.   10. Supports extended instructions for many of the supported
  164.           microprocessor families.
  165.   11. Tables read at run time; single TASM executable for all table versions.
  166.   12. Symbol table export for inclusion in subsequent assemblies.
  167.   13. Symbol table export file compatible with the Avocet 8051
  168.           simulator (.SYM format).
  169.  
  170. SHAREWARE
  171.  
  172. TASM is distributed as shareware. TASM is not public domain. The TASM
  173. distribution files may be freely copied (excluding the source code files)
  174. and freely used for the purpose of evaluating the suitability of TASM for
  175. a given purpose.  Use of TASM beyond a reasonable evaluation period requires
  176. registration.  Prolonged use without registration is unethical.
  177.  
  178. TASM - Table Driven Assembler Version 2.9                              Page 5
  179.  
  180. INVOCATION
  181.  
  182. TASM can be invoked as follows  (optional fields shown in brackets,  symbolic
  183. fields in italics):
  184.  
  185.     tasm -pn [-option_flag ...] src_file
  186.                            [obj_file [lst_file [exp_file [sym_file]]]]
  187.  
  188.     Where  option_flag can be one or more of the following:
  189.  
  190.         -table        Specify version (table = table designation)
  191.         -ttable       Table (alternate form of above)
  192.         -aamask       Assembly control (optional error checking)
  193.         -b            Produce object in binary (.COM) format
  194.         -c            Object file written as a contiguous block
  195.         -dmacro       Define a macro (or just a macro label)
  196.         -e            Show source lines after macro expansion
  197.         -ffillbyte    Fill entire memory space with fillbyte (hex)
  198.         -gobjtype     Object file (0=Intel, 1=MOS Tech, 2=Motorola, 3=binary)
  199.         -h            Produce hex table of the assembled code (in list file)
  200.         -i            Ignore case for labels
  201.         -l[al]        Produce a label table in the listing
  202.         -m            Produce object in MOS Technology format
  203.         -oobytes      Bytes per object record (for hex obj formats)
  204.         -p[lines]     Page the listing file (lines per page. default=60)
  205.         -q            Quiet, disable the listing file
  206.         -rkb          Set read buffer size in Kbytes (default 2 Kbytes)
  207.         -s            Write a symbol table file
  208.         -x[xmask]     Enable extended instruction set (if any)
  209.         -y            Time the assembly
  210.  
  211. The file parameters are defined as follows:
  212.  
  213. src_file  Source file name
  214. obj_file  Object code file name
  215. lst_file  Listing file name
  216. exp_file  Symbol export file (only if the EXPORT directive is used).
  217. sym_file  Symbol table file
  218.               (only if the "-s" option or the SYM/AVSYM directives are used).
  219.  
  220. The source file must be specified.  If not, some usage information is
  221. displayed. Default file names for all the other files are generated if they
  222. are not explicitly provided. The filename is formed by taking the source
  223. filename and changing the extension to one of the following:
  224.  
  225. Extension           File type
  226. ________________________________________________________
  227. .OBJ                Object file
  228. .LST                Listing file
  229. .EXP                Symbol export file
  230. .SYM                Symbol table  file
  231.  
  232. TASM has no built-in instruction set tables.  Instruction set definition
  233. files are read at run time. TASM determines which table to use based on the
  234. '-table' field shown above. For example, to assemble the code in a file
  235. called source.asm, one would enter:
  236. TASM - Table Driven Assembler Version 2.9                              Page 6
  237.  
  238.         tasm -48   source.asm            for an 8048 assembly
  239.         tasm -65   source.asm            for a  6502 assembly
  240.         tasm -51   source.asm            for an 8051 assembly.
  241.         tasm -85   source.asm            for an 8085 assembly.
  242.         tasm -80   source.asm            for a  Z80  assembly.
  243.         tasm -05   source.asm            for a  6805 assembly.
  244.         tasm -68   source.asm            for a  6800/6801/68HC11 assembly.
  245.         tasm -70   source.asm            for a  TMS7000  assembly.
  246.         tasm -3210 source.asm            for a  TMS32010 assembly.
  247.         tasm -3225 source.asm            for a  TMS320C25 assembly.
  248.  
  249. The file name that the tables are read from is formed by taking the digits
  250. specified after the '-' and appending it to 'TASM' then appending the '.TAB'
  251. extension. Thus, the '-48' flag would cause the tables to be read from the
  252. file 'TASM48.TAB'.
  253.  
  254. It is possible to designate tables by non numeric part numbers if the '-t'
  255. flag is used. For example, if a user built a table called TASMF8.TAB then
  256. TASM could be invoked as follows:
  257.  
  258.         tasm -tf8 source.asm
  259.  
  260. Each option flag must be preceded by a dash.  Options need not precede the
  261. file names, however. The various options are described below:
  262.  
  263. a - Assembly Control. TASM can provide additional error checking by
  264. specifying the '-a' option at the time of execution. If the '-a' is provided
  265. without a digit following, then all the available error checking is done. If
  266. a digit follows, then it is used as a mask to determine the error checks to
  267. be made. The bits of the mask are defined as follows:
  268.  
  269. Bit    Option Flag   Description
  270. ___________________________________________________________________________
  271. 0      -a1           Check for apparent illegal use of indirection
  272. 1      -a2           Check for unused data in the arguments
  273. 2      -a4           Check for duplicate labels
  274. 3      -a8           Check for non-unary operators at start of expression.
  275. 4      -a10          Check for 8051 AJMP/ACALL branches off current 2K page.
  276.  
  277. Combinations of the above bits  can also be used.   For example, '-a5'  would
  278. enable the checking for illegal indirection and duplicate labels.
  279.  
  280. Illegal indirection applies to micros that use parenthesis around an argument
  281. to indicate indirection. Since it is always legal to put an extra pair of
  282. parenthesis around any expression (as far as the expression parser is
  283. concerned), the user may think that he/she is indicating indirection for an
  284. instruction that has no indirection and TASM would not complain.  Enabling
  285. this checking will result in an error message (warning) whenever an outer
  286. pair of parenthesis is used and the instruction set definition table does not
  287. explicitly indicate that to be a valid form of addressing.
  288.  
  289. Unused data in arguments applies to cases where a single byte of data is
  290. needed from an argument, but the argument contains more than one byte of
  291. data. If a full sixteen bit address is used in a 'Load Immediate' type
  292. instruction that needs only a single byte, for example, an error message
  293. would be generated. Here is an example (6502 code):
  294. TASM - Table Driven Assembler Version 2.9                             Page 7
  295.  
  296. 0001   1234                    .org $1234
  297. tasm: Unused data in MS byte of argument.  Line 0002 in test.asm
  298. 0002   1234 A9 34       start  lda  #start
  299.  
  300. To make the above checks occur whenever you do an assembly, add a line like
  301. this to your AUTOEXEC.BAT file:
  302.  
  303.        SET TASMOPTS=-a
  304.  
  305. b  -  Binary Object Format. This option causes the object file to be written
  306. in binary - one byte for each byte of code/data.  Note that no address
  307. information is included in the object file in this format. The contiguous
  308. block (-c) output mode is forced when this option is invoked. This flag is
  309. equivalent to '-g3'.
  310.  
  311. c - Contiguous Block Output. If this option is specified, then all bytes in
  312. the range from the lowest used byte to the highest will be defined in the
  313. object file. Normally, with the default Intel Hex object format enabled, if
  314. the Program Counter (PC) jumps forward because of an .ORG directive, the
  315. bytes skipped over will not have any value assigned them in the object file.
  316. With this option enabled, no output to the object file occurs until the end
  317. of the assembly at which time the whole block is written.  This is useful
  318. when using TASM to generate code that will be put into a PROM so that all
  319. locations will have a known value. This option is often used in conjunction
  320. with the -f option to ensure all unused bytes will have a known value.
  321.  
  322. d -  Define a Macro. Macros are defined on the command line generally to
  323. control the assembly of various IFDEF's that are in the source file.  This
  324. is a convenient way to generate various versions of object code from a single
  325. source file.
  326.  
  327. e -  Expand Source. Normally TASM shows lines in the listing file just as they
  328. are in the source file. If macros are in use (via the DEFINE directive) it
  329. is sometimes desirable to see the source lines after expansion. Use the '-e'
  330. flag to accomplish this.
  331.  
  332. f -  Fill Memory. This option causes the memory image that TASM
  333. maintains to be initialized to the value specified by the two hex characters
  334. immediately following the 'f'. TASM maintains a memory image that is a full
  335. 64K bytes in size (even if the target processor cannot utilize that memory
  336. space). Invocation of this option introduces a delay at start up of up to 2
  337. seconds (time required to initialize all 64K bytes).
  338.  
  339. g -  Object File Format. TASM can generate object code in four different
  340. formats as indicated below:
  341.  
  342.         -g0    for Intel hex (default)
  343.         -g1    for MOS Technology hex (same as -m)
  344.         -g2    for Motorola hex
  345.         -g3    for binary (same as -b)
  346.  
  347. The '-m' and '-b' flags may also be used, as indicated above.
  348.  
  349. See the section on OBJECT FILE FORMATS for descriptions of each of the above.
  350.  
  351.  
  352. TASM - Table Driven Assembler Version 2.9                              Page 8
  353.  
  354. h - Hex Object Code Table. This option causes a hex table of the produced
  355. object code to appear in the listing file.  Each line of the table shows
  356. sixteen bytes of code.
  357.  
  358.  
  359. i - Ignore Case in Labels. TASM is normally case sensitive when dealing with
  360. labels. For those that prefer case insensitivity, the '-i' command line
  361. option can be employed.
  362.  
  363. l - Label Table. This option causes a label table to appear in the listing
  364. file. Each label is shown with its corresponding value. Macro labels (as
  365. established via the DEFINE directives) do not appear.
  366.  
  367. Two optional suffixes may follow the '-l' option:
  368.  
  369.         Suffix          Description
  370.         _______________________________________________
  371.         l               Use long form listing
  372.         a               Show all labels (including local labels)
  373.  
  374. The suffix should immediately follow the '-l'.  Here are some examples:
  375.  
  376.         -l      to show non-local labels in the short form
  377.         -la     to show all labels in the short form
  378.         -ll     to show non-local labels in the long form
  379.         -lal    to show all labels in the long form
  380.  
  381.  
  382. m - MOS Technology Object Format. This option causes the object file to be
  383. written in MOS Technology hex format rather than the default Intel hex
  384. format. See section on OBJECT FILE FORMATS for a description of the format.
  385.  
  386. o - Set Number of Bytes per Object Record. When generating object code in
  387. either the MOS Technology format or the Intel hex format,  a default of 24
  388. (decimal) bytes of object are defined on each record. This can be altered by
  389. invoking the '-o' option immediately followed by  two hex digits defining
  390. the number of bytes per record desired. For example, if 32 bytes per record
  391. are desired, one might invoke TASM as:
  392.  
  393.         TASM -48 -o20 source.asm
  394.  
  395. p - Page Listing File. This option causes the listing file to have top of
  396. page headers and form feeds inserted at appropriate intervals (every sixty
  397. lines of output). To override the default of sixty lines per page, indicate
  398. the desired number of lines per page as a decimal number immediatly following
  399. the '-p'. Here is an example:
  400.  
  401.         TASM -48 -p56 source.asm
  402.  
  403. q - Disable Listing File.  This option causes all output to the listing  file
  404. to be  suppressed, unless a .LIST directive is encountered in the source file
  405. (see LIST/NOLIST directives).
  406.  
  407. r - Set Read Buffer Size. This option overrides the default read buffer  size
  408. of 2 Kbytes.  The first hexadecimal digit immediately after the 'r' is  taken
  409. as the  number of  K  bytes to  allocate for  the  read buffer  (.e.g.  '-r8'
  410. TASM - Table Driven Assembler Version 2.9                              Page 9
  411.  
  412. indicates an 8K byte buffer, '-rf' indicates  a 15K byte buffer).  Note  that
  413. that read buffers are  taken from the  same memory pool  as labels and  macro
  414. storage, and that additional read buffers are needed if "includes" are  used.
  415. Thus, using 8K byte buffers may be suitable for most assemblies, but programs
  416. with large numbers of symbols may not allow such a value.  Also, reducing the
  417. buffer size  to 1  Kbyte can  increase the  memory pool  available for  label
  418. storage, if such is needed.
  419.  
  420. s - Enable Symbol File Generation.    If this flag  is set, a symbol file  is
  421. generated at the end of the assembly.  The format of the file is one line per
  422. label, each label starts in the first  column and is followed by white  space
  423. and then four hexadecimal digits representing the  value of the label.    The
  424. following illustrates the format:
  425.  
  426.         label1         FFFE
  427.         label2         FFFF
  428.         label3         1000
  429.  
  430. The symbol  file name  can be  provided as  the fifth  file name  on the  the
  431. command line, or the name will be generated from the source file name with  a
  432. '.SYM' extension.  The symbol table file  can also be  generated by  invoking
  433. the SYM directive.  The AVSYM directive also generates the symbol file but in
  434. a different format (see section on ASSEMBLER DIRECTIVES).
  435.  
  436. t - Table Name.  As an alternative to specifying the instruction set table as
  437. two decimal digits, the table indication may be preceeded by the '-t' option.
  438. This is useful if the desired table name starts with a non-numeric.  Thus,  a
  439. table for an F8 might be selected as:
  440.  
  441.         TASM -tf8 source.asm
  442.  
  443. TASM would expect to read the  instruction set definition tables from a  file
  444. named TASMF8.TAB.
  445. TASM - Table Driven Assembler Version 2.9                             Page 10
  446.  
  447.  
  448. x - Enable Extended Instruction Set.  If a processor family has  instructions
  449. that are valid for only  certain members, this option  can be used to  enable
  450. those beyond the basic standard instruction set.  A hex digit may follow  the
  451. 'x' to indicate a  mask value used in  selecting the appropriate  instruction
  452. set.  Bit 0 of the mask selects the basic instruction set, thus a '-x1' would
  453. have  no  effect.    A  '-x3'  would  enable  the  basic  set  plus  whatever
  454. instructions have bit  1 set in  their class mask.   A '-x'  without a  digit
  455. following is equivalent to a '-xf' which sets all four of the mask bits.  The
  456. following table indicates the current extended instruction sets available  in
  457. the TASM tables:
  458.  
  459. Base   Base           Extension 1   Extension 2  Extension 3    Extension 4
  460. Table  Family         (-x3)         (-x7)        (-x5)          (-x9)
  461. _____________________________________________________________________________
  462. 48     8048           8041A                      8022           8021
  463. 65     6502           R65C02                     R65C00/21
  464. 05     6805           M146805 CMOS               HC05C4
  465. 80     Z80            HD64180       
  466. 68     6800           6801/6803     68HC11
  467. 51     8051                         
  468. 85     8080                         
  469. 3210   TMS32010                     
  470. 3225   TMS320C25                                 TMS320C26
  471. 70     TMS7000                      
  472.  
  473. The above  table does  not attempt  to show  the many  microprocessor  family
  474. members that may apply under a given column.
  475.  
  476. See the TASMTABS.DOC on-line document for details on each specific table.
  477.  
  478. y - Enable Assembly Timing.  If  this option is enabled TASM will generate  a
  479. statement of elapsed time and  assembled lines per second  at the end of  the
  480. assembly.
  481.  
  482. TASM - Table Driven Assembler Version 2.9                             Page 11
  483.  
  484. ENVIRONMENT VARIABLES
  485.  
  486. The TASM  environment can  be customized  by using  the enviroment  variables
  487. listed below:
  488.  
  489. TASMTABS.  This  variable  specifies  the  path  to  be  searched  for   TASM
  490. instruction set definition tables.   If it is  not defined then the  table(s)
  491. must exist in the current  working directory.  If it  was desired to put  the
  492. instruction set definition  tables in a  directory called 'TASM'  on a  drive
  493. called 'C:', the following statement would be appropriate in the AUTOEXEC.BAT
  494. file:
  495.  
  496.         set TASMTABS=C:\TASM
  497.  
  498. TASMOPTS. This variable specifies  TASM command line options  that are to  be
  499. invoked every time TASM is executed.  For example, if TASM is being used  for
  500. 8048 assemblies  with  binary  object  file  output  desired,  the  following
  501. statement would be appropriate in the AUTOEXEC.BAT file:
  502.  
  503.         set TASMOPTS=-48 -b
  504.  
  505.  
  506. EXIT CODES
  507.  
  508. When TASM terminates, it will return to DOS the following exit codes:
  509.  
  510. Exit Code      Meaning
  511. ___________________________________________________________
  512. 0              Normal completion, no assembly errors
  513. 1              Normal completion, with assembly errors
  514. 2              Abnormal completion, insufficient memory
  515. 3              Abnormal completion, file access error
  516. 4              Abnormal completion, general error
  517.  
  518.  
  519. Exit codes 2 and above  will also be accompanied  by messages to the  console
  520. concerning the error.
  521.  
  522. TASM - Table Driven Assembler Version 2.9                             Page 12
  523.  
  524. SOURCE FILE FORMAT
  525.  
  526. Statements in the  source file must  conform to a  format as follows  (except
  527. for assembler  directive  statements  which are  described  in  a  subsequent
  528. section):
  529.  
  530.         label  operation    operand       comment
  531.  
  532. All of  the  fields  are  optional,  under  appropriate  circumstances.    An
  533. arbitrary amount of white space (space and tabs) can separate each field  (as
  534. long as the maximum line length of 255 characters is not exceeded).  Each  of
  535. the fields are described below:
  536.  
  537. Label Field. If the first character of the line is alphabetic, it is  assumed
  538. to be the start of  a label.  Subsequent characters  are accepted as part  of
  539. that label until a space, tab, or ':' is encountered.  The assembler  assigns
  540. a value to the label corresponding  to the current location counter.   Labels
  541. can be a maximum of 32 characters  long.  Labels can contain upper and  lower
  542. case letters, digits, underscores, and  periods (the first character must  be
  543. alphabetic).  Labels are  case sensitive - the  label 'START' is a  different
  544. label from 'start' - unless the '-i' (ignore case) option is enabled.
  545.  
  546. Operation Field. The operation field  contains an instruction mnemonic  which
  547. specifies the action  to be  carried out by  the target  processor when  this
  548. instruction is executed.  The interpretation of each mnemonic is dependent on
  549. the target microprocessor  (as indicated by  the selected TASM  table).   The
  550. operation field may  begin in  any column except  the first.   The  operation
  551. field is case insensitive.
  552.  
  553. Operand Field. The operand field specifies the data to be operated on by  the
  554. instruction.  It  may include expressions  and/or special symbols  describing
  555. the addressing mode  to be  used.  The  actual format  and interpretation  is
  556. dependent on  the target  processor.   For a  description of  the format  for
  557. currently supported  processors,  see  the  TASMTABS.DOC  file  on  the  TASM
  558. distribution disk.
  559.  
  560. Comment Field.  The comment field always  begins with a semicolon.  The  rest
  561. of the line from the semicolon to the end of the line is ignored by TASM, but
  562. passed on to  the listing file  for annotation purposes.   The comment  field
  563. must be the last field on a line,  but it may be the only field, starting  in
  564. column one, if desired.
  565.  
  566. Multiple  Statement Lines.   If the backslash  character is encountered on  a
  567. source line,   it  is  treated as  a  newline.   The  remainder of  the  line
  568. following  the  backslash  will be processed as an independent line of source
  569. code.  This allows one to put multiple statements  on a line.  This  facility
  570. is not so useful of itself,   but when coupled with  the capability  of   the
  571. DEFINE   directive,    powerful    multiple  statement    macros    can    be
  572. constructed  (see  section  on ASSEMBLER DIRECTIVES).  Note that when   using
  573. the  statement  separator,  the character  immediately  following  it  should
  574. be considered the first character of a new  line,  and thus must either be  a
  575. start of a label or  white space (not an instruction).  As the examples show,
  576. a space is put between the backslash and the start of the next instruction.
  577.  
  578.  
  579. Some  examples  of  valid  source  statements follow (6502 mnemonics shown):
  580. TASM - Table Driven Assembler Version 2.9                             Page 13
  581.  
  582.  
  583. label1   lda      byte1   ;get the first byte
  584.          dec      byte1
  585.          jne      label1
  586.                   
  587. ;                 
  588. label2            
  589.          sta      byte2,X
  590.          ;        a multiple statement line follows
  591.          lda      byte1\ sta byte1+4\ lda byte2\ sta byte2+4
  592.  
  593.  
  594.  
  595. EXPRESSIONS
  596.  
  597. Expressions are  made  up of  various  syntactic elements  (tokens)  combined
  598. according to  a set  of syntactical  rules.   The  tokens are  summarized  as
  599. follows:
  600.  
  601.         1.  Labels
  602.         2.  Constants
  603.         3.  Location Counter Symbol
  604.         4.  Operators
  605.         5.  Parenthesis
  606.  
  607. Labels. Labels are strings of characters that have a numeric value associated
  608. with them, generally representing an address.   Labels can contain upper  and
  609. lower case letters, digits,  underscores, and periods.   The first  character
  610. must be a  letter or the  local label prefix  (default '_'). The  value of  a
  611. label is  limited  to  32  bit  precision.   Labels  can  contain  up  to  32
  612. characters, all of which are significant (none are ignored when looking at  a
  613. label's value, as in some assemblers).   Case is significant unless the  '-i'
  614. command line option is invoked.
  615.  
  616. Local labels must  only be  unique within the  scope of  the current  module.
  617. Modules are defined with the MODULE directive.  Here is an example:
  618.  
  619.                .MODULE xxx
  620.                lda regx
  621.                jne _skip
  622.                dec
  623.         _skip  rts
  624.                
  625.                .MODULE yyy
  626.                lda regy
  627.                jne _skip
  628.                dec
  629.         _skip  rts
  630.  
  631.  
  632. In the above example, the _skip label is reused without harm.  As a  default,
  633. local labels are not shown in the label table linting (resulting from the  '-
  634. l' command line  option).   See also  sections on  MODULE and  LOCALLABELCHAR
  635. directives.
  636.  
  637. Numeric Constants. Numeric constants must  always begin with a decimal  digit
  638. TASM - Table Driven Assembler Version 2.9                             Page 14
  639.  
  640. (thus hexadecimal constants that  start with a letter  must be prefixed by  a
  641. '0' unless the  '$' prefix is  used).  The  radix is determined  by a  letter
  642. immediately following the digit string according to the following table:
  643.  
  644.        Radix          Suffix                   Prefix
  645.        ______________________________________________________
  646.        2              B or b                   %
  647.        8              O or o                   @
  648.        10             D or d (or nothing)      
  649.        16             H or h                   $
  650.  
  651. Decimal is the default radix, so decimal constants need no suffix or prefix.
  652.  
  653. The following representations are equivalent:
  654.  
  655.        1234H          or     $1234
  656.        100d           or     100
  657.        177400O        or     @177400
  658.        01011000b      or     %01011000
  659.  
  660. The prefixes  are provided  for  compatibility with  some other  source  code
  661. formats but  introduce  a  problem of  ambiguity.    Both '%'  and  '$'  have
  662. alternate uses  ('%' for  modulo,  '$' for  location  counter symbol).    The
  663. ambiguity is  resolved  by examining  the  context.   The  '%'  character  is
  664. interpreted as the modulo operator only if it is in a postion suitable for  a
  665. binary operator. Similarly, if the first character following a '$' is a valid
  666. hexadecimal digit, it is assumed to be a radix specifier and not the location
  667. counter.
  668.  
  669. Character Constants. Character constants are single characters surrounded  by
  670. single quotes  (following  quote  is  optional).   The  ASCII  value  of  the
  671. character in the quotes is returned.  No escape provision exists to represent
  672. non-printable characters within the quotes,  but this is not necessary  since
  673. these can be just  as easily represented as  numeric constants (or using  the
  674. TEXT directive which does allow escapes).
  675.  
  676. String Constants. String constants are  one or more characters surrounded  by
  677. double quotes.  Note  that string constants are  not allowed in  expressions.
  678. They are  only  allowable  following  the  TITLE,  BYTE  and  TEXT  assembler
  679. directives. The quoted strings  may also contain escape  sequences to put  in
  680. unprintable values.  The following escape sequences are supported:
  681.  
  682.         Escape
  683.         Sequence       Description
  684.         ___________________________________________________________
  685.         \n             Line Feed
  686.         \r             Carriage return
  687.         \b             Backspace
  688.         \t             Tab
  689.         \f             Formfeed
  690.         \\             Backslash
  691.         \"             Quote
  692.         \000           Octal value of character
  693.  
  694. Location  Counter  Symbol.   The  current value of the location counter  (PC)
  695. can be  used in  expressions by  placing a  '$' in  the desired  place.   The
  696. TASM - Table Driven Assembler Version 2.9                             Page 15
  697.  
  698. Location Counter Symbol is allowable anywhere  a numeric constant is.   (Note
  699. that if the '$' is followed  by a decimal digit then it  is  taken to be  the
  700. hexadecimal radix  indicator  instead  of the  Location  Counter  symbol,  as
  701. mentioned above).    The '*'  may  also be  used  to represent  the  location
  702. counter,  but  is  less   preferred  because  of   its  ambiguity  with   the
  703. multiplicative operator.
  704.  
  705. Operators. Expressions  can  optionally  contain operators  to  perform  some
  706. alterations or  calculations  on  particular  values.     The  operators  are
  707. summarized as follows:
  708.  
  709.        Operator    Type            Description
  710.        __________________________________________
  711.        +           Additive        addition
  712.        -                           subtraction
  713.                                    
  714.        *           Multiplicative  multiplication
  715.        /                           division
  716.        %                           modulo
  717.        <<                          logical shift left
  718.        >>                          logical shift right
  719.                                    
  720.        ~           Unary           bit inversion (one's complement)
  721.        -                           unary negation
  722.                                    
  723.        =           Relational      equal
  724.        ==                          equal
  725.        !=                          not equal
  726.        <                           less than
  727.        >                           greater than
  728.        <=                          less than or equal
  729.        >=                          greater than or equal
  730.                                    
  731.        &           Binary          binary 'and'
  732.        |                           binary 'or'
  733.        ^                           binary 'exclusive or'
  734.  
  735. The syntax is much the same as in 'C' with the following notes:
  736.  
  737. 1.  No operator precedence  is in effect.  Evaluation  is from left to  right
  738. unless grouped by  parenthesis (see example below).
  739.  
  740. 2.  All evaluations are done with 32 bit signed precision.
  741.  
  742. 3.  Both '=' and '==' are allowable equality checkers.  This is allowed since
  743. the syntax  does not  provide assignment  capability (as  '=' would  normally
  744. imply).
  745.  
  746. The relational operators return a value of 1 if the relation is true and 0 if
  747. it is false.  Thirtytwo bit signed arithmetic is used.
  748.  
  749. It is  always  a  good idea  to  explicitly  indicate the  desired  order  of
  750. evaluation with  parenthesis,   especially  to   maintain  portability  since
  751. TASM does  not  evaluate  expressions  in  the  same  manner  as  many  other
  752. assemblers.   To  understand  how it  does  arrive    at   the    values  for
  753. expressions, consider the following example:
  754. TASM - Table Driven Assembler Version 2.9                             Page 16
  755.  
  756.         1 + 2*3 + 4
  757.  
  758. TASM would evaluate this as:
  759.  
  760.        (((1 + 2) * 3) + 4) = 13
  761.  
  762. Typical rules of precedence would cause the (2*3) to be evaluated first, such
  763. as:
  764.  
  765.         1 + (2*3) + 4      = 11
  766.  
  767. To make  sure  you get  the  desired  order of  evaluation,  use  parenthesis
  768. liberally.
  769.  
  770. Note that  TASM versions  earlier than  2.7.8 employed  a somewhat  different
  771. method of evaluating expressions  (also without precedence) that  essentially
  772. resulted in a right to left evaluation.
  773.  
  774. Here are some examples of valid expressions:
  775.  
  776.         (0f800H + tab)
  777.         (label_2 >> 8)
  778.         (label_3 << 8) & $f000
  779.         $ + 4
  780.         010010000100100b + 'a'
  781.         (base + ((label_4 >> 5) & (mask << 2))
  782. TASM - Table Driven Assembler Version 2.9                             Page 17
  783.  
  784. ASSEMBLER DIRECTIVES
  785.  
  786. Most of  the  assembler directives  have  a  format similar  to  the  machine
  787. instruction format.    However,  instead of  specifying  operations  for  the
  788. processor to carry out,  the directives cause the  assembler to perform  some
  789. function related to  the assembly process.  TASM has two  types of  assembler
  790. directives - those that mimic the 'C' preprocessor functions, and those  that
  791. resemble the more traditional assembler  directive functions.  Each of  these
  792. will be discussed.
  793.  
  794. The 'C' preprocessor  style directives are  invoked with a  '#' as the  first
  795. character of the line followed by the appropriate directive (just as in 'C').
  796. Thus, these directives cannot have a label preceding them (on the same line).
  797. Note that in the examples directives are shown in upper case, however, either
  798. upper or lower case is acceptable.
  799.  
  800. ADDINSTR. This directive can  be used to  define additional instructions  for
  801. TASM to use in this assembly.  The format is:
  802.  
  803. [label]  .ADDINSTR inst args opcode nbytes modop class shift binor
  804.  
  805. The fields are  separated by  white space  just as  they would  appear in  an
  806. instruction  definition  file.  See  the   TASMTABS.DOC  file  on  the   TASM
  807. distribution disk for more detail.
  808.  
  809. AVSYM.  See SYM/AVSYM.
  810.  
  811. BLOCK. This directive causes the Instruction Pointer to advance the specified
  812. number of bytes without assigning values to the skipped over locations.   The
  813. format is:
  814.  
  815.         [label] .BLOCK        expr
  816.  
  817. Some valid examples are:
  818.  
  819.         word1   .BLOCK     2
  820.         byte1   .block     1
  821.         buffer  .block     80
  822.  
  823. BSEG/CSEG/DSEG/NSEG/XSEG. These  directives can  be invoked  to indicate  the
  824. appropriate address space for  symbols and labels  defined in the  subsequent
  825. code.   The  invocation  of these  directives  in  no way  affects  the  code
  826. generated, only provides  more information in  the symbol table  file if  the
  827. AVSYM directive is employed.   Segment control directives  such as these  are
  828. generally supported  by assemblers  that  generate relocatable  object  code.
  829. TASM does not generate  relocatable object code and  does not support a  link
  830. phase, so these  directives have  no direct  effect on  the resulting  object
  831. code. The segments are defined as follows:
  832.  
  833.         Directive       Segment Description
  834.         _________________________________________________________
  835.         BSEG            Bit  address
  836.         CSEG            Code address
  837.         DSEG            Data address (internal RAM)
  838.         NSEG            Number or constant (EQU)
  839.         XSEG            External data address (external RAM)
  840. TASM - Table Driven Assembler Version 2.9                             Page 18
  841.  
  842. BYTE.  This directive allows a value assignment to the byte pointed to by the
  843. current Instruction Pointer.  The format is:
  844.  
  845.         [label] .BYTE   expr [, expr ...]
  846.  
  847. Onlythe lower eight bits of expr are used.  Multiple bytes may be assigned by
  848. separating them with  commas or  (for printable strings)  enclosed in  double
  849. quotes. Here are some examples:
  850.  
  851.  
  852.       label1   .BYTE     10010110B
  853.                .byte     'a'
  854.                .byte     0
  855.                .byte     100010110b,'a',0
  856.                .byte     "Hello", 10, 13, "World"
  857.  
  858.  
  859. CHK.  This directive causes  a checksum to be  computed and deposited at  the
  860. current location.    The  starting  point  of  the  checksum  calculation  is
  861. indicated as an argument.  Here is the format:
  862.  
  863.         .CHK    starting_addr
  864.  
  865. Here is an example:
  866.  
  867.  
  868.         start:  NOP
  869.                 LDA #1
  870.                 .CHK start
  871.  
  872.  
  873. The checksum is calculated as the simple arithmetic sum of all bytes starting
  874. at the start_add up to  but not including the  address of the CHK  directive.
  875. The least significant byte is all that is used.
  876.  
  877. CODES/NOCODES. These directives can be used to alternately turn on or off the
  878. generation of formatted listing output with line numbers, opcodes, data, etc.
  879. With NOCODES  in  effect, the  source  lines are  sent  to the  listing  file
  880. untouched.  This  is useful around  blocks of  comments that need  a full  80
  881. columns of width for clarity.
  882.  
  883. DB.  This is alternate form of the BYTE directive.
  884.  
  885. DW.  This is alternate form of the WORD directive.
  886.  
  887. DEFINE. The DEFINE directive  is one of the  most powerful of the  directives
  888. and allows string substitution with optional arguments (macros).  The  format
  889. is as follows:
  890.  
  891.     #DEFINE  macro_label[(arg_list)]  [macro_definition]
  892.  
  893.     macro_label := string to be expanded when found in the source file.
  894.                   
  895.     arg_list    := optional argument list for variable substitution
  896.                   
  897.     macro_def   := string to replace the occurrences of macro_label in
  898. TASM - Table Driven Assembler Version 2.9                             Page 19
  899.  
  900.                             the source file.
  901.  
  902. The simplest form of the DEFINE directive might look like this:
  903.  
  904.         #DEFINE         MLABEL
  905.  
  906. Notice that  no  substitutionary string  is  specified.   The  purpose  of  a
  907. statement like this would typically be to  define a label for the purpose  of
  908. controlling some subsequent conditional assembly (IFDEF or IFNDEF).
  909.  
  910. A more complicated example, performing  simple substitution, might look  like
  911. this:
  912.  
  913.         #DEFINE         VAR1_LO         (VAR1 & 255)
  914.  
  915. This statement would cause all occurrences of  the  string  'VAR1_LO' in  the
  916. source to be substituted with '(VAR1 & 255)'.
  917.  
  918. As   a   more   complicated   example,    using   the   argument    expansion
  919. capability, consider this:
  920.  
  921.         #DEFINE         ADD(xx,yy)      clc\ lda xx\ adc yy\ sta xx
  922.  
  923. If the source file then contained a line like this:
  924.  
  925.         ADD(VARX,VARY)
  926.  
  927. It would be expanded to:
  928.  
  929.         clc\ lda VARX\ adc VARY\ sta VARX
  930.  
  931. The above  example shows  the use  of the  backslash ('\')  character   as  a
  932. multiple   instruction    statement  delimiter.   This  approach  allows  the
  933. definition of fairly  powerful,   multiple statement   macros.   The  example
  934. shown generates 6502 instructions to add one memory location to another.
  935.  
  936. Some rules associated with the argument list:
  937.  
  938. 1.  Use a maximum of 10 arguments.
  939.  
  940. 2.  Each argument should be a maximum of 15 characters.
  941.  
  942. Note that macros can be defined on the TASM command line, also, with the '-d'
  943. option flag.
  944.  
  945. DEFCONT. This directive can be used to  add to the last macro started with  a
  946. DEFINE directive.   This  provides a  convenient way  to define  long  macros
  947. without running off the edge of the page. The ADD macro shown above could  be
  948. defined as follows:
  949.  
  950.         #DEFINE         ADD(xx,yy)     clc
  951.         #DEFCONT                     \ lda xx
  952.         #DEFCONT                     \ adc yy
  953.         #DEFCONT                     \ sta xx
  954.  
  955. EJECT.   This   directive   can   be used  to force  a top  of form  and  the
  956. TASM - Table Driven Assembler Version 2.9                             Page 20
  957.  
  958. generation of a page  header on the  list file.  It  has no   effect  if  the
  959. paging mode is off (see PAGE/NOPAGE).  The format is:
  960.  
  961.         .EJECT
  962.  
  963. ELSE.  This directive  can optionally be  used with IFDEF,  IFNDEF and IF  to
  964. delineate an alternate block of code to be assembled if the block immediately
  965. following the IFDEF, IFNDEF or IF is not assembled.
  966.  
  967. Here are some examples of the use of IFDEF, IFNDEF,  IF,  ELSE,  and ENDIF:
  968.  
  969.         #IFDEF   label1
  970.         lda      byte1
  971.         sta      byte2
  972.         #ENDIF   
  973.                  
  974.         #ifdef   label1
  975.         lda      byte1
  976.         #else    
  977.         lda      byte2
  978.         #endif   
  979.                  
  980.         #ifndef  label1
  981.         lda      byte2
  982.         #else    
  983.         lda      byte1
  984.         #endif   
  985.  
  986.         #if ($ >= 1000h)
  987.         ; generate an invalid statement to cause an error
  988.         ;  when we go over the 4K boundary.
  989.          !!! PROM bounds exceeded.
  990.         #endif
  991.  
  992. END.   This  directive should follow all  code/data generating statements  in
  993. the source file.  It forces the last record to be written to the object file.
  994. The format is:
  995.  
  996.         [label]       .END
  997.  
  998. ENDIF. This directive must  always follow an IFDEF,  IFNDEF, or IF  directive
  999. and signifies the end of the conditional block.
  1000.  
  1001. EQU. This directive can be used to  assign values to labels.  The labels  can
  1002. then be used in expressions in place of the literal constant.  The format is:
  1003.  
  1004.         label   .EQU    expr
  1005.  
  1006. Here is an example:
  1007.  
  1008.         MASK   .EQU   0F0H
  1009.         ;             
  1010.                lda    IN_BYTE
  1011.                and    MASK
  1012.                sta    OUT_BYTE
  1013.  
  1014. TASM - Table Driven Assembler Version 2.9                             Page 21
  1015.  
  1016. An alternate form of 'EQU' is  '='.  The previous example is equivalent to:
  1017.  
  1018.         MASK    =   0F0H
  1019.  
  1020. or
  1021.  
  1022.         MASK    =0FOH
  1023.         MASK    =$FO
  1024.  
  1025. White space must exist after the label,  but none is required after the '='.
  1026.  
  1027. EXPORT. This directive can be used to define labels (symbols) that are to  be
  1028. written to the export symbol file.  The symbols are written as equates (using
  1029. the .EQU  directive)  so  that  the  resulting file  can  be  included  in  a
  1030. subsequent assembly.  This feature can help overcome some of the deficiencies
  1031. of TASM due to its lack of a relocating linker. The format is:
  1032.  
  1033. [label]  .EXPORT      label
  1034.  
  1035. The following example  illustrates the use  of the EXPORT  directive and  the
  1036. format of the resulting export file:
  1037.  
  1038. Source file:
  1039.  
  1040.         .EXPORT        read_byte
  1041.         .EXPORT        write_byte
  1042.         .EXPORT        open_file
  1043.  
  1044. Resulting export file:
  1045.  
  1046. read_byte      .EQU   $1243
  1047. write_byte     .EQU   $12AF
  1048. open_file      .EQU   $1301
  1049.  
  1050.  
  1051. IFDEF. This directive can be used to optionally assemble a block of code.  It
  1052. has the following form:
  1053.  
  1054.         #IFDEF  macro_label
  1055.  
  1056. When invoked, the list of macro labels (established via DEFINE directives) is
  1057. searched.  If the label is found, the following lines of code are  assembled.
  1058. If not found, the input file is skipped  until an ENDIF or ELSE directive  is
  1059. found.
  1060.  
  1061. Lines that are skipped over still appear in the listing file, but a '~'  will
  1062. appear immediately after the current PC and no object code will be  generated
  1063. (this is applicable to IFDEF, IFNDEF, and IF).
  1064.  
  1065. IFNDEF. This directive is the opposite of the IFDEF directive.  The block  of
  1066. code following is assembled only  if the specified macro_label is  undefined.
  1067. It has the following form:
  1068.  
  1069.         #IFNDEF  macro_label
  1070.  
  1071. When invoked, the list of macro labels (established via DEFINE directives) is
  1072. TASM - Table Driven Assembler Version 2.9                             Page 22
  1073.  
  1074. searched.   If the  label  is not  found, the  following  lines of  code  are
  1075. assembled.  If it is found, the input file is skipped until an ENDIF or  ELSE
  1076. directive is found.
  1077.  
  1078. IF.   This directive  can be  used to  optionally assemble  a block  of  code
  1079. dependent on the value of a given expression.  The format is as follows:
  1080.  
  1081.         #IF     expr
  1082.  
  1083. If the expression expr evaluates to non-zero, the following block of code  is
  1084. assembled (until an ENDIF or ELSE is encountered).
  1085.  
  1086. INCLUDE.  The INCLUDE directive reads  in and assembles the indicated  source
  1087. file.  INCLUDEs can  be nested up  to six levels.   This allows a  convenient
  1088. means to keep common definitions, declarations, or subroutines in files to be
  1089. included as needed.  The format is as follows:
  1090.  
  1091.         #INCLUDE        filename
  1092.  
  1093. The filename must be enclosed in double quotes.  Here are some examples:
  1094.  
  1095.         #INCLUDE       "macros.h"
  1096.         #include       "equates"
  1097.         #include       "subs.asm"
  1098.  
  1099. LIST/NOLIST.  These directives can be used to alternately turn the output  to
  1100. the list file on (LIST) or off (NOLIST).  The format is:
  1101.  
  1102.         .LIST
  1103.         .NOLIST
  1104.  
  1105. LOCALLABELCHAR. This directive can be used to override the default "_" as the
  1106. label prefix indicating a local label.  For example, to change the prefix  to
  1107. "?" do this:
  1108.  
  1109.         .LOCALLABELCHAR "?"
  1110.  
  1111. Be carefull to  use only  characters that  are not  operators for  expression
  1112. evaluation.  To do  so causes ambiguity for  the expression evaluator.   Some
  1113. safe characters are "?", "{", and "}".
  1114.  
  1115. LSFIRST/MSFIRST. These  directives  determine  the  byte  order  rule  to  be
  1116. employed for the WORD  directive.  The default  (whether correct or not)  for
  1117. all TASM  versions  is the  least  significant  byte first  (LSFIRST).    The
  1118. following illustrates its effect:
  1119.  
  1120.         0000  34 12    .word $1234
  1121.         0002           .msfirst
  1122.         0002  12 34    .word $1234
  1123.         0004           .lsfirst
  1124.         0004  34 12    .word $1234
  1125.  
  1126.  
  1127. ORG. This directive provides the means to set the Instruction Pointer (a.k.a.
  1128. Program Counter) to the desired value.  The format is:
  1129.  
  1130. TASM - Table Driven Assembler Version 2.9                             Page 23
  1131.  
  1132.         [label] .ORG    expr
  1133.  
  1134. The label is optional.  The Instruction pointer is assigned the value of  the
  1135. expression, expr.  For example, to  generate code starting at address  1000H,
  1136. the following could be done:
  1137.  
  1138.         start   .ORG    1000H
  1139.  
  1140. The expression  (expr)  may contain  references  to the  current  Instruction
  1141. Pointer, thus  allowing various  manipulations to  be done.  For example,  to
  1142. align the Instruction Pointer  on the next 256  byte boundary, the  following
  1143. could be done:
  1144.  
  1145.                 .ORG  (($ + 0FFH) & 0FF00H)
  1146.  
  1147. ORG can also be used to reserve space without assigning values:
  1148.  
  1149.                .ORG    $+8
  1150.  
  1151. An alternate form of ORG  is '*=' or '$='.   Thus the following two  examples
  1152. are exactly equivalent to the previous example:
  1153.  
  1154.                 *=*+8
  1155.                 $=$+8
  1156.  
  1157. PAGE/NOPAGE.  These  directives can be  used to alternately  turn the  paging
  1158. mode on (PAGE) or  off (NOPAGE).  If  paging is in  effect, then every  sixty
  1159. lines of output will be  followed by a Top of  Form character and a two  line
  1160. header containing page number, filename, and the title.  The format is:
  1161.  
  1162.         .PAGE
  1163.         .NOPAGE
  1164.  
  1165. The number of lines per page can be set with the '-p' command line option.
  1166.  
  1167.  
  1168. SET. This directive allows the value of an existing label to be changed.  The
  1169. format is:
  1170.  
  1171.         label   .SET    expr
  1172.  
  1173. The use of the SET directive should be avoided since changing the value of  a
  1174. label can sometimes  cause phase  errors between  pass 1  and pass  2 of  the
  1175. assembly.
  1176.  
  1177. SYM/AVSYM. These directives can be  used to cause a  symbol table file to  be
  1178. generated.  The format is:
  1179.  
  1180.         .SYM    ["symbol_filename"]
  1181.         .AVSYM  ["symbol_filename"]
  1182.  
  1183. TASM - Table Driven Assembler Version 2.9                             Page 24
  1184.  
  1185. For example:
  1186.  
  1187.         .SYM       "symbol.map"
  1188.         .SYM       
  1189.         .AVSYM     "prog.sym"
  1190.         .AVSYM
  1191.  
  1192. The two  directives are  similar, but  result in  a different  format of  the
  1193. symbol table file.  The format of the  SYM file is one line per symbol,  each
  1194. symbol starts in the  first column and  is followed by  white space and  then
  1195. four hexadecimal digits representing the value of the symbol.  The  following
  1196. illustrates the format:
  1197.  
  1198.        label1         FFFE
  1199.        label2         FFFF
  1200.        label3         1000
  1201.  
  1202. The AVSYM is provided  to generate symbol tables  compatible with the  Avocet
  1203. 8051 simulator.  The format is similar, but each line is prefixed by an  'AS'
  1204. and each symbol value is prefixed by a segment indicator:
  1205.  
  1206.         AS     start          C:1000
  1207.         AS     read_byte      C:1243
  1208.         AS     write_byte     C:1280
  1209.         AS     low_nib_mask   N:000F
  1210.         AS     buffer         X:0080
  1211.  
  1212. The segment  prefixes are  determined by  the most  recent segment  directive
  1213. invoked (see BSEG/CSEG/DSEG/NSEG/XSEG directives).
  1214.  
  1215. TEXT. This directive allows an ASCII string to be used to assign values to  a
  1216. sequence of  locations starting  at  the current  Instruction Pointer.    The
  1217. format is:
  1218.  
  1219.         [label] .TEXT   "string"
  1220.  
  1221. The ASCII value of each character in string is taken and assigned to the next
  1222. sequential location.  Some escape sequences are supported as follows:
  1223.  
  1224.         Escape
  1225.         Sequence       Description
  1226.         ___________________________________________________
  1227.         \n             Line Feed
  1228.         \r             Carriage return
  1229.         \b             Backspace
  1230.         \t             Tab
  1231.         \f             Formfeed
  1232.         \\             Backslash
  1233.         \"             Quote
  1234.         \000           Octal value of character
  1235. TASM - Table Driven Assembler Version 2.9                             Page 25
  1236.  
  1237.  
  1238. Here are some examples:
  1239.  
  1240.         message1   .TEXT   "Disk I/O error"
  1241.         message2   .text   "Enter file name "
  1242.                    .text   "abcdefg\n\r"
  1243.                    .text   "I said \"NO\""
  1244.  
  1245.  
  1246. TITLE.  This directive allows the user to define a title string that  appears
  1247. at the top of each page of the list file (assuming the PAGE mode is on).  The
  1248. format is:
  1249.  
  1250.                 .TITLE  "string"
  1251.  
  1252. The string should not exceed 80 characters.  Here are some examples:
  1253.  
  1254.                 .TITLE  "Controller version 1.1"
  1255.                 .title  "This is the title of the assembly"
  1256.                 .title  ""
  1257. TASM - Table Driven Assembler Version 2.9                             Page 26
  1258.  
  1259.  
  1260. WORD. This directive allows a value assignment to the next two bytes  pointed
  1261. to by the current Instruction Pointer.  The format is:
  1262.  
  1263.         [label] .WORD  expr
  1264.  
  1265. The least significant byte of expr is put at the current Instruction  Pointer
  1266. with the most significant  byte at the next  sequential location (unless  the
  1267. MSFIRST directive has been invoked).  Here are some examples:
  1268.  
  1269.         data_table     .WORD   (data_table + 1)
  1270.                        .word   $1234
  1271.                        .Word   (('x' - 'a')  << 2)
  1272.                        .Word   12, 55, 32
  1273.  
  1274. TASM - Table Driven Assembler Version 2.9                             Page 27
  1275.  
  1276. OBJECT FILE FORMATS
  1277.  
  1278. TASM supports four object file formats:
  1279.  
  1280.         1.  Intel Hex (default).
  1281.         2.  MOS Technology Hex.
  1282.         3.  Motorola Hex.
  1283.         4.  Binary
  1284.  
  1285. Each are described below:
  1286.  
  1287. Intel Hex Object Format.  This is the  default format.   This format is  line
  1288. oriented and uses  only printable  ASCII characters except  for the  carriage
  1289. return/line feed at the end of each line.  Each line in the file assumes  the
  1290. following format:
  1291.  
  1292. :NNAAAARRHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHCCTT
  1293.  
  1294. Where:
  1295.  
  1296. All fields marked 'hex' consist of two or four ASCII hexadecimal digits (0-9,
  1297. A-F).  A maximum of 24 data bytes will be represented on each line  (override
  1298. the 24 byte default with the '-o' command line option).
  1299.  
  1300. :      = Record Start Character
  1301. NN     = Byte Count (hex)
  1302. AAAA   = Address of first byte (hex)
  1303. RR     = Record Type (hex, 00 except for last record which is 01)
  1304. HH     = Data Bytes (hex)
  1305. CC     = Check Sum (hex)
  1306. TT     = Line Terminator (carriage return, line feed)
  1307.  
  1308. The last line of  the file will be  a record conforming  to the above  format
  1309. with a byte count of zero:
  1310.  
  1311.          :00000001FF
  1312.  
  1313. The checksum is defined as:
  1314.  
  1315.   sum = byte_count + addr_hi + addr_lo + record_type + (sum of data bytes)
  1316.   checksum =  ((-sum) & ffh)
  1317. TASM - Table Driven Assembler Version 2.9                             Page 28
  1318.  
  1319. MOS Technology Hex Object Format. This format is line oriented and uses  only
  1320. printable ASCII characters except  for the carriage  return/line feed at  the
  1321. end of each line.  Each line in the file assumes the following format:
  1322.  
  1323. ;NNAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHCCCCTT
  1324.  
  1325. All fields marked 'hex' consist of two or four ASCII hexadecimal digits (0-9,
  1326. A-F).  A maximum of 24 data bytes will be represented on each line  (override
  1327. the 24 byte default with the '-o' command line option).
  1328.  
  1329. ;      = Record Start Character
  1330. NN     = Byte Count (hex)
  1331. AAAA   = Address of first byte (hex)
  1332. HH     = Data Bytes (hex)
  1333. CCCC   = Check Sum (hex)
  1334. TT     = Line Terminator (carriage return, line feed)
  1335.  
  1336. The last line of the file will be a record with a byte count of zero (';00').
  1337.  
  1338. The checksum is defined as:
  1339.  
  1340.     sum  =  byte_count + address_hi + address_lo + record_type +
  1341.                 (sum of all data bytes)
  1342.     checksum =  (sum & ffffh)
  1343.  
  1344.  
  1345. Motorola Hex  Object Format.  This  format is  line  oriented and  uses  only
  1346. printable ASCII characters except  for the carriage  return/line feed at  the
  1347. end of each line.  Each line in the file assumes the following format:
  1348.  
  1349. S1NNAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHCCCCTT
  1350.  
  1351. All fields marked 'hex' consist of two or four ASCII hexadecimal digits (0-9,
  1352. A-F).  A maximum of 24 data bytes will be represented on each line  (override
  1353. the 24 byte default with the '-o' command line option).
  1354.  
  1355. S1     = Record Start Prefix
  1356. NN     = Byte Count (hex) (data byte count + 3)
  1357. AAAA   = Address of first byte (hex)
  1358. HH     = Data Bytes (hex)
  1359. CC     = Check Sum (hex)
  1360. TT     = Line Terminator (carriage return, line feed)
  1361.  
  1362. The last  line of  the  file will  be a  record  with a  byte count  of  zero
  1363. ('S903AAAACCTT'). The checksum is defined as:
  1364.  
  1365.     sum  =  byte_count + address_hi + address_lo + record_type +
  1366.             (sum of all data bytes)
  1367.     checksum =  (~sum & ffh)
  1368.  
  1369.  
  1370. Binary Object Format. This  file format has only  a binary representation  of
  1371. each data byte with no  address, checksum or format description,  whatsoever.
  1372. It is often a convenient format to use to pass the data to other programs  on
  1373. your PC (like a PROM programmer package) but because of the  non-printability
  1374. and lack of address information, it is not often used to transmit the code to
  1375. TASM - Table Driven Assembler Version 2.9                             Page 29
  1376.  
  1377. other systems.
  1378.  
  1379. Note that when this object format is  selected (-b option), the -c option  is
  1380. forced.  This is done so that no ambiguity arises as a result of the lack  of
  1381. address information in the file.  Without the -c option, discontinuous blocks
  1382. of object code would appear contiguous.
  1383.  
  1384. TASM - Table Driven Assembler Version 2.9                             Page 30
  1385.  
  1386. LISTING FILE FORMAT
  1387.  
  1388. Each line of  source code  generates one  (or more)  lines of  output in  the
  1389. listing file.  The fields of the output line are as follows:
  1390.  
  1391. 1.  Current  source  file  line  number  (4 decimal digits).
  1392.  
  1393. 2.  An optional '+'  appears if this is   an  'INCLUDE'   file. (One '+'  for
  1394. each level of INCLUDE invoked).
  1395.  
  1396. 3.  Current Instruction Pointer (4 hex digits).  An optional '~' follows  the
  1397. Instruction Pointer if the line of source code is not being assembled because
  1398. of an IFDEF, IFNDEF, or IF directive.
  1399.  
  1400. 4.  Resulting code/data generated from  this source line (two hex digits  per
  1401. byte, each byte separated by a space, up to six bytes per line).
  1402.  
  1403. 5.  The source line exactly as it appears in the source file.
  1404.  
  1405. If   paging   is   enabled  (by either  the  '-p' option  flag or  the  .PAGE
  1406. directive) some additional  fields will be  inserted into the   listing  file
  1407. every 60 lines.  These fields are:
  1408.  
  1409.         1.  Top of Form (form feed).
  1410.         2.  Assembler identifier (e.g. "TASM 6502 Assembler").
  1411.         3.  Initial source file name.
  1412.         4.  Page number.
  1413.         5.  Title.
  1414. TASM - Table Driven Assembler Version 2.9                             Page 31
  1415.  
  1416. PROM PROGRAMMING
  1417.  
  1418. A wide variety of PROM programming equipment is available that can use object
  1419. code in  one or  more of  the formats  TASM supports.   Here  are some  notes
  1420. concerning the generation of code to be put in PROMs:
  1421.  
  1422. 1.  PRESET  MEMORY.   It is often  desirable to  have all bytes  in the  PROM
  1423. programmed even if not explicitly assigned  a value in the source code  (e.g.
  1424. the bytes are skipped over with a .ORG statement).  This can be  accomplished
  1425. by using the  -c (contiguous  block) and the  -f (fill)  command line  option
  1426. flags.  The -c will  ensure that every byte from  the lowest byte assigned  a
  1427. value to the the  highest byte assigned  a value will be  in the object  file
  1428. with no gaps.   The  -f flag will  assign the  specified value  to all  bytes
  1429. before the assembly begins so that when the object file is written, all bytes
  1430. not assigned a  value in  the source code  will have  a known value.   As  an
  1431. example, the following command line will generate object code in the  default
  1432. Intel Hex format with all bytes not assigned a value in the source set to  EA
  1433. (hex, 6502 NOP):
  1434.  
  1435.                 tasm -65 -c -fEA test.asm
  1436.  
  1437. 2.  CONTIGUOUS BLOCKS.   To ensure that TASM  generates object code to  cover
  1438. the full address range of the target PROM, put a .ORG statement at the end of
  1439. the source file set to  the last address desired.   For example, to  generate
  1440. code to be put in a 2716 EPROM (2 Kbytes) from hex address $1000 to $17ff, do
  1441. something like this in the source file:
  1442.  
  1443.                          ;start of the file
  1444.                          .ORG    $1000
  1445.                          ;rest of the source code follows
  1446.  
  1447.                          <source code>
  1448.  
  1449.                          ;end of the source code
  1450.                          .ORG    $17ff
  1451.                          .BYTE   0
  1452.                          .END
  1453.  
  1454. Now, to  invoke TASM  to generate  the code  in the  binary format  with  all
  1455. unassigned bytes set to 00 (6502 BRK), do the following:
  1456.  
  1457.                 tasm -65 -b -f00 test.asm
  1458.  
  1459. Note that -b forces the -c option.
  1460.  
  1461. TASM - Table Driven Assembler Version 2.9                             Page 32
  1462.  
  1463. ERROR MESSAGES
  1464.  
  1465.  
  1466. Error Message                             Description
  1467. ______________________________________________________________________________
  1468. Binary operator where value expected.     Two  binary  operators  in  a   row
  1469.                                           indicate a missing value.
  1470.  
  1471. Cannot malloc for label storage           Insufficient memory  to store  more
  1472.                                           labels. See LIMITATIONS.
  1473.  
  1474. Duplicate label.                          Duplicate    label    checks    are
  1475.                                           optionally  enabled  by  the   '-a'
  1476.                                           option.
  1477.  
  1478. File name too short                       A file name on the command line  is
  1479.                                           fewer than  3 characters.  This  is
  1480.                                           done to  prevent a  garbled  option
  1481.                                           flag from being  taken as a  source
  1482.                                           file, which in  turn can result  in
  1483.                                           the source file taken as an  object
  1484.                                           file (which are truncated at start-
  1485.                                           up time).
  1486.  
  1487. Heap overflow on label definition.        TASM was unable to allocate  memory
  1488.                                           to store the label.
  1489.  
  1490. Invalid operand.  No indirection for this instruction.
  1491.                                           The first character  of an  operand
  1492.                                           was  a  left  parenthesis  for   an
  1493.                                           instruction    that    does     not
  1494.                                           explicitly  specify  that  as   the
  1495.                                           format.    Some   micros  use   the
  1496.                                           parenthesis  as  an  indicator   of
  1497.                                           indirection, but putting a layer of
  1498.                                           parenthesis around an expression is
  1499.                                           always a valid thing to do (as  far
  1500.                                           as  the  expression  evaluator   is
  1501.                                           concerned).  The test for this case
  1502.                                           is only done if  the -a4 option  is
  1503.                                           selected. See  section on  ASSEMBLY
  1504.                                           CONTROL.
  1505.  
  1506. Invalid token where value expected.       Two binary operators  in a row  are
  1507.                                           not allowed.
  1508.  
  1509. Label too long                            Labels are limited to 31 characters.
  1510.  
  1511. Label value misaligned                    The value  of  a label  appears  to
  1512.                                           have  a  different  value  on   the
  1513.                                           second pass then it was computed to
  1514.                                           have on the  first pass.   This  is
  1515.                                           generally   due   to   Zero    Page
  1516.                                           Addressing mode  problems with  the
  1517.                                           6502 version of TASM.  Labels  that
  1518.                                           are used in operands for statements
  1519. TASM - Table Driven Assembler Version 2.9                             Page 33
  1520.  
  1521.                                           that  could   utilize   Zero   Page
  1522.                                           addressing mode  should  always  be
  1523.                                           defined before used as an operand.
  1524.  
  1525. Label not found                           A label used  in an expression  was
  1526.                                           not  found  in  the  current  label
  1527.                                           table.
  1528.  
  1529. Label must pre-exist for SET.             The  SET  directive  can  only   be
  1530.                                           applied to an existing label.
  1531.  
  1532. Label table overflow                      To   many    labels    have    been
  1533.                                           encountered.
  1534.  
  1535. List file open error                      TASM  was  not  able  to  open  the
  1536.                                           specified list file.
  1537.  
  1538. Macro expansion too long.                 The expansion of  a macro  resulted
  1539.                                           in a line that exceeded the maximum
  1540.                                           length.
  1541.  
  1542. Maximum number of macros exceeded         To many macros (DEFINEs) have  been
  1543.                                           encountered.
  1544.  
  1545. No END directive before EOF               The source file did not have an END
  1546.                                           directive in it. This is not fatal,
  1547.                                           but may cause the last object  file
  1548.                                           record to be lost.
  1549.  
  1550. No  files  specified                      TASM was  invoked  with  no  source
  1551.                                           file specified.
  1552.  
  1553. No such label yet defined.                A SET directive was encountered for
  1554.                                           a label not yet defined.  The value
  1555.                                           of labels that are modified by  the
  1556.                                           SET directive must already exist.
  1557.  
  1558. No indirection for this instruction.      A parenthesis was found around  the
  1559.                                           operand  expression.     This   may
  1560.                                           indicate   an   attempt   to    use
  1561.                                           indirection     where     it     is
  1562.                                           inappropriate.
  1563.  
  1564. Non-unary operator at start of expression A binary operator (such as '*') was
  1565.                                           found  at  the   beginning  of   an
  1566.                                           expression.  Some micros use '*' as
  1567.                                           an indirection operator.  Since  it
  1568.                                           is also a  legititmate operator  in
  1569.                                           an expression,  some ambiguity  can
  1570.                                           arise.        If    a    particular
  1571.                                           instruction/addressing  mode   does
  1572.                                           not allow indirection, and a '*' is
  1573.                                           placed in front  of the  associated
  1574.                                           expression,  the   assembler   will
  1575.                                           assume this error.     See the  -a8
  1576.                                           option of ASSEMBLY CONTROL.
  1577. TASM - Table Driven Assembler Version 2.9                             Page 34
  1578.  
  1579. Object file open error                    TASM  was  not  able  to  open  the
  1580.                                           specified object file.
  1581.  
  1582. Range of argument exceeded                The value  of an  argument  exceeds
  1583.                                           the valid  range  for  the  current
  1584.                                           instruction and addressing mode.
  1585.  
  1586. Range of relative branch exceeded         A branch  instruction  exceeds  the
  1587.                                           maximum range.
  1588.  
  1589. Source file open error                    TASM  was  not  able  to  open  the
  1590.                                           specified source file.
  1591.  
  1592. Unrecognized directive                    A statement starting with a '.'  or
  1593.                                           '#' has  a  mnemonic  that  is  not
  1594.                                           defined as a directive.
  1595.  
  1596. Unrecognized  instruction                 A statement has an opcode  mnemonic
  1597.                                           that is not defined.
  1598.  
  1599. Unrecognized argument                     A statement has  an  operand format
  1600.                                           that is not defined.
  1601.  
  1602. Unknown token                             Unexpected  characters  were  found
  1603.                                           while parsing an expression.
  1604.  
  1605. Unused data in MS byte of argument.       An instruction  or  directive  used
  1606.                                           the least  significant byte  of  an
  1607.                                           argurment   and   left   the   most
  1608.                                           significant byte unused, but it was
  1609.                                           non-zero.
  1610.  
  1611. Unkown option Flag.                       Invalid  option   flag   has   been
  1612.                                           specified  on  the  command   line.
  1613.                                           invoke TASM  with  nothing  on  the
  1614.                                           command line to see a list of valid
  1615.                                           options.
  1616.  
  1617. TASM - Table Driven Assembler Version 2.9                             Page 35
  1618.  
  1619. BUGS AND LIMITATIONS
  1620.  
  1621. Limitations and Specifications
  1622.                                            TASM                  TASMB
  1623. _____________________________________________________________________________
  1624. Maximum number of labels                   2000                  10000
  1625. Maximum length of labels                   32 characters
  1626. Maximum address space                      64 Kbytes (65536 bytes)
  1627. Maximum number of nested INCLUDES          4
  1628. Maximum length of TITLE string             79 characters
  1629. Maximum source line length                 255 characters
  1630. Maximum length after macro expansion       255 characters
  1631. Maximum length of expressions              255 characters
  1632. Maximum length of pathnames                79 characters
  1633. Maximum length of command line             127 characters
  1634.                                            
  1635. Maximum number of instructions (per table) 600                   1000
  1636. Maximum number of macros                   1000                  
  1637. Maximum number of macro arguments          10                    
  1638. Maximum length of macro argument           16 characters         
  1639. Heap size (for labels, macros, & buffers)  20000 bytes           60000
  1640. Memory requirements                        160K                  256K
  1641.  
  1642. Bugs
  1643.  
  1644. 1.  The  8048 version of  TASM does not  check for use  of memory beyond  any
  1645. reasonable bounds (e.g.  an 8048 has a maximum address space of 4 Kbytes  but
  1646. TASM will let you pretend that you have 64 Kbytes).
  1647.  
  1648. 2.  Expression  evaluation has  no operator  precedence in  effect which  can
  1649. make  for  unexpected results if not explicitly grouped with parenthesis.
  1650.  
  1651. 3.  First page of  listing file will not show  a user defined title  (defined
  1652. via TITLE directive).
  1653.  
  1654. 4.  TASM sometimes does not generate  error messages  for  improperly  formed
  1655. expressions.
  1656.  
  1657. TASM - Table Driven Assembler Version 2.9                             Page 36
  1658.  
  1659. APPENDIX A - ORDERING INFORMATION
  1660.  
  1661. TASM is distributed as shareware.   The shareware portion of the product  may
  1662. be freely copied and  used for evaluation  purposes.  Use  of TASM beyond  an
  1663. evaluation period of 90 days requires registration. Registered users  receive
  1664. the following benefits:
  1665.  
  1666.     1.  The recent version of TASM.
  1667.     2.  TASM source code (in C).
  1668.     3.  Bound TASM manual.
  1669.     4.  Telephone support.
  1670.     5.  Knowledge that they are supporting the development of useful
  1671.         but inexpensive software.
  1672.  
  1673. DESCRIPTION                                  UNIT PRICE    PRICE
  1674. ___________________________________________________________________________
  1675.  
  1676. TASM Registration (TASM disk, manual, & source)  $40.00    _______
  1677.  
  1678. TASM Site Registration (for sites with multiple   90.00    _______
  1679.    users.  Includes same materials as above.)          
  1680.  
  1681. TASM User's Manual (included above)               10.00    _______
  1682.  
  1683. TASM update for registered users                  10.00    _______
  1684.    (