@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.
- package/.editorconfig +13 -0
- package/.eslintignore +3 -0
- package/.eslintrc.json +35 -0
- package/.github/workflows/node.js.yml +47 -0
- package/.prettierignore +3 -0
- package/.prettierrc +3 -0
- package/.vscode/extensions.json +7 -0
- package/README.md +53 -27
- package/apps/.gitkeep +0 -0
- package/apps/z80-assembler-app/.eslintrc.json +18 -0
- package/apps/z80-assembler-app/index.html +16 -0
- package/apps/z80-assembler-app/postcss.config.js +24 -0
- package/apps/z80-assembler-app/project.json +70 -0
- 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 +25 -0
- package/apps/z80-assembler-app/public/robots.txt +3 -0
- package/apps/z80-assembler-app/src/app/app.module.css +0 -0
- package/apps/z80-assembler-app/src/app/app.tsx +122 -0
- package/apps/z80-assembler-app/src/app/binary.tsx +39 -0
- package/apps/z80-assembler-app/src/app/editor.tsx +228 -0
- package/apps/z80-assembler-app/src/app/errors.tsx +31 -0
- package/apps/z80-assembler-app/src/app/footer.tsx +20 -0
- package/apps/z80-assembler-app/src/app/header.tsx +57 -0
- package/apps/z80-assembler-app/src/app/misc.ts +13 -0
- package/apps/z80-assembler-app/src/app/opcodes.tsx +335 -0
- 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 +22 -0
- package/apps/z80-assembler-app/src/styles.css +8 -0
- package/apps/z80-assembler-app/tailwind.config.js +28 -0
- package/apps/z80-assembler-app/tsconfig.app.json +22 -0
- package/apps/z80-assembler-app/tsconfig.json +21 -0
- package/apps/z80-assembler-app/tsconfig.spec.json +23 -0
- package/apps/z80-assembler-app/vite.config.ts +64 -0
- 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 +551 -0
- 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 +18 -0
- package/libs/z80-assembler/package.json +20 -0
- package/libs/z80-assembler/project.json +35 -0
- package/{CHANGELOG.md → libs/z80-assembler/public/CHANGELOG.md} +5 -1
- package/libs/z80-assembler/public/README.md +54 -0
- package/{index.d.ts → libs/z80-assembler/src/index.ts} +1 -1
- package/libs/z80-assembler/src/lib/assets/code/basic-end.zx81 +4 -0
- package/libs/z80-assembler/src/lib/assets/code/basic-line1.zx81 +4 -0
- package/libs/z80-assembler/src/lib/assets/code/basic-line2.zx81 +9 -0
- package/libs/z80-assembler/src/lib/assets/code/characters.zx81 +190 -0
- package/libs/z80-assembler/src/lib/assets/code/display.zx81 +50 -0
- package/libs/z80-assembler/src/lib/assets/code/system-variables.zx81 +46 -0
- package/{lib/compiler/Assets.d.ts → libs/z80-assembler/src/lib/compiler/Assets.ts} +6 -1
- package/libs/z80-assembler/src/lib/compiler/Ast.ts +545 -0
- package/libs/z80-assembler/src/lib/compiler/Compiler.test.ts +2141 -0
- package/libs/z80-assembler/src/lib/compiler/Compiler.ts +185 -0
- package/libs/z80-assembler/src/lib/compiler/Formatter.ts +43 -0
- package/libs/z80-assembler/src/lib/compiler/Generator.ts +255 -0
- package/libs/z80-assembler/src/lib/compiler/Labels.ts +165 -0
- package/libs/z80-assembler/src/lib/grammar/LowLevel.ts +163 -0
- package/libs/z80-assembler/src/lib/grammar/Parse.ts +128 -0
- package/libs/z80-assembler/src/lib/grammar/z80.peg +1252 -0
- package/libs/z80-assembler/src/lib/grammar/z80.ts +10649 -0
- package/libs/z80-assembler/src/lib/types/Error.ts +105 -0
- package/{lib/types/Types.d.ts → libs/z80-assembler/src/lib/types/Types.ts} +26 -11
- package/libs/z80-assembler/tsconfig.json +23 -0
- package/libs/z80-assembler/tsconfig.lib.json +10 -0
- package/libs/z80-assembler/tsconfig.spec.json +19 -0
- package/libs/z80-assembler/vite.config.ts +58 -0
- package/nx.json +57 -0
- package/package.json +52 -14
- package/tsconfig.base.json +22 -0
- package/index.js +0 -312
- package/index.mjs +0 -6441
- package/lib/compiler/Ast.d.ts +0 -210
- package/lib/compiler/Compiler.d.ts +0 -53
- package/lib/compiler/Formatter.d.ts +0 -23
- package/lib/compiler/Generator.d.ts +0 -40
- package/lib/compiler/Labels.d.ts +0 -47
- package/lib/grammar/LowLevel.d.ts +0 -68
- package/lib/grammar/Parse.d.ts +0 -48
- package/lib/grammar/z80.d.ts +0 -2938
- package/lib/types/Error.d.ts +0 -62
package/docs/assembly.md
ADDED
|
@@ -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 |  | 00h | | _ | |  | 80h |
|
|
115
|
+
| " | 22h |  | 0Bh | | | | | |
|
|
116
|
+
| £ | A3h |  | 0Ch | | | | | |
|
|
117
|
+
| $ | 24h |  | 0Dh | | | | | |
|
|
118
|
+
| : | 3Ah |  | 0Eh | | | | | |
|
|
119
|
+
| ? | 3Fh |  | 0Fh | | | | | |
|
|
120
|
+
| ( | 28h |  | 10h | | | | | |
|
|
121
|
+
| ) | 29h |  | 11h | | | | | |
|
|
122
|
+
| > | 3Ch |  | 12h | | | | | |
|
|
123
|
+
| < | 3Eh |  | 13h | | | | | |
|
|
124
|
+
| = | 3Dh |  | 14h | | | | | |
|
|
125
|
+
| + | 2Bh |  | 15h | | | | | |
|
|
126
|
+
| - | 2Dh |  | 16h | | | | | |
|
|
127
|
+
| * | 2Ah |  | 17h | | | | | |
|
|
128
|
+
| / | 2Fh |  | 18h | | | | | |
|
|
129
|
+
| ; | 3Bh |  | 19h | | | | | |
|
|
130
|
+
| , | 2Ch |  | 1Ah | | | | | |
|
|
131
|
+
| . | 2Eh |  | 1Bh | | | | | |
|
|
132
|
+
| 0 | 30h |  | 1Ch | | | | | |
|
|
133
|
+
| 1 | 31h |  | 1Dh | | | | | |
|
|
134
|
+
| 2 | 32h |  | 1Eh | | | | | |
|
|
135
|
+
| 3 | 33h |  | 1Fh | | | | | |
|
|
136
|
+
| 4 | 34h |  | 20h | | | | | |
|
|
137
|
+
| 5 | 35h |  | 21h | | | | | |
|
|
138
|
+
| 6 | 36h |  | 22h | | | | | |
|
|
139
|
+
| 7 | 37h |  | 23h | | | | | |
|
|
140
|
+
| 8 | 38h |  | 24h | | | | | |
|
|
141
|
+
| 9 | 39h |  | 25h | | | | | |
|
|
142
|
+
| A | 31h |  | 26h | | a | 61h |  | A6h |
|
|
143
|
+
| B | 32h |  | 27h | | b | 62h |  | A7h |
|
|
144
|
+
| C | 33h |  | 28h | | c | 63h |  | A8h |
|
|
145
|
+
| D | 34h |  | 29h | | d | 64h |  | A9h |
|
|
146
|
+
| E | 35h |  | 2Ah | | e | 65h |  | AAh |
|
|
147
|
+
| F | 36h |  | 2Bh | | f | 66h |  | ABh |
|
|
148
|
+
| G | 37h |  | 2Ch | | g | 67h |  | ACh |
|
|
149
|
+
| H | 38h |  | 2Dh | | h | 68h |  | ADh |
|
|
150
|
+
| I | 39h |  | 2Eh | | i | 69h |  | AEh |
|
|
151
|
+
| J | 3Ah |  | 2Fh | | j | 6Ah |  | AFh |
|
|
152
|
+
| K | 3Bh |  | 30h | | k | 6Bh |  | B0h |
|
|
153
|
+
| L | 3Ch |  | 31h | | l | 6Ch |  | B1h |
|
|
154
|
+
| M | 3Dh |  | 32h | | m | 6Dh |  | B2h |
|
|
155
|
+
| N | 3Eh |  | 33h | | n | 6Eh |  | B3h |
|
|
156
|
+
| O | 3Fh |  | 34h | | o | 6Fh |  | B4h |
|
|
157
|
+
| P | 50h |  | 35h | | p | 70h |  | B5h |
|
|
158
|
+
| Q | 51h |  | 36h | | q | 71h |  | B6h |
|
|
159
|
+
| R | 52h |  | 37h | | r | 72h |  | B7h |
|
|
160
|
+
| S | 53h |  | 38h | | s | 73h |  | B8h |
|
|
161
|
+
| T | 54h |  | 39h | | t | 74h |  | B9h |
|
|
162
|
+
| U | 55h |  | 3Ah | | u | 75h |  | BAh |
|
|
163
|
+
| V | 56h |  | 3Bh | | v | 76h |  | BBh |
|
|
164
|
+
| W | 57h |  | 3Ch | | w | 77h |  | BCh |
|
|
165
|
+
| X | 58h |  | 3Dh | | x | 78h |  | BDh |
|
|
166
|
+
| Y | 59h |  | 3Eh | | y | 79h |  | BEh |
|
|
167
|
+
| Z | 5Ah |  | 3Fh | | z | 7Ah |  | 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 |  | | | | |
|
|
339
|
+
| _SPC | 00h |  | | _SPCV | 80h |  |
|
|
340
|
+
| _DQT | 0bh |  | | _DQTV | 8bh |  |
|
|
341
|
+
| _PND | 0ch |  | | _PNDV | 8ch |  |
|
|
342
|
+
| _DLR | 0dh |  | | _DLRV | 8dh |  |
|
|
343
|
+
| _CLN | 0eh |  | | _CLNV | 8eh |  |
|
|
344
|
+
| _QMK | 0fh |  | | _QMKV | 8fh |  |
|
|
345
|
+
| _OBR | 10h |  | | _OBRV | 90h |  |
|
|
346
|
+
| _CBR | 11h |  | | _CBRV | 91h |  |
|
|
347
|
+
| _GTH | 12h |  | | _GTHV | 92h |  |
|
|
348
|
+
| _LTH | 13h |  | | _LTHV | 93h |  |
|
|
349
|
+
| _EQU | 14h |  | | _EQUV | 94h |  |
|
|
350
|
+
| _PLS | 15h |  | | _PLSV | 95h |  |
|
|
351
|
+
| _MNS | 16h |  | | _MNSV | 96h |  |
|
|
352
|
+
| _ASK | 17h |  | | _ASKV | 97h |  |
|
|
353
|
+
| _SLS | 18h |  | | _SLSV | 98h |  |
|
|
354
|
+
| _SMC | 19h |  | | _SMCV | 99h |  |
|
|
355
|
+
| _CMA | 1ah |  | | _CMAV | 9ah |  |
|
|
356
|
+
| _FST | 1bh |  | | _FSTV | 9bh |  |
|
|
357
|
+
| _0 | 1ch |  | | _0V | 9ch |  |
|
|
358
|
+
| _1 | 1dh |  | | _1V | 9dh |  |
|
|
359
|
+
| _2 | 1eh |  | | _2V | 9eh |  |
|
|
360
|
+
| _3 | 1fh |  | | _3V | 9fh |  |
|
|
361
|
+
| _4 | 20h |  | | _4V | a0h |  |
|
|
362
|
+
| _5 | 21h |  | | _5V | a1h |  |
|
|
363
|
+
| _6 | 22h |  | | _6V | a2h |  |
|
|
364
|
+
| _7 | 23h |  | | _7V | a3h |  |
|
|
365
|
+
| _8 | 24h |  | | _8V | a4h |  |
|
|
366
|
+
| _9 | 25h |  | | _9V | a5h |  |
|
|
367
|
+
| _A | 26h |  | | _AV | a6h |  |
|
|
368
|
+
| _B | 27h |  | | _BV | a7h |  |
|
|
369
|
+
| _C | 28h |  | | _CV | a8h |  |
|
|
370
|
+
| _D | 29h |  | | _DV | a9h |  |
|
|
371
|
+
| _E | 2ah |  | | _EV | aah |  |
|
|
372
|
+
| _F | 2bh |  | | _FV | abh |  |
|
|
373
|
+
| _G | 2ch |  | | _GV | ach |  |
|
|
374
|
+
| _H | 2dh |  | | _HV | adh |  |
|
|
375
|
+
| _I | 2eh |  | | _IV | aeh |  |
|
|
376
|
+
| _J | 2fh |  | | _JV | afh |  |
|
|
377
|
+
| _K | 30h |  | | _KV | b0h |  |
|
|
378
|
+
| _L | 31h |  | | _LV | b1h |  |
|
|
379
|
+
| _M | 32h |  | | _MV | b2h |  |
|
|
380
|
+
| _N | 33h |  | | _NV | b3h |  |
|
|
381
|
+
| _O | 34h |  | | _OV | b4h |  |
|
|
382
|
+
| _P | 35h |  | | _PV | b5h |  |
|
|
383
|
+
| _Q | 36h |  | | _QV | b6h |  |
|
|
384
|
+
| _R | 37h |  | | _RV | b7h |  |
|
|
385
|
+
| _S | 38h |  | | _SV | b8h |  |
|
|
386
|
+
| _T | 39h |  | | _TV | b9h |  |
|
|
387
|
+
| _U | 3ah |  | | _UV | bah |  |
|
|
388
|
+
| _V | 3bh |  | | _VV | bbh |  |
|
|
389
|
+
| _W | 3ch |  | | _WV | bch |  |
|
|
390
|
+
| _X | 3dh |  | | _XV | bdh |  |
|
|
391
|
+
| _Y | 3eh |  | | _YV | beh |  |
|
|
392
|
+
| _Z | 3fh |  | | _ZV | bfh |  |
|
|
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
|