home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progasm / pcmac.arj / DOCS / USRGUID.TXT < prev   
Encoding:
Text File  |  1991-05-22  |  163.6 KB  |  2,894 lines

  1.                            PCMAC USERS GUIDE
  2.                    PCMAC Universal Macro Assembler for
  3.                the IBM PC XT\AT\PS2 and Compatible Computers
  4.          
  5.                What Is PCMAC ?
  6.                ---------------
  7.                PCMAC is a two pass, symbolic cross assembler  for  the  IBM
  8.          PC\XT\AT\PS2 computers. This assembler is a special  one,  because
  9.          it is not dedicated to any processor. The user of PCMAC can decide
  10.          what kind of assembly language to use, and what kind  of  code  he
  11.          wants to be generated. Therefore a very special macro language  is
  12.          supported in PCMAC that is powerful enough to define any  assembly
  13.          language  like  Z80  or  MC68000.  The  assembler  supports   many
  14.          possibilities to maintain  big  assembly  programs.  Some  of  the
  15.          features:
  16.               - special string and character expressions
  17.               - full C language like expressions
  18.               - powerful  primitive  commands  to  build  up  higher  level
  19.                 assembly instruction
  20.               - directive and command line option driven listing
  21.               - symbol table listing
  22.               - fully compiled binary or linkable object code output chosen
  23.                 by the user
  24.          On the distribution disk you have the PCMAC  assembler,  a  linker
  25.          that links the object file output of the assembler, and some other
  26.          files.
  27.             Why You Need It
  28.             ---------------
  29.             You need PCMAC if you intend to develop  assembly  programs  on
  30.          your PC for some rarely used  processor  for  which  there  is  no
  31.          assembler.
  32.             Mr.  Developer  bought  a  seven-a-half-bit  processor   called
  33.          BRXX7.5 none heard of it before. He had documentation for it,  and
  34.          he decided to use it in a control  circuit.  He  built  a  control
  35.          system driven by the BRXX7.5 and he tried to develop a program for
  36.          it. At first he thought to develop the program  in  a  high  level
  37.          language but there was no compiler targeting the BRXX7.5. Then  he
  38.          tried to develop the program in assembly language, but even before
  39.          the first pass of the compilation an error message appeared:
  40.                 No assembler present for your processor.
  41.          Mr. Developer decided to have an assembler written. He  asked  Mr.
  42.          Lazy, a programmer, to  write  an  assembler  for  him.  Mr.  Lazy
  43.          accepted the job, and said to have done the assembler in six month
  44.          for 2000 bucks. Of course the assembler won't be very easy to use,
  45.          and may generate false code in the first versions, but  any  times
  46.          such a problem arises Mr. Developer can phone him, and he will fix
  47.          the bug in two weeks.
  48.             Well, this is not the story that  makes  Mr.  Developer  happy.
  49.          Then he decided to buy the new PCMAC assembler. He  did  it,  read
  50.          the users guide through and defined his special assembly  language
  51.          in two days. He made some mistakes in his first version, but PCMAC
  52.          once warned him, when it could, and in another time he  found  the
  53.          bug himself looking at the highly readable listing of his program.
  54.          He could find the bug in the macro definition in two  minutes  and
  55.          also could correct it immediately.
  56.             Mr. Developer  had  an  assembler  that  compiled  his  special
  57.          assembly language. But many times  he  wrote  the  instruction  EX
  58.          DE,HL that changed two registers  into  the  form  EX  HL,DE.  The
  59.          assembler pointed out that it could not  compile  the  instruction
  60.          many times
  61.          . Then Mr. Developer included this  instruction,  as  a
  62.          new form of the other one,  and  PCMAC,  since  that  time,  could
  63.          compile the programs. If he had an ordinary assembler he  couldn't
  64.          do that.
  65.             Finally Mr. Developer finished up his work soon  and  his  boss
  66.          was very great to give him a salary raise.
  67.             This is the story of Mr. Developper and it can be the story  of
  68.          you.
  69.             How to Use?
  70.             -----------
  71.             It is very easy to use. You have to prepare a  text  containing
  72.          your assembly program. There are many good editors  for  the  PCs.
  73.          You can use any of them. Suppose you prepared an assembly  program
  74.          and the program is now in the file MYFIRST.ASM. Now  type  at  the
  75.          DOS prompt:
  76.          PCMAC MYFIRST.ASM
  77.          The word PCMAC on the start  of  the  line  is  the  name  of  the
  78.          assembler and typing it invokes DOS to start PCMAC.  The  rest  of
  79.          the line is the name  of  the  program  that  you  want  PCMAC  to
  80.          compile. PCMAC having been loaded reads the name of  the  assembly
  81.          program and tries to compile it. It writes some text to the screen
  82.          that says that there were errors in your assembly file   and  does
  83.          not generate output. After correcting the bugs  in  your  assembly
  84.          program you should type the same line again for the DOS promt, and
  85.          happily read that there was no error in your  assembly  file,  and
  86.          the compilation was successful. Now list the directory, where  you
  87.          work, with the DOS command 'dir', and see that  there  is  a  file
  88.          named: MYFIRST.TSK. This file contains the compiled code  of  your
  89.          program. Try to load into your target machine and start. Well this
  90.          is the point where we can not  give  you  any  advice  how  to  do
  91.          because it can vary from user to user. External machines are often
  92.          connected to the RS232C channel, and you can  use  a  program  was
  93.          written in 80X86 assembly, in C, in PASCAL or in any language that
  94.          loads the code into the external machine.
  95.             The Assembly Language
  96.             ---------------------
  97.             It is difficult to speak about the assembly language  of  PCMAC
  98.          because every user defines his own  assembly.  However  there  are
  99.          some main rules that stand for every user defined assembly syntax.
  100.             An assembly program consists of lines, and every line  contains
  101.          at most one instruction. The instructions are  terminated  by  the
  102.          new line character at the end of the line or by a semicolon ; that
  103.          can be followed by comment. Every line  contains  two  parts.  The
  104.          first part is the label and the second  is  the  instruction.  The
  105.          labels start in the first column of the line and are terminated by
  106.          a space or tabulator. The instructions start at any position,  but
  107.          a space or tabulator character has to precede them. Many  case  it
  108.          is neccesary to start a label not in the first column. It  can  be
  109.          for the sake of the readability. In such case the label has to  be
  110.          terminated by a colon. Any part of a line can be missing.  A  line
  111.          can contain only instruction without label, only a label  or  only
  112.          comment or even no comment. So a line  can  even  be  empty.  Some
  113.          examples:
  114.          1.)
  115.          LABEL_IN_THE_FIRST_COLUMN LD A,B ;COMMENT
  116.          The label LABEL_IN_THE_FIRST_COLUMN is a long label  that  starts
  117.          in the first column and  separated  from  the  instruction  by  a
  118.          space. It could be separated by many spaces. Many spaces  in  this
  119.          case work like one. The command is LD A,B and  terminated  by  the
  120.          semicolon ;. The rest of the line is comment. Another example:
  121.          2.)
  122.           LABEL_NOT_IN_THE_FIRST_COLUMN :
  123.          This line contains only a label that has to  be  terminated  by  a
  124.          colon, even if there is no instruction following. A label  has  to
  125.          start with a letter or  with  the  underscore  character  and  can
  126.          contain letters, numbers and the underscore character. A label can
  127.          be as long as you want but should not exceed the maximal length of
  128.          a line that is 500 character. This is an exceptable limit.  It  is
  129.          regarded to use  long  labels  that  tell  you  the  meaning.  The
  130.          assembly format of PCMAC always pays attention to the  possibility
  131.          of readable programming.
  132.          3.)
  133.          Well, this example is difficult to typeset. The line  above  wants
  134.          to present an empty line.
  135.          4.)
  136.          ;This text is comment
  137.          This line contains only a comment.
  138.          5.)
  139.          LABEL LD a,B ;Comment
  140.          This is a line  that  contains  a  label  starting  in  the  first
  141.          column, instruction separated by a space and comment.
  142.             A line can contain a directive. Directives start in  the  first
  143.          column with a sharp # character. This looks like in  C  language,
  144.          but PCMAC has much more directives than C language. As a matter of
  145.          fact PCMAC currently has 28 kinds  of  directives.  You  can  read
  146.          about directives in details in a separate chapter. Example:
  147.          #dw hl
  148.          This line is a directive that tells PCMAC  to  generate  words  on
  149.          order: higher byte, lower byte. Some line looks:
  150.          #dw lh ; Usual convention
  151.          that changes the order to the usual and the line contains comment.
  152.                   How PCMAC Generates the Code
  153.                   ----------------------------
  154.                   The main reason to use PCMAC to  generate    binary  file
  155.          from a text file. The text file can be read easy by  human,  while
  156.          the binary file can be read by some program or machine.  From  the
  157.          point of view  of  code  generation  the  assembly  lines  can  be
  158.          grouped into two groups. Instructions of the first group generate
  159.          code, while the instructions of the second group do not.
  160.                   PCMAC reads the lines twice. One going through the  lines
  161.          is usually called PASS. This is why PCMAC is  called  a  two  pass
  162.          assembler. In the first pass  PCMAC  decides  how  big  memory  is
  163.          needed for the code, and the second pass generates the code. After
  164.          the first pass PCMAC reserves place to store the code. When a line
  165.          containing instruction  that  generates  code  encounters  in  the
  166.          second pass PCMAC stores the code in the reserved area at a  place
  167.          that is shown by the variable $. This  variable  is  a  predefined
  168.          variable of PCMAC that you even can reference  in  your  assembly.
  169.          This variable in  other  assemblers  is  usually  called  Location
  170.          Counter. PCMAC increments this variable after generating  a  byte.
  171.          If you set this variable to a certain value  than  the  next  byte
  172.          would be generated to the location that is pointed by  the  value.
  173.          If you set this variable to point a location where  PCMAC  already
  174.          had generated a byte then PCMAC will overwrite the old value  with
  175.          the next byte. Some assemblers do not allow to generate bytes with
  176.          descending addresses. However in some cases it is neccessary to do
  177.          so.
  178.                   Primitives
  179.                   ----------
  180.             Primitives  are  instructions  that  are  known  by  the  PCMAC
  181.          assembler itself. They are primitive, but they has to be  used  to
  182.          build up macros, assembly language. These primitives are the  same
  183.          as they are in any other assembly language. These primitives are:
  184.                  DB,DW,DD,DRB,DRW,DRD,VAR,EQU,EXTERN,EXTRN,PUBLIC
  185.          The first six directives generate code  the  others  do  not.  The
  186.          instructions in details:
  187.                  DB       Abbreviation of Define Byte. The syntax  of  this
  188.                           instruction is:
  189.                           DB expression1,expression2,...,expressionN
  190.                                                  or
  191.                           DB string
  192.                           The instruction generates so many bytes  as  many
  193.                           expressions there are after the keyword DB. PCMAC
  194.                           first evaluates  the  expressions  and  generates
  195.                           successive bytes to hold the values. If  a  value
  196.                           does not fit into the  interval  [-128,255]  then
  197.                           PCMAC generates an error message.  This  interval
  198.                           allows you to treat a byte as  signed  value.  In
  199.                           that case the assembler  generates  a  byte  that
  200.                           contains the value in two's complement  code.  In
  201.                           other words: if the value is less than zero  then
  202.                           the assembler adds 256 to it  before  generation.
  203.                           This instruction can  also  be  used  to  declare
  204.                           strings. From the  point  of  view  of  the  code
  205.                           generation a string is nothing else then  a  byte
  206.                           vector. Every character of a string  is  a  byte,
  207.                           and these bytes are  generated  succesively  when
  208.                           using a string  instead  of  an  expression.  The
  209.                           syntax of strings is detailed in a later chapter.
  210.                  DW       Abbreviation of Define Word. The syntax  of  this
  211.                           instruction is:
  212.                           DW expression1,expression2,...,expressionN
  213.                           The instruction generates  two  bytes  for  every
  214.                           expression. The expressions are treated as  words
  215.                           ie: two byte values. If a value does not fit into
  216.                           the interval [-32768,65535]  PCMAC  generates  an
  217.                           error message. This interval allows you to  treat
  218.                           a  word  as  signed  value.  In  that  case   the
  219.                           assembler generates  a  word  that  contains  the
  220.                           value in two's complement code. In  other  words:
  221.                           if the value is less than zero then the assembler
  222.                           adds 65536 to it before generation. The order  of
  223.                           the bytes in a word is: lower byte,  higher  byte
  224.                           by default. This ordering can be redefined by the
  225.                           #DW directive. String can not take place  between
  226.                           the expressions.
  227.                  DD       Abbreviation of Define Doubleword. The syntax  of
  228.                           this instruction is:
  229.                           DD expression1,expression2,...,expressionN
  230.                           The instruction generates four  bytes  for  every
  231.                           expression. There is no limit for the value of an
  232.                           expression, because PCMAC uses 32 bit  arithmetic
  233.                           and it makes impossible to be out of the interval
  234.                           of doubleword. The generation takes place in  two
  235.                           steps. PCMAC splits up the  doubleword  into  two
  236.                           words and generates words. The order of the  word
  237.                           generation  is:  lower  word,  higher   word   by
  238.                           default. This ordering can be  redefined  by  the
  239.                           #DD directive. The order of the bytes between the
  240.                           words is the same as if the words were  generated
  241.                           by  DW  primitives.  They  go  through  the  same
  242.                           ordering  procedure.   In   other   words   PCMAC
  243.                           generates two DW instructions for a  DD.  Strings
  244.                           can not take place among the expressions.
  245.                  DRB      Abbreviation of Define Relative Byte. The  syntax
  246.                           of the instruction is:
  247.                           DRB expression1,expression2,...,expressionN
  248.                           The expressions are treated as 32 bit values, and
  249.                           the  generated  value  is  the   value   of   the
  250.                           expression minus the value of the variable $  plus
  251.                           one.  At  first  glance  this   procedure   seems
  252.                           sophisticated and  useless.  The  power  of  this
  253.                           primitive   is   that   many   instructions    of
  254.                           microprocessors refer to relative  addresses  and
  255.                           this is the way those addresses are treated  when
  256.                           byte offset is given. The generated  bytes  added
  257.                           to the address of the next  byte  will  give  the
  258.                           target address. PCMAC  will  generate  a  warning
  259.                           message  if  some  of  the  expressions  is   not
  260.                           relocatable. PCMAC will generate error message if
  261.                           the  modified  value  is   not   in   the   range
  262.                           [-128,127]. A string can not take place among the
  263.                           expressions.
  264.                  DRW      Abbreviation of Define Relative Word. The  syntax
  265.                           of the instruction is:
  266.                           DRW expression1,expression2,...,expressionN
  267.                           The expressions are treated as 32 bit values, and
  268.                           are modified the same way as in  the  instruction
  269.                           DRB. A main difference is that  the  modificating
  270.                           value is the value of the  variable  $  plus  two
  271.                           because this  instruction  generates  two  bytes.
  272.                           This primitive is useful when relative addressing
  273.                           takes place with  word  offset.  PCMAC  generates
  274.                           warning  message  if   an   expression   is   not
  275.                           relocatable and will generate  error  message  if
  276.                           the modified value is not  between  the  interval
  277.                           [-32768,32767]. A string can not take place among
  278.                           the expressions.
  279.                  DRD      Abbreviation of Define Relative  Doubleword.  The
  280.                           syntax of the instruction is:
  281.                           DRD expression1,expression2,...,expressionN
  282.                           The expression are treated as 32 bit  values  and
  283.                           are modified the same way as in the  instructions
  284.                           DRW  or  DRB.  A  main  difference  is  that  the
  285.                           modificating value is the value of the variable $
  286.                           plus 4 because this  instruction  generates  four
  287.                           bytes. PCMAC generates warning message if any  of
  288.                           the expressions is not relocatable.
  289.          EXAMPLES:
  290.          Let us look at the next program!
  291.          ;Program to demonstrate the primitives DB,DW,DD,DRB,DRW and DRD
  292.          ;Set the variable $ to zero
  293.          ;This instruction is useless because this is the default.
  294.            $ := 0
  295.          ; Generate byte 11h
  296.            DB  11h
  297.          ; The next instruction generates byte 0FEh because
  298.          ; now $=1, $+1=2 and 0-2=-2 equals to 0FEh in two's complement.
  299.          ; NOTE: This instruction makes PCMAC to give a
  300.          ;       warning message because the expression 0 is not
  301.          ;       relocatable.
  302.            DRB 0
  303.          ; The following instruction generates two bytes.
  304.          ; The generated bytes are 0FFh and 00h
  305.          LABEL1
  306.            DRB LABEL1,LABEL2
  307.          LABEL2
  308.            DW 1234h     ; The generated bytes are 34h and 12h respectively.
  309.            DD 12345678h ; The generated bytes are
  310.                         ; 78h, 56h, 34h, 12h respectively
  311.            DRW LABEL3   ; The generated bytes are zeroes
  312.          LABEL3 DRD LABEL3 ; The generated bytes accord to the value -4
  313.                            ; -4=0FFFFFFFCh in two's complement,
  314.                            ; so the generated bytes are 0FCh,0FFh,0FFh
  315.                            ; and 0FFh
  316.          ;End of EXAMPLE PROGRAM
  317.                  VAR      This instruction declares variables.
  318.                           The syntax of the instruction is:
  319.                           VAR identifier1,identifier2,...,identifierN
  320.                           The  identifiers   are   treated   as   variables
  321.          following the instruction. If an identifier appears  on  the  left
  322.          hand side of an assignment  that  was  not  declared  with  a  VAR
  323.          instruction then PCMAC generates a warning  message.  The  initial
  324.          value of a variable is definitily zero.
  325.                  EQU      This is a  special  instruction  that  assigns  a
  326.                           value to a label. The syntax of  the  instruction
  327.                           is:
  328.                           label  EQU  expression
  329.                             label : EQU expression
  330.                           The label has to appear on the place of labels in
  331.                           the line as it was mentioned earlier.  The  value
  332.                           is assigned  to  the  label.  This  is  the  only
  333.                           exception when a value that is not the  value  of
  334.                           the variable $ is assigned to  a  label.  In  any
  335.                           other case if a label stands  on  the  left  hand
  336.                           side of a line the value that is assigned  to  it
  337.                           is the value of the variable $ when PCMAC  starts
  338.                           to read the line.
  339.                  EXTERN
  340.                  EXTRN    These instructions are the same, so we  refer  to
  341.                           it as one instruction. This instruction only  has
  342.                           two different forms because it is often  mistyped
  343.                           by  assembly  programmers.  The  syntax  of   the
  344.                           instruction is:
  345.                           EXTERN label1,label2,...,labelN
  346.                           This  instruction  declares  the  labels  to   be
  347.                           external.  It  means  that  there  is  no   value
  348.                           assigned to the label in the assembly program and
  349.                           this is because it is defined in  an  other  part
  350.                           that is compiled separately. Such  a  label  must
  351.                           not appear in an expression. The  only  exception
  352.                           is when the label itself forms an expression. For
  353.                           example we can write:
  354.                                  DW external_label
  355.                           where external_label is an  external  label.  The
  356.                           instruction can  only  be  used  when  PCMAC  was
  357.                           invoked with the -o option.  This  option  forces
  358.                           PCMAC  to  generate  object   file   instead   of
  359.                           executable task file. The references can  not  be
  360.                           resolved by PCMAC. The assembler only generates a
  361.                           note for the linker about the unsolved reference.
  362.                           When  the  linker  reads  the  note  solves   the
  363.                           reference. If  nor  the  option  -o  neither  the
  364.                           option -t is  present  then  PCMAC  generates  an
  365.                           error message when an EXTERN or EXTRN instruction
  366.                           appears.
  367.                  PUBLIC   This instruction declares a label to  be  public.
  368.                           This instruction can only be used  if  PCMAC  was
  369.                           invoked with  the  option  -o.  This  instruction
  370.                           means that PCMAC makes a note about the label  in
  371.                           the object file, and the  linker  can  solve  the
  372.                           references to this  label  that  are  present  in
  373.                           other modules. The instructions EXTERN and PUBLIC
  374.                           are as husband and wife. If nor  the  -o  neither
  375.                           the option -t is present when invoking PCMAC then
  376.                           PCMAC  generates  a  warning   message   if   the
  377.                           instruction appears.
  378.          EXAMPLE:
  379.          Here we present two simple programs. Assume that the programs  are
  380.          stored  in  the  files  TTHL.ASM  and  HL2.ASM.  The   first   one
  381.          (TTHL.ASM):
  382.          ;A program that multiplies HL by two
  383.          TWO_TIMES_HL
  384.                  ADD HL,HL
  385.                  RET
  386.                  PUBLIC TWO_TIMES_HL
  387.          The other program (HL2.ASM):
  388.          ;Program that calls TWO_TIMES_HL
  389.                  EXTERN  TWO_TIMES_HL
  390.                  CALL TWO_TIMES_HL
  391.          The user can compile these programs with the DOS commands:
  392.                  PCMAC -o TTHL.ASM
  393.                  PCMAN -o HL2.ASM
  394.                  LINK TTHL.O HL2.ASM
  395.          The first two commands compile the  assembly  files  and  generate
  396.          object files. The last command links the files together.
  397.               Directives
  398.               ----------
  399.               The current version of PCMAC knows 28 directives of 8  group.
  400.          A directive always appears on the start of a line  preceded  by  a
  401.          sharp character #. The directives:
  402.          1. include, macros, lib
  403.          2. fatal, error, warning, message, pause, list, ilist
  404.          3. if, endif, else, elsif, ifdef, ifndef
  405.          4. octal, decimal, char
  406.          5. dw, dd
  407.          6. macarg, macnum
  408.          7. stack, pop, push, clostack
  409.          8. while, wend, repeat, until
  410.          Collecting the directives into groups accords  to  their  effects.
  411.          Here we present all the directives with some text that can work as
  412.          short reminder.
  413.          1. Including directives.
  414.              include  includes assembly file,
  415.              macros   includes assembly file while the first pass
  416.              lib      includes compiled macro library
  417.          2. Listing directives.
  418.              fatal    generates an error message and stops PCMAC
  419.              error    generates an error message
  420.              warning  generates a warning message
  421.              message  generates a message
  422.              pause    supresses compilation until ENTER is pressed.
  423.              list     switches the listing on and off
  424.              ilist    switches the listing of include files on and off
  425.          3. Conditional directives.
  426.              ifdef
  427.              ifndef
  428.              if       switches the compilation on or off.
  429.              endif    closes a block that was opened with some if...
  430.              else
  431.              elsif    switches the compilation on or off.
  432.          4. String option setting directives.
  433.              octal    changes string radix octal.
  434.              decimal  changes string radix decimal.
  435.              char     redefines character code.
  436.          5. Code ordering directives.
  437.              dw       sets ordering of bytes in a word.
  438.              dd       sets ordering of words in a doubleword.
  439.          6. Macro option setting directives.
  440.              macarg   redefines the macro argumentum character.
  441.              macnum   redefines the macro number character.
  442.          7. Compilation stack handling directives.
  443.              stack    opens a stack.
  444.              pop      pops a value from the top of the stack.
  445.              push     pushes a value onto the stack.
  446.              clostack closes a stack.
  447.          8. Loop directives.
  448.             !!!!! These directives can ONLY be used inside of a macro. !!!
  449.              while    start a while loop
  450.              wend     end a while loop
  451.              repeat   start a repeat loop
  452.              until    end a repeat loop
  453.          The rest of this chapter tells you the effect  and  usage  of  all
  454.          directives. However there are some definition  that  you  can  not
  455.          understand until you are not familiar with string and  macros.  We
  456.          recommand you to skip the definition of group 4  if  you  are  not
  457.          familiar with strings and groups 6 and 8 if you are  not  familiar
  458.          with macros. Having learnt what PCMAC call string  and  macro  you
  459.          can return to this chapter.
  460.          Group No 1.
  461.          #include "file name" or #include <file name>
  462.                  This directive makes PCMAC to suppress reading the  actual
  463.          file and open the file that is named following the directive. This
  464.          directive has the same effect as if the file was copied  into  the
  465.          place of the directive into the current file.  The  directive  has
  466.          two forms. In the first case the name  of  the  file  is  enclosed
  467.          between "s. In the second case between < and >. If the  file  name
  468.          is enclosed between "s then PCMAC searches the file in the current
  469.          DOS directory if not path presents in the file name. If  the  file
  470.          name enclosed between < and > then PCMAC searches the file in  the
  471.          directory that is pointed by the environment  variable  INCLUDE.  A
  472.          file that is included from an other one can also include.  Include
  473.          directives can be nested into 5 level deep.
  474.          EXAMPLE:
  475.          Assume that we have set  the  environment  variable  with  the  DOS
  476.          command:
  477.          SET INCLUDE=C:\PCMAC\INCLUDE
  478.          or
  479.          SET INCLUDE=C:\PCMAC\INCLUDE\
  480.          There is no difference between the two settings from the point  of
  481.          view  of   PCMAC.   Assume   that   the   current   directory   is
  482.          C:\PCMAC\SOURCE. The directive:
  483.          #include "DECL.ASM"
  484.          will include the file C:\PCMAC\SOURCE\DECL.ASM. The directive
  485.          #include <DECL.ASM>
  486.          will include the file C:\PCMAC\INCLUDE\DECL.ASM. The directive
  487.          #include <SYS\MACROS.ASM>
  488.          will  include  the   file   C:\PCMAC\INCLUDE\SYS\MACROS.ASM.   The
  489.          directive
  490.          #include <C:\ROOT.ASM>
  491.          forces  PCMAC  to  try   to   open   and   read   a   file   named
  492.          C:\PCMAC\INCLUDE\C:\ROOT.ASM. It is an invalid file name so  PCMAC
  493.          will fail trying to read, and generates an error  message.  If  we
  494.          use the directive
  495.          #include "C:\ROOT.ASM"
  496.          PCMAC will include the file "ROOT.ASM" from the root directory  of
  497.          the drive C.
  498.          macros "file name" or macros <file name>
  499.                  This directive has almost the same effect as an  #include.
  500.          The difference is that this directive is neglected in  the  second
  501.          pass. This is useful to collect the  macro  definitions,  the  EQU
  502.          primitives into a file  and  to  include  it  with  the  directive
  503.          macros. These  lines  are  skipped  while  the  second  pass.  The
  504.          directive is called macros, because usually macros  are  collected
  505.          in a file that is included only in the first pass. The meaning  of
  506.          the delimiters of the file name is the same  as  in  case  of  the
  507.          #include directive. One can say that
  508.          #macros "file"
  509.          can be used instead of the three lines:
  510.          #if PASS = 1
  511.          #include "file"
  512.          #endif
  513.          A file that was included with the directive macros can  contain  a
  514.          macros directive or even #include directive.  Obviously  the  file
  515.          that is included into a  file  that  is  included  with  a  macros
  516.          directive will only be  included  only  in  the  first  pass.  The
  517.          nesting of their directive can be 5 level deep together  with  the
  518.          opened files of the directive include.
  519.          #lib "file name" or #lib <file name>
  520.                  This directive forces PCMAC to open and read a  file  that
  521.          was generated  by  PCMAC  and  containing  only  compressed  macro
  522.          definitions. If a file contains only  macro  definitions,  and  no
  523.          line generating code, then this program can be compiled  with  the
  524.          -K option. If PCMAC was invoked with the -K option  it  only  goes
  525.          through one pass, and finishing  the  pass  creates  a  file  that
  526.          contains  the  macros  that  were  defined.  If  we  have  a  file
  527.          MACROS.ASM containing only macros  and  we  compile  it  with  the
  528.          command line:
  529.          PCMAC MACROS.ASM MACROS.LIB -K
  530.          then including the result file MACROS.LIB with the  directive  lib
  531.          has the same effect as including the original file MACROS.ASM with
  532.          the directive macros or include. The difference is that  including
  533.          a compressed lib file is much faster  because  PCMAC  checked  the
  534.          syntax in an earlier compilation. The  delimiters  have  the  same
  535.          meaning as in the case of macros or include.
  536.          Group No 2.
  537.          #fatal   string
  538.          #error   string
  539.          #warning string
  540.          #message string
  541.                  These directives generate message that appears  on  screen
  542.          and in the listing file if it exists. These directives are useful,
  543.          when creating macros. An example can be  seen  in  the  Z80  macro
  544.          definition file:
  545.          macro("LD\  *,*",_SS,_SS)
  546.          #if     #0 == 6 && #1 == 6
  547.          #error  "LD (HL),(HL) is invalid."
  548.          #else
  549.                  DB      40h+(#0<<3)+#1
  550.          #endif
  551.          endm
  552.          This macro defines the instructions that load 8bit from a register
  553.          to a register, or from the memory location addressed by  HL  to  a
  554.          register or backward. However to load  from  the  memory  location
  555.          pointed by HL to the same memory location is invalid.  If  a  code
  556.          encounters that  would  accord  to  the  assembly  instruction  LD
  557.          (HL),(HL) then the processor Z80 gets into a halt state. There  is
  558.          a separated instruction for this purpose, HALT. In other words, if
  559.          the programmer writes the line:
  560.                  LD (HL),(HL)
  561.          then he probably wants something else than HALT. This  macro  does
  562.          not compile this line, but generates an error message instead. The
  563.          message appears on the same place where the  errors  generated  by
  564.          PCMAC appear, and PCMAC treats the message  as  an  error  message
  565.          generated by itself. Continues the compilation to  discover  other
  566.          mistakes, but having finished the two  passes  does  not  generate
  567.          object nor task file.
  568.                  One could define the macro in the following way:
  569.          macro("LD\  *,*",_SS,_SS)
  570.          #if     #0 == 6 && #1 == 6
  571.          #fatal "LD (HL),(HL) is invalid."
  572.          #endif
  573.                  DB      40h+(#0<<3)+#1
  574.          endm
  575.          In this case the compilation halts having  put  out  the  message.
  576.          This is a very strong wake up for the programmer,  and  the  fatal
  577.          directive is regarded to be in use when  a  really  serious  error
  578.          appeared. PCMAC generates fatal errors e.g. when it can not open a
  579.          file.
  580.                  One could define the macro in the following way as well:
  581.          macro("LD\  *,*",_SS,_SS)
  582.          #if     #0 == 6 && #1 == 6
  583.          #warning "LD (HL),(HL) is invalid."
  584.          #endif
  585.                  DB      40h+(#0<<3)+#1
  586.          endm
  587.          If a line LD (HL),(HL) encounters and  this  macro  definition  is
  588.          valid, then the message appears as warning and PCMAC treats  as  a
  589.          warning. The compilation goes on,  and  having  finished  the  two
  590.          passes PCMAC writes out the object or task file.
  591.                  The  last  of  this  three  directives  is  message.  This
  592.          directive generates a message appearing on the screen, and in  the
  593.          list file, but this event  is  treated  neither  an  error  nor  a
  594.          warning. This is only a message. PCMAC puts it out and forgets all
  595.          about it. You can use it if you  run  PCMAC  on  a  two-disk-drive
  596.          machine and you compile very large files. In  this  case  you  can
  597.          create a main file that contains only  directives  on  one  floppy
  598.          disk, and the other files on other  floppy  disks.  You  start  to
  599.          compile the main file (eg. MAIN.ASM ) on drive A, and include  the
  600.          files containing the program fragments on  drive  B.  The  program
  601.          MAIN.ASM can look like this:
  602.          ;MAIN.ASM includer of a very large program
  603.          #message "Put the disk containing SUB1.ASM into the drive B:"
  604.          #message "and press RETURN!"
  605.          #pause
  606.          #include "B:SUB1.ASM"
  607.          #message "Put the disk containing SUB2.ASM into the drive B:"
  608.          #message "and press RETURN!"
  609.          #pause
  610.          #include "B:SUB2.ASM"
  611.          #message "Put the disk containing SUB3.ASM into the drive B:"
  612.          #message "and press RETURN!"
  613.          #pause
  614.          #include "B:SUB3.ASM"
  615.          ;End of file MAIN.ASM
  616.          You should not forget to use the pause directive before the  first
  617.          #include, because finishing the first pass the disk that  contains
  618.          SUB3.ASM but not SUB1.ASM is in the drive B.
  619.          #pause
  620.                  This directive makes PCMAC to stop until one  presses  the
  621.          key ENTER. The usage of  this  directive  was  described  for  the
  622.          directives just above.
  623.          #list  expression
  624.          #ilist expression
  625.                  These directives switches the listing of the  compilation.
  626.          They have only effect if the command line option -l was  given  on
  627.          invocation of PCMAC. If the expression is true (not zero) then the
  628.          listing will be on following the directive, if the  expression  is
  629.          false (zero) then the listing will be  off.  The  directive  #list
  630.          switches the listing  of  all  the  files.  The  directive  #ilist
  631.          switches the listing only of the include files. The listing of the
  632.          include files is off by default. This means  that  if  you  invoke
  633.          PCMAC with the command line:
  634.          PCMAC -l MAIN.ASM
  635.          then you will get a listing on the screen, but no lines  of  files
  636.          SUB1.ASM, SUB2.ASM and SUB3.ASM  will  appear.  (See  the  example
  637.          above!) The directives #list and #ilist have effect  only  if  the
  638.          compilation is on. It means that the lines:
  639.          #if 0
  640.          #list on
  641.          #endif
  642.          will not switch the listing on.
  643.          Group No 3.
  644.          #if expression
  645.                  This is a directive to switch the compilation off. If  the
  646.          expression is true (non zero) then the compilation remains on,  if
  647.          the expression is false (zero) then the compilation is turned off.
  648.          However the expression will be evaluated if  the  compilation  was
  649.          on. In other words this directive opens a conditional  block  that
  650.          has to be ended with the directive  #endif.  Such  blocks  can  be
  651.          nested as deep as you want.
  652.          #ifdef  identifier
  653.          #ifndef identifier
  654.                  These directives are similar to the  directive  #if.  They
  655.          switch the  compilation  off  according  to  the  identifier.  The
  656.          directive #ifdef turns the compilation off if the  identifier  was
  657.          not defined. The directive #ifndef turns the  compilation  off  if
  658.          the identifier was defined. These directives have the same  effect
  659.          as the lines:
  660.          #if isdef(identifier)
  661.          #if !isdef(identifier)
  662.          #endif
  663.                  This directive closes a  conditional  block.  If  the  the
  664.          compilation was on before the block started it will be  on  again,
  665.          and if it was off then it will be off.
  666.          #else
  667.                  This directive splits  up  a  conditional  block.  If  the
  668.          expression  following  the  directive  #if  was  true,  then   the
  669.          compilation is turned off at the point of the directive  else.  If
  670.          the expression was false then the compilation  will  be  on  again
  671.          unless  the whole conditional block is  in  a  larger  conditional
  672.          block that switched off the compilation.
  673.          #elsif expression
  674.                  This  directive  the  mixture  of  #else  and   #if.   The
  675.          expression will be evaluated if the directive #if switched off the
  676.          compilation, and the compilation switches on if the expression  is
  677.          true. Using this directive it is possible to  separate  more  than
  678.          two cases. To make it clear let us look at an  example!  The  next
  679.          program demonstrates how the directives of this group work.
  680.          ;CONDEMO.ASM
  681.          ;Program to demonstrate
  682.          ;the directives
  683.          ;#if
  684.          ;#ifdef
  685.          ;#ifndef
  686.          ;#else
  687.          ;#elsif
  688.          ;#endif
  689.          ;Some simple examples first:
  690.          #if 1
  691.          #message "The expression 1 is true"
  692.          #endif
  693.          #if 0
  694.          #message "No matter what this string is,"
  695.          #message "because it won't appear on the screen."
  696.          #endif
  697.          ;Some more complex
  698.          var variable
  699.          variable := 1
  700.          #ifdef variable
  701.          #message "The identifier variable is defined."
  702.          #if variable
  703.          #message "The value of variable is true."
  704.          #else
  705.          #message "The value of variable is false."
  706.          #endif
  707.          #else
  708.          #message "The identifier variable is not defined."
  709.          #endif
  710.          ;Three different cases to separate
  711.          variable := 3
  712.          #if variable = 1
  713.          #message "Variable = one."
  714.          #elsif variable =2
  715.          #message "Variable = two."
  716.          #else
  717.          #message "Variable greater than two."
  718.          #endif
  719.          ;End of file CONDEMO.ASM
  720.          If we compile this program invoking PCMAC with the command line:
  721.          PCMAC condemo.asm
  722.          we will get the messages on the screen:
  723.          MESSAGE **** The expression 1 is true
  724.          MESSAGE **** The identifier variable is defined.
  725.          MESSAGE **** The value of variable is true.
  726.          MESSAGE **** Variable greater than two.
  727.          MESSAGE **** The expression 1 is true
  728.          MESSAGE **** The identifier variable is defined.
  729.          MESSAGE **** The value of variable is true.
  730.          MESSAGE **** Variable greater than two.
  731.          We will get every messages twice because of  the  two  compilation
  732.          passes. Try to  compile  the  file  CONDEMO.ASM  that  is  on  the
  733.          distribution disk.
  734.          Group No 4.
  735.                  You can understand this group of  directives  if  you  are
  736.          familiar with strings, and the way how PCMAC deals with strings.
  737.          #octal
  738.                  This directive sets the radix of the string escape numbers
  739.          to be eight. The numbers will be evaluated  as  octal  numbers  in
  740.          string escape sequences, and any non  octal  character  terminates
  741.          them even the digits '8' and '9'.  The  radix  for  string  escape
  742.          numbers is octal by default,  but  it  can  be  changed  in  later
  743.          version of PCMAC. It  is  regarded  to  use  explicitly  octal  or
  744.          decimal in your program if you use string escape numbers.
  745.          #decimal
  746.                  This directive sets the radix of the string escape numbers
  747.          to be ten. The numbers will be evaluated  as  decimal  numbers  in
  748.          string escape sequences.
  749.                  This is a good style of programming to use the directive
  750.          decimal or octal at the start of every file, and to use after  the
  751.          #include or macros directives.
  752.                  Well, the best way is to use only one  of  them  in  every
  753.          program.
  754.          #char expression1,expression2
  755.                  This directive  is  useful  when  writing  program  for  a
  756.          machine that uses non ASCII character set.  When  PCMAC  starts  a
  757.          pass fills up a table with numbers from 0 to 255. When a character
  758.          appears in a string or in a character  constans  it  represents  a
  759.          number according to the ASCII coding standard. PCMAC changes  this
  760.          value according to the table. If  the  character  'A'  appears  it
  761.          represented by the code 65 in ASCII. PCMAC changes this code  with
  762.          the code that is in the table at the location 65. By default it is
  763.          65, because PCMAC sets the location i to hold the value i for  any
  764.          i=0 to 255.
  765.                  The directive #char changes the table.  It  evaluates  the
  766.          expressions and then changes the location pointed by the first one
  767.          to hold the value of the second one. The order of  this  event  is
  768.          important. Let us look an example:
  769.          ;CHARDEMO.ASM
  770.          ;Demo program for the char directive
  771.                  DB "AAA\n\r"
  772.          #char 'A','a'
  773.                  DB "AAA\n\r"
  774.          #char 'A','A'
  775.                  DB "AAA\n\r"
  776.          #char 65,'A'
  777.                  DB "AAA\n\r"
  778.          #char 65,65
  779.                  DB "AAA\n\r"
  780.          #char 'A','a'
  781.          ;End of the file CHARDEMO.ASM
  782.          If you compile this program with the command line:
  783.          PCMAC CHARDEMO.ASM
  784.          the resulting file CHARDEMO.TSK will be an ASCII file that you can
  785.          type. Try to compile this assembly file,  and  then  use  the  dos
  786.          command:
  787.          TYPE CHARDEMO.TSK
  788.          You will see the following lines:
  789.          AAA
  790.          aaa
  791.          aaa
  792.          aaa
  793.          AAA
  794.          These bytes were generated by the assembly program above. Why?
  795.                  The first DB primitive generated three capital  case  'A's
  796.          and carriage return and new line. The second DB primitive generated
  797.          three lower case 'a's, because the char directive changed the code
  798.          of the character 'A' from 65 to 97. The second char directive does
  799.          nothing. The value of the first expression is 97 at this time, and
  800.          the table at the location 97 contains the value 97 because of  the
  801.          default setting. Therefore the third DB  primitive  generates  the
  802.          same code as the previous one. What does the next #char  directive
  803.          do? It changes the location 65 of the table to hold  the  code  of
  804.          the character 'A'. But this time it is 97  because  of  the  first
  805.          char directive. This directive does not change the table again and
  806.          the fourth DB primitive generates three lower case 'a's again. The
  807.          fourth char directive is clear how to interpret. The  location  65
  808.          changed to hold the value 65.  The  last  DB  primitive  generates
  809.          three capital case 'A's.  The  last  char  directive  is  only  to
  810.          demonstrate that PCMAC really fills up the table at the  start  of
  811.          every pass. This is because you may wish to change  the  character
  812.          set more than once in one  file.  An  example  when  you  have  an
  813.          assembly program that sends messages to  the  screen  and  to  the
  814.          printer as well. In this case your  program  will  look  something
  815.          like this:
  816.          ;Program skeleton for multiple character set usage
  817.          START   ;start of the executable code
  818.                          .
  819.                          .
  820.                          .
  821.                  Executable code
  822.                  LD      A,'a' ; This is standard ASCII code
  823.                          .
  824.                          .
  825.                          .
  826.          ;Character table setting for the screen
  827.          #char 'a',1
  828.          #char 'b',2
  829.                 .
  830.                 .
  831.                 .
  832.          #char 'z',26
  833.          ;messages to send to the screen
  834.          scr_mes1    DB "message number one"
  835.          scr_mes2    DB "message number two"
  836.                       .
  837.                       .
  838.                       .
  839.          scr_mesN   DB "message number many"
  840.          ;Character table setting for the printer
  841.          #char 'a',65
  842.          #char 'b',66
  843.                 .
  844.                 .
  845.                 .
  846.          #char 'z',90
  847.          ;messages to send to the printer
  848.          prt_mes1    DB "message number one"
  849.          prt_mes2    DB "message number two"
  850.                       .
  851.                       .
  852.                       .
  853.          prt_mesN   DB "message number many"
  854.          ;End of program skeleton
  855.          The instruction LD A,'a' will load into the accumulator the  value
  856.          97 because the default setting of the table is ASCII,  and  it  is
  857.          reloaded at the start of the second pass.
  858.                  You can redefine non printable  code  with  the  directive
  859.          char but there is no use of it. All the escape  sequences  in  the
  860.          strings and in the character constants are treated as they are. So
  861.          if you have a character constans '\65' in  decimal  mode  then  it
  862.          will mean the value 65 no matter  what  kind  of  char  directives
  863.          preceded it. The other escape sequences as '\n' or '\r' will  also
  864.          not be changed.
  865.                  Remember that PCMAC refills the table at the start of  the
  866.          second pass! If you collect all the char directives in a file then
  867.          you have to include it using the directive #include and  not  the
  868.          directive macros!
  869.          Group No 5.
  870.          #dw hl    or     #dw lh
  871.          #dd hl    or     #dd lh
  872.                  These directives change the byte and word generating order
  873.          of the DW and DD primitives. By default DW generates a word in the
  874.          way that the lower significant byte is the first  and  the  higher
  875.          significant byte is the second. The DD generates a doubleword in a
  876.          similar way: the lower significant word is on  the  lower  address
  877.          and the higher significant word is on the higher address.
  878.                  This ordering method can be changed with this  directives.
  879.          The directive dw changes the ordering of  the  primitive  DW.  The
  880.          letter pairs hl and lh means the order of  the  bytes.  hl  means:
  881.          higher byte on the lower address lower byte on the higher address.
  882.          lh means backward. The directive dd changes the word  ordering  in
  883.          the same way. The meaning of the letter pairs  are  the  same  for
  884.          words instead of bytes. These letter are not predefined labels  or
  885.          variables. They are  keywords.  You  can  use  both  as  label  or
  886.          variable. You  can  find  a  demonstration  program  in  the  file
  887.          ORDEMO.ASM. Here it is:
  888.          ;ORDEMO.ASM
  889.          ;Demo program for the dw and dd directives
  890.                          dw      1234h
  891.                          dd      12345678h
  892.          #dw hl
  893.                          dw      1234h
  894.                          dd      12345678h
  895.          #dd hl
  896.                          dw      1234h
  897.                          dd      12345678h
  898.          #dw     lh
  899.                          dw      1234h
  900.                          dd      12345678h
  901.          #dd lh
  902.                          dw      1234h
  903.                          dd      12345678h
  904.          ;End of the file ORDEMO.ASM
  905.          The easiest way to see what codes were generated is to look at the
  906.          list file. Here is the list:
  907.          Versoft macro assembler.
  908.          V 1.0
  909.          Pass2
  910.          +               ;ORDEMO.ASM
  911.          +               ;Demo program for the dw and dd directives
  912.          0000 34 12                      dw      1234h
  913.          0002 78 56 34                   dd      12345678h
  914.          0005 12
  915.          +               #dw hl
  916.          0006 12 34                      dw      1234h
  917.          0008 56 78 12                   dd      12345678h
  918.          000B 34
  919.          +               #dd hl
  920.          000C 12 34                      dw      1234h
  921.          000E 12 34 56                   dd      12345678h
  922.          0011 78
  923.          +               #dw     lh
  924.          0012 34 12                      dw      1234h
  925.          0014 34 12 78                   dd      12345678h
  926.          0017 56
  927.          +               #dd lh
  928.          0018 34 12                      dw      1234h
  929.          001A 78 56 34                   dd      12345678h
  930.          001D 12
  931.          +               ;End of the file ORDEMO.ASM
  932.          Error    : 0
  933.          Warning  : 0
  934.          PCMAC gives a listing for all the passes. Here we  presented  only
  935.          the listing of the second pass. You can see that the primitive  DD
  936.          generates the bytes  in  the  same  order  between  the  words  as
  937.          primitive DW.
  938.          Group No 6.
  939.                  You can understand this group of  directives  if  you  are
  940.          familiar with macros, and the way how PCMAC deals with macros.
  941.          #macarg expression
  942.          #macnum expression
  943.                  A macro definition consists of syntax definition and macro
  944.          body. You can and  probably  want  to  use  the  macro  argumentum
  945.          character and sometimes the macro numbering character in the macro
  946.          body as normal characters. The macro argumentum character  is  the
  947.          character #, the macro numbering character is the character  @  by
  948.          default. It can happen that some macro that you want to  refer  to
  949.          in a macro body contains the # or the @ character. Assume that  we
  950.          have an instruction defined by the macro:
  951.          macro("MOV ACC,#*",NUMBER)
  952.          ;The macro body is not interesting here
  953.          endm
  954.          and we want to reference this  instruction  in  the  body  of  the
  955.          following macro:
  956.          ;Wrong macro definition
  957.          macro("CLRJP *",LABEL)
  958.                  MOV ACC,#0
  959.                  JUMP    #0
  960.          endm
  961.          PCMAC will think that you want to have the  actual  value  of  the
  962.          argument in the first line. If we used this macro definition  then
  963.          PCMAC would extend it when reading the line
  964.                  CLRJP   LABEL1
  965.          to the lines:
  966.                  MOV ACC,LABEL1
  967.                  JUMP    LABEL1
  968.          This is actually not the wanted effect. What we want is:
  969.                  MOV ACC,#0
  970.                  JUMP    LABEL1
  971.          The correct definition for this can be:
  972.          ;A possible solution
  973.          #macarg '&'
  974.          macro("CLRJP *",LABEL)
  975.                  MOV ACC,#0
  976.                  JUMP    &0
  977.          endm
  978.          The directive #macarg changes the macro argument character to '&'.
  979.          When  PCMAC  works  up  the  macro  definition  it  remembers  the
  980.          locations of the references to the macro argument  and  it  stores
  981.          this  information.  The  later  change  of  the  macro  argumentum
  982.          character does not disturb PCMAC  when  it  extends  a  macro.  In
  983.          other words: it is  not  interesting  for  PCMAC  what  the  macro
  984.          argumentum  character  was  when  the  definition  of  the   macro
  985.          is finished. Another possibility for this macro definition is:
  986.          ;Another possible solution
  987.          macro("CLRJP *",LABEL)
  988.          #macarg 0 ;any value not equal to '#'
  989.                  MOV ACC,#0
  990.          #macarg '#'
  991.                  JUMP    #0
  992.          endm
  993.          The macro numbering character is @, but using the directive macnum
  994.          you  can  redefine  it  the  same  way  as  redefining  the  macro
  995.          argumentum character.
  996.                  Be care when using any of the directive macnum and  macarg
  997.          together with the directive char. If you redefine the code of the
  998.          character '&' and  you  use  it  as  a  macro  argument  or  macro
  999.          numbering character then writing the line
  1000.          #macarg '&'
  1001.          will set the macro argumentum character to a  value  you  did  not
  1002.          expect. The new value of the macro argumentum character will equal
  1003.          the new code of the character '&', because PCMAC changed the ASCII
  1004.          code evaluating the expression. However PCMAC does not change  the
  1005.          ASCII code when it reads the source. The directive char influences
  1006.          only the string and character constants and not the source. If you
  1007.          write the lines:
  1008.          #char '&',')'
  1009.          macarg '&'
  1010.          then a reference to the first macro argumentum will be )0  instead
  1011.          of &0. The same holds for the macro numbering character.
  1012.          Group No 7.
  1013.                  This group is useful for creating macros  for  high  level
  1014.          assembly language. These features are not common in assemblers.
  1015.                  Stack in assembly language is well known. These directives
  1016.          handle compile time stacks, and you must not confuse this with the
  1017.          conventional stacks. These stacks exists  during  the  compilation
  1018.          and not during the program run. You can use these stacks to  store
  1019.          32 bit values during the compilation. You can push values onto the
  1020.          stack, you can drop a value from the stack you can open new stacks
  1021.          and close stack. A stack can contain many values. The value on the
  1022.          top of the stack is the value that was pushed to the  top  of  the
  1023.          stack last. When you push a value to the top of the stack then the
  1024.          new value pushes the previous value one level  down.  Every  value
  1025.          will get into one level deeper. When you  pop  a  value  from  the
  1026.          stack then you remove the value from the  top  of  the  stack  and
  1027.          every value that were pushed onto the stack  will  get  one  level
  1028.          higher. The top of the stack is the value of  the  highest  level.
  1029.          The location, top of the stack, is often called TOS.
  1030.          #stack variable
  1031.                  This directive opens a stack, and the number of the  stack
  1032.          will be held by the variable. You can use this variable  to  refer
  1033.          the stack. Of course, you can transfer the  identifier  number  of
  1034.          the stack into another variable and you can use the other variable
  1035.          to refer the stack. Onehundred stacks can be opened at a time.  If
  1036.          you want to open more then onehundred stacks PCMAC  will  generate
  1037.          an error message.
  1038.          #pop expression
  1039.                  This directive drops one value from the stack  denoted  by
  1040.          the value of the expression. It is possible to use any  expression
  1041.          following the directive, but as a good programming  style,  it  is
  1042.          regarded to use a single variable that the value was  assigned  to
  1043.          by the directive #stack. Using this directive you can  not  access
  1044.          the value that you drop from the stack. If you refer  to  a  stack
  1045.          that was not opened or to a stack that is empty  then  PCMAC  will
  1046.          generate an error message.
  1047.          #push expression1,expression2
  1048.                  This directive pushes the value of the  second  expression
  1049.          to the stack  that  is  identified  by  the  value  of  the  first
  1050.          expression. It is possible to use  any  expression  following  the
  1051.          directive, but as a good programming style, it is regarded to  use
  1052.          a single variable that the value was assigned to by the  directive
  1053.          stack. If you refer to a stack that  was  not  opened  PCMAC  will
  1054.          generate an error message. You can push so many items onto a stack
  1055.          as many memory there are in your computer.
  1056.          #clostack expression
  1057.                  This directive releases the stack identified by the  value
  1058.          of the expression.  It is possible to use any expression following
  1059.          the directive, but as a good programming style, it is regarded  to
  1060.          use a single variable that  the  value  was  assigned  to  by  the
  1061.          directive stack. When a stack has been closed it is emptied and is
  1062.          released and can be opened with the directive stack.
  1063.                  Here we present some examples  how  to  use  these  stacks
  1064.          handling directives. However, to read this text  you  have  to  be
  1065.          familiar a little bit with expressions.
  1066.                  Let us define an instruction pair for  the  Z80  processor
  1067.          (that is an 8-bit machine), that creates an infinite loop. One can
  1068.          of course break this loop with jump instruction. We want to write:
  1069.                  LOOP
  1070.                   .
  1071.                   .
  1072.                   .
  1073.               body of the loop
  1074.                   .
  1075.                   .
  1076.                   .
  1077.                  ENDLOOP
  1078.          The simplest way is to use a variable that contains the address of
  1079.          the LOOP instruction, and make jump to that address in the body of
  1080.          the macro ENDLOOP. The definitions look like this:
  1081.          ;LOOP macro definition
  1082.          macro("LOOP")
  1083.          #ifndef loop_address
  1084.          var loop_address
  1085.          #endif
  1086.          loop_address := $
  1087.          endm
  1088.          ;ENDLOOP macro definition
  1089.          macro("ENDLOOP")
  1090.                  JP      loop_address
  1091.          endm
  1092.          This is very simple and we even needed not to use any compile time
  1093.          stack operation. The disadvantage of  this  solution  is  that  we
  1094.          should not nest the loops.  If  we  write  a  program  that  looks
  1095.          something like this:
  1096.                  LOOP
  1097.                   .
  1098.                  LOOP
  1099.                   .
  1100.                   .
  1101.              body of the inner loop
  1102.                   .
  1103.                   .
  1104.                  ENDLOOP
  1105.                   .
  1106.                  ENDLOOP
  1107.          then both of the ENLOOPs will jump back to the  second  LOOP.  The
  1108.          solution is to open a stack by the directive stack, and  push  the
  1109.          jump-back address onto the stack. When closing a loop we  can  pop
  1110.          the address from the TOS. The macro  definitions  then  look  like
  1111.          this:
  1112.          ;LOOP macro definition nestable
  1113.          macro("LOOP")
  1114.          #ifndef loop_stack
  1115.          var loop_stack
  1116.          #stack loop_stack
  1117.          #endif
  1118.          #push loop_stack , $
  1119.          endm
  1120.          ;ENDLOOP macro definition nestable
  1121.          macro("ENDLOOP")
  1122.                  JP      pop(loop_stack)
  1123.          endm
  1124.          When the first macro is extended then it checks  if  the  variable
  1125.          loop_stack is already defined or not. If not then it  defines  and
  1126.          opens a stack to hold the jump-back addresses.  The  rest  of  the
  1127.          macro pushes  the  address  onto  the  stack.  The  macro  of  the
  1128.          instruction ENDLOOP generates an instruction  that  jumps  to  the
  1129.          address that was taken from the stack. Now you can see  that  this
  1130.          kind of stack has no relation to the  usual  machine  stack.  This
  1131.          stack stores values while compilation time, and helps you to  keep
  1132.          tracing back information.
  1133.                  Let us look a more sophisticated solution, when we want to
  1134.          implement the instruction BREAK that breaks the deepest  loop.  In
  1135.          this case when a BREAK instruction encounters we have to  generate
  1136.          a jump to the end of the loop. The  macro  definitions  will  look
  1137.          like this:
  1138.          ;LOOP macro definition nestable with break
  1139.          macro("LOOP")
  1140.          #ifndef loop_stack
  1141.          var loop_stack,code_counter_store,address
  1142.          #stack loop_stack
  1143.          #endif
  1144.          #push loop_stack , NONADDRESS ;Any value that can not represent address
  1145.          #push loop_stack , $
  1146.          endm
  1147.          ;BREAK macro definition
  1148.          macro("BREAK")
  1149.                  JP      0 ; We do not know the address now
  1150.          #push loop_stack , $-2  ;Store the address of
  1151.                                  ;the second byte of the instruction
  1152.          endm
  1153.          ;ENDLOOP macro definition that fills in the BREAK jumps
  1154.          macro("ENDLOOP")
  1155.          code_counter_store := $
  1156.          address := pop(loop_stack)
  1157.          #while tos(loop_stack) != NONADDRESS
  1158.          $ := address
  1159.                  DW code_counter+3 ; 3 is the length of
  1160.                                    ; the jump-back instruction
  1161.          address := pop(loop_stack)
  1162.          #wend
  1163.          $ := code_counter_store
  1164.                  JP      address
  1165.          #pop    loop_stack
  1166.          endm
  1167.                  Well, the last macro is really  sophisticated,  and  needs
  1168.          some explanation how it works. Let  us  look  the  list  that  was
  1169.          generated by PCMAC when it compiled the file STACK.ASM.
  1170.          Versoft macro assembler.
  1171.          V 1.0
  1172.          Pass1
  1173.          +               ;STACK.ASM
  1174.          +               ;Demonstration program for the usage of stack directives
  1175.          +
  1176.          FFFF            NONADDRESS EQU  -1 ;Any value that can not
  1177.          +                                  ;       represent address
  1178.          +
  1179.          Error    : 0
  1180.          Warning  : 0
  1181.          Start of the code : 0
  1182.          End   of the code : 23
  1183.          Pass2
  1184.          +               #list on
  1185.          +               #endif
  1186.          +
  1187.          +                       LOOP      ;*  loop #1
  1188.          +                       LOOP      ; * loop #2
  1189.          0000 C3 00 00           BREAK
  1190.          0003 C3 00 00           BREAK
  1191.                                  ENDLOOP   ; * endloop #2
  1192.          0004 09 00
  1193.          0001 09 00
  1194.          0006 C3 00 00
  1195.          0009 C3 00 00           BREAK
  1196.          +                       LOOP      ; * loop #3
  1197.          000C C3 00 00           BREAK
  1198.                                  ENDLOOP   ; * endloop #3
  1199.          000D 12 00 C3
  1200.          0010 0C 00
  1201.          0012 C3 00 00           BREAK
  1202.                                  ENDLOOP   ;* endloop #1
  1203.          0013 18 00
  1204.          000A 18 00
  1205.          0015 C3 00 00
  1206.          +               ;End of file STACK.ASM
  1207.          Error    : 0
  1208.          Warning  : 0
  1209.                  You can see that the LOOP  instructions  do  not  generate
  1210.          code. It is shown by the sign '+' on the start of the  line.  This
  1211.          sign means that the  line  did  not  generate  code  although  the
  1212.          compilation was not switched. If the compilation is  switched  off
  1213.          then a sing '-' appears on the start of the line. The  instruction
  1214.          LOOP only stores the address in a  stack.  The  instruction  BREAK
  1215.          generates three bytes, but these bytes later have to  be  updated.
  1216.          The main code generation work is done by the instruction  ENDLOOP.
  1217.          This macro pops out the addresses of the BREAK  instructions,  and
  1218.          fills up the address space of the jump instruction, and  generates
  1219.          a jump instruction that jumps back to the start of the  loop.  The
  1220.          value NONADDRESS is to separate the nested stack space. It can  be
  1221.          -1 because the processor Z80 we assumed in this example  is  an  8
  1222.          bit machine and -1 equals to 0FFFFFFFFh for PCMAC.
  1223.          Group No 8.
  1224.                  This is a special group of directives  that  can  only  be
  1225.          used inside of a macro definition. These instruction make possible
  1226.          to define macros like ENDLOOP  in  the  example  of  the  previous
  1227.          group. However these macros could be neglected  and  even  ENDLOOP
  1228.          could be defined recursively. The point to use these directives is
  1229.          to save up memory and speed up the compilation. Linear recursivity
  1230.          always needs a lot of memory, and a recursive macro needs a  macro
  1231.          extension in every loop.
  1232.          #while expression
  1233.          #wend
  1234.                  If these directive pairs surround a block of  lines  in  a
  1235.          macro body then PCMAC will extend and repeat the lines so long  as
  1236.          the expression is TRUE (non zero). If the expression becames FALSE
  1237.          (zero) then the lines between the directives will be  skipped.  If
  1238.          the expression is false at start then the  lines  will  totaly  be
  1239.          neglected  and  won't  be  extended  at  all.  The  expression  is
  1240.          evaluated before the body of the loop.
  1241.          #repeat
  1242.          #until expression
  1243.                  If these directives surround a block of lines in  a  macro
  1244.          body then PCMAC will extend and repeat the lines so  long  as  the
  1245.          expression  is  false.  The  expression  is  evaluated  after  the
  1246.          extension of the loop body, so the lines  between  the  directives
  1247.          will be extended at least once.
  1248.                  These directives can  be  used  only  inside  of  a  macro
  1249.          definition because PCMAC stores the macro bodies  in  the  memory.
  1250.          When a loop directive encounters PCMAC has to track  back  to  the
  1251.          start of it. It is not possible to track back in  a  file,  or  at
  1252.          least it would be very slow. The real power of these directives is
  1253.          the usage inside of a macro.
  1254.                  Example:
  1255.          ;LOOP.ASM
  1256.          ;Demo program for looping directives
  1257.          macro("DEFS *",NUMERIC)
  1258.          #ifndef defs
  1259.                  var defs
  1260.          #endif
  1261.          defs := #0
  1262.          #while defs>0
  1263.                  DB 0
  1264.                  defs := defs - 1
  1265.          #wend
  1266.          endm
  1267.          macro("SKIP *",NUMERIC)
  1268.          #ifndef skip
  1269.                  var skip
  1270.          #endif
  1271.          skip := #0
  1272.          #repeat
  1273.                  DB 0
  1274.                  skip := skip - 1
  1275.          #until skip=0
  1276.          endm
  1277.                  DEFS    10
  1278.                  SKIP    10
  1279.                  DEFS    0
  1280.                  SKIP    0
  1281.          ;End of file LOOP.ASM
  1282.                  This example can be found in  the  file  LOOP.ASM  on  the
  1283.          distribution discette. You can try to compile it, but use  the  -l
  1284.          or the -m option and keep your hands  over  the  control  and  the
  1285.          break (scroll lock) key. The DEFS 10 and the SKIP 10  instructions
  1286.          generate the same  bytes:  ten  zeroes.  The  instruction  DEFS  0
  1287.          generates nothing because the  condition  of  the  while  loop  is
  1288.          false. The instruction SKIP 0 generates a lot of  zeroes,  because
  1289.          it generates at  least  one  byte.  Having  defined  the  byte  it
  1290.          decreases the variable 'skip' which  is  now  becames  0FFFFFFFFh.
  1291.          This instruction generates 100000000h bytes. So you should be very
  1292.          carefully using these instructions. In debugging your  macros  you
  1293.          can use the -m directive of the compiler.
  1294.                  You could see in these examples in this chapter some macro
  1295.          definitions   that   used   conditional    directives,    variable
  1296.          declarations. A macro can be extended many times  and  it  has  to
  1297.          define a variable only the first time.  This  is  the  reason  for
  1298.          which we used the construction:
  1299.          #ifndef variable ;If the variable is not defined
  1300.           var variable    ; then define the variable
  1301.          #endif
  1302.          We used this construction for the sake of simplicity.  For  larger
  1303.          macro libraries it is a better way to collect the  macros  into  a
  1304.          file eg. MACROS.ASM and the variable and label  declarations  into
  1305.          another file  eg.  MACROS.H.  Then  the  file  MACROS.ASM  can  be
  1306.          compiled with the -K option of PCMAC and can be included with  the
  1307.          lines
  1308.          #lib    "MACROS.LIB"
  1309.          #macros "MACROS.H"
  1310.          In this case the macros do not  check  every  time  if  they  were
  1311.          extended first time or not. They only do the work they really have
  1312.          to, and the variables and labels  are  defined  in  the  separated
  1313.          file. You can use the  directive  #macros,  because  the  variable
  1314.          declarations are skipped in the second pass.
  1315.               Identifiers
  1316.               -----------
  1317.               An identifier is a character literal. The first letter can be
  1318.          an alpha character that are the letters from 'a' to 'z'  and  from
  1319.          'A' to 'Z' or can be one of the letters '_', '$', '@'.  The  other
  1320.          letters of the  identifier  can  be  alpha  character  of  numeric
  1321.          characters. The numeric characters are the digits: '0', '1',  '2',
  1322.          '3', '4', '5', '6', '7', '8', '9'. The number of the letters in an
  1323.          identifier is not limited, but any label has to fit into  a  line.
  1324.          The maximal length of a line is 500 characters, because PCMAC uses
  1325.          a 500 bytes long buffer to store the lines. All the characters  of
  1326.          an identifier are significant and PCMAC  always  treat  lower  and
  1327.          upper  case  letters  in  identifiers   as   different.   Do   not
  1328.          misunderstand the usage of the -c option!
  1329.               Labels
  1330.               ------
  1331.               A label  identifies  a  constant  of  the  range  from  0  to
  1332.          0FFFFFFFFh. A label in  the  source  code  is  represented  by  an
  1333.          identifier. A label is defined when it stands  on  the  left  hand
  1334.          side of a line. You can assign a value to a  label  with  the  EQU
  1335.          primitive. If the line stands on the left hand side that  contains
  1336.          not an EQU directive then the value of the predefined  variable  $
  1337.          is assigned to it. This value represents the address of the  first
  1338.          byte that is generated according to the line. If the line does not
  1339.          generate code then the variable $ does not change and the value of
  1340.          it is not ambiguous. There can be assigned a value to a label only
  1341.          once while a compilation. The labels  has  to  get  usually  their
  1342.          value in the first pass. If a value is assigned to  a  label  with
  1343.          the EQU primitive then the expression on the right hand  side  has
  1344.          to be defined. It means that all the  labels  and  variables  that
  1345.          appear in the expression have to be defined. So you  have  to  pay
  1346.          attention on the ordering of the EQU directives. You can not write
  1347.          into a file:
  1348.          A       EQU     B
  1349.          B       EQU     12
  1350.          because B is not defined when it is referenced. You can  say  that
  1351.          easy to see that B will get the value 12 later,  and  PCMAC  could
  1352.          assign the value  to A when B is determined. Do  not  forget  that
  1353.          there can be expression on the right of the EQU directive, and  if
  1354.          PCMAC wanted to remember what value to assign to a label  then  it
  1355.          would have to store all the expressions that  stand  on  EQUs  and
  1356.          sort them after the first pass into an order they could be solved.
  1357.          Such a scheduler is not built into PCMAC to save up speed, program
  1358.          size and memory. You can easy sort the  EQU  primitives  into  the
  1359.          order:
  1360.          B       EQU     12
  1361.          A       EQU     B
  1362.          It is usually not a problem programming in assembly language. Some
  1363.          programmers collect the EQU directives to the end  of  the  source
  1364.          because when the assembler reaches the last code  generating  line
  1365.          it determined all the address dependent values and they can  stand
  1366.          in expression.
  1367.                  PCMAC does not skip the label definitions  in  the  second
  1368.          pass. It checks if the label gets the same value  or  not.  If  it
  1369.          gets some other value then PCMAC gives an error message. It should
  1370.          not happen when you compile an errorless assembly program. It  can
  1371.          happen only if you use the conditional directives referring to the
  1372.          predefined variable pass incorrectly.
  1373.               Variables
  1374.               ---------
  1375.                  Variables  identify  values  of  the  range  from  0   to
  1376.          0FFFFFFFFh. A variable  is  defined  when  it  appears  in  a  VAR
  1377.          primitive or when appears on the left hand side of  an  assignment
  1378.          instruction. PCMAC generates a warning message on the second case.
  1379.                  The main difference between variables and labels  is  that
  1380.          the variables can have different  values  while  the  compilation.
  1381.          Their value can change. They are necessary  in  macros  like  the
  1382.          examples  in  the  chapters  above.  Variables   can   appear   in
  1383.          expressions. However variables can not be public, because they  do
  1384.          not represent a value. They represent a  lot  of  values  as  they
  1385.          change during the compilation. With the same assingment a variable
  1386.          can  get  different  values  in  the  first  and  in  the   second
  1387.          compilation. A very simple example is:
  1388.          VARIABLE := pass
  1389.          In this instruction the variable gets the value  1  in  the  first
  1390.          pass and gets the value 2 in the second pass. PCMAC does not  care
  1391.          about it.
  1392.               Assignment Instruction
  1393.               ----------------------
  1394.                  An assignment instruction assignes a value to a  variable.
  1395.          A variable has to stand on the left hand side of the line.  It  is
  1396.          not necessary to start the name  of  the  variable  on  the  first
  1397.          column. The mnemonic of the assignment is the sign pair ':='.  To
  1398.          the right of it an expression has to stand that must  not  contain
  1399.          undefined label or variable. Some examples:
  1400.          pass2   := pass = 2
  1401.          Having executed this instruction the variable pass2 will  be  true
  1402.          during the second pass and false  during  the  first  pass.  Don't
  1403.          forget that the value of the variable pass2 will be  false  during
  1404.          the second pass so long as this instruction was not executed.
  1405.          BIT :=( defined(Z80) || defined(I8080) )*8
  1406.                       + ( defined(I8086) || defined(M68000) )*16
  1407.          The variable BIT gets the value if one of the identifiers Z80  and
  1408.          I8080 is defined. The variable gets the value 16  if  one  of  the
  1409.          identifiers I8086 and M68000 is defined. If one of the identifiers
  1410.          Z80 and I8080 and one of the  identifiers  I8086  and  M68000  are
  1411.          defined at the same time then the variable BIT will get the  value
  1412.          24.
  1413.                  Warning!!! This example is written into two lines  because
  1414.          of the limits of the typesetting. In an assembly program it has to
  1415.          fit into one line.
  1416.               Predefined Labels and Variables
  1417.               -------------------------------
  1418.                  The assembler has some variables that you need not define.
  1419.          They are defined before the assembler starts reading  the  source.
  1420.          These variables are different from  the  other  variables  because
  1421.          some of them change the value automatic. These variables:
  1422.          $       The dollar sign.  This  variable  represents  the  current
  1423.                  address  of  the  code  generator.  This  variable  always
  1424.                  contains the address where the  next  byte  gets.  If  the
  1425.                  source program changes the value of this variable then the
  1426.                  next byte will be generated to the new  address.  See  the
  1427.                  definition of the ORG instruction in the Z80 macro library
  1428.                  file. Here it is:
  1429.          macro("ORG *",NUMERIC)
  1430.                  $ := #0
  1431.          endm
  1432.                  The value of the variable $ is relocatable.
  1433.          pass    The value of this variable is set to 1  before  the  first
  1434.                  pass and is set to 2  before  the  second  pass.  You  can
  1435.                  assign a value to this variable  but  the  value  will  be
  1436.                  updated between the passes. The value is not relocatable.
  1437.          line    This variable contains the number of the lines  that  were
  1438.                  worked up in the actual file. This value can be  redefined
  1439.                  and it will be incremented finishing each line. The  value
  1440.                  is not relocatable.
  1441.          tline   This variable contains the number of the lines  that  were
  1442.                  worked up in the actual pass. This value can be  redefined
  1443.                  but it will be updated the same way as the  value  of  the
  1444.                  variable  line.  The  value  of  this  variable   is   not
  1445.                  relocatable.
  1446.          on      This is a variable that is defined by  the  assembler  and
  1447.                  the  value  of  it  is  set  to  1.  This  value  is   not
  1448.                  relocatable.
  1449.          off     This variable is defined by the assembler before the first
  1450.                  pass and the value of it set to zero.  The  value  is  not
  1451.                  relocatable.
  1452.                  All the predefined variables can be assigned to, but it is
  1453.          not a good style to monkey with them. Do reassignment only when it
  1454.          is really necessary and increases the readability.
  1455.               Expressions
  1456.               -----------
  1457.                  We  were  talking  about  expressions  in   the   previous
  1458.          chapters, but until now we did not define what they are.
  1459.                  An expression consists of  labels,  variables,  functions,
  1460.          operators, brackets and strings. Every expression has a value that
  1461.          is a number between the interval from 0  to  0FFFFFFFFh  and  this
  1462.          value is  relocatable  or  not  relocatable.  The  relocation  has
  1463.          meaning only in case when PCMAC generates object code  instead  of
  1464.          task file.
  1465.               Numbers
  1466.               -------
  1467.                  The simplest expression is  a  number.  A  number  can  be
  1468.          written in decimal, hexadecimal, binary, octal or ASCII form.  The
  1469.          first four type can be positive or negative.
  1470.                  DECIMAL NUMBER
  1471.                  A decimal is the sequence of decimal digits. These are  0,
  1472.          1, 2, 3, 4, 5, 6, 7, 8, 9. A decimal number  has  no  postfix  but
  1473.          PCMAC can accept the 'd' or the 'D' postfix. A decimal number  can
  1474.          be positive in the range from 0 to 4294967295, or can be  negative
  1475.          in the range from -1 to -2147483648.
  1476.          Examples:
  1477.                  123         one-hundred and twenty three
  1478.                  2000        twenty hundred (two thousand)
  1479.                  -1          minus one. This value is the same as
  1480.                  4294967295
  1481.                  33d         thirty three with a 'd' decimal postfix
  1482.                  HEXADECIMAL NUMBER
  1483.                  A hexadecimal number is a sequence of hexadecimal  digits.
  1484.          The hexadecimal digits are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C,
  1485.          D, E, F. The letters can be written in lower case as a, b,  c,  d,
  1486.          e, f. These letters stand for the values: 10, 11, 12, 13,  14  and
  1487.          15. Hexadecimal numbers has to be followed by a letter 'H' or 'h'.
  1488.          This is called hexadecimal postfix. A  hexadecimal  number  always
  1489.          has to start with a decimal digit. If eventually it  started  with
  1490.          some of the hexadecimal digits from  A  to  F  then  you  have  to
  1491.          precede it with the digit 0. In  order  to  get  the  value  of  a
  1492.          hexadecimal number you have to count the digits from right to left
  1493.          from zero up to the number of the digits minus one.  You  have  to
  1494.          summ up the  digits  multiplying  each  with  16  powered  by  the
  1495.          position of the digit. Hexadecimal numbers are important when  you
  1496.          want to  see  how  many  bytes  are  occupied  by  a  number.  One
  1497.          hexadecimal digit occupies exactly half byte that  is  four  bits.
  1498.          Two digit hexadecimal numbers occupy exactly one byte, four  digit
  1499.          hexadecimal numbers occupy exactly two bytes and so on.
  1500.          Examples:
  1501.                  1h      one
  1502.                  0Fh     fifteen. As you see it starts with the letter '0'.
  1503.                          If we wrote Fh PCMAC would think that this  is  an
  1504.                          identifier.
  1505.                  1Fh     1*16+15=31 in decimal form.
  1506.                  8E3aH   8*16*16*16+14*16*16+3*16+10=36410 You see that the
  1507.                          case of the letters is not important in this case.
  1508.                  BINARY NUMBERS
  1509.                  Binary numbers consist of binary digits that are 0 and  1.
  1510.          Binary numbers are followed by the  binary  postfix  that  is  the
  1511.          letter 'B' or 'b'. Each digit represents one bit. The  calculation
  1512.          of the value of  a  binary  number  is  almost  the  same  as  the
  1513.          calculation of hexadecimal numbers. The  difference  is  that  the
  1514.          digits have to be multiplied by the powers of  2  instead  of  16.
  1515.          Binary numbers are important when we want to write a number  in  a
  1516.          form that shows which bit is set to one and which is zeroed.
  1517.          Examples:
  1518.                  1b      one
  1519.                  10b     two
  1520.                  10B     also two
  1521.                  11B     three
  1522.                  1010b   ten
  1523.                  OCTAL NUMBERS
  1524.                  Octal numers are sequences of octal digits. These  are  0,
  1525.          1, 2, 3, 4, 5, 6 and 7. An octal number is followed with the octal
  1526.          postfix letter 'O' or 'o'. Do not mix it with  the  digit  0  that
  1527.          stands for the value  zero.  The  reason  why  PCMAC  knows  octal
  1528.          numbers is that the first generation of computer programmers  used
  1529.          to write numbers in octal form. Some of  them  still  loves  octal
  1530.          numbers. The value of an octal number can be calculated  the  same
  1531.          way as the value of a hexadecimal or binary number. Here the radix
  1532.          is eight, in other words you have to multiply the digits with  the
  1533.          powers of 8.
  1534.          Examples:
  1535.                  1o      one and not ten!
  1536.                  1O      one and still not ten!( 1O is not the same as 10)
  1537.                  22o     2*8+2 = 18
  1538.                  25442o  2*8*8*8*8+5*8*8*8+4*8*8+4*8+2 = 1142
  1539.                  ASCII NUMBERS
  1540.                  Ascii numbers start with the character ' and end with  it.
  1541.          There has to be at least one and at most four characters  between.
  1542.          Each character represents its code. The code is usually the  ASCII
  1543.          code, but it can be  redefined  with  the  #char  directive.  Each
  1544.          character code has to multiplied with the value 256 powered by the
  1545.          position of the character.
  1546.                  There are special characters  that  could  not  appear  in
  1547.          character constants. One of them is the ' sign.  This  is  because
  1548.          that sign terminates the ascii number. If you want to include  the
  1549.          character ' into an ascii number then you have to replace it  with
  1550.          the character pair \'. Generally saying every character but digits
  1551.          and the letters t,n,r following the backslash \  character  in  an
  1552.          ascii number means itself  and  nothing  else.  So  the  backslash
  1553.          character has  to  be  written  \\.  If  some  digits  follow  the
  1554.          backslash character then they are  treated  as  octal  or  decimal
  1555.          numbers. They are treated as  decimal  numbers  if  the  directive
  1556.          #decimal was used, and they are treated if  the  directive  #octal
  1557.          was used or  if  none  these  directives  were  used.  The  escape
  1558.          sequence can be three digit long.
  1559.          Examples: (We assume that no #char directive was used.)
  1560.                  '0'      48
  1561.                  '00'     48*256+48=12336
  1562.                  '0\0'    48*256+0 =12288
  1563.                  '0\0000' 48*256*256+0*256+48=3145776
  1564.                           This is because the escape  sequence  means  zero
  1565.                           and terminates after three digits. There  is  one
  1566.                           more digit left that represents its ASCII code.
  1567.                  'A\19'   65*256+19=16659
  1568.                           or
  1569.                           65*256*256+1*256+57=4260153
  1570.                           depending on what the ASCII escape radix  is.  If
  1571.                           the  directive  #decimal  was   used   then   the
  1572.                           character '9'  following  the  character  '1'  is
  1573.                           member of the escape sequence and  the  value  of
  1574.                           the escape  sequence  is  19.  If  the  directive
  1575.                           #decimal was not used then the character '9'  can
  1576.                           not be member of the escape sequence  because  it
  1577.                           is not an octal digit. In this  case  the  escape
  1578.                           sequence  consists   of   two   characters:   the
  1579.                           backslash character and the digit 1. The value of
  1580.                           the escape sequence in this case is one  and  the
  1581.                           character '9' represents its ASCII code.
  1582.          If the ASCII radix is octal  and  a  digit  terminates  an  escape
  1583.          sequence then PCMAC generates a warning message.  There  are  some
  1584.          other special escape sequences for codes that  often  happen.  The
  1585.          letter t,n,r following the backslash character  means  the  values
  1586.          9,10 and 13, respectively. These are special codes  in  the  ASCII
  1587.          standard. The meaning of them are:
  1588.          '\t'    tabulator character.
  1589.          '\n'    new line character.
  1590.          '\r'    carriage return character.
  1591.          All other characters have the same meaning as they stand after the
  1592.          character \ or not.
  1593.                  ASCII character are useful when a number  represents  some
  1594.          character code in the assembly. If you see the assembly lines:
  1595.                  LD      A,65
  1596.                  CALL    1601h
  1597.          you probably won't know what it means. If you can read the lines
  1598.                  LD      A,'A'
  1599.                  CALL    PRTCHAR
  1600.          you will  find  out  the  meaning.  The  program  prints  out  the
  1601.          character 'A'. You need not  search  the  ASCII  code  table  that
  1602.          always is in your way  but  when  you  need  it.  There  are  more
  1603.          advantages of ASCII numbers. Assume that you calculated  the  code
  1604.          of the character for your machine in a wrong way and that  is  not
  1605.          56 but 57. If you did not use character constants when  you  refer
  1606.          to the code of the letter A then  you  have  to  replace  all  the
  1607.          appearance of the digits 56 to 57. It is for sure that doing it by
  1608.          hand you will forget to change some of them. If you used some text
  1609.          editor command for automatic replace it  will  change  the  number
  1610.          56738 to 57738. You should use ASCII numbers  instead  and  change
  1611.          only the directive
  1612.          #char 'A' , 56
  1613.          to
  1614.          #char 'A' , 57.
  1615.                  Let  us  turn  back  to  expressions.  Using  numbers  and
  1616.          operators we can build up compound expressions. If you  wrote  1+1
  1617.          it would means the  same  as  if  you  wrote  2.  There  are  many
  1618.          operators PCMAC knows. Here is a table containing them:
  1619.          Precedence          The operator           Meaning
  1620.          --------------------------------------------------------------
  1621.           1.                 ||    OR               Logical or
  1622.          --------------------------------------------------------------
  1623.           2.                 &&    AND              Logical and
  1624.          --------------------------------------------------------------
  1625.           3.                     |                  Bitwise or
  1626.          --------------------------------------------------------------
  1627.           4.                     ^                  Bitwise xor
  1628.          --------------------------------------------------------------
  1629.           5.                     &                  Bitwise and
  1630.          --------------------------------------------------------------
  1631.           6.                     <>                 Non equality
  1632.                              ==     =               Equality
  1633.          --------------------------------------------------------------
  1634.           7.                     <                  Less than
  1635.                                  >                  Greater than
  1636.                                  <=                 Less or equal
  1637.                                  >=                 Greater or equal
  1638.          --------------------------------------------------------------
  1639.           8.                 <<      SHL            Shift left
  1640.                              >>      SHR            Shift right
  1641.          --------------------------------------------------------------
  1642.           9.                     +                  Addition
  1643.                                  -                  Substraction
  1644.          --------------------------------------------------------------
  1645.          10.                     *                  Multiplication
  1646.                                  /                  Division
  1647.                               %       MOD           Remainder
  1648.          --------------------------------------------------------------
  1649.          11.                  !       NOT           Logical not
  1650.                                  ~                  Bitwise not
  1651.                                  -                  Unary minus
  1652.                                  +                  Unary plus
  1653.          --------------------------------------------------------------
  1654.          The higher the precedence of some operator is  the  earlier  PCMAC
  1655.          performs it. Examine the expression:
  1656.          !12+5*3-7%4<<1  = 6*3 ^ 2 && +1 > 1+12
  1657.          PCMAC reduces this expression into a number in 11 steps. First  it
  1658.          looks for unary operators. It finds the subexpressions !12 and +1.
  1659.          PCMAC replaces them by their value. !12  equals  to  zero  and  +1
  1660.          equals to one. The expression after the first step:
  1661.          0+5*3-7%4<<1  = 6*3 ^ 2 && 1 > 1+12
  1662.          Now PCMAC looks for the  operators  multiplication,  division  and
  1663.          remainder. It finds the  subexpressions  5*3,  7%4  and  6*3.  The
  1664.          values for these are 15, 3, 18. Substituting:
  1665.          0+15-3<<1  = 18 ^ 2 && 1 > 1+12
  1666.          PCMAC now looks for addition and substraction. There are some,  so
  1667.          the expression gets the form:
  1668.          12<<1  = 18 ^ 2 && 1 > 13
  1669.          The next step is to perform the operation 12<<1 that is 24:
  1670.          24  = 18 ^ 2 && 1 > 13
  1671.          The next is to calculate the value  1 > 13. The  value  of  it  is
  1672.          FALSE. The numerical value of FALSE is zero.
  1673.          24  = 18 ^ 2 && 0
  1674.          Now to perform the operation 24 = 18 that is FALSE==0.
  1675.          0 ^ 2 && 0
  1676.          The next operation is the bitwise or 0^2=2
  1677.          2 && 0
  1678.          The last step is to perform the operation && that  is  1  if  both
  1679.          arguments are not zero and the result is zero if any  of  them  is
  1680.          zero. Finally the value of the expression is zero.
  1681.          0
  1682.          To be honest the evaluation of an  expression  is  not  really  so
  1683.          simple and later we will discuss it more detailed. Now we turn for
  1684.          the operations in detail.
  1685.          Logical OR  || OR
  1686.          ----------
  1687.                  This operator is written as two bars || or  the  word  OR.
  1688.          The first version is common in the language C and can easy be read
  1689.          by C programmers. The second form is common in many languages  and
  1690.          can easy be read by anyone. You can use any of them you wish.  You
  1691.          can even mix them in an expression. The formal definition of  this
  1692.          operation is:
  1693.          argument1 OR argument2
  1694.          The result of the operation is  1  if  any  of  the  arguments  is
  1695.          non-zero.  If  argument1  is  not  zero  then  argument2  is   not
  1696.          evaluated, so in this case  argument2  can  contain  undefined  or
  1697.          external identifiers. The line:
  1698.          !isdef(alpha) || alpha > 1
  1699.          will never cause the error: Undefined  label  in  the  expression!
  1700.          However argument2 must be syntactically correct.
  1701.          Logical AND     && AND
  1702.          -----------
  1703.                  This operator is written as two et signs &&  or  the  word
  1704.          AND. The first form is common in the language C, the second one is
  1705.          common in any other language. You can use any of  them  you  wish.
  1706.          You can even mix them in an expression. The formal  definition  of
  1707.          this operation is:
  1708.          argument1 AND argument2
  1709.          The result of this operation is 1 if both of the  argumentums  are
  1710.          non-zero. If argument1 is zero then argument2  is  not  evaluated.
  1711.          The line:
  1712.          isdef(alpha) && alpha > 1
  1713.          will never cause the error: Undefined  label  in  the  expression!
  1714.          However argument2 must be syntactically correct.
  1715.                  This kind of evaluation when  the  logical  arguments  are
  1716.          evaluated  if  it  is  necessary  is  usually  called  short   cut
  1717.          evaluation.
  1718.          Bitwise OR     |
  1719.          ----------
  1720.                  This  operator  is  written  as  one  bar  |.  The  formal
  1721.          definition of this operation is:
  1722.          argument1 | argument2
  1723.          The result of this operator is the number what is created  setting
  1724.          all the bits that are in a position for which the bit of argument1
  1725.          or argument2 is set. So 2|1 is 3, 3|1 is also 3 and 2|4 is 6.
  1726.          Bitwise xor   ^
  1727.          -----------
  1728.                  This operator is denoted by the character caret ^. This is
  1729.          usually on your keyboard over the number 6 on the  same  key.  The
  1730.          formal definition of this operation is:
  1731.          argument1 ^ argument2
  1732.          The result of this operation is the number that we get setting all
  1733.          the bits that are in a position in which one and only one  of  the
  1734.          bits of argument1 and argument2 is set.
  1735.          Bitwise and  &
  1736.          -----------
  1737.                  This operator is denoted  by  the  character  &.  This  is
  1738.          usually on your keyboard over the number 7. The formal  definition
  1739.          of this operation is:
  1740.          argument1 & argument2
  1741.          The result of this operator is the number that we get setting  all
  1742.          the bits that are in a position for which both bits  of  argument1
  1743.          and argument2 are set.
  1744.          Nonequality, equality = ==, <>
  1745.          ---------------------
  1746.                  The equality operator has to  form.  One  is  a  single  =
  1747.          character. The other one is a double = that is ==. Any of them can
  1748.          be used. The inequality operator is <>. The formal definition is:
  1749.          argument1 = argument2
  1750.          is 1 if argument1  has  the  same  value  as  argument2  and  zero
  1751.          otherwise. The inequality
  1752.          argument1 <> argument2
  1753.          is the opposite of  equality.  It  is  1  if  the  arguments  have
  1754.          different values and 0 if they are the same.
  1755.          Comparing operators  <, >, <=, >=
  1756.          -------------------
  1757.                  These  operators  are  <,  >,  <=  and  >=.   The   formal
  1758.          definitions are:
  1759.          argument1 <  argument 2
  1760.          It is 1 if the value of  argument1  is  less  than  the  value  of
  1761.          argument2 and is 0 otherwise.
  1762.          argument1 <= argument 2
  1763.          It is 1 if argument1 is less  or  equal  to  argument2  and  is  0
  1764.          otherwise.
  1765.          argument1 >= argument 2
  1766.          It is 1 if argument2 is less  or  equal  to  argument1  and  is  0
  1767.          otherwise.
  1768.          argument1 >  argument 2
  1769.          It is 1 if the value of  argument2  is  less  than  the  value  of
  1770.          argument1 and is 0 otherwise.
  1771.          Shift operators  >> SHR, << SHL
  1772.          ---------------
  1773.                  These operators are denoted the same  as  they  are  in  C
  1774.          language. The lexeme << means the shift left, the lexeme >>  means
  1775.          the sift right. The words SHL and SHR can also be used. The formal
  1776.          definitions are:
  1777.          argument1 << argument2
  1778.          The result of the operation is the value  of  the  first  argument
  1779.          multiplied by 2 powered by argument2. This can be  interpreted  as
  1780.          the binary form of argument1 shifted to the left argument2 times.
  1781.          argument1 >> argument2
  1782.          The result of the operation is the value of argument1 divided by 2
  1783.          powered by  argument2.  Only  the  integer  part  is  taken.  This
  1784.          operation can be interpreted as if the binary  form  of  argument1
  1785.          was shifted to the right argument2 times.
  1786.          Addition, Substraction   +, -
  1787.          ----------------------
  1788.                  The sign of these operations is + and -. The  operation  +
  1789.          adds argument1 and argument2, the operator - substracts  argument2
  1790.          from argument1. The formal definitions are:
  1791.          argument1 + argument2
  1792.          argument1 - argument2
  1793.          Multiplication, Division, Remainder *, /, % MOD
  1794.          -----------------------------------
  1795.                  The operator * generates the argument1 times argument2 for
  1796.          argument1 * argument2.
  1797.          The operator  /  generates  argument1  divided  by  argument2  and
  1798.          truncating to be integer.
  1799.          argument1 / argumnet2
  1800.          The operator % creates  the  remainder  of  argument1  divided  by
  1801.          argument2.
  1802.          argument1 % argument2
  1803.          The operator % has another form, the word MOD. Any of these can be
  1804.          used.
  1805.          Unary operators  ! NOT , ~ , - , +
  1806.          ---------------
  1807.                  These operators are unary. It means that  they  have  only
  1808.          one argument. The formal definitions of these operations are:
  1809.          ! argument    or     NOT argument
  1810.          ~argument
  1811.          -argument
  1812.          +argument
  1813.                  The result of the  operation  Logical  Not  is  1  if  the
  1814.          argument is zero. The result is zero if the argument is not zero.
  1815.                  The result of the Bitwise Not is the number  that  we  get
  1816.          setting all the bits that are cleared in the argument and clearing
  1817.          all the bits that are set in the argument.
  1818.                  The result of the operation unary minus is the opposite of
  1819.          the argument.
  1820.                  The result of the operation unary plus is the value of the
  1821.          argument itself.
  1822.                  The last operator seems useless. However it  is  not.  You
  1823.          can use brackets to change the order of the evaluation.  For  this
  1824.          purpose you can use the () brackets and the [] brackets.  This  is
  1825.          because some assembly language  uses  the  ()  brackets  to  refer
  1826.          memory location, other uses  the  []  brackets  for  it.  If  your
  1827.          assembly uses one of these for that purpose then use the other one
  1828.          to close the subexpressions. It is the easiest way not to  confuse
  1829.          the different brackets. The only problem is that  PCMAC  does  not
  1830.          know which type of brackets is used in expressions and which  type
  1831.          of brackets is used to refer memory location. How can PCMAC decide
  1832.          what the instruction
  1833.                          LD      A,(63)
  1834.          means. At first glance it seems to be an  instruction  that  loads
  1835.          the value of the memory location 63 into the register  A.  At  the
  1836.          same time this instruction could mean to load the  value  63  into
  1837.          the  register  A.  This  is  because  the  string  '(63)'  can  be
  1838.          interpreted as an expression in brackets, or an expression without
  1839.          brackets because the brackets can be part of the expression.
  1840.                  The solution is that PCMAC does not allow you to start  an
  1841.          expression with bracket. If you really have an expression that has
  1842.          to start with bracket then put + sign before it. An example is:
  1843.                                   (#0<<3)*(#1>>1)
  1844.          This line can appear in  a  macro  body.  You  can  not  sort  the
  1845.          expression to start with no bracket. You have to write:
  1846.                                  +(#0<<3)*(#1>>1)
  1847.          The + sign will tell PCMAC that this is an expression.
  1848.                  Sometimes very  complex  expressions  can  appear  and  it
  1849.          happens that the number of the closing brackets is  the  same  but
  1850.          they are not paired the way you wanted. PCMAC  helps  to  maintain
  1851.          sophisticated expression by its rigour. PCMAC does not  allow  you
  1852.          to pair a ( bracket with a ] one or vice versa. You should use the
  1853.          same type of brackets. So you can write:
  1854.                                  +[#0<<3]*(#1>>1) ,
  1855.          but you are not allowed to write
  1856.                                  +[#0<<3)*(#1>>1] .
  1857.                  Some words more about how PCMAC evaluates  an  expression.
  1858.          PCMAC always evaluates an expression from the left to  the  right,
  1859.          and if an operation can be executed it executes immediately.  When
  1860.          PCMAC sees the expression:
  1861.                         6*3+5*2
  1862.          when reaches the sign + it knows that the  multiplication  can  be
  1863.          done. No matter what follows the + sign. The subexpression
  1864.                         6*3+...
  1865.          is equivalent to the expression
  1866.                         18+...
  1867.          The three dots mean that the expression  continues.  If  the  left
  1868.          argument of an operator determines the result then PCMAC does  not
  1869.          evaluate the right argument. However the right  argument  must  be
  1870.          syntactically correct because PCMAC has to parse it to know  where
  1871.          it ends.
  1872.                  Expressions can contain some functions. These are:
  1873.          isdef( identifier )  The result of  this  function  is  1  if  the
  1874.                                identifier was defined and 0 otherwise.
  1875.          strlen( string )     The result of this function is the length  of
  1876.                               the string. This is the number of  the  bytes
  1877.                               that would be generated if the  string  stood
  1878.                               after a DB primitive.
  1879.          pop( expression )    The value of the function is the value of the
  1880.                               top element of the stack that is  denoted  by
  1881.                               the  expression.  As  a  side   effect   this
  1882.                               function also removes the  element  from  the
  1883.                               given stack.
  1884.          tos( expression )    This function returns the same value as  pop,
  1885.                               that is the top value of the stack given  but
  1886.                               it does not remove the  top  element  of  the
  1887.                               stack.
  1888.          isreloc(expression)  The result  of  the  function  is  1  if  the
  1889.                               expression is relocatable and 0 otherwise.
  1890.          doreloc(expression)  The result of this function is  the  same  as
  1891.                               the value of the expression.  The  difference
  1892.                               is that this value is relocatable  no  matter
  1893.                               if the value of the  expression  was  or  not
  1894.                               relocatable.
  1895.          doureloc(expression) The result of this function is  the  same  as
  1896.                               the value of the expression.  The  difference
  1897.                               is that this  value  is  not  relocatable  no
  1898.                               matter if the value of the expression was  or
  1899.                               not relocatable.
  1900.                  Relocation
  1901.                  ----------
  1902.                  When writing a large program it is good to split  up  into
  1903.          modules and link  them  together.  Assume  a  large  program  that
  1904.          consists of the modules MAIN.ASM and PART.ASM. We have to  compile
  1905.          these files with the command lines:
  1906.          PCMAC -o MAIN.ASM
  1907.          and
  1908.          PCMAC -o PART.ASM
  1909.          The resulting files will be:
  1910.          MAIN.O
  1911.          and
  1912.          PART.O.
  1913.          To generate executable code we have to link  them  together  with
  1914.          the command line:
  1915.          LINK MAIN.O PART.O
  1916.          The resulting file MAIN.TSK is executable fix code. When we  wrote
  1917.          the assembly lines PART.ASM we did not know where this part of the
  1918.          program will start in the memory. It is not a problem. You can say
  1919.          any address. PCMAC remembers  the  addresses  and  when  you  link
  1920.          programs PCMAC relocates the program automatic. The address of the
  1921.          first byte of the program PART is the length of the program  MAIN.
  1922.          PCMAC links them together.
  1923.          MAIN +-----------------------+START
  1924.               |                       |
  1925.               |       MAIN            |
  1926.               |                       |END
  1927.          PART +-----------------------+START
  1928.               |                       |
  1929.               |       PART            |
  1930.               |                       |END
  1931.               +-----------------------+
  1932.          Relocation means that all the words and double words that refer to
  1933.          addresses that varies with the start of the module are  corrected.
  1934.          If we wrote an assembly program that starts at  the  address  100H
  1935.          and it is linked and gets to the location 101H then all  the  jump
  1936.          instructions and other instructions that refer to memory  location
  1937.          in the program will be corrected adding one to them.
  1938.                  The  predefined  variable  $  has  relocatable  value.  An
  1939.          expression has relocatable value if it is a  relocatable  variable
  1940.          or  label,  or  if  it  is  the  sum  of  a  relocatable   and   a
  1941.          nonrelocatable value. The difference of two relocatable  value  is
  1942.          not relocatable. You need not care the ordering of an  expression.
  1943.          There won't be difference. If all the variables A,  B  and  C  are
  1944.          relocatable, then the following expressions are all relocatable:
  1945.                                   A-C+B
  1946.                                   A+B-C
  1947.                                   B-C+A
  1948.          The result of any other operation is nonrelocatable no matter what
  1949.          the   arguments   were.   The   exceptions   is    the    function
  1950.          doreloc(expression) that generates always relocatable value.
  1951.                  Strings
  1952.                  -------
  1953.                  Strings can appear after the DB primitive  in  expressions
  1954.          and as actual macro argument. A string starts and  ends  with  the
  1955.          sign  ".  There  can  be  any  character  between  them  with  the
  1956.          exceptions that were discussed in the chapter  of  ASCII  numbers.
  1957.          The sign ' can appear in a string without \ but the "  has  to  be
  1958.          preceded  with  the  backslash  character.  The  \n,\t,\r   escape
  1959.          sequences can be used, and the three-digit octal or decimal escape
  1960.          sequences work as well. The directives #decimal and #octal do  for
  1961.          the strings as well.
  1962.                  Macro definitions
  1963.                  -----------------
  1964.                  PCMAC could not do without  macros.  Macros  are  used  to
  1965.          define the assembly language. You can read  and  study  the  files
  1966.          Z80.MAC and EZ80.MAC that are on the distribution  disk  to  avoid
  1967.          reading this chapter. However this contains  detailed  information
  1968.          that you can not find out only reading the files.
  1969.                  The syntax definition of macros
  1970.                  -------------------------------
  1971.                  Each macro definitio contains two parts. The first part is
  1972.          the syntax definition. This is one line and looks like this:
  1973.          macro(syntax string , symbolic constans list)
  1974.          The keyword macro tells PCMAC  that  the  line  contains  a  macro
  1975.          definition. The string that was called syntax string  tells  PCMAC
  1976.          how the main syntax of  the  macro  looks  like.  This  string  is
  1977.          special. The escape sequences  are  treated  other  than  ordirary
  1978.          strings, and  the  character  asterisk  has  special  meaning.  An
  1979.          assembly line is treated as a  macro  if  it  matches  the  syntax
  1980.          string. If we have the syntax string "LD A , ( H L )"  it  can  be
  1981.          matched by any of the lines:
  1982.                  LD A,(HL)
  1983.                  LD           A,(H        L)      ;Comment
  1984.          label   LD A     ,(HL)
  1985.                  LDA,(HL)
  1986.          But the line
  1987.                  L D A,(HL)
  1988.          does not match the definition. You can see that  labels, comments,
  1989.          trailing and leading spaces do not disturb PCMAC. A  line  matches
  1990.          the syntax string if cutting off these parts  all  the  characters
  1991.          matches. The space character is  a  special  one.  In  the  syntax
  1992.          definition a space works as a hundred. One space matches zero, one
  1993.          or more spaces. If you want to force PCMAC to look for exactly one
  1994.          space after the keyword LD you have to use the syntax  definition:
  1995.          "LD\ A , ( H L  )"  The  character  pair  backslash-space  matches
  1996.          exactly one space. In this case only the first  and  the  labeled
  1997.          match the syntax definition. Let us require  at  least  one  space
  1998.          after the keyword LD using the syntax definition: "LD\  A , ( H  L
  1999.          )". After the backslash  there  are  two  spaces.  The  first  one
  2000.          matches exactly one space and the second one matches zero or more.
  2001.          Generally saying  all  the  characters  but  space  backslash  and
  2002.          asterisk matches the same character. Space matches  zero  or  more
  2003.          spaces (tabulators as well). Asterisk matches a symbolic  constans
  2004.          that has to be defined earlier. The  backslash  character  is  the
  2005.          escape character in the syntax string. Any character following the
  2006.          backslash character matches the same character  and  there  is  no
  2007.          exception. So \\ matches one  \  character.  If  we  look  at  the
  2008.          previous example we will see  that  the  macro  matches  only  the
  2009.          instruction that loads the memory location pointed by  HL  to  the
  2010.          accumulator. However the value of that location can be loaded into
  2011.          any register  that  the  Z80  has.  So  we  have  to  define  this
  2012.          instruction in the following way:
  2013.          const   _SS     :=      (B,C,D,E,H,L,(HL\),A)
  2014.          macro("LD *,(HL)",_SS)
  2015.          The part  of  the  syntax  definition  that  was  called  symbolic
  2016.          constans list now contains only one symbolic  constans,  _SS.  The
  2017.          asterisk in the  syntax  string  can  match  any  element  of  the
  2018.          symbolic constans _SS. These are the letters B,C,E,H,L,A  and  the
  2019.          four letter character literal (HL). The definition of the symbolic
  2020.          constans is
  2021.          const identifier := ( literal list )
  2022.          The keyword const tells PCMAC that the line  contains  a  symbolic
  2023.          constant definition.  The  identifier  is  used  to  identify  the
  2024.          constant. The literal list is  a  list  of  the  elements  of  the
  2025.          symbolic constant. Every element is a character sequence that must
  2026.          not contain comma(,), backslash (\) and closing  bracket  ()).  If
  2027.          some has to contain any of these then  the  character  has  to  be
  2028.          preceded with a backslash character, as you saw  in  the  example.
  2029.          The elements are separated by commas. The symbolic  constant  list
  2030.          has to contain so many symbolic constant  name  as  many  asterisk
  2031.          there are  in  the  syntax  string  (not  counting  the  asterisks
  2032.          following backslashes). The  first  asterisk  will  match  the
  2033.          members of the first symbolic constant in  the  list,  the  second
  2034.          asterisk will match those of the second one and so on.
  2035.                  What Are Symbolic Constants
  2036.                  ---------------------------
  2037.                  The symbolic constants  are  those  parts  of  the  syntax
  2038.          definition that are not stable, that can vary. As you see  in  the
  2039.          previous example there was a place in the line where not only  one
  2040.          character could stand but a great number  of  different  literals.
  2041.          The  literals  have  to  be  defined  earlier.  There  are   three
  2042.          predefined  symbolic  constants:  STRING,  NUMERIC,   LABEL.   The
  2043.          asterisks that are related to these constants will match a string,
  2044.          any expression and any identifier, respectively.
  2045.                  Referencing a Macro
  2046.                  -------------------
  2047.                  Referencing a macro is the easiest to do. You only have to
  2048.          write a line that matches a macro. If you did and PCMAC finds  the
  2049.          line then PCMAC replaces it with the  lines  of  the  macro  body.
  2050.          These lines stand between  the  macro  syntax  definition  and  the
  2051.          keyword endm. These lines can contain macro referencing lines, but
  2052.          no  macro  definitions.  So  macros  can  be  nested   but   macro
  2053.          definitions can not.
  2054.                  When a macro matches a  line  PCMAC  collects  the  actual
  2055.          value of the symbolic constants, and replaces  the  references  to
  2056.          them in the macro body. A special character # is used to reference
  2057.          the argumentums. #0 refers to the first argumentum, #1  refers  to
  2058.          the second one and so on. (The character # can be redefined by the
  2059.          directive #macarg.) If we have the macro definition:
  2060.          macro("LD\  *,*",_SS,_SS)
  2061.          #if     #0 == 6 && #1 == 6
  2062.          #error  "LD (HL),(HL) is invalid."
  2063.          #endif
  2064.                  DB      40h+(#0<<3)+#1
  2065.          endm
  2066.          then writing the line
  2067.                  LD   A,B
  2068.          is the same as we wrote the lines:
  2069.          #if 7 == 6 && 0 == 6
  2070.          #error "LD (HL),(HL) is invalid."
  2071.          #endif
  2072.                  DB      40h+(7<<3)+0
  2073.          You can see that the user defined symbolic constants are  replaced
  2074.          by the position number of the literal that stands at the place  of
  2075.          the argument. This position number starts with  zero  and  not  1.
  2076.          This is more comfortable in many cases. This  makes  you  easy  to
  2077.          define assembly instructions. According to this in the example:
  2078.          const   _SS     :=      (B,C,D,E,H,L,(HL\),A)
  2079.          the value of B is zero, the value of C is 1, ... , the value of  A
  2080.          is 7. The #nn references that refer to a STRING type argument will
  2081.          be replaced by the string itself. If a #nn references  a  NUMBERIC
  2082.          type argument then it will be replaced by the actual value of  the
  2083.          expression. If a #nn references a LABEL type argument then it will
  2084.          be replaced by the label itself instead of the value of the label.
  2085.          It makes you possible to define macros that  can  accept  external
  2086.          labels. Here are three examples:
  2087.          1.)
  2088.          macro("JP *",LABEL)
  2089.                  DB 0c3H
  2090.                  DW #0
  2091.          endm
  2092.          The line
  2093.                  JP      J1
  2094.          will be replaced by
  2095.                  DB 0c3h
  2096.                  DW J1   .
  2097.          2.)
  2098.          macro("ASCII *",STRING)
  2099.                  DB strlen(#0),#0
  2100.          endm
  2101.          The line
  2102.                  ASCII "Udvozlet mindenkinek."
  2103.          will be replaced by the line:
  2104.                 DB strlen("Udvozlet mindenkinek."),"Udvozlet mindenkinek."
  2105.          3.)
  2106.          macro("JP *",NUMERIC)
  2107.                  DB 0c3h
  2108.                  DW #0
  2109.          endm
  2110.          The line
  2111.                  JP      J1
  2112.          will be replaced by the lines
  2113.                  DB 0c3h
  2114.                  DW 1601
  2115.          assuming that the value of the label J1 is 1601.
  2116.                  To examine how macros are extended you can use the -m option
  2117.          of PCMAC. This option forces PCMAC to list all the lines, not only
  2118.          the source but every lines that were generated extending a macro.
  2119.                  There is another special character that is extended in the
  2120.          macro body, not only the # character. This character is the @.  If
  2121.          this  character  appears  anywhere  but  inside  of  a  string  or
  2122.          character constant in the  macro  body  it  is  treated  as  macro
  2123.          numbering character. When extending a macro this character will be
  2124.          replaced by the decimal form of the number  that  shows  how  many
  2125.          times the actual macro was extended in the pass. If there are  two
  2126.          of these characters close to each other then they will be replaced
  2127.          by the decimal form of  the  number  that  shows  how  many  macro
  2128.          extension were in the actual pass. You can examine  how  it  works
  2129.          using the -m option of the assembler. This character also  can  be
  2130.          redefined with the directive #macnum.
  2131.                  Some Fine Points of Macros
  2132.                  --------------------------
  2133.                  Assume that you want to use the jump instruction referring
  2134.          to external labels, but sometimes you want to specify  the  target
  2135.          address using expressions. What to do? The macro definition
  2136.          macro("JP *",NUMERIC)
  2137.          won't accept external variable and the definition
  2138.          macro("JP *",LABEL)
  2139.          won't accept sophisticated expressions. The  solution  is  to  use
  2140.          both. You have to define two different  jump  instruction  in  the
  2141.          same macro definition system.
  2142.          macro("JP *",LABEL)
  2143.                  db      0c3h
  2144.                  dw      #0
  2145.          endm
  2146.          macro("JP *",NUMERIC)
  2147.                  db      0c3h
  2148.                  dw      #0
  2149.          endm
  2150.          The body of these macros obviously is the same. It is important to
  2151.          order of the definitions. PCMAC stores the macro definitions in  a
  2152.          list in the same order as they  were  defined.  If  you  have  the
  2153.          macros:
  2154.          macro("JP *",NUMERIC)
  2155.                  db      0c3h
  2156.                  dw      #0
  2157.          endm
  2158.          macro("JP *",LABEL)
  2159.                  db      0c3h
  2160.                  dw      #0
  2161.          endm
  2162.          then writing the line
  2163.                  JP      EXTERNAL_LABEL
  2164.          will cause error message if EXTERNAL_LABEL is really  an  external
  2165.          label. This is because the  first  macro  matches  the  line,  and
  2166.          accepts it. Using this  ordering  all  the  lines  that  could  be
  2167.          accepted by the second definition will be accepted  by  the  first
  2168.          one and so the second one plays no role.
  2169.                  Sometimes ordering is not so important. If  you  have  the
  2170.          macro definitions:
  2171.          macro("JP *",NUMERIC)
  2172.                  DB 0c3h
  2173.                  DW #0
  2174.          endm
  2175.          macro("JP RESET")
  2176.                  DB 0c3h
  2177.                  DW 0
  2178.          endm
  2179.          then the line
  2180.                  JP      RESET
  2181.          will be accepted always by the  macro  definition  that  is  fully
  2182.          static. This is because PCMAC tries to accept a line in two  pass.
  2183.          First it only tries the macro definitions  that  have  no  NUMERIC
  2184.          argument, and tries these only if the first try was unsuccessful.
  2185.                  Some macro definitions are unmatchable. This is  the  case
  2186.          if a macro definition ends with a '\ ' forced space  that  matches
  2187.          exactly one space. No line will end with one space  because  PCMAC
  2188.          cuts off the trailing spaces before trying to interpret as  macro.
  2189.          Some simple cases are discovered  by  PCMAC  and  it  generates  a
  2190.          warning message.  However  the  problem  to  discover  unmatchable
  2191.          syntax definitions is very difficult, and PCMAC sometimes thinks a
  2192.          syntax definition to be matchable when it is not. Some example is:
  2193.          macro("Artificial *+(3)",NUMERIC)
  2194.          endm
  2195.          This macro will never be matched. If we want to refer to it a line
  2196.          like
  2197.                  Artificial  1+(3)
  2198.          PCMAC will think that all the characters  '1+(3)'  belong  to  the
  2199.          expression and won't find the characters '+(3)'.
  2200.                  Command Line Options
  2201.                  --------------------
  2202.                  If you start PCMAC with the  command  line  that  contains
  2203.          only the name of the program, that is PCMAC if you did not  rename
  2204.          it, then PCMAC will print out the following lines:
  2205.          Macro assembler (C) Versoft Ltd. Hungary.
  2206.          Usage: pcmac ['-' options ] filename
  2207.           Options:
  2208.          l list on
  2209.          ln&name listfilename+list on
  2210.          m list macro extension(+list).
  2211.          mn&name listfilename+macro listing+listing.
  2212.          s symbol table
  2213.          c case sensitivity
  2214.          n&outfilename
  2215.          K to make library.
  2216.          o generate object.
  2217.          t don't care publics and externals.
  2218.          h generate header file.
  2219.          v version number.
  2220.          & means: write the name without any space!
  2221.          A command line that invokes PCMAC has to start with its name.  You
  2222.          can freely rename the file with the standard DOS  command  rename.
  2223.          This name tells the DOS what program to start.  The  rest  of  the
  2224.          line is read by the program. PCMAC parses the rest of the  command
  2225.          line and every argument starting with the sign  -  is  treated  as
  2226.          option. Options can appear anywhere on the  line.  The  file  name
  2227.          that appears on the line is the file that contains the  source  of
  2228.          the assembly program. The full file name has to be written because
  2229.          PCMAC makes no default extension. If no file names present in  the
  2230.          -n option then PCMAC generates a name for the output. It cuts  off
  2231.          the extension of the name of the input file and adds the extension
  2232.          .o if generates object file or .tsk if generates task file or  the
  2233.          extension .lib if the option -K was given or the extension  .h  if
  2234.          the option -h was given. If the extension of the input file is  .o
  2235.          and the option -o was given then  PCMAC  gives  the  .q  extension
  2236.          under MSDOS and .O under UNIX. If another file  name  presents  on
  2237.          the command line in the option -n then that  is  taken  as  output
  2238.          file name. Let us go through the options in details:
  2239.          l list on
  2240.                  If this option is given then the assembler generates  list
  2241.                  of the compilation to the screen.
  2242.          ln&name listfilename+list on
  2243.                  If this option is given then PCMAC generates list  of  the
  2244.                  compilation into the file
  2245.          m list  macro extension(+list).
  2246.                  If this option is given then PCMAC generates a  list  that
  2247.                  contains each line that  is  compiled.  If  you  use  this
  2248.                  option then you can see in the list file  how  the  macros
  2249.                  are extended.
  2250.          mn&name listfilename+macro listing+listing.
  2251.                  This option is similar to the -ln option. You can  specify
  2252.                  a  listing  file.  PCMAC  will  generate  a  list  of  the
  2253.                  compilation to the specified list  file  and  the  listing
  2254.                  will contain the macro extensions.
  2255.          s symbol table
  2256.                          If you use this option then PCMAC will generate  a
  2257.                  symbol table finishing the second pass. The  symbol  table
  2258.                  listing is highly readable and appears on the end  of  the
  2259.                  list file.
  2260.          c case sensitivity
  2261.                  By default PCMAC does not care the case of letters in  the
  2262.                  macro definitions, so any character matches it lower  case
  2263.                  or upper case pair. If you specify this option then  PCMAC
  2264.                  won't  treat  upper  and  lower  case  letters  in   macro
  2265.                  definitions as same.
  2266.          n&outfilename
  2267.                  You can use this option to specify the name of the file to
  2268.                  be generated.
  2269.          K to make library.
  2270.                  You can use this option to generate a macro library  file.
  2271.                  Such a file usually has the  extension  .lib  and  can  be
  2272.                  included with the directive #lib. Only such files  can  be
  2273.                  compiled with this  option  that  do  not  contain    code
  2274.                  generation instructions. The generated macro library  file
  2275.                  will contain the macro definitions and the byte  and  word
  2276.                  ordering, but will  not  contain  any  variable  or  label
  2277.                  declaration.
  2278.          o generate object.
  2279.                  Using this option PCMAC will  generate  object  code.  The
  2280.                  generated object code will contain the  code,  information
  2281.                  how to link it to other object files, which code fragments
  2282.                  to relocate and so on.
  2283.          t don't care publics and externals.
  2284.                  Sometimes you want to  compile  a  file  that  is  usually
  2285.                  compiled using the -o option. If  you  don't  use  the  -o
  2286.                  option then PCMAC  will  generate  error  message  when  a
  2287.                  public or extern primitive appears. This option  supresses
  2288.                  this messages.
  2289.          h generate header file.
  2290.                  If you use this option then  PCMAC  will  stop  after  the
  2291.                  first  pass  and  generates  a  readable  text  file  that
  2292.                  contains EQU primitives that assigns  the  values  to  the
  2293.                  labels that appeared in the source. Using this option  you
  2294.                  can avoid using the linker if you really want to.  However
  2295.                  using the linker is much powerful.
  2296.          v version number.
  2297.                  If you specified this option then PCMAC would neglect  all
  2298.                  other options and filename, if any, and writes out a short
  2299.                  text on the original owner of the copy. If this text names
  2300.                  any person then your copy is a pirate one.  Some  Hungarian
  2301.                  men got copies for debugging purposes.  All  those  copies
  2302.                  contain the name of the owner and it is  written  out  for
  2303.                  the -v option. What is more: these copies are not the last
  2304.                  versions of  the  assembler,  these  copies  do  not  work
  2305.                  properly and there is no guarantee that such a  copy  will
  2306.                  not damage your files or hardware. If you have such a copy
  2307.                  connect the firm ???????????????????.
  2308.                  The Linker
  2309.                  ----------
  2310.                  The linker is a separated program that  links  the  object
  2311.          files were generated by PCMAC to task  file.  You  can  start  the
  2312.          linker with the command line:
  2313.          link
  2314.          If no argument  is  given  then  the  linker  prints  out  a  sort
  2315.          remainder about its usage:
  2316.          Usage: link [options] input_file_name_list
  2317.          Options: -B[x]nnnn base address. (if x then in hex.)
  2318.          n&name change default (a.tsk) outfilename
  2319.          w reverse word order.
  2320.          d reverse long word order.
  2321.          The & means: write the name without space.
  2322.          The word link is the name of the file containing the  linker.  You
  2323.          can change it if you want with the standard  DOS  command  rename.
  2324.          Many different linkers have the name: link. You can choose a  name
  2325.          that is good for you as pcmaclnk or  linkpcmc  or  any  else.  The
  2326.          first word on the command line has to be  the  name  of  the  file
  2327.          containing the program. The rest of the line is read by the linker
  2328.          itself. Every argument that starts with the character - is treated
  2329.          option. The arguments that start with some character that is not -
  2330.          is treated as file name that the linker has to read  and  link  to
  2331.          the others. The PCMAC  linker  has  much  less  options  than  the
  2332.          assembler. The most important option is the -B option. Using  this
  2333.          option you can specify the base address of the task code. This  is
  2334.          the address where you want to load the program.  The  linker  will
  2335.          relocate the addresses that are relocatable in the object file  so
  2336.          that your program will start on the address you specified with the
  2337.          option -B. This option must contain  a  number.  If  you  have  an
  2338.          object file named MYFIRST.o then using the command line:
  2339.          link MYFIRST.o -B32000
  2340.          will generate a task file called a.tsk that contains code that you
  2341.          can load into your target machine to the address  32000.  You  can
  2342.          specify the base address in hexadecimal form. In such a  case  you
  2343.          have to use the option -Bx. So the command line:
  2344.          link MYFIRST.o -Bx7d00
  2345.          has the same effect as the previous one.
  2346.                  The linker has to know how to  treat  the  words  and  the
  2347.          double words. If the the words contain the bytes in normal  order,
  2348.          that is lower address lower significant byte, then you should  not
  2349.          use the -w option. This option says that  the  words  have  to  be
  2350.          dealt with in reverse order. This is the case for the code of  the
  2351.          MOTOROLA processors. The option -d  says  that  the  double  words
  2352.          contain the words in reverse order.
  2353.                  The default file name for the generated code is a.tsk.  If
  2354.          you want to change this then you have to use the  -n  option.  You
  2355.          can use it the same way as the option -n of the assembler PCMAC.
  2356.                  The Format of the Object Code
  2357.                  -----------------------------
  2358.                  This chapter is not necesary to be read for  using  PCMAC
  2359.          assembler and linker. This chapter is included  here  to  save  up
  2360.          time of heavy hackers who would  investigate  the  format  of  the
  2361.          object format of PCMAC. By the way, it  is  not  secret.  You  can
  2362.          write your own programs that generate PCMAC  object  format  file,
  2363.          and you can link them together with the PCMAC linker. If you do so
  2364.          then do not  depend  on  features  that  you  found  scanning  the
  2365.          generated object files but which  are  not  declared  here.  Later
  2366.          versions of PCMAC may generate different format.  In  the  current
  2367.          version all the public and external label declarations are at  the
  2368.          end of the file. This feature is NOT declared  and  later  can  be
  2369.          changed.
  2370.                  The format of the PCMAC object code is  different  to  the
  2371.          standard Microsoft object format. This is because:
  2372.          1.) When the development of PCMAC stated  the  developers  had  no
  2373.              information on that format.
  2374.          2.) The Microsoft object format is too sophisticated.  Using  that
  2375.              format would have caused a slower assembler and linker.
  2376.                  Here we present the definition of the format of the  PCMAC
  2377.          object file. All the codes are written in hexadecimal form.
  2378.                  PCMAC object file starts with the  bytes  55  and  AA.  If
  2379.          these bytes are missing then the linker stops  with  error.  These
  2380.          bytes make possible for the linker to find out if the file is not
  2381.          a PCMAC object file with the probability  99.99847412%.  Following
  2382.          this magic word the object file consists of  blocks.  Every  block
  2383.          starts with an identifier byte. These are:
  2384.                  81       CODE
  2385.                  82       RELOC
  2386.                  83       PUB
  2387.                  84       EXTDEF
  2388.                  85       EXTREF
  2389.          The names here present as reference names. The developers of PCMAC
  2390.          used  these  names.  Following  this  byte  there  are  two  bytes
  2391.          containing the length of the body of the block. The body is follow
  2392.          by one byte check sum. The format of the body of a  block  depends
  2393.          on the type of the block. Here is the format  of  the  bodies  and
  2394.          some comment on their contents.
  2395.           81  CODE   4ADDRESS 1NRofBYTES bytes
  2396.                These blocks contain generated code. The first four bytes of
  2397.              contains the address where  the  code  has  to  be  put.  This
  2398.              address will be modified by the  linker.  The  following  byte
  2399.              contains the number of the bytes that are  in  the  body.  The
  2400.              rest of the block body is the list of the bytes.
  2401.           82  RELOC  1NRofITEMS ITEMS( 1SIZE[0W F0D] 4ADDRESS)
  2402.                These  block  bodies  contain  the  information  about   the
  2403.              addresses that have to be relocated. The  first  byte  of  the
  2404.              body is the number of the items that are  in  the  block.  The
  2405.              rest of the block body is the items. Every item is five bytes.
  2406.              The first byte is zero if the address  points  to  a  word  to
  2407.              relocate and contains F0 if the address  points  to  a  double
  2408.              word to relocate. The last four bytes of the item presents the
  2409.              address.
  2410.           83  PUB    1(0=NREL F0=REL) name \0 4VALUE
  2411.                These block define the public symbols that  are  defined  as
  2412.              external  symbols  in  other  files.  These  symbols  can   be
  2413.              referenced in other files. The first byte of the block body is
  2414.              zero if the value of the symbol is absolute and is F0  if  the
  2415.              value of the symbol is relocatable. This byte is  followed  by
  2416.              the identifier of the  symbol.  Any  character  sequence  that
  2417.              contains no zero byte and is shorter  than  100  bytes  is  an
  2418.              identifier for the PCMAC linker. The name is terminated with a
  2419.              zero byte. The last four byte of the block body is  the  value
  2420.              of the symbol.
  2421.           84  EXTDEF name \0 2IDTFNUM
  2422.                These blocks define an external symbol. The body starts with
  2423.              the the name of the  external  symbol.  The  name  has  to  be
  2424.              shorter than 100 bytes and must be terminated by a zero  byte.
  2425.              The last two bytes of the block body contain  the  identifying
  2426.              number of the symbol. This identifying number is used  in  the
  2427.              blocks EXTREF. Such an identifying number is unique within one
  2428.              object file. Different object  files  for  different  external
  2429.              identifiers can have the same identifying number and different
  2430.              object  files  for  the  same  external  identifier  can  have
  2431.              different identifying number.
  2432.           85  EXTREF 1NRofITEMS ITEMS(2IDTFNUM 1TYPE[
  2433.                         1BYTE 2WORD 4DWORD feRBYTE fdRWORD fbRDWORD] 4ADDRESS)
  2434.                These blocks contain the information of  the  holes  of  the
  2435.              code that have to be filled up with the values of  the  global
  2436.              symbols. The first byte contains the number of  the  items  of
  2437.              the block. Every item is seven bytes long. The first two bytes
  2438.              contain the identifying number that has to  be  defined  in  a
  2439.              EXTDEF block. The next byte is the type of the location  where
  2440.              the address points to. This byte can be:
  2441.              01          The value has to fit into a byte.
  2442.              02          The value has to fit into a word.
  2443.              04          The value has to fit into a double word.
  2444.              FE          The value has to be converted relative
  2445.                          and fit into a byte.
  2446.              FD          The value has to be converted relative
  2447.                          and fit into a word.
  2448.              FB          The value has to be converted relative
  2449.                          and fit into a double word.
  2450.              The last four bytes of the item contain the address of the value.
  2451.                  Error messages of the assembler
  2452.                  -------------------------------
  2453.            The assembler handles five different type of errors. These types
  2454.          are:
  2455.          MESSAGE
  2456.          WARNING
  2457.          NORMAL
  2458.          FATAL
  2459.          INTERNAL
  2460.            A MESSAGE type error  message  appears  in  the  list,  that  is
  2461.          usually the  screen,  when  the  assembly  program  contains  some
  2462.          #message directive. This is not really an error.  It  is  a  simle
  2463.          message. The assembler writes it out and forgets all about it. The
  2464.          assembler itself does not generate such type of messages.
  2465.            A WARNING type message warns the user if he  made  some  mistake
  2466.          which is not too serious and the assembler can correct it. However
  2467.          in many cases it is very useful to pay attention  to  the  warning
  2468.          messages.
  2469.            A NORMAL type error message appears in the list if  PCMAC  finds
  2470.          some error in the source that is too  serious  to  decide  how  to
  2471.          solve  it.  After  such  an  error  message  PCMAC  continues  the
  2472.          compilation but it is only for  the  discovery  of  later  errors.
  2473.          PCMAC does not generate code if  any  NORMAL  type  error  message
  2474.          appeared. PCMAC starts the second pass even  if  there  were  some
  2475.          NORMAL type error messages in the first pass, and can happen  that
  2476.          there is no such error in the second  pass.  In  this  case  PCMAC
  2477.          warns you at the end of the list that there were error messages in
  2478.          the first pass.
  2479.            A FATAL type error message appears if  PCMAC  finds  some  error
  2480.          that prevents PCMAC to continue the compilation. If such an  error
  2481.          encounters PCMAC stops the compilation immediately.
  2482.            An INTERNAL type error appearance means that there is some error
  2483.          in the assembler itself. You can do  nothing  to  recover  it  but
  2484.          report it to the firm who released your version of  PCMAC  and  to
  2485.          wait for the next release. However you  can  try  to  change  your
  2486.          assembly file in some way but  there  is  no  guarantee  that  you
  2487.          succeed.
  2488.            The error messages appear in the list file and on the screen. If
  2489.          the list file is the screen itself  then the error message appears
  2490.          only once. The messages appear in the list file following the list
  2491.          of the line where the errors were detected. The  assembler  writes
  2492.          out the type of the error and the message. This  message  is  some
  2493.          short remainder in case of WARNING, NORMAL, and FATAL messages. In
  2494.          case of INTERNAL message the text is only a three digit number. In
  2495.          case of MESSAGE type the text is determined by the assembly  file.
  2496.          The next chapter contains the messages that are generated  by  the
  2497.          assembler itself. The messages are sorted into alphabetical order.
  2498.                  The list of the error messages
  2499.                  ------------------------------
  2500.            The items of the  list  contain  the  error  messages  and  some
  2501.          explanation and advises how to recover if such  an  error  appear.
  2502.          The first character of the line means the type of the messages.  W
  2503.          for WARNING,N for NORMAL, F  for  FATAL.  An  item  contains  more
  2504.          messages if the same explanation describes them.
  2505.          N   #ifdef needs an identifier
  2506.          N   #ifndef needs an identifier
  2507.            The directives #ifdef and #ifndef need an identifier in the same
  2508.          line. These directives switch the compilation on and  off  if  the
  2509.          identifier was declared or if was not.
  2510.          N   #stack needs variable
  2511.            The directive #stack needs a variable in the same line. Get sure
  2512.          that you wrote the identifier of a variable and not a label in the
  2513.          line of the directive.
  2514.          N   #until for an outer #repeat
  2515.            PCMAC found some #until directive for which it can not find  the
  2516.          directive  #repeat.  The  directive   pairs   #repeat,#until   and
  2517.          #while,#wend can be nested but not overlapped. Remember that these
  2518.          directives can be used only in macro definitions.
  2519.          N   #until without #repeat
  2520.            PCMAC found some #until directive for which it can not find  the
  2521.          directive #repeat. You forgot to write the #repeat for the pointed
  2522.          #until or you used two different #until directives  for  the  same
  2523.          #repeat. Remember that these directives can be used only in  macro
  2524.          definitions.
  2525.          N   #wend for an outer #while
  2526.            PCMAC found some #wend directive for which the directive  #while
  2527.          was not declared before an unclosed #repeat. The  directive  pairs
  2528.          #repeat,#until and #while,#wend can be nested but not  overlapped.
  2529.          Remember  that  these  directives  can  be  used  only  in   macro
  2530.          definitions.
  2531.          N   #wend without #while
  2532.            PCMAC found a directive #wend for which  it  can  not  find  the
  2533.          directive #while. You forgot to write the directive #while or  you
  2534.          used two #wend directives for the same #while. Remember that these
  2535.          directives can be used only in macro definitions.
  2536.          N   #while has no #wend in the macro
  2537.            PCMAC reached the end of a macro definition and found  a  #while
  2538.          for which there was no closing #wend. Remember that all the #while
  2539.          directives have to have their pairs. The same holds for  #repeats.
  2540.          Remember  that  these  directives  can  be used  only   in   macro
  2541.          definitions.
  2542.          N   ( missing in the macro definition
  2543.            Starting a macro definition PCMAC found the  keyword  macro  but
  2544.          the character ( is missing after it.
  2545.          N   ( expected!
  2546.            PCMAC found an expression  in  which  a  function  name  is  not
  2547.          followed by a left brace. Remember that the characters ( and [ can
  2548.          be used in expression to close  subexpressions,  but  argument  of
  2549.          predefined functions can only closed between ( and ).
  2550.          N   ) missing after the const definition.
  2551.            PCMAC found the end of the line following a const definition but
  2552.          the definition was not close with the character ).
  2553.          N   , missing between the expressions
  2554.            In expression lists you have to separate  the  expressions  with
  2555.          commas. You separated the expressions with some  spaces  or  you
  2556.          made some syntactical mistake in the first  expression  and  PCMAC
  2557.          thinks that the separating comma is missing.
  2558.          N   := expected
  2559.            You forgot to use  the  sign  :=  in  a  const  definition.  You
  2560.          probably wrote spaces or a single = sign.
  2561.          N   ASCII code out of range
  2562.            The value of an expression following the directive #char is  not
  2563.          between the interval 0..255. Try to calculate  the  value  of  the
  2564.          expression by hand and get sure that the value is really valid.
  2565.          W   ASCII number is too long
  2566.            An ASCII number starts and ends with an  apostrof  (')  and  can
  2567.          contain at most four characters between. You wrote more than  four
  2568.          characters or only forgot to type the closing apostrof.
  2569.          N   Assign for a non variable symbol
  2570.            The assignment can be used only to assign value to  a  variable.
  2571.          The Identifier that stands in the line was declared as label.  Use
  2572.          some other identifier.
  2573.          F   Bad macro library file
  2574.            PCMAC tried to include a file as a macro library file,  but  the
  2575.          file, of which the name was given following the directive #lib, is
  2576.          not a macro library file. The file might damaged. In this case you
  2577.          have to recompile it with PCMAC using the command line option  -K.
  2578.          Be sure that you named the compiled file following  the  directive
  2579.          #lib and not the original macro definition file. If you  mixed  up
  2580.          the two files than you have to change  the  file  name  after  the
  2581.          directive #lib or you can use the directive #macros.
  2582.          W   Character not terminated
  2583.            You forget to write out the terminating apostrof of a  character
  2584.          constant before the end  of  the  line.  Terminate  the  character
  2585.          constants with the character (')!
  2586.          N   Code generating error !
  2587.            PCMAC tried to generate a byte for an address that is lower than
  2588.          the lowest address of the first pass or higher  then  the  highest
  2589.          byte of the  first  pass.  It  means  that  the  different  passes
  2590.          generate different code. It is hard to recover of this  error.  It
  2591.          is usually caused by conditional compilation that depends  on  the
  2592.          variable pass. Get sure that the blocks that are not  compiled  in
  2593.          one of the passes do not generate code.
  2594.          N   Dangling #endif
  2595.            A line containing a directive #endif encountered and  PCMAC  can
  2596.          not find the directive #if, #ifdef or #ifndef. You forgot to write
  2597.          the line that contains that directive or used two different #endif
  2598.          directives for the same #if??? directive.
  2599.          N   Empty syntax definition
  2600.            You specified an empty string as syntax definition of  a  macro.
  2601.          This macro definition can not be matched by any  line,  so  such  a
  2602.          macro definition is out of use. Do not do it.
  2603.          F   End of memory!
  2604.            Well, this error is a very unconfortable one. You get  an  error
  2605.          message though you made no  mistakes.  Only  the  memory  of  your
  2606.          computer is to small. Buy some more memory if possible. A  cheaper
  2607.          solution is to split up the assembly program into more  files  and
  2608.          compile it with the option -o and link the object files. Use  less
  2609.          variables, labels and macros.
  2610.          N   Error in the file name
  2611.            A directive #include, #macros or #lib is followed by a file name
  2612.          that is closed between " or <> pairs. You should not  mix  up  the
  2613.          different terminators. If you start a file name with  <  then  you
  2614.          have to terminate it with > and if you opened a file name  with  "
  2615.          then you have to close it with ".
  2616.          N   Expression must be predefined
  2617.            The expression standing on the right hand side of an command  :=
  2618.          or equ is not evaluateable.  This  is  because  some  label  is  not
  2619.          defined yet. An expression like that has to be evaluatable.
  2620.          N   External can not be public
  2621.            You declared a label as public and as external. It is no use and
  2622.          impossible.
  2623.          N   External in an expression
  2624.            A variable that is declared as external can not be  used  in  an
  2625.          expression. Use two macro definitions with the same syntax  string
  2626.          for the same instruction if you  want  to  refer  expressions  and
  2627.          external labels as macro arguments.
  2628.          N   External with no -o option
  2629.          N   Public with no -o option
  2630.            You tried to compile a program that  contains  external  labels.
  2631.          This is a mistake. You probably forgot to use the  option  -o.  If
  2632.          you really want to generate a tsk file immediately then use the -t
  2633.          option, but be sure that all the external labels get value.
  2634.          N   Identifier expected after public
  2635.            There must be one or more identifiers  following  the    keyword
  2636.          public. The identifiers must be separated by commas.
  2637.          N   Identifier expected in the CONST!
  2638.            You forgot to specify an identifier for the  symbolic  constant.
  2639.          Without this name you can not reference the constans so no use to
  2640.          declare literals without name. Insert a name between the  sign  :=
  2641.          and the  keyword 'const'.
  2642.          N   Identifier missing as a const definition
  2643.            This message appears if the assembler does  not  find  the  next
  2644.          literal following a comma. You probably deleted the  last  literal
  2645.          of the list but forgot to delete the separating comma or you  just
  2646.          simply mistyped something.
  2647.          W   Inconsistent options -o -h
  2648.          F   Inconsistent options -o -K
  2649.          W   Inconsistent options -o -t
  2650.            The options -h, -K and -t can or may not be used with the option
  2651.          -o. Read through the chapter that tells you what are caused by the
  2652.          options.
  2653.          W   Input file name *.o
  2654.            The extension of the input file name is the letter o that is the
  2655.          default extension of the  generated  file  if  the  -o  option  is
  2656.          present. Do not use the .o extension  for  source  files.  If  you
  2657.          compile a file with the  extension  .o  to  object  file  and  you
  2658.          do not specify output file name then the assembler  will  put  the
  2659.          object code into a file that is named with the same  name  as  the
  2660.          input but the extension will be .q  for  MSDOS  or  .O  for  UNIX.
  2661.          (This is because MSDOS treats .o and .O the same.)
  2662.          N   Invalid case suboption
  2663.            The option -c has no suboption so it has to  be  followed  by  a
  2664.          space. You should not specify UNIX style options. E.g.: You should
  2665.          write -c -K instead of -cK.
  2666.          N   Invalid list suboption.
  2667.            The option -l can be followed by the character  n.  This  letter
  2668.          tells PCMAC that the name of the list file follows.  You  can  not
  2669.          specify any other sub option.
  2670.          N   Invalid option
  2671.            You specified an option letter that is not used  by  PCMAC.  You
  2672.          probably wrote -k instead of -K.
  2673.          N   Invalid const number
  2674.            You used a number following the  macro  argument  character  for
  2675.          which there is no argument for. Do not forget that  the  numbering
  2676.          of the arguments start with zero instead of 1.
  2677.          N   Macro definition nesting is not allowed
  2678.          N   Macro definition not terminated
  2679.            Macros can not be nested.  This  speeds  up  the  assembler  and
  2680.          prevents the user to generate memory  vasting  constructions.  All
  2681.          neccessary definitions can be made without nesting. If you do  not
  2682.          know what we are talking about because you did not  want  to  nest
  2683.          any macro into another then you probably forgot to write the  line
  2684.          endm. It can be the case even if you got the first error  message
  2685.          because PCMAC does not know whether you forgot to close  a  macro
  2686.          or wanted them to be nested.
  2687.          F   No more stacks
  2688.            At most 100 stack can be opened at a time. It must be enough for
  2689.          every development. You tried to open the 101. stack. It can happen
  2690.          if open a stack inside of a macro in a loop or  if  the  macro  is
  2691.          recursive.
  2692.          N   No label whom assign the value to
  2693.          N   No variable whom assign the value to
  2694.            The mnemonic equ or the sign := is not preceeded by  identifier.
  2695.          These instructions are  to  assign  value  to  a  label  or  to  a
  2696.          variable.
  2697.          N   Non ascii character for macro number
  2698.          N   Non ascii character for macro prefix
  2699.            The value of the expression following the directive  #macarg  or
  2700.          #macnum is not between the interval 0..255. Try to  calculate  the
  2701.          value of the expression by hand and get sure  that  the  value  is
  2702.          really valid.
  2703.          W   Non octal character in string number
  2704.            This is a very dangerous warning.  This  is  generated  if  a  \
  2705.          character in a string is followed by the character 8 or 9. This is
  2706.          dangerous because you can think that the assembler generates bytes
  2707.          with the value 8 or 9. However the assembler generates bytes  that
  2708.          hold the ASCII code of the characters '8'  or  '9'.  This  warning
  2709.          message will not appear if the ASCII radix is set to decimal  with
  2710.          the directive #decimal. In that case the assembler will generate a
  2711.          byte whith he value 8 or 9.
  2712.          W   Non relocatable for byte offset
  2713.          W   Non relocatable for word offset
  2714.          W   Non relocatable for dword offset
  2715.            The expression following the drb, drw  or  drd  command  is  not
  2716.          relocatable. This is probably wrong.
  2717.          N   Not 16 bit value for a word
  2718.            The value of the expression following the directive dw is not  a
  2719.          16  bit  value.  The  assembler  does  not  truncate  the   values
  2720.          automatic.  You  have  to  declare  the  truncation   and   write:
  2721.          '(expression)&0FFFFh' instead of 'expression'.
  2722.          N   Not closed loop in the macro
  2723.            PCMAC reached the end of  a  macro  definition  and  found  some
  2724.          unclosed loop. It can either  be  #repeat,#until  or  #while,#wend
  2725.          loop. Read the macro definition and correct it.
  2726.          F   Not only macros for macro library
  2727.            You tried to compile a file with the option  -K  that  contained
  2728.          code generating instructions. These instructions can  not  be  put
  2729.          into a macro library file. Eliminate these lines or do not compile
  2730.          this file but include it with the directive #macros.
  2731.          N   Not used user stack free
  2732.            You specified a stack in the directive #clostack which  was  not
  2733.          opened with the directive #stack. You tried  to  close  the  stack
  2734.          twice or you close the stack in  a  macro  that  is  recursive  or
  2735.          contains loop.
  2736.          W   Octal number terminated by digit
  2737.            This is a dangerous warning and never  skip  it!  You  used  an
  2738.          escape sequence in a string and the octal numbers were  terminated
  2739.          by a non octal digit that is 8 or 9. You can easy  read  it  as  a
  2740.          digit that belongs to the octal  number  and  interpret  it  as  a
  2741.          decimal number. Be  sure  that  you  really  want  a  nonprintable
  2742.          character followed by the character 8 or 9. This message will  not
  2743.          appear if the radix of the ascii numbers is set  to  decimal  with
  2744.          the directive #decimal.
  2745.          N   Poping an empty stack
  2746.          N   Reading the TOS of an empty stack
  2747.            The assembly program wants to fetch a value from a compile time
  2748.          stack that is empty. In the current version of the assembler there
  2749.          is no way to check if a stack is empty.
  2750.          N   Public symbol was not defined
  2751.            You declared a variable as public but it got no value during the
  2752.          passes.
  2753.          N   External with no -o option
  2754.          N   Public with no -o option
  2755.            You tried to compile a program that  contains  external  labels.
  2756.          This is a mistake. You probably forgot to use the  option  -o.  If
  2757.          you really want to generate a tsk file immediately then use the -t
  2758.          option, but be sure that all the external labels get value.
  2759.          N   Redefining a label
  2760.          N   Redefining a symbol
  2761.          N   Redefining an identifier
  2762.            A label may appear only once on the left hand side of a line.  A
  2763.          literal can stand in different definitions, but  the  const  names
  2764.          has to be different. An identifier  can  be  used  to  identify  a
  2765.          label, a variable, const name, but only one at a time.
  2766.            Many programmers cause the first error message  forgetting  that
  2767.          the l;abels inside of a macro are not local. They will  appear  as
  2768.          labels so many times as many  times  the  macro  is  extended.  To
  2769.          generate  local  labels  you  have  to  use  the  macro  numbering
  2770.          characters with which you can extend your labels with numbers.
  2771.          W   Relocatable data for byte
  2772.            The assembler does not relocate byte values. If a byte value  is
  2773.          relocatable then a mistake is very probable.
  2774.          N   Relocatable value for ASCII code
  2775.          W   Relocatable value for list switching
  2776.          N   Relocatable value for macro number
  2777.          N   Relocatable value for macro prefix
  2778.          N   Relocatable value for stack number
  2779.            The value of an expression is relocatable, but the way of  usage
  2780.          is not. If you really want to  use  relocatable  values  at  these
  2781.          places then use the doureloc function.
  2782.          N   Right bracket missing in the expression
  2783.            You can use () and [] characters to close  subexpressions  inside
  2784.          of an expression. The subexpressions can be nested any level  deep,
  2785.          but all '('s have to have the pair ')' and the same  is  true  for
  2786.          the '['s. You can not close a subexpression opened with '(' with a
  2787.          ']' and vice versa. It is a good style to use one of the  brackets
  2788.          to close  subexpressions.  Some  assembly  languages  use  the  ()
  2789.          brackets to refer to memory and other use the [] brackets. You  do
  2790.          use the other one to close subexpressions. Do not forget that  the
  2791.          arguments of the predefined functions should be closed with ().
  2792.          N   Const definition can not be inside of a macro
  2793.            A const definition can only be global in an assembly program and
  2794.          can not be localised for a macro. That is the reason for which you
  2795.          can not define a const definition inside of a macro.  If  you  get
  2796.          this error message, but you did not wan to declare const inside of
  2797.          a macro then you probably forgot to close the previous  macro.  It
  2798.          is a good style to collect all the const macro definitions to  the
  2799.          start of the file before the macro definitions.
  2800.          N   Syntax error in the expression
  2801.            The assembler found an expression that it can not understand.
  2802.          N   String not terminated
  2803.            The closing " is missing at the end of the string. Unlike  in  C
  2804.          language you can not continue a string in the next line using a  \
  2805.          to close the line.
  2806.          F   Too deep include in the file system
  2807.            An included file may include another one but  the  nesting  must
  2808.          not exceed the number 5. This deepness is enough for the  most  of
  2809.          the applications. Deeper include appears if you probably  made
  2810.          a loop and the files recursively include each other.
  2811.          N   Too few const definition
  2812.            The syntax definition string contains more  asterisks  than  the
  2813.          number of the consts on the end of the syntax  definition  line  of
  2814.          the macro. In this case the assembler does not know what  kind  of
  2815.          arguments should be excepted. If you wanted to have  an  asterisks
  2816.          in the line then do not forget to preceede it with a  backslash  in
  2817.          the syntax definition string.
  2818.          F   Unable to open the library file
  2819.          F   Unable to open the object file
  2820.          F   Unable to open the output file
  2821.          N   Unable to open the list file
  2822.            The assembler can not open one of the files. It  can  happen  if
  2823.          you specified a wrong directory or mistyped the name of the file.
  2824.          It also can happen that the assembler wants  to  open  the  output
  2825.          file but it  already  exists  and  protected.  In  this  case  the
  2826.          assembler can not delete the old file to open the new one with the
  2827.          same name. The assembler was developed to be a very safe tool and
  2828.          it will not damage your file system.
  2829.          N   Unbalanced #ifs
  2830.            The assembler found a directive  #if  for  which  there  is  not
  2831.          #endif. Get sure that you closed all the #ifs. The directive pairs
  2832.          #if\#endif, #ifdef\#endif and #ifndef\#endif  can  be  nested  any
  2833.          level deep but each has to have its pair.
  2834.          N   Undefined label in the expression
  2835.            One of the labels in the expression is not defined. It also  can
  2836.          happen that you try to compile a  file  with  the  option  -t  and
  2837.          forgot to include some of the files that define the value  of  the
  2838.          variables.
  2839.          N   Unexpected characters on the end of the line
  2840.            The assembler found some characters on the end of the line  with
  2841.          which it can not do anything. You probably forgot to  preceede  the
  2842.          comment with a ; character or mistyped something.
  2843.          N   Unknown byte order in the #dw directive
  2844.          N   Unknown word order in the #dd directive
  2845.            The directives #dw and #dd should be followed with the character
  2846.          pairs lh or hl. Nothing else can stand on that place.
  2847.          N   Unmatchable syntax definition
  2848.            The assembler generates this error message if it found a  syntax
  2849.          definition string that is not matchable. The  assembler  does  not
  2850.          discover the unmatchability of the syntax string so:  if  you  get
  2851.          this error message then there is no line accepted by this   syntax
  2852.          definition, if you did not get  this  message  then  there  is  no
  2853.          guarantee that there is line.
  2854.          N   Variable can not be public
  2855.            An identifier that was declared as public is used  as  variable.
  2856.          Only labels can be public. Variables are tools to  be  used  while
  2857.          compile time and not while link time.
  2858.          W   Variable was not explicitly declared
  2859.            A variable has to be declared in the instruction  'var'.  If  an
  2860.          identifier was not declared as variable and  stands  on  the  left
  2861.          hand side of a assignment then the assembler automaticly  declares
  2862.          the it as a variable but sends the warning message.
  2863.          N   Wrong binary number
  2864.          N   Wrong octal number
  2865.          N   Wrong decimal number
  2866.          N   Wrong hexadecimal number
  2867.            The assembler found a mistyped number. You  can  get  the  third
  2868.          error message for hexadecimal numbers if the number ends with  the
  2869.          hexadecimal digit 'D' or  'd'  and  you  forgot  to  use  the  'h'
  2870.          postfix. This is because in this case the  assembler  thinks  that
  2871.          you used the optional decimal postfix 'd'.
  2872.          N   Wrong stack number
  2873.            The assembler generates this error message if the program refers
  2874.          to a stack that was not opened or is closed yet.
  2875.          N   " missing after the macro definition
  2876.            The  assembler  generates  this  error  message  if  the   macro
  2877.          definition string is not terminated with a ".
  2878.          N   " missing in the macro definition
  2879.            A macro syntax definition is closed between ( and ).  The  first
  2880.          member of the definition is the syntax string that  starts  with  a
  2881.          character ". The assembler can not find this character.
  2882.          N   " missing after the message in an 'message' directive
  2883.          N   " missing after the message in an 'warning' directive
  2884.          N   " missing after the message in an 'error' directive
  2885.          N   " missing after the message in an 'fatal' directive
  2886.             The assembler generates  this  error  message  if  the  message
  2887.          string following the directive is not terminated before the end of
  2888.          the line.
  2889.          N   " missing after the 'message' directive
  2890.          N   " missing after the 'warning' directive
  2891.          N   " missing after the 'error' directive
  2892.          N   " missing after the 'fatal' directive
  2893.            The directives #message, #warning, #error and #fatal has  to  be
  2894.          followed with a string.