Skip to content

Commit fa325b2

Browse files
committed
Slight modifications following full code review
1 parent 10ee76f commit fa325b2

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
lines changed

Expr.d

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,18 @@ class Dim2 : Expr {
120120
private Expr row, col;
121121
this(int i, Expr idx1, Expr idx2) {
122122
ident = i;
123-
row = idx1;
124-
col = idx2;
123+
left = new Node(idx1, idx2);
125124
}
126125
override void codegen() {
127-
row.codegen();
128-
writeln("\tvcvt.s32.f64\ts0, d", row.result);
126+
left.left.codegen();
127+
writeln("\tvcvt.s32.f64\ts0, d", (cast(Expr)(left.left)).result);
129128
writeln("\tvmov\tr0, s0");
130-
deallocateReg(row.result);
129+
deallocateReg((cast(Expr)(left.left)).result);
131130
writeln("\tpush\t{ r0 }");
132-
col.codegen();
133-
writeln("\tvcvt.s32.f64\ts0, d", col.result);
131+
left.right.codegen();
132+
writeln("\tvcvt.s32.f64\ts0, d", (cast(Expr)(left.right)).result);
134133
writeln("\tvmov\tr2, s0");
135-
setResult(col.result);
134+
setResult((cast(Expr)(left.right)).result);
136135
writeln("\tpop\t{ r1 }");
137136
writeln("\tadrl\tr0, ._size2", symtab.getId(ident));
138137
writeln("\tldr\tr3, [r0, #4]"); // sz2

Mat.d

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ class MatPrint : Node {
8686
this(int id, bool p = false) {
8787
ident = id;
8888
packed = p;
89-
//symtab.initializeMat(ident);
9089
type = symtab.getMatType(ident);
9190
if (type == 0) {
9291
symtab.error("NOT A MATRIX");

Node.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Node {
4848
writeln(".basic_end:");
4949
writeln("\tpop\t{ r0 }");
5050
writeln("\tcmn\tr0, #1");
51-
writeln("\tmovne\tr0, #1"); // error: end within GOSUB/FN
51+
writeln("\tmovne\tr0, #2"); // error: end within GOSUB/FN
5252
writeln("\tmovne\tr1, #", symtab.line & 0xff00);
5353
writeln("\torrne\tr1, r1, #", symtab.line & 0xff);
5454
writeln("\tblne\truntime_error(PLT)");

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
Modern implementation of the original Dartmouth BASIC compilers from the 1960s in the D programming language.
44

5-
This software is currently under a state of rapid development and should therefore be considered alpha quaality.
6-
7-
**Important Note**: The original version targeting 32-bit ARM is being moved to a separate branch (target-arm32), and it is unlikely much further work will be done. The focus of development is currently to support an LLVM target which will ultimately allow for compilation to native code (instead of ARM assembly language), as well as use of the LLVM optimizer.
5+
**Important Note**: This original version targeting 32-bit ARM is now in a separate branch (target-arm32), and it is unlikely much further work will be done. The focus of development for the main branch is currently to support an LLVM target which will ultimately allow for compilation to native code (instead of ARM assembly language), as well as use of the LLVM optimizer.
86

97
## Building
108

119
### Windows
1210

1311
**Prerequisites:**
1412

15-
* Bison parser generator `win_bison.exe` from https://github.com/lexxmark/winflexbison (to compile `grammar.y`). Note that a patch to the D skeleton file `d.m4` is currently required (see below); if running or patching WinFlexBison is not possible simply copy `Parser.d` out of the `autogen` directory.
13+
* Bison parser generator `win_bison.exe` from https://github.com/lexxmark/winflexbison (to compile `grammar.y`). Note that a patch to the D skeleton file `d.m4` is currently required (see below); if running or patching WinFlexBison is not possible simply copy `Parser.d` out of the `autogen` directory and remember to time-stamp it.
1614

1715
* Recent D compiler `dmd.exe`, tested with Digital Mars D (DMD) v2.098.1 from https://dlang.org/download.html#dmd
1816

@@ -38,7 +36,7 @@ This software is currently under a state of rapid development and should therefo
3836

3937
**Prerequisites:**
4038

41-
* Recent `bison` (ideally trunk from https://github.com/akimd/bison), versions available with a "testing" or rolling release distro (3.8.2.x or above) may work. Note that a patch to the D skeleton file `/usr/share/bison/skeletons/d.m4` is currently required (see below); if running or patching `bison` is not possible simply copy `Parser.d` out of the `autogen` directory.
39+
* Recent `bison` (ideally trunk from https://github.com/akimd/bison), versions available with a "testing" or rolling release distro (3.8.2 or above) may work. Note that a patch to the D skeleton file `/usr/share/bison/skeletons/d.m4` is currently required (see below); if running or patching `bison` is not possible simply copy `Parser.d` out of the `autogen` directory and `touch` it.
4240

4341
* Recent D compiler, tested with both GNU `gdc` and LLVM `ldc`
4442

@@ -90,7 +88,7 @@ The file `data\skeletons\d.m4` (WinFlexBison) or `/usr/share/bison/skeletons/d.m
9088

9189
### Windows
9290

93-
The executable `dbasic.exe` reads from standard input and writes to standard output, optionally with the required numerical Language Edition (only 1-3 currently supported).
91+
The executable `dbasic.exe` reads from standard input and writes to standard output, optionally with the required numerical Language Edition (only 1-4 currently supported).
9492

9593
The following command will compile the first example program `example-p12.bas` from the `examples` directory with First Edition compatibility, outputting the result to `test.s`:
9694

@@ -115,7 +113,7 @@ gcc -o test test.s basic_lib.s -lm
115113
./test
116114
```
117115

118-
### Linux (Debian/Ubuntu)
116+
### Linux (Debian/Ubuntu etc.)
119117

120118
To compile the assembly language output and support library, the ARM cross-compiler toolchain is required, including `arm-linux-gnueabihf-gcc`, from issuing `apt install gcc-arm-linux-gnueabihf libc-dev-armhf-cross`
121119

@@ -140,6 +138,12 @@ arm-linux-gnueabihf-gcc -o test test.s basic_lib.s -lm
140138
QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf qemu-arm ./test
141139
```
142140

141+
Alternatively use the executable shell script `run-linux.sh` to create and execute `a.out` with`qemu-arm`, eg:
142+
143+
```
144+
./runtime/run-linux.sh examples/example-p12.bas
145+
```
146+
143147
### Linux (Arch-based)
144148

145149
To compile the assembly language output and support library, the ARM cross-compiler toolchain is required, including `arm-none-linux-gnueabihf-gcc`, from AUR package `arm-none-linux-gnueabihf-toolchain-bin`
@@ -165,6 +169,12 @@ arm-none-linux-gnueabihf-gcc -o test test.s basic_lib.s -lm
165169
QEMU_LD_PREFIX=/usr/arm-none-linux-gnueabihf/libc qemu-arm ./test
166170
```
167171

172+
Alternatively use the executable shell script `run-arch.sh` to create and execute `a.out` with`qemu-arm`, eg:
173+
174+
```
175+
./runtime/run-arch.sh examples/example-p12.bas
176+
```
177+
168178
## Resources
169179

170180
Manual for the original 1964 Dartmouth BASIC: https://cs.bris.ac.uk/~dave/basic.pdf
@@ -193,6 +203,8 @@ Ultimately support for all of the early Dartmouth BASICs (First thru Sixth) is e
193203

194204
* 2023/07/01: Tag 0.40.3 (bug fixes and code improvements) Basic The Fourth update
195205

206+
* 2023/07/09: Tag 0.45.0 (bug fixes and code improvements) Basic The Fourth update **likely to be the final ARM release**
207+
196208
## Bugs
197209

198210
Please do report bugs, together with correct or incorrect BASIC input files. I would recommend testing against the latest release or master branch, even if an earlier BASIC Edition is being used, as bugs will have been fixed while new features are being added.

runtime/basic_lib.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#include <string.h>
55
#include <stdbool.h>
66

7-
#define TmpBufSz 16
7+
#define TmpBufSz 80
8+
#define MaxString 256
89

910
extern int basic_run();
1011

@@ -28,7 +29,7 @@ struct Data {
2829
};
2930

3031
unsigned pos = 0, vpos = 0;
31-
const unsigned PrintWidth = 75, Comma = 15, SemiColon = 3, MaxString = 255;
32+
const unsigned PrintWidth = 75, Comma = 15, SemiColon = 3;
3233

3334
void print_string(const char *s) {
3435
while (*s) {

0 commit comments

Comments
 (0)