CBASIC® Language Reference Manual [Q] DIGITAL RESEARCHTM

CBASIC® Language Reference Manual [Q] DIGITAL RESEARCHTM

CBASIC® Language Reference Manual [Q] DIGITAL RESEARCHTM CBASIC® Language Reference Manual COPYRIGHT Copyright © 1981, 1982 by Digital Research. All rights reserved. No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval system, or translated into any language or computer language, in any form or by any means, electronic, mechanical, magnetic, optical, chemical, manual or otherwise, without the prior written permission of Digital Research, Post Office Box 579, Pacific Grove, California, 93950. This manual is, however, tutorial in nature. Thus, the reader is granted permission to include the example programs, either in whole or in part, in his own programs. DISCLAIMER Digital Research makes no representations or warranties with respect to the contents hereof and specifically disclaims any implied warranties of merchantability or fitness for any particular purpose. Further, Digital Research reserves the right to revise this publication and to make changes from time to time in the content hereof without obligation of Digital Research to notify any person of such revision or changes. TRADEMARKS CBASIC, CP 1M, CP IM-86 , and CP INET are registered trademarks of Digital Research. CBASIC-86, DDT, MP 1M, and MP IM-86 are trademarks of Digital Research. Z80 is a registered trademark of Zilog Inc. Intel is a registered trademark of Intel Corporation. The CBASIC Language Reference Manual was prepared using the Digital Research TEX Text Formatter and printed in the United States of America by Commercial Press/ Monterey. First Edition: November 1981 Second Edition: October 1982 Foreword CBASIC® is a comprehensive and versatile programming language for developing professional microcomputer software. Software developers worldwide have selected CBASIC for its capacity to quickly produce reliable, maintainable programs in an enhanced programming environment. CBASIC combines the power of a structured, high-level language with the simplicity of BASIC to provide a serious development tool that is easy to learn and easy to use. If you are a newcomer to data processing, read an introductory text on BASIC first. All you need is an understandJng of elementary programming concepts and a familiarity with BASIC terminology to learn CBASIC. The CBASIC Language Reference Manual covers CBASIC and CBASIC-86™. • CBASIC runs under the CP/M®, MPIM™, and CPINET® operating systems for computers based on the Intel® 8080, 8085 or the Zilog Z80® microprocessor. • CBASIC-86 runs under the CP IM-86® or MPIM-86™ operating systems for computers based on the Intel 8086 microprocessor. Section 6 discusses the minor differences between the two versions of CBASIC. At the end of Section 1 is a demonstration program that you can compile and run by following a few simple steps. The rest of the manual covers three main topics: CBASIC language definition, machine dependencies, and the Compiler and Interpreter. • Sections 2, 3, and 4 define the CBASIC language. • Section 5 covers input and output. • Section 6 discusses assembly language interfacing and other machine-dependent topics. • Section 7 discusses the Compiler, run-time Interpreter, and Cross-reference Lister. iii iv Table of Contents 1 Getting Started with CBASIC 1.1 CBASIC Components ......................................... 1 1.2 Program Structure ............................................ 1 1.3 A Demonstration Program ..................................... 2 2 Names, Numbers, and Expressions 2.1 Identifiers ................................................... 5 2.2 Strings ...................................................... 6 2.3 Numbers ...........................' .........'................ 7 2.4 Variables and Array Variables .................................. 8 2.5 Expressions .................................................. 9 3 Statements and Functions ........................................... 13 4 Defining and Using Functions 4.1 Function Names .............................................. 103 4.2 Function Definitions .......................................... 104 4.2.1 Single-Statement Functions ............................. 104 4.2.2 Multiple-Statement Functions ........................... 105 4.3 Function References ........................................... 106 5 Input and Output 5.1 Console Input and Output ..................................... 107 5.2 Printing ..................................................... 108 5.3 Formatted Printing ................................ 108 5.3. 1 String Character Fields ................................. 109 5.3.2 Fixed-Length String Fields .............................. 109 5.3.3 Variable-Length String Fields ............................ 110 5.3.4 Numeric Data Fields ................................... 111 5.3.5 Escape Characters ...........................' . .. 114 v Table of Contents (continued) 5.4 File Organization ............................................. 114 5.4.1 Sequential Files ........................................ 115 5.4.2 Relative Files..................................... ..... 117 5.5 Maintaining Files ............................................. 119 6 Machine Language Interface 6.1 Memory Allocation ........................................... 121 6.2 Internal Data Representation. .. 123 6.3 Assembly Language Interface ................................... 124 6.4 CBASIC 8-bit (8080) Demonstration Program ................... 126 6.5 CBASIC 16-bit (8086) Demonstration Program .................. 129 7 Compiling and Running CBASIC Programs 7.1 Compiler Directives ........................................... 133 7.2 Listing Control ............................................... 133 7.3 %INCLUDE Directive ........................................ 134 7.4 %CHAIN Directive........................................... 134 7.5 CBASIC Compile-time Toggles ................................ 135 7.6 Compiler Output ............................................. 137 7.7 TRACE Option .............................................. 139 7.8 Cross-Reference Lister ......................................... 140 Appendixes A Compiler Error Messages 143 B Run-time Error Messages 149 C CBASIC Key Words ............................................... 155 D Decimal-ASCII-Hex Table ......................................... 157 E Glossary ......................................................... 159 vi Table of Contents (continued) List of Tables 2-1 Hierarchy of Operators ............................................ 10 7-1 Compile-time Toggles ....................................... 137-138 7-2 Cross-reference Lister Toggle Functions ............................ 141 A-l File System and Memory Space Errors ......................... 143-144 A-2 Compilation Error Codes ..................................... 144-148 B-1 CBASIC Warning Messages ...................................... 149 B-2 CBASIC Warning Codes ......................................... 150 B-3 CBASIC Error Codes ........................................ 150-154 D-l Conversion Table ........................................... 157-158 List of Figures 5-1 Sequential File .................................................. 115 5-2 Relative File .................................................... 117 6-1 CP 1M Memory Allocation ....................................... 121 6-2 Real Number Storage ............................................ 123 6-3 Integer Storage .................................................. 124 vii viii Section 1 Getting Started With CBASIC 1.1 CBASIC Components The CBASIC system has two main components: the Compiler and the run-time Interpreter. CBASIC also provides a Cross-reference Lister. • The CBASIC Compiler translates a source program into intermediate code. Source programs must be in .BAS files. The intermediate files are .INT files. • The run-time Interpreter executes the .INT file that the Compiler generates. • The Cross-reference Lister produces an alphabetized list of identifiers used in your CBASIC program. The Cross-reference Lister is a utility program provided as a convenience. It does not affect your programs. 1.2 Program Structure CBASIC has features found in high-level languages, such as structured statements, functions, complex expressions, and data types. Some other CBASIC features are parameter passing, local and global variables, easy access to the operating system, and chaining between programs. CBASIC requires no line numbers and allows the free use of commas, spaces, and tabs to make your programs more readable. A statement number or label is needed only when the statement is referenced from another location in the program. CBASIC allows integers, decimal fractions and exponential numbers as statement labels, as in the following examples: 1 PRINT "THESE ARE VALID LINE NUMBERS" o INPUT "ENTER A NUMBER:";N 100 GO TO 100.0 100.0 END ALI.., INFORMATION PRESENTED HE.RE IS PROPR!ETARY TO DIGITAL RESEARCH 1 1.2 Program Structure CBASIC Language Reference Manual 21.543 A$ = NAME$ 7820E12 Y = 2.0 * X CBASIC statement labels do not have to be sequential. The Compiler treats the labels as strings of characters, not as numeric quantities. For example, the two labels 100 and 100.0 are distinct CBASIC statement labels. The maximum length for a statement label is 31 characters. CBASIC statements can span more than one line. Use the backslash character, \, to continue a CBASIC statement on the next line. The Compiler ignores any character that follows a backslash on the same line. The backslash does not work as a continuation character

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    189 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us