@andrivet/z80-assembler 1.3.1 → 1.4.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 (197) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.json +35 -0
  4. package/.github/workflows/node.js.yml +47 -0
  5. package/.prettierignore +3 -0
  6. package/.prettierrc +3 -0
  7. package/.vscode/extensions.json +7 -0
  8. package/README.md +53 -27
  9. package/apps/.gitkeep +0 -0
  10. package/apps/z80-assembler-app/.eslintrc.json +18 -0
  11. package/apps/z80-assembler-app/index.html +16 -0
  12. package/apps/z80-assembler-app/postcss.config.js +24 -0
  13. package/apps/z80-assembler-app/project.json +70 -0
  14. package/apps/z80-assembler-app/public/favicon.ico +0 -0
  15. package/apps/z80-assembler-app/public/logo.png +0 -0
  16. package/apps/z80-assembler-app/public/logo192.png +0 -0
  17. package/apps/z80-assembler-app/public/logo512.png +0 -0
  18. package/apps/z80-assembler-app/public/manifest.json +25 -0
  19. package/apps/z80-assembler-app/public/robots.txt +3 -0
  20. package/apps/z80-assembler-app/src/app/app.module.css +0 -0
  21. package/apps/z80-assembler-app/src/app/app.tsx +122 -0
  22. package/apps/z80-assembler-app/src/app/binary.tsx +39 -0
  23. package/apps/z80-assembler-app/src/app/editor.tsx +228 -0
  24. package/apps/z80-assembler-app/src/app/errors.tsx +31 -0
  25. package/apps/z80-assembler-app/src/app/footer.tsx +20 -0
  26. package/apps/z80-assembler-app/src/app/header.tsx +57 -0
  27. package/apps/z80-assembler-app/src/app/misc.ts +13 -0
  28. package/apps/z80-assembler-app/src/app/opcodes.tsx +335 -0
  29. package/apps/z80-assembler-app/src/assets/.gitkeep +0 -0
  30. package/apps/z80-assembler-app/src/assets/images/logo192.png +0 -0
  31. package/apps/z80-assembler-app/src/main.tsx +22 -0
  32. package/apps/z80-assembler-app/src/styles.css +8 -0
  33. package/apps/z80-assembler-app/tailwind.config.js +28 -0
  34. package/apps/z80-assembler-app/tsconfig.app.json +22 -0
  35. package/apps/z80-assembler-app/tsconfig.json +21 -0
  36. package/apps/z80-assembler-app/tsconfig.spec.json +23 -0
  37. package/apps/z80-assembler-app/vite.config.ts +64 -0
  38. package/assets/images/compile.png +0 -0
  39. package/assets/images/logo.png +0 -0
  40. package/assets/images/menu.png +0 -0
  41. package/assets/images/opcodes-load8.png +0 -0
  42. package/assets/images/opcodes.png +0 -0
  43. package/assets/images/open-dir.png +0 -0
  44. package/assets/images/z80-assembler-app.png +0 -0
  45. package/docs/assembly.md +551 -0
  46. package/docs/images/ZX81-0x00.png +0 -0
  47. package/docs/images/ZX81-0x0B.png +0 -0
  48. package/docs/images/ZX81-0x0C.png +0 -0
  49. package/docs/images/ZX81-0x0D.png +0 -0
  50. package/docs/images/ZX81-0x0E.png +0 -0
  51. package/docs/images/ZX81-0x0F.png +0 -0
  52. package/docs/images/ZX81-0x10.png +0 -0
  53. package/docs/images/ZX81-0x11.png +0 -0
  54. package/docs/images/ZX81-0x12.png +0 -0
  55. package/docs/images/ZX81-0x13.png +0 -0
  56. package/docs/images/ZX81-0x14.png +0 -0
  57. package/docs/images/ZX81-0x15.png +0 -0
  58. package/docs/images/ZX81-0x16.png +0 -0
  59. package/docs/images/ZX81-0x17.png +0 -0
  60. package/docs/images/ZX81-0x18.png +0 -0
  61. package/docs/images/ZX81-0x19.png +0 -0
  62. package/docs/images/ZX81-0x1A.png +0 -0
  63. package/docs/images/ZX81-0x1B.png +0 -0
  64. package/docs/images/ZX81-0x1C.png +0 -0
  65. package/docs/images/ZX81-0x1D.png +0 -0
  66. package/docs/images/ZX81-0x1E.png +0 -0
  67. package/docs/images/ZX81-0x1F.png +0 -0
  68. package/docs/images/ZX81-0x20.png +0 -0
  69. package/docs/images/ZX81-0x21.png +0 -0
  70. package/docs/images/ZX81-0x22.png +0 -0
  71. package/docs/images/ZX81-0x23.png +0 -0
  72. package/docs/images/ZX81-0x24.png +0 -0
  73. package/docs/images/ZX81-0x25.png +0 -0
  74. package/docs/images/ZX81-0x26.png +0 -0
  75. package/docs/images/ZX81-0x27.png +0 -0
  76. package/docs/images/ZX81-0x28.png +0 -0
  77. package/docs/images/ZX81-0x29.png +0 -0
  78. package/docs/images/ZX81-0x2A.png +0 -0
  79. package/docs/images/ZX81-0x2B.png +0 -0
  80. package/docs/images/ZX81-0x2C.png +0 -0
  81. package/docs/images/ZX81-0x2D.png +0 -0
  82. package/docs/images/ZX81-0x2E.png +0 -0
  83. package/docs/images/ZX81-0x2F.png +0 -0
  84. package/docs/images/ZX81-0x30.png +0 -0
  85. package/docs/images/ZX81-0x31.png +0 -0
  86. package/docs/images/ZX81-0x32.png +0 -0
  87. package/docs/images/ZX81-0x33.png +0 -0
  88. package/docs/images/ZX81-0x34.png +0 -0
  89. package/docs/images/ZX81-0x35.png +0 -0
  90. package/docs/images/ZX81-0x36.png +0 -0
  91. package/docs/images/ZX81-0x37.png +0 -0
  92. package/docs/images/ZX81-0x38.png +0 -0
  93. package/docs/images/ZX81-0x39.png +0 -0
  94. package/docs/images/ZX81-0x3A.png +0 -0
  95. package/docs/images/ZX81-0x3B.png +0 -0
  96. package/docs/images/ZX81-0x3C.png +0 -0
  97. package/docs/images/ZX81-0x3D.png +0 -0
  98. package/docs/images/ZX81-0x3E.png +0 -0
  99. package/docs/images/ZX81-0x3F.png +0 -0
  100. package/docs/images/ZX81-0x80.png +0 -0
  101. package/docs/images/ZX81-0x8B.png +0 -0
  102. package/docs/images/ZX81-0x8C.png +0 -0
  103. package/docs/images/ZX81-0x8D.png +0 -0
  104. package/docs/images/ZX81-0x8E.png +0 -0
  105. package/docs/images/ZX81-0x8F.png +0 -0
  106. package/docs/images/ZX81-0x90.png +0 -0
  107. package/docs/images/ZX81-0x91.png +0 -0
  108. package/docs/images/ZX81-0x92.png +0 -0
  109. package/docs/images/ZX81-0x93.png +0 -0
  110. package/docs/images/ZX81-0x94.png +0 -0
  111. package/docs/images/ZX81-0x95.png +0 -0
  112. package/docs/images/ZX81-0x96.png +0 -0
  113. package/docs/images/ZX81-0x97.png +0 -0
  114. package/docs/images/ZX81-0x98.png +0 -0
  115. package/docs/images/ZX81-0x99.png +0 -0
  116. package/docs/images/ZX81-0x9A.png +0 -0
  117. package/docs/images/ZX81-0x9B.png +0 -0
  118. package/docs/images/ZX81-0x9C.png +0 -0
  119. package/docs/images/ZX81-0x9D.png +0 -0
  120. package/docs/images/ZX81-0x9E.png +0 -0
  121. package/docs/images/ZX81-0x9F.png +0 -0
  122. package/docs/images/ZX81-0xA0.png +0 -0
  123. package/docs/images/ZX81-0xA1.png +0 -0
  124. package/docs/images/ZX81-0xA2.png +0 -0
  125. package/docs/images/ZX81-0xA3.png +0 -0
  126. package/docs/images/ZX81-0xA4.png +0 -0
  127. package/docs/images/ZX81-0xA5.png +0 -0
  128. package/docs/images/ZX81-0xA6.png +0 -0
  129. package/docs/images/ZX81-0xA7.png +0 -0
  130. package/docs/images/ZX81-0xA8.png +0 -0
  131. package/docs/images/ZX81-0xA9.png +0 -0
  132. package/docs/images/ZX81-0xAA.png +0 -0
  133. package/docs/images/ZX81-0xAB.png +0 -0
  134. package/docs/images/ZX81-0xAC.png +0 -0
  135. package/docs/images/ZX81-0xAD.png +0 -0
  136. package/docs/images/ZX81-0xAE.png +0 -0
  137. package/docs/images/ZX81-0xAF.png +0 -0
  138. package/docs/images/ZX81-0xB0.png +0 -0
  139. package/docs/images/ZX81-0xB1.png +0 -0
  140. package/docs/images/ZX81-0xB2.png +0 -0
  141. package/docs/images/ZX81-0xB3.png +0 -0
  142. package/docs/images/ZX81-0xB4.png +0 -0
  143. package/docs/images/ZX81-0xB5.png +0 -0
  144. package/docs/images/ZX81-0xB6.png +0 -0
  145. package/docs/images/ZX81-0xB7.png +0 -0
  146. package/docs/images/ZX81-0xB8.png +0 -0
  147. package/docs/images/ZX81-0xB9.png +0 -0
  148. package/docs/images/ZX81-0xBA.png +0 -0
  149. package/docs/images/ZX81-0xBB.png +0 -0
  150. package/docs/images/ZX81-0xBC.png +0 -0
  151. package/docs/images/ZX81-0xBD.png +0 -0
  152. package/docs/images/ZX81-0xBE.png +0 -0
  153. package/docs/images/ZX81-0xBF.png +0 -0
  154. package/libs/.gitkeep +0 -0
  155. package/libs/z80-assembler/.eslintrc.json +18 -0
  156. package/libs/z80-assembler/package.json +20 -0
  157. package/libs/z80-assembler/project.json +35 -0
  158. package/{CHANGELOG.md → libs/z80-assembler/public/CHANGELOG.md} +5 -1
  159. package/libs/z80-assembler/public/README.md +54 -0
  160. package/{index.d.ts → libs/z80-assembler/src/index.ts} +1 -1
  161. package/libs/z80-assembler/src/lib/assets/code/basic-end.zx81 +4 -0
  162. package/libs/z80-assembler/src/lib/assets/code/basic-line1.zx81 +4 -0
  163. package/libs/z80-assembler/src/lib/assets/code/basic-line2.zx81 +9 -0
  164. package/libs/z80-assembler/src/lib/assets/code/characters.zx81 +190 -0
  165. package/libs/z80-assembler/src/lib/assets/code/display.zx81 +50 -0
  166. package/libs/z80-assembler/src/lib/assets/code/system-variables.zx81 +46 -0
  167. package/{lib/compiler/Assets.d.ts → libs/z80-assembler/src/lib/compiler/Assets.ts} +6 -1
  168. package/libs/z80-assembler/src/lib/compiler/Ast.ts +545 -0
  169. package/libs/z80-assembler/src/lib/compiler/Compiler.test.ts +2141 -0
  170. package/libs/z80-assembler/src/lib/compiler/Compiler.ts +185 -0
  171. package/libs/z80-assembler/src/lib/compiler/Formatter.ts +43 -0
  172. package/libs/z80-assembler/src/lib/compiler/Generator.ts +255 -0
  173. package/libs/z80-assembler/src/lib/compiler/Labels.ts +165 -0
  174. package/libs/z80-assembler/src/lib/grammar/LowLevel.ts +163 -0
  175. package/libs/z80-assembler/src/lib/grammar/Parse.ts +128 -0
  176. package/libs/z80-assembler/src/lib/grammar/z80.peg +1252 -0
  177. package/libs/z80-assembler/src/lib/grammar/z80.ts +10649 -0
  178. package/libs/z80-assembler/src/lib/types/Error.ts +105 -0
  179. package/{lib/types/Types.d.ts → libs/z80-assembler/src/lib/types/Types.ts} +26 -11
  180. package/libs/z80-assembler/tsconfig.json +23 -0
  181. package/libs/z80-assembler/tsconfig.lib.json +10 -0
  182. package/libs/z80-assembler/tsconfig.spec.json +19 -0
  183. package/libs/z80-assembler/vite.config.ts +58 -0
  184. package/nx.json +57 -0
  185. package/package.json +52 -14
  186. package/tsconfig.base.json +22 -0
  187. package/index.js +0 -312
  188. package/index.mjs +0 -6441
  189. package/lib/compiler/Ast.d.ts +0 -210
  190. package/lib/compiler/Compiler.d.ts +0 -53
  191. package/lib/compiler/Formatter.d.ts +0 -23
  192. package/lib/compiler/Generator.d.ts +0 -40
  193. package/lib/compiler/Labels.d.ts +0 -47
  194. package/lib/grammar/LowLevel.d.ts +0 -68
  195. package/lib/grammar/Parse.d.ts +0 -48
  196. package/lib/grammar/z80.d.ts +0 -2938
  197. package/lib/types/Error.d.ts +0 -62
