Sharp OZ-707 Operation Manual - Page 29

Programming

Page 29 highlights

Example: 41 AND 27 ~ equals 9 41 OR 27 ~ equals 59 41 = 101001 AND 27 = 011011 ~ 001001 41 = 101001 OR 27 = 011011 ~ 111011 41 XOR 27 ~ equals 50 41 = 101001 XOR 27 = 011011 ~ 110010 NOT3~ equals -4 (two's complement form) 3= 0000000000000011 NOT ~ 1111111111111100 NOT X can generally be calculated by the equation NOT X = -(X+1). Parentheses and Operator Precedence When evaluating complex expressions, the C.ard f~1I0WS a predefined set of priorities that deter~ine .th~ ~equence In which operators are evaluated. This can be qUite significant: * 5 + 2 3 could be * 5 + 2 = 7 or 2 3 = 6 *7 3 = 21 6 + 5 = 11 The exact rules of "operator precedence" are given on page 28. To avoid having to remember all these rules and to make your program more precise, always use parentheses to determ.i~e the sequence of evaluation. The above example is clarified by wntlng: 46 3. PROGRAMMING In the previous chapter, we examined some of the concepts and terms of the BASIC programming language. In this chapter, you will use these elements to create programs. Let us remind you, however, that this is not a manual on how to program in BASIC. What this chapter will do is familiarize you with the use of BASIC on your Card. Programs A program consists of a set of instructions to the Card. It will perform the exact operations that you specify. You, the programmer, are responsible for issuing the correct instructions. BASIC Statements The Card interprets instructions according to a predetermined format. This format is called a statement. You must always enter BASIC statements in the same pattern. Statements must start with a line number: 10: INPUT A 20: PRINT A*A 30: END Line Numbers Each line of a program must have a unique line number - any integer between 1 and 65279. Line numbers are the reference for the Card. They tell the Card the order in which to run the program, and can be used to tell the Card at which line to start. You need not enter lines in sequential order (although if you are a beginning programmer, it is probably less confusing for you to do so). The computer always begins execution with the lowest line number and moves sequentially through the lines of program in ascending order. 47

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128

Example:
41
AND 27
~
41
= 101001 AND
equals
27 = 011011
9
~
001001
41
OR
27
~
41
= 101001
OR
equals
27 = 011011
59
~
111011
41
XOR 27
~
41
= 101001
XOR
equals
27 = 011011
50
~
110010
NOT3~
3=
0000000000000011
NOT
equals
~
1111111111111100
-4
(two's complement
form)
NOT X can generally be calculated by the equation
NOT
X =
-(X+
1
).
Parentheses and Operator Precedence
When evaluating complex expressions, the C.ard
f~1I0WS
a predefined
set of priorities that
deter~ine
.th~
~equence
In
which operators are
evaluated. This can be
qUite
significant:
5 + 2
*
3 could be
5
+
2
=
7
or
2
*
3
=
6
7
*
3
=
21
6
+
5
=
11
The exact rules of "operator precedence" are given on page
28.
To avoid having to remember all these rules and to make your program
more precise, always use parentheses to
determ.i~e
the sequence of
evaluation. The above example is clarified by wntlng:
46
3.
PROGRAMMING
In
the previous chapter, we examined some of the concepts and terms
of the BASIC programming language.
In
this chapter, you will use
these elements to create programs. Let us remind you, however, that
this is not a manual on how to program in BASIC. What this chapter
will do is familiarize you with the use of BASIC on your Card.
Programs
A program consists of a set of instructions to the Card. It will perform
the exact operations that you specify. You, the programmer, are
responsible for issuing the correct instructions.
BASIC Statements
The Card interprets instructions according to a predetermined format.
This format
is
called a statement. You must always enter BASIC
statements
in
the same pattern. Statements must start with a line
number:
10: INPUT A
20: PRINT
A*A
30: END
Line Numbers
Each line of a program must have a unique line number -
any integer
between 1 and 65279. Line numbers are the reference for the Card.
They tell the Card the order in which to run the program, and can
be
used to tell the Card at which line to start. You need not enter lines
in
sequential order (although if you are a beginning programmer, it is
probably less confusing for you
to
do
so).
The computer
always
begins
execution with the lowest line number and moves sequentially through
the lines of program
in
ascending order.
47