home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
basic
/
compiler
/
asic
/
asic.doc
next >
Wrap
Text File
|
1994-03-01
|
312KB
|
9,638 lines
+--------------------------------------------------------------------+
| |
| A S I C (tm) 4.00 |
| "Its Almost Basic" |
| |
| |
| |
| Copyright 1993 |
| by |
| 80/20 Software |
| |
| All Rights Reserved |
+--------------------------------------------------------------------+
| ASIC 4.00 is provided as shareware. Under the shareware |
| concept, you can test a program before you buy it. If you find |
| it suitable for your needs and make use of this program, you are |
| expected to send a $20 registration fee. |
| |
| Feel free to distribute this software to others. However, you |
| may not charge for the distribution of this software to others |
| nor may you alter the software or this documentation. |
| |
| Registered users of any version of ASIC will receive a diskette |
| containing the current version of ASIC, plus may purchase future |
| updates at half of the normal registration price. A printed |
| manual is available to registered users for an additional $10.00. |
| |
| For further ordering information, please see the file ORDER.FRM, |
| included with ASIC. |
+--------------------------------------------------------------------+
| |
| Please send registration fees and suggestions to: |
| |
| 80/20 Software |
| P.O. Box 2952 |
| Raleigh, NC 27602-2952 |
| |
| |
| Please mention the version of ASIC in any correspondence |
| (This is ASIC Version 4.00) |
+--------------------------------------------------------------------+
| You can also send questions/comments on GEnie and Compuserve |
| via EMAIL: |
| |
| Compuserve 73065,1302 |
| GEnie D.VISTI |
| |
+--------------------------------------------------------------------+
| |
| DISCLAIMER: This software is provided "as is" without warranty |
| of any kind, either expressed or implied. |
| |
| Your registration fee entitles you to use this software on a |
| single computer. Site licenses are available, write for details. |
| |
| ASIC is a trademark of 80/20 Software |
+--------------------------------------------------------------------+
A S I C
Table of Contents
Chapter Title
1. Getting Started Page 5
Introduction Page 5
Installation Page 6
2. Tutorial Page 7
3. Integrated Editor/Compiler Environment Page 13
Introduction Page 13
ASIC Screen Contents Page 13
Menu Bar Processing Page 13
Mouse Usage Page 14
Getting Help Page 15
Menu Help Page 15
Keyword Help Page 15
File Menu Page 16
Open Page 16
DOS Shell Page 16
Save Page 16
Save As Page 16
Exit Page 16
Edit Menu Page 17
Begin Block Page 17
End Block Page 17
Search Page 17
Replace Page 17
Delete Block Page 17
Move Block Page 18
Copy Block Page 18
Search Again Page 18
Compile Menu Page 18
Compile Program Page 18
Full Program Listing Page 19
Printer Output Page 19
Symbol Table Page 19
Extended Math Page 19
Decimal Math Page 20
Debugging Code Page 20
View Compile Errors Page 20
Write Options To Disk Page 21
Advanced Options Sub-Menu Page 21
COM Output File Page 21
EXE Output File Page 21
OBJ Output File Page 22
Stack Size Page 22
Object Names Page 23
Library Names Page 23
LINK.EXE Path Page 23
Page - 1
Table of Contents (Continued)
Chapter Title
3. Integrated Editor/Compiler Environment (Continued)
Run Menu Page 24
Run Your Program Page 24
Breakpoint Toggle Page 24
Trace Page 24
Modify Variable Page 25
Watch Variable Page 25
Unwatch Variable Page 25
Abort Execution Page 25
Clear All Break/Watch Page 25
Program Arguments Page 26
Swap To User Screen Page 26
Status Line Page 26
Edit Window Page 28
Keyboard Usage Page 28
4 Using the Debugger Page 29
Introduction Page 29
Debugger Tutorial Page 29
Debugger Tips Page 35
5. Command-Line Compiler Options Page 37
Command Line Syntax Page 37
Compiler Options Page 38
Compiler Examples Page 42
Program Project File Page 43
6. Language Elements Page 44
Character Set Page 44
Constants, Variables, and Labels Page 46
Variables vs. Constants Page 49
Conversion Between Numeric Formats Page 50
7. Keyword Reference Page 52
ABS Page 52
ASC Page 52
BEEP Page 53
BLOAD Page 54
BSAVE Page 55
CALL Page 56
CHDIR Page 59
CHR$ Page 60
CLOSE Page 60
CLS Page 61
CODE Page 61
COLOR Page 62
COMMAND$ Page 63
COMSTAT Page 64
CSRLIN Page 65
DATA Page 66
DATE$ Page 67
DEFSEG Page 67
DIM Page 68
END Page 68
ENVIRON$ Page 69
FILEPOS Page 70
Page - 2
Table of Contents (Continued)
Chapter Title
7. Keyword Reference (Continued)
FIND Page 72
FOR/NEXT Page 74
GETDIR Page 75
GOSUB Page 76
GOTO Page 76
IF/THEN/ELSE/ENDIF Page 77
INKEY$ Page 79
INP Page 79
INPUT Page 80
INPUT# Page 82
INSTR Page 84
INT86 Page 85
KILL Page 87
LCASE$ Page 87
LEFT$ Page 88
LEN Page 88
LOCATE Page 89
LPRINT Page 90
LTRIM$ Page 91
MID$ Page 91
MKDIR Page 92
MOD Page 92
NAME Page 93
OPEN Page 93
OPENCOM Page 94
OUT Page 95
PEEK Page 95
POINT Page 96
POKE Page 97
POS Page 97
PRESET Page 98
PRINT Page 99
PRINT# Page 100
PSET Page 102
RANDOMIZE Page 102
READ Page 103
RECEIVE Page 104
REM Page 105
RESTORE Page 105
RETURN Page 106
RIGHT$ Page 106
RMDIR Page 107
RND Page 108
RTRIM$ Page 109
RUN Page 110
SCREEN Page 111
SEND Page 112
SOUND Page 112
SPACE$ Page 113
STR$ Page 113
STRING$ Page 114
Page - 3
Table of Contents (Continued)
Chapter Title
7. Keyword Reference (Continued)
TIME$ Page 115
TIMER Page 116
UCASE$ Page 117
VAL Page 117
VARPTR Page 118
WHILE/WEND Page 118
WIDTH Page 119
ZBIT Page 119
ZMODE Page 120
8. Compatibility with BASICA/GWBASIC Page 121
9. Technical Details/Tips Page 124
Compiler Limits Page 124
Compiler Operation Page 125
Memory Optimization Page 125
Performance Optimization Page 126
Debugger Limits Page 127
Debugger Operation Page 127
Debugger Overhead Page 127
Storage Formats Page 128
Memory Map - COM File Page 130
Memory Map - EXE File Page 131
10. Mixed Language Programming Page 133
Overview Page 133
Developing Assembler Routines Page 133
Assembling Your Subroutine Page 134
Developing the Calling ASIC Progrm Page 134
Building the Executable Program Page 134
Other Link Options Page 136
Debugging Page 136
11. Error Messages Page 137
Compiler Errors Page 137
Fatal Errors Page 137
Non-Fatal Warnings Page 144
Run Time Errors Page 149
System ERROR Code Values Page 150
Page - 4
A S I C
Chapter 1
Getting Started
INTRODUCTION
Welcome to ASIC!
ASIC is a "BASIC" programming language compiler for IBM PCs and
compatibles. It includes an integrated full screen editor, from which
you can edit, compile, and debug your programs. Or, at your option, you
can use your own text editor, and compile your programs from the MS DOS
command line.
ASIC supports a large subset of BASICA and GWBASIC. It supports
over 80 BASIC statements, decimal, integer and string variables and
arrays. It will compile your programs at high speed, and the code it
generates is fast and compact. The syntax of each ASIC statement is
generally a valid subset of the syntax used by BASICA and GWBASIC
(exceptions are noted in Chapter 8.)
All you need to get started is:
1) ASIC
2) IBM PC or 100% Compatible
3) 405k Available Memory
4) Two floppy disk drives
<or>
One hard disk drive and one floppy disk drive
Optional:
1) Microsoft Compatible Mouse
The first step is to install ASIC as described below. Then,
proceed to Chapter 2 for a brief ASIC tutorial. Following that you can
read the remainder of the documentation straight through, or refer to it
as you need it. Have Fun!
Page - 5
INSTALLATION
To conserve disk space, ASIC files are shipped in compressed format.
So, before you can run ASIC, you must first install it using the ASIC
INSTALL.EXE program. To do so, follow the instructions below. Commands
you type are listed in ALL CAPS . Where you see <ENTER>, you should
press the <ENTER> key on your keyboard.
If you are installing to a 3 1/2" diskette or a 1.2 megabyte 5 1/4"
diskette, you will need 1 blank formatted diskette. If you are
installing to a 360k diskette, you will need 2 formatted diskettes for a
full install (or 1 formatted diskette if you opt to not install the
documentation). If you are installing to a hard disk, about 500k bytes
are required for a full install (about 150k is required for a minimal
install). To install:
1) Insert your ASIC diskette into your floppy drive.
2) If the ASIC diskette is in drive A, type: A: <ENTER>
If the ASIC diskette is in drive B, type: B: <ENTER>
3) Change the default directory by typing: CD \ <ENTER>
4) Run the ASIC INSTALL.EXE program by typing: INSTALL <ENTER>
The ASIC install program will prompt you for the information it needs.
You will be asked for the following information:
1) The drive and directory containing the ASIC installation files.
2) The drive and directory you want ASIC installed to.
You will be offered the option of installing (or not installing) the
ASIC documentation files and sample programs. It is recommended that
you install all options. Note: If you do not install the documentation
files, the online help function will not be available. If you are
installing to a 360k 5-1/4" floppy diskette, the online help function
will not be available inside the integrated editor.
You may rerun the INSTALL program later to install options that you
skipped the first time.
Page - 6
A S I C
Chapter 2
Tutorial
ASIC programs look very much like regular "BASIC" programs which you are
probably already familiar with. The one very noticeable difference is
that ASIC programs have no line numbers. Let's take a look at a very
simple program written both in GWBASIC/BASICA and in ASIC:
GWBASIC/BASICA ASIC
-------------------------+----------------------------------
|
10 I=I+1 | ADDONE: I=I+1
20 PRINT I | PRINT I
30 IF I<100 THEN 10 | IF I<100 THEN ADDONE:
-------------------------+----------------------------------
Both of these programs do the same thing. They display the numbers
from 1 to 100. However, notice that ASIC allows you to use descriptive
labels (ADDONE) instead of a line number (10). These labels can be up
to 80 characters long! Also note that the ASIC "PRINT" and "IF"
statements were indented only for increased program readability. The
ASIC program could just as well have been written as:
ASIC
------------------------------
ADDONE:I=I+1
PRINT I
IF I<100 THEN ADDONE:
------------------------------
We could have made our variable names longer. Instead of "I" we
could have chosen "SECONDS" or "VELOCITY", or some other name up to 80
characters in total. In ASIC, variable names, labels, and string
constants can all be up to 80 characters in length.
Well, now that we've seen a basic ASIC program, let's try to enter
and run a slightly larger program. The program we will be working with
will print the message "HELLO yourname" in 256 color combinations. If
you have a monochrome display card, don't worry, the program will work,
but instead of seeing different colors you'll see characters with
different attributes, such as blinking, underlined, etc.
Let's get started. If you haven't done so already, install ASIC as
described in Chapter 1. Now then, writing an ASIC program involves
these three steps.
1. Write your program.
2. Compile your program.
3. Run/Test your Program.
Page - 7
These three steps can all be performed from within the ASIC
Integrated Environment. Before we proceed with our "Hello yourname"
Program, let's go over some conventions.
In the following section:
FLOPPY TYPE--> Means that only 2-floppy disk system users
should type this line.
HARD TYPE--> Means that only hard disk system users
should type this line.
TYPE--> Means that both floppy and hard disk users
should type this line.
X> This is a representation of the prompt from
PC-DOS or MS-DOS. Floppy Disk Users will
actually see "A>" for a prompt. Hard Disk
Users will see "C>" for a prompt.
<enter> Means that you should press the <enter>
or <return> key on your keyboard.
<?> Text enclosed between the "<" and the ">"
symbols indicate a key to type. Don't type
the "<" or ">" symbols. For example, if the
tutorial lists "<F1>", your should press the
"F1" key on your keyboard.
NOTE: Floppy Disk users need to insert their ASIC Compiler diskette in
Drive A: at this point, and a blank diskette in Drive B: (See the
Installation section for more information)
The tutorial uses the keyboard for all commands, but includes a few
notes on mouse usage. For more information on using the mouse with ASIC
see the "MOUSE USAGE" section in Chapter 3.
Let's begin:
FLOPPY TYPE--> A: <enter>
HARD TYPE--> CD C:\ASIC <enter>
The computer should respond:
X>
Now enter the command to invoke ASIC:
TYPE--> ASIC <enter>
You are now in ASIC. The top line is the Menu Bar. The bottom line is
the Status Line. Chapter 3 describes this in more detail. For now,
we'll just describe a couple of features on these lines.
Page - 8
The status line indicates that the current mode is "INSERT". This means
that any characters you type on a line will be inserted between the
existing characters. If you press the <INS> key on the keypad, ASIC
will toggle to its other mode, OVERSTRIKE. In this mode, when you type
a character, it overlays the character that was there before. Each time
you press the <INS> key, ASIC will toggle between the INSERT and
OVERSTRIKE modes.
You can open the menus listed on the "Menu Bar" by holding down the ALT
key while typing the Red Capitalized letter of the menu you wish to
open. For example, to open the File menu, press <ALT><F>. Try it now:
TYPE--> <Alt><F>
The "File" menu will pop open. You can select a menu option from that
menu by typing the capitalized letter of the option, or by using the
arrow keys on your keypad to highlight the option you want and then
pressing <enter>.
MOUSE USERS: If you have a mouse, you can open a
menu by clicking the left mouse button on the menu
name. For example, to open the "File" menu,
position the mouse pointer anywhere on the word
"File", and click the left button.
If you are not sure what the menu option will do, you can press <F1> and
ASIC will display some help information for the highlighted menu option.
When you opened the File menu, the first option on that menu, "Open" was
highlighted. Let's get some help on "Open":
TYPE--> <F1>
ASIC will display some help information on "Open". Let's close the help
window now:
TYPE--> <ESC>
The help window will close. The <ESC> key will always let you escape
from any menu or help screen in ASIC, without taking any action.
MOUSE USERS: To close a menu you can click the
right mouse button. In fact, you can always use the
right mouse button to cancel an option, instead of
pressing the <ESC> key, if you prefer.
Let's also close the file menu for now:
TYPE--> <ESC>
The "File" menu should have closed. By the way, in addition to the menu
help, ASIC provides additional online help. If you need general ASIC
help, press the <F1> key for a quick summary of some of ASIC's features:
TYPE--> <F1>
Page - 9
ASIC will display some general help. From this screen, we can also
retrieve additional information about BASIC statements such as PRINT or
GOSUB. Let's bring up an index of these statements.
TYPE--> <F1>
ASIC has opened a help index screen. From this screen we can use the
arrow keys to highlight any ASIC keyword and obtain more information for
that keyword by then pressing enter. We won't do that now, but don't
forget that this screen is available. Chapter 3 of the ASIC Reference
Manual describes all of the online "HELP" features available in ASIC and
provides a full description of the ASIC Editor Commands which are
available. Exit the help menu:
TYPE--> <ESC>
Entering a program in ASIC is simplicity itself. We'll simply type in
each line, pressing <enter> at the end of each line. If you make a
typing mistake, just use the arrow keys to move to the error, and type
in the correction. Use the <DEL> or <Backspace> keys to delete any
unwanted characters from the screen.
Make sure the status line says "Mode: Insert". This is the default mode
in ASIC. If it doesn't, press the <INS> key until it does. Now let's
enter our program (the program below intentionally contains an invalid
ASIC statement. We'll correct the line later in the tutorial, for now,
type in the program exactly as it's listed below):
TYPE--> CLS <enter>
TYPE--> PRINT "Please enter your name"; <enter>
TYPE--> INPUT YOURNAME$ <enter>
TYPE--> FOR I=1 TO 16 <enter>
TYPE--> FOR J=1 TO 16 <enter>
TYPE--> COLOR I,J <enter>
TYPE--> PRINT "HELLO "; <enter>
TYPE--> PRINT YOURNAME$; <enter>
TYPE--> NEXT J <enter>
TYPE--> NEXT I <enter>
TYPE--> CLS <enter>
TYPE--> THE END <enter>
There, that was easy. Now, let's compile our program. To do it, we'll
open the "Compile" menu, and select the "Compile program" option:
TYPE--> <ALT><C>
The "Compile" menu will pop open. The first option, "Compile program"
can be selected by typing the option letter which is capitalized "C", or
by moving the highlight bar to this option and pressing the <enter> key.
Since the highlight bar is already on this option, let's just press
<enter>:
MOUSE USERS: To select an option with the mouse,
position the mouse pointer on the option name and
click the left mouse button.
TYPE--> <enter>
Page - 10
Since we didn't specify a file name when we invoked ASIC, ASIC will now
ask for a file name (so it can save your program before calling the
compiler):
FLOPPY TYPE--> B:TUTOR.ASI <enter>
HARD TYPE--> TUTOR.ASI <enter>
Note that ASIC requires that your programs be stored in files ending
with the extension ".ASI". Had we entered "TUTOR" for our program name,
ASIC would have appended the letters ".ASI" for us. If we tried to
provide a different extension, such as "TUTOR.SRC", ASIC would display
an error message.
Once you select the "Compile program" option, you'll see the ASIC
compiler screen appear. It will display a count of the lines compiled,
and when it is done, it will return to the ASIC editor.
If ASIC detected any errors, it will display the first error message at
the bottom of the editor screen. It will also highlight the line in
your program which is in error. In this case the line "THE END" was
flagged with the error message "Syntax Error". Of course, that line
should have been entered simply as "END".
That should be easy enough to fix. Let's exit the error menu by
pressing the <ESC> key:
TYPE--> <ESC>
The error menu has disappeared, and our cursor is now on the erroneous
line. To fix the line:
TYPE--> <DEL><DEL><DEL><DEL>
That should do it. The last line of our program should now read "END".
Before we continue, let's assume we knew the name of the END command,
but could not remember the proper syntax for it. ASIC provides an
online lookup for each ASIC statement. With the cursor positioned
somewhere on the word "END":
TYPE--> <Ctl><F1>
ASIC should have opened a help window describing the "END" statement.
To return to your program press the <ESC> key.
TYPE--> <ESC>
The help window should have disappeared and you should see your program
displayed again. Let's recompile the program:
TYPE--> <ALT><C>
TYPE--> <enter>
Page - 11
This time you should see the message "No Compiler Errors". If you
didn't, check your spelling and recompile the program until you receive
this message. Press <ESC> to remove the "No Compiler Errors" Window.
Now let's run the program. To do so, we'll open the "Run" menu, and
select the "Run your program" option.
TYPE--> <ALT><R>
TYPE--> <r>
This time, we just entered the capitalized letter from the menu option
"Run your program". Your computer screen should now prompt you to
"Please enter your name?". Go ahead and enter your name now:
TYPE--> yourname <enter>
You should see "HELLO yourname" printed in various color combinations,
and then the ASIC editor screen will reappear. Well, that's all there
is to writing, compiling, and running an ASIC program. Now, to exit
ASIC, open the "File" menu and select the "eXit" option.
TYPE--> <ALT><F>
TYPE--> <X>
You should see your MS DOS prompt once again. By the way, now that
you've successfully compiled the program, you can execute it directly
from MS DOS. Let's try it:
HARD TYPE--> TUTOR <enter>
FLOPPY TYPE--> B:TUTOR <enter>
Well, that's a brief introduction to ASIC! Next, you might want to read
Chapter 3, "Integrated Editor/Compiler Environment" to learn about the
many other features available in the ASIC editor. Following this you
should read Chapter 4 which explains how to use the ASIC Debugger.
Chapter 4 includes another short tutorial in which you debug a program.
The remaining chapters provide reference material which you can
either read, or just refer to as needed. Chapter 5 explains how to
compile programs directly from the command line of DOS. Chapters 6-8
describe the BASIC statements which are supported by ASIC. Chapter 9
provides some technical information about ASIC. Chapter 10 explains how
to call assembly language object modules from an ASIC program. Chapter
11 provides more descriptive information for ASIC error messages.
Hope you enjoy programming in ASIC!
Page - 12
A S I C
Chapter 3
Integrated Editor/Compiler
Environment
INTRODUCTION
The ASIC integrated environment lets you edit, save, compile, and
debug your ASIC programs without ever leaving ASIC! This chapter will
explain the usage of the integrated environment.
ASIC SCREEN CONTENTS
ASIC divides the screen into three parts. The top line is called
the "Menu Bar". All of the menus available to you are listed on this
line. The bottom line is called the "Status Line". It continuously
displays some important program information. The middle 23 lines are
the "Edit Window". This is the section of the screen where you can make
changes or additions to your program.
MENU BAR PROCESSING
Currently, there are four menus available. The "File" menu allows you
to load/save your existing program files to/from disk. It is also used
to exit ASIC. The "Edit" menu contains various editing commands which
are available. The "Compile" menu is used to compile your program, set
compiler options, and to view compiler errors. The "Run" menu allows
you to run your programs, and test them using the ASIC debugger.
To open a menu, hold down the <ALT> key and type the first letter
of the menu. The menu will pop down and display the options available
on that menu. If you want to close the menu without taking any action,
press the <ESC> key. If you wish to open a different menu without first
closing the current menu, press the left or right arrow keys.
Otherwise, to select an option, type the capitalized letter of the
menu option. For example, on the "File" menu, to select the "eXit"
option, type an "X" or an "x". Another way to select an option is to
move the "Highlighted Bar" down to the option you wish to select, and
press the <enter> key.
Some functions may be accessed outside of the menus with short cut
keys. For example, the "eXit <ALT-X>" function in the file menu can
be selected by holding down the ALT key and tapping the "x" key. The
short cut keys are listed on the menus following the option name (they
are enclosed in brackets as in <F2> or <ALT-X>). Not all menu options
have short cut keys. Note that these short cut keys do not operate when
a menu is open. (A list of these short cut keys is presented later in
this chapter in the Keyboard Usage Section).
Page - 13
MOUSE USAGE
If you are familiar with other Mouse Programs, such as Microsoft
Windows, you will find that you will use the mouse in much the same way
in ASIC.
Menus can be opened by moving the mouse pointer to a menu name on
the menu bar, and clicking the left mouse button. Once the menu is open
you can select an option by positioning the mouse pointer on the desired
option, and clicking the left mouse button. To close a menu without
selecting an option, click the right button.
A new feature added to several screens, is the "scroll bar".
Scroll bars let you scroll through lists of items in screen window. A
vertical scroll bar appears on the right side of the main editor window
(and on the file open, save, and some help screens). At the top of the
scroll bar is a small arrow that points upwards. At the bottom of the
scroll bar is a small arrow that points downwards. Between the two
arrows is a small square, called a slider.
At the bottom of the main edit window there is also a horizontal
scroll bar, that lets you scroll the edit buffer left and right.
To use the scroll bar, click the left mouse button on one of the
arrows to scroll the contents of a window by one line. Click on the
shaded area between the arrows to scroll a page at a time. You can also
"drag" the slider to any position on the scroll bar to scroll the window
to the same relative position. To drag the slider, position the mouse
pointer on the slider, hold down the left mouse button, and move the
mouse pointer to the desired position on the scroll bar. Once at the
desired position, release the mouse button.
To select a block of text in the editor, position the mouse pointer
on the first line in the block you wish to select. Press and HOLD the
left mouse button until the first line is highlighted. Continue holding
the left mouse button down, and drag the mouse pointer to the ending
line of the block. When you reach the last line you want to include in
the block, release the left mouse button.
When responding to dialog box messages, the left mouse button is
the same as pressing <ENTER>, and the right mouse button is the same as
press the <ESC> key.
To get context sensitive help for menu options or ASIC keywords,
press and briefly HOLD the right mouse button.
To position the keyboard cursor, move the mouse pointer to the
desired location in the edit window, and click the left mouse button.
The cursor will move to the mouse pointer location.
Page - 14
GETTING HELP
ASIC provides "online" help within the integrated environment to assist
you with keyboard usage, menu options, and ASIC keywords. This section
tells you how to access this online help.
General Help
General describes the usage of the keyboard in ASIC. Keyboard keys
which perform ASIC functions are described in this section. Access
general help by pressing Function key <F1>. Pressing <F1> a second time
will display an ASIC keyword index. You can get additional help on
individual ASIC keywords from this screen. This information includes a
description of what the keyword does, and the keyword syntax.
MOUSE USERS: You can select help by positioning the
mouse pointer on the "F1=Help" option on the menu
bar, and clicking the left mouse button.
Menu Help
If you open a menu, but you are not sure what a certain menu option
does, you may display a description of the highlighted menu option by
pressing the <F1> key. Doing so will open a help window which describes
the menu option. Press <ESC> to exit the help screen and return to the
menu.
MOUSE USERS: You can get help for a menu option with the
mouse as follows. Position the mouse pointer on the menu
option, and press and briefly HOLD the right mouse button.
Keyword Help
Can't remember the syntax for a particular ASIC keyword? Well, help is
just a keystroke away. Position the cursor on the keyword in the edit
buffer. Then, hold down the <Ctl> key and press the <F1> key.
ASIC will display a description of the keyword, and describe proper
syntax for that keyword. For example, if you tried to compile a
program, but received a syntax error on the keyword "PRINT" in your
program, you could obtain help on the "PRINT" statement by using the
arrow keys to position the cursor anywhere on the word "PRINT" and then
pressing <Ctl-F1>. If ASIC cannot find the keyword (eg, say the cursor
was positioned on a variable called "APPLES", which is not an ASIC
keyword), then ASIC will display a list of valid keywords. Use the
cursor keys to highlight one of these keywords and press <enter> to
retrieve help for the highlighted keyword. You may also access this
keyword help list by pressing the <F1> key twice from within the editor.
MOUSE USERS: You can also get keyword help using the mouse.
Position the mouse pointer on the keyword, and press and
briefly HOLD the right mouse button.
Now let's describe the options available on each menu.
Page - 15
FILE MENU
"Open... <F3>" Option
This option allows you to open an existing ASIC file and load it
into the ASIC edit buffer where you can modify it. If you select this
option another window will open to ask you the file name. If you don't
wish to open a file, you can press <ESC> to close the menu without
taking any action. Otherwise, enter an ASIC file name, and press the
<enter> key. There is a second way to select a file to open, if the
file already exists. You can select the file name from the list
displayed, by using the arrow keys or mouse to scroll through the list
of file names. To select a file from the list, press <ENTER>, or
position the mouse pointer on the file name, and click the left mouse
button. This option may also be selected outside of the menu by
pressing the <F3> key.
"Dos shell" Option
This option allows you to temporarily exit to MS DOS to execute one
or more DOS commands or other programs. When you are ready to return to
ASIC, type EXIT <enter>.
"Save <F2>" Option
This option allows you to write the changes you've made to your
program back to the file. Changes you enter in the ASIC editor are made
to memory only. You must select this option before your changes will
become permanent. Note: Your file is saved to disk automatically
whenever you compile it or run it, if the file has been modified. This
option may also be selected outside the menu by pressing the <F2> key.
"save As..." Option
This option will allow you to write the changes you've made to the
program in the edit buffer to a new file. You will be prompted to
provide ASIC with a new file name. If you want to overlay an existing
file, you can select the file name from the list displayed by using the
arrow keys or mouse to scroll through the list of file names. To select
a file from the list, press <ENTER>, or position the mouse pointer on
the file name, and click the left mouse button. BE CAREFUL--WHEN YOU
SELECT A FILE FROM THE LIST, YOU ARE TELLING ASIC TO OVERLAY AN EXISTING
FILE.
"eXit <Alt-X>" Option
This option will allow you to exit from ASIC back to MS DOS. ASIC
will ask you if you wish to save your file before you exit. This option
may be selected outside this menu by pressing <ALT-X>.
Page - 16
EDIT MENU
"Begin block" Option
This option will allow you to mark the beginning of a block of text
for use with the block delete, copy, and move commands. To mark a block
of text, move the cursor to the first line of the block, and then select
this option. The beginning line of the block will be highlighted on the
screen. Next, move the cursor to the ending line of the block, and
select the "End block" option from this menu. All of the lines in the
block will be highlighted. This block of lines can now be "moved",
"copied", or "deleted" using the block commands. If you have a mouse,
you can select text without using the "Begin Block" and "End Block"
options. To select a block of text with the mouse, position the mouse
pointer on the first line in the block, press and HOLD the left mouse
button until the line is highlighted, and (while continuing to hold down
the left mouse button) drag the mouse pointer to the ending line of the
block. Once you reach the ending line of the block, you may release the
left mouse button. The block should be highlighted on the screen.
"End block" Option
This option will allow you to mark the end of a block of text.
Refer to the "Begin block" Option for more information.
"Search..." Option
This option allows you to locate a string of characters in the edit
buffer. When you select this option, ASIC will ask you for a search
string which can be up to 30 characters in length. ASIC will then
search forward from the current line until it finds the string or
reaches the end of the edit buffer. If it finds the string, the cursor
will be placed on the line containing the string.
"Replace..." Option
This option will allow you to replace one or more occurrences of a
string of characters with another set of characters. When you select
this option, ASIC will ask you for a search string which can be up to 30
characters in length. ASIC will then ask you for the string of
characters which is to replace the search string. Finally, ASIC will
ask you to specify how many occurrences of this search string are to be
replaced (from 1-9999). ASIC will search forward from the current line,
and briefly display each line as it modifies it. If it reaches the end
of the edit buffer before it has replaced the number of occurrences
you've specified, ASIC will display an "End of Buffer" message, and
stop.
"Delete block" Option
This option will delete a block of lines. Refer to the "Begin
block" option for information on marking a block of lines. If you
haven't marked a block of lines, selecting this option will have no
effect.
Page - 17
EDIT MENU (Continued)
"Move block" Option
This option will move a block of lines to a new location in the
edit buffer. Refer to the "Begin block" option for information on
marking a block of lines. If you don't mark a block of lines, selecting
this option will have no effect. Once you have marked a block of lines,
move the cursor to the location in the edit buffer where you want the
lines moved. Selecting the "Move block" option will result in the block
of lines being deleted from their current location, and moved to the
buffer at the line following the cursor. ASIC will not overlay lines,
it will insert enough blank space to hold the relocated text.
"Copy block" Option
This option is the same as the "Move block" option, with one
exception. After moving the block, ASIC does NOT delete the original
block of lines. Use this option to clone a block of text. Refer to the
"Begin block" option for information on marking a block of text.
"search Again <CTL-L>" Option
This option will allow you to search for the next occurrence of the
last string you searched for with the "Search" Option, without retyping
the previous search string. This option may also be selected outside of
the Edit Menu by pressing <CTL-L>.
COMPILE MENU
"Compile program <F10>" Option
Use this option to have ASIC compile the program which is currently
loaded in the edit buffer. If the compile is successful, ASIC will
display the message "No Compiler Errors". Otherwise, it will display
the first error message (see "View compile errors" option). ASIC will
automatically save your program before calling the compiler. This
option may also be selected outside of the menu by pressing function key
<F10>.
"Advanced options" Option
Select this option to bring up a menu of compiler options for the
advanced ASIC user.
Page - 18
COMPILE MENU (Continued)
"Full program listing" Option
This menu option, and the next six options are used to toggle
various compiler options on or off. When the option is on, you will see
a "check mark" symbol next to the option. This compiler option will
cause ASIC to display each source line as it compiles it. This option
will slow down the compile, but since ASIC also writes these lines to a
listing file, this option can be used to create a compile listing. The
compile listing will be contained in a file called "progname.LST", where
"progname" is the name of your program.
"Printer output" Option
This menu option will toggle the "Printer output" compiler option
on or off. When the option is on, you will see a "check mark" symbol
next to the option name. This compiler option will cause compiler
messages to be printed on your printer.
"Symbol table" Option
This menu option will toggle the "Symbol table" compiler option on
or off. When the option is on, you will see a "check mark" symbol next
to the option name. This compiler option will cause ASIC to create a
symbol table file called "progname.SYM", where "progname" is the name of
your program. The symbol table is a list of all variables, labels, and
internally created compiler addresses.
"Extended math" Option
By default, ASIC will permit regular integer variables. These
variables are very efficient and only require two bytes (or characters)
of memory storage. However, these integers can only hold numbers in the
range of -32767 to +32767. For many programs this is sufficient.
However, there may be cases when you want to represent larger integer
values. Because of this, ASIC provides a "long" integer data type. The
long integer requires four bytes of memory storage. However, it can
hold a much larger range of numbers. A long integer can store numbers
in the range of -2,147,483,647 to +2,147,483,647. When you need to use
long integers in your program, you need to turn on this option, so that
ASIC can generate the proper code. When the option is on, you will see
a "check mark" symbol next to the option name. If this option is not
turned on and your program contains long integers, ASIC will generate a
compiler error. If this happens, just turn this option on, and re-
compile your program. To "create" a long integer variable or constant,
simply append the "&" character to the variable name or constant
value(eg, SAMPLEVAR& or 123456&). For further information on using long
integers, refer to Chapter 6, "Language Elements", of the ASIC Manual.
Page - 19
COMPILE MENU (Continued)
"decimal Math" Option
Select this option if your program needs to perform decimal math.
When the option is on, you will see a "check mark" symbol next to the
option name. When you select this option, ASIC generates supporting
code for your program which supports the "Decimal" variable type.
Decimal variables may be identified by adding a "@" symbol following the
variable name. (eg, BALANCE@). "Decimal" type variables can contain
numbers in the range of +999,999,999,999.99999 to
-999,999,999,999.99999. Unlike floating point numbers in GWBASIC or
BASICA, ASIC "Decimal" variables do not exhibit rounding errors. Full
precision is maintained through all 5 decimal places (digits following
the fifth decimal place are truncated). For further information on
using decimal variables, refer to Chapter 6, "Language Elements", of the
ASIC Manual. If this option is not turned on and your program contains
decimal variables or constants, ASIC will generate a compiler error. If
this happens, just turn this option on, and re-compile your program.
"Debugging code" Option
This menu option will toggle the "Debugging code" compiler option
on or off. When the option is on, you will see a "check mark" symbol
next to the option name. This compiler option will cause ASIC to
generate code required by the ASIC debugger to allow you to set
breakpoints, single step through your program, and view/modify program
variables. This option is "on" by default in the integrated
environment. You should leave this option on while you are debugging
your program. When you have everything working properly, you should
turn it "off" and recompile your program. This will reduce the size of
your program slightly, and will make it run faster (of course, you can't
use the debugger with it, since there is no debugging information
available to ASIC any more. If you need to debug your program again,
just recompile with the this option turned "on" again).
"View compile errors" Option
When you wish to examine the errors from a previous compile of your
program, select this option. If no errors exist, ASIC will so inform
you. Otherwise, ASIC will display the first error message at the bottom
of the screen, and it will highlight the line of your program which
corresponds to that error. If you wish to correct the program line,
press the <ESC> key. The cursor will be positioned at the beginning of
that program line. You may also view subsequent compiler errors by
pressing the <ENTER> key instead of the <ESC> key.
Page - 20
COMPILE MENU (Continued)
"Write options to disk" Option
Writes current compiler options to a file called ASIC.CFG. When
you enter ASIC, ASIC always reads options from this file. Note that
when you open a program, ASIC first checks for a "progname.PRJ" file.
The ".PRJ" file ,if found, will override ASIC.CFG. Since ASIC
automatically creates/updates the ".PRJ" file whenever you save a
program, normally the only time that the ASIC.CFG options will be used
is when you enter the editor with a new file. Once you save a program
the first time, ASIC creates the custom ".PRJ" file for the program.
Think of the ASIC.CFG file, then, as the default options for new
programs.
ADVANCED OPTIONS
(SUBMENU OF "COMPILE" MENU)
When you select the "Advanced options" option from the "Compile"
menu, this sub-menu will be displayed. These give the advanced
programmer the ability to tell ASIC how to produce the compiler output
files.
"Com output file" Option
This option, the "Exe output file", and the "Obj output file"
options allow you to tell ASIC what type of output file to produce when
compiling. Only one of these three options may be selected at the same
time. The option that is currently selected will be preceded with a
small dot. This option is the default option. When you select this
option, ASIC will produce a ".COM" output file. This file can contain a
maximum of 64k bytes of program code and data.
"Exe output file" Option
This option, the "Com output file", and the "Obj output file"
options allow you to tell ASIC what type of output file to produce when
compiling. Only one of these three options may be selected at the same
time. The option that is currently selected will be preceded with a
small dot. When you select this option, ASIC will produce a ".EXE"
output file. This output file can contain up to 64k program code, 64k
program data, and 64k stack. ASIC does not produce an intermediate OBJ
file, and ASIC uses its internal linker. Unlike the "Obj output file"
option, ASIC does not use the DOS LINK command to produce the EXE file,
and no OBJ file is created when using this option. Turn this option on
when: 1) you want to compile large programs, 2) you want to minimize
the amount of memory required when your program runs, or 3) you want to
adjust the program stack size. The only drawback to this option, is
that the EXE file is slightly larger on disk than the COM file, and that
ASIC only asks DOS for the amount of memory your program needs. With
COM files, DOS gives your program all available memory. Note: If you
compile a program with this option turned off, and then turn this option
on, be sure to recompile your program.
Page - 21
ADVANCED OPTIONS (Continued)
"Obj output file" Option
This option, the "Exe output file" option, and the "Com output
file" option allow you to tell ASIC what type of output file to produce
when compiling. Only one of these three options may be selected at the
same time. The option that is currently selected will be preceded with
a small dot. When you select this option, ASIC will produce a ".OBJ"
output file that is in the standard MS DOS LINK format. This file is
not directly executable. First, it must be "LINK"ed into a ".EXE" file.
ASIC will attempt to call the MS DOS LINK program for you. To do so, it
must be able to locate the "LINK.EXE" program (provided with MS DOS).
It will search for this file in the current directory, and the "C:\DOS"
subdirectory. If it can't find the file there, it will not be able to
link your program. ASIC does provide a new option, to let you specify
the location of the LINK.EXE program (see "Link.EXE path" option). You
may be wondering why you'd want to go through all of the bother of using
this option, when you could create an EXE file directly using the "EXE
output file" option. Well, normally you will want to use the "EXE
output file" option. But, the "OBJ output file option provides one
important advantage. Using this option, you can use the CALL SUB
statement in your programs, and you can tell ASIC to link in other OBJ
files (created with an assembler) with your ASIC program. See chapter
10, "Mixed Language Programming", of the ASIC manual for more
information. Also, refer to the "obJect names..." option, the "liBrary
name..." option, and the "Link.exe path..." option on this same menu.
"Stack size..." Option
This option will allow you to adjust the size of the stack that
ASIC generates for your program. When you select this option, you will
be prompted for the number of bytes to allocate to the stack in your
program. If you select a number that is too small for your program's
needs, the results when you attempt to run your program will be
unpredictable. The ASIC defaults are 2000 bytes (4000 bytes in
debugging mode). Note that if you compile with debugging mode on and
specify a stack size of less than 4000 bytes, ASIC will ignore your
stack size and continue to use 4000 bytes. This option has no effect
when you are using the "Com output file" option.
Page - 22
ADVANCED OPTIONS (Continued)
"obJect names..." Option
This option allows you to identify other object file names that
ASIC should pass to the DOS LINK.EXE program. This option is ignored by
the compiler unless you are compiling with the "Obj output file" Option.
When you select this option, ASIC will prompt you for a list of object
names. Each object file name should be separated from each other by a
"+" sign. For example, to identify OBJECT1.OBJ and OBJECT2.OBJ you
would enter: OBJECT1.OBJ+OBJECT2.OBJ for the object names. Since the
LINKer expects the file extensions to be ".OBJ", you can omit the
extension as long as it is ".OBJ". For example, we could have entered:
OBJECT1+OBJECT2. By default, the linker will assume that the object
files will be in the current directory, so if they're somewhere else, be
sure to include the full path, as in:
C:\OBJECT\OBJECT1+C:\OBJECT\OBJECT2. Refer to the "Mixed Language
Programming" chapter of the ASIC Manual for more information.
"liBrary names..." Option
This option allows you to identify object program libraries (such
as those built with the Microsoft LIB command) that ASIC should pass to
the DOS LINK.EXE program. This option is ignored by the compiler unless
you are compiling with the "Obj output file" Option. When you select
this option, ASIC will prompt you for a list of library file names.
Each library file name should be separated from each other by a "+"
sign. For example, to identify LIB1.LIB and LIB2.LIB you would enter:
LIB1.LIB+LIB2.LIB for the library names. Since the LINKer expects the
file extensions to be ".LIB", you can omit the extension as long as it
is ".LIB". For example, we could have entered: LIB1+LIB2. By default,
the linker will assume that the library file will be in the current
directory, so if the libraries are elsewhere, be sure to include the
full path, as in: C:\LIB\LIB1+C:\LIB\LIB2 for example. Refer to the
"Mixed Language Programming" Chapter of the ASIC Manual for more
information.
"Link.exe path..." Option
This option is used to tell ASIC where to find the MS DOS LINK.EXE
program. This option is ignored by the compiler, unless you are using
the "Obj output file" Option. When you use the "Obj output file"
Option, ASIC utilizes the LINK.EXE program, which is provided with MS
DOS, to link your ASIC program and additional object files into an MS
DOS EXE file. If you do not provide a path, ASIC will attempt to find
LINK.EXE under the current directory, and under the "C:\DOS" directory
(if applicable). If it can't find the program in either place, the EXE
file will not be built. When you select this option, you will be
prompted to enter the directory in which ASIC may find the LINK.EXE
program. For example, if you determined that the LINK.EXE program is
stored under "C:\UTIL" on your hard disk, you would enter: C:\UTIL for
this option. On future compiles, ASIC will look for the LINK.EXE file
in the "C:\UTIL" directory. Instead of using this option, you may also
copy the LINK.EXE file to your ASIC directory.
Page - 23
RUN MENU
The "Using the ASIC Debugger" Chapter has additional information on
the debugger and it's options. You may wish to refer to it, should you
need more information than is provided below.
"Run your program <F5>" Option
After you have successfully compiled your program, you can select
this option to cause ASIC to load and execute your program. After your
program ENDs, ASIC will return you to the editor. ASIC will save the
edit buffer before loading and executing your program. If you are
running a program containing debugging code, this option will cause ASIC
to run your program up to the first breakpoint it encounters, or through
the end of your program if you haven't set any breakpoints. If you are
already "paused" at a breakpoint, selecting this option will cause your
program to resume execution at the statement following the breakpoint,
and run up to the next breakpoint or to the end of your program, if no
further breakpoints are encountered. This option may also be selected
outside of the "Run menu" by pressing function key <F5>.
"Breakpoint toggle <F9>" Option
If you have compiled your program with the "Debugging code" option
turned on, you may use this option to set breakpoints. You can have up
to 20 breakpoints active at a time. When you run your program with
breakpoints set, ASIC will pause your program when it tries to execute a
line on which you have set a breakpoint. At this time, you can view or
modify variables, or view the screen output produced by your program.
You can then resume program execution by selecting the "Run your
program" option from the run menu. If you select this option and the
current statement in the edit buffer already has a breakpoint set, then
the breakpoint for that source statement will be removed (toggled off).
Lines at which you have set a breakpoint will be displayed in reverse
video. Also, when you run your program and ASIC stops at a breakpoint,
ASIC will display the next line to execute in reverse video on the
second line of the screen with a red background (underlined if you have
a monochrome system). This option may also be selected outside of the
"Run" Menu by pressing function key <F9>.
"Trace <F8>" Option
If you have compiled your program with the "Debugging code" option
turned on, you may use this option to execute your program one statement
at a time. After you select this option, ASIC will execute the next
program statement in your program, and pause, displaying the next line
which will be executed in reverse video with a red background
(underlined if you have a monochrome system). At this time, you can
view or modify variables, or view the screen output produced by your
program. You can then resume program execution by selecting the "Run
your program" option from the run menu, or by selecting the "Trace"
option again. This option may also be selected outside of the "Run"
Menu by pressing function key <F8>.
Page - 24
RUN MENU (Continued)
"Modify variable..." Option
If you have compiled your program with the "Debugging code" option
turned on, you may use this option to modify the contents of variables
in your program while your program is paused at a breakpoint or
following a "Trace" command. When you select this option, ASIC will ask
you for the variable name. After you enter the variable name, ASIC will
ask you for the new value to be stored in the variable. If the variable
is an array, ASIC will ask you which element of the array to modify.
"Watch variable... <F6>" Option
If you have compiled your program with the "Debugging code" option
turned on, you may use this option to view the contents of variables in
your program, while your program is paused at a breakpoint or following
a "Trace" command. After you enter the variable name, ASIC will open a
"Watch" window at the bottom of the screen showing you the variable name
and the current value. As you continue execution of your program and
reach a new breakpoint, the values of variables will be updated to
reflect their new values. In this way you can watch the changing values
of variables in your program without inserting "PRINT variablename"
statements in your program. Up to 10 variables may be watched at a
time. If you enter a variable name which is an array, ASIC will ask you
which element of the array you wish to watch. This option may also be
selected outside of the "Run" Menu by pressing function key <F6>.
"Unwatch variable... <F7>" Option
If you have compiled your program with the "Debugging code" option
turned on, you may use this option to remove variables from the "Watch"
window (see previous option). When you select this option, you will be
asked for a variable name to remove from the window. If the variable is
an array, you will also be asked which element of the array. ASIC will
then remove the variable from the watch window, and resize the window
accordingly. Since only 10 variables may be watched concurrently, you
may need to remove variables which are no longer needed from the "Watch"
Window using this command. This option may also be selected outside of
the "Run" Menu by pressing function key <F7>.
"Abort execution" Option
If you are running your program, and it is paused at a breakpoint,
you may select this option to abort the execution of your program. Your
program will be terminated immediately.
"Clear all break/watch" Option
If you have set breakpoints or watch variable options, you may use
this option to remove all of them at once, instead of removing them one
at a time using the "Toggle breakpoint" or "Unwatch variable" options.
Page - 25
RUN MENU (Continued)
"Program arguments..." Option
This option allows you to pass command line arguments to your
programs, which may be retrieved by your program using the COMMAND$
statement. If you are testing outside the integrated environment, you
would normally specify the command line arguments by typing
"progname arguments". However, in the integrated environment, since
ASIC is executing your program for you, this option is a means to pass
the "arguments" to your program as if they had been typed on the command
line following your program name.
"Swap to user screen <F4>" Option
Whenever ASIC pauses your program at a breakpoint, it saves the
screen created by your program in a memory buffer. You may select this
option to view your program screen output. When you are done viewing
your program's output, press a key to return to viewing the ASIC editor.
This function may also be selected outside the "Run" Menu by pressing
the <F4> function key.
STATUS LINE
The bottom line of the ASIC screen is called the "Status Line". As
it's name implies, it is used to display various types of status
information. At the left of the status line "FILE: xxxxxxxx.xxx" will
display the name of the file which is currently loaded in the edit
buffer. If you haven't opened a file yet, the file name will be blank.
After the file name is the "File Modified Indicator". If you have
entered any changes in the edit buffer, and have not saved them to disk,
an "*" will appear to indicate this. If the edit buffer has not been
modified since the last save to disk, no "*" will be present.
The next piece of information is "Mode:". Mode will always display
one of two values: "Insert" or "Ovrstr". In "Insert" mode, any
characters you type in the edit buffer will be inserted at the cursor
position, and the characters to the right of the cursor will be shifted
to the right by one. In "Ovrstr" mode, any characters you type in the
edit buffer will overlay (and thus destroy) the character at the cursor
position. You can change back and forth between these two modes by
pressing the <INS> key on your keypad.
To the right of "Mode:" ASIC displays how many thousands of bytes
are still available for use by ASIC. You will see this number decrease
as you add more lines to your programs.
The "Line: nnnn" status indicator, will identify which line of the
file is being displayed. For example, if the display reads "Line: 100",
the line containing the cursor is the 100th line in the file. When ASIC
is reading or writing your program to/from disk, it will display a
running total of the number of records read/written in this field.
Page - 26
STATUS LINE (Continued)
The "Row:" and "Col:" numbers identify the relative position of the
cursor within the "Edit Window".
EDIT WINDOW
The edit window is the area of the screen where your program is
displayed. It displays up to 21 lines of your program at a time. You
can use the keys described below to manipulate the text in this window.
KEYBOARD USAGE
Most keys on the keyboard behave in ASIC just as you'd expect. The
key usages which might not be obvious are described here.
<ESC> Exit from any menu without taking any action.
<TAB> Move the cursor to the next "tab stop". Tab stops in
ASIC are fixed at every fourth column (4,8,12,etc).
<HOME> Move the cursor to the beginning of the current line.
<END> Move the cursor to the first blank character following
the last non-blank character on the current line.
<DEL> Delete the character at the cursor position.
<INS> Toggle between Insert and Overstrike Modes.
<PGUP> Display the previous "page" of the edit buffer.
<PGDN> Display the next "page" of the edit buffer.
<Ctl-PGUP> Display the first "page" of the edit buffer.
<Ctl-PGDN> Display the last "page" in the edit buffer.
<Backspace> Delete the character to the left of the cursor
position, and move the cursor one column to the left.
<Up Arrow> Moves cursor up one line.
<Down Arrow> Moves cursor down one line.
Page - 27
KEYBOARD USAGE (Continued)
<Left Arrow> Moves cursor left one column.
<Right Arrow> Moves cursor right one column.
<Ctl-LfArrow> Moves cursor left one word.
<Ctl-RtArrow> Moves cursor right one word.
<Ctl-L> Repeats the last "Search" command. See Edit Menu
Section of this chapter for more information.
<Alt-A> Add a line following the line containing the cursor.
<Alt-D> Delete the line containing the cursor.
<Alt-I> Insert a line before the line containing the cursor.
<Alt-X> Exit ASIC.
<F1> Displays a help screen.
<CTL-F1> Displays help information for the keyword located at
the cursor position.
<F2> Saves the edit buffer to disk.
<F3> Load a new file into the edit buffer.
<F4> Swaps the display to the output from your program
temporarily. See Run Menu Section of this chapter for
more information.
<F5> Runs your program. See Run Menu Section of this
chapter for more information.
<F6> Add a variable to the "Watch" Window. See Run Menu
Section of this chapter for more information.
<F7> Remove a variable from the "Watch" Window. See Run
Menu Section of this chapter for more information.
<F8> Execute a single statement of your program. See Run
Menu Section of this chapter for more information.
<F9> Toggle breakpoint on/off at the current edit buffer
line. See Run Menu Section of this chapter for more
information.
<F10> Compile your program. See Compile Menu Section of
this chapter for more information.
<enter> In Insert mode, pressing <enter> is identical to
pressing <Alt-A>. In OvrStr mode, pressing <enter>
is identical to pressing the <Down Arrow> key.
Page - 28
A S I C
Chapter 4
Using the Debugger
INTRODUCTION
The source level debugger in ASIC's integrated programming
environment helps you debug your programs by allowing you to "peek"
inside them as they're running. You can single step through your
programs, or select places in the program where you wish execution to
pause by setting breakpoints. Then, while the program is paused, you
can view or modify any of your program's variables, and also examine the
screen output created by your program.
All of the debugger's commands can be selected from the run menu,
and they are described in the "RUN MENU" Section of Chapter 3,
"Integrated Editor/Compiler Environment". Many of the debugger commands
may be selected outside the "Run" menu, by pressing a function key (eg,
<F5>,<F6>,etc). A complete list of the function keys available is
contained in Chapter 3, in the "KEYBOARD USAGE" Section.
This chapter explains how to use the debugger with a short tutorial
which guides you through a sample debugging session. The tutorial is
followed by a reference section which you should read after completing
the tutorial.
DEBUGGER TUTORIAL
The debugger tutorial follows the same format as the general
tutorial in chapter 2. You should complete (or at least review) the
general tutorial before taking the debugger tutorial.
This tutorial will use a program file provided with your ASIC
compiler package called "DBGTUTOR.ASI". If you are running from a hard
disk, make sure it is in the ASIC directory. If you are running from a
two-floppy system, make sure it is on the diskette in drive b:, with the
compiler in drive a:.
NOTE: Floppy disk users should verify that the ASIC compiler diskette
is in drive A: and the "DBGTUTOR.ASI" disk is in drive b: before
proceeding.
Let's get started:
FLOPPY TYPE--> A: <enter>
ASIC B:DBGTUTOR <enter>
HARD TYPE--> C: <enter>
CD C:\ASIC <enter>
ASIC DBGTUTOR <enter>
Page - 29
You should be in ASIC now, and you should see a source program. The
first few lines should contain:
dim scores(10)
data 55,33,877,99,44,101,21,88,105,1
rem DBGTUTOR.ASI
.
. (etc)
.
This sample program will sort an array of 10 scores into ascending
sequence. It uses a simple "bubble" sort algorithm. The "bubble" sort
algorithm simply steps through each element of the array and compares it
to its next higher neighbor. If its neighbor's value is less than its
own, the two values are swapped. It is necessary to execute this
process N-1 times where N= number of items to sort. Here's why. Let's
say the lowest value to be sorted was "1" and it is in array element
"10" (assume 10 numbers will be sorted). The first swapping pass will
result in the "1" being swapped from element 10 to element 9 of the
array. An additional 8 passes through the array are necessary to move
the "1" to array element number 1. This algorithm gets its name,
because the process of moving the elements has been compared to that of
bubbles slowly rising to the surface.
This program has a list of ten scores to be sorted. Line 5 of the
program will read the ten scores to an array called "Scores", and also
print the original values (before the sort) to the screen. Then two
loops will execute at statements 8 and 9 in the program to perform the
bubble sort as described above. Finally, after the sort is complete,
the sorted values will be displayed.
First, let's compile the program. When we plan to use the debugger, we
must set the "Debugging code" option on. This is done on the Compile
Menu. However, the default in the integrated environment is "Debugging
code" on. Let's take a look to be sure:
TYPE--> <Alt><c>
The compile menu should pop open, and you should see a check mark next
to the "Debugging code" option. If you don't, press the letter "D", and
a check mark should appear. Once you've verified that the option is on,
we can compile the program. Notice that there is an <F10> next to the
option. Instead of opening this menu and selecting the "Compile"
option, we could have pressed <F10>. Let's try it. First, let's close
the menu (Function keys don't work inside a menu):
TYPE--> <ESC>
The menu should have closed. Now let's compile using the function key:
TYPE--> <F10>
You should see the compiler screen pop up, and compile the program. No
errors should be detected. Now we're ready to test the program. First,
let's set a breakpoint so we can easily view the screen output, Use the
Page - 30
down arrow key to position the cursor on line 20 (the line number is
displayed on the ASIC status line). Line 20 should contain an "END"
statement. Let's open the run menu and set a breakpoint:
TYPE--> <Alt><r>
<b>
The "END" statement should now be displayed in reverse video. That
tells us that a breakpoint has been set there. Did you notice that the
breakpoint option on the menu also had a function key listed. We could
set a breakpoint without opening a menu, by pressing <F9> instead. Now
that we've set a breakpoint, let's run the program and see how it works:
TYPE--> <Alt><r>
<r>
Note that we could have pressed the short cut key of <F5> to run the
program instead of selecting the option from the menu. At this point
our program is running, but is paused at the breakpoint we set on line
20. When you reach a breakpoint, ASIC will position the breakpointed
line on the second line of the edit window, highlighted in red (or
underlined, if you have a monochrome system). ASIC has interrupted the
program before it executed the line with the breakpoint, in this case
"END". Let's take a look at the screen output of the program to see if
it worked:
TYPE--> <Alt><r>
<s>
Note we could also select the "Swap" function by pressing <F4> without
opening a menu. You should now see the output from the program on the
screen. It should look something like:
Original Scores:
55 33 877 99 44 101 21 88 105 1
Sorting...
Here are the sorted scores:
33 55 99 44 101 21 88 105 1 877
Well, that doesn't look quite right. Maybe we can use the debugger to
figure out what went wrong. First, let's allow the program to run to
completion (remember, we're paused at a breakpoint on the "END"
statement). Swap back to the ASIC screen from the user screen by
pressing any key:
TYPE--> <enter>
You should see the editor screen again. Now let's tell ASIC to resume
program execution:
TYPE--> <Alt><r>
<r>
ASIC has executed the END statement, and our program has terminated.
You should see the message "Program Terminated Normally (0)". (The "0"
is the return code set by the program. You can set return codes in your
Page - 31
programs using the END statement. Refer to Chapter 7 for details.).
Now we'll set another breakpoint in the program. Move the cursor to
line 7 (the status line should now say LINE: 7) using the arrow keys.
The cursor should now be positioned on the statement which says: PRINT
"Sorting...". Set a breakpoint here:
TYPE--> <F9>
The source statement should now appear in reverse video. We used the
shortcut key <F9> to set the breakpoint this time, but you could have
opened the Run Menu, and selected the Breakpoint option and done the
same thing. Let's remove the breakpoint:
TYPE--> <F9>
Line 7 should no longer be highlighted. The same command is used to
turn breakpoints on or off for a source line. ASIC just checks to see
if a breakpoint is already set at that source line when you select the
breakpoint command. If one is set, it "toggles" it off (ie removes it),
otherwise, it "toggles" it on (ie sets a breakpoint). This exercise was
just to show you how to remove a breakpoint, let's go ahead and set it
again:
TYPE--> <F9>
Line 7 should be highlighted again (the breakpoint is set).
It might be nice to see what's in some of our program's variables, so
let's "watch" some variables. Open the Run Menu, select the Watch
command, and tell ASIC you want to watch variable "I".
TYPE--> <Alt><r>
<w>
i<enter>
ASIC should have opened a "Watch" window at the bottom of the screen.
You should see the variable name "I" at the left, followed by a ":".
Following the ":" is the current value of that variable. The number
there now doesn't really mean anything, since our program is not
running. But once the we start the program, this number should
represent the actual value of the variable "I".
Let's watch a few more variables: j, j1, and scores(1). This time,
we'll use the shortcut key for the watch command:
TYPE--> <F6>
j<enter>
Variable "J" should now be in the watch window.
TYPE--> <F6>
j1<enter>
Variable "J1" should now be in the watch window. When we watch
"scores", we'll also have to tell ASIC which element we want to watch by
entering a subscript, since "scores" is an array. First ASIC will
prompt you for the variable name. Type it, without the subscript. ASIC
will prompt you for the numeric subscript.
Page - 32
TYPE--> <F6>
scores<enter>
<1><enter>
Scores(1) should now be in the watch window. Now we're ready to run the
program again:
TYPE--> <F5>
Again we selected the short cut key, you could have selected the "Run
your program" option from the "Run" Menu. The second line of the edit
screen should show the PRINT "Sorting..." statement (highlighted in red,
or underlined if you have a monochrome monitor). The variables in the
watch window should have the following values:
I: 11
J: 0
J1: 0
SCORES(1): 55
Let's execute the next statement by using the Trace command:
TYPE--> <Alt><r>
<t>
ASIC has executed the PRINT "Sorting..." statement and has paused
execution on the "FOR I" statement on line 8 of the program. Since the
PRINT statement did not modify any variables, the numbers in the watch
window should remain unchanged. Let's Trace one more statement, this
time, we'll use the short cut key:
TYPE--> <F8>
ASIC has executed the "FOR I" statement on line 8, and is now paused on
statement "FOR J" on line 9 of the program. Something looks wrong
though. Even though we executed the first "FOR I" statement, the
variable "I" still contains "11". It should contain "1". If you look
at line 8, you'll see that the FOR statement was mistyped, it reads:
"FOR I = I to 9", instead of "FOR I=1 to 9". Since the program also
used variable "I" to READ the data into the array, "I" still contains
the value "11". Since "11" is greater than the "TO" value of the "FOR"
loop, the FOR loop on line 8 is executed only 1 time instead of 9 times.
That's why the data is not being fully sorted. With the ASIC debugger,
we can continue testing without recompiling, by modifying the value of
"I" to "1", so we can see if the rest of our logic is correct. If
changing "I" to "1" works, then we can go back and modify the "FOR"
statement and recompile the program to correct the program permanently.
Modify the value of "I" to "1":
TYPE--> <Alt><r>
<m>
i<enter>
<1><enter>
Page - 33
The watch window should now show the value of "I" as 1. We can resume
program execution at this point by selecting the "Run your program"
option. We'll use the short cut key again:
TYPE--> <F5>
ASIC should pause the program at the next breakpoint, which is on line
20. This statement contains the "END" command. Now let's see if the
program worked, by swapping to the user screen:
TYPE--> <F4>
Again, we used the short cut key. You should see the following on your
screen:
Original Scores:
55 33 877 99 44 101 21 88 105 1
Sorting...
Here are the sorted scores:
1 21 33 44 55 88 99 101 105 877
It looks like the program worked. Let's return to the editor screen.
TYPE--> <enter>
Now we could press <F5> to resume execution and in this case terminate,
since the END statement is the next one to execute. But let's look at
another way to terminate a program. While at a breakpoint, you can
select the "Abort your program" option, which instructs ASIC to
terminate your program immediately, without executing any more of your
program. Let's try it:
TYPE--> <Alt><r>
<a>
ASIC should display the message "Program Terminated Normally (0)". At
this point, we'll just exit from ASIC, but normally, you would fix the
FOR statement using the editor, save the file, recompile the program,
and retest it to make sure the "bug" is really fixed.
TYPE--> <Alt><f>
<x>
You should be back at the DOS prompt now. That concludes the brief
introduction to the ASIC debugger. The rest of this chapter provides
some additional reference material for the debugger. Chapter 3 provides
additional information about each of the debugging commands.
Page - 34
DEBUGGER TIPS
1) WHEN YOU ARE DONE DEBUGGING YOUR PROGRAM, YOU SHOULD RECOMPILE
WITH THE "DEBUGGING CODE" OPTION TURNED OFF. Although your program
can run from the DOS command line with debugging code present, it
will increase the program size and execution times. Recompiling
with the "Debugging code" option off will insure your programs
will be smaller and faster.
2) Remember that the default option on the command line compiler is
"Debugging code" off. The default option in the integrated
environment is "Debugging code" on.
3) Breakpoints/Watches are automatically cleared when you
OPEN or COMPILE a file.
4) If you change source lines in a program while a program
is running, without recompiling, source statements will
not match executable code. Abort the running program
and recompile after making code changes.
5) Breakpoints are set in the edit buffer relative to the
beginning of the buffer. If you insert/delete lines in
the buffer, the breakpoints will still be set at the
same relative line number from the beginning of the
buffer.
6) ASIC takes over the INT 3 Interrupt vector for debugging
purposes. It re-installs the default vector when you
exit ASIC.
7) You must compile with the "Debugging code" option to use
source level debugging.
8) If you wish to run a program from the beginning again
while its already running, select the "Abort your
program" option from the Run menu. Then, select the
"Run your program" option.
9) If you select the Abort option from the Run menu, your
program's files will NOT be closed gracefully. That
is, data in the buffers will not be flushed to disk.
10) You may still run a program in the integrated environment that
has been compiled without the Debugging code option. You just
won't be able to use the debugging commands (eg,
Breakpoints/Watches).
11) Toggling a breakpoint on/off will clear any block of
text you had previously marked for editing (eg, MOVE,
COPY).
Page - 35
DEBUGGER TIPS (Continued)
12) When modifying array variables, make sure that the
subscript you specify is valid. For example, if you
"DIM A(10)", make sure the subscript you specify is in
the range of 0 to 10. ASIC does not check the range of
a subscript. If you specify a subscript that exceeds
the valid range for that variable, your program may
crash.
13) You can pass arguments to programs using the "Arguments"
option on the Run Menu. You may retrieve these options
in your program with the COMMAND$ statement. Using the
"Arguments" option is equivalent to specifying arguments
following the program name, when you run your program
from the DOS command line.
14) The compiler allows variable names up to 80 characters in
length. The debugger only uses the first 30 characters of a
variable name. When the debugger finds two variables whose names
are not unique within 30 characters, it will always select the
first one it finds (this applies to the Watch/Unwatch/Modify
Variables commands).
15) ASIC will allow you to set a breakpoint on a "FOR" statement.
However, you should be aware that the source statement containing
the "FOR" is executed only once (to initialize the loop). When
the "NEXT" statement executes, control transfers back to the line
following the "FOR", instead of the "FOR". For example, in the
following code fragment:
FOR I = 1 TO 3 <---Executes 1 time to initialize loop
PRINT I <---Executes 3 times
A=A+1 <---Executes 3 times
NEXT I <---Executes 3 times, loops back to
"PRINT I", not to "FOR I= 1 TO 3"
16) Because a single machine language instruction could span multiple
CODE statements, ASIC does not allow breakpoints on CODE
statements.
Page - 36
A S I C
Chapter 5
Command Line Compiler Options
COMMAND LINE SYNTAX
Invoke the command line version of the compiler as follows:
ASICC filename option1 option2 option3[...optionN]
or
ASICC filename.PRJ option1 option2 option3[...optionN]
Where: filename is the name of the source program or project
file to be compiled. Source files must have
the file extension ".ASI", although the
extension may be omitted from the command line.
filename.PRJ Project files may be specified instead of a
source file name. These have a ".PRJ"
extension, and the ".PRJ" extension must be
typed if you want ASIC to use the project file
for the compile. Specifying a project file
tells ASIC to look for a project file (created
by the integrated environment), and use the
options from this file during the compile.
ASIC will then strip off the ".PRJ" extension
and try to compile a file with the same
filename as the ".PRJ" file, but with a ".ASI"
extension.
optionN specifies any options desired. No options are
required, but more than one can be specified as
long as you insert a space between each one.
Page - 37
COMPILER OPTIONS
The following compiler switches are currently available for ASIC:
Switch Description
B/xxx BUILD--Use this option to specify the type of output file
ASIC is to produce. The "xxx" on this option should be
one of the following:
xxx= COM <--produce .COM file
EXE <--produce .EXE file
OBJ <--produce .EXE file via OBJ file
using DOS LINK command
optionally linking with
other OBJ or LIB files.
Default: ASIC will generate a ".COM" output file.
C CONTINUE--ASIC will not pause after messages are issued,
but will continue compiling.
Default: ASIC will pause after each error message.
Compilation will resume after you press a key.
D DISKLIST--ASIC will echo all screen messages to a disk
file named "progname.LST". The format is the same
produced by PRINTLIST. This allows you to compile at
higher speed, and print the source listing later from the
disk file via the DOS print spooler.
Default: ASIC does not produce a ".LST" file.
DEC DECIMAL MATH--ASIC will enable the Decimal Math Option.
When this option is selected, you may specify decimal
numbers (eg, BALANCE@, 123.456789, etc) which can hold
numbers in the range +/-999,999,999,999.99999. This
option does increase the size of your ".COM" or ".EXE"
file.
Default: ASIC does not enable the Decimal Math Option.
E EMATH--ASIC will enable the Extended Math Option. When
this option is selected, you may specify long integers
(eg, VELOCITY&, 123456789&, etc) which can hold a larger
range of values (+2,147,483,647 to -2,147,483,647). This
option does increase the size of your ".COM" or ".EXE"
file by a couple of hundred bytes.
Default: ASIC does not enable the Extended Math Option.
Page - 38
COMPILER OPTIONS (Continued)
Switch Description
L LIST ALL--ASIC will list each source line as it compiles
it.
Default: ASIC will list only source lines with compile
errors.
Comment: Use of this switch will slow compile speeds
slightly due to the additional screen I/O.
LIB=xxx LINK LIBRARY--Specifies libraries that ASIC should pass
to the DOS LINKer. This option is ONLY used by ASIC when
you compile with the "B/OBJ" option. It is ignored when
you compile with the "B/COM" or "B/EXE" options. A link
library is usually used to store commonly used
subroutines in OBJECT format. You can create assembly
language subroutines for ASIC, and store them in a
library using the Borland TLIB Program or the Microsoft
LIB Program. The "xxx" should specify one or more
library file specs with each library spec separated with
a "+" character. See the "Mixed Language Programming"
chapter of the ASIC manual for more information.
Examples:
LIB=C:\ASIC\MATH.LIB
LIB=C:\DOS\MISC.LIB+C:\LIB\COMMON
The first example shows a single library spec for
MATH.LIB library. The second example shows how to
include more than one library--MISC.LIB and COMMON.LIB
libraries.
Comments: When specifying libraries, you may omit the
file extension, if it is ".LIB".
Page - 39
COMPILER OPTIONS (Continued)
Switch Description
LNK=xxx LINKer LOCATION--Specifies the location of the DOS
LINK.EXE program to ASIC. This option is ONLY used when
compiling with the "B/OBJ" option. Unless the LINK.EXE
which is provided with MS DOS is located in the default
ASIC directory, ASIC may not be able to locate the
program, and will thus be unable to LINK your program to
create a ".EXE" file. The LINK.EXE should be included on
your MS DOS distribution disks (if it is not already in
your DOS directory). "xxx" should specify a file path.
For more information on this option see the "Mixed
Languages Programming" Chapter of the ASIC Manual.
Example:
LNK=C:\DOS3
Default: By default, ASIC will attempt to locate the
linker in the default directory. If it can't find the
LINK.EXE file there, it tries to find it under the
"C:\DOS" directory. If it can't find it there, it gives
up and issues an error message.
OBJ=xxx ADDITIONAL OBJECT FILES--Specifies a list of additional
object files that ASIC should link with the main object
file. This option is ONLY used by ASIC when you are
compiling with the "B/OBJ" option. You do not need to
include the name of your ASIC program here, that is done
automatically by ASIC. When you compile with this
option, ASIC creates an OBJ file which can be linked
using the DOS LINKer. Optionally, you can included "CALL
SUB" statements in your program which reference
separately compiled OBJ files. This option allows you to
pass other object file names to the DOS LINKer to resolve
these external references. The "xxx" parameter should
include file specs for one or more object files with a
"+" character separating each object file. See the
"Mixed Language Programming" Chapter of the ASIC Manual
for more details.
Examples:
OBJ=C:\ASIC\MYSUB.OBJ
OBJ=C:\LIB\SUB1.OBJ+C:\OBJ\SUB2
The first example specifies a single object to be passed
to the linker. The second example illustrates two object
files: SUB1.OBJ and SUB2.OBJ.
Comments: The file extension may be omitted if it is
".OBJ".
Page - 40
COMPILER OPTIONS (Continued)
Switch Description
P PRINTLIST--ASIC will echo all messages which appear on
the screen to the printer. Output to the printer will be
paged with header lines identifying the program name, and
the date/time compiled.
Default: ASIC will not send any messages to the printer
Comments: Even though output to the printer is buffered,
this option will slow compile speeds considerably. The
compiler typically compiles only as fast as your printer
can print the messages. An alternative to this switch is
the DISKLIST option.
S SYMTAB--ASIC will produce a formatted Symbol Table in a
file named "progname.SYM". The symbol table contains a
list of all variables, labels, and internally created
compiler addresses.
Default: ASIC does not produce a ".SYM" file.
STK=n STACK SIZE--Specifies the size of the stack that you wish
ASIC to create. This option is ignored when you are
using the "B/COM" option. "n" equals the size of the
stack you want in bytes.
Default: By default, ASIC sets the stack size to 2000
bytes (4000 bytes if you are compiling with debugging
mode).
Examples:
STK=512
In the above example, the stack size would be set to 512
bytes.
Comments: The default stack sizes that ASIC provides are
normally adequate, however, they may be larger than your
program may need. If you are interested in minimizing
your program's memory usage, you may experiment with the
STK option, however, setting the size too small can cause
unpredictable results. This option is recommended only
for experienced ASIC users. The stack size must be in
the range 16 to 32767. ASIC will not allow you to create
a stack size smaller than 4000 bytes when compiling with
debugging mode on. If you specify a smaller value in
this instance, ASIC will override it with a size of 4000.
Page - 41
COMPILER OPTIONS (Continued)
Switch Description
X DEBUG--ASIC will generate debugging code in the ".COM" or
".EXE" file and a ".DBG" file for use by the integrated
environment debugger.
Default: ASIC does not generate debugging information.
Comment: If you are running from the integrated
environment, ASIC sets this option on by default. You
may turn it off in the Compile menu, should you so
desire.
COMPILE EXAMPLES
Example 1: Compile "MYFILE.ASI" with default compiler options:
ASICC MYFILE
Example 2: Compile "MYPROG.ASI", Listing all source lines, writing a
compile listing to a disk file for printing later. The
listing file will be called "MYPROG.LST":
ASICC MYPROG L D
Example 3: Compile "FILEX.ASI", don't pause for any errors, and
print the errors on the printer:
ASICC FILEX C P
Example 4: Compile "CRUNCH.ASI" and allow long (32 bit) integer
numbers:
ASICC CRUNCH E
Example 5: Compile "BIGPROG.ASI" and create a ".EXE" format output
file:
ASICC BIGPROG B/EXE
Example 6: Compile "SAMPLE.ASI" and create a ".EXE" format output
file, with a stack size of 2500 bytes.
ASICC SAMPLE B/EXE STK=2500
Page - 42
COMPILE EXAMPLES (Continued)
Example 7: Here's a more complex example, which demonstrates the
use of the B/OBJ build options. Assume we have a program
called "MAIN.ASI" which calls three assembly language
subroutines, called "A", "B", and "C". Subroutine "A" is
stored in file "A.OBJ". Subroutines "B" and "C" are
stored in a library called "ASMSUB.LIB". The DOS
LINK.EXE file is contained in the subdirectory "C:\UTIL".
Here is the ASICC command to compile MAIN.ASI and link in
the subroutines called using "CALL SUB" in the MAIN.ASI
program:
ASICC MAIN B/OBJ OBJ=A LIB=ASMSUB LNK=C:\UTIL
PROGRAM PROJECT FILE
The ASIC integrated environment automatically stores compile
options for each program in a file called "progname.PRJ". Whenever you
compile from the integrated editor, ASIC will always check for this
file, and set compile options based on the file.
Since MS DOS has a restriction of 128 characters for a command
line, you may find it useful to use the integrated environment to set
your compile options for a program, even if you are not using the
environment for editing. This is especially true when you are using the
"B/OBJ" option, where you frequently may be passing many parameters.
Then, you may type the program project file name instead of the program
source file name when compiling from the command line and ASIC will use
the options from the ".PRJ" file for that compile.
You may still specify additional compile line options when
compiling using the ".PRJ" file option. In this case, the option from
the command line will override any corresponding option from the ".PRJ"
file.
Although the ".PRJ" file is a standard DOS text file, it is
recommended that you not edit this file using a text editor--if
incorrectly modified, compiler results may be unpredictable.
Example:
ASICC myfile.prj LIB=NEWLIB
In this example, all options set in the "MYFILE.PRJ" file will be
read and used by the ASIC command line compiler, except for the "LIB"
option which was specified on the command line. For this compile, ASIC
will set the LIB option to "NEWLIB" irregardless of what the LIB option
was set to in the project file. ASIC will then try to compile a source
file called "MYFILE.ASI".
Page - 43
A S I C
Chapter 6
Language Elements
CHARACTER SET
Symbol Description
* Multiplication
Example: A=B*C (multiply B by C, store result in A)
/ Division
Example: A=B/C (divide B by C, store result in A)
+ Addition
Example: A=B+C (add C to B, store result in A)
+ String Concatenation
Example: A$="AB"+"C" (A$ will contain "ABC")
= Assignment
Example: A=1 (A will be assigned the value 1)
= Equality testing
Example: IF A=1 THEN QUIT: (If the value stored in
A equals 1 goto label QUIT)
< Less than testing
Example: IF A<1 THEN QUIT: (If the value stored in
A is less than 1 goto label QUIT)
> Greater than testing
Example: IF A<1 THEN QUIT: (If the value stored in
A is greater than 1 goto label QUIT)
- Subtraction
Example: A=B-C (Subtract C from B, store result in A)
" String Delimiter
Example: A$="the string is inside quote marks"
() Parenthesis -- Ignored by ASIC
; Suppress Carriage Return/Line Feed with PRINT/LPRINT
# Used to identify file usage with PRINT#/INPUT#
Page - 44
CHARACTER SET (Continued)
Symbol Description
, Comma, Ignored by ASIC
$ Distinguishes a String Variable from an Integer.
Example: ABC$ <---- String Variable
Example: ABC <---- Integer Variable
: Distinguishes a Label from a variable name.
Example: START: <---Label name
& Distinguishes a "long" (32 bit) integer from a normal
integer (16 bit) variable or constant. Normal integers
can hold numbers in the range +32,767 to -32,767. Long
integers can hold numbers in the range +2,147,483,647
to -2,147,483,647. Note: You must compile with the
"Extended Math" Option enabled to use long integers.
Example: APPLES& <--Long Integer Variable
Example: ORANGES <--Normal Integer Variable
Example: 123457& <--Long Integer Constant
Example: 1234 <--Short Integer Constant
@ Distinguishes a "decimal" (64 bit) variable or constant
from a normal integer (16 bit) variable or constant.
Decimal numbers can be in the range
+999,999,999,999.99999 to -999,999,999,999.99999. Note:
You must compile with the "Decimal Math" option enabled
to use decimal numbers.
Example: APPLES@ <--Decimal Variable
Example: 1234.567 <--Decimal Constant
Example: 123@ <--Decimal Constant
Example: 1.2@ <--Decimal Constant
Page - 45
CONSTANTS, VARIABLES, AND LABELS
ASIC supports the following data types:
Decimal Constants Integer Constants
Decimal Variables Integer Variables
Decimal Arrays Integer Arrays
String Constants Long Integer Constants
String Variables Long Integer Variables
String Arrays Long Integer Arrays
Integer constants may be specified in decimal (base 10), hexidecimal
(base 16), or binary (base 2). The following describes the restrictions
for each data type.
DECIMAL CONSTANTS Range +999,999,999,999.99999 to
-999,999,999,999.99999
Example: 105.1
DECIMAL VARIABLE Described by a variable name beginning with a
letter, followed by up to 78 additional letters
or numbers, terminated with an "@" symbol. It
may contain a number in the range of
+/-999,999,999,999.99999
Example: INTEREST@
DECIMAL ARRAY Described by a variable name beginning with a
letter, followed by up to 78 additional letters
or numbers, terminated by an "@" symbol. This
is followed by an integer variable or constant
for the dimension of the array. Arrays must be
dimensioned at the beginning of the program. See
the DIM statement.
Example: SALES@(YEAR)
INTEGER CONSTANTS Range +32767 to -32767
Example: -26
INTEGER VARIABLE Described by a variable name beginning with a
letter, followed by up to 79 additional letters
or numbers. It may contain a number in the range
+32767 to -32767.
Example: VELOCITY1
Page - 46
CONSTANTS, VARIABLES, AND LABELS (Continued)
INTEGER ARRAY Described by a variable name beginning with a
letter, followed by up to 79 additional letters
or numbers. This name is followed by an
integer variable or constant for the dimension
of the array. Arrays must be dimensioned at the
beginning of the program. See the DIM statement.
Example: GROWTH (YEAR)
LONG INTEGER Range +2,147,483,647 to -2,147,483,647
CONSTANTS
Example: 3234457&
LONG INTEGER Described by a variable name beginning with a
VARIABLE letter, followed by up to 78 additional letters or
numbers terminated with a "&". Can contain
numbers in the range +2,147,483,647 to
-2,147,483,647.
Example: VELOCITY1&
LONG INTEGER Described by a variable name beginning with a
ARRAY letter, followed by up to 78 additional letters or
numbers, terminated with a "&". This name is
followed by an integer variable or constant for
the dimension of the array. Arrays must be
dimensioned at the beginning of the program.
See the DIM statement.
Example: GALAXY& (BILLIONSOF)
HEXIDECIMAL Hexidecimal constants are constants which are
CONSTANT stated in base 16 instead of base 10 like normal
constants. These may be specified wherever you
can specify a integer constant. Hexidecimal
constants in ASIC must be prefixed by "&hex". This
prefix should be immediately followed by a valid
normal or long integer constant. Hex constants
may contain up to 8 hexidecimal digits for long
constants, and 4 hexidecimal digits for normal
constants.
Example: &hexB000 <--equivalent to -20400
Example: &hexB& <--equivalent to 11&
Example: &hexFFFFFFFF& <--equivalent to -1&
Example: &hexB000& <--equivalent to 45056&
Page - 47
CONSTANTS, VARIABLES, AND LABELS (Continued)
BINARY CONSTANT Binary constants are constants which are stated in
base 2 instead of base 10 like normal constants.
These may be specified wherever you can specify a
integer constant. Binary constants in ASIC must
be prefixed by "&bin". This prefix should be
immediately followed by a valid normal or long
integer constant. Binary constants may contain
up to 32 binary digits for long constants or 16
binary digits for normal constants.
Example: &bin10 <--equivalent to 2
Example: &bin10101011& <--equivalent to 171&
STRING CONSTANT A group of 0-80 characters enclosed by quotation
marks.
Example: "This is a String Constant"
STRING VARIABLE Described by a variable name which begins with a
letter, followed by up to 78 additional
letters or numbers, terminated with a "$".
Can contain 0-80 characters.
Example: ADDRESS$
STRING ARRAY Described by a variable name which begins with a
letter, followed by up to 78 additional letters or
numbers, followed by a $, followed by an integer
variable or constant enclosed in parenthesis
representing the subscript. Arrays must be
dimensioned at the beginning of the program.
See the DIM statement.
Example: STATE$(50)
LABEL A Label is a location in your program you wish
to transfer to. It must begin with a letter,
and it may contain up to 78 additional letters
or numbers. It must be terminated with a ":".
Example: START:
Page - 48
VARIABLES VS. CONSTANTS
In general, ASIC will allow the use of either variables, arrays, or
constants as operands to any program statement. For example:
PRINT CASH
PRINT 20
PRINT A(10)
All three of the above examples are valid. The only case where a
constant cannot be used, is where the value is being modified. For
example:
A = A + B <----VALID
17 = A + C <----INVALID
Of course you must specify the correct data type for the ASIC keyword.
For example:
A = ABS("HELLO") <----INVALID
This statement is invalid because you cannot take the absolute value of
a string!
There are a few ASIC statements which will accept only integer constants
for some operands (DIM, OPEN, PRINT#, INPUT#). Refer to the individual
statement for more information.
There is a restriction on the use of subscripts for Arrays. A subscript
for an array cannot be another array,. For example:
A(I(1)) <----INVALID
A(I) <----VALID
Finally, decimal variables or constants cannot be used as subscripts:
A@(1.1) <----INVALID
A@(B@) <----INVALID
A@(1) <----VALID
A@(A) <----VALID
A@(A&) <----VALID
Page - 49
CONVERSION BETWEEN NUMERIC FORMATS (INTEGER, LONG INTEGER AND DECIMAL)
Decimal numbers, long integers, or normal integers may be used on any
ASIC statement in any combination. Consequently, in the "Keyword
Reference" Chapter of this is manual, operands are identified only as
"number". "Number" in this context should be interpreted as meaning
that the operand for that statement can be any of the following: integer
constant, integer variable, integer array, long integer constant, long
integer variable, long integer array, decimal constant, decimal
variable, or decimal array. Exceptions, if any, are noted in the
documentation for the statement.
If you do mix decimal number, long integers, or regular integers in a
statement, you should be aware of how ASIC converts between the formats.
The following rules apply:
1) If a long integer variable or constant is being stored in a
normal integer variable, the long integer (32 bit) number
will ALWAYS convert correctly to a normal integer (16 bit)
value provided the long integer variable contains a number
which will fit in a normal integer (ie, within the range of
+32767 to -32767). If, however, the number is outside of
this range, ASIC will truncate it to make it fit in a normal
integer. This truncation will cause some surprising (but
predictable) answers. For example if "A&" contained the
value "50000&", and the following ASIC statement was executed
"A=A&", then the value of "A" would be "-15536". The reason
that the overflow results in such a strange number is due to
the way the IBM PC stores numbers in binary format and is too
complicated to describe here. The important thing
to remember is, for ASIC to convert from long integers to
normal integers correctly, the value in the long integer
should be in the range of +32767 to -32767.
2) If a normal integer variable or constant is being stored in
a long integer variable, ASIC will always convert the number
correctly.
3) If a decimal number is stored in a normal or long integer, the
fractional component of the number will be discarded, and the
remaining integer value will be stored in the normal or long
integer. The result will be truncated if necessary to fit.
For example, after the statement "A=12345.67890" is executed,
variable "A" would contain the value "12345". As another
example, after the statement, "A=50000.12345" is executed,
variable "A" would contain the value "-15536". The reason
that the overflow results in such a strange number is due to
the way the IBM PC stores numbers in binary format and is too
complicated to describe here. The important thing
to remember is, for ASIC to convert from decimal numbers to
integers correctly, the value of the decimal number should be
within the range for the target variable type.
Page - 50
4) If a long or normal integer is stored in a decimal variable,
ASIC will always convert the number correctly.
5) IMPORTANT NOTE: When performing math with a mixture of decimal
and integer variables, ASIC automatically converts the operands
to the storage type of the result BEFORE computing the result,
and the math function called will be based on the variable type
of the result. GWBASIC/BASICA floating point, on the other
hand, converts the operands to the most precise format of the
operand types to the RIGHT of the equal sign and compute the
results based on the longest type to the right of the equal
sign, before scaling the result. This can be illustrated with
the following examples:
ASIC GWBASIC/BASICA
A@=2*2.6 = 5.2 A#=2%*2.6 = 5.2
B=2*2.6= 4 B%=2%*2.6 = 5
B&=500 * 500=250000 B&=500% * 500%= OVERFLOW
B&=500& * 500&=250000 B&=500& * 500&=250000
Page - 51
A S I C
Chapter 7
Keyword Reference
ABS
Format: number1 = ABS (number2)
Description:
This function returns the absolute value of number2 which is then
stored in number1.
Example:
A = ABS (-7)
After execution of this statement, "A" will contain 7.
ASC
Format: number1 = ASC (string1)
Description:
This function returns the ASCII value of the first character of
string1, storing the result in number1.
Example:
A = ASC("123")
After execution of this statement "A" would contain 49, which the is
ASCII value of "1".
Page - 52
BEEP
Format: BEEP
Description:
This statement will cause a short "beep" to be produced on the PC
speaker.
Example:
IF A>99 THEN
BEEP
PRINT "Number is too big!"
A=99
ENDIF
The preceding program fragment will check to see if variable "A"
contains a value less than 100. If it does not, it will produce a short
"beep", display a message, and set the value of "A" to 99.
Page - 53
BLOAD
Format: BLOAD string1, number1, number2
Description:
This function loads data previously saved by BSAVE from a file to
memory. String1 should be the name of the file previously created by
BSAVE. Number1 should be the memory offset to load the data to.
Number2 should be the number of bytes to read from the file (in the
range of 1 to 32767). If DEFSEG has been set, it will be used as the
data segment, otherwise, the default ASIC data segment will be used.
Example:
DEFSEG = &hexB800
BLOAD "SAVED.DAT" 0 100
After execution of these statements 100 bytes will be read from the file
"SAVED.DAT" and stored in memory start at 0 bytes from the start of the
override data segment (which in this case happens to point to the
beginning of video memory for a CGA card). Assuming a CGA card was
present, the first 50 characters on the screen would contain data read
from the file (don't forget that each screen character is represented by
two bytes data and attribute, that's why only 50 characters will be
displayed, assuming you are not in graphics mode).
Comments:
THIS FUNCTION IS RECOMMENDED ONLY FOR ADVANCED PROGRAMMERS. THIS
STATEMENT WILL ALLOW YOU TO OVERLAY ANY AREA OF MEMORY, AND IT IS VERY
EASY TO ACCIDENTALLY OVERLAY YOUR PROGRAM OR THE MEMORY USED BY DOS.
If ASIC detects an error executing this command, it will set the
system ERROR variable. These error codes are listed in the Error
Messages Chapter of the ASIC Manual
This statement is slightly different from GWBASIC/BASICA in that
you must specify how many bytes to read from the file. Also, the memory
offset is not stored in the file by BSAVE, so you must specify the
offset as number1 in ASIC. Offset is optional in GWBASIC/BASICA.
ASIC uses a slightly different file format than GWBASIC/BASICA,
however, it is relatively easy to convert the GWBASIC/BASICA to ASIC
format. GWBASIC/BASICA files have a seven byte header that ASIC does
not have. If you strip off these 7 bytes and rewrite the file, ASIC
should be able to process the file.
See also:
DEFSEG,BSAVE
Page - 54
BSAVE
Format: BSAVE string1, number1, number2
Description:
This statement writes the block of memory beginning at offset
number1 from the start of the data segment for a length of number2 bytes
to the file specified by string1. This data may be later loaded by
BLOAD. If DEFSEG has been set, it will be used as the data segment,
otherwise, the default ASIC data segment will be used.
Number2 should be in the range of 1 to 32767.
Example:
DEFSEG = &hexB800
BSAVE "SAVED.DAT" 0 4000
After execution of these statements 4000 bytes at offset 0 bytes from
the start of the override data segment (which in this case happens to
point to the beginning of video memory for a CGA card) will be written
to the file "SAVED.DAT". Assuming a CGA card was present, the current
screen would be saved to disk, assuming you are not in graphics mode.
Comments:
If ASIC detects an error executing this command, it will set the
system ERROR variable. These error codes are listed in the Error
Messages Chapter of the ASIC Manual.
See also:
DEFSEG,BLOAD
Page - 55
CALL
Format: CALL (string1,string2) <-Format 1
CALL SUB (stringconstant1,[arg1,...,argN]) <-Format 2
Description:
Depending on the format that you select, this statement can be used
to perform two different functions. Format 1 is used to load and
execute another program (in .EXE, .COM format). Format 2 is used when
you have compiled a subroutine in a .OBJ file, and wish to incorporate
this routine in an ASIC program, and CALL it as a subroutine. Notice
the difference between these two approaches. In format 1, execution of
your ASIC program is suspended, and a new .EXE or .COM file is loaded
from disk and executed. When the .EXE or .COM program terminates, your
ASIC program resumes execution. With format 2, however, the subroutine
itself is bound into your ASIC program with the DOS linker, so that when
you call it, no disk access is required, and the overhead of the call is
much lower.
When using format 1, this statement can be used to load and execute
other programs compiled with ASIC or another compiler. String1
represents the name of the program to execute. String2 contains any
arguments to be passed to the program (it may be NULL, ie ""). If an
error occurs when ASIC attempts to call the program, it will set the
system ERROR variable to 255. Otherwise, the ERROR variable will be set
to the value of the return code of the called program (which is 0 unless
the called program specifies otherwise).
Format 2 is used to call a separately compiled subroutine, that
uses the BASIC (or PASCAL) parameter passing conventions. You could use
this to call a subroutine that you had written in assembler. When using
this format, you must compile using the OBJ output option. ASIC will
produce an OBJ format output file, that can be linked with the standard
DOS linker. When you compile within the integrated environment, ASIC
automatically calls the DOS linker for you, when the OBJ option is
selected. With this format, stringconstant1 must be a string constant
that contains the name of the subroutine to be called. The remaining
fields (arg1 through argN) are optional, but if specified, they must be
variables or constants. These arguments will be passed to the called
subroutine using the stack. These arguments will be passed "by
reference", which means that a pointer to the variable will be passed,
instead of the value contained in the variable. This means that the
subroutine you call can modify the values of the ASIC variables passed.
(See Chapter 10, Mixed Language Programming, of the ASIC manual, for
more information on using format 2).
Page - 56
CALL (Continued)
Example 1: (format 1)
CALL ("MYPROG.COM","")
REM other code follows
This statement would cause ASIC to load and execute the program
"MYPROG.COM". No arguments will be passed to the program. When MYPROG
terminates, the calling program will regain control on the line
following the call, in this case the "REM" statement.
Example 2: (format 1)
CALL ("COMMAND.COM"," /C WP.BAT")
In this example, a ".BAT" type file is executed called "WP.BAT". To run
".BAT" files, it is necessary to load a copy of COMMAND.COM as shown
above (COMMAND.COM contains the DOS code required to load and execute
".BAT" files). Using this format, you can also run some "built in" DOS
commands such as DIR or SORT. Using CALL with this format, is similar
to using the GWBASIC/BASICA SHELL command.
Example 3: (format 2)
CALL SUB ("mysub",A,A$,1)
In this example, a subroutine "mysub" is being called. Three arguments
are being passed to the subroutine, "A", "A$" and "1". You must set the
compiler output option to OBJ, and specify "MYSUB.OBJ" in the LINK
options subroutine list. The arguments will be passed to the subprogram
on the stack in the order: A,A$,1.
Comments:
Format 1:
When using format 1, string1 must contain the FULL pathname of the
program (ie,"\directory\progname.COM") only if the program is NOT in the
current directory. You must include the file extension on the file name
(for example, use "MYPROG.COM" instead of just "MYPROG", or use
"MYPROG.EXE" instead of "MYPROG").
If you wish to pass arguments to the program build it as follows:
YOURPARM$ = "arguments"
N = LEN(YOURPARM$)
A$ = CHR$(N)
A$ = A$ + YOURPARM$
B$ = CHR$(13)
A$ = A$ + B$
CALL "progname" a$
Page - 57
CALL (Continued)
The above creates an argument list according to the strict DOS
calling rules, however, you can just create the arguments in a string,
and precede them with a leading space. This will work for arguments up
to 32 characters in length (space character is ASCII 32). You might
want to try this short cut first, and only resort to the full formal
approach if you have problems with it, or need to specify longer
arguments:
CALL "progname" " arguments"
It is recommended (but not required) that you compile your program
using the EXE format (instead of the COM format) when your program uses
format 1, since an EXE program will release more memory when calling the
program. This will allow you to call a slightly larger program than is
possible with the COM format.
Format 2:
When using format 2 , the following considerations apply. First,
remember that the arguments you pass to the subroutine must match the
arguments the subroutine expects to receive. For example, if you pass a
single integer to the subroutine, the subroutine had better expect to
receive a single integer, or the results will be unpredictable. Second,
since all arguments are passed by reference, all arguments can be
modified by the called routine. Be aware that if you pass a constant
such as "1" to the routine and it modifies the value to "2", that ASIC
will now use the value "2" for the constant value of "1" wherever "1" is
referenced your program. For example, suppose you wrote a subroutine
called ADD that added the value of argument 2 to the value of argument 1
and stored the result in argument 1:
CALL SUB ("ADD", 1,33)
PRINT "1=";
PRINT 1
END
Program output is:
1=34
Instead, you would want to code the program as follows:
A=1
CALL SUB ("ADD",A,1)
PRINT "A=";
PRINT A
PRINT "1=";
PRINT 1
END
Program output is:
A=34
1=1
Page - 58
CALL (Continued)
CAUTION:
IF YOU CALL A ".BAT" FILE AND DO NOT LOAD A COPY OF COMMAND.COM,
THE RESULTS ARE UNPREDICTABLE (SEE ABOVE FOR AN EXAMPLE OF HOW TO CALL
BAT FILE).
You may use the debugger with programs which contain "CALL"
statements. However, the programs you call should not themselves
contain debugging code. For example, if A.ASI calls B.ASI, then make
sure you compile B.ASI with the "Debugging Code" option OFF before you
try to debug program A.ASI. Failure to do so will cause the debugger to
behave erratically. This also applies to programs you write using other
compilers, since they also use the same interrupt as ASIC (INT 3).
See also:
RUN,COMMAND$
CHDIR
Format: CHDIR string1
Description:
This statement will change the current directory to that specified
in string1. If an error occurs when ASIC executes this command, it will
set the System ERROR variable. A list of possible error codes is listed
in the Error Messages Chapter of the ASIC Manual.
Example:
CHDIR "\DOS"
IF ERROR = 0 THEN NOERROR:
If Drive "C" was the current drive, then this statement would change the
current directory to "C:\DOS".
CHDIR "C:\DOS"
This statement would change the current directory on drive C to "C:\DOS"
whether or not drive C is the current drive. It would NOT change the
default drive to "C". Note that DOS retains a current directory for
each disk drive on your computer.
See also:
MKDIR, RMDIR
Page - 59
CHR$
Format: string1 = CHR$(number1)
Description:
This function converts an integer in the range of 0-255 to an
ASCII character, and stores in string1.
Example:
A$ = CHR$(49)
After execution of this statement, "A$" will contain "1", since "1" is
represented by ASCII 49.
Comments:
If number1 is outside the range 0-255, then the least
significant byte of the integer is converted to string1.
CLOSE
Format: CLOSE number1
Description:
This function closes the file number identified by number1. If an
error is returned by DOS, the system variable "ERROR" will be > 0.
Example:
CLOSE 1
IF ERROR > 0 THEN CHECKERROR:
After successful execution of the CLOSE statement, the file previously
opened as file 1 will be closed. If an error is returned by DOS, the
ERROR variable will be set by ASIC to a non-zero value.
Comments:
IF YOU FAIL TO CLOSE AN OPEN FILE (WHICH WAS OPENED FOR WRITING),
YOU MAY LOSE DATA, SINCE FILE I/O IS BUFFERED, AND THE LAST BUFFER MAY
NOT HAVE BEEN FLUSHED.
Also, number1 may only be a constant with the value of 1-3.
See Also:
OPEN,PRINT#,INPUT#
Page - 60
CLS
Format: CLS
Description:
This function clears the screen.
Example:
CLS
After execution of the above statement, the screen will be cleared.
CODE
Format: CODE number1[,number2...numberN]
Description:
This function may be used to insert machine language code directly
into your program. Number1 through numberN should be integer constants
in the range of 0-255. At least one number must be specified, however,
ASIC will allow up to 30 per CODE statement.
Example:
CODE 205,5
This statement represent the machine code generated from the assembly
language statement "INT 5". INT 5 is the BIOS routine which will print
the screen to the printer. After execution of these statements in your
program, the current screen contents would be printed on your printer.
Comments:
THIS STATEMENT IS INTENDED FOR ADVANCED PROGRAMMERS. THIS
STATEMENT IS VERY POWERFUL, AND IF YOU DON'T UNDERSTAND MACHINE LANGUAGE
YOU COULD EASILY CRASH YOUR PROGRAM.
When you use this statement, be sure to save the contents of the
following 8088 registers if you plan to modify them, and restore them
before returning to ASIC. Otherwise the results may be unpredictable.
Registers: DS/CS/ES/SS. Also, make sure you clean up the stack before
you return (ie, if you push a value to the stack, make sure you pop it
before you return to ASIC) Failure to do so, will almost certainly
cause your program to crash.
Page - 61
COLOR
Format: COLOR number1,number2
Description:
This function is used to set the foreground and background screen
colors. The foreground color is specified in number1, the background
color in number2.
Valid Colors: Foreground Background
---------- ----------
Black 0 0
Blue 1 1
Green 2 2
Cyan 3 3
Red 4 4
Magenta 5 5
Brown 6 6
White 7 7
Dark Gray 8
Light Blue 9
Light Green 10
Light Cyan 11
Light Red 12
Light Magenta 13
Yellow 14
Bright White 15
Note: Colors 8-15 when specified for background color
result in blinking text.
Example:
COLOR 4,8
After execution of this statement, future characters written to the
screen will be Blinking Red on a Black Background.
Page - 62
COMMAND$
Format: string1 = COMMAND$
Description:
This statements retrieves any command line arguments that were
entered and stores them in string1.
Example:
If your program was invoked with: MYPROG XXX
And if your program MYPROG.ASI contained the following:
A$=COMMAND$
A$=LTRIM$(A$)
IF A$="" THEN
PRINT "Enter File Name ";
INPUT A$
ENDIF
OPEN "I", 1, A$
The above example would open file "XXXX" for input. If the user
had invoked the program by typing "MYPROG" with no parameters, then the
program would prompt for the file name to open.
Comments:
In the integrated environment, you can specify command line
arguments on the "Run" Menu.
This statement is an extension over BASICA/GWBASIC.
Page - 63
COMSTAT
Format: number1 = COMSTAT (number2)
Description:
This statement returns the status of a com port. Number2 should
contain "0" for COM1, or "1" for COM2. The status of that COM port is
returned in number1. Each bit in number1 represents a different piece
of information. These are described in the table below. Note that you
may test if a bit is on/off using the ZBIT command.
Example:
PORTSTAT = COMSTAT (0)
DATAREADY = ZBIT(8,PORTSTAT)
IF DATAREADY = 1 THEN GORECEIVE:
These statements do the following. The first retrieves the status of
COM1 to the variable PORTSTAT. The second checks to see if bit 8 is on,
DATAREADY will contain 1 if so, otherwise it will contain 0. Since Bit
8 is used to determine if data is waiting to be received from the port,
if DATAREADY = 1 then the program will transfer to the label GORECEIVE:
which would contain code to RECEIVE data from the port.
Comments:
Status Codes Returned by COMSTAT (Meaning when set to 1)
Bit 0 Delta clear-to-send
1 Delta data-set-ready
2 Trailing-edge ring detector
3 Delta receive line signal detect
4 Clear-to-send
5 Data-set-ready
6 Ring Indicator
7 Received line signal detect
8 Data Ready
9 Overrun error
10 Parity error
11 Framing error
12 Break-detect error
13 Transfer holding register empty
14 Transfer shift-register empty
15 Time-out error
See also:
OPENCOM,SEND,RECEIVE
Page - 64
CSRLIN
Format: number1 = CSRLIN
Description:
This function returns row of the cursor.
Example:
LOCATE 10,20
A = CSRLIN
The locate command will have positioned the cursor in row 10, column 20.
After execution of the CSRLIN statement, "A" will contain the value of
10.
See also:
POS
Page - 65
DATA
Format: DATA constant1[,constant2,...,constantn]
Description:
This statement is used store integer, decimal and string constants
in memory for later retrieval by READ statements. At least one constant
must be specified, although multiples of each type are permitted.
Example:
DATA 1,"APPLE",2&,"ORANGES",1.2345
READ A
READ A$
READ B&
READ B$
READ C@
The above statements are equivalent of entering the following code:
A=1
A$="APPLE"
B&=2&
B$="ORANGES"
C@=1.2345
Comments:
All DATA Statements must be placed at the beginning of the program,
before all other statement types, except DIM or REM statements (or blank
lines). DIM statements, if specified, must precede all other statements
including DATA statements except REM statements (or blank lines). As
long as you follow these rules, you may specify an unlimited number of
DATA statements.
GWBASIC/BASICA does not require quotes around string constants in
some instances. ASIC always requires quotes around string constants.
See also:
READ,RESTORE
Page - 66
DATE$
Format: string1 = DATE$
Description:
This function returns the value of the system date in the format of
"MM-DD-YYYY".
Example:
A$=DATE$
PRINT A$
After executing these statements, the date stored in the PC
System Clock will be displayed on the screen.
Comments:
Note: if the date printed is wrong, you have probably not set the
system clock. Most older XTs and PCs do not have a battery to preserve
the DATE and TIME in the system clock, so you have to set them each time
you power up the PC. Most ATs and newer PCs have a battery backup, so
that the date is preserved for you.
Unlike GWBASIC/BASICA, you cannot set the system date with DATE$,
however, you can set the system date from DOS by typing DATE.
See also:
TIME$, TIMER
DEFSEG
Format: DEFSEG = number1
This function is used to alter the default data segment used when
peeking and poking data with PEEK and POKE statements. DEFSEG, PEEK,
and especially POKE are not recommended for beginners. If number1 =-1,
then the data segment address is set back to the ASIC default data
segment address.
Example:
DEFSEG = -1
Execution of the above statement would reset the default data segment to
the default ASIC data segment.
See also:
PEEK, POKE, BLOAD, BSAVE
Page - 67
DIM
Format: DIM variable(integer1)
Description:
This statement will create one dimensional arrays. An integer,
decimal or string variable name must be specified in variable. Integer1
contains the number of elements in the array.
Example:
DIM A(10)
DIM A&(20)
DIM A$(5)
DIM A@(3)
In this example an array of 10 normal integer variables is defined, an
array of 20 long integer variables is defined, an array of 5 string
variables is defined and an array of 3 decimal variables is defined.
Comments:
On the DIM statement, number1 may only be a constant. Also, DIM
statements must appear before all other statement types in the program
except REM statements (or blank lines).
END
Format: END [(number1)]
Description:
This statement causes your program to terminate and return to DOS,
optionally setting a return code. Number1 may be optionally specified
to set the return code. If omitted, ASIC uses a return code of zero by
default.
Example:
END
In this example, the program will terminate and return to DOS with a
return code of zero.
END (20)
In this example, the program will terminate and return to DOS with a
return code of "20".
Comments:
The optional return code is an extension over GWBASIC/BASICA.
Page - 68
ENVIRON$
Format: string1 = ENVIRON$(number1)
Description:
This statement will retrieve DOS environment strings. Number1
identifies which string to retrieve. If found, the string is placed in
string1. If not found, a NULL string (length=0) is stored in string1.
Example:
FOR I=1 TO 5
A$=ENVIRON$(I)
PRINT A$
NEXT I
The above example will retrieve the first five DOS environment strings
and display them.
Comments:
If the requested DOS environment string entry is greater than 80
characters in length, ASIC will truncate it at 80 characters.
Environment strings may be set in DOS using the SET command.
Environment strings are one way of passing information to your program.
Refer to your MS DOS Manual for more information. Common uses of this
command are to retrieve the user's PATH statement, or the COMSPEC
variable.
Page - 69
FILEPOS
Format: number1 = FILEPOS (number2,number3) <--Format 1
number1 = FILEPOS (number2,EOF) <--Format 2
number1 = FILEPOS (number2,CURRENT) <--Format 3
Description:
This statement is used to set or retrieve the read/write position
for files opened in Random mode. In all three formats, number2 is the
file number of the file. This file number must have been previously
opened for Random mode by the OPEN statement. Format 1 is used to set
the current read/write position of the file specified by number2.
Number3 should be the offset (in bytes) from the start of the file.
Format 2 is used to set a read/write position of a random file to the
end of the file. Format 3 is used to retrieve the current read/write
position (as a byte offset from the beginning of the file) of the file.
In all cases, if an error occurs, the system ERROR variable will be set.
A list of these codes is contained in the Error Codes Chapter of the
ASIC Manual. If no error occurs, then number1 will be set to the
current read/write position of the file.
Example 1:
A&=FILEPOS(1, 100)
This example assumes that file 1 was previously opened for RANDOM I/O
using the OPEN statement. After execution of this statement, the
read/write position of file number 1 will be set to 100. Subsequent
PRINT # statements would write to the file starting at position 101.
Example 2:
A&=FILEPOS(1,EOF)
This example assumes that file 1 was previously opened for RANDOM I/O
using the OPEN statement. After execution of this statement, the
read/write position of file number 1 will be set to the end of the file.
Subsequent PRINT # operations to this file will result in data being
appended to this file.
Example 3:
A&=FILEPOS(1,CURRENT)
This example assumes that file 1 was previously opened for RANDOM I/O
using the OPEN statement. After execution of this statement, the
current read/write position of file number 1 will retrieved and stored
in A&. The read/write position of file number 1 will NOT be altered
after execution of this statement.
Page - 70
FILEPOS (Continued)
Comments:
If you wish to use this command with files larger than 32767 bytes,
you should use long integer or decimal numbers with this statement. If
you set the read/write position past the physical end of file and
attempt to read from the file, you will receive an error on the INPUT#
command. If you set the read/write position past the end of file and
issue a PRINT# command, the data will be correctly written at the
position you specified.
See also:
OPEN, INPUT#, PRINT#, CLOSE
Page - 71
FIND
Format: string1=FIND FIRST (string2,number1)
string1=FIND CONTINUE
Description:
The FIND command is used to search the current file directory for
file(s) which match a search string. This command has two versions.
FIND FIRST must be used to establish a new search and retrieve the first
matching file name. Thereafter, the FIND CONTINUE will retrieve
additional file names which match the search string. When performing
the FIND FIRST, string2 should contain the full or partial file name to
be searched for. This string can be up to 8 alphanumeric characters
optionally followed by a period and up to 3 alphanumeric characters for
the file extension. Standard DOS wild cards "*" and "?" may be included
in the search string. Number1 is used to specify a file attribute. If
number1 is "0", then all normal files in the directory will be searched.
(A normal file is one in which the hidden, system, volume label, or
directory attribute bit is NOT set). Setting various bits (see table
below) of number1 ON will expand the search to include normal files,
plus those whose attributes have been specified in number1. If a
matching file name is found, then it will be stored in string1. If an
error occurs, then the system ERROR variable will be set. A list of
ERROR codes is contained in the ERROR code chapter of the ASIC Manual.
After the initial FIND FIRST has been performed, you may search for
additional files which match the search string and attribute by issuing
a FIND CONTINUE statement.
Search Attributes bits (number1)
--------------------------------
BIT
0 Not Used
1 Hidden
2 System
3 Volume Label
4 Subdirectory
5-7 Not Used
Note that these attributes can all be specified simultaneously. For
example, to specify both hidden and system, use an attribute value of
&bin00000110 (in binary) or 6 (in decimal).
Page - 72
FIND (Continued)
Example:
SEARCH$="*.ASI"
ATTRIB=0
FILENAME$=FIND FIRST (SEARCH$,ATTRIB)
IF ERROR>0 THEN DONE:
PRINT A$
LOOP:FILENAME$=FIND CONTINUE
IF ERROR>0 THEN DONE:
PRINT A$
GOTO LOOP
DONE: PRINT "ALL MATCHING FILES DISPLAYED"
END
After execution of the above statements, all of the files with a file
extension of ".ASI" in the current directory will be displayed on the
screen.
Comments:
If you execute a FIND CONTINUE without executing a FIND FIRST, then
the results are unpredictable. Additional information is retrieved by
the FIND command besides the file name. Advanced programmers can also
find additional information using the PEEK command starting at offset
149 (from the default ASIC data segment). Do not modify this data. If
you do so, the results are unpredictable.
Additional File Information
---------------------------
Address Size (bytes) Description
149 1 File Attribute
150 2 File Time Stamp
152 2 File Date Stamp
154 4 File Size (bytes)
See also:
NAME, KILL, GETDIR, CHDIR, MKDIR, RMDIR
Page - 73
FOR/NEXT
Format: FOR number1 = number2 to number3
NEXT number1
Description:
These two statements are used to create a loop, so that you can
execute a portion of your program a certain number of times. All of the
code between the FOR and the NEXT statement will be executed a certain
number of times, but at least once. The actual number of times the loop
executes is dependent on number1/number2/number3. When the FOR statement
is encountered in your program, number1 is assigned the value of
number2. Then the statements up to the matching NEXT statement is
executed one time. Then, 1 is added to number1, and number1 is compared
to number3. If number1 is greater than number3 then the control passes
to the statement following NEXT. Otherwise, the program loops back up
to the statement following the FOR statement.
Example:
FOR I = 1 TO 2
FOR J = 3 TO 5
PRINT I;
PRINT J
NEXT J
NEXT I
PRINT "AFTER THE LOOP";
PRINT I;
PRINT J;
Execution of this section of code would result in the following
printout:
1 3
1 4
1 5
2 3
2 4
2 5
AFTER THE LOOP 3 6
Comments:
Unlike BASICA/GWBASIC, ASIC FOR/NEXT loops execute at least 1 time.
For example, the value "HELLO" will be printed in the following example.
It wouldn't have been in BASICA/GWBASIC.
FOR I = 1 TO 0
PRINT "HELLO"
NEXT I
Page - 74
FOR/NEXT (Continued)
Unlike GWBASIC/BASICA, arrays may be used for number1 and number2.
However, if number3 is an array, element zero will be used, regardless
of the subscript you specify.
Loops which range from a negative to positive number are not
supported (for performance reasons). Such loops will terminate after 1
iteration. For example, "FOR I =-10 to 10" will loop once.
ASIC will allow you to modify the value of number3, while
GWBASIC/BASICA ignores changes.
J=1
FOR I=1 TO J
J=2
NEXT I
The above loop will execute one time in GWBASIC/BASICA, but it will
execute two times in ASIC.
Also note: The storage type of number3 must be the same as
number1. For example, if "number1" is a decimal variable, then
"number3" must be a decimal variable--it may not be an integer variable.
GETDIR
Format: string1=GETDIR (number1)
Description:
This statement is used to retrieve the current DOS directory.
Number1 should be set to "0" to obtain the directory for the current
drive, "1" for the "A" drive, "2" for the "B" drive, etc. If the
statement is unsuccessful, the system ERROR variable will be set. A
complete list of ERROR codes is contained in the Error Code Chapter of
the ASIC Manual. The directory string will be stored in string1. The
directory string will not contain the drive letter, or the first "\".
Thus, if the current directory on the specified drive was "C:\ASIC",
then GETDIR would return "ASIC". If the current directory was the root
(eg, "C:\"), then GETDIR would return a NULL string ("").
Example:
A$=GETDIR(0)
After execution of this statement, the variable A$ will contain the name
of current directory on the current disk drive.
See also:
FIND, MDKIR, RMDIR, CHDIR
Page - 75
GOSUB
Format: GOSUB label1
Description:
This statement "calls" a subroutine called "label1". This
subroutine must contain a "RETURN". After the subroutine is executed,
control is returned to the next statement following the GOSUB.
Example:
GOSUB PRINTIT:
PRINT "All Done!"
END
PRINTIT: PRINT "It"
RETURN
After execution of this code the screen would contain:
It
All Done!
GOTO
Format: GOTO label1
Description:
This statement transfers program execution to the statement
identified by label1.
Example:
GOTO SKIPIT:
PRINT "YOU'LL NEVER GET HERE"
SKIPIT: PRINT "ALL DONE!"
After execution of this code, the screen will appear as follows:
ALL DONE!
Note that the first print statement never executes because of the GOTO.
Page - 76
IF/THEN/ELSE/ENDIF
Format: IF condition THEN label1 <--Format 1
IF condition THEN label1 ELSE label2 <--Format 2
IF condition THEN <--Format 3
<zero or more ASIC statements>
ENDIF
IF condition THEN <--Format 4
<zero or more ASIC statements>
ELSE
<zero or more ASIC statements>
ENDIF
Description:
This statement is used to conditionally transfer to a different
location in the program. The operand "condition" is one of the
following:
number1 > number2
string1 > string2
number1 = number2
string1 = string2
number1 < number2
string1 < string2
Format 1--If "condition" is true, control is transferred to label1.
Otherwise the program continues at the next statement.
Format 2--If "condition" is true, control is transferred to label1,
otherwise the program branches to label2 and continues execution from
there.
Format 3--If "condition" is true, the program will continue execution at
the next statement. If the condition is false, the program will branch
to the statement following the next ENDIF statement encountered.
Format 4--If "condition" is true, program will continue execution at the
next statement up to the next ELSE statement encountered, at which point
it will branch to the statement following the next ENDIF statement
encountered. If "condition" is false, the program will branch to the
next ELSE statement and resume execution at that statement.
Example 1:
IF A > 0 THEN APLUS:
In this example, if A is greater than zero, the program jumps to the
label called "APLUS:".
Page - 77
IF/THEN/ELSE/ENDIF (Continued)
Example 2:
IF A$="YES" THEN TRUE: ELSE FALSE:
In this example, if A$ contains the string "YES", the program jumps to
the label called "TRUE:", otherwise the program transfers to label
"FALSE:"
Example 3:
OPEN "I",1,"TEST.DAT"
IF ERROR>0 THEN
PRINT "ERROR OPENING FILE";
PRINT ERROR
END
ENDIF
REM rest of program follows
.
.
In this example, if there is an error opening file "TEST.DAT", the
program will print an error message and terminate. Otherwise control
will fall through to the REM statement and the program will continue.
Example 4:
PRINT "ENTER A NUMBER";
INPUT NUMBER
IF NUMBER > 100 THEN
PRINT "THAT'S A BIG NUMBER"
ELSE
PRINT "THAT'S A SMALL NUMBER"
ENDIF
Comments:
Formats 3 and 4 are BLOCK IF formats. You can nest BLOCK IF
statements up to 25 levels deep. The example below is shown three
levels deep.
IF A=1 THEN <-Level 1
IF B=2 THEN <-Level 2
IF C=3 THEN <-Level 3
PRINT "C=3, B=2, AND A=1"
ELSE
PRINT "C<>3, B=2, AND A=1" <-ELSE for Level 3
ENDIF <-ENDIF for Level 3
ENDIF <-ENDIF for Level 2
ENDIF <-ENDIF for Level 1
It's a good idea to indent your IFs, ELSEs and ENDIFs as shown
above. Otherwise matching IFs up with matching ENDIFs and ELSEs can
become very confusing.
Page - 78
INKEY$
Format: string1 = INKEY$
Description:
Used to retrieve keystrokes from the keyboard buffer. If a
character is waiting in the buffer, string1 will be set to the value of
that character, and that character will be removed from the keyboard
buffer. If the buffer is empty, string1 will be set to a value of ""
(that is, a null string with a length of 0). If an extended key is
pressed (for example the function keys F1 through F10), the system
variable EXTENDED will be set to 1, otherwise it will contain 0.
Example:
LOOP: X$=INKEY$
IF X$="" THEN LOOP:
The above code will cause the program to loop until a key is pressed.
Comment:
ASIC provides an extension here over BASICA/GWBASIC. The EXTENDED
system variable will allow you to detect special keys as mentioned
above. To do so requires an understanding of keyboard scan codes, which
is beyond the scope of the ASIC Manual. For more information I would
suggest Peter Norton's Programmer Guide to the IBM PC (Microsoft Press).
INP
Format: number1 = INP (number2)
Description:
This statement reads a byte from port number2 and stores the result
in number1.
Example:
A=INP(513)
A=ZBIT(4,A)
IF A=1 THEN TRIGGERPRESSED:
The above code will test the joystick port to see if the trigger is
being pressed on joystick 1. You need a game card and joystick for this
to work.
See also:
OUT
Page - 79
INPUT
Format : INPUT variable1 <--Format 1
INPUT variable1; <--Format 2
Description:
This statement will retrieve a line of text from the input buffer
and store it in variable1. There are two statement formats.
When using Format 1, ASIC will first issue the prompt "?". It will
then wait until the user enters a string or number and presses the
<return> or <enter> key. The type of data ASIC will expect is dependent
on the type of variable1 (integer, decimal, or string). If an integer
or decimal is being entered, ASIC will edit the input for validity. If
the edit fails ASIC will issue another "?" to the user, and will wait
for the number to be retyped. Only when a valid integer has been
entered will variable1 be updated, and only then will control return to
your ASIC program. Following a successful INPUT, ASIC will generate a
carriage return/line feed sequence and advance the cursor to the next
line.
When using Format 2, ASIC will NOT issue a prompt. It will still
edit the user input based on the type of variable. However, if the
input is invalid it does not reprompt the user to re-enter the data.
Instead, it will set the system ERROR variable to "1" and return control
to your ASIC program. The value stored in variable1 will be undefined
if the ERROR variable is set! ASIC will issue a carriage return, but it
will NOT issue a line feed. Format 2 is useful when you want to use the
INPUT statement with it's data edit capabilities in conjunction with a
data entry form. In this case, you don't want ASIC to write any prompts
to the screen, and you don't want ASIC to scroll the screen.
Example 1:
PRINT "Enter a String";
INPUT A$
ASIC will issue the prompt:
Enter a String?
It will then wait until you enter a string or press enter. If you
pressed enter with no characters A$ would contain "" (ie its length
would equal 0), otherwise A$ would contain the string entered.
Page - 80
INPUT (Continued)
Example 2:
INPUT I
In this example ASIC will issue the prompt:
?
ASIC will then wait for you to enter a valid number. If you enter an
invalid number, say "x", ASIC will reissue the "?" prompt and wait for
you to retype your input. Once the input has been edited by ASIC, "I"
would contain the number entered.
Example 3:
LOOP:
PRINT "YOUR CHOICE?";
INPUT A;
IF ERROR=1 THEN
PRINT "THE NUMBER YOU ENTERED WAS INVALID"
END IF
GOTO LOOP:
This example uses Format 2. Notice that since ASIC will not issue a
prompt, we must include the "?" on the PRINT statement or it will not
appear on the screen. Also note that errors fall through. If an error
is detected the message "THE NUMBER YOU ENTERED WAS INVALID" will be
displayed, and the program will branch to the label "LOOP:" to ask for
the input again.
See Also:
INKEY$
Page - 81
INPUT#
Format: INPUT# number1, number1 <-Format 1
INPUT# number1, string1 <-Format 2
INPUT# number1, string1 CRLF <-Format 3
INPUT# number1, string1 NONULL <-Format 4
INPUT# number1, string1 BYTE <-Format 5
Description:
This statement will read a variable from a file identified by file
number number1. It will be stored in number1/string1. If an error
occurs during a read, the system variable ERROR will be set to a non-
zero value. The possible errors are listed in the error messages
section the of the ASIC Manual. If you read a file past its end, the
contents of variable1 are undefined.
Five formats of this statement are provided to provide greater
flexibility in reading files written by ASIC and non-ASIC programs. The
five formats are summarized below:
Format 1 -- Read numeric data from a file previously written by ASIC.
Format 2 -- Read string data from a file previously written by ASIC.
Format 3 -- Read strings from a non-ASIC file. Assumes the strings
(CRLF) will be terminated by a CR/LF (carriage return/linefeed).
Note that ASIC still considers a NULL character, if
encountered, as an end of string character. Also ASIC
terminates the string if 80 characters are read before
encountering a CR/LF pair.
Format 4 -- Read strings from a file until 80 characters or the end
(NONULL) of the file is reached. Note that ASIC still considers a
NULL character, if encountered, as an end of string
character.
Format 5 -- Reads a single byte from a file and stores it in string1.
(BYTE) If ASIC has read a NULL byte, the string will be set to
NULL and its length will be 0.
Example 1:
OPEN "I",1,"TEMP.DAT"
INPUT#1, A$
IF ERROR=99 THEN ENDOFFILE:
In this example, a string will be read from file "TEMP.DAT", and it will
be stored in A$. The system ERROR variable is then checked to see if
End of file was reached. Note, other ERRORS could also be returned by
INPUT#, besides error code 99. Refer to the error messages section for
more information.
Page - 82
INPUT# (Continued)
Example 2:
OPEN "I",1,"TEMP.DAT"
INPUT#1, A$ NONULL
IF ERROR=99 THEN ENDOFFILE:
In this example, ASIC will read 80 characters from the file "TEMP.DAT",
or up until the next NULL character in the file, which ever comes first.
Example 3:
OPEN "I",1,"CONFIG.DAT"
INPUT#1, A$ BYTE
IF ERROR=99 THEN ENDOFFILE:
In this example, ASIC will read a single character from the file
"CONFIG.DAT", and place it in the variable A$.
Example 4:
OPEN "I",1,"TEST.DAT"
INPUT#1, A
IF ERROR=99 THEN ENDOFFILE:
In this example, ASIC will read an integer value from the file
"TEST.DAT", and place it in the integer variable "A".
Example 5:
OPEN "I",1,"ASCII.DAT"
OPEN "O",2,"ASCII.NEW"
CR$=CHR$(13)
LF$=CHR$(10)
CRLF$=CR$+LF$
READMORE:
INPUT #1, A$ CRLF
IF ERROR=96 THEN WRITE:
IF ERROR>0 THEN ENDOFFILE:
WRITEWITHCRLF:
PRINT #2,A$ NONULL
PRINT #2,CRLF$ NONULL
GOTO READMORE:
WRITE:
PRINT #2, A$ NONULL
GOTO READMORE:
ENDOFFILE:
CLOSE 1
CLOSE 2
This example copies file ASCII.DAT to file ASCII.NEW. Note: Even
though ASIC can only handle 80 character strings, this example shows
that by checking the ERROR variable for a value of 96, it is possible to
read the file in up-to-80-character chunks and reassemble the strings in
their original forms in the new file. Also note that ASIC will still
treat any NULL characters in the file as an end of string character.
Page - 83
INPUT# (Continued)
Comments:
Note that number1 must be a constant in the range of 1-3. It
identifies a file by file number which must have previously been opened
by an OPEN command for modes INPUT or RANDOM.
ASIC assumes that integers will be stored in files in 2-byte binary
format, which is the format ASIC writes integers. Consequently, If a
file contained a string "123", but you told ASIC to read integer "X",
then ASIC would read two bytes from the file and interpret "12" as two
binary bytes that it would then combine and store as "X". "X" would
contain the integer value 12849. Thus to read an integer correctly, you
will have had to previously written it with an ASIC program.
See Also:
OPEN, CLOSE, PRINT#, FILEPOS
INSTR
Format: number1 = INSTR (string1,string2)
Description:
This statement is used to determine if a given substring exists
within a string, and if so, the character position at which the
substring first appears in the string. String1 is the string to be
searched. String2 contains the substring to find within string1. The
character position of string2 within string1 is returned in number1. If
the string is not found then number1 is set to zero.
Example 1:
A=INSTR("THE QUICK BROWN FOX","QUICK")
After execution of this statement, variable "A" will contain the value
5, which is the offset of the string "QUICK" within the string "THE
QUICK BROWN FOX".
B=INSTR("FOX","HEN")
After the execution of this statement, variable "B" will contain 0,
since the string "HEN" is not found within the string "FOX".
See also:
LEFT$, RIGHT$, MID$, LEN
Page - 84
INT86
Format: INT86(number1,AX,BX,CX,DX,DI,SI,BP,DS,ES)
Description:
This statement is used to call a DOS, BIOS, or custom-written
Interrupt. Number1 must be a constant, and should identify the number
of the interrupt to be called. The fields following number1 represent
the CPU registers. For example, ASIC will move the value from the ASIC
variable "AX" to the CPU register "AX" prior to performing the interrupt
call. After the call, ASIC will move the value from the CPU register
"AX" to the ASIC variable "AX". Your ASIC program can then use this
"AX" variable just like any other integer variable in the rest of the
program. Each of the registers listed (AX,BX,CX,DX,DI,SI,BP,DS,ES) must
be included on the INT86 statement in the same order as shown in the
Format statement above. The exception to this rule, is that you can
substitute "NA" for any register you do not need for the call. The BP
register may be used to pass values to the INT86 call, however, unlike
all of the other registers, ASIC does not return the value of the BP
register following the INT86 call.
Example 1:
INT86(5,NA,NA,NA,NA,NA,NA,NA,NA,NA)
The above example shows the code to perform a screen print to the
printer. This example will call INT 5 (BIOS Print Screen Interrupt),
pass no parameters to the call, and receive no return values from the
call.
Example 2:
AX=&hex3600
DX=0
INT86(&hex21,AX,BX,CX,DX,NA,NA,NA,NA,NA)
PRINT "Default Drive has:"
PRINT
PRINT "Sectors/Cluster";
PRINT AX
PRINT "Available Cluster Count";
PRINT BX
PRINT "Bytes/Sector";
PRINT CX
PRINT "Total Clusters";
PRINT DX
Page - 85
INT86 (Continued)
This example show a more complex call to DOS to find out free disk space
information for the current drive. DOS Interrupt 21 (hex) function 36
(hex) is used to retrieve this information. The AX register is used to
pass the function number. The DX register is used to select the disk
drive (0=the default disk drive). Note that the BX and CX registers
were included on the call. No parameters are being passed to the call
in these registers, however, we'll be receiving information back from
DOS in them, so they need to be on the INT86 statement. Since the
SI,DI,BP,DS, and ES registers are not needed by the call, they have been
substituted with "NA" which you can think of as meaning "Not Applicable"
to this call. After the call, the example program will display
information about the default disk drive.
Comments:
This statement is intended for advanced programmers. To use it
properly, you must have some knowledge of assembler language, or (at
least) the CPU registers in the IBM PC. You also need a DOS or BIOS
reference manual to identify which registers to pass to each interrupt,
and to identify the values to place in those registers.
One register was required for ASIC housekeeping after the INT86 call.
This is why the BP register is unavailable to receive return values from
calls. The BP register was chosen, because none of the DOS or BIOS
Interrupts use this register to return values. If you write your own
interrupts and want to call them from an ASIC program, remember that you
can pass the BP register to the interrupt, but the ASIC "BP" variable
will not be updated following the interrupt.
If a register is not needed for the call, specify "NA" instead of the
register name. ASIC does not generate any code for "NA" registers, and
this will reduce the size of your program.
Page - 86
KILL
Format: KILL string1
Description:
This statement is used to delete a file from disk. It is similar
to the DOS ERASE Statement. Specify the file to delete in string1. You
can specify the full path to the file, or just the file name if it is in
the current directory. If an error occurs (eg, File not found), then
ASIC will set the System ERROR variable. A list of codes returned by
KILL is listed in the ERROR Messages Chapter of the ASIC Manual.
Example:
KILL "TEMP.DAT"
IF ERROR = 0 THEN NOERROR:
REM CHECK ERROR CODES HERE
After this statement is executed, the file "TEMP.DAT" will have been
erased from the current directory of the current drive, and will no
longer be accessible from DOS or your programs.
LCASE$
Format: string1=LCASE$(string2)
Description:
This statement will convert all of the letters in string2 from
upper case to lower case, and store the result in string1.
Example:
A$=LCASE$("123 Main Street, USA")
After the execution of this statement, the variable A$ will contain the
string "123 main street, usa".
See also:
UCASE$
Page - 87
LEFT$
Format: string1=LEFT$(string2,number1)
Description:
This statement will copy number1 characters from the left of
string2 to string1.
Example:
A$=LEFT$("RED RIDING HOOD",3)
After the execution of the above statement, the variable A$ will contain
the string "RED".
See also:
MID$, RIGHT$
LEN
Format: number1 = LEN (string1)
Description:
This statement returns the length (number of characters) of a
string, and stores the length in number1.
Example:
A$="abc"
LENGTH1 = LEN(A$)
After execution of these statements, LENGTH1 would contain 3.
Page - 88
LOCATE
Format: LOCATE row,column
Description:
This statement is used to position the cursor to a row and column.
Row and Column should be integers. Row has the range 0-24, Column has
the range 0-79. This function does not perform edits on the ranges of
row and column. Consequently using this function with values outside
these ranges will have unpredictable results.
Example:
LOCATE 10,20
PRINT "HELLO"
After execution of these statements, the message "HELLO" will appear
beginning at row 10, column 20.
Page - 89
LPRINT
Format: LPRINT printobject [;] <--Format 1
Description:
This statement is used to send the contents of printobject to an
attached printer. "printobject" can be any valid ASIC datatype:
integer, string, or decimal number. Optionally, a ";" can be included
with this statement to suppress a carriage return/line feed which ASIC
normally also sends to the printer following each LPRINT. This can be
used to string several printobjects together on a single print line.
Example:
A=12345
LPRINT "The value of A is: ";
LPRINT A
After execution of these statements the printer would print:
The value of A is: 12345
Comments:
Note that if the printer is not "online" that DOS will issue a
message to "Abort, Retry, or Ignore". This could overwrite a portion of
the program display, unless not planned for.
Note also, that some printers do not begin printing until they
receive a carriage return/line feed sequence.
Page - 90
LTRIM$
Format: string1=LTRIM$(string2)
Description:
This statement will remove all leading spaces from string2 and
store the result in string1.
Example:
A$=" XYZ"
A$=LTRIM$(A$)
After execution of these statements, the variable A$ will contain the
string "XYZ" with no leading spaces.
See also:
RTRIM$
MID$
Format: string1 = MID$(string2,number1,number2)
Description:
This statement is used to extract a substring from string2
beginning at position number1 within string2 and continuing for number2
bytes. This value is then stored in string1.
Example:
A$="THE QUICK BROWN FOX"
B$=MID$(A$,1,4)
C$=MID$(A$,11,9)
D$=B$ + C$
After execution of these statements, the contents of A$ will be
unchanged. The contents of B$ will be "THE ". The contents of C$ will
be "BROWN FOX", and the contents of D$ will be "THE BROWN FOX".
See also:
LEFT$, RIGHT$
Page - 91
MKDIR
Format: MKDIR string1
Description:
This statement is used to create a new DOS directory. Specify the
directory to create in string1. If ASIC is unable to create the
directory, it will set the System ERROR variable. A list of ERROR codes
may be found is the Error Messages Chapter of the ASIC Manual.
Example:
MKDIR "WORK"
IF ERROR = 0 THEN NOERROR:
This code would create a directory called "WORK" under the current
directory of the current drive.
Example 2:
MKDIR "C:\WORK"
This code would create a directory called "WORK" under the root
directory of drive "C".
See also:
CHDIR,RMDIR
MOD
Format: integer1 = number2 MOD number3
Description:
This statement will perform modulo division of number2 by number3
and store the remainder (instead of the quotient) in integer1.
Example:
A = 8
B = 5
C = A MOD B
After execution of these statements, variable "C" will contain the value
"3" which is the remainder of the division of 8 by 5.
Page - 92
NAME
Format: NAME string1 AS string2
Description:
This statement will allow you to rename a file. String1 should
contain the current file name, and string2 should contain the new name
for the file. If ASIC is unable to rename the file, it will set the
System ERROR variable. A list of ERROR codes is contained in the Error
Messages Chapter of the ASIC Manual.
Example:
NAME "olddata.txt" AS "newdata.txt"
IF ERROR = 0 THEN SUCCESS:
After execution of these statements, file "olddata.txt" will have been
renamed to "newdata.txt"
Comments:
You cannot rename a file to a new disk drive.
OPEN
Format: OPEN string1, number1, string2
Description:
This statement is used to open a file for input or output. Up to
three files may be open concurrently, these are known as file 1, 2, or
3. You must specify with number1 which file number you wish to open
this file as. Number1 may only be a constant. The file mode is
specified in string1. The valid values are "I" for INPUT, "O" for
OUTPUT, "A" for APPEND, and "R" for RANDOM INPUT/OUTPUT. The file name
is specified with string2. Any errors returned from DOS on the OPEN
call will be returned in the system variable "ERROR".
Example:
OPEN "I",3,"INFILE"
IF ERROR > 0 THEN PROCESSERROR:
OPEN "O",1,"A:\NEWFILE.DAT"
IF ERROR > 0 THEN PROCESSERROR:
In this example, two files are opened. File "INFILE" from the current
disk drive and directory will be opened as file number 3 for input. The
file "A:\NEWFILE.DAT" will be opened for output as file number 1. Note
that if "A:\NEWFILE.DAT" previously existed, it contents will be
destroyed in preparation for writing.
See also:
CLOSE, FILEPOS, INPUT#, PRINT#
Page - 93
OPENCOM
Format: OPENCOM(number1,number2,number3,number4,number5)
Description:
This statement is used to initialize the serial port. Number1 is
used to specify the baud rate. Number2 specifies parity. Number3
specifies stop bits. Number4 specifies bytesize, and Number5 identifies
which port to open (see the tables below). OPENCOM does not check the
validity of the values you give it.
(number1) (number2)
BAUD RATE PARITY
------+----------- ------+------------
VALUE | DESCRIPTION VALUE | DESCRIPTION
0 | 110 baud 0 | No Parity
1 | 150 baud 1 | Odd Parity
2 | 300 baud 3 | Even Parity
3 | 600 baud
4 | 1200 baud (number3)
5 | 2400 baud STOP BITS
6 | 4800 baud ------+------------
7 | 9600 baud VALUE | DESCRIPTION
0 | One Stop Bit
1 | Two Stop Bits
(number4) (number5)
BYTE SIZE COM PORT
------+------------ ------+------------
VALUE | DESCRIPTION VALUE | DESCRIPTION
2 | 7 Bits 0 | Com1
3 | 8 Bits 1 | Com2
Example:
OPENCOM(2,0,0,3,0)
This statement would open COM1 at 300 baud, No parity, 1 Stop bit, 8 bit
bytesize.
See also:
COMSTAT,RECEIVE,SEND
Page - 94
OUT
Format: OUT (number1,number2)
Description:
This statement writes a byte to a port. Number1 should contain the
port to write to. Number2 should contain an integer value in the range
of 0-255 to be written to the port.
Example:
OUT 512,0
The above statement would send a byte with the binary value of "0" to
port number 512.
See also:
INP
PEEK
Format: number1 = PEEK (number2)
Description:
This statement is used to examine actual memory location values
directly. By default, the ASIC DS address is assumed. However, this
may be overridden with the use of the DEFSEG command. The value of the
byte at address number2 is stored in number1.
Example:
DEFSEG = &hexB800
A = PEEK (0)
The above statements will retrieve the first byte of video memory for a
CGA/EGA/VGA card and store it in variable "A".
Comments:
Since the Intel 8088 architecture is segmented in 64k segments,
number2 is limited to the range of 0-65535.
See also:
DEFSEG, POKE
Page - 95
POINT
Format: number1 = POINT (number2,number3)
Description:
This statement is used to determine the color of a given pixel in
medium and high resolution graphics modes. The row to test is specified
with number2, the column with number3. The color of the pixel is stored
in number1.
Example:
PCOLOR = POINT (10,20)
After execution of this statement, PCOLOR will contain the color of the
pixel in row 10 column 20.
Comments:
No range checking is performed on row and column. If the specified
row or column is outside the valid range for the given graphics mode,
the results are unpredictable.
See also:
PSET, PRESET, SCREEN
Page - 96
POKE
Format: POKE number1, number2
Description:
This instruction is used store the byte value number2 at the memory
address specified by number1. By default, ASIC uses its default data
segment address, however, this may be overridden with the DEFSEG
statement.
Example:
DEFSEG = &hexB800
POKE 0,1
The above statements will store a byte with the binary value of "1" in
the first byte of video memory for a CGA/EGA/VGA card.
Comments:
This statement is NOT RECOMMENDED FOR BEGINNERS. Directly
overwriting memory locations can be disastrous, unless you know what is
stored at that address. This can cause program "hangs", system crashes,
etc.
Since the Intel 8088 architecture is segmented in 64k segments,
number2 is limited to the range of 0-65535.
See also:
DEFSEG, PEEK
POS
Format: number1 = POS (number2)
Description:
This statement finds the column number of the cursor and stores it
in number1. number2 is a dummy argument included only because a dummy
argument is required in BASICA/GWBASIC.
Example:
A = POS(0)
After this statement executes, A will contain the column number of the
cursor.
See also:
CSRLIN
Page - 97
PRESET
Format: PRESET (number1,number2)
Description:
This statement is used to set the color of a pixel to the
background color. The row of the pixel is specified in number1, and the
column is specified in number2. This statement only works in graphics
modes.
Example:
PRESET (10,20)
The pixel at row 10 column 20 would be set to the background color.
See also:
PSET, SCREEN, POINT
Page - 98
PRINT
Format: PRINT [printobject1 [;]] <--Format 1
Description:
This statement is used to print to the screen. Printing begins at
the current cursor location. Printobject1 is defined as any valid ASIC
data type: integer constant, integer variable, decimal constant,
decimal variable, string constant, string variable, and arrays. The
semicolon is optional and is used to tell ASIC if you want a carriage
return/line feed issued. A semicolon at the end of a PRINT statement
will suppress the carriage return/line feed ASIC normally issues. If no
operands are supplied, ASIC will simply issue a carriage return and line
feed.
Example 1:
A=1000
PRINT "A=";
PRINT A
PRINT
PRINT "DONE!"
After execution of these statements your screen would display:
A= 1000
DONE!
See also:
COLOR, SCREEN, LOCATE
Page - 99
PRINT#
Format: PRINT# constant1, printobject1 [NONULL]
Description:
This statement is used to write integers, decimals and strings to
disk. Constant1 identifies the file number that the file was opened as.
This must be a constant with a value of 1, 2 or 3. The file must have
been previously opened with the OPEN command. If printobject1 is a
string, you can also add the optional argument "NONULL", which will
cause ASIC to suppress the trailing NULL character it would normally
write to disk. DOS errors are returned in the system variable "ERROR".
A list of these error codes may be found in the error messages section
of the ASIC Manual. Also, refer to the technical details section of the
ASIC Manual for more information on the format in which ASIC writes the
data to disk.
Example:
PRINT# 1, "HELLO"
IF ERROR = 255 THEN DISKFULL:
PRINT# 1, "WORLD"
IF ERROR = 255 THEN DISKFULL:
After successful execution of the print statements the file identified
by file number 1 would contain "HELLO0WORLD0" . Note that the "0"
following HELLO and WORLD in our example represents the ASCII null
character. Strings in ASIC are always internally terminated with ASCII
null characters. By default, these nulls are also written to disk.
PRINT# 2, "HELLO" NONULL
In this example, the string "HELLO" would be written to file #2, and no
trailing NULL will be written to disk.
PRINT #3, 1234
In this example, the number "1234" would be written to file #3 as two
bytes in Intel binary format (the file would contain the two hexadecimal
bytes: D2 04).
Page - 100
PRINT# (Continued)
Comments:
Note that while ASIC doesn't generate carriage returns and line feeds
for you as it does with the PRINT command, you can write these
characters to disk as follows:
A$=CHR$(13)
B$=CHR$(10)
A$ = A$ + B$
PRINT #1, A$
You might be wondering about the purpose of the NONULL option. ASIC
normally writes trailing NULLs with strings. This is desirable if you
plan to read the file exclusively with other ASIC programs.
However, sometimes you may want to write a string for use by another
program. In this case, the NULL character sometimes confuses the other
program. Specifying the NONULL option will cause ASIC to suppress the
offending NULL character.
What happens if you read a string that is terminated by a Carriage
Return/Line Feed Sequence (such as GWBASIC/BASICA produces)? In this
instance, specify the CRLF option on the INPUT# statement. Then ASIC
will read the string until it finds a CR/LF or until it reads 80
characters, whichever comes first.
See also:
OPEN, CLOSE, INPUT#, FILEPOS
Page - 101
PSET
Format: PSET (number1,number2),number3
Description:
This statement is used to set a pixel to a specified color in
graphics modes. The row is specified in number1, the column in number2,
and the color in number3. Note that no range checking is performed on
number1 or number2. A row or column specified outside the range allowed
by the graphics mode in use can result in unpredictable results.
Example:
PSET (10,20),1
In this example the pixel defined at row 10 and column 20 will be set to
color 1.
See also:
PRESET, SCREEN, POINT
RANDOMIZE
Format: RANDOMIZE
Description:
This statement will cause the seed for the random number
generator to be reseeded using the system timer. This statement should
always precede the first RND statement in your program, unless you want
the same sequence of random numbers generated.
Example:
RANDOMIZE
The above statement would insure that each time your program runs, any
subsequent RND numbers generated would be different.
See also:
RND
Page - 102
READ
Format: READ variable1
Description:
This statement reads a constant from DATA statements into a
variable. Variable1 is a string, decimal or integer type variable.
Example:
DATA 7,"CARGO"
READ A
READ B$
After execution of these statements, "A" will contain 7, and B$ will
contain "CARGO".
Comments:
ASIC does not check to see that the data type on the READ statement
matches the data type on the DATA statement. It is up to the programmer
to insure that the types match. The above example is correct. The DATA
statement contains an integer, then a string. This is the same sequence
in which the DATA is READ (ie, integer, then string). In the above
example, if the read statements were reversed, the contents of A and B$
are undefined. Also note that ASIC does not check to see that you don't
read past the end of the DATA you specified. In the above example, if
you had a third READ statement that contained "READ C$", then C$ would
contain random garbage, since you read three values, but only provided
data for two.
See also:
DATA,RESTORE
Page - 103
RECEIVE
Format: variable1 = RECEIVE(number2)
Description:
This statement will read a byte from the specified serial port.
Number2 identifies which port to read (0=COM1, and 1=COM2). The byte
read is stored in variable1 (which may be an integer or string type
variable). Before executing this statement you should first check to
see if there is data waiting to be read. Executing this statement when
data is not waiting can cause your PC to "hang" until data is received
at the hardware serial port. The example below illustrates how to
determine if data is waiting to be received.
Example:
OPENCOM(2,0,0,3,0)
PORTSTAT = COMSTAT(0)
DATAREADY = ZBIT(8,PORTSTAT)
IF DATAREADY = 0 THEN NODATAWAITING:
A$=RECEIVE(0)
These statements do the following. The first retrieves the status of
COM1 to the variable PORTSTAT. The second checks to see if bit 8 is on,
DATAREADY will contain 1 if so, otherwise it will contain 0. Since Bit
8 is used to determine if data is waiting to be received from the port,
if DATAREADY NOT = 0 then the program will RECEIVE data from the port to
variable "A$".
Comments:
Variable1 can be either a string or integer type variable.
However, if variable1 is a string, bear in mind that you cannot directly
receive a NULL (ASCII Code 0), since NULL is used to delimit the end of
a string in ASIC. However, if in the above example data was waiting at
the port but A$ contained "" after the receive, you would know that the
character received was a NULL. This is not a problem if variable1 is an
integer variable.
See also:
OPENCOM,SEND,COMSTAT
Page - 104
REM
Format: REM free form comments
Description:
This statement is used to insert comments into your program.
Everything following REM is treated by ASIC as a comment.
Example:
REM The compiler will ignore this line
RESTORE
Format: RESTORE
Description:
This statement allows you to READ data from DATA statements after
you have already READ it once.
Example:
DATA 0
READ A
RESTORE
READ B
In this example, "READ A" causes variable "A" to be set to 0. Now, the
DATA statement is "used up". There is no more data left on it to be
read. The RESTORE resets the DATA so that the next statement "READ B"
will result in "B" being set to 0. If the RESTORE was not done, the
contents of B would be undefined.
See also:
READ, DATA
Page - 105
RETURN
Format: RETURN
Description:
Used to return from a GOSUB call.
Example:
GOSUB PRINTIT:
END
PRINTIT: PRINT "IT"
RETURN
In the above example, the word "IT" will be printed on the screen. The
RETURN statement causes program execution to resume on the statement
following the corresponding GOSUB statement. In this example, control
will be returned to the END statement.
Comments:
Executing a RETURN statement without having first executed a GOSUB
statement could cause unpredictable results.
See also:
GOSUB
RIGHT$
Format: string1 = RIGHT$(string2,number1)
Description:
This statement will copy the rightmost number1 characters from
string2 to string1.
Example:
A$=RIGHT$("RED RIDING HOOD",4)
After the execution of the above statement, the variable A$ will contain
the string "HOOD".
See also:
MID$, LEFT$
Page - 106
RMDIR
Format: RMDIR string1
Description:
This statement will delete an empty directory from disk. String1
should contain the name of the directory to delete. If ASIC is unable
to delete the directory, it will set the System ERROR variable. A list
of ERROR codes is listed in the Error Messages Chapter of the ASIC
Manual.
Example:
RMDIR "C:\WORK\TEST"
IF ERROR = 0 THEN SUCCESS:
After execution of this code, the directory TEST under directory WORK
will be deleted (if it had no files or subdirectories in it, and if it
is not the current directory for drive "C").
See also:
MKDIR,CHDIR
Page - 107
RND
Format: number1 = RND (number2)
Description:
This statement will return an integer number in the range of 0
through 32767 for normal integers, and in the range of 0 to
2,147,483,647 for long integers. This random number will be stored in
number1. Number2 is a dummy argument and can be any valid integer
value. If number1 is a decimal variable, the random number returned
will be an integer in the range of 0 to 2,147,483,647.
Example 1:
A& = RND(0)
After execution of this statement "A" will contain a number between 0
and 2,147,483,647 inclusive.
Example 2:
RANDOMIZE
DIEROLL=RND(0)
DIEROLL=DIEROLL MOD 6
DIEROLL=DIEROLL+1
PRINT "YOU ROLLED A";DIEROLL
The above example demonstrates how to generate a number in a given
range. In this case, the range will be 1-6, which would be suitable for
simulating the roll of a die. The above example will generate the
simulated die roll, and print the result.
Comments:
In BASICA/GWBASIC, RND always returns a value between 1 and 0.
Page - 108
RTRIM$
Format: string1=RTRIM$(string2)
Description:
This statement will remove all trailing spaces from string2 and
store the resulting string in string1.
Example:
A$=RTRIM$("XYZ ")
After the execution of this statement, the variable "A$" will contain
"XYZ".
See also:
LTRIM$
Page - 109
RUN
Format: RUN string1
Description:
This function can be used to load and execute other programs
compiled with ASIC or another compiler. String1 represents the name of
the program to execute. If an error occurs when ASIC attempts to RUN
the program, it will set the system ERROR variable to 255. Otherwise,
the ERROR variable will be set to the value of the return code of the
called program (which is 0 unless the called program specifies
otherwise).
Example:
RUN "OTHER.COM"
Comments:
String1 must contain the FULL pathname of the program
(ie,"\directory\progname.COM") only if the program is NOT in the current
directory. You must include the file extension on the file name (for
example, use "MYPROG.COM" instead of just "MYPROG", or use "MYPROG.EXE"
instead of "MYPROG").
At this time, RUN and CALL are functionally equivalent, with one
exception. RUN does not accept program arguments, but CALL does.
It is recommended (but not required) that you compile your program
using the EXE format (instead of the COM format) when your program uses
this statement, since an EXE program will release more memory when
calling the program. This will allow you to call a slightly larger
program than is possible with the COM format.
CAUTION:
You may use the debugger with programs which contain "CALL" or
"RUN" statements. However, the programs you call should not themselves
contain debugging code. For example, if A.ASI calls B.ASI, then make
sure you compile B.ASI with the "Debugging Code" option OFF before you
try to debug program A.ASI. Failure to do so will cause the debugger to
behave erratically. This also applies to programs you write using other
compilers, since they also use the same interrupt that ASIC uses (INT 3)
for debugging purposes.
See also:
CALL
Page - 110
SCREEN
Format: SCREEN number1
Description:
This statement will transfer the computer between text mode and
graphics modes. Number1 must be an integer constant with a value of 0,
1, 2, 7, 9, or 13. These modes are described in the table below. The
"Mode" column identifies the value of number1 to specify on the SCREEN
command to select that graphics mode. The "Graphics Resolution" column
has three numbers. The first identifies the number of rows of pixels
supported in this mode. The second number identifies the number of
columns. The third number identifies the number of colors which may
displayed on screen at one time. The numbers in the "Text Resolution"
column tell you how many rows, columns and colors you may display on the
screen when displaying text. The adapters column identifies the type of
graphics adapter required to use this mode.
Mode Graphics Resolution Text Resolution Adapters
----- ------------------- --------------- -------
0 None 25 x 80 x 16 Any Adapter
1 200 x 320 x 4 25 x 40 x 4 CGA/EGA/VGA
2 200 x 640 x 2 25 x 80 x 2 CGA/EGA/VGA
7 200 x 320 x 16 25 x 40 x 16 EGA/VGA
9 350 x 640 x 16 25 x 80 x 16 EGA/VGA
13 200 x 320 x 256 25 x 40 x 16 VGA
Example:
SCREEN 13
After execution of this statement, the PC will be in Graphics Mode 13
which will allow you to display 200 rows by 320 columns of pixels in 256
different colors. Up to 25 rows and 80 columns of text can be displayed
in up to 256 colors. And finally, mode 13 requires a VGA Graphics Card.
Comments:
Any program which uses the SCREEN command should issue a "SCREEN 0"
command before terminating. Otherwise, the screen will not be reset
properly when you return to DOS.
See also:
PSET, PRESET, POINT, ZMODE
Page - 111
SEND
Format: SEND (data1,number2)
Description:
This statement is used to send one character to a serial port. The
port should initialized with OPENCOM prior to using this statement.
Data1 may be any valid data type (integer or string, variable or
constant) and it should contain the character to be sent to the port.
Number2 identifies which COM port to send to (0=COM1, 1=COM2).
Example:
OPENCOM(2,0,0,3,0)
SEND ("X",0)
The above code will open COM1 at 300baud, 1 stop bit, 8bit character
size, with no parity. It will then send the character "X" to COM1.
See also:
RECEIVE,COMSTAT,OPENCOM
SOUND
Format: SOUND number1,number2
Description:
This statement will generate a sound on your computer speaker with
a frequency of number1, and a duration of number2. Frequency should be
in the range of 0 to 32767. ASIC, however, only checks to see that it
is non-negative.
Example:
SOUND 400,20
Execution of the above statement will produce a short beep.
Comments:
ASIC "frequencies" values go from high to low. That is, a
frequency of 0 is the highest, and 32767 is the lowest.
Page - 112
SPACE$
Format: string1=SPACE$(number1)
Description:
This statement will return a string containing number1 ASCII space
characters.
Example:
A$=SPACE$(10)
B$="<"+A$
B$=B$+">"
After execution of these statements, variable "B$" will contain the
string "< >".
See also:
STRING$
STR$
Format: string1 = STR$ (number1)
Description:
This statement will convert number1 to a string format and store
the string format in string1.
Example:
A=1234
A$ = STR$(A)
After execution of these statements, A$ would contain the string "1234".
See also:
VAL
Page - 113
STRING$
Format: string1=STRING$(number1,number2) <--Format 1
string1=STRING$(number1,string2) <--Format 2
Description:
This statement will return a string containing number1 characters
of ASCII value number2 (Format1). If format 2 is used, this statement
will create a string containing number1 characters. Each of these
characters will be the same as the first character of string2.
Example 1:
A$=STRING$(8,111)
After execution of these statements, variable "A$" will contain the
string "oooooooo".
Example 2:
A$=STRING$(5,"xyz")
After execution of these statements, variable "A$" will contain the
string "xxxxx".
See also:
SPACE$
Page - 114
TIME$
Format: string1 = TIME$
Description:
This statement will retrieve the current time from the PC's system
clock. The time will be retrieved and stored in String1, in the format:
"HH.MM.SS".
Example:
CURTIME$=TIME$
PRINT CURTIME$
After execution of the above statements the current time (as per the
PC's internal clock) will be displayed on the screen.
Comments:
Note: if the time printed is wrong, you have probably not set the
system clock. Most older XTs and PCs do not have a battery to preserve
the DATE and TIME in the system clock, so you have to set them each time
you power up the PC. Most ATs and newer PCs have a battery backup, so
that the date is preserved for you.
Unlike GWBASIC/BASICA, you cannot set the system time with TIME$,
however, you can set the system time from DOS by typing TIME.
See also:
DATE$, TIMER
Page - 115
TIMER
Format: number1 = TIMER
Description:
This statement will retrieve a timer count from the PCs hardware
circuitry. The timer count will be placed in number1. The timer count
is in "clock ticks". A "clock tick" occurs in the PC approximately 18.2
times per second. The PC is continually incrementing this clock
counter. This statement can be used to time the duration of events.
Example:
CLS
PRINT "PRESS A KEY"
STARTCNT&=TIMER
LOOP:X$=INKEY$
IF X$="" THEN LOOP:
ENDCNT&=TIMER
ELAPSED&=ENDCNT&-STARTCNT&
ELAPSED&=ABS(ELAPSED&)
ELAPSED&=ELAPSED&/18
PRINT "IT TOOK YOU APPROXIMATELY";
PRINT ELAPSED&
PRINT " SECONDS TO PRESS A KEY"
The above code fragment will time how long you wait to press a key in
seconds. You could modify it easily to display in clock ticks, which
would provide much more accuracy, if you deleted the statement which
divides the ELAPSED count by 18.
Comments:
Note that it is necessary to use the absolute value of ELAPSED&
since the clock counts is stored as unsigned integers. ASIC integers,
on the other hand, are signed. If number1 is a long integer variable,
then TIMER retrieves the full PC timer value. However, if a normal
integer variable is specified as number1, then ASIC retrieves the least
16 significant bits from the PC timer.
See also:
DATE$,TIME$
Page - 116
UCASE$
Format: string1=UCASE$(string2)
Description:
This statement will convert all lowercase letters in string2 to
uppercase, and store the resulting string in string1.
Example:
A$=UCASE$("123 Main St, USA")
After execution of this statement, the variable "A$" will contain the
string "123 MAIN ST, USA".
See also:
LCASE$
VAL
Format: number1 = VAL (string1)
Description:
This statement will attempt to convert string1 into an integer
value, and it will store the result in number1.
Example:
A$ = "12345"
A = VAL (A$)
After execution of these statements, variable "A" would contain the
value 12345.
See also:
STR$
Page - 117
VARPTR
Format: number1 = VARPTR (variable1)
Description:
This statement will return the address of a variable variable1 and
store it in number1. This may be used to peek and poke values directly
into a variable.
Example:
A$ = "XYZ"
B = VARPTR(A$)
C = PEEK (B)
PRINT C
After execution of these statements the screen would display the number
88 which is the number for the ASCII character "X".
See also:
PEEK, POKE
WHILE/WEND
Format: WHILE condition
WEND
Description:
This statement will execute those statements which are between the
WHILE and the WEND statements as long as the "condition" is true. The
operand "condition" is one of the following:
number1 > number2
string1 > string2
number1 = number2
string1 = string2
number1 < number2
string1 < string2
Example:
PRINT "PRESS A KEY TO CONTINUE"
A$=""
WHILE A$=""
A$=INKEY$
WEND
In this example, the program will pause until the user presses a key.
WHILE statements may be nested 25 levels deep.
Page - 118
WIDTH
Format: WIDTH number1
Description:
This statement will set the screen to 40 column text or 80 column
text mode only. The only two valid values for number1 are thus 40 and
80. In ASIC, WIDTH 80 is equivalent to executing SCREEN 0. Also, WIDTH
40 is equivalent to executing SCREEN 1. If you use WIDTH 40, you should
always reset the screen back to WIDTH 80 before terminating your program
with END. Otherwise, your PC will be left in 40 column mode.
Example:
WIDTH 40
The above statement would put the PC in 40 column mode.
ZBIT
Format: number1 = ZBIT(number2,number3)
Description:
This statement is used to determine if a single "bit" in an integer
variable is set to "1". Number2 represents the bit to be tested. It
should be in the range 0 to 15. Number3 represents the integer variable
or constant to be tested. The result of the test is returned to
number1. If the bit was set, number1 will be set to "1", otherwise,
number1 will be set to "0".
Example:
GAMEPORT = INP(513)
TRIGGER = ZBIT(4,GAMEPORT)
IF TRIGGER = 1 THEN TRIGGERPRESSED:
In this example, the joystick port is read, and its status is placed in
the variable "GAMEPORT". The bit which represents the trigger for
joystick 1 is then tested using ZBIT. If the trigger bit is set, then
the program would transfer to the label "TRIGGERPRESSED:". Note that
the above code assumes that a game card is present in the computer.
Comments:
This statement is an extension over GWBASIC/BASICA, although it is
possible to perform similar tests in GWBASIC/BASICA with the boolean AND
statement.
Page - 119
ZMODE
Format: integer = ZMODE
Description:
This command returns a code which indicates whether a color or
monochrome card is active in the system. ZMODE returns a value of 1
when a color card is detected, and a value of 0 for monochrome.
Example:
A = ZMODE
IF A = 0 THEN
PRINT "This program requires a Color Card to Run"
END
ENDIF
The above code fragment will check for a color card; if not found, the
program will terminate with an appropriate message. Otherwise, the
program will continue.
Comments:
This statement is an extension over BASICA/GWBASIC.
Page - 120
A S I C
Chapter 8
Compatibility with GWBASIC/BASICA
In general, although ASIC does not support all options on every BASIC
statement, those it does support work like they do in BASICA/GWBASIC.
The known exceptions are listed in this chapter.
INKEY$
This statement is compatible, however ASIC does provide an
extension over GWBASIC/BASICA. If an extended key is pressed (e.g. F1-
F10), ASIC returns the scan code for the extended key, and sets a
special system variable "EXTENDED" to a value of 1. For non-extended
keys, the "EXTENDED" variable will contain 0.
FILE HANDLING
ASIC provides no EOF statement or ON ERROR statements. Instead,
ASIC sets a special system variable when an error occurs during file
I/O. This special variable is called "ERROR" and it is set after every
file I/O statement (OPEN/INPUT#/PRINT#/CLOSE, etc) to either 0 to
indicate no errors, or a non-zero value. If a non-zero value is
present, an error has occurred. The specific errors are identified in
chapter 10.
FILE FORMAT
ASIC Files are written with 2/4 bytes per normal/long integer in
binary format, instead of string format as in BASICA/GWBASIC. Strings
are written as a sequence of ASCII characters terminated by an ASCII
null, or optionally with no NULL terminator.
PUNCTUATION
ASIC permits use of punctuation that it does not require to allow
you to enter statements in their familiar GWBASIC/BASICA Formats. For
example:
A = ABS (B(1))
This statement is valid in both ASIC and in GWBASIC/BASICA.
However, ASIC ignores the parenthesis and comma. Thus ASIC will
actually accept the following formats as alternatives to the above:
A = ABS B 1
A = ABS B 1,,,,,,)))))
Page - 121
FOR/NEXT
FOR/NEXT loops always fall through the body of the FOR at least one
time in ASIC. This does not happen in BASICA/GWBASIC. For more
information on this, refer to Chapter 7.
RND
RND (N) returns a value from 0-32767 for normal integers and 0-
2,147,483,647 for long integers instead of 0 to 1 as in BASICA/GWBASIC.
LOCATE/CSRLIN/POS
Coordinates are specified in range 0-24 and 0-79 instead of 1-25
and 1-80.
PSET/PRESET/POINT
Coordinates are specified in row/column order instead of column/row
order.
BLOAD/BSAVE
File formats are not compatible with GWBASIC/BASICA. BLOAD
requires offset and the number of bytes to read.
OPENCOM/COMSTAT/SEND/RECEIVE
These statements provide serial port support in ASIC. In
GWBASIC/BASICA this is provided by OPEN/INPUT#/PRINT#.
DATE$/TIME$
ASIC allows you to retrieve the system date and time, but will not
allow you to set new system date/time values.
CALL/RUN
These statements perform functions similar to their GWBASIC/BASICA
counterparts, but function differently. Refer to the keyword reference
for the appropriate keyword for details on their operation.
Page - 122
EXTENSIONS OVER BASICA/GWBASIC
CODE COMMAND$
INT86 FILEPOS
FIND LCASE$
LTRIM$ MOD
RTRIM UCASE$
ZBIT ZMODE
EXTENDED
The statements above are extensions over BASICA/GWBASIC.
Page - 123
A S I C
Chapter 9
Technical Details/Tips
This chapter contains technical information and tips regarding ASIC.
COMPILER LIMITS
Maximum Source Program Size: Command Line Compiler - Unlimited
Integrated Environment - Limited only by
available memory
Maximum Object Program Size: 64k bytes--.COM Format:
64k code/data/stack
130k+ bytes--.EXE Format:
64k code
64k data
up to 64k stack
130k+ bytes--.OBJ Format:
64k ASIC code
64k ASIC data
up to 64k stack
PLUS up to ~500k externally
assembled ".OBJ" files can
be linked into your ASIC
program and called using
the CALL SUB statement.
Maximum Source Line Length 128 bytes - Command Line
80 bytes - Integrated Environment
Compiler Symbol Table Size: Unlimited - can use all available memory
Maximum Number of Arrays: 25
FOR/NEXT Nesting Depth 25
IF/THEN/ELSE Nesting Depth 25
WHILE/WEND Nesting Depth 25
Compiler Memory Requirements 305k - Command Line
405k - Integrated Environment
Page - 124
COMPILER OPERATION
ASIC is a single pass compiler written entirely in C (Borland C
Version 3.1). Each source statement is translated directly into machine
code. ASIC compiles 100% in memory for maximum speed. The compiler
does not require any disk work space. ASIC generates a minimum of error
checking code. This is because the ASIC philosophy stresses execution
speed. This does place greater responsibility on the programmer to
check for out of bounds conditions, etc...
MEMORY OPTIMIZATION
ASIC provides 32 bit long integers in addition to 16 bit normal
integers. This allows you to store much larger numbers, however,
nothing in life is free. Long integers will increase the size of the
resulting ".COM" file by approximately 475 bytes. If you are not using
long integers, be sure to compile with the "Extended Math" Option turned
OFF so that ASIC does not include these unneeded bytes in your COM or
EXE file. Otherwise, ASIC will include the long integer support code in
your file, even if you never create a single long integer! Note: by
default, this option is turned off in both the command line and
integrated versions of the compiler.
Likewise, the "Decimal Math" option will allow math with fractional
results of very large numbers, but this option will increase your
program size. Use integers or long integers unless you need this
fractional precision, and turn off the "Decimal Math" option. Note: by
default, this option is turned off in both the command line and
integrated versions of the compiler.
Also remember that ASIC's debugging option increases your ".COM"
file size. So don't forget to recompile your program with the
"Debugging" Option turned off (after you have finished debugging it, of
course).
COM disk files will usually be smaller than EXE files by several
hundred bytes. However, COM files require 64k of memory to execute.
Additionally, COM files (because of a DOS requirement), will
automatically allocate all available memory at load time. EXE files
require the actual size of the program plus 2000 bytes for the stack
(4000 bytes for the stack when compiling with debugging mode). Thus,
your program may be loadable in as few as 3-4k bytes of memory. Also
note that an ASIC EXE does NOT allocate all available memory to your
program. ASIC only allocates the amount of memory your program actually
needs. The following chart summarizes when it is usually best to use
each type of file:
Page - 125
MEMORY OPTIMIZATION (Continued)
Use COM files when:
-------------------
o You want to minimize the disk space a program occupies
o Your program is smaller than 64k in size
Use EXE files when:
-------------------
o Your program is larger than 64k in size
o You want to minimize your program's run-time memory requirements
o You are calling another program using the RUN or CALL Statements
Use the OBJ option to create an EXE file when:
----------------------------------------------
o To use the CALL SUB statement.
PERFORMANCE OPTIMIZATION
This section contains tips for making your programs run as fast as
possible.
1) VARIABLE TYPES - Don't use long integer variables or decimal
variables to store numbers that can fit in a regular integer variable.
Long integer variables are exponentially slower than regular integers,
and decimal variables are exponentially slower than long integer
variables. If the number will exceed the range allowed by a regular
integer, but is an integer in the range +/-2,147,483,647, then use a
long integer. If the number requires one or more decimal places of
precision, or is an integer larger than +/-2,147,483,647, then use a
decimal variable. Always use integers on FOR/NEXT loops, when possible.
2) DECIMAL VARIABLES - When using decimal variables, be aware that the
least efficient operation is screen I/O. Don't PRINT a number unless
you need to. (Note: The decimal variable format used by ASIC was
selected to optimize speed when adding, subtracting, multiplying,and
dividing. The trade off in using this format is that it takes longer to
convert the internal format to printable form than it would have with a
packed binary coded decimal (BCD) format.)
3) MATH FUNCTIONS - The math functions, in order of least efficient to
most efficient, are: Division, Multiplication, Subtraction and
Addition.
4) DON'T MIX VARIABLE TYPES - When performing calculations using
decimal variables, avoid mixing decimal variables with integer
variables. Although ASIC will automatically convert the integers to a
decimal format internally, this conversion will slow down your
calculations.
Page - 126
DEBUGGER LIMITS
Maximum Concurrent Breakpoints 20
Maximum Concurrent Watches 10
Maximum Symbol Length 30 Characters
Maximum Symbols Same as Compiler
Maximum Source Statements Unlimited
DEBUGGER OPERATION
When you select the "Debugging code" compiler option, the ASIC
compiler inserts additional machine language instructions into your
program. It inserts a single statement at the beginning of your program
(specifically, INT 3) which allows it to gain control. When the ASIC
editor is loaded, it saves the existing INT 3 vector, and installs the
ASIC Debugger as INT 3. In this way, when your program begins
executing, the INT 3 statement that ASIC inserted in your program causes
a transfer of control to the debugger. Once the debugger gains control,
it can set or remove additional breakpoints as needed in your program,
plus provide access to the video memory and variable memory locations
with the Swap, Watch, Unwatch, and Modify Commands. When you exit the
ASIC editor, ASIC deinstalls the debugger from INT 3, and restores the
original interrupt 3 vector.
The compiler also creates a file with a ".DBG" extension which
contains the symbolic information needed by the debugger (ie, variable
names and offsets, and source statement offsets).
DEBUGGER OVERHEAD
Running a program in debugging mode adds a small amount of overhead
to your program (both compiled code size, and execution speed).
Specifically, the size of the debugging code will be (approximately):
CodeSizeIncrease = 1 + LinesOfSourceCode
Note that the actual increase will usually be less than the above, since
DIM, DATA, REM, and blank source lines do not require debugging code.
The reduction in execution speed is very slight in most cases (for you
assembly language programmers out there, a single NOP instruction is
executed for each source line).
In EXE files, the stack size is increased by an additional 2k when
debugging is enabled.
Page - 127
STORAGE FORMATS
NORMAL INTEGERS are stored in ASIC as two bytes, with the low order
byte appearing first (as per Intel conventions).
LONG INTEGERS are stored in ASIC as four bytes, with the least
significant word first, followed by the most significant word. Within
these two words, the least significant byte appears first followed by
the most significant byte.
STRING VARIABLES are stored as FIXED 80 character strings
terminated by an ASCII null character for a total length of 81
characters.
STRING CONSTANTS are stored with 1 byte per character in the string
followed by a terminating ASCII null character.
DECIMAL VARIABLES AND CONSTANTS are stored in 8 bytes, from least
significant byte to most significant byte. They are stored as signed
binary integers, with an implicit decimal point. The integer values are
adjusted after each multiplication or division to scale the result to
the proper number of decimal places.
ARRAYS - Each element in an array requires two bytes. (Don't
forget arrays have an element zero (ie DIM A(2) is comprised of A(0),
A(1), and A(2)).
Examples:
Item Data Type Storage Requirements
A Integer Variable 2 bytes
17 Integer Constant 2 bytes
A& Long Integer Variable 4 bytes
55555& Long Integer Constant 4 bytes
A$ String Variable 81 bytes
"ABC" String Constant 4 bytes
"A" String Constant 2 bytes
A@ Decimal Variable 8 bytes
1.23456 Decimal Constant 8 bytes
12345@ Decimal Constant 8 bytes
DIM A(10) Integer Array 22 bytes
DIM A(1) Integer Array 4 bytes
DIM A&(10) Long Integer Array 44 bytes
DIM A$(10) String Array 891 bytes
DIM A@(10) Decimal Array 88 bytes
As you can see, string variables are expensive in terms of storage
space. Since string constants are stored at actual length +1, It is
MUCH more efficient to store short strings as constants in ASIC in terms
of storage space. There is no performance advantage to constants over
variables, however.
Page - 128
STORAGE FORMATS (Continued)
In disk files, strings, decimals, and integers are written out in the
above formats. Note that unlike GWBASIC/BASICA, integer and decimal
values are NOT expanded into strings when written, and conversely, not
converted from strings when read. String variables and constants are
written out as ASCII strings terminated by a null character (however,
the null can be suppressed). Thus, string variables when written to
disk, take the same space byte for byte as string constants.
The reason behind fixed length string variables was avoidance of string
"garbage collection". In addition to slight performance advantages,
there is the added benefit of providing a string memory address which
never changes. Thus once VARPTR retrieves the address of a variable,
you never have to worry about it changing.
Page - 129
MEMORY MAP
COM File Memory Map
The following describes the structure of the ".COM" file created by
ASIC. All addresses are in Hexadecimal.
Description Address Range
------------------------------ -------------
Program Segment Prefix (PSP) 0000 - 00FF
(Created/Required by DOS)
Transfer to Program Code 0100 - 0102
String Conversion Buffer 0103 - 0109
Input Buffer 010A - 015B
Screen Width 015C
Color/Attribute Byte 015D
Screen Graphics Mode 015E
Cursor Position 015F - 0160
File Control Table 0161 - 0169
ERROR System Variable 016A - 016B
System Subroutine Vectors 016C - 017F
EXTENDED System Variable 0180 - 0181
RND Seed 0182 - 0185
Math Work Area 0186 - 018D
DEFSEG System Variable 018E - 018F
Start DATA Block Pointer 0190 - 0191
Current DATA Block Pointer 0192 - 0193
Reserved for future use 0194 - 0195
Optional Sys Subroutine Vectors 0196+
and Work Areas (decimal math option)
System Subroutines Address Varies
|
|
v
Data Segment Address Varies
|
|
|
v
Code Segment Address Varies
|
|
|
v
^
|
|
Program Stack (builds downward) FFFF
Page - 130
MEMORY MAP (Continued)
EXE File Memory Map
The following describes the structure of the ".EXE" file created by
ASIC. In the COM file format the code, data, and stack are all in the
same memory segment. In an ASIC EXE format file, the code, data, and
stack each reside in their own segment. Addresses are given as offsets
from the CS (Code Segment), DS (Data Segment), or SS (Stack Segment)
registers.
Description Address Range
------------------------------ -------------
Program Segment Prefix (PSP) CS: minus 00FF
(Created/Required by DOS, and
immediately precedes the
code segment)
|
|
v
Code Segment (CS:)
User Program 0000 +
|
|
v
System Subroutines Address Varies
|
|
v
Data Segment (DS:)
Program Data Area #1 0000 - 0102
String Conversion Buffer 0103 - 0109
Input Buffer 010A - 015B
Screen Width 015C
Color/Attribute Byte 015D
Screen Graphics Mode 015E
Cursor Position 015F - 0160
File Control Table 0161 - 0169
ERROR System Variable 016A - 016B
System Subroutine Vectors 016C - 017F
EXTENDED System Variable 0180 - 0181
RND Seed 0182 - 0185
Math Work Area 0186 - 018D
DEFSEG System Variable 018E - 018F
Start DATA Block Pointer 0190 - 0191
Current DATA Block Pointer 0192 - 0193
Reserved for future use 0194 - 0195
Optional System Sub Vectors 0196+
and Work Areas (decimal math option)
Program Data Area #2 Address Varies
|
|
v
Stack (SS:) (builds downward) 0000 - 07D0 (0FA0--debug mode)
Page - 131
MEMORY MAP (Continued)
NOTE: The format of an EXE file created using the
"B/OBJ" option is essentially the same as the one
produced by the "B/EXE" option, except that the
"B/OBJ" output file may contain additional code or
data segments linked in from other OBJ or LIB files.
Page - 132
A S I C
Chapter 10
Mixed Language Programming
ASIC programs can incorporate subroutines you write in assembly
language. This is a powerful feature, but it is a bit complicated until
you have done it a few times. This chapter describes how to use the
CALL statement to call separately compiled assembly language programs.
OVERVIEW
Of course, the first thing you need is an assembler such as
Borland's Turbo Assembler or Microsoft's Assembler. You need to develop
your assembly language subroutines and assemble them into OBJ format
files. Optionally, you can store these in a library file (.LIB) if you
have Microsoft's LIB program or Borland's TLIB program. Then, you
develop the ASIC program which will call the subroutine, tell ASIC about
the external object files and libraries, and compile your program.
Thereafter, you may run and debug your program normally.
DEVELOPING ASSEMBLER SUBROUTINES
The first step is to develop an assembler subroutine. There are
several things you need to be aware of, when developing an assembler
program:
1) The entry point must be declared using the PUBLIC keyword. If you
do not do this, you will receive a linker error.
2) ASIC saves most critical registers prior to the CALL, however, in
your assembler subroutine, you must take care to preserve the value of
the SS and SP registers. When you return to ASIC from your subroutine,
you must insure that the SS and SP register values have not changed.
This means that if you PUSH any values to the stack, you MUST POP them
before the return instruction to ASIC. Failure to do so will almost
always crash your program.
3) ASIC calls external assembler subroutines using FAR calls
(segment:offset), so you must declare the PROC as FAR, and must use the
RETF (far return) instruction to return to ASIC.
4) ASIC passes parameters on the stack as far pointers (by reference).
This means, that irregardless of whether the parameter being passed is a
short integer, long integer, or string, ASIC will always place 4 bytes
on the stack. ASIC always pushes the segment portion (2 bytes) of the
pointer to the stack first, followed by the offset (2 bytes). Remember
that these 4 bytes are not the value of the variable, but a pointer to
the variable in memory. If you look at the memory location pointed to
by these 4 bytes, you will find the starting location of the variable.
ASIC passes variables from the CALL SUB statement from left to right.
Page - 133
5. When your subroutine receives control from ASIC, the stack will
look like the following:
etc
SS:SP+10 (2 bytes) segment of next-to-last parameter
SS:SP+8 (2 bytes} offset of next-to-last parameter
SS:SP+6 (2 bytes) segment of last parameter
SS:SP+4 (2 bytes) offset of last parameter
SS:SP (4 bytes) return address
6) If your ASIC calling program passes constants to a subroutine, be
aware that the subroutine can update the memory location used to store
the constant values. For example, if you modify the memory location
used by ASIC to store the value of the constant "1" to "2", you will
have inadvertently redefined the constant "1" to "2" throughout your
ASIC program. If you are not sure if a parameter will be updated by a
subroutine, play it safe, use a variable for the parameter.
ASSEMBLING YOUR SUBROUTINE
Before you subroutine can be used, it must be assembled. Use your
favorite assembler to do so. If you like, you can store your object
files in Microsoft LIB compatible format files for convenience.
DEVELOPING THE CALLING ASIC PROGRAM
All that you have to do to call the subroutine, is insert a CALL
SUB statement in your program. The CALL SUB statement has the following
format:
CALL SUB "subroutinename" [parm1...parmN]
Where "subroutinename" is the name of the subroutine you wish to
call (it must be in quotes). No parameters are required, but you may
provide one or more, if you like. Any valid ASIC variable or constant
type may be passed as a parameter. "subroutinename" must match the name
of the PUBLIC PROCedure you declared in your assembly language
subroutine.
BUILDING THE EXECUTABLE PROGRAM
Finally, you have to build the program. You must do the following
steps to create a valid EXE file:
o Load the edit buffer with the calling ASIC program
o Select the "Obj output file" option.
o Identify the names of any object modules to be linked with your
ASIC program, if any.
o Identify the names of any object libraries to be linked with
your ASIC program, if any.
o Tell ASIC where to find the MS DOS Linker
o Compile your program--ASIC will call the DOS linker
automatically.
This can be made more clear through the use of an example.
Included with your ASIC package are 2 files:
Page - 134
CALLSRCH.ASI
SRCH.ASM
The file CALLSRCH.ASI is an ASIC program which calls a subroutine
called SRCH. SRCH.ASM is the source to an assembly language program.
Make sure these files are in your ASIC working directory for purposes of
this example. Also, copy the LINK.EXE file which comes with MS DOS to
your ASIC directory or to the directory "C:\DOS". Note: if you don't
want to make a copy of LINK.EXE, you don't have to, but you need to tell
ASIC how to find LINK.EXE by using the LNK= compile option (see Chapter
5 command line options, or the ADVANCED MENU OPTIONS section in chapter
3, for information on setting the LINK path).
The first step in producing the EXE file is to assemble the
SRCH.ASM program. If you have Borland's Turbo Assembler, type:
TASM SRCH <return>
Otherwise, if you have Microsoft's Macro Assembler, type:
MASM SRCH <return>
This should create a file called SRCH.OBJ in your working
directory. The second step is to build the ASIC program. If you prefer
the ASIC command line compiler, you can accomplish the build with a
single command:
ASICC CALLSRCH B/OBJ OBJ=SRCH
That's all there is to it, if you are building from the command
line. You should be able to run the program now, try it--type:
CALLSRCH <return>
Read the comments in the programs for a description on what the
program does. You can also accomplish this easily from the integrated
environment.
First, load the program into ASIC:
<Alt><f>
<o>
CALLSRCH <return>
The above opens the "file" menu, selects the "open" option, and
selects the file "CALLSRCH.ASI". Next, set the compiler options:
<Alt><c>
<a>
<o>
<j>
SRCH <return>
This opens the "compile" menu, selects the "advanced options"
menu, sets the file output type to "obj" and set the "obJect names" to
"SRCH".
Page - 135
<Alt><f>
<s>
This opens the "file" menu, and selects the "save" option. This
not only saves the CALLSRCH.ASI file to disk, it also saves all of the
compile options you just set, to a file called CALLSRCH.PRJ. So, the
next time you enter ASIC, you won't have to re-set all those options for
this program.
Now compile the program:
<F10>
You should see the ASIC compiler screen compile the program, and
you should then see a few messages as the Microsoft LINK program builds
the EXE file. In the future, from the integrated environment, you can
rebuild the CALLSRCH program by loading it into the edit buffer and
pressing <F10> to compile. ASIC will remember all of the options you
told it, so it will remember to link the "SRCH" module, automatically.
OTHER LINK OPTIONS
The above is a simple example; there are other compile examples in
Chapter 5. If you have one or more subroutine object modules stored in
a library, you can use the "LIB=" option on the command line to specify
the library names to ASIC. You can also specify the library information
inside the integrated environment (Open the "compile" menu, select the
"Advanced options" option. From the "Advanced options" menu that pops
up, select the "liBrary names" option.
When specifying object files, remember that the ".OBJ" file
extension is optional, as is the ".LIB" extension on library files. You
don't have to give the full file spec (ie, disk drive and directory) if
the file is in the ASIC directory. See Chapter 3 and Chapter 5 for more
information on setting these options from the integrated environment and
command line compiler respectively.
DEBUGGING
You can use the debugger on ASIC programs which use the CALL SUB
statement, however, you can't "trace into" the assembly language
subroutine instructions. When you press <F8> to trace one line, and you
are positioned on a CALL SUB statement, the CALL SUB is executed, and
ASIC advances to the next ASIC statement following the CALL SUB. The
called assembler subroutine should not contain INT 3 instructions. If
they do, the debugger will behave erratically.
Page - 136
A S I C
Chapter 11
Error Messages
This chapter contains compiler messages, run-time error messages, and
File I/O Error Codes.
COMPILER ERRORS
These messages indicate errors in your source program. Those which
begin with "** E" indicate "fatal" errors, which prevent ASIC from
successfully compiling your program. Warnings begin with "* W" and
indicate possible errors and informative messages which will not prevent
ASIC from generating an executable ".COM" or ".EXE" file.
FATAL ERRORS
** E001 ** File Extensions must be '.ASI', '.PRJ' or omitted
ASIC requires source programs to have the extension ".ASI". Rename
your source file with the DOS "RENAME" command to the name "file.ASI",
where "file" is your source program name. Then resubmit the compile.
The ".ASI" extension is the only valid one for the ASIC Editor, but the
command line compiler will also accept a ".PRJ" extension.
** E002 ** File Name specified is too long
The source file may be identified by a file name up to 124
characters long including disk drive specifiers and sub directory names.
Move the source program to a directory which may be specified within
this length.
** E003 ** Error Opening File: xxxxxxxx.xxx
The file indicated by "xxxxxxxx.xxx" could not be opened by ASIC.
This error can be issued when ASIC attempts to read your source file, or
when it writes any one of the possible output files (".COM", ".EXE",
".LST", or ".SYM"). If indicated file is your source program name,
verify the spelling, and either make sure it is in the same directory as
ASIC, or specify the full path name for the file. If the indicated file
is an output file, the error is usually a result of a write protect tab
on the diskette or insufficient disk space.
Page - 137
** E004 ** DIM Statements must precede all others except REMs
In ASIC, DIM statements must appear before all other statement
types, except REM statements (or blank lines).
** E005 ** Too many characters in source line
Source program lines in ASIC are limited to 120 characters. Change
the indicated source line, so that it fits within this limit.
** E006 ** Unmatched Quote ('"') in source line
A string constant was found with either no opening or closing quote
mark. Quotation marks must be matched in pairs within source lines.
** E007 ** Token in source line > 82 characters long
Individual tokens in ASIC are limited to 82 characters in length,
regardless of type. A token is a group of letters and/or numbers
delimited on either side by a space or math symbol. Example, even
though string constants are limited to 80 characters, ASIC considers the
"token" to include the quotation marks. In this case, however, ASIC
detected a token longer than the longest possible token, the string
constant. Check for "tokens" or "words" more than 82 characters long in
the indicated source line.
** E008 ** More than 30 tokens in source line
Since all ASIC statements require less than 30 tokens, ASIC will
flag any statement which contains more than this number. A token is a
group of letters and/or numbers delimited on either side by a space or
math symbol.
** E009 ** Keyword Unknown: xxxxxxxxx
ASIC detected the symbol indicated by "xxxxxxxx" in your source
line, but it was not a valid variable name, constant, label, or ASIC
Function Name.
** E010 ** Symbol Table Space Exhausted
The symbol table is used by ASIC to keep track of your variables,
constants and labels. It is also used to hold information used in
FOR/NEXT processing, and internal system subroutine generation. Reduce
the number of LABELS, VARIABLE NAMES, or CONSTANTS in your program, and
recompile.
Page - 138
** E011 ** Symbol Incomplete Reference Space Exhausted
This table is a sister table to the Symbol Table, it contains
references to LABEL type symbols which have been defined in the symbol
table. Try to reduce the number of references made to LABEL symbols
within the program and recompile.
** E012 ** No keywords in source line
Every ASIC source program line must contain an ASIC keyword (eg.
"PRINT", "=", "GOSUB", etc).
** E013 ** Syntax Error
The "catch-all" error for ASIC. This error is usually issued when
ASIC has identified an error in the parameters for an ASIC keyword. The
best way to find this error is to refer to the entry in the Keyword
Reference (chapter 7) for that particular keyword.
** E014 ** Undefined Symbol: xxxxxx
ASIC detected a LABEL "xxxxxx" which was referenced, but never
defined in the program. A label is considered to be defined when it is
the first token on the source line. A reference to a label occurs when
a label name appears elsewhere in the source statement
Example: PRINTIT: PRINT "hello" <---Defined
GOTO PRINTIT: <--Referenced
** E015 ** Compiled Code Exceeds 64k-Can't fit in .COM file
Your source program is too large to fit in the .COM file format.
Recompile using the "Build EXE" option. See Chapter 5 for more
information.
** E016 ** Integer Constant Not in range +32767 to -32767
The above range of numbers is the maximum which can be contained in
integer format in ASIC. Reduce the constant so that it falls within the
specified range.
** E017 ** Duplicate Label: xxxxxx
The indicated label "xxxxxx" was defined more than once in the
program. Reduce the multiple definitions to a single definition and
then recompile.
Page - 139
** E018 ** Second FOR defined for variable with no intervening NEXT
FOR/NEXT Statements cannot be nested with the same variable name.
VALID INVALID
FOR I=1 TO 10 FOR I=1 TO 10
FOR J=1 TO 20 FOR I=1 TO 20
NEXT J NEXT I
NEXT I NEXT I
** E019 ** For/Next Table Space Exhausted
An unlimited of FOR/NEXT statements can exist, however, they can be
"nested" to a maximum depth of 25.
** E020 ** NEXT without FOR
A NEXT statement was found, however it was not preceded in the
source program with a matching FOR statement.
** E021 ** FOR without NEXT at Source Line NNNNN
The indicated source line NNNNN contains a FOR statement, for which
no NEXT statement was ever found.
** E022 ** Invalid Option: x
An invalid compile option was specified. Review Chapter 5 for a
list of valid compile options.
** E023 ** More than 63000 bytes in Data Segment
An ASIC program can be up to 64k bytes in size. Of this total,
63000 bytes can contain program variables and constants, leaving at
least 1k for program code. Reduce the number of variables and constants
in your program.
** E024 ** Too many arrays defined
A single ASIC source program can contain up to 25 arrays.
** E025 ** Re-DIMension of previously DIMensioned variable
Only one DIM statement can be specified per array name.
Page - 140
** E026 ** Invalid subscript on Array
A subscript was found which is not valid. Either ASIC expected
more or less subscripts than were present, or ASIC detected a subscript
which was itself an array. Subscripts on arrays may only be non-array
variables and/or integer constants.
** E030 ** Code Segment Memory Exhausted
ASIC will attempt to allocate 64k of memory to use a work space to
hold the code generated by your program statements. This message
indicates that the amount of memory it was able to allocate was not
sufficient to hold the code generated by the program you are trying to
compile.
** E031 ** Data Segment Memory Exhausted
ASIC will attempt to allocate 64k of memory to use a work space to
hold the data segment for your program. This message indicates that the
amount of memory it was able to allocate was not sufficient to hold the
data generated by the program you are trying to compile.
** E032 ** Insufficient Memory to Run ASIC
You don't have enough memory to run ASIC. If you have any TSRs
loaded, try removing them and re-compiling.
** E033 ** Edit Buffer Memory Allocation Failed
ASIC attempted to allocate memory for the edit buffer in the
integrated environment, but was unable to. If you have any TSRs loaded,
remove them from memory, and try again.
Page - 141
** E034 ** DATA Statements Must Precede All Except DIMs or REMs
If you wish to use the DATA statement in ASIC, you must place them
all at the beginning of your program following any DIM and/or REM
statements (or blank lines).
** E035 ** Requires 32 Bit Math--Recompile W/Math Option
The compiler found a statement containing long (32bit) integer
variables or constants. You must compile with the Extended Math Option
turned on to be able to use long integer math. Turn on the "Extended
Math" Option from the Compile Menu in the ASIC Integrated Environment,
and recompile the program. If you are compiling from the MS DOS command
line, recompile using switch "E".
** E036 ** Error Allocating Debugger Screen Memory
ASIC was unable to allocate memory to save the screen output from
your programs when you run your program in debugging mode in the ASIC
integrated environment. You could try removing some TSRs from your
AUTOEXEC.BAT file. Then try running ASIC again.
** E037 ** IF Statements Nested Deeper Than 25 Levels
An unlimited number of block IF statements may be used in your
program, however, they may be nested to a maximum depth of 25 levels.
See the IF statement documentation in Chapter 7 for more information.
** E038 ** ELSE Statement Without Preceding IF Statement.
ASIC found an ELSE statement but did not find a preceding block IF
statement. See the IF Statement documentation in Chapter 7 for more
information.
** E039 ** ENDIF Statement Without Preceding IF Statement.
ASIC found an ENDIF statement with no preceding matching IF
statement. See the IF statement documentation in Chapter 7 for more
information.
** E040 ** Block IF Statement Without Matching ENDIF Statement.
When using the block IF format of the IF statement, you must always
specify a matching ENDIF statement. See the IF Statement documentation
in Chapter 7 for more information.
Page - 142
** E041 ** WHILE Statements Nested Deeper Than 25 Levels
An unlimited number of WHILE statements may be used in your
program, however, they may be nested to a maximum depth of 25 levels.
See the WHILE statement in Chapter 7 for more information.
** E042 ** WEND Statement Without Preceding WHILE Statement
ASIC found a WEND statement with no preceding matching WHILE
statement. See the WHILE statement documentation in Chapter 7 for more
information.
** E043 ** WHILE Statement Without Matching WEND Statement
Each WHILE statement must be followed by a matching WEND statement.
See the WHILE statement documentation in Chapter 7 for more information.
** E044 ** This statement format is only valid when producing OBJ files.
You used a format of a statement which does not make sense with the
current compiler option. For example, you specified "CALL SUB" when
compiling with the B/EXE or B/COM option. This is invalid, since CALL
SUB will generate a reference for the linker to resolve the SUB
procedure name. ASIC will not resolve the SUB reference when using the
B/COM or B/EXE option, since no OBJ file is produced with these options.
Recompile with the B/OBJ option (select the OBJ option in the integrated
environment).
** E047 ** Requires Decimal Math--Recompile w/DEC Option
Your program contains a statement containing a decimal variable or
constant (eg, A@ or 1.234). To use decimal numbers, you must turn on
the "Decimal Math" option from the "Compile" menu, or, if you are
compiling from the command line, by specifying the command line option
"DEC". Turn on this option, and recompile your program.
** E048 ** 999999999999.99999 Is Max Constant Size
You specified a decimal constant in your program which exceeds the
maximum size that ASIC can handle. Modify your program until the
constant is within +/-999,999,999,999.99999 and recompile your program.
Page - 143
NON-FATAL WARNINGS
* W002 * Printer Not Ready - 'P' Option Ignored
You selected the "Printer" option, but ASIC was not able to access
the printer. Make sure the printer is online before compiling with the
'P' option.
* W004 * Edit Buffer Full--File Truncated
While loading a file, the edit buffer filled before ASIC reached
end-of-file. The file is truncated in memory. IF YOU SAVE THE FILE
AFTER RECEIVING THIS MESSAGE, PART OF THE FILE WILL BE LOST ON DISK. IT
IS RECOMMENDED THAT YOU EITHER EXIT ASIC IMMEDIATELY, OR THAT YOU SAVE
THE TRUNCATED FILE UNDER A NEW NAME SO THAT THE ORIGINAL FILE IS NOT
DAMAGED.
* W005 * Edit Buffer Full
ASIC issues this message when the edit buffer is full and you
attempt to insert a line. Delete some unnecessary source lines to
create space in the edit buffer.
* W006 * Source/Dest of Block Copy/Move May Not Overlap
You attempted to move or copy a block of lines to a destination
line which was within the source block of lines. Execution of this
block move/copy would result in an endless series of copies or moves.
Move the cursor outside of the highlighted block of lines, and try
again.
* W007 * Source Program Modified. Recompile? (Y/N)
You selected the RUN or TRACE option of ASIC. ASIC has noticed
that you have modified the source. You should answer "Y" here to cause
ASIC to recompile your program before running it. If you instead answer
"N", ASIC will execute the existing copy of the compiled program, which
will not contain your latest changes.
* W009 * File has been modified. Save File Now? (Y/N)
You have told ASIC to exit back to DOS, but the edit buffer has
been modified. You should answer "Y" so that ASIC will save your
changes back to disk. If you answer "N" here, any changes you have made
to your program since the last SAVE command will be lost.
Page - 144
* W010 * Too Much Debugging Info-Truncating
ASIC could not handle all of the debugging information it found.
This error should not occur.
* W011 * Variable Not Found
During the processing of a Watch, Unwatch, or Modify Command, you
specified a variable name which ASIC could not find in the debugging
information. Checking your spelling for possible errors. Also, verify
that you have compiled your program with the Debugging compiler option
turned ON.
* W012 * Maximum Number of Variables Are Being Watched
You are already "watching" the maximum number of variables that
this version of ASIC supports. "Unwatch" one of the variables in the
watch window. This will allow you to "Watch" a new one.
* W013 * There Are No Variables Being Watched
You selected the "Unwatch" command. However, there are no
variables in the watch window to "Unwatch". Before this command may be
used, you must first have added a variable to the Watch window using the
"Watch variable" command.
* W014 * Unable to Load/Run Program
When ASIC attempted to load and run either the compiler or your
program it detected an error. This is due to one of two reasons.
First, ASIC could not find the program on disk. If compiling, make sure
that the ASICC.EXE file is in the same directory as the ASIC.EXE file,
and make that directory current. The second reason that you might get
this error is that there may be insufficient memory available on your
PC. In this case, you either need to free up more memory (by removing
TSRs etc), or you could execute your program or the compiler from the
DOS command line. For more information on compiling from the command
line, see Chapter 5--Stand-alone Compiler Options.
* W015 * Can't Set Breakpoint--No Code Generated For That Source
Line
You attempted to set a breakpoint and either 1) You haven't
compiled with the Debugging Compiler Option turned on, or 2) You have
tried to set a breakpoint on a line which did not generate any object
code. Thus, breakpoints cannot be set on REM or DATA statements, for
example. If you are sure that you have compiled with the above option
turned on, then try setting the breakpoint on another nearby statement.
Page - 145
* W018 * Your Program Must Be Running To Use This Function
You selected a function which is only operable when you are running
a program (which was compiled with the debugging compiler option turned
on). After your program terminates, this function is not available.
* W019 * Function Unavailable Until You Terminate Your Program
You selected a function while your program was running in debugging
mode. Before you can execute this function you must either Abort your
program, or allow it to Run until normal termination. Both the Run and
the Abort Options are available on the "Run" Menu.
* W020 * Invalid Debug (.DBG) File Format
ASIC attempted to access the symbolic debugging information file
created by the compiler for your program. It was able to locate the
file, but detected an error in the format while reading it. Make sure
that the version number of both the ASIC Integrated Editor and the ASIC
Compiler are the same. The version number is displayed on the top line
of the editor screen, following the word "ASIC". It is also displayed
on the compiler status screen while a compile is executing.
* W021 * Maximum Number of Breakpoints Already Set
You have attempted to set another breakpoint, but the maximum
number that this version of ASIC can support are already in use. Remove
one of the existing breakpoints you have set. This will free one up for
your use elsewhere.
* W022 * Can't Open ASIC.IDX File
You requested online help for an ASIC keyword. This function
requires a file called "ASIC.IDX" provided with your ASIC package, and
ASIC could not find this file in the current disk directory. Copy this
file from your ASIC package to the directory in which you are running
ASIC and try again.
* W023 * Can't Open ASIC.DOC File
You requested online help for an ASIC keyword or menu option. This
function requires a file called "ASIC.DOC" provided with your ASIC
package, and ASIC could not find this file in the current disk
directory. Copy this file from your ASIC package to the directory in
which you are running ASIC and try again.
Page - 146
* W024 * Can't Open ASICM.IDX File
You requested online help for an ASIC menu option. This function
requires a file called "ASICM.IDX" which was provided with your ASIC
package, and ASIC could not find this file in the current disk
directory. Copy this file from your ASIC package to the directory in
which you are running ASIC and try again.
* W025 * No Help Available For Selected Item
There is no online help available for the item you selected. The
information should be available in the ASIC Manual.
* W026 * Unable To Write ASIC.CFG File
You told ASIC to save your current Integrated Environment Options.
ASIC attempted to do so, but was not able to. Your options were not
saved to disk. This is usually caused by one of two things: 1) The
disk is full, or 2) The disk is write-protected. If the disk is full,
delete some unneeded files and try again. If the disk is write-
protected, remove the write-protect tab from the disk and try again.
* W027 * Debugger Can't Fully Save User Screen--Insufficient Memory
ASIC was not able to allocate enough memory to save the screen
output from your program while it was running in debugging mode in the
integrated environment. As a result, the screen displays may become
garbled. You should normally only see this message when your program is
using a high resolution EGA/VGA graphic mode on machines with very low
memory, or you have many TSRs installed. Either purchase more memory,
go to a lesser graphics mode, remove some TSRs from the AUTOEXEC.BAT
file, or run your program outside of the integrated environment.
* W028 * Not Enough Memory To Build Full File List
After you selected the Open or Save options from the File menu,
ASIC attempted to build a list of existing file names in memory, but was
unable to due to lack of memory. Exit from the editor and try to free
up more memory by removing TSR's, etc.
* W029 * Out of Memory -- Allocating Debug Symbols
The editor was trying to read the debugging information for your
program, but was unable to allocate enough memory to store the
information. If you proceed, the Watch, Unwatch, Modify Variable,
Trace, and Breakpoint commands may perform erratically. Exit the editor
and try to free up more memory by removing TSR's, etc.
* W030 * Stack Size Must Be 16-32767
You selected the Stack Option off of the Advanced Options Menu, and
entered a stack size that is too small or too large. Your entry was
ignored--the stack size was not updated.
Page - 147
* W031 * Unable To Save Program Options
ASIC attempted to save program compile options to disk, but was not
able to. This is usually caused by a disk that is full or has the write
protect tab set.
* W032 * Unable to run COMMAND.COM
ASIC was unable to locate the COMMAND.COM file. Because of this,
it was unable to complete your request.
Page - 148
RUN TIME ERRORS
Divide Overflow
This message indicates that your program attempted to divide by
zero.
Page - 149
SYSTEM ERROR CODE VALUES
After most commands which access the disk, ASIC sets a special "ERROR"
variable to indicate success or failure of that command. After you
execute one of these commands, you can reference this variable as a
regular variable in your program, to determine the outcome of the
command(eg. "IF ERROR = 000 THEN OKAY:").
ERROR Codes Set by BLOAD
000 No Error
002 File Not Found
003 Path Not Found or File Doesn't Exist
004 File Not Found
005 File Access Denied
006-255 Read Past End of File
ERROR Codes Set by BSAVE
000 No Error
002 File Not Found
004 File Not Found
005 File Access Denied
006-255 Disk Full
ERROR Codes Set by CALL
000-254 Return Code from Program (Zero If Not Set by User Program)
255 Error Loading/Running Program
ERROR Codes Set by CHDIR
000 No Error
003 Path Not Found
ERROR Codes Set by CLOSE
000 No Error
006 Invalid Handle
095 Cannot Close File -- File is not Open
ERROR Codes Set by FILEPOS
000 No Error
001 Invalid Function Number
006 Invalid Handle
098 File mode not Random or Append
Page - 150
SYSTEM ERROR CODE VALUES (Continued)
ERROR Codes Set by FIND
000 No Error
002 File Not Found
018 No More Files Match Search Criteria
ERROR Codes Set by GETDIR
000 No Error
015 Invalid Disk Drive Specification
ERROR Codes Set by INPUT (when using ";" option)
000 No Error
001 Invalid Input
ERROR Codes Set by INPUT#
000 No Error
005 Read Access Denied
006 Invalid File Handle
096 Input String Truncated at 80 characters
(this error code is not set when you specify NONULL)
098 File Not Open for Input or Random Modes
099 End of File
ERROR Codes Set by KILL
000 No Error
002 File Not Found
005 Access Denied
ERROR Codes Set by MKDIR
000 No Error
003 Path Not Found
005 Access Denied
ERROR Codes Set by NAME
000 No Error
002 File Not Found
003 Path Not Found or File Doesn't Exist
005 Access Denied
017 Not Same Disk Drive
ERROR Codes Set by OPEN --- Mode Input
000 No Error
002 File Not Found
004 File Not Found
005 File Access Denied
254 File Number Already in Use
Page - 151
SYSTEM ERROR CODE VALUES (Continued)
ERROR Codes Set by OPEN --- Mode Output, Append, or Random
000 No Error
001 Invalid Append Function
003 Path Not Found
004 No File Handle Available
005 File Access Denied
006 Invalid Append Handle
254 File Number Already in Use
ERROR Codes Set by PRINT#
000 No Error
005 File Access Denied
006 Invalid File Handle
097 File Not Open for Output, Append, or Random Modes
255 Disk Full
ERROR Codes Set by RMDIR
000 No Error
003 Path Not Found
005 Access Denied
006 Can't Delete Current Directory
016 Can't Delete Current Directory
ERROR Codes Set by RUN
000-254 Return Code from Program (Zero If Not Set by User Program)
255 Error Loading/Running Program
ERROR Codes Set by DECIMAL Math Routines
000 No Error
001 Division By Zero
Page - 152