Sharp MZ-80B Basic Manual

Sharp MZ-80B Basic Manual

Personal computer double precision disc
Hide thumbs Also See for MZ-80B:
Table of Contents



Table of Contents

Summary of Contents for Sharp MZ-80B

  • Page 3 Personal Computer MZ-808 Double Precision DISK BASIC MANUAL •••• ••• ••• Copyright © by SHARP CORPORATION...
  • Page 4: Notice

    However, in the event that you should notice any errors or ambiguities, please feel free to contact your local Sharp representative or your nearest dealer for clarification. All system software packs provided for the MZ-808 are original products, and all rights are reserved.
  • Page 5: Introduction

    Introduction The greatest care must be taken in handling disk drives diskettes. Carefully read the notes in "Handling Diskettes" on page 69 . The master diskette and blank diskette will not be exchanged for new ones after purchase. I t is recommended that the master diskette be copied using the disk copy utility (refer to page 36) to Be sure to keep the generate a submaster diskette, and that the submaster diskette be used generally.
  • Page 6: Table Of Contents

    Contents , ........ii Notice Introduction Chapter 1 Outline of double precision DISK BASIC S(:J-661 0 ..
  • Page 7 2 . 2 . 1 1 ROPEN # ..........25 2 .
  • Page 8 ......;:, 1 3 . 1 . 1 2 Comment and control statements 3 . 1 . 1 3 Music control statements ....... . 5 2 3 .
  • Page 9: Chapter 1 Outline Of Double Precision Disk Basic S

    Chapter 1 Outline of double precision DISK BASIC SB-661 This chapter outlines programming procedures and use of the double precision DISK BASIC interpreter SB-667 0. The chapter begins with a description of the procedure for activating the BASIC SB-6610, fol­ lowed by general file control concepts.
  • Page 10: Activating The Disk Basic Interpreter Sb-6610

    1 . 1 Activating the DISK BASIC interpreter SB-6610 DISK BASIC SB-66 1 0 is st ored (along wi t h MONITOR SB- 1 5 1 0 ) on a diskett e file and mu st u ndergo init ial program loading whenever it is t o be u sed. Loading is easily performed. Ready t he disk drive u nit, place t he mast er diskett e (or su bmast er diskett et , if available) in disk drive and simply tum on t he p ower of t he MZ-80 B.
  • Page 11: Introduction To File Control

    1.2 Introduction to file control The DISK BASIC interpreter SB-66 1 0 is a system software which has a su perb file control f u nc­ tion . It f u lly u tilizes the large capacity and high speed accessing featu re of the floppy disk file system ·s o th at files can be u sed not only for data storage bu t also as a random access data area connected to the system program .
  • Page 12 The file to which the specif ied logical file number has been assigned is accessed by the write or read command issued by a PRINT # or INPUT # statement or by a file close statement. CHAIN and SWAP are statements which overlay a program up on another program in the m emory and transfer control to the overlying program.
  • Page 13: Control Of Sequential Access Files

    1. 3 Control of sequential access files A sequ enti al access file i s a dat a file whose dat a i s recorded or read wit h sequ enti al access proce­ du res, whi ch accesses dat a sequ enti ally st arti ng wit h t he first dat a it em . You already know how t o handle dat a files on cassett e t ape u si ng BASIC SB-5 5 1 0.
  • Page 14 As a simple example of sequ ential access file control, let ' s discu ss the recording of names and addresses o f persons' homes in a sequ ential access file. Ou r file, an address list in this example, mu st be made in the following form .
  • Page 16: Control Of Random Access Files

    1 . 4 Control of random access files A random access f ile is a dat a file which permit s dat a t o be recorded or recalled u sing t he "random access" met hod. The t erm "random access" refers t o t he process of recording or recalling each dat a it em by specifying it as an array element .
  • Page 17 "RND 1 " "RND 1 " When data is added with � the "expression" set to 30. Now , J et' s try to device a program for making a simple inventory J ist u sing a random access file. It is assu med that individu al articles are given fixed item nu mbers from 1 to 5 0 and that the inventory J ist inclu des five fields of information : item name, u nit price, nu mber of u nits in stock, valu e (u nit price X nu mber items in) and comments.
  • Page 19: File Access Cancellation And How To Detect File End

    1. 5 File access cancellation and how to detect file end 1.5.1 KILL This st at ement, when i t follows t he WOPEN st at ement, cancels t he WOPEN command. The execut ion of KILL st at ement cancels t he WOPEN and prevent s t he dat a array, even if it is u nder const r u ct ion, from being recorded in t he sequ ent ial access file.
  • Page 20: Making A Chain Of Programs

    1. 6 Making a chain of programs The t opic of t his sect ion is t wo program file cont rol st at ement s. These are t he CHAIN are SWAP st at ement s. When some programs are recorded on a diskett e, t he u se of t hese st at ement s enables you t o call anot her program while ru nning t he recorded programs and moves t he cont rol t o it .
  • Page 21: Swapping Programs

    1. 7 Swapping programs The SWAP st at ement reads a program from a diskett e file, overlays anot her program wit h it or links t hem, and leaves cont rol t o t hat program t ext, resu ming cont rol by t he original program t he inst ant t he execut ion of t he t ext h as been complet ed .
  • Page 22 Text area Initially , the text "CO M POSER" , Composer "PLAY THE CELLO" present in the text area, is exe­ cuted. First the SWAP statement, line Sheltered No. 6 0, shelters the text on the diskette present in the drive FD 1 that has executed the DIR com- mand, and renews the text area.
  • Page 23: Usr Function In A Logical Open Statement

    1. 8 USR function in a logical open statement T he USR function generally calls a subroutine coded in machine language. When it is used in a logical open statement (WOPEN or ROPEN) , however, logical open is performed with the assump ti on that the USR function is a logical file which is executed when a subsequent PRIN T # or INPU T # statement is executed.
  • Page 24 (Read) 200 ROPEN # 1 1 , USR (n) 2 10 INPUT # 1 1 , B $ 2 20 CLOSE # 1 1 200 : Assigns logical file number # 1 1 t o US R (n) and logically opens it . 2 10 : Execu t es US R (n).
  • Page 25: Chapter 2 Instructions Unique To Sb-6610

    Chapter Instructions Unique to SB-661 This chapter describes SB-667 0 direct commands, statements, updated commands and utilities which are not supported by the ordinary cassette BASIC interpreter SB-5570. Command and statement format Commands and statements must be coded accordin g to the following conventions. •...
  • Page 26: Direct Commands

    2.1 Direct commands 2 . 1 . 1 DIR < FD d > Format d number : 1 through 4 Displays the file directory of the diskette specified. Function When FDd is omitted, the value defaults to the number of the drive against which Description the last DIR F D d com mand was executed.
  • Page 27: Save

    2. 1 .3 SAVE SAVE < FD d @v, > "file name" Format d number 1 through 4 v ..diskette volume number Assigns the specified file name to the BASIC text contained in the text area and Function stores it on the diskette in the specified drive.
  • Page 28: Run

    2.1.5 RUN < FDd @ v, > "file name" Format d number 1 through 4 v ..diskette volume number "file name " ..BTX file or OBJ file Loads the BASIC text ( BTX) assigned the file name "file name"...
  • Page 29: File Control Statements

    2. 2 File control statements LOCK 2.2.1 LOCK < FD d @v , > "file name" Format d number 1 through 4 v ..diskette volume number This statement locks a specified file. Function When a file is locked, requests to modify it will be denied.
  • Page 30: Delete

    2.2.4 DELETE DELETE < FD d @v,> "file name " Format d number 1 through 4 v ..diskette volume number This statement deletes a specified file from the diskette. Function This statement is prohibited for any locked file.
  • Page 31: Swap

    2.2.6 SWAP SWAP < FD d @v ,> "file name" Format d number : 1 through 4 v ..diskette volume number This statement swaps the program execution to BASIC text on the diskette. Function SWAP F D2@7, "TEXT S-R"...
  • Page 32: Print

    2.2.8 PRINT # PRINT #l, d1, <, d2, dn > Format • • • l ..logical number di ..write data This statement writes the data d 1 , d2 dv (numeric data or string data) in order Fonction •...
  • Page 34: Xopen

    • BRD (BASIC Random access Data file) control 2.2.1 3 XOPEN # XOPEN #1, < FD d @v, > "file name " Format ..logical number d number : 1 through 4 v .
  • Page 35: F Eof (#) Then

    2.2. 1 5 INPUT # ( Format INPUf# l ( n ) , v 1 < , v2 , . . . , vn > l ..logical number n ..item expression v;...
  • Page 36: Error Processing Control

    2. 3 Error processing control 2.3 .1 ON E RROR GOTO ON E RROR GOTO lr Format lr ..reference line number : error processing routine This statement declares the number of the line to which program execution is to Function be moved in order to correct errors.
  • Page 37: If Erl

    The statement shown below causes program execution to jump to line 1 200 when Example Error 5 (String Overflow) occurs, indicating that the string length exceeded 2 5 5 characters. 800 IF E RN = 5 THEN 1 200 2.3 .3 IF ERL IF ERL expression THEN lr Format...
  • Page 38: Resume

    2.3.4 RESUME RESUME < NEXT > Format RESUME lr lr ..reference line num b er or 0 This statement returns program execution to the main program after correction of Function an error. The system holds the number of the line on which the error occurred in memory Description and returns program execution to that line or to another specified line after t1:1e error is corrected.
  • Page 39: Updated Comman D

    2.4 Updated commands 2 .4 . 1 PRINT USING PRINT USING format ; variable name list Format format ..string variable consisting of special characters variable name list . . . numeric variables and/or numeric expression This statement displays the contents of the numeric variable indicated by h he Function variable name list operand in the specified format.
  • Page 41: Delete

    Format Over Display • When the data length is longer than that specified, preceeds the data displayed. PRINT USING "##,###" ; 1 23456 % 1 23,456 Other Characters except Format • When any other characters are specified at the beginning or end of the format operand, they are displayed as they are.
  • Page 42: Dim

    2.4.3 DIM Format DIM a 1 Ut ) < , a 2 U2 ), .., a n Un ) > DIM b 1 Ut , jd < , b 2 ( i 2 , j.2 ), . . . , b n Un , jn ) > one-dimensional array t wo-dimensional array i n .
  • Page 44: Use Of Utility Program "Utility

    You obtain the object file (OBJ) "BASIC SB-5 5 1 0" on the diskette in drive 2 . Therefore, to call BASIC interpreter SB-5 5 1 0 from the diskette file , simply enter RUN "BASIC SB-5 5 1 0" 2.5 .2 U s e of utility program "Utility"...
  • Page 45 S command assigns a volume number t o a initialized diskette for making a slave diskette. Figure 2 . 5 shows an example where the slave diskette in drive 1 is made with volume number 2.5 assigned. [ COMMAND TABLE ] DISKETTE INIT SLAVE-DISK INIT D ISKETTE COPY...
  • Page 46 Any number of submaster diskettes can be made by copying the master diskette using this diskette copy command explained above. However, submaster diskettes cannot be made by copying another submaster diskette. FIGURE NOTE : It is recommended that a write protect seal be placed on the original diskette to prevent it from being accidentally erased.
  • Page 47: Chapter 3 Programming Instructions

    Chapter Programming Instructions This chapter summarizes all commands, statements, operators, symbols and specifications of the double precision DISK BASIC interpreter SB-667 0.
  • Page 48: List Of Disk Basic Interpreter Sb-6610 Commands, Statements And

    3. 1 List of DISK BASIC interpreter SB-6610 commands, statements and · functions 3 . 1 . 1 Commands DIR FDd Displays the file directory of the diskette in drive d (d= 1 �4). The contents of the directory are as follows : 1 ) Volume number 2) Number of unused sectors 3) Mode, l ock condition and file name of each file on the dis­...
  • Page 49 Transfers system control from the BASIC interpreter to the MONI­ TOR. To transfer system control from the MONITOR to the BASIC interpreter, execute monitor command J . Activates the MZ-80B system initial program loader. BOOT BOOT Displays a complete list of string definitions for special function...
  • Page 50: File Control Statements

    3 . 1 .2 File control statements Locks file "ABC" on the diskette in the active drive. LOCK LOCK "ABC" Locks file "ABC" on the diskette (whose volume number is 7), in LOCK FD4@7 "ABC " drive 4 . The locked me cannot be updated o r deleted. When the me directory is listed, the locked file name is indicated with an asterisk.
  • Page 51: Bsd (Basic Sequential Access Data File) Control Statements

    3 . 1 .3 BSD (BASIC Sequential access Data file) control statements Defines the file name o f a BSD (BASIC sequential access data file) WOPEN # WOPEN #3, FD2@7 , to be created as "SEQ DATA 1 " and opens it with logical number "SEQ DATA 1 "...
  • Page 52: Error Processing Statements

    PRINT #( ) PRINT #5 (20), AR$, AS$ Writes the contents of string variables AR$ and AS$ on field 20 and field 2 I of the BRD assigned logical number 5 , respectively. All BRD fields have a fixed length of 32 bytes and , if the length of string variable exceeds 32 bytes, the excess part is discarded.
  • Page 53: Cassette File Input/Output Statements

    Returns program execution to the statement just after the one in 700 RESUME NEXT which the error occurred. 750 RESUME 400 Returns program execution to line number 400 . 800 RESUME 0 Returns program execution to the beginning of the program. 3.
  • Page 54: Input/Output Statements

    3.1 .8 Input/outpu t statements PRINT 10 PRINT A Displays the numeric value of A on the CRT screen. Displays the character string of variable A$ on the CRT screen. 1 00 PRINT A ; A$, B ; B$ Combinations of numeric variables and string variables can be spe­ cified in a PRINT statement.
  • Page 55 Displays £ 7 ,658.35. 20 PRINT USING " £###,###.##" ; 7658.35 30 PRINT USING Displays @2,9 3 5 . "@###,###' ; 2935 40 PRINT USING Displays $8 1 ,96 5 . "$###,###" ; 8 1 965 Displays spaces for X's. PRINTUSING "#XX#.
  • Page 56 10 A$= "###.##' The format operand can be specified with a string variable as shown at the left. 20 PRINT USING A$ 1 .5 8 Displays 1 .5 8. 30 PRINT USING A$ 28.3 Displays 28.30. 10 INPUT A Obtains numeric data for variable A from the keyboard. INPUT 20 INPUT A$ Obtains string data for string variable A$ from the keyboard.
  • Page 58: Definition Statements

    Jumps to the subroutine starting on line number 700 when the IF - GOSUB 3 0 IF A=B* 2 GOSUB 90 value of variable A is twice the value of B ; otherwise the next state­ ment is executed. (When other statements follow a conditional statement on the same line and the conditions are not satisfied, those following an ON statement are executed sequentially, but those following an I F statement are ignored and the statement on the next line i s exe­...
  • Page 59: Comment And Control Statements

    DEF KEY 1 5 DEF KEY ( l )=LIST A DEF KEY statement def mes a function for any of the ten special 25 DEF KEY (2)=LOAD ! function keys. The statement on line number 1 5 defines special function key 1 as LIST. The statement on line number 25 defines special function key 2 as the multi-command LOAD: RUN.
  • Page 60: Music Control Statements

    3 1 0 MUSIC "DE#FGA" MUSIC statement on line number 3 1 0 generates a melody consist­ ing of D, E, F sharp, G and A. Each note is a quarter note. When the TEMPO statement is omitted, default tempo is set.
  • Page 61 Sets a dot in the specified position ·in a graphic area operating in the input mode. The first operand specifies the X-coordinates (0-3 19) and the second operand specifies the Y-coordinates (0- 1 99). 300 SET 1 60, 1 00 Displays a dot in the center of the screen.
  • Page 62: Machine Language Control Statements

    System variable indicating the X-coordinate (horizontal location) POSH of the position pointer. System variable indicating the Y-coordinate (vertical location) of POSY the position pointer. 3 . 1 . 1 5 Machine language control statements Limits the area in which BASIC programs can be loaded to the area LIMIT 100 LIMIT 49 1 5 1 up to address 49 1 5 1 ($BFFF in hexadecimal).
  • Page 63: Printer Control Statements

    600 WOPEN #8, USR The statement on line 600 opens a file which is to be written by ($COOO) the machine language program called by USR ($COOO) with logical 6 1 0 PRINT #8, A $ number 8 assigned . At this stage of program execution the USR 620 C LOSE #8 function is not executed.
  • Page 64 PRINT /P CHR$ ( 1 9) Cancels the double size mode. Returns to the 80 digit mode or 1 36 digit mode . PRINT/P C H R$ (20) Sets the printing mode as reduced characters of the normal size printing (80 digit mode). It is called reduced mode or 1 36 digit mode.
  • Page 65: Arithmetic Functions

    3. 1 . 1 8 Arithmetic functions Substitutes the absolute value of variable X into variable A . X may 1 00 A = ABS (X) be either a constant or an expression. ABS (-3) = 3 ABS ( 1 2 ) = 1 2 1 00 A = INT (X) Substitutes the greatest integer which is less than X into variable A.
  • Page 66: Tabulation Function

    Substitutes the N characters following the Mth character from the MID $ MID$ (X$ , M, N) beginning of string variable X$ into string variable B$. C$ = RIGHT$ (X$, N) Substitutes the last N characters of string variable X$ into string RIGHT $ variable C$.
  • Page 67: Arithmetic Operators

    3.1 .21 Arithmetic operators The number to the left of each operator indicates its operational priority. Any group of operations enclosed in parentheses has first priority. x · y • · 1 0 A = (power) Substitutes into variable A. (If X is negative and Y is not an integer, an e rror results.) (j - Note that "-"...
  • Page 68: Other Symbols

    A comma is used to separate two variables. 320 A$ = "SHA RP BASIC" Indicates that characters between double quotation marks form a 330 B$ = "MZ-80B" string constant . 340 C$= "ABC " + "C HR$ (3) Indicates that the variable followed by a dollar sign is a string vari­...
  • Page 69: Specifications Of Double Precision Basic Sb-6610 Interpreter

    3. 2 Specifications of double precision BASIC SB-6610 interpreter • Type Interpreter system Program siz e : about 1 6 . 5K bytes Start address: $ 1 2 20 (hexadecimal) • Numeric d ata BCD floating point system Real num ber : + l E-4 8 +9 .
  • Page 70 • S tring variable Kinds of string variable s : String variable One-dimension al string variable Two-dimensional string variable Format : A string variable is expressed by a name following $ . Requirements for string variable name are the same as those for numeric variable. Example : A $ , ST$ and Nl $ are normal string variables.
  • Page 71: Appendix

    APPENDIX The Appendix includes the follo wing; • ASCII Code Table ..Table A. 7 • DISK BASIC interpreter SB-667 0 Error Message Table ..Table A . 2 This table list all the possible errors which may occur during program execution. The interpreter notifies the operator of occurrence of an error during program execution or operation in the direct mode with the corresponding error number.
  • Page 72 ASCII Code Table Code in parentheses represents a hexadecimal code. (34) 1 0 4 (68 ) (00 ) ( I A) (4E) [§] ( 69) (3 5 ) (0 1 ) (4F) ( I B) 1 0 5 [!_] 1 06 ( 6A) ( 3 6 ) (02)
  • Page 73 1 29 1 5 5 (9B) (8 1 ) 1 8 1 (BS) (E9) (CF) 1 30 (9C) (B 6 ) (DO) (8 2) 1 5 6 1 8 2 (E A) 1 3 1 (9D) 1 5 7 (B7) (83) 1 83 (EB)
  • Page 74: Error Message Table

    A 2 . Error Message Table Syntax error Operation result overflow Illegal data Data type mismatch String length exceeded 2 5 5 characters Insufficient memory capacity The size of an array defined was larger than that d efined previously. The length of a BASIC text line was too long. The num ber o f levels of GO SUB nests exceeded 1 5 .
  • Page 76: Memory Map

    A . 3 Memory Map $0000 $ 1 22 0 $ 1 220 : Cold start address $ 1 280 : Hot start address User's area...
  • Page 77: Handling Diskettes

    OBJ file "Utility" on the master diskette. Be s � re to keep the m aster diskette in a safe place . All optional blank diskettes supplied by the Sharp Co. are not initialized. Be sure to initialize them before use.
  • Page 80 T I N S E 00 1 8PAZZ 8 1 0429-500-K Pri nted in Japan SHAR P COR PORATION...
  • Page 81 Dl R instruction. If the disket is replaced SAVE SAVE with another one immediately after the instruction and the instruction is executed again, the contents of the replaced new disket will be destroyed. SHARP CORPORATION Printed in Japan...

Table of Contents