home *** CD-ROM | disk | FTP | other *** search
- u
- B A S S E M
- Fernando Buelna Sanchez
- from Compute! Gazette
- April/May 1990
-
-
- BASSEM is a two-pass assembler
- that contains many features and
- commands normally found only on
- commercial assemblers.
-
- Moreover, BASSEM's most powerful
- feature is its ability to work as an
- extension of the C64's operating
- system. To the commands of BASIC 2.0,
- BASSEM adds assembly commands, disk
- commands, editing commands, and 6502
- machine language instructions.
-
- Because it runs within the BASIC
- environment, you can use the built-in
- screen editor to enter and edit your
- programs. And, you can use BASIC's
- commands to control how your programs
- assemble. For example, you can use
- IF-THEN statements for conditional
- assembly or FOR-NEXT loops to generate
- tables.
-
-
- USING THE ASSEMBLER
-
- You will obviously want to copy
- BASSEM to its own disk. Boot up
- B.BASSEM. The screen will clear and
- present a BASSEM opening screen. Now
- you are ready to create a machine
- language program by entering the
- source code. With BASSEM, this is done
- using the familiar BASIC screen
- editor. You simply enter each line of
- code with a line number as you would a
- BASIC program.
-
- For example, the source code for a
- simple program to change the screen
- border color to cyan might look like
- this:
-
- 10 WRT 1:SET $A000,$B000:BAS $C000
- 20 PASS 1:'BEGIN ASSEMBLY
- 30 _BORDER = $D020
- 40 _COLOR = 3:'CYAN
- 50 _START LDA#_COLOR:STA_BORDER:RTS
- 55 _DONE
- 60 PASS2:'END ASSEMBLY
-
- In line 10, the WRT command tells
- BASSEM to write the machine language
- to memory, the SET command establishes
- the label buffer, and the BAS command
- sets the starting address for the
- program. (If you don't understand
- what's going on, don't worry; we'll
- discuss each of these in more detail
- later.)
-
- The PASS 1 command in line 20
- tells the assembler that the following
- lines should be assembled. BASSEM
- continues assembling commands until it
- encounters a PASS 2 command (line 60).
- As you might have guessed, the text
- immediately following the PASS 1
- command is a comment; BASSEM treats
- the <'> as a REM statement.
-
- Lines 30 and 40 assign values to
- the labels BORDER and COLOR. BASSEM
- labels are always preceded by a <BACK
- ARROW> and can be up to 40 characters
- long. They can contain letters of the
- alphabet, numerical digits, and the
- decimal point. They may also contain
- BASIC keywords and reserved variables.
- Some examples of valid labels are:
-
- _THIS.IS.A.LABEL
- _PRINTOUT
- _3RD.JMP
-
- As you can see in lines 30 and 40,
- you can assign a value to a label
- using the assignment <=> character.
- When defining labels this way, you can
- use hexadecimal, octal, binary, or
- decimal constants or expressions.
- Hexadecimal values must be preceded by
- a <$>; octal valuse by an <&>; and
- binary valuse by a <%>. Decimal valuse
- are the default and require no prefix.
-
- When you use an expression to
- define a label, you must abide by a
- few rules. First, with one exception,
- the expression must be a valid BASIC
- expression. The exception is that you
- can use hexadecimal, octal, and binary
- constants in the expression. Second,
- BASEM must be able to evaluate the
- expression during assembly. For
- example, the expression cannot be
- based on the value of the accumulator,
- because BASSEM has no way of knowing
- what will be in the accumulator when
- the program is executed.
-
- The other way to give a label a
- value is to place it in front of a
- 6502 mnemonic or on a line of its own.
- Line 50 contains an example of this
- method. Labels used this way take on
- the value of the program counter. This
- value corresponds to the address of
- the instruction. For example, in line
- 50, the LDA instruction is at location
- $C000 (49152), so the label _START has
- a value of 49152. The value of _DONE
- is 49158.
-
- Line 50 demonstrates one more
- feature of BASSEM -- you're not
- limited to one instruction per line.
- You can fill an entire logical line
- (two screen lines) with instructions
- and labels. Simply separate the
- instruction with colons, just like you
- would in BASIC.
-
- After you've entered the source
- code for your program, be sure to save
- it before you continue. Since BASSEM
- operates in the BASIC environment, you
- can save your source files just as yo
- would a BASIC program.
-
-
- [LOADSTAR EXTRA]
-
- To make life simpler for you and
- me (especially me), I have included a
- file called SHELL.BC on this disk.
- SHELL.BC contains all the stuff
- normally needed when setting up BASSEM
- source code. After booting BASSEM and
- loading SHELL.BC, list line 60008, and
- edit it to assign N$ with the name of
- your program:
-
- 60008 N$ = "MYPROG"
-
- Then, in immediate mode, type and
- <RETURN>:
-
- GOTO60000
-
- This command will save the source code
- as
-
- MYPROG.BC
-
- with .BC indicating Bassem Code.
- Now you can write your ML code,
- beginning with line 50. Several other
- conveniences are included in SHELL.BC.
- We will discuss them later.
-
-
- NEXT STEP
-
- The next step is to assemble your
- program. This is extremely easy. Type
- and <RETURN> RUN. If you are using
- SHELL, you can assemble to Memory (to
- the address displayed) by pressing
- <1>, or to Disk (with the load address
- displayed) by pressing 2. (Note:
- BASSEM has a minor bug. Once you
- assemble to Disk, further assemblies
- send garbage to the screen. So SAVE
- OFTEN! with GOTO60000. And after a
- Disk assembly, reboot BASSEM and
- reload your source code (.BC).
-
-
- ----------
- We have just started! BASSEM is
- extremely powerful, with many, many
- very useful features. Take a look at
- the next file!
-
- DMM
-
-
-