💾 Archived View for spam.works › mirrors › textfiles › apple › DOCUMENTATION › acos.tutor.1 captured on 2023-06-16 at 21:13:45.
-=-=-=-=-=-=-
[-----------------------------------------------------------------------] [ A C O S Tutorial ] [ ver 1.2 ] [ Written by . A RIPCO System... Upgraded By UPS Network ] [ ] [ ] [-----------------------------------------------------------------------] ACOS COMPILER RELEASE 1.2 SPECS ----------------------------- Hardware Required : Apple ][ series Memory Required : 64k Operating System : DOS 3.3 or PRODOS Hardware Supported : printer, modem, display cards, clock, etc. Total Program Space: 24k Total Variable Space: 24k - program space Internal Editor Space: 4k Disk Channels: 2 (plus 1 for message base use) Ram Drive: 128 bytes Scratch Ram: 192 bytes Compiler Info: standard 2 pass compiler built on assembler principles for label oriented languages. Pass 1 Info: compiler pass 1 takes text source code and tokenizes all statements and functions into single byte tokens. All text and symbols are marked as such for fast recognition. All label addresses are stored into a table. All label references are also put into a separate table. Tokenized code is generated into memory without addresses. Pass 2 Info: Compiler pass 2 goes through the label reference table and searches for the address of the desired routine. If a match is not found, a LABEL NOT FOUND message is displayed. Otherwise, the address is saved into the second table. Afterwards, all references that were found are inserted into the actual code. The compiled code is then saved to disk. Code Execution: Actual code execution is based on a "fetch-and-go" method. Each token is fetched from the compiled code. The routine is then found via a lookup table and is executed. When label references are made, the address is already known so no time is taken searching for it. ------------------------- ACOS REFERENCE FOR ACOS RELEASE 1/2 --------------------------------- GENERAL INFORMATION Welcome to the world of ACOS. The following document was written to help give you an introduction to ACOS and to help you to learn to write your own programs or modify others written in ACOS. ACOS is a full featured language just like BASIC, PASCAL, FORTRAN, or any other language. it resembles BASIC more than any other language due to the fact that almost everyone involved with computers is familiar with BASIC because it comes standard with most personal computers. Since the aim was to make ACOS as easy to use as possible, it was modeled after BASIC. At the same time, there are also many differences also. This package contains a proprietary ACOS compiler which you will be using. Unlike many interpreted BASICs which have their editor built in, ACOS requires the use of some form of text editor for you to manipulate your source files. All ACOS source files are stored as text, so any editor that can modify standard text files can be used. ------------------------- WRITING A PROGRAM Since actually doing something tends to be a better teacher than just reading about something, we will be writing a small sample program in ACOS. The first thing you need to do is start your text editor/word processor you plan on using to write your code. Once you are ready, enter the following program: LOOP print "this is an acos program" print "i hope it works!" goto loop The important points to note are these: ACOS is not based around line numbers as is the BASIC language. It is free form like PASCAL or ASSEMBLY LANGUAGE. It uses labels as markers for groups of code instead of line numbers that marks the beginning of a line of code when the requirement arises to identify a specific point within the program. Since your labels can have descriptive names to begin a section of code, it makes it easier to see what this code does. Also, you can add extra blank lines at the top and bottom of a group of code to identify it more clearly. If you add comments within your code it helps you remember what you are trying to do in that section. When you begin to write your program there are a few rules that must be followed in order for ACOS to process your code. LABELS must ALWAYS begin at the column 0 at the left side of the screen. The rest of the code always begins in column 1. The only exception to this deals with the use of quotes (") to identify text. When you open a quote at the start of the print statement, all following text will be printed to the screen until another quote is encountered. This includes normal text, any control character and blank lines as well. Once you have typed in this test program, save it to your ACOS compiler disk under the name "TEST.S". You must ALWAYS add a ".S" to the end of any source file for ACOS so that ACOS knows it is a "source" file. Then exit from your editor back to your operating system. Insert the disk with the ACOS compiler and log to that disk. Execute the ACOS compiler with the appropriate operating system command (-ACOS, BRUN ACOS, ACOS). At this time, the ACOS loader will execute and check through you directory for any ACOS source files and do some file maintenence at the same time. You will then be asked for the name of the ACOS program to be executed. Hitting return will execute the default starting program which is indicated in brackets. This default filename will differ from application to application. Type in "TEST" and return. You will see "TEST" displayed as the default filename. Enter a return and the compl'iler will start to execute. The screen will clear and you will get a "COMPILING 1..." message. This means that the compiler is in the first phase of its two phase compile. This first phase takes the longest. After a quick wait, the message will change to "COMPILING 2...". This indicates that the compiler is in the second phase. This generally is very fast. Once the second phase is complete and has created a new file, which in this case is called "TEST.G", the message will be cleared and the program executed. In this case, the following will be displayed: THIS IS AN ACOS PROGRAM I HOPE IT WORKS! THIS IS AN ACOS PROGRAM I HOPE IT WORKS! THIS IS AN ACOS PROGRAM I HOPE IT WORKS! The two lines will be repeated over and over again, unless you stop the program via the RESET key. Lets see how this program worked. The first thing that happend is that the ACOS interpreter looked at the first line of code for a label that begins at the very left most column of the screen. This told ACOS that the first line is actually a LABEL. A LABEL is a reference point in a program to a section of code. A LABEL has no effect when the program flow passes through it, but it directs the operation from the line executing from one section of code to the beginning of the section where the LABEL is. Execution then is passed to the next line, the first having no actual effect. ACOS looked and saw that the second line did NOT start at the leftmost column but started at column 1 instead. This tells ACOS that the data on the line is the actual program code. ACOS then looked at the first word which in this case was PRINT. ACOS then went into its internal PRINT routine as you asked it. Once within the PRINT routine, special rules take over that govern the PRINT statement. Summing it up quickly, PRINT will display to the console whatever text or data is in between the " " marks. In this case, it printed "THIS IS AN ACOS PROGRAM". This data was placed within quotes to show that it was text. Once the end of the line was encountered, execution passed to the next line. The next line was another PRINT statement which was displayed: "I HOPE THIS WORKS!". This is the same text that you typed in when you wrote the short program. It works in the same way as the first PRINT statement. This is the simplest form of the PRINT statement. Its function is by no means limited to this basic form since there are many other variations that can be used. The last line of the program contained another statement to be executed by virtue that it was indented 1 space. This time, the STATEMENT or COMMAND was GOTO. This statement does what is called FLOW CONTROL. This is the process by which the point of execution of the program is changed from the last line executed to a new line. When the GOTO routine is executed, it searches for the name of the LABEL and when it finds the LABEL it executes the next line of code. In this case, the label was LOOP. ACOS then looks through the program to find a label called LOOP. As it happens, that label is on the first line of the program, though it could have been in any line. The program execution point is then moved to the label LOOP which happens to be at the beginning of the program in this case. Thus, the text is printed again and again. This situation is called an INFINITE LOOP. That is, the loop will never stop (unless you as operator stops it via RESET or some other means). After you hit [RESET], you will be faced with a group of choices labeled "RESTART: S,M,Q ?". By pressing "S" you will restart the original program you told ACOS to execute. By pressing "M" you will restart the program in memory. In this case, they are the same, but programs can link to other programs so that the original one is different from the one in memory now. This is helpful for debugging so you can re-start that program in memory without starting with the original program first. By pressing "Q", you will quit ACOS and return to your operating system. At this point, you have successfully written, entered, and executed an ACOS program. Though this was a simple example, the steps are the same for advanced programs. The following is a summary of the steps involved with writing an ACOS program: 1) Enter some form of word or text processor that can accommodate standard text files. 2) Type in your ACOS program. All labels start at column 0 while all actual code starts at column 1. 3) Save the program to disk adding a ".S" suffix onto your filename (ex: TEST.S) so that ACOS can identify it as an ACOS source file. 4) Execute ACOS from your operating system via whatever commands are needed. (ex: -ACOS, BRUN ACOS, ACOS). 5) Enter the name of the module you wish to execute if it is different from the default name. Don't add the ".S" suffix or the file will not be found. 6) The compiler will then compile and execute your program. If you execute the program again without changing the source code, the compiler will NOT re-compile, it will just run the old code. The following section contains information on all the data formats, variable types, and disk access methods that can be used with ACOS. A working knowledge of BASIC is recommended to help you along. If you don't know ant other language, try and use the examples as much as possible. They will be the best teacher. Also, try modifying existing code. This is another easy way to learn. ------------------------- PROGRAM STRUCTURE Under ACOS the structure of a program is very much "free-form". That is, the compiler is very tolerant of different styles of programming. You are allowed to add blank lines and comments anywhere in your code for ease of reading. Any line within an ACOS source program must be in one of the following formats: Blank Line: If the line is blank, this line will be skipped by the compiler. Blank lines are a good way to separate blocks of your code apart from other bloacks for ease of reading. Comment Line: By placing a semi-colon (;) as the first character of the line in column 0, all data until the end of the line will be ignored. In this way, you can enter comments so that when you come back to work on a program, you will have some idea of what you were trying to accomplish. Label Line: By entering just a keyword of your choice starting at column 0 of the line, you can enter a label. The first character of a label must be alphabetic. The rest of the label can consist of alphanumeric characters. The first 8 characters of the label are significant. That is, the labels TEST and TEST2 are considered different labels by ACOS while SHOWFILE2 and SHOWFILE8 would appear the same to ACOS since the first 8 characters are the same. Statement line: A statement line is always indented 1 space from the the left side. That is, at column 1, not column 0 like the previous line types. Statements are just entered on the line in the order you want them executed. If you wish to put multiple statements on a line, separate the statements with a colon (:). Statements may be typed in either upper,lower or mixed case. ------------------------- SPECIAL CHARACTERS There are several special characters that ACOS recognizes within your program code and uses them for different purposes. The following list show characters that have special meanings to ACOS. There are other characters which when encountered will be ignored. Any character including those below can be displayed by the program without problem, they just have special meanings when encountered outside the PRINT statement. Character Meaning space or blank = equals sign and also used for assignment statements + plus sign also used for adding strings - minus sign used for subtraction