@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.
Files changed (198) hide show
  1. package/CHANGELOG.md +123 -0
  2. package/README.md +27 -53
  3. package/{libs/z80-assembler/src/index.ts → index.d.ts} +1 -1
  4. package/index.js +312 -0
  5. package/index.mjs +8573 -0
  6. package/{libs/z80-assembler/src/lib/compiler/Assets.ts → lib/compiler/Assets.d.ts} +1 -6
  7. package/lib/compiler/Ast.d.ts +221 -0
  8. package/lib/compiler/Compiler.d.ts +63 -0
  9. package/lib/compiler/Formatter.d.ts +23 -0
  10. package/lib/compiler/Generator.d.ts +40 -0
  11. package/lib/compiler/Labels.d.ts +47 -0
  12. package/lib/grammar/LowLevel.d.ts +70 -0
  13. package/lib/grammar/Parse.d.ts +42 -0
  14. package/lib/grammar/z80.d.ts +3994 -0
  15. package/lib/types/Error.d.ts +62 -0
  16. package/{libs/z80-assembler/src/lib/types/Types.ts → lib/types/Types.d.ts} +11 -26
  17. package/package.json +14 -52
  18. package/.editorconfig +0 -13
  19. package/.eslintignore +0 -3
  20. package/.eslintrc.json +0 -35
  21. package/.github/workflows/node.js.yml +0 -47
  22. package/.prettierignore +0 -3
  23. package/.prettierrc +0 -3
  24. package/.vscode/extensions.json +0 -7
  25. package/apps/.gitkeep +0 -0
  26. package/apps/z80-assembler-app/.eslintrc.json +0 -18
  27. package/apps/z80-assembler-app/index.html +0 -16
  28. package/apps/z80-assembler-app/postcss.config.js +0 -24
  29. package/apps/z80-assembler-app/project.json +0 -70
  30. package/apps/z80-assembler-app/public/favicon.ico +0 -0
  31. package/apps/z80-assembler-app/public/logo.png +0 -0
  32. package/apps/z80-assembler-app/public/logo192.png +0 -0
  33. package/apps/z80-assembler-app/public/logo512.png +0 -0
  34. package/apps/z80-assembler-app/public/manifest.json +0 -25
  35. package/apps/z80-assembler-app/public/robots.txt +0 -3
  36. package/apps/z80-assembler-app/src/app/app.module.css +0 -0
  37. package/apps/z80-assembler-app/src/app/app.tsx +0 -122
  38. package/apps/z80-assembler-app/src/app/binary.tsx +0 -39
  39. package/apps/z80-assembler-app/src/app/editor.tsx +0 -228
  40. package/apps/z80-assembler-app/src/app/errors.tsx +0 -31
  41. package/apps/z80-assembler-app/src/app/footer.tsx +0 -20
  42. package/apps/z80-assembler-app/src/app/header.tsx +0 -57
  43. package/apps/z80-assembler-app/src/app/misc.ts +0 -13
  44. package/apps/z80-assembler-app/src/app/opcodes.tsx +0 -335
  45. package/apps/z80-assembler-app/src/assets/.gitkeep +0 -0
  46. package/apps/z80-assembler-app/src/assets/images/logo192.png +0 -0
  47. package/apps/z80-assembler-app/src/main.tsx +0 -22
  48. package/apps/z80-assembler-app/src/styles.css +0 -8
  49. package/apps/z80-assembler-app/tailwind.config.js +0 -28
  50. package/apps/z80-assembler-app/tsconfig.app.json +0 -22
  51. package/apps/z80-assembler-app/tsconfig.json +0 -21
  52. package/apps/z80-assembler-app/tsconfig.spec.json +0 -23
  53. package/apps/z80-assembler-app/vite.config.ts +0 -64
  54. package/assets/images/compile.png +0 -0
  55. package/assets/images/logo.png +0 -0
  56. package/assets/images/menu.png +0 -0
  57. package/assets/images/opcodes-load8.png +0 -0
  58. package/assets/images/opcodes.png +0 -0
  59. package/assets/images/open-dir.png +0 -0
  60. package/assets/images/z80-assembler-app.png +0 -0
  61. package/docs/assembly.md +0 -551
  62. package/docs/images/ZX81-0x00.png +0 -0
  63. package/docs/images/ZX81-0x0B.png +0 -0
  64. package/docs/images/ZX81-0x0C.png +0 -0
  65. package/docs/images/ZX81-0x0D.png +0 -0
  66. package/docs/images/ZX81-0x0E.png +0 -0
  67. package/docs/images/ZX81-0x0F.png +0 -0
  68. package/docs/images/ZX81-0x10.png +0 -0
  69. package/docs/images/ZX81-0x11.png +0 -0
  70. package/docs/images/ZX81-0x12.png +0 -0
  71. package/docs/images/ZX81-0x13.png +0 -0
  72. package/docs/images/ZX81-0x14.png +0 -0
  73. package/docs/images/ZX81-0x15.png +0 -0
  74. package/docs/images/ZX81-0x16.png +0 -0
  75. package/docs/images/ZX81-0x17.png +0 -0
  76. package/docs/images/ZX81-0x18.png +0 -0
  77. package/docs/images/ZX81-0x19.png +0 -0
  78. package/docs/images/ZX81-0x1A.png +0 -0
  79. package/docs/images/ZX81-0x1B.png +0 -0
  80. package/docs/images/ZX81-0x1C.png +0 -0
  81. package/docs/images/ZX81-0x1D.png +0 -0
  82. package/docs/images/ZX81-0x1E.png +0 -0
  83. package/docs/images/ZX81-0x1F.png +0 -0
  84. package/docs/images/ZX81-0x20.png +0 -0
  85. package/docs/images/ZX81-0x21.png +0 -0
  86. package/docs/images/ZX81-0x22.png +0 -0
  87. package/docs/images/ZX81-0x23.png +0 -0
  88. package/docs/images/ZX81-0x24.png +0 -0
  89. package/docs/images/ZX81-0x25.png +0 -0
  90. package/docs/images/ZX81-0x26.png +0 -0
  91. package/docs/images/ZX81-0x27.png +0 -0
  92. package/docs/images/ZX81-0x28.png +0 -0
  93. package/docs/images/ZX81-0x29.png +0 -0
  94. package/docs/images/ZX81-0x2A.png +0 -0
  95. package/docs/images/ZX81-0x2B.png +0 -0
  96. package/docs/images/ZX81-0x2C.png +0 -0
  97. package/docs/images/ZX81-0x2D.png +0 -0
  98. package/docs/images/ZX81-0x2E.png +0 -0
  99. package/docs/images/ZX81-0x2F.png +0 -0
  100. package/docs/images/ZX81-0x30.png +0 -0
  101. package/docs/images/ZX81-0x31.png +0 -0
  102. package/docs/images/ZX81-0x32.png +0 -0
  103. package/docs/images/ZX81-0x33.png +0 -0
  104. package/docs/images/ZX81-0x34.png +0 -0
  105. package/docs/images/ZX81-0x35.png +0 -0
  106. package/docs/images/ZX81-0x36.png +0 -0
  107. package/docs/images/ZX81-0x37.png +0 -0
  108. package/docs/images/ZX81-0x38.png +0 -0
  109. package/docs/images/ZX81-0x39.png +0 -0
  110. package/docs/images/ZX81-0x3A.png +0 -0
  111. package/docs/images/ZX81-0x3B.png +0 -0
  112. package/docs/images/ZX81-0x3C.png +0 -0
  113. package/docs/images/ZX81-0x3D.png +0 -0
  114. package/docs/images/ZX81-0x3E.png +0 -0
  115. package/docs/images/ZX81-0x3F.png +0 -0
  116. package/docs/images/ZX81-0x80.png +0 -0
  117. package/docs/images/ZX81-0x8B.png +0 -0
  118. package/docs/images/ZX81-0x8C.png +0 -0
  119. package/docs/images/ZX81-0x8D.png +0 -0
  120. package/docs/images/ZX81-0x8E.png +0 -0
  121. package/docs/images/ZX81-0x8F.png +0 -0
  122. package/docs/images/ZX81-0x90.png +0 -0
  123. package/docs/images/ZX81-0x91.png +0 -0
  124. package/docs/images/ZX81-0x92.png +0 -0
  125. package/docs/images/ZX81-0x93.png +0 -0
  126. package/docs/images/ZX81-0x94.png +0 -0
  127. package/docs/images/ZX81-0x95.png +0 -0
  128. package/docs/images/ZX81-0x96.png +0 -0
  129. package/docs/images/ZX81-0x97.png +0 -0
  130. package/docs/images/ZX81-0x98.png +0 -0
  131. package/docs/images/ZX81-0x99.png +0 -0
  132. package/docs/images/ZX81-0x9A.png +0 -0
  133. package/docs/images/ZX81-0x9B.png +0 -0
  134. package/docs/images/ZX81-0x9C.png +0 -0
  135. package/docs/images/ZX81-0x9D.png +0 -0
  136. package/docs/images/ZX81-0x9E.png +0 -0
  137. package/docs/images/ZX81-0x9F.png +0 -0
  138. package/docs/images/ZX81-0xA0.png +0 -0
  139. package/docs/images/ZX81-0xA1.png +0 -0
  140. package/docs/images/ZX81-0xA2.png +0 -0
  141. package/docs/images/ZX81-0xA3.png +0 -0
  142. package/docs/images/ZX81-0xA4.png +0 -0
  143. package/docs/images/ZX81-0xA5.png +0 -0
  144. package/docs/images/ZX81-0xA6.png +0 -0
  145. package/docs/images/ZX81-0xA7.png +0 -0
  146. package/docs/images/ZX81-0xA8.png +0 -0
  147. package/docs/images/ZX81-0xA9.png +0 -0
  148. package/docs/images/ZX81-0xAA.png +0 -0
  149. package/docs/images/ZX81-0xAB.png +0 -0
  150. package/docs/images/ZX81-0xAC.png +0 -0
  151. package/docs/images/ZX81-0xAD.png +0 -0
  152. package/docs/images/ZX81-0xAE.png +0 -0
  153. package/docs/images/ZX81-0xAF.png +0 -0
  154. package/docs/images/ZX81-0xB0.png +0 -0
  155. package/docs/images/ZX81-0xB1.png +0 -0
  156. package/docs/images/ZX81-0xB2.png +0 -0
  157. package/docs/images/ZX81-0xB3.png +0 -0
  158. package/docs/images/ZX81-0xB4.png +0 -0
  159. package/docs/images/ZX81-0xB5.png +0 -0
  160. package/docs/images/ZX81-0xB6.png +0 -0
  161. package/docs/images/ZX81-0xB7.png +0 -0
  162. package/docs/images/ZX81-0xB8.png +0 -0
  163. package/docs/images/ZX81-0xB9.png +0 -0
  164. package/docs/images/ZX81-0xBA.png +0 -0
  165. package/docs/images/ZX81-0xBB.png +0 -0
  166. package/docs/images/ZX81-0xBC.png +0 -0
  167. package/docs/images/ZX81-0xBD.png +0 -0
  168. package/docs/images/ZX81-0xBE.png +0 -0
  169. package/docs/images/ZX81-0xBF.png +0 -0
  170. package/libs/.gitkeep +0 -0
  171. package/libs/z80-assembler/.eslintrc.json +0 -18
  172. package/libs/z80-assembler/package.json +0 -20
  173. package/libs/z80-assembler/project.json +0 -35
  174. package/libs/z80-assembler/public/CHANGELOG.md +0 -35
  175. package/libs/z80-assembler/public/README.md +0 -54
  176. package/libs/z80-assembler/src/lib/assets/code/basic-end.zx81 +0 -4
  177. package/libs/z80-assembler/src/lib/assets/code/basic-line1.zx81 +0 -4
  178. package/libs/z80-assembler/src/lib/assets/code/basic-line2.zx81 +0 -9
  179. package/libs/z80-assembler/src/lib/assets/code/characters.zx81 +0 -190
  180. package/libs/z80-assembler/src/lib/assets/code/display.zx81 +0 -50
  181. package/libs/z80-assembler/src/lib/assets/code/system-variables.zx81 +0 -46
  182. package/libs/z80-assembler/src/lib/compiler/Ast.ts +0 -545
  183. package/libs/z80-assembler/src/lib/compiler/Compiler.test.ts +0 -2141
  184. package/libs/z80-assembler/src/lib/compiler/Compiler.ts +0 -185
  185. package/libs/z80-assembler/src/lib/compiler/Formatter.ts +0 -43
  186. package/libs/z80-assembler/src/lib/compiler/Generator.ts +0 -255
  187. package/libs/z80-assembler/src/lib/compiler/Labels.ts +0 -165
  188. package/libs/z80-assembler/src/lib/grammar/LowLevel.ts +0 -163
  189. package/libs/z80-assembler/src/lib/grammar/Parse.ts +0 -128
  190. package/libs/z80-assembler/src/lib/grammar/z80.peg +0 -1252
  191. package/libs/z80-assembler/src/lib/grammar/z80.ts +0 -10649
  192. package/libs/z80-assembler/src/lib/types/Error.ts +0 -105
  193. package/libs/z80-assembler/tsconfig.json +0 -23
  194. package/libs/z80-assembler/tsconfig.lib.json +0 -10
  195. package/libs/z80-assembler/tsconfig.spec.json +0 -19
  196. package/libs/z80-assembler/vite.config.ts +0 -58
  197. package/nx.json +0 -57
  198. 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
