📄 manual.txt
字号:
User's Manual
SBasic68k Compiler Version 3.4
by
Karl E. Lunt
Copyright (c) 1996, 1998, 1999, 2000, 2001 Bothell, WA
All rights reserved
April 8, 2001
DISCLAIMER
I am releasing the executable for the SBasic68k (SB68k)
compiler, all supporting library and include files, assorted
test cases, and this document as freeware. Feel free to use
SBasic68k for whatever non-commercial application seems
appropriate.
The SBasic68k compiler, with or without its attendant
support files, is freeware and in the public domain. You
may not charge for the sale or distribution of SBasic68k or
its distribution files. If you distribute SBasic68k to
others, please include this manual in its present form,
complete with this disclaimer.
I make no warranty, representation, or guarantee regarding
the suitability of SBasic68k for any particular purpose, nor
do I assume any liability arising out of the application or
use of SBasic68k, and I disclaim any and all liability,
including without limitation consequential or incidental
damages.
You, as the user, take all responsibility for direct and/or
consequential damages of any kind that might arise from
using SBasic68k in any fashion.
I do not warrant that SBasic68k is free of bugs. If you
find what you think is a bug, kindly let me know what it is
IN DETAIL, and I'll certainly consider fixing it in a later
release, if there ever is such.
I developed SBasic68k as a tool for working with the
Motorola 68xxx family of MCUs. If you use SBasic68k for
developing robotics (or other) application code and find it
useful, fine. If you don't find it suitable in some
fashion, then don't use it.
DISCLAIMER
Karl Lunt
116 173rd St., SW
Bothell, WA 98012
Page 2
Introduction
This manual describes the use of the SBasic68k (SB68k)
compiler. SB68k is a PC-based cross-compiler for a subset
of the Basic language. Source files containing SB68k
statements are compiled into a source file of assembly
language for the target machine. Subsequent assembly of
that file yields an exectuable file for the target machine.
SB68k creates code for a 68xxx target. The compiler's
output is compatible with the Motorola as32 assembler,
available on the Motorola web site or from my own web site
at: http://www.seanet.com/~karllunt.
The SBasic68k compiler was written in Borland C (version
4.52), and is compiled as a 32-bit DOS standard app. My
SB68k design is loosely based on a small Basic interpreter
developed by Herbert Schildt and presented in his excellent
book, "The Art of C." (Osborne McGraw-Hill, Berkeley, CA
94710; ISBN 0-07-881691-2)
Page 3
History of SBasic68k
Version 3.4 fixed what I hope is the last bug in the
comparison code, again spotted by Doug Kelly of the SRS.
The error occurred when comparing the result of a math
operation on two variables with a constant. I also noticed
that version 3.3 was incorrectly printing out version 3.2 in
the header of the listing file; this version now prints out
version 3.4.
Version 3.3 fixed a few bugs reported by Doug Kelly of the
Seattle Robotics Society. The copy library was not being
included when invoked, and the library code had an error in
it. Also fixed an obscure error when adding two literals on
one side of a test.
Version 3.2 fixed a bug in the 2D array index calculations.
It also includes updated library files minmx68k.lib and
inkey68k.lib, both contributed by Doug Kelly of the SRS.
Version 3.1 fixed a number of bugs in the 3.0 release. My
thanks to Doug Kelly of the SRS for his determined efforts
in using the original release, and in helping me weed out
these bugs.
Version 3.0 was adapted from the 68hc11 SB68k compiler,
version 2.7; this is the baseline release of the 68k
version.
Besides reworking the code generator to support 68000
assembler output, I also added a number of features. The
biggest change is with variable size; all SB68k variables
and arrays use 32-bit integers, rather than the 16-bit
integers in the 68hc11 version.
I added word-sized (16-bit) versions of several statements
and functions, including POKEW and PEEKW. I also added
support for 2-dimension arrays.
I included shift and roll functions similar to RROLL() and
LSHFT() that work on bytes, rather than bits. These
functions, with names such as RROLLB(), will speed up byte
manipulations during I/O.
Page 4
Invocation
You execute SB68k by entering the command:
sb68k infile <options>
where 'infile' contains the path to the source file you wish
to compile. SB68k writes its output, the assembly language
source for the target, to the standard output, which is
normally the screen.
You can redirect the output file to another file by entering
the command:
sb68k infile <options> >outfile
where 'outfile' is the path to an output file to hold the
created source lines. This file should carry a .asm
extension, as that is expected by the as32 assembler used
with SB68k.
If SB68k did not detect any errors in your source file, its
output file should assemble correctly with the as32
assembler. If SB68k detected errors, it inserts error
notices in the output file. These are almost guaranteed to
generate numerous errors if the resulting output file is
assembled.
SB68k supports several command-line options, used to control
the addresses of key elements in the final program. These
options will be explained in detail below.
Upon completion, SB68k returns an errorlevel that can be
used to determine success or failure of the compilation. If
SB68k successfully compiled the source program, it returns
an errorlevel of 0. If SB68k detected one or more errors
during compilation, it returns an errorlevel of 1.
Page 5
Command-line options
You can control the placement of variables, code space, and
stack space in the target executable by means of SB68k
command-line options. If you supply any options in your
command line, they must follow the name of the SB68k source
file. Refer to the above section on executing SB68k.
You can control where SB68k places the start of its RAM
variables by using the /v option. The format of this option
is:
/vxxxxxxxx
where xxxxxxxx is an eight-digit hexadecimal address that
marks the start of the variable space. SB68k assigns this
address to the assembler label VARBEG; if you do not use the
/v option, SB68k assigns a default value of $3000 to VARBEG.
You can control where SB68k places the beginning of the
executable code by using the /c option. The format of this
option is:
/cxxxxxxxx
where xxxxxxxx is an eight-digit hexadecimal address that
marks the start of the code space. SB68k assigns this
address to the assembler label CODEBEG; if you do not use
the /c option, SB68k assigns a default value of $5000 to
CODEBEG.
You can control where SB68k places the top of the target's
stack space by using the /s option. The format of this
option is:
/sxxxxxxxx
where xxxxxxxx is an eight-digit hexadecimal address that
marks the top of the stack space. SB68k assigns this
address to the assembler label STKBEG; if you do not use the
/s option, SB68k assigns a default value of $4ff0 to STKBEG.
You can control the type of branch instruction SB68k creates
by using the /b option. The format of this option is:
/b
SB68k normally converts a transfer or jump instruction into
two assembly language source lines. The first line is a
relative branch around the next line, and the second line is
a long jump to the target address. For example:
while n=3
' other code goes here
Page 6
wend
contains a branch instruction that tests the value of
variable N and branches back to the WHILE statement if N
equals 3.
SB68k normally generates code similar to:
whl000
moveq.l #$3,d0
cmp.l var003(a5),d0
beq *+8 if equal, branch
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -