home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / asmbly.tzt / ASMBLY.TXT
Text File  |  1988-01-30  |  6KB  |  117 lines

  1. CP/M - ASSEMBLY LANGUAGE
  2. by Stanley M. Gee, PUGSKUG, August 1987
  3.  
  4. (Assembly language primer for CP/M)
  5.  
  6. Assembly language programing, while not difficult, is tedious and
  7. slow for most beginners.  You may wonder why, if assembly
  8. programing is so tedious and slow, it is used almost universally
  9. by the computer industry.  Assembly language programs are written
  10. in machine coding and run faster.  Unlike a higher level language
  11. like basic, the programmer in assembly language must have an
  12. understanding of the computer architecture.  Memory locations
  13. which are taken care of by the basic software are the
  14. responsibility of the assembly programmer.
  15.  
  16. There are several books written on assembly programming and I
  17. would recommend that any one truly interested in learning
  18. assembly language programming obtain any or all of the books
  19. available and study them in earnest.  Also there are courses
  20. taught in assembly language programming which will assist the
  21. neophyte in learning about this primitive language. 
  22.  
  23. Assembly language programs can be written with the CP/M editor
  24. (Ed. note: if you're a masochist!), a Word Processor like Perfect
  25. Writer or with the CP/M Dynamic Debugger Tool (DDT).  After the
  26. program is written with a word processor or the editor, it must
  27. be compiled with ASM.COM.  If successful the HEX file generated
  28. by the compiler must be loaded with LOAD.COM which generates the
  29. machine coding.  The program is then executable after it is
  30. loaded.
  31.  
  32. If the program is written using the DDT.COM it must be saved with
  33. the SAVE.COM.  Simple programs can and should be written with the
  34. DDT utility.  However programs written with the DDT utility will
  35. not have a comment field.  Large programs should be written using
  36. your word processor.  The DDT utility must be used if you do not
  37. have the source or original program listing.
  38.  
  39. The source file for an assembly language is normally divided into
  40. five fields.  Each field is separated by spaces or a tab
  41. character.  The separation of the fields makes for a more
  42. readable source program.  The first field contains program line
  43. numbers.  These line numbers are ignored by the Assembler and is
  44. optional.  The second field contains labels much like the labels
  45. in a Fortran program.  The labels can be 16 characters long (Ed
  46. note: depending on the assembler) and must start with a letter. 
  47. A colon may follow the label.  A label is optional except when it
  48. is used in the operand field.  A label should appear only once in
  49. the label field; however it may appear in the operand field many
  50. times.
  51.  
  52. The third field contains Mnemonics, which is a fancy term for
  53. name and is not optional.  The fourth field is the Operand field
  54. which requires one or more operands, however some Mnemonics do
  55. not require an operand.  This field can be occupied by a label,
  56. constant or an expression.  The fifth column is for Comments and
  57. begins with a semi-colon.  This field is also optional; however,
  58. it is good programming practice to comment your programs.
  59.  
  60. A numerical constant is a fixed number which can be binary,
  61. octal, decimal or hexadecimal.  Dollar signs can be used as
  62. delimiters within the numerical constants.  A string constant is
  63. a series of characters delimited by apostrophe symbols. 
  64. Delimiter is a fancy programming term which means a special
  65. character used to block off a series of characters or numbers,
  66. much like the use of the apostrophe symbols.  Delimiter is a
  67. fancy programming term which means a special character used to
  68. block off a series of characters or numbers, much like the use of
  69. the apostrophe in marking of quotations.
  70.  
  71. Arithmetic and logical operators are also possible.  A single
  72. dollar sign, when used as an operand, causes the current value of
  73. the location counter to be used.
  74.  
  75. Lastly there are the assembler directives.  DB = define byte, DW
  76. = define word and DS = define storage.  These directives
  77. initialize storage areas in memory.  The DB statements are stored
  78. as 8-bit values and the DW statement is stored as 16 bit values. 
  79. The low-order bit is stored first then the high-order bit.  DS is
  80. evaluated and the number of memory locations is reserved.  ORG =
  81. start address of the instructions following.  End = end of source
  82. program.  EQU = assignment of a value to a label.  IF and ENDIF =
  83. conditional branching when IF is true.
  84.  
  85. The assembly language source file must have an .ASM extension. 
  86. Upon completion of the program it must be compiled with the ASSY
  87. compiler.  The correct syntax is "ASSY Filename.shp <cr>".  SHP
  88. breaks down as follows: "S" is the disc drive where the HEX  file
  89. will reside.  "H" and "P" can be substituted with a "Z" to skip
  90. the generation of the files.  "X" can be substituted for the "P"
  91. to send the PRN file to the lineprinter.
  92.  
  93. After entering the ASM command the computer will respond with
  94. CP/M ASSEMBLER - VER 2.0 followed by any error message.  When the
  95. assembler is finished it will return a hexadecimal address of the
  96. first free space following the assembly language program, a use
  97. factor of the symbol table area and an end of assembly message in
  98. the following format.
  99.  
  100. XXXX
  101. yyyH USE FACTOR
  102. END OF ASSEMBLY
  103.  
  104. If errors are encountered they must be corrected and the program
  105. must be recompiled.
  106.  
  107. Upon successful compilation, the program must then be loaded with
  108. the LOAD command.  The correct syntax is A>LOAD B:PROGRAM<CR> 
  109. The computer will respond with 
  110.  
  111.    FIRST ADDRESS       0100
  112.    LAST ADDRESS        0345
  113.    BYTES READ          0244
  114.    RECORDS WRITTEN       02
  115.  
  116. If the load was successful the Program can now be executed.
  117.