Part 1 of Lll 8080 Basic Interpreter
Total Page:16
File Type:pdf, Size:1020Kb
SOFTWARE SECTION MICROCOMPUTER DEVELOPMENT SOFTWARE PART 1 OF LLL 8080 BASIC INTERPRETER Submitted by E. R. Fisher By Jerry Barber & Royce Eckard Lawrence Livermore Laboratory FOREWARD Execution time The BASIC interpreter was developed at the Univer Operation on 8080 (m secl sity of Idaho by John Dickenson. Jerry Barber. and John Teeter under a contract with the Lawrence Liver ADD 2.4 m sec SUBSTRACT more Laboratory. The floating point package was 2.4 m sec MULTIPLY developed by David Mead. modified by Hal Brand and 5.4 m sec DIVIDE 7.0 m sec Frank Olken. In addition. Jerry Barber. as an LLL summer employee. made significant contributions to this document and to implementing the BASIC lan BASIC INTERPRETER LANGUAGE GRAMMAR guage in an MCS-8080 microprocessor. COMMANDS - Six BASIC interpreter commands INTRODUCTION are provided. These commands are: This article is Part 1 of a series of four articles RUN Begins program execution covering the LLL 8080 BASIC interpreter just released Clears program from merrory to the public domain by Lawrence Livermore Labor SCR Lists ASCII program in merrory atory. The other three articles that will be published in LIST Punches paper-tape copy of program the next three months are: PLST PTAPE Reads paper-tape copy of program PART 2 - LLL 8080 BASIC INTERPRETER SOURCE using high-speed reader PROGRAM WITHOUT FLOAT O\ITRL S Interrupts program during execution PART 3 - LLL 8080 BASIC FLOAT SOURCE PRO GRAM PART 4 - LLL 8080 OCTAL DEBUGGING SOURCE The LIST and PLST commands can be followed by PROGRAM one or two line numbers to indicate that only a part of the program is to be listed. If one line number follows The partition approach of publishing the com the command. the program is listed from that line plete 120 page LLL BASIC interpreter source pro number to the end of the program. If two line numbers gram assembly listing and descriptive text is taken as (separated by a comma) follow the command. the list the only logical way to transfer the complete source ing begins at the first line number and ends at the program and text to INTERFACE AGE readers. second. When a command is completed. READY will be STORAGE REQUIREMENTS typed on the teletype. Once initialized by a command. a process will normally go to completion. However. if The BASIC interpreter consists of a 5K-byte-PROM you wish to interrupt an executing program or a list resident interpreter used for program generation and ing. simply strike CNTRL S and the process will ter debug was configured to operate with the MCS-8080 minate and a READY message will be microprocessor. typed. The goal in developing the 8080 BASIC was to provide a high-level. easy-to-use conversational lan ST A TEM ENTS - Each statement line begins with a guage for performing both control and computation line number. which must be an integer between 0 and functions in the MCS-8080 microprocessor. To mini 32767. Statements can be entered in any order. but mize system memory size and cost. the interpreter was they will be executed in numerical order. All blanks are constrained to fit into 5 K bytes. It was necessary. ignored. The following types of statements are therefore. to limit the commands to those considered allowed: the most useful in microprocessor applications. REM - Indicates a remark (comment). The system deletes blanks from all character strings that are MATH OPERATOR EXECUTION TIMES not enclosed in quotes ("). Therefore. it is sug Average execution times of the four basic math gested that characters following the REM key operators are as follows; word be enclosed in quotes. END - Indicates the end of a program. The program stops when it gets to the END statement. All Happy Holidays programs must end with EN D. 110 INTERFACE AGE DECEMBER 1976 SOFTWARE SECTION MICROCOMPUTER DEVELOPMENT SOFTWARE STOP - Stops the program. This statement is used after the last identifier so, if only one identifier is when the program needs to be stopped other present no comma is needed. When an INPUT than at the end of the program text. statement is executed, a colon (:) is output to the GOTO - Transfers program control to specified teletype to indicate that data are expected. The statement line number. This statement is used to data are entered as numbers separated by com loop or jump unconditionally within a program. mas. If fewer data are entered than expected, Program execution continues from new state another colon is output to the teletype, indicat ment. ing again that data are expected. For example, DIM - Declares an array. Only one-dimensional where arrays with an integer constant number of ele 50 INPUT I,J,K,P ments are allowed. An array with N elements is executed, a colon is output to the teletype. uses indexes 0 through N-1. All array locations Then, if only 3 numerical values are entered, ano are set to zero. No check is made on subscripts to ther colon will be output to indicate that more ensure that they are within the declared array. An data are expected; e.g., array variable must be a ·single letter. : 4,4,6.2 CIR LET - Indicates an assignment statement (Addition, : 10.3 CIR, subtraction, multiplication, division, or special function may be used). The LET statement is used where CIR is the carriage-return key. If an error is to assign a value to a variable. Non-array var made in the input-data line, an error message is iables can be either a single letter or a letter issued and the entire line of data must be re followed by a digit. It is possible to have an array entered. If, for the above example, and a non-array variable with the same name. : 4,4,6M2,1 0.3 CIR The general form of the LET statement is: is entered, the system will respond line number LET identifier = expression, INPUT ERROR, TRY AGAIN where "identifier" is either a subscripted array element or a non-array variable or function (see section on functions) and "expression" is a unary At this time, the proper response would be or binary expression. The expression will be one 4,4,6.2,10.3 C/R. of the following ten types: PRINT - This command allows numerical data and variable character strings to be printed on the teletype. -variable Two types of print items are legal in the print variable + variable statement: character strings enclosed in quotes variable - variable (") and expressions. These items .are separated by -variable + variable either a comma or a semicolon. If print items are -variable - variable separated by a comma, a skip occurs to the next variable * variable pre-formatted field before printing of the item -variable * variable following the comma begins. The pre-formatted variable I variable, fields begin at columns 1, 14,27,40, and 52. If -variable I variable, print items are separated by a semicolon, no skip occurs. If a semicolon or comma is the last where "variable" is an identifier, function, or character on a print statement line, the appro number. The subscript of an array can also be an priate formatting occurs and the carriage-return expression. line feed is suppressed. A print statement of the IF - Condition statement which transfers to specified form line number statement if the condition of the 50 PRINT expression is met. It has the form: line number IF will generate a carriage-return-line feed. Thus, expression relation expression TH EN transfer line the two lines below number. The possible relations are: 50 PRINT "INPUT A NUMBER"; Equal = 60 INPUT A Greater than > Less than < will result in the following output: Greater than or equal > = = < Less than or equal < = = < INPUT A NUMBER: Not equal <> >< FOR - Causes program to iterate through a loop a If the relation between the two expressions is designated number of times. true then the program transfers to the line NEXT - Signals end of loop at which point the number, otherwise it continues sequentially. computer adds the step value to the variable and INPUT - This command allows numerical data to be checks to see if the variable is still less than the input via the teletype. The general form is: terminal value. Line nu mber I N PUT identifier list GOSUB - Transfer control to a subroutine that begins at specified line number where an "identifier list" is a sequence of iden tifiers separated by commas. There is no comma RETURN - Returns control to the next sequential line 112 INTERFACE AGE DECEMBER 1976 SOFTWARE SECTION MICROCOMPUTER DEVELOPM-=NT SOFTWARE after the last GOSUB statement executed. A on the stack. Thus. on entry to a subroutine. the return statement executed before a GOSUB is first POP instruction will recover the address to equivalent to a STOP statement. the last parameter in the call list. The next will CALL - Calls user-written assembly-language rou recover the next to last. etc. tines of the form Each scalar variable passed results in the address CALL (N. A. B•... l. to the first byte of a four-byte block of memory. where N is a subroutine number from 0- 254 and Each array element passes the address to the first A. B.... are parameters. The parameters can be byte of a (N-M) x four-byte memory block. where constants. variables. or expressions. However. if N is the number of elements given the array in variables and constants or expressions are inter the DIM STMT and M is the array subscript in the mixed. all variables should have been referenced CALL STMT.