[net.sources] TI 99 assembler, documentation

lee@unmvax.UUCP (07/22/84)

  To unarchive, remove the first line through and
 including the dashed line. Then type:

   % sh <thisfilename>
Don't forget to strip off the .signature at the end!
-------------------------------------------
: Run this with sh NOT csh!
echo extracting Makefile
cat << //*FUNKYSTUFF*// > Makefile
TROFF= itroff
NROFF= nroff
PACKAGE= -ms
SRC= body.t a.t b.t c.t

troff:	\$(SRC)
	tbl \$(SRC) | \$(TROFF) \$(PACKAGE)

nroff: \$(SRC)
	tbl \$(SRC) | \$(NROFF) \$(PACKAGE) | col
//*FUNKYSTUFF*//
echo extracting a.t
cat << //*FUNKYSTUFF*// > a.t
.CT
APPENDIX A, escaped codes
.PP
In the following table the character in column one is escaped with
a backslash ('\\\\') in order to produce the correct code.
.TS
allbox;
c c s s s
c c c c c
n n n n n.
character	ASCII number
	octal	hex	decimal	meaning
a	141	61	97
b	10	8	8
c	143	63	99
d	144	64	100
e	145	65	101
f	14	c	12
g	147	67	103
h	150	68	104
i	151	69	105
j	152	6a	106
k	153	6b	107
l	154	6c	108
m	155	6d	109
n	12	a	10	line-feed
o	157	6f	111
p	160	70	112
q	161	71	113
.TE
.bp
.TS
allbox;
c c s s s
c c c c c
n n n n n.
character	ASCII number
	octal	hex	decimal	meaning
r	15	d	13	carriage return
s	163	73	115
t	11	9	9	tab
u	165	75	117
v	13	b	11
w	167	77	119
x	170	78	120
y	171	79	121
z	172	7a	122
.TE
//*FUNKYSTUFF*//
echo extracting b.t
cat << //*FUNKYSTUFF*// > b.t
.CT
APPENDIX B, "standard" assembler sample program.
.PP
This example program reads an integer from the terminal attached
to the micro and stores the value in r1.
.LD
;		Read an Integer from the Terminal
;
;	This program reads the decimal representation of a signed
;	integer in its character representation from the terminal
;	and stores its value (in 2's complement representation)
;	in R1.  If the values cannot be stored in 16 bits using
;	2's complement representation, an error message is written
;	to the terminal.
;
;
;	CONSTANTS
MS	EQU	>2D;	ASCII '-'
PS	EQU	>2B;	ASCII '+'
D0	EQU	>30;	ASCII '0'
D9	EQU	>39;	ASCII '9'
;
;
;	Initialize R0, R1, R2 and R15.
	CLR	R0;	R0 and R1 are used for multiplication
	CLR	R1;
	LI	R2,10;
	CLR	R15;
;
;
;	Read the first character.
	XOP	R3,11;
	SWPB	R3;	Put character into low byte of R3.
	CI	R3,MS;
	JNE	L1;
		INC	R15;	Set a flag.
		JMP	LP;
L1	EQU	$
	CI	R3,PS;
	JNE	CK;	Jump into the main loop (sick!)
;
;
;	Main loop--read a character, check it and update the value in R1.
LP	EQU	$
		XOP	R3,11;
		SWPB	R3;
;		Check for a valid character.
CK		CI	R3,D0;
		JLT	DN;
		CI	R3,D9;
		JGT	DN;
;		Update R1.
		AI	R3,-D0;
		MOV	R1,R0;
		MPY	R2,R0;
		MOV	R0,R0;
		JNE	OV;
		MOV	R1,R1;
		JLT	OV;
		A	R3,R1;
		CI	R1,>8000;
	JEQ	LP;
	JNO	LP;
;
;
;	Overflow.
OV	EQU	\$;
	XOP	@ER,14;
	JMP	RT;
;
;
;	Done.  We need to check for the minint case.  Then we
;	check for a negative value.
DN	EQU	\$;
	CI	R1,>8000;
	JNE	OK;
	MOV	R15,R15;
	JEQ	OV;
	JMP	RT;
OK	EQU	\$;
	MOV	R15,R15;
	JEQ	RT;
	NEG	R1;
RT	B	@>3000;
;
;
;	DATA
ER	TEXT	'OVERFLOW'
.DE
//*FUNKYSTUFF*//
echo extracting body.t
cat << //*FUNKYSTUFF*// > body.t
.TM
.TL
tiasm - An alternative assembler for the TI990/U89
.AU
Lee Ward
.AI
University of New Mexico at Albuquerque
.AB
Tiasm is meant as an alternative to the assembler provided on the
Texas Instruments Corporation's TM990/U89 educational board. It runs under
.UX
and provides facilities commonly associated with much larger assemblers
while attempting to maintain as much consistency as possible with the assembler
provided on the above mentioned board.
.AE
.SH
INTRODUCTION
.PP
This paper is not a tuorial on the tiasm assembler but is instead meant to
enlighten the user as to the differences between the assembler provided
on the TI990/U89 board running the UNIBUG monitor (henceforth referred
to as "the standard assembler") and tiasm. If you have not already read about
or used the standard assembler it is highly recommended that you read
the
.UL TM990
.UL users
.UL guide,
chapter number 4.
Tiasm is an attempt to extend and modify the standard assembler
rather than replace it. Therefore, comparisons and contrasts will
be drawn rather than a complete guide to the instructions and
possible use of them given.
.PP
Very briefly, the facilities tiasm
supplies beyond the standard assembler are:
.ID
1)	A macro preproccessor
2)	A more consistent approach to addressing mode syntax.
3)	Many more specific directives including one for strings.
4)	Support of seperate assembly with resolution at link time.
5)	The ability to catch syntax errors before downloading.
.DE

