home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
develop, the CD; issue 1
/
Apple_Develop_1989.bin
/
dynamo
/
rt.macros
< prev
next >
Wrap
Text File
|
1989-12-10
|
35KB
|
1,472 lines
*******************************************************
* *
* DYNAMO *
* *
* Apple II 8-bit runtime macros. *
* Copyright (C) 1989 Apple Computer. *
* *
* Written by Eric Soldan, Apple II DTS *
* *
*******************************************************
* These macros are interfaces for the runtime routines associated with them.
* The runtime routines handle up to 128 integer variables, and up to 256
* strings. The integer functions are simple add,sub,mul,div, and others.
* These others include mass-initialization, min, max, print decimal, etc.
* The string functions are most of what is available in AppleSoft, in
* various forms. There is also support for multi-dimension arrays.
* The principle of the runtime routines is that the xreg holds a destination
* variable number (for ints: 0-254, for strings: 0-255). All runtimes preserve
* the xreg, therefore, you can do multiple operations to a single variable
* without having to reload the xreg. The values that are used on the xreg
* variable (the source data), is one of 3 forms for integers:
* 1. 1-byte value
* 2. 2-byte value
* 3. 2-byte integer variable.
* 1-byte values are placed in the acc. 2-byte values are placed in the acc,y
* (acc=lo, y=hi). 2-byte integer variables have the variable number placed in
* the yreg. (The yreg is not preserved by the runtime routines.)
* Once the source data is loaded (in acc, acc-y, or y), the proper call to the
* runtime routines is made. The 'proper' routine is based on the type of data
* the source is. (If the source is a variable, and we are adding, the macro
* will call the addvar routine.)
* Strings are also referenced by number. There are 3 tables for strings:
* 1. String length table.
* 2. Max string length table.
* 3. Pointer table.
* So, each string takes up four bytes, plus however long the max string length
* is. Having the pointer allows the program to point into memory that was
* never loaded or initialized. This can save time loading the application from
* disk. The string routines will never overwrite the buffer space alloced for
* them. The string will be truncated. So, you can append strings without
* worry about clobbering memory.
*****************************************************************
*****************************************************************
*****************************************************************
* These macros are called by other macros in this file.
MACRO
acorm &op
if &substr(&op,1,1)='#' goto .imm
if &substr(&op,1,1)<>'*' then
aerror 'non-variable parameter must be preceeded by a # or *'
mexit
endif
lda &substr(&op,2,999)
mexit
.imm lda #<&substr(&op,2,999)
mend
MACRO
xcorm &op
if &substr(&op,1,1)='#' goto .imm
if &substr(&op,1,1)<>'*' then
aerror 'non-variable parameter must be preceeded by a # or *'
mexit
endif
ldx &substr(&op,2,999)
mexit
.imm ldx #<&substr(&op,2,999)
mend
MACRO
axcorm &op
if &substr(&op,1,1)='#' goto .imm
if &substr(&op,1,1)<>'*' then
aerror 'non-variable parameter must be preceeded by a # or *'
mexit
endif
lda &substr(&op,2,999)
ldx &substr(&op,2,999)+1
mexit
.imm lda #<&substr(&op,2,999)
ldx #>&substr(&op,2,999)
mend
MACRO
ycorm &op
if &substr(&op,1,1)='#' goto .imm
if &substr(&op,1,1)<>'*' then
aerror 'non-variable parameter must be preceeded by a # or *'
mexit
endif
ldy &substr(&op,2,999)
mexit
.imm ldy #<&substr(&op,2,999)
mend
MACRO
aycorm &op
if &substr(&op,1,1)='#' goto .imm
if &substr(&op,1,1)<>'*' then
aerror 'non-variable parameter must be preceeded by a # or *'
mexit
endif
lda &substr(&op,2,999)
ldy &substr(&op,2,999)+1
mexit
.imm lda #<&substr(&op,2,999)
ldy #>&substr(&op,2,999)
mend
*****************************************************************
*****************************************************************
*****************************************************************
* This macro initializes everything necessary in the runtime and runtime
* macros. It initializes global macro variables and resets everything
* in the runtime so the application can resume if the user presses a reset.
MACRO
&lab _rtreset
&lab jsr rtreset
MEND
***************************************
* This macro is used to turn on the hi-bit for characters that are sent to rtcout.
MACRO
&lab _hibitchrs
&lab jsr hibitchrs
MEND
***************************************
* This macro is used to turn off the hi-bit for characters that are sent to rtcout.
MACRO
&lab _lowbitchrs
&lab jsr lowbitchrs
MEND
***************************************
* This macro is used to make sure that characters sent to rtcout are used as-is. There
* will be no modification of the hi-bit.
MACRO
&lab _regchrs
&lab jsr regchrs
MEND
***************************************
* This macro prints a character. This character is either already in the acc
* (no operand), or what is described by the operand. The operand can either
* be an absolute or a value in memory.
* (acorm means load Acc with a Constant OR Memory value).
MACRO
&lab _rtcout &op
&lab
if &op='' goto .jsr
acorm &op
.jsr jsr rtcout
MEND
***************************************
* This macro prints ascii data following the _write macro. The write routine
* works by using the return address as a pointer to the ascii data. The ascii
* data is terminated with a 0 (C-string style). When the write routine
* encounters a 0, it sets the return address so the when an rts is executed,
* it returns to the code following the 0 terminator. As many parameters as
* are desired can be passed to this routine. If the ascii data is more than
* 1 line, end it with a comma,backslash to indicate line continuation.
MACRO
&lab _write
&lab
if &syslist[1]='' then
aerror '_write: must have at least one parameter'
mexit
endif
jsr write
lcla &i,&n
&i seta 1
&n seta &nbr(&syslist)
.a dc.b &syslist[&i]
&i seta &i+1
if &i<=&n goto .a
dc.b 0
MEND
***************************************
* This macro prints a carriage return.
MACRO
&lab _writecr
&lab jsr writecr
MEND
***************************************
* This macro prints a c string pointed to by the operand.
MACRO
&lab _wrcstr &op
&lab aycorm &op
jsr wrcstr
MEND
***************************************
***************************************
***************************************
* This macro sets signed mode. Printing decimal numbers is affected by this.
MACRO
&lab _signed
&lab jsr signed
MEND
***************************************
* This macro sets unsigned mode. Printing decimal numbers is affected by this.
MACRO
&lab _unsigned
&lab jsr unsigned
MEND
***************************************
* This macro does a two's compliment on the variable.
MACRO
&lab _chngsgn
&lab jsr chngsgn
MEND
***************************************
* This macro prints a 1-byte decimal value. This value is either already in
* the acc (no operand), or what is described by the operand. The operand can
* either be an absolute or a value in memory.
MACRO
&lab _decoutl &op
&lab
if &op='' goto .jsr
acorm &op
.jsr jsr decoutl
MEND
***************************************
* This macro prints a 2-byte decimal value. This value is stored in a
* variable. The variable number is either already in the xreg (no operand),
* or is determined by the operand.
MACRO
&lab _vdecout &op
&lab
if &op='' goto .jsr
ldx #<&op
.jsr jsr vdecout
MEND
***************************************
* This macro prints a 2-byte decimal value. This value is either already in
* the acc,y (no operand), or what is described by the operand. The operand
* can either be an absolute or a value in memory.
MACRO
&lab _decout &op
&lab
if &op='' goto .jsr
aycorm &op
.jsr jsr decout
MEND
***************************************
* This macro sets pad mode for hex. The value is either already in the acc
* (no operand), or what is described by the operand. The operand can either
* be an absolute or a value in memory. Printing hex numbers is affected by
* this.
MACRO
&lab _hexpad &op
&lab
if &op='' goto .jsr
acorm &op
.jsr jsr hexpad
MEND
***************************************
* This ma