Intel 9800758-02 manual Arithmetic Operators, BASIC-SO Operators in Order of Precedence Contd

Page 21

BASIC-80

Language Elements

Table 2-6.BASIC-SO Operators in Order of Precedence (Cont'd.)

Order

Operator

Example

9.Logical NOT, used to invert a given

argument.

NOT-1 =0

 

10.Logical AND, used to test if the nth bit of X

and the nth bit of Yare both on.

1ANDO=O

11.Logical OR, used to test if the nth bit of X or

Y equals 1.

150RO=15

12.Logical exclusive OR, used to test if either

 

the nth bit of X or the nth bit of Y = 1, but not

15XOR7= 8

 

both.

 

13.

Logical implication, used to test if the nth bit

OFOFOH IMP OOFFH=OFFFOH

 

of X is on, then the nth bit of Y is on.

 

 

14.Logical equivalence, used to test if the nth

bit of X equals the nth bit of Y.

OFOFH EQV.OOFFH=OFOOFH

 

Operators and Precedence of Evaluation

Complex expressions may be formed by combining constants and variables with arithmetic, logical, relational, and string operators. BASIC-SO follows an order of precedence to insure orderly and predictable evaluation when analyzing complex ex- pressions. This order of precedence may be overridden by parentheses; any elements within the parentheses are evaluated first. The numeric operators (arithmetic, logical, and relational) are listed in order of precedence in Table 2-6.

Arithmetic Operators

There are seven arithmetic operators in BASIC-SO, each performing a familiar arithmetic operation on two numeric expressions. They are evaluated before the relational or logical operators, and if two operators of equal precedence are found by BASIC-SO, they are evaluated from left to right. Table 2-6 lists the arithmetic operators in order of precedence. Some examples of arithmetic operators are:

A= 8*(C*2.49) K1=(L+M) S RS = (83* Et .S)

Relational Operators

There are six relational operators in BASIC-SO, which test relationships between two expressions and return a -1if the premise is true, a 0 if it is false. You can write in- structions to direct program execution according to either result. The relational operators are evaluated after the arithmetic operators, and if two operators with the same order of precedence are given in an expression, they are evaluated left to right. Table 2-6 lists the relational operators, and some examples are given below:

IF (A*2.2)<>8*81 THEN 220

IF INT(A1) = INT(81) THEN A=B

IF A> B THEN IF 8>(C* VA#)THEN 340

2-11

Image 21
Contents BASIC-SO Reference Manual A108/0979/7500 FL Preface Page Contents Illustrations Invoking BASIC-80 Chapter Introduction to BASIC-80Introduction to BASIC-80 ExamplesBasic filename MEMTOPaddress FilenameRenaming a File Listing the Directory of a DiskChanging File Attributes Deleting a FileSave LP ,A You can now run, list, or edit the programStatements CommandsBASIC-80 Statements BASIC-80 Commands ContdBASIC-80 Functions BASIC-80 Statements ContdBASIC-80 Functions Contd Functions Representing DataInteger Constants ConstantsDecimal Integer Constants Hexadecimal Integer ConstantsOctal Integer Constants Single-Precision Floating-Point ConstantsDouble-Precision Floating-Point Constants String Variables String ConstantsThis is a string constant $ = Enter next data stringYI,1 L4! = Csng l4String Arrays BASIC-SO Operators in Order of Precedence Contd Arithmetic OperatorsString Operator Logical OperatorsNumeric Expressions String ExpressionsEntering and Editing Programs 30 A=8 30 A=8*5230 A=8*52 30 A=8*37 30 A--=8xx*522537 Control-R a = 8*37Command 3D press 3, then D results SubcommandInteger D If AB thenIf AB then 120 Else Null SET At this point, the other editing subcommands may be used Syntax of the X subcommand isInteger C character character Print Undefined SET The E subcommand is enteredMove the cursor to PRINT. Enter 2C RE L Print Undefined SET. Enter a LBASIC-80 Error Messages Syntax Error MessagesOverflow, Underflow, and Divide-by-Zero Error Trapping Trace Facility Error Handling Error SimulationRestarting Program Execution If line 40 is replaced withOpen 1,#1,F1DATES Opening a Sequential FileWriting to a Sequential File Refer to for further details of Print UsingReading from a Sequential File If executed four times, it would read all eight valuesValue of R$ would be Closing a Sequential FileBuffers Defining a Random 1/0 Field-FIELDField #3, 20 AS N$ Field #3, 20 AS N$, 9 AS SS$ Disk File Input/OutputReading from a Random 1/0 File Opening and Closing a Random Disk FileAny of the parameters can be variables To read the next recordInteger Writing to a Random 1/0 FileSingle-precision value Double-precision valueMKI$ Attrib Fdrive numberfilename, WO Attrib Fdrive numberfilename, W1Auto first lineJ, increment Clear expression,addressClose Commands and StatementsRules for function name are the same as for variable name DEF FNXDefsng Defdbl Defstr Defint Delete DIMDIR ErrorEdit ENDExit Error expressionField FOR-NEXT-STEPGosub GETFor variable=expression to expression Step expression GET I file number ,record numberIF-THEN-ELSE InputGoto LET KillLine Input ListLoad LSET, RsetNEW Merge9 16 NextOn ... Gosub On ... GotoOpen Option Base OUTPoke Print Using PrintString Fields If X$=SEVEN and Y$=EIGHT, the results of line 40 would be Numeric fieldsPUT PrunRead RandomizeREM Return ResumeRUN line numberlstring expression ,F SaveLine number RUN filename 60 END? 5,8,2 TRON, TroffWidth WaitATN ABSCHR$ CintFunctions CVI CVS Csng10 A# = 1.00/3.00 AO/o =EOF DskfOk· FIXHexs INPInputs INT InstrLEFT$ LOC LENLOF LOGMID$ MKI$ MKS$ MKD$OCT$ Peek expression RightsPOS integer RIGHT$ string,integerSIN SGNSpaces 10 a =1SPC integer SPCIf A$ = 2 then Print Correct Else Goto SQRexpressionSTR$ expression TAB expressionTAN expression 60 AO/o = Here is an example of how the USRn statement is usedTable A-I. BASIC-80 Error Codes Appendix a BASIC-SO Error CodesTable A-I. BASIC-SO Error Codes Contd Appendix B BASIC-SO Reserved Words Page Level To halt program execution and return to commandTo tab across the line To resume program execution after it is stopped byPage Appendix D Ascii Codes Table D-l. Ascii Code ListBEL Table D-2. Ascii Code DefinitionAppendixe Calling Subroutines Figure B-1. Internal Representation of Numbers and Strings RESULT=USR%1VARPTRA, VARPTRB, VARPTRC» PRINTA+B+C= Result Some Real ExamplesFigure E-2 /8085 Assembly Language Program Figure E-3. PL/M-80 Program Appendix F RMX/SO BASIC-SO ISIS-II BASIC-SO Initializing the Predefined RMX/SO BASIC-SO ConfigurationOOOOH-OFFFH Table F-l. Sample Configuration Jumper WiringBASIC-80 Source Files Generating Boot-Loaded and PROM-Based VersionsBASIC-80 Object Files BASIC-80 Executable FilesGenerating a Boot-Loaded RMX/80 BASIC-80 This option is used to allocate memory. It is 1 if the boot That are not boot loadedSetting baud rates, refer to the RMX/SO Users Guide This option enables your user-written I/O drivers if youISBC 80/20-4 Generating a PROM-Based RMX/80 BASIC-80 Prom F1 RMX820.L1BSTART, & FOBASCM.OBJ,& FORMXBAS.LlB F1 DFSDIR. L1BDIRECTORY ,RENAM E,& F1 MTI810.L1B Adding BASIC-SO to an Existing RMX/SO Configuration Configuring DFS on an iSBC 80/10Configuration Requirements ISBC SO/10 System ClockPublic Variables Open 0,#1, L1LlST Adding User-Written I/O Drivers to RMX/SO BASIC-SOFigure F-S. Sample User-Written 1/0 Driver Routine Burning a BASIC-80 Program Into Prom Altering BASIC-80 WorkspaceBaprom F1HEATER.BAS Page Index Ase BASIC-80 RIGHT$,7-1O Request for Readerscomments 111111