.SH
SYNTAX AND PARSING
.PP
The general format of the symbolic instructions along
with their names are as given in the users guide. Case distinction in labels,
operands and directives is recognized. Only the mnemonic instruction names
.UL must
be capitolized. just as in the standard assmebler. White space is considered
to be a space, tab or blank
line. Comments remain as any number of alphanumeric characters up to
and including the newline character that follow a semi-colon.
.PP
It is no longer necessary to equate character literals. It is sufficient
to merely surround them with forward ticks (apostrophes).
The radix
of any numeric literals may be deferred from the default radix of 10 to:
.ID
base 2	by preceding the number with 0B or 0b
base 8	by preceding the number with 0O or 0o
base 16	by preceding the number with 0X or 0x
base 10	by preceding the number with 0D or 0d
.DE
For example the instruction:
.ID
	CI	R1,>8000
.DE
in the standard assembler becomes:
.ID
	CI	R1,0x8000
.DE
in tiasm. Arithmetic negation may be used on any literal. The minus
sign signifies this. The plus sign is also recognized but is redundant.
.PP
Labels may now be defined without equating them to the location counter.
This may be done by following any previously undefined identifier
with a colon. To reference these labels the preceding at sign ('@') is
no longer be used. It must be omitted entirely or be part of the symbol name.
Valid identifiers are recognized to be unbroken strings of alphanumeric
characters belonging to the following set; [a-z, A-Z, -, _, 0-9]. Identifiers
may not start with '-' or numbers.
.PP
The greatest difficulty in porting any source code to be assembled
by tiasm will lie in the fact that the syntactical specifications for
the addressing modes has been extremely modified. There are two sample
programs in the appendices that accomplish the same task. One is
written to conform to the syntax of the standard assembler and the
other is a port of same to tiasm. These provide decent examples of
some of the addressing modes provided. What follows here is a list of
addressing modes and their syntax in both the standard assembler
and tiasm.
.TS
allbox;
ccc
nnn.
mode	standard	tiasm
Direct	reg	reg
Indirect	*reg	(reg)
Indirect, auto	*reg+	(reg)+
Symbolic	@symb	symb
Indexed symbolic	@symb(reg)	symb[reg]
Immediate	literal	literal
PC relative	$[+/-num]	$[+/-num]
.TE

.SH
DIRECTIVES
.PP
There are currently four directives supplied in tiasm. The first is
used to specify that a given identifier is defined external to the module
being assembled now. This facility is meant to allow seperate assembly.
The directive takes the form:
.br
 .extern	symbol
.br
Where "symbol" is any valid identifier name.
.PP
The next directive is used to specify that one (or more) word(s) are
to be reserved beginning at tiasm's idea of the current location. It takes
the form:
.br
 .word	[number]
.br
Without the number one word is reserved.
.PP
There is a data directive. What it does is allow the programmer to
have initialized data placed into memory. This data is not write
protected so it may be used as an initialized global variable
if you like. The data directive reserves one word no matter what form
the data takes.  The data directive takes the form:
.br
 .data	data
.br
The only limitation on the data type is that it may not be a string.
One type that may be placed here is symbol. At link time, when
the modules adresses become absolute, the address of the identifier
will be placed here. This could be useful for example in keeping an indexed
table of functions.
.PP
Initialized ASCIZ (ASCII zero terminated) data may be specified by use
of the string directive. It takes the form:
.br
 .string	"ASCII string"
.br
If the string is too long to fit on one line a backslash ('\\\\<RETURN>') may
be used to continue to the next line. There are some special operators
that may be placed in the string that have some meaning. An escaped
(preceded by a backslash) quote mark allows a quote to be inserted in the
string. In addition to this escaped character there are many others
that generate ASCII codes. A complete table of these may be found in the
appendices. The whole scheme with string literals is very
.B 'C'
like.