- ![Z80](assets/images/logo.png)
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
- A Z80 assembler entirely written in Typescript and derived from a PEG grammar.
6
+ ## Demo application
6
7
 
7
- ## Components
8
+ A demo application is available: https://andrivet.github.io/z80-assembler/.
8
9
 
9
- * The first component is the library itself, `z80-assembler` that can be used like any npm library.
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
- ![z80-assembler-app](assets/images/z80-assembler-app.png)
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 --legacy-peer-deps install
21
- ./node_modules/.bin/nx run z80-assembler-app:build:production
15
+ $ npm install @andrivet/z80-assembler
22
16
  ```
23
17
 
24
- Notes:
18
+ The main function is simply called `compile`. It takes three arguments:
25
19
 
26
- * For the moment, you have to use `--legacy-peer-deps` because react-daisyui is not yet updated for DaisyUI 3.
27
- Once it is the case, this flag will no more be necessary.
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
- * If you have installed NX globally, you do not need to specify its path.
24
+ It returns an object of type `CompilationInfo` with the following fields:
30
25
 
31
- ## How to run the application
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
- nx run z80-assembler-app:dev:production
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
- Open a navigator at the URL http://localhost:4200/
38
-
39
-
40
- ## Quick guide to use the application
41
-
42
- Under the **File** menu, you find the following commands:
43
-
44
- ![Z80](assets/images/menu.png)
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
- ![Z80](assets/images/open-dir.png)
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
- ![Z80](assets/images/compile.png)
60
-
61
- While writing your Z80 assembly code, you can display the list of Z80 opcodes by clicking on **Z80 Opcodes**:
62
-
63
- ![Z80](assets/images/opcodes.png)
64
-
65
- Click on a category to see the corresponding opcodes:
66
-
67
- ![Z80](assets/images/opcodes-load8.png)
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
- The format of assembly source file is described in [Z80 Assembly Source Code Format](./docs/assembly.md).
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';