@@ -0,0 +1,551 @@
1
+ # Z80 Assembly Source Code Format
2
+
3
+ ## Z80 opcodes
4
+
5
+ This assembler supports all the official Z80 opcodes as defined in [Zilog Z80 CPU User Manual](https://www.zilog.com/docs/z80/um0080.pdf).
6
+ Each z80 opcode has to be on a separate line.
7
+
8
+ ## Z80 non-standard or fake opcodes
9
+
10
+ Some assemblers (such as [sjasmplus](http://z00m128.github.io/sjasmplus/documentation.html#s_fake_instructions)) support fake opcodes such as `ld bc,de`. This is not the case of this assembler (on purpose).
11
+ You have to use the equivalent with official opcodes such as:
12
+
13
+ ```asm
14
+ ld b,d
15
+ ld c,e ; equivalent of the fake opcode ld bc,de
16
+ ```
17
+
18
+ ## Labels
19
+
20
+ Labels are sequence of characters representing a numerical value. It is often an address but can be something else.
21
+ The name of a label has to start with a letter, an underscore or a period and continues with a letter, a digit or one of those characters: `_!?#@.$`.
22
+ Case is ignored. Labels have to be unique. There is (currently) no notion of global or local labels.
23
+
24
+ When they are declared, label have to be at the beginning of a line. They can be optionally followed by a column (`:`). This is not part of the name.
25
+ If the label is followed by `equ` (or `.equ`), it takes the value of the expression after this keyword. Otherwise, the value of the label is the address of the next instruction.
26
+
27
+ ```
28
+ label1:
29
+ ld a,1
30
+ ```
31
+
32
+ ```
33
+ label2 equ 1234h
34
+ ```
35
+
36
+ Labels can be used in expressions by using their name (without the column). This label is replaced by its value when evaluated.
37
+ It is possible to use labels before their declaration. This is typically the case in code such as:
38
+
39
+ ```
40
+ jr z,label1
41
+ ...
42
+ label1:
43
+ ...
44
+ ```
45
+
46
+ The value of a label can't be ambiguous. For example, the following code results in a compilation error because the two labels are dependent of each other (cycle) :
47
+
48
+ ```
49
+ label1 equ label2
50
+ label2 equ label1
51
+ ```
52
+
53
+ Likewise, the following code is ambiguous in a more subtle way (the size of the block depends on label1 and label1 depends on the size of the block):
54
+
55
+ ```
56
+ block label1
57
+ ...
58
+ label1:
59
+ ...
60
+ ```
61
+
62
+ ## Numeric Constants
63
+
64
+ Numeric constants can be declared in decimal, hexadecimal, octal or binary using a prefix
65
+
66
+ | Prefix | Base | Example |
67
+ |--------|-------------|-----------|
68
+ | none | Decimal | 123 |
69
+ | $ | Hexadecimal | $ab12 |
70
+ | # | Hexadecimal | #ab12 |
71
+ | @ | Octal | @123 |
72
+ | & | Binary | &00001000 |
73
+
74
+ It is also possible to use prefixes starting with `0`, similar to the syntax of the C language:
75
+
76
+ | Prefix | Base | Example |
77
+ |--------|-------------|------------|
78
+ | 0x | Hexadecimal | 0xab12 |
79
+ | 0o | Octal | 0o123 |
80
+ | 0q | Octal | 0q123 |
81
+ | 0b | Binary | 0b00001000 |
82
+
83
+ Another possibility is to use a suffix:
84
+
85
+ | Suffix | Base | Example |
86
+ |--------|-------------|-------------|
87
+ | d | Decimal | 123d |
88
+ | h | Hexadecimal | ab12h |
89
+ | q | Octal | 123q |
90
+ | o | Octal | 123o |
91
+ | b | Binary | 0b00001000b |
92
+
93
+ Hexadecimal digits, prefixes and suffixes are not case-sensitive. The following constants are all equivalent:
94
+
95
+ ```
96
+ AB12H
97
+ ab12h
98
+ Ab12H
99
+ 0xAB12
100
+ 0Xab12
101
+ ```
102
+
103
+ > Note: `abh` is ambiguous. It could be the hexadecimal value `ab` or the label `abh`.
104
+ > Some assemblers require to start such hexadecimal value with `0`. This is not the case here.
105
+ > The sequence of characters is interpreted as an hexadecimal value.
106
+
107
+ ## Character and String Constants
108
+
109
+ Character and string constants are enclosed in single or double quotes.
110
+ The ASCII (more precisely Latin-1) characters and translated into their ZX81 counterparts if it is possible:
111
+
112
+ | Latin-1 | Code | ZX81 | Code | | Latin-1 | Code | ZX81 | Code |
113
+ |---------|------|-----------------------------|------|-|---------|------|-----------------------------|------|
114
+ | | 20h | ![](./images/ZX81-0x00.png) | 00h | | _ | | ![](./images/ZX81-0x80.png) | 80h |
115
+ | " | 22h | ![](./images/ZX81-0x0B.png) | 0Bh | | | | | |
116
+ | £ | A3h | ![](./images/ZX81-0x0C.png) | 0Ch | | | | | |
117
+ | $ | 24h | ![](./images/ZX81-0x0D.png) | 0Dh | | | | | |
118
+ | : | 3Ah | ![](./images/ZX81-0x0E.png) | 0Eh | | | | | |
119
+ | ? | 3Fh | ![](./images/ZX81-0x0F.png) | 0Fh | | | | | |
120
+ | ( | 28h | ![](./images/ZX81-0x10.png) | 10h | | | | | |
121
+ | ) | 29h | ![](./images/ZX81-0x11.png) | 11h | | | | | |
122
+ | > | 3Ch | ![](./images/ZX81-0x12.png) | 12h | | | | | |
123
+ | < | 3Eh | ![](./images/ZX81-0x13.png) | 13h | | | | | |
124
+ | = | 3Dh | ![](./images/ZX81-0x14.png) | 14h | | | | | |
125
+ | + | 2Bh | ![](./images/ZX81-0x15.png) | 15h | | | | | |
126
+ | - | 2Dh | ![](./images/ZX81-0x16.png) | 16h | | | | | |
127
+ | * | 2Ah | ![](./images/ZX81-0x17.png) | 17h | | | | | |
128
+ | / | 2Fh | ![](./images/ZX81-0x18.png) | 18h | | | | | |
129
+ | ; | 3Bh | ![](./images/ZX81-0x19.png) | 19h | | | | | |
130
+ | , | 2Ch | ![](./images/ZX81-0x1A.png) | 1Ah | | | | | |
131
+ | . | 2Eh | ![](./images/ZX81-0x1B.png) | 1Bh | | | | | |
132
+ | 0 | 30h | ![](./images/ZX81-0x1C.png) | 1Ch | | | | | |
133
+ | 1 | 31h | ![](./images/ZX81-0x1D.png) | 1Dh | | | | | |
134
+ | 2 | 32h | ![](./images/ZX81-0x1E.png) | 1Eh | | | | | |
135
+ | 3 | 33h | ![](./images/ZX81-0x1F.png) | 1Fh | | | | | |
136
+ | 4 | 34h | ![](./images/ZX81-0x20.png) | 20h | | | | | |
137
+ | 5 | 35h | ![](./images/ZX81-0x21.png) | 21h | | | | | |
138
+ | 6 | 36h | ![](./images/ZX81-0x22.png) | 22h | | | | | |
139
+ | 7 | 37h | ![](./images/ZX81-0x23.png) | 23h | | | | | |
140
+ | 8 | 38h | ![](./images/ZX81-0x24.png) | 24h | | | | | |
141
+ | 9 | 39h | ![](./images/ZX81-0x25.png) | 25h | | | | | |
142
+ | A | 31h | ![](./images/ZX81-0x26.png) | 26h | | a | 61h | ![](./images/ZX81-0xA6.png) | A6h |
143
+ | B | 32h | ![](./images/ZX81-0x27.png) | 27h | | b | 62h | ![](./images/ZX81-0xA7.png) | A7h |
144
+ | C | 33h | ![](./images/ZX81-0x28.png) | 28h | | c | 63h | ![](./images/ZX81-0xA8.png) | A8h |
145
+ | D | 34h | ![](./images/ZX81-0x29.png) | 29h | | d | 64h | ![](./images/ZX81-0xA9.png) | A9h |
146
+ | E | 35h | ![](./images/ZX81-0x2A.png) | 2Ah | | e | 65h | ![](./images/ZX81-0xAA.png) | AAh |
147
+ | F | 36h | ![](./images/ZX81-0x2B.png) | 2Bh | | f | 66h | ![](./images/ZX81-0xAB.png) | ABh |
148
+ | G | 37h | ![](./images/ZX81-0x2C.png) | 2Ch | | g | 67h | ![](./images/ZX81-0xAC.png) | ACh |
149
+ | H | 38h | ![](./images/ZX81-0x2D.png) | 2Dh | | h | 68h | ![](./images/ZX81-0xAD.png) | ADh |
150
+ | I | 39h | ![](./images/ZX81-0x2E.png) | 2Eh | | i | 69h | ![](./images/ZX81-0xAE.png) | AEh |
151
+ | J | 3Ah | ![](./images/ZX81-0x2F.png) | 2Fh | | j | 6Ah | ![](./images/ZX81-0xAF.png) | AFh |
152
+ | K | 3Bh | ![](./images/ZX81-0x30.png) | 30h | | k | 6Bh | ![](./images/ZX81-0xB0.png) | B0h |
153
+ | L | 3Ch | ![](./images/ZX81-0x31.png) | 31h | | l | 6Ch | ![](./images/ZX81-0xB1.png) | B1h |
154
+ | M | 3Dh | ![](./images/ZX81-0x32.png) | 32h | | m | 6Dh | ![](./images/ZX81-0xB2.png) | B2h |
155
+ | N | 3Eh | ![](./images/ZX81-0x33.png) | 33h | | n | 6Eh | ![](./images/ZX81-0xB3.png) | B3h |
156
+ | O | 3Fh | ![](./images/ZX81-0x34.png) | 34h | | o | 6Fh | ![](./images/ZX81-0xB4.png) | B4h |
157
+ | P | 50h | ![](./images/ZX81-0x35.png) | 35h | | p | 70h | ![](./images/ZX81-0xB5.png) | B5h |
158
+ | Q | 51h | ![](./images/ZX81-0x36.png) | 36h | | q | 71h | ![](./images/ZX81-0xB6.png) | B6h |
159
+ | R | 52h | ![](./images/ZX81-0x37.png) | 37h | | r | 72h | ![](./images/ZX81-0xB7.png) | B7h |
160
+ | S | 53h | ![](./images/ZX81-0x38.png) | 38h | | s | 73h | ![](./images/ZX81-0xB8.png) | B8h |
161
+ | T | 54h | ![](./images/ZX81-0x39.png) | 39h | | t | 74h | ![](./images/ZX81-0xB9.png) | B9h |
162
+ | U | 55h | ![](./images/ZX81-0x3A.png) | 3Ah | | u | 75h | ![](./images/ZX81-0xBA.png) | BAh |
163
+ | V | 56h | ![](./images/ZX81-0x3B.png) | 3Bh | | v | 76h | ![](./images/ZX81-0xBB.png) | BBh |
164
+ | W | 57h | ![](./images/ZX81-0x3C.png) | 3Ch | | w | 77h | ![](./images/ZX81-0xBC.png) | BCh |
165
+ | X | 58h | ![](./images/ZX81-0x3D.png) | 3Dh | | x | 78h | ![](./images/ZX81-0xBD.png) | BDh |
166
+ | Y | 59h | ![](./images/ZX81-0x3E.png) | 3Eh | | y | 79h | ![](./images/ZX81-0xBE.png) | BEh |
167
+ | Z | 5Ah | ![](./images/ZX81-0x3F.png) | 3Fh | | z | 7Ah | ![](./images/ZX81-0xBF.png) | BFh |
168
+
169
+ Upper case letters are translated into their black on white counterparts, lower case letters into white on black capital counterparts.
170
+
171
+ Strings and characters can contain escape sequences:
172
+
173
+ | Escape | Description | Code |
174
+ |--------|------------------|-------|
175
+ | \n | New Line | 76h |
176
+ | \" | Double quote | 0Bh |
177
+ | \123 | Octal value | 53h |
178
+ | \x60 | Hexdecimal value | 60h |
179
+
180
+ ## Location Counter Symbol
181
+
182
+ The current value of the location counter (PC) can be used in expressions by using `$`.
183
+ The location counter is the address of the instruction or directive (its first byte) on the line.
184
+
185
+ ## Expressions
186
+
187
+ Expressions can be used when a numerical value is expected. They are comprised of:
188
+
189
+ * Labels
190
+ * Numerical constants
191
+ * Location Counter Symbol
192
+ * Operators
193
+ * Parenthesis
194
+
195
+ The available operators are the following, in order of precedence:
196
+
197
+ | Operator | Type | Description |
198
+ |----------|----------------|----------------|
199
+ | - | Unary | Negation |
200
+ | + | Unary | No effect |
201
+ | ~ | Unary | Bits inversion |
202
+ | * | Multiplicative | Multiplication |
203
+ | % | Multiplicative | Modulo |
204
+ | / | Multiplicative | Division |
205
+ | + | Additive | Addition |
206
+ | - | Additive | Substraction |
207
+ | << | Shift | Left Shift |
208
+ | \>> | Shift | Right Sift |
209
+ | & | And | Bitwise And |
210
+ | ^ | Xor | Bitwise Xor |
211
+ | \| | Or | Bitwise Or |
212
+
213
+ ## Directives
214
+
215
+ This assembler supports the following directives:
216
+
217
+ * `equ` (or `.equ`): Define a value for a label
218
+ * `org` (or `.org`): Set the current address to compile the code.
219
+ * `include` (or `.include`): Include another assembly file.
220
+ * `device` (or `.device`): Set the current target (device).
221
+ * `byte` (or `db`, `dm`, `defb`, `defm`): Define a list of byte values
222
+ * `word` (or `dw`, `defw`): Define a list of word values
223
+ * `block` (or `defs`, `ds`): Define a block of byte values.
224
+ * `end` (or `.end`): This directive is optional and will stop the generation of binary.
225
+
226
+ ### equ Directive
227
+
228
+ This directive defines explicitly the value of a label. The formats are the following:
229
+
230
+ ```
231
+ label equ expression
232
+ label .equ expression
233
+ label: equ expression
234
+ label: .equ expression
235
+ label: = expression
236
+ label: = expression
237
+ ```
238
+
239
+ ### org Directive
240
+
241
+ Set explicitly the value of the program counter (PC). The formats are the following:
242
+
243
+ ```
244
+ [label] org expression
245
+ [label] .org expression
246
+ ```
247
+
248
+ The label is optional. The program counter is assigned the value of the expression.
249
+ For example, to generate code starting at address `4009h`, the following could be done:
250
+
251
+ ```
252
+ org 4009h
253
+ ```
254
+
255
+ ### include Directive
256
+
257
+ The include directive reads in and assembles another source file. The formats are the following:
258
+
259
+ ```
260
+ include "filename.zx81"
261
+ .include filename.zx81
262
+ ```
263
+
264
+ The double quotes are optional unless there is a space in the filename.
265
+
266
+ ### device Directive
267
+
268
+ The device directive modifies the binary generated for the given computer. The formats are the following:
269
+
270
+ ```
271
+ device name
272
+ .device name
273
+ ```
274
+
275
+ The only defined value for name is `zx81`. ALl other values are ignored.
276
+
277
+ #### ZX81 device
278
+
279
+ When `device zx81` is specified in the source code, the assembler performs the following:
280
+
281
+ * It defines labels for all system variables and it defines appropriate values for those system variables.
282
+ * It defines labels for all ZX81 characters.
283
+ * It generates bytes for a first BASIC line containing the compiled program (in a `REM` statement).
284
+ * It generates bytes for a second BASIC line calling the compiled program.
285
+ * It generates bytes for the display file (D_FILE).
286
+ * It assigns implicitly 4082h (16514) to the Program Counter.
287
+
288
+ To summarize, you only have to write the code of your assembly program and the assembler will take care of the rest.
289
+
290
+ The following labels are created for system variables at the start of the RAM:
291
+
292
+ | Label | Value | Size |
293
+ |--------|-------|------|
294
+ | ERR_NR | 4000h | 1 |
295
+ | FLAGS | 4001h | 1 |
296
+ | ERR_SP | 4002h | 2 |
297
+ | RAMTOP | 4004h | 2 |
298
+ | MODE | 4006h | 1 |
299
+ | PPC | 4007h | 2 |
300
+ | VERSN | 4009H | 1 |
301
+ | E_PPC | 400AH | 2 |
302
+ | D_FILE | 400CH | 2 |
303
+ | DF_CC | 400EH | 2 |
304
+ | VARS | 4010H | 2 |
305
+ | DEST | 4012H | 2 |
306
+ | E_LINE | 4014H | 2 |
307
+ | CH_ADD | 4016H | 2 |
308
+ | X_PTR | 4018H | 2 |
309
+ | STKBOT | 401AH | 2 |
310
+ | STKEND | 401CH | 2 |
311
+ | BERG | 401EH | 1 |
312
+ | MEM | 401FH | 2 |
313
+ | SPARE1 | 4021H | 1 |
314
+ | DF_SZ | 4022H | 1 |
315
+ | S_TOP | 4023H | 2 |
316
+ | LAST_K | 4025H | 2 |
317
+ | DB_ST | 4027H | 1 |
318
+ | MARGIN | 4028H | 1 |
319
+ | NXTLIN | 4029H | 2 |
320
+ | OLDPPC | 402BH | 2 |
321
+ | FLAGX | 402DH | 1 |
322
+ | STRLEN | 402EH | 2 |
323
+ | T_ADDR | 4030H | 2 |
324
+ | SEED | 4032H | 2 |
325
+ | FRAMES | 4034H | 2 |
326
+ | COORDS | 4036H | 2 |
327
+ | PR_CC | 4038H | 1 |
328
+ | S_POSN | 4039H | 2 |
329
+ | CDFLAG | 403BH | 1 |
330
+ | PRBUF | 403CH | 33 |
331
+ | MEMBOT | 404DH | 30 |
332
+ | SPARE2 | 407DH | 2 |
333
+
334
+ The following labels are defined for ZX81 printable characters:
335
+
336
+ | Label | Value | Character | | Label | Value | Character |
337
+ |-------|-------|-----------------------------|-|-------|-------|-----------------------------|
338
+ | __ | 00h | ![](./images/ZX81-0x00.png) | | | | |
339
+ | _SPC | 00h | ![](./images/ZX81-0x00.png) | | _SPCV | 80h | ![](./images/ZX81-0x80.png) |
340
+ | _DQT | 0bh | ![](./images/ZX81-0x0B.png) | | _DQTV | 8bh | ![](./images/ZX81-0x8B.png) |
341
+ | _PND | 0ch | ![](./images/ZX81-0x0C.png) | | _PNDV | 8ch | ![](./images/ZX81-0x8C.png) |
342
+ | _DLR | 0dh | ![](./images/ZX81-0x0D.png) | | _DLRV | 8dh | ![](./images/ZX81-0x8D.png) |
343
+ | _CLN | 0eh | ![](./images/ZX81-0x0E.png) | | _CLNV | 8eh | ![](./images/ZX81-0x8E.png) |
344
+ | _QMK | 0fh | ![](./images/ZX81-0x0F.png) | | _QMKV | 8fh | ![](./images/ZX81-0x8F.png) |
345
+ | _OBR | 10h | ![](./images/ZX81-0x10.png) | | _OBRV | 90h | ![](./images/ZX81-0x90.png) |
346
+ | _CBR | 11h | ![](./images/ZX81-0x11.png) | | _CBRV | 91h | ![](./images/ZX81-0x91.png) |
347
+ | _GTH | 12h | ![](./images/ZX81-0x12.png) | | _GTHV | 92h | ![](./images/ZX81-0x92.png) |
348
+ | _LTH | 13h | ![](./images/ZX81-0x13.png) | | _LTHV | 93h | ![](./images/ZX81-0x93.png) |
349
+ | _EQU | 14h | ![](./images/ZX81-0x14.png) | | _EQUV | 94h | ![](./images/ZX81-0x94.png) |
350
+ | _PLS | 15h | ![](./images/ZX81-0x15.png) | | _PLSV | 95h | ![](./images/ZX81-0x95.png) |
351
+ | _MNS | 16h | ![](./images/ZX81-0x16.png) | | _MNSV | 96h | ![](./images/ZX81-0x96.png) |
352
+ | _ASK | 17h | ![](./images/ZX81-0x17.png) | | _ASKV | 97h | ![](./images/ZX81-0x97.png) |
353
+ | _SLS | 18h | ![](./images/ZX81-0x18.png) | | _SLSV | 98h | ![](./images/ZX81-0x98.png) |
354
+ | _SMC | 19h | ![](./images/ZX81-0x19.png) | | _SMCV | 99h | ![](./images/ZX81-0x99.png) |
355
+ | _CMA | 1ah | ![](./images/ZX81-0x1A.png) | | _CMAV | 9ah | ![](./images/ZX81-0x9A.png) |
356
+ | _FST | 1bh | ![](./images/ZX81-0x1B.png) | | _FSTV | 9bh | ![](./images/ZX81-0x9B.png) |
357
+ | _0 | 1ch | ![](./images/ZX81-0x1C.png) | | _0V | 9ch | ![](./images/ZX81-0x9C.png) |
358
+ | _1 | 1dh | ![](./images/ZX81-0x1D.png) | | _1V | 9dh | ![](./images/ZX81-0x9D.png) |
359
+ | _2 | 1eh | ![](./images/ZX81-0x1E.png) | | _2V | 9eh | ![](./images/ZX81-0x9E.png) |
360
+ | _3 | 1fh | ![](./images/ZX81-0x1F.png) | | _3V | 9fh | ![](./images/ZX81-0x9F.png) |
361
+ | _4 | 20h | ![](./images/ZX81-0x20.png) | | _4V | a0h | ![](./images/ZX81-0xA0.png) |
362
+ | _5 | 21h | ![](./images/ZX81-0x21.png) | | _5V | a1h | ![](./images/ZX81-0xA1.png) |
363
+ | _6 | 22h | ![](./images/ZX81-0x22.png) | | _6V | a2h | ![](./images/ZX81-0xA2.png) |
364
+ | _7 | 23h | ![](./images/ZX81-0x23.png) | | _7V | a3h | ![](./images/ZX81-0xA3.png) |
365
+ | _8 | 24h | ![](./images/ZX81-0x24.png) | | _8V | a4h | ![](./images/ZX81-0xA4.png) |
366
+ | _9 | 25h | ![](./images/ZX81-0x25.png) | | _9V | a5h | ![](./images/ZX81-0xA5.png) |
367
+ | _A | 26h | ![](./images/ZX81-0x26.png) | | _AV | a6h | ![](./images/ZX81-0xA6.png) |
368
+ | _B | 27h | ![](./images/ZX81-0x27.png) | | _BV | a7h | ![](./images/ZX81-0xA7.png) |
369
+ | _C | 28h | ![](./images/ZX81-0x28.png) | | _CV | a8h | ![](./images/ZX81-0xA8.png) |
370
+ | _D | 29h | ![](./images/ZX81-0x29.png) | | _DV | a9h | ![](./images/ZX81-0xA9.png) |
371
+ | _E | 2ah | ![](./images/ZX81-0x2A.png) | | _EV | aah | ![](./images/ZX81-0xAA.png) |
372
+ | _F | 2bh | ![](./images/ZX81-0x2B.png) | | _FV | abh | ![](./images/ZX81-0xAB.png) |
373
+ | _G | 2ch | ![](./images/ZX81-0x2C.png) | | _GV | ach | ![](./images/ZX81-0xAC.png) |
374
+ | _H | 2dh | ![](./images/ZX81-0x2D.png) | | _HV | adh | ![](./images/ZX81-0xAD.png) |
375
+ | _I | 2eh | ![](./images/ZX81-0x2E.png) | | _IV | aeh | ![](./images/ZX81-0xAE.png) |
376
+ | _J | 2fh | ![](./images/ZX81-0x2F.png) | | _JV | afh | ![](./images/ZX81-0xAF.png) |
377
+ | _K | 30h | ![](./images/ZX81-0x30.png) | | _KV | b0h | ![](./images/ZX81-0xB0.png) |
378
+ | _L | 31h | ![](./images/ZX81-0x31.png) | | _LV | b1h | ![](./images/ZX81-0xB1.png) |
379
+ | _M | 32h | ![](./images/ZX81-0x32.png) | | _MV | b2h | ![](./images/ZX81-0xB2.png) |
380
+ | _N | 33h | ![](./images/ZX81-0x33.png) | | _NV | b3h | ![](./images/ZX81-0xB3.png) |
381
+ | _O | 34h | ![](./images/ZX81-0x34.png) | | _OV | b4h | ![](./images/ZX81-0xB4.png) |
382
+ | _P | 35h | ![](./images/ZX81-0x35.png) | | _PV | b5h | ![](./images/ZX81-0xB5.png) |
383
+ | _Q | 36h | ![](./images/ZX81-0x36.png) | | _QV | b6h | ![](./images/ZX81-0xB6.png) |
384
+ | _R | 37h | ![](./images/ZX81-0x37.png) | | _RV | b7h | ![](./images/ZX81-0xB7.png) |
385
+ | _S | 38h | ![](./images/ZX81-0x38.png) | | _SV | b8h | ![](./images/ZX81-0xB8.png) |
386
+ | _T | 39h | ![](./images/ZX81-0x39.png) | | _TV | b9h | ![](./images/ZX81-0xB9.png) |
387
+ | _U | 3ah | ![](./images/ZX81-0x3A.png) | | _UV | bah | ![](./images/ZX81-0xBA.png) |
388
+ | _V | 3bh | ![](./images/ZX81-0x3B.png) | | _VV | bbh | ![](./images/ZX81-0xBB.png) |
389
+ | _W | 3ch | ![](./images/ZX81-0x3C.png) | | _WV | bch | ![](./images/ZX81-0xBC.png) |
390
+ | _X | 3dh | ![](./images/ZX81-0x3D.png) | | _XV | bdh | ![](./images/ZX81-0xBD.png) |
391
+ | _Y | 3eh | ![](./images/ZX81-0x3E.png) | | _YV | beh | ![](./images/ZX81-0xBE.png) |
392
+ | _Z | 3fh | ![](./images/ZX81-0x3F.png) | | _ZV | bfh | ![](./images/ZX81-0xBF.png) |
393
+
394
+
395
+ The following labels are defined for ZX81 non-printable characters and keywords:
396
+
397
+ | Label | Value |
398
+ |------------|-------|
399
+ | _RND | 40h |
400
+ | _INKEY$ | 41h |
401
+ | _PI | 42h |
402
+ | _UP | 70h |
403
+ | _DOWN | 71h |
404
+ | _LEFT | 72h |
405
+ | _RIGHT | 73h |
406
+ | _GRAPHICS | 74h |
407
+ | _EDIT | 75h |
408
+ | _NEWLINE | 76h |
409
+ | _NL | 76h |
410
+ | _RUBOUT | 77h |
411
+ | _KL_MODE | 78h |
412
+ | _FUNCTION | 79h |
413
+ | _NUMBER | 7Eh |
414
+ | _CURSOR | 7Fh |
415
+ | _DQUOTES | C0h |
416
+ | _AT | C1h |
417
+ | _TAB | C2h |
418
+ | _CODE | C4h |
419
+ | _VAL | C5h |
420
+ | _LEN | C6h |
421
+ | _SIN | C7h |
422
+ | _COS | C8h |
423
+ | _TAN | C9h |
424
+ | _ASN | CAh |
425
+ | _ACS | CBh |
426
+ | _ATN | CCh |
427
+ | _LN | CDh |
428
+ | _EXP | CEh |
429
+ | _INT | CFh |
430
+ | _SQR | D0h |
431
+ | _SGN | D1h |
432
+ | _ABS | D2h |
433
+ | _PEEK | D3h |
434
+ | _USR | D4h |
435
+ | _STR$ | D5h |
436
+ | _CHR$ | D6h |
437
+ | _NOT | D7h |
438
+ | _PWR | D8h |
439
+ | _OR | D9h |
440
+ | _AND | DAh |
441
+ | _LESS | DBh |
442
+ | _GREATER | DCh |
443
+ | _NOT_EQUAL | DDh |
444
+ | _THEN | DEh |
445
+ | _TO | DFh |
446
+ | _STEP | E0h |
447
+ | _LPRINT | E1h |
448
+ | _LLIST | E2h |
449
+ | _STOP | E3h |
450
+ | _SLOW | E4h |
451
+ | _FAST | E5h |
452
+ | _NEW | E6h |
453
+ | _SCROLL | E7h |
454
+ | _CONT | E8h |
455
+ | _DIM | E9h |
456
+ | _REM | EAh |
457
+ | _FOR | EBh |
458
+ | _GOTO | ECh |
459
+ | _GOSUB | EDh |
460
+ | _INPUT | EEh |
461
+ | _LOAD | EFh |
462
+ | _LIST | F0h |
463
+ | _LET | F1h |
464
+ | _PAUSE | F2h |
465
+ | _NEXT | F3h |
466
+ | _POKE | F4h |
467
+ | _PRINT | F5h |
468
+ | _PLOT | F6h |
469
+ | _RUN | F7h |
470
+ | _SAVE | F8h |
471
+ | _RAND | F9h |
472
+ | _IF | FAh |
473
+ | _CLS | FBh |
474
+ | _UNPLOT | FCh |
475
+ | _CLEAR | FDh |
476
+ | _RETURN | FEh |
477
+ | _COPY | FFh |
478
+
479
+ ### byte Directive
480
+
481
+ The `byte` directive defines a sequence of bytes and their values. The values are separated by commas and can be expressions, characters or strings.
482
+ The formats are the following:
483
+
484
+ ```
485
+ [label] byte expression [, expression ...]
486
+ [label] .byte expression [, expression ...]
487
+ [label] db expression [, expression ...]
488
+ [label] dm expression [, expression ...]
489
+ [label] defb expression [, expression ...]
490
+ [label] defm expression [, expression ...]
491
+ ```
492
+
493
+ Examples:
494
+
495
+ ```
496
+ label1:
497
+ byte 'a', $76, "TEST", _NL
498
+ ```
499
+
500
+ ### word Directive
501
+
502
+ The `word` directive defines a sequence of 16-bit words and their values.
503
+ The values are separated by commas and can be expressions.
504
+ They are stored in little-endian format with the least significant byte first, followed by the most significant byte.
505
+ The formats are the following:
506
+
507
+ ```
508
+ [label] word expression [, expression ...]
509
+ [label] .word expression [, expression ...]
510
+ [label] dw expression [, expression ...]
511
+ [label] defw expression [, expression ...]
512
+ ```
513
+
514
+ Examples:
515
+
516
+ ```
517
+ label1:
518
+ word 0xABCD, %0100002000000000
519
+ ```
520
+
521
+ ### block Directive
522
+
523
+ The `block` directive defines a sequence of bytes that are filled with the same value. The formats are the following:
524
+
525
+ ```
526
+ [label] block expression [, expression]
527
+ [label] .block expression [, expression]
528
+ [label] ds expression [, expression]
529
+ [label] defs expression [, expression]
530
+ ```
531
+
532
+ The first expression gives the number of bytes, the second and optional expression gives the value to used to fill the bytes.
533
+ If this value is omitted, the block is filled with zeros.
534
+
535
+ ### end Directive
536
+
537
+ The `end` directive stopped the generation of the binary. It is optional. If it is omitted, the generation stops at the end of the file.
538
+
539
+ ## Comments
540
+
541
+ Comments begin with a semicolon (`;`) or two slashes (`//`). The rest of the line from the semicolon to the end of the line is ignored.
542
+
543
+
544
+ ## Limitations
545
+
546
+ * No support for non-official Z80 opcodes.
547
+ * No support for fake instructions like `LD BC, DE`. The actual corresponding opcodes are `LD B, D` and `LD C, E`.
548
+ * No support for structures.
549
+ * No support for conditional assembly and macros.
550
+ * Each instruction has to be on a separate line.
551
+ * It is not allowed to declare labels with the same name as an instruction. So, for example, `ld` is not an allowed name for a label.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file