home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 242
/
242.d81
/
t.bbii
< prev
next >
Wrap
Text File
|
2022-08-26
|
7KB
|
289 lines
u
BASSEM
Part II
MNEMONICS AND PSEUDO-OPS
BASSEM supports all 6502
addressing modes and instructions as
shown in the [COMMODORE 64 Program-
mer's Reference Guide]. In addition,
it supports several pseudo-ops which
tell the assembler on how to generate
code. The following paragraphs
summarize the pseudo-ops that you will
need to know to start using BASSEM,
including the ones demonstrated in the
example above. In each description,
optional parameters are indicated by
pointy brackets and repeating
parameters are represented by
ellipses. When only one of several
choices are allowed, the parameters
are surrounded by parentheses and
separated by a </>.
BAS address
Sets the program counter (PC) to a
specified address. The BAS command
is usually used to define the starting
address for the program. The [address]
parameter must be a value between 0
and 65535. If you don't set a starting
address, BASSEM assumes a default
value of $C000 (49152).
BUF number of bytes <,byte>...
Reserves space for the specified
number of bytes. The first parameter
is required and tells BASSEM how many
bytes of memory to reserve within the
object code. Legal values range from 1
to 65535. Optionally, BUF may be
followed by byte values which
determine how the reserved space is
filled.
If BUF is followed by only the
first parameter, the number of memory
locations specified by the value is
filled with 0's. Otherwise, it is
filled with the pattern established by
the given values. For example, if you
enter the command
BUF 8,2,2,3 -
BASSEM will write
2,2,3,2,2,3,2,2
to the object file. Legal values for
the fill-byte parameters are between 0
and 255.
BYT (number/strng)<,(number/strng)>...
Places the specified byte(s) or
string(s) into the object file. If you
specify a number or numerical
expression, BASSEM places the value
into the object file. Legal values
range from 0 to 255. If you specify a
string, BASSEM places each character
of the string into a byte. You can
specify multiple byte values or
strings with one BYT command by
separating each with a comma.
1001 BYT"COM,X,Y",0,1,"end",0
PASS (1/2)
Tells the assembler where to begin
and end assembly. Assembly begins with
the PASS 1 command. You must place the
PASS 1 command just before the first
label definition or machine language
instruction to be assembled.
The PASS 2 command indicates the
end of the program and must be placed
just after the last label definition
or machine language instruction.
SET start label addr, end label addr
Specifies the location of the
label buffer. The SET command is used
to define the buffer where BASSEM
stores labels as it assembles. The
first argument sets the beginning of
the buffer, and the second argument
sets the end. If you don't specify a
location for the label buffer,
BASSEM places it under BASIC ROM
($A000-$BFFF). When defining the label
buffer, be sure to use an area of
memory that won't conflict with BASIC,
BASSEM, or your object code (if you
are writing it to memory). In general,
it is best to use areas above $A000.
WRT (0/1)
Specifies whether or not the
object code should be written to
memory. If WRT is 0, the assembler
will [not] write the code to memory.
If the parameter is 1, BASSEM writes
the code to memory. The WRT command is
useful when you don't want to place
the code in memory but need to check
the systax of your program or assemble
it to disk.
WOR number<,number>...
Places the specified number(s)
into the object code in low-byte/high-
byte format. Legal values for numbers
range from 0 to 65535. You can specify
multiple values with one WOR command
by separating them with commas.
FLP number<,number>...
Places the specified number(s)
into the object file in five-byte
floating-point format. Legal values
for numbers range from -1E38 to 1E38.
As with the BYT and WOR commands, you
can specify multiple values with one
FLP command by separating them with
commas.
OPZ (0/1)<,number>
Tells the assembler how to
assemble zero-page addressing modes
for those instructions whih support
it. Setting the first parameter to 1
tells BASSEM to use zero-page
addressing whenever possible. (This is
the way most assemblers handle zero-
page addressing.) Setting it to 0
tells BASSEM to use absolute
addressing mode.
If, for example, you enter the
commands:
250 OPZ 1: LDA #C6
in your source file, the assembler
generates the values
$A5 $C6.
If you change the zero-page command to
OPZ 0,
$AD $C6 $00
will be generated.
The first example is in zero-page
addressing mode, and the second is in
absolute addressing mode. Zero-page
addressing is both shorter and faster,
but in some applications where timing
is critical, you may want to use
absolute addressing instead.
If you're not careful, setting OPZ
incorrectly can cause errors during
assembly. One such case occurs when
you attempt to assemble an instruction
which supports X- or Y-indexed, zero-
page addressing mode but doesn't
support its equivalent absolute
addressing mode. If you try to
assemble
250 OPZ 0:STX$61,Y
BASSEM will stop assembling with a
SYNTAX ERROR message. The error is
flagged as a syntax error because the
assembler does not expect the comma
before the Y.
A 6502 instruction generally has
one of two types of arguments: address
and data, or value. The second
parameter of the OPZ instruction
determines which messages BASSEM
prints when an instruction's argument
is 0. If OPZ's second parameter is set
to 0, no messages are issued; if it is
1, BASSEM prints a warning when it
encounters a 0 address; if the
parameter is 2, the assembler issues a
warning upon encountering a 0 data
value; and if it is 3, it prints
warning for both types of 0 arguments.
[LOADSTAR NOTE:] Using SHELL.BC as the
beginning template for your own
program takes care of most of these
controls for you.
In SHELL.BC, line 1 you can assign the
beginning address for assembly to
Memory (MM= address) and Disk (DD=
address). Line 10 SETs label memory
for you.
When you RUN the assembler, lines 6-7
puts your choice of mode in Z. In
lines 20-32, if you chose Disk, the
name of your program is fetched, has
".ML" appended, is scratched, and is
opened for writing by the assembler.
If you chose Memory, all that is
skipped, and the WRT 1 in line 22
sends the assembly to memory.
We have added two other features:
BASSEM does not recognize immediate
loads of lo or hi address bytes:
LDA#<ADDR
LDX#>ADDR
So SHELL.BC includes BASIC FN
definitions in lines 41-42 to do the
job:
DEF FNH(X)=INT(X/256)
DEF FNL(X)=X-FNH(X)*256
In the body of your code, you can then
use
LDA#FNL(ADDR)
LDX#FNH(ADDR)
We have also included FNI(address),
which is very useful in debugging.
FNI(251) returns the two byte value in
251/252.
The last feature is a ready-written
hard-copy LIST print routine at line
61000. Set the LIST parameters in line
61002, then GOTO61000. The listing is
sent to Device 4.
----------------
There's MORE! Continued with Part III
DMM