home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 242 / 242.d81 / t.bbi < prev    next >
Text File  |  2022-08-26  |  6KB  |  205 lines

  1. u
  2.              B A S S E M
  3.        Fernando Buelna Sanchez
  4.         from Compute! Gazette
  5.             April/May 1990
  6.  
  7.  
  8.     BASSEM is a two-pass assembler
  9. that contains many features and
  10. commands normally found only on
  11. commercial assemblers.
  12.  
  13.     Moreover, BASSEM's most powerful
  14. feature is its ability to work as an
  15. extension of the C64's operating
  16. system. To the commands of BASIC 2.0,
  17. BASSEM adds assembly commands, disk
  18. commands, editing commands, and 6502
  19. machine language instructions.
  20.  
  21. Because it runs within the BASIC
  22. environment, you can use the built-in
  23. screen editor to enter and edit your
  24. programs. And, you can use BASIC's
  25. commands to control how your programs
  26. assemble. For example, you can use
  27. IF-THEN statements for conditional
  28. assembly or FOR-NEXT loops to generate
  29. tables.
  30.  
  31.  
  32. USING THE ASSEMBLER
  33.  
  34.     You will obviously want to copy
  35. BASSEM to its own disk. Boot up
  36. B.BASSEM. The screen will clear and
  37. present a BASSEM opening screen. Now
  38. you are ready to create a machine
  39. language program by entering the
  40. source code. With BASSEM, this is done
  41. using the familiar BASIC screen
  42. editor. You simply enter each line of
  43. code with a line number as you would a
  44. BASIC program.
  45.  
  46.     For example, the source code for a
  47. simple program to change the screen
  48. border color to cyan might look like
  49. this:
  50.  
  51.  10 WRT 1:SET $A000,$B000:BAS $C000
  52.  20 PASS 1:'BEGIN ASSEMBLY
  53.  30 _BORDER = $D020
  54.  40 _COLOR = 3:'CYAN
  55.  50 _START LDA#_COLOR:STA_BORDER:RTS
  56.  55 _DONE
  57.  60 PASS2:'END ASSEMBLY
  58.  
  59.     In line 10, the WRT command tells
  60. BASSEM to write the machine language
  61. to memory, the SET command establishes
  62. the label buffer, and the BAS command
  63. sets the starting address for the
  64. program. (If you don't understand
  65. what's going on, don't worry; we'll
  66. discuss each of these in more detail
  67. later.)
  68.  
  69.     The PASS 1 command in line 20
  70. tells the assembler that the following
  71. lines should be assembled. BASSEM
  72. continues assembling commands until it
  73. encounters a PASS 2 command (line 60).
  74. As you might have guessed, the text
  75. immediately following the PASS 1
  76. command is a comment; BASSEM treats
  77. the <'> as a REM statement.
  78.  
  79.     Lines 30 and 40 assign values to
  80. the labels BORDER and COLOR. BASSEM
  81. labels are always preceded by a <BACK
  82. ARROW> and can be up to 40 characters
  83. long. They can contain letters of the
  84. alphabet, numerical digits, and the
  85. decimal point. They may also contain
  86. BASIC keywords and reserved variables.
  87. Some examples of valid labels are:
  88.  
  89.     _THIS.IS.A.LABEL
  90.     _PRINTOUT
  91.     _3RD.JMP
  92.  
  93.     As you can see in lines 30 and 40,
  94. you can assign a value to a label
  95. using the assignment <=> character.
  96. When defining labels this way, you can
  97. use hexadecimal, octal, binary, or
  98. decimal constants or expressions.
  99. Hexadecimal values must be preceded by
  100. a <$>; octal valuse by an <&>; and
  101. binary valuse by a <%>. Decimal valuse
  102. are the default and require no prefix.
  103.  
  104.     When you use an expression to
  105. define a label, you must abide by a
  106. few rules. First, with one exception,
  107. the expression must be a valid BASIC
  108. expression. The exception is that you
  109. can use hexadecimal, octal, and binary
  110. constants in the expression. Second,
  111. BASEM must be able to evaluate the
  112. expression during assembly. For
  113. example, the expression cannot be
  114. based on the value of the accumulator,
  115. because BASSEM has no way of knowing
  116. what will be in the accumulator when
  117. the program is executed.
  118.  
  119.     The other way to give a label a
  120. value is to place it in front of a
  121. 6502 mnemonic or on a line of its own.
  122. Line 50 contains an example of this
  123. method. Labels used this way take on
  124. the value of the program counter. This
  125. value corresponds to the address of
  126. the instruction. For example, in line
  127. 50, the LDA instruction is at location
  128. $C000 (49152), so the label _START has
  129. a value of 49152. The value of _DONE
  130. is 49158.
  131.  
  132.     Line 50 demonstrates one more
  133. feature of BASSEM -- you're not
  134. limited to one instruction per line.
  135. You can fill an entire logical line
  136. (two screen lines) with instructions
  137. and labels. Simply separate the
  138. instruction with colons, just like you
  139. would in BASIC.
  140.  
  141.     After you've entered the source
  142. code for your program, be sure to save
  143. it before you continue. Since BASSEM
  144. operates in the BASIC environment, you
  145. can save your source files just as yo
  146. would a BASIC program.
  147.  
  148.  
  149. [LOADSTAR EXTRA]
  150.  
  151.     To make life simpler for you and
  152. me (especially me), I have included a
  153. file called SHELL.BC on this disk.
  154. SHELL.BC contains all the stuff
  155. normally needed when setting up BASSEM
  156. source code. After booting BASSEM and
  157. loading SHELL.BC, list line 60008, and
  158. edit it to assign N$ with the name of
  159. your program:
  160.  
  161.     60008 N$ = "MYPROG"
  162.  
  163. Then, in immediate mode, type and
  164. <RETURN>:
  165.  
  166.     GOTO60000
  167.  
  168. This command will save the source code
  169. as
  170.  
  171.     MYPROG.BC
  172.  
  173. with .BC indicating Bassem Code.
  174. Now you can write your ML code,
  175. beginning with line 50. Several other
  176. conveniences are included in SHELL.BC.
  177. We will discuss them later.
  178.  
  179.  
  180. NEXT STEP
  181.  
  182.     The next step is to assemble your
  183. program. This is extremely easy. Type
  184. and <RETURN> RUN. If you are using
  185. SHELL, you can assemble to Memory (to
  186. the address displayed) by pressing
  187. <1>, or to Disk (with the load address
  188. displayed) by pressing 2. (Note:
  189. BASSEM has a minor bug. Once you
  190. assemble to Disk, further assemblies
  191. send garbage to the screen. So SAVE
  192. OFTEN! with GOTO60000. And after a
  193. Disk assembly, reboot BASSEM and
  194. reload your source code (.BC).
  195.  
  196.  
  197. ----------
  198. We have just started! BASSEM is
  199. extremely powerful, with many, many
  200. very useful features. Take a look at
  201. the next file!
  202.  
  203.  DMM
  204.  
  205.  
  206.