.SH
THE MACRO PREPROCCESSOR
.PP
The macro preprocessor, unfortunately, is a very touchy subject. It was
decided in the design phase to take advantage of the facilities of
.UX
for this phase of assembly.
.UX
provides two, very fine, macro preprocessors. One is known as
.B m4
and the other as
.B cpp.
The first is a bit easier to use and provides very elegant features as
well as encouraging good style in writing and using macros. The second,
while not as nice, is the one utilized by the
.B C
compiler under
.UX
and is quite well known. It has the advantage of being able to tell
the assembler what line an included file the assembler is currently
parsing. This allows the assembler to generate error messages for the
included file as well as the file that included it. The
.B m4
preprocessor does not have this capability and will force the line numbers
in any error messages given to be off.
Both allow the inclusion of files, macros and aliases (the EQUATE directive
in the standard assembler is an alias). Which one is in use at a given
site should be specified in the manual pages.
.SH
ERROR MESSAGES
.PP
Currently the error detection scheme is primitive. Most errors
will generate two messages. The first is an attempt to qualify the
second which is almost always;
.br
"Syntax error".
.br
These error messages are meant to be self-explanatory.
Occasionally an error message of the form:
.br
Internal error: message
.br
may be generated. This is meant for the person maintaining the package
and should be duely reported to him/her.
.SH
PROBLEMS, SOLUTIONS AND THE WISHLIST
.PP
Currently there is no directive that will allow the relocation
counter to become absolute. This
.I must
be remedied to allow the interrupt vectors to be set with ease.
The work-around for this is to write a module with nothing but
data and word directives. Initialize the vectors using the data
directive and skip over unused ones with the word directive. Be warned though,
the word directive inserts garbage into the location. Load this
module first at the address corresponding to the first vector location
to overwrite (this doesn't apply if a word directive was first).
The next load module would be the one containing the code and goes
wherever.
.PP
The word directive is handled by the assembler proper. This increases
the object modules size in an unnecessary way. It should be modified
so that the loader merely resets the current load address in the
micro effectively skipping over the reserved space.
.PP
The error messages should be cleaned up. Currently, only the
most primitive form of management is used in the parser. This
was to take advantages of
.B YACC's
ability to recover from errors. It is more important to recover
from lexical errors than print pretty error messages. The remedy
for this is rather involved but definately worth investigation.
//*FUNKYSTUFF*//
echo extracting c.t
cat << //*FUNKYSTUFF*// > c.t
.bp
.CT
APPENDIX C, tiasm assembler sample program.
.PP
This is the same program as given in appendix b. The binary, when
down loaded to the micro will be identical.
.LD
;               Read an Integer from the Terminal
;
;       This program reads the decimal representation of a signed
;       integer in its character representation from the terminal
;       and stores its value (in 2's complement representation)
;       in R1.  If the values cannot be stored in 16 bits using
;       2's complement representation, an error message is written
;       to the terminal.
;
;
;       Initialize R0, R1, R2 and R15.
        CLR     R0;     R0 and R1 are used for multiplication
        CLR     R1;
        LI      R2,10;
        CLR     R15;
;
;
;       Read the first character.
        XOP     R3,11;
        SWPB    R3;     Put character into low byte of R3.
        CI      R3,'-';
        JNE     L1;
                INC     R15;    Set a flag.
                JMP     LP;
L1:
        CI      R3,'+';
        JNE     CK;     Jump into the main loop (sick!)
;
;
;       Main loop--read a character, check it and update the value in R1.
LP:
                XOP     R3,11;
                SWPB    R3;
;               Check for a valid character.
CK:             CI      R3,'0';
                JLT     DN;
                CI      R3,'9';
                JGT     DN;
;               Update R1.
                AI      R3,-'0';
                MOV     R1,R0;
                MPY     R2,R0;
                MOV     R0,R0;
                JNE     OV;
                MOV     R1,R1;
                JLT     OV;
                A       R3,R1;
                CI      R1,0x8000;
        JEQ     LP;
        JNO     LP;
;
;
;       Overflow.
OV:
        XOP     ER,14;
        JMP     RT;
;
;
;       Done.  We need to check for the minint case.  Then we
;       check for a negative value.
DN:
        CI      R1,0x8000;
        JNE     OK;
        MOV     R15,R15;
        JEQ     OV;
        JMP     RT;
OK:
        MOV     R15,R15;
        JEQ     RT;
        NEG     R1;
RT:     B       0x3000;
;
;
;       DATA
ER:     .str	"OVERFLOW\\\\r\\\\n"
.DE
//*FUNKYSTUFF*//
-- 
			--Lee (Ward)
			{ucbvax,convex,gatech,pur-ee}!unmvax!lee