Skip to content

Commit 5844759

Browse files
authored
Merge pull request #458 from boriel/docs
Docs
2 parents bd761ad + 73b2ed8 commit 5844759

6 files changed

Lines changed: 129 additions & 146 deletions

File tree

docs/architectures/bitwiselogic.md

Lines changed: 0 additions & 118 deletions
This file was deleted.

docs/bitwiselogic.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#Bitwise Operators
2+
3+
ZX Basic allows Bit Manipulation (bitwise), on every integer type (from 8 to 32 bits).
4+
5+
| **BITWISE OPERATORS** |
6+
|: ---------------------------- :|
7+
| bAND |
8+
| bOR |
9+
| bNOT |
10+
| bXOR |
11+
12+
Except bNOT, all the others require two integral (Byte, Ubyte, Integer, UInteger, Long, ULong) operands.
13+
The operation will be applied bit by bit.
14+
15+
---
16+
##bAND
17+
18+
Performs the _Bitwise Conjunction_ and returns 1 for every bit if and only if both bits are 1.
19+
20+
| a | b | result |
21+
|:----:|:----:|:------:|
22+
| 0 | 0 | 0 |
23+
| 0 | 1 | 0 |
24+
| 1 | 0 | 0 |
25+
| 1 | 1 | 1 |
26+
27+
###Example
28+
29+
Binary "mask" that will get only the 4 rightmost bits 0 1 2 3 of a number:
30+
31+
`PRINT BIN 01110111 bAND BIN 00001111` will print 3, which is 0111`
32+
33+
---
34+
35+
## bOR
36+
37+
Performs the _Bitwise Disjunction_ and returns 1 if any of the arguments is 1.
38+
39+
| a | b | result |
40+
|:----:|:----:|:------:|
41+
| 0 | 0 | 0 |
42+
| 0 | 1 | 1 |
43+
| 1 | 0 | 1 |
44+
| 1 | 1 | 1 |
45+
46+
###Example
47+
48+
Ensure an ASCII letter is always in lowercase:
49+
50+
`PRINT CHR$(CODE "A" OR BIN 10000)` will print `a` because lowercase letters have bit 5 set.
51+
52+
---
53+
54+
## bNOT
55+
56+
Performs the _Bitwise Negation_ and returns _1_ if the arguments is _0_ and vice versa.
57+
Basically it flips all the bits in an integer number.
58+
59+
| a |result |
60+
|:----:|:------:|
61+
| 0 | 1 |
62+
| 1 | 0 |
63+
64+
65+
###Example
66+
67+
Invert the first cell (upper-leftmost) in the screen:
68+
69+
```
70+
PRINT AT 0, 0; "A";
71+
FOR i = 0 TO 3
72+
POKE 16384 + 256 * i, bNOT PEEK(16384 + 256 * i)
73+
NEXT
74+
```
75+
---
76+
77+
#bXOR
78+
79+
Performs a logical XOR and returns 1 if one and only one of the arguments is 1, 0 if both bits are the same.
80+
In essence, returns 1 ONLY if one of the arguments is 1.
81+
82+
| a | b | result |
83+
|:----:|:----:|:------:|
84+
| 0 | 0 | 0 |
85+
| 0 | 1 | 1 |
86+
| 1 | 0 | 1 |
87+
| 1 | 1 | 0 |
88+
---
89+
90+
###Example
91+
92+
Flips an ASCII letter from lower to uppercase and vice versa
93+
94+
`PRINT CHR$(CODE "A" bXOR BIN 10000)`

docs/byref.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ and no access is specified, it's supposed to be `ByRef` (arrays cannot be passed
2626
ByRef allows us to pass arrays to [FUNCTION](function.md) or [SUB](sub.md):
2727

2828
```
29-
REM arrays passed to functions can be of *any dimensions*. Use LBOUND and UBOUND to detect dimensions!
29+
REM arrays passed to functions can be of *any dimensions*.
30+
REM Use LBOUND and UBOUND to detect dimensions!
31+
3032
FUNCTION maxValue(ByRef a() as Ubyte) As UByte
3133
DIM i as UInteger
3234
DIM result As UByte = 0
@@ -40,8 +42,8 @@ DIM myArray(4) As UByte = {4, 3, 1, 2, 5}
4042
PRINT "Max value is "; maxValue(myArray)
4143
```
4244

43-
In this example, is `ByRef` was omitted, it will be used by default, since the parameter was an array.
44-
Arrays cannot be passed [ByVAL](byval.md).
45+
When passing arrays like in this example, if `ByRef` can be omitted.
46+
Arrays parameters cannot be passed to a function using [ByVAL](byval.md).
4547

4648
`ByRef` is also useful to return values in the parameters. [RETURN](return.md) allows to return a single value
4749
from a [FUNCTION](function.md), but we can return several values by storing the result in those parameters.

docs/chr.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ In fact, if the compiler detects the programmer is using `CHR(x) + CHR(y)`, it m
5151

5252
##See Also
5353

54+
* [CODE](code.md)
5455
* [STR](str.md)
56+
* [VAL](val.md)

docs/installation.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
11
#Installation
22

33
##Installation of ZX Basic SDK
4-
ZX Basic SDK comes in two flavours:
4+
ZX Basic SDK comes two several flavours:
55

6-
* Multiplatform (Linux / Windows / Mac) python scripts. This is the main distribution and recommended for everyone.
7-
* Windows .MSI Installer.
8-
9-
The latest is only for Windows users who are not able or very lazy to use python scripts directly. This .MSI distribution is not updated as often as the Multiplatform one, but has the advantage of not requiring to have the python interpreter previously installed.
6+
* OS Specific binary package (the recommended way).<br />
7+
For Windows, Mac OS and Linux
8+
* Multiplatform python scripts (will require Python 3.8+ to be installed in your system)
109

1110
###Prerequisites
12-
For the _Multi-platform_ bundle, you will need the [python](http://www.python.org) interpreter **version 3.5** or
13-
higher installed on your system (Linux and Mac OS X users will probably have it already installed since
14-
it is very common on those operating systems).
15-
For Windows users, there's also a python interpreter from [ActiveState](http://www.activestate.com),
16-
the [ActivePython](http://www.activestate.com/store/download.aspx?prdGUID=b08b04e0-6872-4d9d-a722-7a0c2dea2758)
17-
interpreter, 100% python compatible (Windows users who choose the .ZIP package distribution does not need to install
18-
any python interpreter).
11+
For the _Multi-platform_ bundle, you will need a [python](http://www.python.org) interpreter **version 3.8** or
12+
higher installed in your system (Linux and Mac OS X users will probably have it already).
1913

2014
###Downloading
21-
To get the latest version of the ZX BASIC SDK, go to the [Download Page](http://www.boriel.com/files/zxb/),
22-
and get the `tar.gz` or `.ZIP` file you want. The .ZIP files are _Multiplatform_ (Linux / Windows / Mac), except those
23-
with the `win32` suffix, which are for Windows only.
24-
25-
###Installing
26-
Installing the .MSI distribution is pretty straightforward:
27-
They **do not require any installation**. Just uncompress the SDK tree in a directory of your choice and make sure
28-
that folder is included in your PATH environment variable.
15+
To get the latest version of the ZX BASIC SDK, head to [Download Page](https://zxbasic.readthedocs.io/en/docs/archive/),
16+
and get the file you want.
2917

18+
###Installation
19+
Installation is pretty straightforward: Just uncompress the SDK tree in a directory of your choice and make sure
20+
the folder is included in your PATH environment variable.
3021

3122
##Testing your installation
32-
For the .ZIP distribution, type **zxb.py** (in windows you can type **zxb**).
23+
For the binary distribution type **zxbc** (ensure this file is in your PATH).
3324
You should see something like:
3425
```
35-
>zxb.py
36-
Usage: zxb.py <input file> [options]
26+
>zxbc
27+
Usage: zxbc <input file> [options]
3728
38-
zxb.py: error: missing input file. (Try -h)
29+
zxbc: error: missing input file. (Try -h)
30+
```
31+
32+
For the python distribution type **zxbc.py** (in windows you can type **zxbc**).
33+
You should see something like:
3934
```
35+
>zxbc.py
36+
Usage: zxbc.py <input file> [options]
37+
38+
zxbc.py: error: missing input file. (Try -h)
39+
```
40+
4041
Ok, the compiler is working (or it seems so). Now you should proceed to the following section to learn about its usage.
42+

docs/operators.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#Operators
22

3-
Operators in ZX Basic ranges from arithmetical and logical to bitwise ones.
3+
Operators in ZX Basic can be arithmetical, logical and [bitwise](bitwiselogic.md) ones.
4+
For bitwise operators checks the [Bitwise Operators](bitwiselogic.md) page.
45

56
## Arithmetic Operators
67

0 commit comments

Comments
 (0)