@andrivet/z80-assembler 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +123 -0
- package/README.md +27 -53
- package/{libs/z80-assembler/src/index.ts → index.d.ts} +1 -1
- package/index.js +312 -0
- package/index.mjs +8573 -0
- package/{libs/z80-assembler/src/lib/compiler/Assets.ts → lib/compiler/Assets.d.ts} +1 -6
- package/lib/compiler/Ast.d.ts +221 -0
- package/lib/compiler/Compiler.d.ts +63 -0
- package/lib/compiler/Formatter.d.ts +23 -0
- package/lib/compiler/Generator.d.ts +40 -0
- package/lib/compiler/Labels.d.ts +47 -0
- package/lib/grammar/LowLevel.d.ts +70 -0
- package/lib/grammar/Parse.d.ts +42 -0
- package/lib/grammar/z80.d.ts +3994 -0
- package/lib/types/Error.d.ts +62 -0
- package/{libs/z80-assembler/src/lib/types/Types.ts → lib/types/Types.d.ts} +11 -26
- package/package.json +14 -52
- package/.editorconfig +0 -13
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -35
- package/.github/workflows/node.js.yml +0 -47
- package/.prettierignore +0 -3
- package/.prettierrc +0 -3
- package/.vscode/extensions.json +0 -7
- package/apps/.gitkeep +0 -0
- package/apps/z80-assembler-app/.eslintrc.json +0 -18
- package/apps/z80-assembler-app/index.html +0 -16
- package/apps/z80-assembler-app/postcss.config.js +0 -24
- package/apps/z80-assembler-app/project.json +0 -70
- package/apps/z80-assembler-app/public/favicon.ico +0 -0
- package/apps/z80-assembler-app/public/logo.png +0 -0
- package/apps/z80-assembler-app/public/logo192.png +0 -0
- package/apps/z80-assembler-app/public/logo512.png +0 -0
- package/apps/z80-assembler-app/public/manifest.json +0 -25
- package/apps/z80-assembler-app/public/robots.txt +0 -3
- package/apps/z80-assembler-app/src/app/app.module.css +0 -0
- package/apps/z80-assembler-app/src/app/app.tsx +0 -122
- package/apps/z80-assembler-app/src/app/binary.tsx +0 -39
- package/apps/z80-assembler-app/src/app/editor.tsx +0 -228
- package/apps/z80-assembler-app/src/app/errors.tsx +0 -31
- package/apps/z80-assembler-app/src/app/footer.tsx +0 -20
- package/apps/z80-assembler-app/src/app/header.tsx +0 -57
- package/apps/z80-assembler-app/src/app/misc.ts +0 -13
- package/apps/z80-assembler-app/src/app/opcodes.tsx +0 -335
- package/apps/z80-assembler-app/src/assets/.gitkeep +0 -0
- package/apps/z80-assembler-app/src/assets/images/logo192.png +0 -0
- package/apps/z80-assembler-app/src/main.tsx +0 -22
- package/apps/z80-assembler-app/src/styles.css +0 -8
- package/apps/z80-assembler-app/tailwind.config.js +0 -28
- package/apps/z80-assembler-app/tsconfig.app.json +0 -22
- package/apps/z80-assembler-app/tsconfig.json +0 -21
- package/apps/z80-assembler-app/tsconfig.spec.json +0 -23
- package/apps/z80-assembler-app/vite.config.ts +0 -64
- package/assets/images/compile.png +0 -0
- package/assets/images/logo.png +0 -0
- package/assets/images/menu.png +0 -0
- package/assets/images/opcodes-load8.png +0 -0
- package/assets/images/opcodes.png +0 -0
- package/assets/images/open-dir.png +0 -0
- package/assets/images/z80-assembler-app.png +0 -0
- package/docs/assembly.md +0 -551
- package/docs/images/ZX81-0x00.png +0 -0
- package/docs/images/ZX81-0x0B.png +0 -0
- package/docs/images/ZX81-0x0C.png +0 -0
- package/docs/images/ZX81-0x0D.png +0 -0
- package/docs/images/ZX81-0x0E.png +0 -0
- package/docs/images/ZX81-0x0F.png +0 -0
- package/docs/images/ZX81-0x10.png +0 -0
- package/docs/images/ZX81-0x11.png +0 -0
- package/docs/images/ZX81-0x12.png +0 -0
- package/docs/images/ZX81-0x13.png +0 -0
- package/docs/images/ZX81-0x14.png +0 -0
- package/docs/images/ZX81-0x15.png +0 -0
- package/docs/images/ZX81-0x16.png +0 -0
- package/docs/images/ZX81-0x17.png +0 -0
- package/docs/images/ZX81-0x18.png +0 -0
- package/docs/images/ZX81-0x19.png +0 -0
- package/docs/images/ZX81-0x1A.png +0 -0
- package/docs/images/ZX81-0x1B.png +0 -0
- package/docs/images/ZX81-0x1C.png +0 -0
- package/docs/images/ZX81-0x1D.png +0 -0
- package/docs/images/ZX81-0x1E.png +0 -0
- package/docs/images/ZX81-0x1F.png +0 -0
- package/docs/images/ZX81-0x20.png +0 -0
- package/docs/images/ZX81-0x21.png +0 -0
- package/docs/images/ZX81-0x22.png +0 -0
- package/docs/images/ZX81-0x23.png +0 -0
- package/docs/images/ZX81-0x24.png +0 -0
- package/docs/images/ZX81-0x25.png +0 -0
- package/docs/images/ZX81-0x26.png +0 -0
- package/docs/images/ZX81-0x27.png +0 -0
- package/docs/images/ZX81-0x28.png +0 -0
- package/docs/images/ZX81-0x29.png +0 -0
- package/docs/images/ZX81-0x2A.png +0 -0
- package/docs/images/ZX81-0x2B.png +0 -0
- package/docs/images/ZX81-0x2C.png +0 -0
- package/docs/images/ZX81-0x2D.png +0 -0
- package/docs/images/ZX81-0x2E.png +0 -0
- package/docs/images/ZX81-0x2F.png +0 -0
- package/docs/images/ZX81-0x30.png +0 -0
- package/docs/images/ZX81-0x31.png +0 -0
- package/docs/images/ZX81-0x32.png +0 -0
- package/docs/images/ZX81-0x33.png +0 -0
- package/docs/images/ZX81-0x34.png +0 -0
- package/docs/images/ZX81-0x35.png +0 -0
- package/docs/images/ZX81-0x36.png +0 -0
- package/docs/images/ZX81-0x37.png +0 -0
- package/docs/images/ZX81-0x38.png +0 -0
- package/docs/images/ZX81-0x39.png +0 -0
- package/docs/images/ZX81-0x3A.png +0 -0
- package/docs/images/ZX81-0x3B.png +0 -0
- package/docs/images/ZX81-0x3C.png +0 -0
- package/docs/images/ZX81-0x3D.png +0 -0
- package/docs/images/ZX81-0x3E.png +0 -0
- package/docs/images/ZX81-0x3F.png +0 -0
- package/docs/images/ZX81-0x80.png +0 -0
- package/docs/images/ZX81-0x8B.png +0 -0
- package/docs/images/ZX81-0x8C.png +0 -0
- package/docs/images/ZX81-0x8D.png +0 -0
- package/docs/images/ZX81-0x8E.png +0 -0
- package/docs/images/ZX81-0x8F.png +0 -0
- package/docs/images/ZX81-0x90.png +0 -0
- package/docs/images/ZX81-0x91.png +0 -0
- package/docs/images/ZX81-0x92.png +0 -0
- package/docs/images/ZX81-0x93.png +0 -0
- package/docs/images/ZX81-0x94.png +0 -0
- package/docs/images/ZX81-0x95.png +0 -0
- package/docs/images/ZX81-0x96.png +0 -0
- package/docs/images/ZX81-0x97.png +0 -0
- package/docs/images/ZX81-0x98.png +0 -0
- package/docs/images/ZX81-0x99.png +0 -0
- package/docs/images/ZX81-0x9A.png +0 -0
- package/docs/images/ZX81-0x9B.png +0 -0
- package/docs/images/ZX81-0x9C.png +0 -0
- package/docs/images/ZX81-0x9D.png +0 -0
- package/docs/images/ZX81-0x9E.png +0 -0
- package/docs/images/ZX81-0x9F.png +0 -0
- package/docs/images/ZX81-0xA0.png +0 -0
- package/docs/images/ZX81-0xA1.png +0 -0
- package/docs/images/ZX81-0xA2.png +0 -0
- package/docs/images/ZX81-0xA3.png +0 -0
- package/docs/images/ZX81-0xA4.png +0 -0
- package/docs/images/ZX81-0xA5.png +0 -0
- package/docs/images/ZX81-0xA6.png +0 -0
- package/docs/images/ZX81-0xA7.png +0 -0
- package/docs/images/ZX81-0xA8.png +0 -0
- package/docs/images/ZX81-0xA9.png +0 -0
- package/docs/images/ZX81-0xAA.png +0 -0
- package/docs/images/ZX81-0xAB.png +0 -0
- package/docs/images/ZX81-0xAC.png +0 -0
- package/docs/images/ZX81-0xAD.png +0 -0
- package/docs/images/ZX81-0xAE.png +0 -0
- package/docs/images/ZX81-0xAF.png +0 -0
- package/docs/images/ZX81-0xB0.png +0 -0
- package/docs/images/ZX81-0xB1.png +0 -0
- package/docs/images/ZX81-0xB2.png +0 -0
- package/docs/images/ZX81-0xB3.png +0 -0
- package/docs/images/ZX81-0xB4.png +0 -0
- package/docs/images/ZX81-0xB5.png +0 -0
- package/docs/images/ZX81-0xB6.png +0 -0
- package/docs/images/ZX81-0xB7.png +0 -0
- package/docs/images/ZX81-0xB8.png +0 -0
- package/docs/images/ZX81-0xB9.png +0 -0
- package/docs/images/ZX81-0xBA.png +0 -0
- package/docs/images/ZX81-0xBB.png +0 -0
- package/docs/images/ZX81-0xBC.png +0 -0
- package/docs/images/ZX81-0xBD.png +0 -0
- package/docs/images/ZX81-0xBE.png +0 -0
- package/docs/images/ZX81-0xBF.png +0 -0
- package/libs/.gitkeep +0 -0
- package/libs/z80-assembler/.eslintrc.json +0 -18
- package/libs/z80-assembler/package.json +0 -20
- package/libs/z80-assembler/project.json +0 -35
- package/libs/z80-assembler/public/CHANGELOG.md +0 -35
- package/libs/z80-assembler/public/README.md +0 -54
- package/libs/z80-assembler/src/lib/assets/code/basic-end.zx81 +0 -4
- package/libs/z80-assembler/src/lib/assets/code/basic-line1.zx81 +0 -4
- package/libs/z80-assembler/src/lib/assets/code/basic-line2.zx81 +0 -9
- package/libs/z80-assembler/src/lib/assets/code/characters.zx81 +0 -190
- package/libs/z80-assembler/src/lib/assets/code/display.zx81 +0 -50
- package/libs/z80-assembler/src/lib/assets/code/system-variables.zx81 +0 -46
- package/libs/z80-assembler/src/lib/compiler/Ast.ts +0 -545
- package/libs/z80-assembler/src/lib/compiler/Compiler.test.ts +0 -2141
- package/libs/z80-assembler/src/lib/compiler/Compiler.ts +0 -185
- package/libs/z80-assembler/src/lib/compiler/Formatter.ts +0 -43
- package/libs/z80-assembler/src/lib/compiler/Generator.ts +0 -255
- package/libs/z80-assembler/src/lib/compiler/Labels.ts +0 -165
- package/libs/z80-assembler/src/lib/grammar/LowLevel.ts +0 -163
- package/libs/z80-assembler/src/lib/grammar/Parse.ts +0 -128
- package/libs/z80-assembler/src/lib/grammar/z80.peg +0 -1252
- package/libs/z80-assembler/src/lib/grammar/z80.ts +0 -10649
- package/libs/z80-assembler/src/lib/types/Error.ts +0 -105
- package/libs/z80-assembler/tsconfig.json +0 -23
- package/libs/z80-assembler/tsconfig.lib.json +0 -10
- package/libs/z80-assembler/tsconfig.spec.json +0 -19
- package/libs/z80-assembler/vite.config.ts +0 -58
- package/nx.json +0 -57
- package/tsconfig.base.json +0 -22
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.0.0 - December 29, 2025
|
|
4
|
+
|
|
5
|
+
* Fix propagation or source file name in case of compilation error.
|
|
6
|
+
* Allowed device names are now:
|
|
7
|
+
- zx81: automatic generation of system variables, BASIC REM lines, etc. for the ZX81
|
|
8
|
+
- zx81-raw: without automatic generation of code but with translation for the ZX81 (characters)
|
|
9
|
+
- z80: Generic Z80 code without any generation or translation specific to the ZX81. Characters are treated as ASCII (i.e. they are not translated).
|
|
10
|
+
* Strings are translated only for zx81 or zx81raw devices, not z80.
|
|
11
|
+
* Add undocumented instructions
|
|
12
|
+
- Add support for IXh, IXl, IYh, IYl 8 bits registers
|
|
13
|
+
- Add support of these registers for ADC, ADD, AND, CP, DEC, INC, OR, SBC, SUB and XOR
|
|
14
|
+
- Add support of these registers for LD
|
|
15
|
+
- Add support of (IX+d), (IY+d) to RL, RLC, RR, RRC, SLA, SRA, SRL
|
|
16
|
+
- Add new instruction SSL
|
|
17
|
+
- Add IN F, (C)
|
|
18
|
+
- Add OUT (C), 0
|
|
19
|
+
* Add fake instructions
|
|
20
|
+
- 16-bit rotate and shift
|
|
21
|
+
* rl qq
|
|
22
|
+
* rr qq
|
|
23
|
+
* sla qq
|
|
24
|
+
* sll qq, sli qq
|
|
25
|
+
* sra qq
|
|
26
|
+
* srl qq
|
|
27
|
+
- 16-bit load
|
|
28
|
+
* ld qq, qq
|
|
29
|
+
* ld qq, ix
|
|
30
|
+
* ld qq, iy
|
|
31
|
+
* ld qq, (hl)
|
|
32
|
+
* ld qq, (ix + nn)
|
|
33
|
+
* ld qq, (iy + nn)
|
|
34
|
+
* ld ix, qq
|
|
35
|
+
* ld iy, qq
|
|
36
|
+
* ld iy, ix
|
|
37
|
+
* ld ix, iy
|
|
38
|
+
* ld (hl), qq
|
|
39
|
+
* ld (ix + nn), qq
|
|
40
|
+
* ld (iy + nn), qq
|
|
41
|
+
- 16-bit load, increment
|
|
42
|
+
* ldi qq, (hl)
|
|
43
|
+
* ldi qq, (ix + nn)
|
|
44
|
+
* ldi qq, (iy + nn)
|
|
45
|
+
* ldi (hl), qq
|
|
46
|
+
* ldi (ix + nn), qq
|
|
47
|
+
* ldi (iy + nn), qq
|
|
48
|
+
- 8-bit load, increment
|
|
49
|
+
* ldi a, (bc)
|
|
50
|
+
* ldi a, (de)
|
|
51
|
+
* ldi r, (hl)
|
|
52
|
+
* ldi r, (ix + nn)
|
|
53
|
+
* ldi r, (iy + nn)
|
|
54
|
+
* ldi (bc), a
|
|
55
|
+
* ldi (de), a
|
|
56
|
+
* ldi (hl), r
|
|
57
|
+
* ldi (ix + nn), r
|
|
58
|
+
* ldi (iy + nn), r
|
|
59
|
+
* ldi (hl), n
|
|
60
|
+
* ldi (ix + nn), n
|
|
61
|
+
* ldi (iy + nn), n
|
|
62
|
+
- 8-bit load, decrement
|
|
63
|
+
* ldd a, (bc)
|
|
64
|
+
* ldd a, (de)
|
|
65
|
+
* ldd r, (hl)
|
|
66
|
+
* ldd r, (ix + nn)
|
|
67
|
+
* ldd r, (iy + nn)
|
|
68
|
+
* ldd (bc), a
|
|
69
|
+
* ldd (de), a
|
|
70
|
+
* ldd (hl), r
|
|
71
|
+
* ldd (ix + nn), r
|
|
72
|
+
* ldd (iy + nn), r
|
|
73
|
+
* ldd (hl), n
|
|
74
|
+
* ldd (ix + nn), n
|
|
75
|
+
* ldd (iy + nn), n
|
|
76
|
+
- 16-bit arithmetic
|
|
77
|
+
* adc de, ss
|
|
78
|
+
* add de, ss
|
|
79
|
+
* sbc de, ss
|
|
80
|
+
* sub de, ss
|
|
81
|
+
* sub hl, ss
|
|
82
|
+
|
|
83
|
+
## 1.4.1 - December 22, 2025
|
|
84
|
+
|
|
85
|
+
* Fix wrong publication
|
|
86
|
+
|
|
87
|
+
## 1.4.0 - December 22, 2025
|
|
88
|
+
|
|
89
|
+
* Fix #8: 'Invalid ZX81 character' when using '9', 'Z' or 'z' in a string.
|
|
90
|
+
|
|
91
|
+
## 1.3.2 - November 20, 2024
|
|
92
|
+
|
|
93
|
+
* Fix bugs introduced in commit 4bcb12ea82d38f83ce2079f8635909d0c5b5c57a
|
|
94
|
+
* Add more compilation tests
|
|
95
|
+
|
|
96
|
+
## 1.3.1 - November 20, 2024
|
|
97
|
+
|
|
98
|
+
* Remove french comments
|
|
99
|
+
* Fix issue #6 Labels are not generated in SLD when alone on a line
|
|
100
|
+
|
|
101
|
+
## 1.3.0 - June 28, 2023
|
|
102
|
+
|
|
103
|
+
* **1** - Allow (IX) and (IY) without an explicit offset.
|
|
104
|
+
* **2** - Define the pseudo value $ for PC.
|
|
105
|
+
* **3** - Be more specific when an expression can't be evaluated.
|
|
106
|
+
* **5** - Recursive labels are now properly detected (max 20 recursions).
|
|
107
|
+
|
|
108
|
+
## 1.2.0 - June 20, 2023
|
|
109
|
+
|
|
110
|
+
* Solve issue with expression starting with an open parenthesis
|
|
111
|
+
* More comment (english and french)
|
|
112
|
+
|
|
113
|
+
## 1.1.0 - June 13, 2023
|
|
114
|
+
|
|
115
|
+
* Add special handling of ZX81 device
|
|
116
|
+
* Only allow ZX81 string (ASCII string do not make sense)
|
|
117
|
+
* Publication on GitHub Pages using GitHub Actions
|
|
118
|
+
|
|
119
|
+
## 1.0.0 - June 5, 2023
|
|
120
|
+
|
|
121
|
+
* First public version
|
|
122
|
+
|
|
123
|
+
|
package/README.md
CHANGED
|
@@ -1,79 +1,53 @@
|
|
|
1
1
|
# z80-assembler
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Z80 assembler library entirely written in Typescript and derived from a PEG grammar.
|
|
4
|
+
It optimized for the old ZX81 computer but can also be used with any other Z80 targets.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
## Demo application
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
A demo application is available: https://andrivet.github.io/z80-assembler/.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
* The second component is an application, `z80-assembler-app` that uses this library.
|
|
11
|
-
It can be used by itself or as an example of how to use the library. It is written in Typescript with React.
|
|
10
|
+
## Quick guide to use the library
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
This assembler is also used in the [ZX81 Debugger](https://github.com/andrivet/ZX81-Debugger).
|
|
16
|
-
|
|
17
|
-
## How to build from source
|
|
12
|
+
To install the library:
|
|
18
13
|
|
|
19
14
|
```
|
|
20
|
-
npm
|
|
21
|
-
./node_modules/.bin/nx run z80-assembler-app:build:production
|
|
15
|
+
$ npm install @andrivet/z80-assembler
|
|
22
16
|
```
|
|
23
17
|
|
|
24
|
-
|
|
18
|
+
The main function is simply called `compile`. It takes three arguments:
|
|
25
19
|
|
|
26
|
-
*
|
|
27
|
-
|
|
20
|
+
* the name of the source file
|
|
21
|
+
* the Z80 source code to compile
|
|
22
|
+
* a function used to return the content of included files
|
|
28
23
|
|
|
29
|
-
|
|
24
|
+
It returns an object of type `CompilationInfo` with the following fields:
|
|
30
25
|
|
|
31
|
-
|
|
26
|
+
* `outputName`: The name of the output as set by the `output` directive.
|
|
27
|
+
* `bytes`: A array of numbers. Each element represents a byte of the generated machine code.
|
|
28
|
+
* `sld`: The Source Level Debugging data as a string. This is used in order to debug the code.
|
|
29
|
+
* `errs`: An array of errors
|
|
30
|
+
|
|
31
|
+
A typical way to use the function is:
|
|
32
32
|
|
|
33
33
|
```
|
|
34
|
-
|
|
34
|
+
const info = compile(filepath, code, handleGetFileCode);
|
|
35
|
+
if(info.errs.length > 0)
|
|
36
|
+
displayErrors(info.errs);
|
|
37
|
+
else
|
|
38
|
+
saveOutput(info.outputName, info.bytes);
|
|
35
39
|
```
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## Quick guide to use the application
|
|
41
|
-
|
|
42
|
-
Under the **File** menu, you find the following commands:
|
|
43
|
-
|
|
44
|
-

|
|
45
|
-
|
|
46
|
-
* **Open Code**: Open a Z80 source file.
|
|
47
|
-
* **Open Code Directory**: Open a directory with Z80 source files. This is especially useful if your source files contain includes.
|
|
48
|
-
* **Save Code**: Save the current code file.
|
|
49
|
-
* **Save Binary**: Save the compiled binary.
|
|
50
|
-
* **Save SLD File**: Save the Source Level Debugging data in text format.
|
|
51
|
-
* **Close Code**: Close the current code.
|
|
52
|
-
* **Close All**: Close all the open codes.
|
|
53
|
-
|
|
54
|
-

|
|
55
|
-
|
|
56
|
-
Once one or more files are open, click on Compile to compile the code.
|
|
57
|
-
The binary are displayed on the right side:
|
|
58
|
-
|
|
59
|
-

|
|
60
|
-
|
|
61
|
-
While writing your Z80 assembly code, you can display the list of Z80 opcodes by clicking on **Z80 Opcodes**:
|
|
62
|
-
|
|
63
|
-

|
|
64
|
-
|
|
65
|
-
Click on a category to see the corresponding opcodes:
|
|
66
|
-
|
|
67
|
-

|
|
41
|
+
You can find a complete example in the [demo application](https://github.com/andrivet/z80-assembler/), in particular in the `app.tsx` file.
|
|
68
42
|
|
|
69
|
-
## Z80 assembly
|
|
70
43
|
|
|
71
|
-
|
|
44
|
+
## Source code
|
|
72
45
|
|
|
46
|
+
The source code is published on GitHub: https://github.com/andrivet/z80-assembler/.
|
|
73
47
|
|
|
74
48
|
## Licence
|
|
75
49
|
|
|
76
|
-
This library and application are released under GPLv3.
|
|
50
|
+
This library and associated application are released under GPLv3.
|
|
77
51
|
|
|
78
52
|
## Copyrights
|
|
79
53
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* License: GPLv3
|
|
8
8
|
* Copyrights: Copyright (C) 2023 Sebastien Andrivet
|
|
9
9
|
*/
|
|
10
|
-
export * from './lib/types/Types'
|
|
10
|
+
export * from './lib/types/Types';
|
|
11
11
|
export * from './lib/types/Error';
|
|
12
12
|
export * from './lib/compiler/Compiler';
|
|
13
13
|
export * from './lib/compiler/Generator';
|