We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 28
| APPENDICES |
nnnAPPENDIX A,
‘HOWTO TOAD BASIC
When the ALTAIR is first turned on, there is random garbage in its
menory. BASIC is supplied on a paper tape or audio cassette. Somehow
‘the information on the paper tape or cassette must be’ transfered into the
computer. Programs that perform this type of information transfer are
called loaders.
Since initially there is nothing of use in menory; you must toggle
in, using the switches on the front panel, a 20 instruction bootstrap
loader. This loader will then load BASIC.
To load BASIC follow these steps:
1) Turn the ALTAIR on.
2) Raise the STOP switch and RESET switch simultaneously.
3) Turn your terminal (such as a Teletype) to LINE.
Because the instructions must be toggled in via the switches on the
front panel, it is rather inconvenient to specify the positions of each
switch as “up" or "down", Therefore, the switches are arranged in groups
of 3 as indicated by the broken lines below switches 0 through 15. To
specify the positions of each switch, we use the numbers 0 through 7 as
shown below:
3 SWITCH GROUP
OCTAL
NUMBER
0
1
2
up Down, 4
up up s
up Down 6
up Up 7
So, to put the octal mumber 315 in switches 0 through 7, the switches
would have the following positions:
7 6 5 4 3 2 1 0 SWITCH
up up | DOWN = pows. Ss uP] UP DOWN. Ss UP ~#=POSITION
3 1 5 ———ocTaL No.
468Note that switches 8 through 15 were not used. Switches 0 through
7 correspond to the switches labeled DATA on the front panel, A memory
address would use all 16 switches.
The following program is the bootstrap loader for users loading from
paper tape, and not using a REV 0 Serial 1/0 Board.
OCTAL ADDRESS OCTAL DATA
‘G00 O81
oot 175
002 037 (for aK; for 4K use 017)
003 O61
004 022
005 000
006 333
007 00
010 017
oul 330
o12 333
ais oon
ona 275
015 310
016 055
017 167
020 300
21 352,
022 003
023 000
‘The following 21 byte bootstrap loader is for users loading from a
paper tape and using a REV 0 Serial 1/0 Board on which the update changing
the flag bits has not been made. If the update has been made, use the
above bootstrap loader.
OCTAL ADDRESS OCTAL DATA
000 O81
001, 17s
002 037 (for 8X; for 4K use 017)
003 061
04 23
0s 200
006 333
007 000
010 346
ou 040
012 310
013 333,
ola 001
ous 25
01s 310
ol7 055
: 020 167
aOCTAL ADDRESS OCTAL DATA
{cont.)
oan 300
022 351
025 003
024 000
‘The following bootstrap loader is for users with BASIC supplied on
an audio cassette.
QCTAL ADDRESS OCTAL DATA
ae 0s Oar
cox 175
002 037° (for 8K; for 4K use 017)
003 061
04 022
00s 000
006 333
007 006
10 17
oul 330
012 333
01s 007
ols 275
o1s 310
016 oss
017 167
020 300
021 351
022 003
023 000
To load a bootstrap loader:
1) Put switches 0 through 15 in the down position.
2) Raise EXAMINE.
3) Pur O41 (data for address 000) in switches 0 through 7.
4) Raise DEPOSIT.
5) Put the data for the next address in switches 0 through 7.
6) Depress DEPOSIT NEXT.
7) Repeat steps 5 § 6 until the entire loader is toggled in.
8) Put switches 0 through 15 in the down position.
9) Raise EXAMINE.
10) Check that lights D0 through D7 correspond with the data that should
@uM)
12)
13)
uM)
45)
16)
17)
18)
19)
be in address 000. A light on means the switch was up, a light off
means the switch was down. So for address 000, lights D1 through D4
and Lights D6 § D7 should be off, and lights DO and DS should be on.
I£ the correct value is there, go to step 13. If the value is wrong,
continue’with step 11.
Put the correct value in switches 0 through 7.
Raise DEPOSIT.
Depress EXAMINE NEXT.
Repeat steps 10 through 13, checking to see that the correct data is
in each corresponding address for the entire loader.
If you encountered any mistakes while checking the loader, go back
now and re-check the whole program to be sure it is corrected.
Put the tape of BASIC into the tape reader. Be sure the tape is
positioned at the beginning of the leader. The leader is the section
of tape at the beginning with 6 out of the @ holes punched.
If you are loading from audio cassette, put the cassette in the ze-
corder. Be sure the tape is fully rewound.
Put switches 0 through 15 in the down position.
Raise EXAMINE.
if you have connected to your terminal a REY 0 Serial 1/0 Board
on which the update changing the flag bits has not been made, rai:
switch 14; if you are loading from an audio cassette, raise switch
15 alse.
2
If you have @ REV 0 Serial 1/0 Board which has been updated, or have
a REV 1 1/0 Board, switch 14 should renain down and switch 15 should
be raised only if you are loading from audio cassette.
Turn on the tape reader and then depress RUN. Be sure RUN is depres-
sed while the reader is still on the leader. Do not depress run be-
fore turning on the reader, since this may cause the tape to be read
incorrectly.
If you are loading from a cassette, turn the cassette recorder to
Play. Wait 15 seconds and then depress RUN.
Wait for the tape to be read in. This should take about 12 minutes
for 8K BASIC and 6 minutes for 4K BASIC. It takes about 4 minutes
to load 8K BASIC from cassette, end about 2 minutes for 4k BASIC.
Do not move the switches while the tape is being read in.
4922)
23)
24)
If aC or an 0 is printed on the terminal as the tape reads in, the
tape has been mis-read and you should start over at step 1 on page
46.
When the tape finishes reading, BASIC should start up and print
MEMORY SIZE?. See Appendix 8 for the initialization procedure.
If BASIC refuses to load from the Audio Cassette, the ACR Demodulator
may need alignment. The flip side of the cassette contains 90 seconds
of 125's (octal) which were recorded at the same tape speed as BASIC.
Use the Input Test Program described on pages 22 and 28 of the ACR
manual to perform the necessary alignnent.
a0APPENDIX B
TINTTIATIZATION DIALOG
STARTING BASIC
Leave the sense switches as they were set for loading BASIC (Appen-
dix A). After the initialization dialog is complete, and BASIC types OK,
you are free to use the sense switches as an input device (I/O port 255).
‘After you have loaded BASIC, it will respond:
MEMORY SIZE?
If you type a carriage return to MEMORY SIZE?, BASIC will use all
the contiguous memory upwards from location zero that it can find. BASIC
will stop searching when it finds one byte of ROM or non-existent memory.
If you wish to allocate only part of the ALTAIR's memory to BASIC,
type the number of bytes of memory you wish to allocete in decimal. This
might be done, for instance, if you were using part of the menory for a
machine language subroutine.
There are 4096 bytes of memory in a 4K system, and $192 bytes in an
aK systen.
BASIC will then ask:
TERMINAL WIDTH? This is to set the output line width for
PRINT statements only. Type in the nunber
of characters for the line width for the
particular terminal or other output device
you are using. This may be any number
from 1 to 255, depending on the terminal.
Tf no answer is given (i.e. a carriage
return is typed) the line width is set
to 72 characters.
Now ALTAIR BASIC will enter a dialog which will allow you to delete
some of the arithnetic functions. Deleting these functions will give
more menory space to store your programs and Varisbles. However, you will
not be able to call the functions you delete. Attempting to do so will
result in an FC error. The only way to restore a function that has been
deleted is to reload BASIC.
The following is the dialog which will occur:
4K Version
WANT SIN? Answer " Y" to retain SIN, SQR and RND.
Tf you answer "N'", asks next question.
WANT SaRe Answer " Y" to retain SQR snd RND.
£ you answer "NN", asks next question.
atWANT RND? Answer " Y " to retain RND.
Answer "'N "to delete RND.
8K Version
WANT SIN-COS-TAN-ATN?
Answer "Y " to retain all four of
the functions, "\N" to delete all four,
or A" to delete ATN only.
Now BASIC will type out:
XXXX BYTES FREE,
ALTAIR BASIC VERSION 3.0.
{FOUR-K VERSION}
(or)
(ELGHT-K VERSION]
oK
"MOK" is the number of bytes
available for program, variables,
matrix storage and the stack. It
does not include string space.
You will now be ready to begin using ALTAIR BASIC.TaPFENDIX
ERROR MESSAGES
After an error occurs, BASIC returns to command level and types OK.
Variable values and the program text remain intact, but the program can
not be continued and all GOSUB and FOR context is lost.
When an error occurs in a direct statement, no line number is printed.
Format of error messages:
Direct Statenent XX ERROR
Indirect Statement XX ERROR IN YYYYY
In both of the above examples, "XX"' will be the error code, The
wyyyYY" will be the line number where the error occured for the indirect
statement.
‘The following are the possible error codes and their meanings:
(OR _CODE MEANING
4x VERSION
BS Bad Subscript. An attempt was made to reference a
natrix element which is outside the dimensions of the
matrix. In the 8K version, this error can occur if
the wrong number of dimensions are used in a matrix
reference; for instance, LET A(1,1,1)=2 when A has
been dimensioned DIM A(2,2).
DD Double Dimension. After a matrix was dimensioned,
another dimension statement for the same matrix was
encountered. This error often occurs if a matrix
has been given the default dimension 10 because a
statement like A(I)=3 is encountered and then later
in the progran a DIM A(100) is found.
FC Function Cali error. The parameter passed to a math
or string function was out of range.
FC errors can occur due to:
a) a negative matrix subscript (LET A(-1)=0)
b) an unreasonably large matrix subscript
(232767)
¢) LOG-negative or zero argunent
4) SQR-negative argument
53op
on
ov
SN
RG
us
10
aK
e) AtB with A negative and B not an integer
£) a call to USR before the address of the
machine language subroutine has been
patched in
g) calls to MIDS, LEFTS, RIGHTS, INP, OUT,
WAIT, PEEK, POKE, TAB, SPC or ON...GOTO
with an improper argument.
Illegal Direct. You cannot use an INPUT or (in 8K Vers
DEFFN statement as a direct command.
ton)
NEXT without FOR, The variable in a NEXT statement
corresponds to no previously executed FOR statement.
Out of Data. A READ statement was executed but all of
the DATA statements in the program have already been
read. The program tried to read too much data or insuf-
ficient date was included in the program.
Out of Memory. Program too large, too many variables,
too many FOR loops, too many GOSUB's, too complicated
an expression or any combination of the above. (see
Appendix D}
Overflow. The result of a calculation was too large to
be represented in BASIC's mumber format. If an underflow
occurs, zero is given as the result and execution continues
without any error message being printed.
Syntax error. Missing parenthesis in an expression,
illegal character in a line, incorrect punctuation, etc.
RETURN without GOSUB. A RETURN statement was encountered
without a previous GOSUB statement being executed.
Undefined Statement. An attempt was made to GOTO, GOSUB
or THEN to a statement which does not exist.
Division by Zero.
VERSION (Includes ait of the previous codes in addition to the
‘oltowing.)
Continue error. Attempt to continue a program when
none exists, an error occured, or after a new line
was typed into the program.
54oS
UF
Long String. Attempt was made by use of the concatenation
operator to create a string more than 255 characters long.
Out of String Space. Save your program on paper tape or
cassette, reload BASIC and allocate more string space
or use smaller strings or less string variables.
String Temporaries. A string expression was too complex.
Break it into two or more shorter ones.
‘Type Mismatch. The left hand side of an assignment
statement was a numeric variable and the right hand
side was a string, or vice versa; or, a function which
expected a string argunent was given'a numeric one or
vice versa.
Undefined Function. Reference was made to a user defined
function which had never been defined.
55PEI
SPACE HINTS
In order to make your program smaller and save space, the following
hints may be useful.
1) Use multiple statements per line. There is 4 small amount of
overhead (Sbytes) associated with each line in the program. Two of these
five bytes contain the line number of the line in binary. This means
‘that no matter how many digits you have in your line number (minimum Line
number is 0, maximum is 65529), it takes the same number of bytes. Put-
ting as many statements as possible on a line will cut down on the number
Of bytes used by your program.
2) Delete ali unnecessary spaces from your program. For instance:
10 PRINT X, Y, Z
uses three more bytes than
10 PRINTX,Y,2
Note: All spaces between the line number and the first non-
blank character are ignored.
3) Delete all REM statements. Each REM statement uses at least
one byte plus the mumber of bytes in the comment text. For instance,
the statement 130 REM THIS IS A COMMENT uses up 24 bytes of menory.
In the statement 140 X-X+Y: REM UPDATE SUM, the REM uses 14 bytes of
menory including the colon before the REM.
4) Use variables instead of constants. Suppose you use the constant
3.14159 ten times in your program. If you insert a statement
10 P=3.14159
in the program, and use P instead of 3.14159 each tine it is needed, you
will save 40 bytes. This will also result in a speed improvement.
5) A program need not end with an END; ‘36, en
the end of 2 program may be deleted.
6) Reuse the same variables. If you have a variable T which is used
to hold a temporary result in one part of the program and you need a ten-
porary variable later in your program, use it again. Or, if you are asking
‘the terminal user to give a YES or NO answer to two different questions
at two different times during the execution of the program, use the same
vemporary variable A$ to store the reply.
7) Use GOSUB's to execute sections of program statements that per-
form identical actions.
8) _ If you are using the 8K version and don't need the features of
the 8K version to run your program, consider using the 4K version in-
stead. This will give you approximately 4.7K to Work with in an 8K machine,
as opposed to the 1.6K you have available in an 8K machine running the
8K version of BASIC.
569) Use the zero elements of matrices; for instance, A(0), B(0,X).
STORAGE ALLOCATION INFORMATION
Simple (non-matrix) numeric variables Like V use 6 bytes; 2 for the
variable name, and 4 for the value. Simple non-natrix string variables
also-use 6 bytes; 2 for the variable name, 2 for the length, and 2 for a
pointer.
Matrix variables use a minimum of 12 bytes. Two bytes are used for
the variable name, two for the size of the matrix, two for the number of
dimensions and two for each dimension along with four bytes for each of
the matrix elements.
String variables also use one byte of string space for each character
in the string. This is true whether the string variable is a simple string
variable like A$, or an element of a string matrix such as QUS(5,2).
When a new function is defined by a DEF statement, 6 bytes are used
to store the definition.
Reserved words such as FOR, GOTO or NOT, and the names or the
intrinsic functions such as COS, INT and STRS take up only one byte of
progran storage. All other characters in programs use one byte of pro-
gram storage each.
When a program is being executed, space is dynamically allocated on
the stack as follows:
1) Each active FOR...NEXT loop uses 16 bytes.
2) Each active GOSUB (one that has not returned yet) uses 6 bytes.
3) Each parenthesis encountered in an expression uses 4 bytes and
each temporary result calculated in an expression uses 12 bytes.
ATAPPENDIX E
SPEED HINTS.
The hints below should improve the execution time of your BASIC pro-
gram, Note that some of these hints are the same as those used to decrease
the Space used by your programs. This means that in many cases you can
increase the efficiency of both the speed and size of your programs at
the same time.
1) Delete all unnecessary spaces and REM's from the program. This
may cause a small decrease in execution time because BASIC would otherwise
have to ignore or skip over spaces and REM statements.
2) PRIS IS PROBABLY TEE MOST IMPORPANT SPUED HINT BY A FACTOR OF 10.
Use variables instead of constants. It takes more time to con-
vert a constant to its floating point representation than it does to fetch
the value of a simple or matrix variable. This is especially important
within FOR...NEXT loops or other code that is executed repeatedly.
3) Variables which are encountered first during the execution of
a BASIC program are allocated at the start of the variable table. This
means that a statement such as 5 A=0:B=A:C=A, will place A first, B second,
and.C third in the symbol table (assuming line 5 is the first statement
executed in the program). Later in the program, when BASIC finds a refer-
ence to the variable A, it will search only one entry in the symbol table
to find A, two entries to find B and three entries to find C, etc.
4) (8% Vereton) NEXT statements without the index variable. NEXT
is somewhat faster than NEXT I because no check is made to see if the
variable specified in the NEXT is the same as the variable in the most re-
cent FOR statement.
5) Use the 8K version instead of the 4K version. The 8K version
is about 40% faster than the 4K due to improvements in the floating point
arithmetic routines.
6) The math functions in the 8K version are much faster than their
counterparts simulated in the 4K version. (see Appendix 6)
58APPENDIX F
‘DERIVED FUNCTIONS
The following functions, while not intrinsic to ALTAIR BASIC, can be
calculated using the existing BASIC functions.
FUNCTION FUNCTION EXPRESSED IN TERMS OF BASIC FUNCTIONS
SECANT SEC(X) = 1/C0S(x)
COSECANT esc(x) = 1/SIN(X)
COTANGENT COray) = 1/TAN(X)
INVERSE SINE ARCSIN(X) = ATN(X/SQR(-K"X+1))
INVERSE COSINE ARCCOS (KX) = -ATN(X/SQR(-X*X+1)) #1.5708
INVERSE SECANT ARCSEC(X) = ATN(SQR(X*K-1) )+ (SGN (KX) -1)*1.5708
INVERSE COSECANT ARCCSC(X) = ATNCL/SQR (X*X=1) }+ (SGN (X)=1)*1.5708
INVERSE COTANGENT ARCCOT(X) = -ATN(X)+1.5708
HYPERBOLIC SINE SINH(S) = (EXP(X)-EXP(-X))/2
HYPERBOLIC COSINE COSH(X) = (EXP (X)+ExP(-x))/2
HYPERBOLIC TANGENT ‘TANH(X) = ~EXP (-X) / (EXP (10) +EXP (-X)) #241
HYPERBOLIC SECANT SECH(X) = 2/ (EXP (X)+EXP(-X))
HYPERBOLIC COSECANT CSCH(X) = 2/ (EXP (X)-EXP(-X)}
HYPERBOLIC COTANGENT — COTH(X) = EXP(-X)/(EXP (X) -EXP(-K))*2+1
INVERSE HYPERBOLIC
SINE ARGSINH(X) = LOG(X+SQR(X*X+2))
INVERSE HYPERBOLIC
COSINE ARGCOSH(X) = LOG(X+SQR(X*X-1))
INVERSE HYPERBOLIC
‘TANGENT ARGTANH(X) = LOG((1+X)/(1-X))/2
INVERSE HYPERBOLIC
‘SECANT ARGSECH(X) = LOG( (SQR(-X*X+1)+1)/X)
INVERSE HYPERBOLIC
COSECANT ARGCSCH(K) = LOG( (SGN (X) *SQR(X*X+1)+1) /X)
INVERSE HYPERBOLIC
COTANGENT ARGCOTH(X) = LOG((X+1) /(X-1))/2APPENDIX G
‘SIMULATED MATH FUNCTIONS:
‘The following subroutines are intended for 4K BASIC users who want
to use the transcendental functions not built into 4K BASIC. The cor-
responding routines for these functions in the 8K version are much faster
and more accurate. The REM statements in these subroutines are given for
documentation purposes only, and should not be typed in because they take
up a large amount of memory.
‘The following are the subroutine calls and their 8K equivalents:
8K EQUIVALENT SUBROUTINE CALL
Po=xgeyo GosuB 60030
GosuB 60090
GosuB 60160
GOSUB 60240
GosuB 60280
GosuB 60310
‘The unneeded subroutines should not be typed in. Please note which
variables are used by each subroutine, Also note that TAN and COS require
that the SIN function be retained when BASIC is loaded and initialized.
LOO0O REM EXPONENTZATION: PS=xXatY9.
GOOLO REN NEED! EXP. LOG
LGO20 REM VARIABLES USED? A9.B5:CHETLIPTXTYS
BOOSO PSs: ETO ¢ IF YS=0 THEN RETURN
OOO IF X9<0 THEN TF INT(YS)=¥9 THEN PS=:
BOOSO IF X4<>0 THEN GOSUB LOOSO + Xd=YS*L9
GOOLO P=PS*ET = RETURN
0070 REM NATURAL LOGARITHI: L5=L0G(x9)
KOOBO REM VARIABLES USED! A9+85.CH ETL 0X9
BOOS ESO + IF Xi<=0 THEN PRINT "LOG FC ERRORS STOP
BOOSS ASSL + BIZ + CH=. : REM THIS WILL SPEED UP THE FOLLOWING
OOO IF XS>