@asm198x/z80 0.1.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/LICENSE +340 -0
- package/README.md +99 -0
- package/asm198x_web.d.ts +98 -0
- package/asm198x_web.js +335 -0
- package/asm198x_web_bg.wasm +0 -0
- package/package.json +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 2, June 1991
|
|
3
|
+
|
|
4
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
|
5
|
+
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
7
|
+
of this license document, but changing it is not allowed.
|
|
8
|
+
|
|
9
|
+
Preamble
|
|
10
|
+
|
|
11
|
+
The licenses for most software are designed to take away your
|
|
12
|
+
freedom to share and change it. By contrast, the GNU General Public
|
|
13
|
+
License is intended to guarantee your freedom to share and change free
|
|
14
|
+
software--to make sure the software is free for all its users. This
|
|
15
|
+
General Public License applies to most of the Free Software
|
|
16
|
+
Foundation's software and to any other program whose authors commit to
|
|
17
|
+
using it. (Some other Free Software Foundation software is covered by
|
|
18
|
+
the GNU Library General Public License instead.) You can apply it to
|
|
19
|
+
your programs, too.
|
|
20
|
+
|
|
21
|
+
When we speak of free software, we are referring to freedom, not
|
|
22
|
+
price. Our General Public Licenses are designed to make sure that you
|
|
23
|
+
have the freedom to distribute copies of free software (and charge for
|
|
24
|
+
this service if you wish), that you receive source code or can get it
|
|
25
|
+
if you want it, that you can change the software or use pieces of it
|
|
26
|
+
in new free programs; and that you know you can do these things.
|
|
27
|
+
|
|
28
|
+
To protect your rights, we need to make restrictions that forbid
|
|
29
|
+
anyone to deny you these rights or to ask you to surrender the rights.
|
|
30
|
+
These restrictions translate to certain responsibilities for you if you
|
|
31
|
+
distribute copies of the software, or if you modify it.
|
|
32
|
+
|
|
33
|
+
For example, if you distribute copies of such a program, whether
|
|
34
|
+
gratis or for a fee, you must give the recipients all the rights that
|
|
35
|
+
you have. You must make sure that they, too, receive or can get the
|
|
36
|
+
source code. And you must show them these terms so they know their
|
|
37
|
+
rights.
|
|
38
|
+
|
|
39
|
+
We protect your rights with two steps: (1) copyright the software, and
|
|
40
|
+
(2) offer you this license which gives you legal permission to copy,
|
|
41
|
+
distribute and/or modify the software.
|
|
42
|
+
|
|
43
|
+
Also, for each author's protection and ours, we want to make certain
|
|
44
|
+
that everyone understands that there is no warranty for this free
|
|
45
|
+
software. If the software is modified by someone else and passed on, we
|
|
46
|
+
want its recipients to know that what they have is not the original, so
|
|
47
|
+
that any problems introduced by others will not reflect on the original
|
|
48
|
+
authors' reputations.
|
|
49
|
+
|
|
50
|
+
Finally, any free program is threatened constantly by software
|
|
51
|
+
patents. We wish to avoid the danger that redistributors of a free
|
|
52
|
+
program will individually obtain patent licenses, in effect making the
|
|
53
|
+
program proprietary. To prevent this, we have made it clear that any
|
|
54
|
+
patent must be licensed for everyone's free use or not licensed at all.
|
|
55
|
+
|
|
56
|
+
The precise terms and conditions for copying, distribution and
|
|
57
|
+
modification follow.
|
|
58
|
+
|
|
59
|
+
GNU GENERAL PUBLIC LICENSE
|
|
60
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
61
|
+
|
|
62
|
+
0. This License applies to any program or other work which contains
|
|
63
|
+
a notice placed by the copyright holder saying it may be distributed
|
|
64
|
+
under the terms of this General Public License. The "Program", below,
|
|
65
|
+
refers to any such program or work, and a "work based on the Program"
|
|
66
|
+
means either the Program or any derivative work under copyright law:
|
|
67
|
+
that is to say, a work containing the Program or a portion of it,
|
|
68
|
+
either verbatim or with modifications and/or translated into another
|
|
69
|
+
language. (Hereinafter, translation is included without limitation in
|
|
70
|
+
the term "modification".) Each licensee is addressed as "you".
|
|
71
|
+
|
|
72
|
+
Activities other than copying, distribution and modification are not
|
|
73
|
+
covered by this License; they are outside its scope. The act of
|
|
74
|
+
running the Program is not restricted, and the output from the Program
|
|
75
|
+
is covered only if its contents constitute a work based on the
|
|
76
|
+
Program (independent of having been made by running the Program).
|
|
77
|
+
Whether that is true depends on what the Program does.
|
|
78
|
+
|
|
79
|
+
1. You may copy and distribute verbatim copies of the Program's
|
|
80
|
+
source code as you receive it, in any medium, provided that you
|
|
81
|
+
conspicuously and appropriately publish on each copy an appropriate
|
|
82
|
+
copyright notice and disclaimer of warranty; keep intact all the
|
|
83
|
+
notices that refer to this License and to the absence of any warranty;
|
|
84
|
+
and give any other recipients of the Program a copy of this License
|
|
85
|
+
along with the Program.
|
|
86
|
+
|
|
87
|
+
You may charge a fee for the physical act of transferring a copy, and
|
|
88
|
+
you may at your option offer warranty protection in exchange for a fee.
|
|
89
|
+
|
|
90
|
+
2. You may modify your copy or copies of the Program or any portion
|
|
91
|
+
of it, thus forming a work based on the Program, and copy and
|
|
92
|
+
distribute such modifications or work under the terms of Section 1
|
|
93
|
+
above, provided that you also meet all of these conditions:
|
|
94
|
+
|
|
95
|
+
a) You must cause the modified files to carry prominent notices
|
|
96
|
+
stating that you changed the files and the date of any change.
|
|
97
|
+
|
|
98
|
+
b) You must cause any work that you distribute or publish, that in
|
|
99
|
+
whole or in part contains or is derived from the Program or any
|
|
100
|
+
part thereof, to be licensed as a whole at no charge to all third
|
|
101
|
+
parties under the terms of this License.
|
|
102
|
+
|
|
103
|
+
c) If the modified program normally reads commands interactively
|
|
104
|
+
when run, you must cause it, when started running for such
|
|
105
|
+
interactive use in the most ordinary way, to print or display an
|
|
106
|
+
announcement including an appropriate copyright notice and a
|
|
107
|
+
notice that there is no warranty (or else, saying that you provide
|
|
108
|
+
a warranty) and that users may redistribute the program under
|
|
109
|
+
these conditions, and telling the user how to view a copy of this
|
|
110
|
+
License. (Exception: if the Program itself is interactive but
|
|
111
|
+
does not normally print such an announcement, your work based on
|
|
112
|
+
the Program is not required to print an announcement.)
|
|
113
|
+
|
|
114
|
+
These requirements apply to the modified work as a whole. If
|
|
115
|
+
identifiable sections of that work are not derived from the Program,
|
|
116
|
+
and can be reasonably considered independent and separate works in
|
|
117
|
+
themselves, then this License, and its terms, do not apply to those
|
|
118
|
+
sections when you distribute them as separate works. But when you
|
|
119
|
+
distribute the same sections as part of a whole which is a work based
|
|
120
|
+
on the Program, the distribution of the whole must be on the terms of
|
|
121
|
+
this License, whose permissions for other licensees extend to the
|
|
122
|
+
entire whole, and thus to each and every part regardless of who wrote it.
|
|
123
|
+
|
|
124
|
+
Thus, it is not the intent of this section to claim rights or contest
|
|
125
|
+
your rights to work written entirely by you; rather, the intent is to
|
|
126
|
+
exercise the right to control the distribution of derivative or
|
|
127
|
+
collective works based on the Program.
|
|
128
|
+
|
|
129
|
+
In addition, mere aggregation of another work not based on the Program
|
|
130
|
+
with the Program (or with a work based on the Program) on a volume of
|
|
131
|
+
a storage or distribution medium does not bring the other work under
|
|
132
|
+
the scope of this License.
|
|
133
|
+
|
|
134
|
+
3. You may copy and distribute the Program (or a work based on it,
|
|
135
|
+
under Section 2) in object code or executable form under the terms of
|
|
136
|
+
Sections 1 and 2 above provided that you also do one of the following:
|
|
137
|
+
|
|
138
|
+
a) Accompany it with the complete corresponding machine-readable
|
|
139
|
+
source code, which must be distributed under the terms of Sections
|
|
140
|
+
1 and 2 above on a medium customarily used for software interchange; or,
|
|
141
|
+
|
|
142
|
+
b) Accompany it with a written offer, valid for at least three
|
|
143
|
+
years, to give any third party, for a charge no more than your
|
|
144
|
+
cost of physically performing source distribution, a complete
|
|
145
|
+
machine-readable copy of the corresponding source code, to be
|
|
146
|
+
distributed under the terms of Sections 1 and 2 above on a medium
|
|
147
|
+
customarily used for software interchange; or,
|
|
148
|
+
|
|
149
|
+
c) Accompany it with the information you received as to the offer
|
|
150
|
+
to distribute corresponding source code. (This alternative is
|
|
151
|
+
allowed only for noncommercial distribution and only if you
|
|
152
|
+
received the program in object code or executable form with such
|
|
153
|
+
an offer, in accord with Subsection b above.)
|
|
154
|
+
|
|
155
|
+
The source code for a work means the preferred form of the work for
|
|
156
|
+
making modifications to it. For an executable work, complete source
|
|
157
|
+
code means all the source code for all modules it contains, plus any
|
|
158
|
+
associated interface definition files, plus the scripts used to
|
|
159
|
+
control compilation and installation of the executable. However, as a
|
|
160
|
+
special exception, the source code distributed need not include
|
|
161
|
+
anything that is normally distributed (in either source or binary
|
|
162
|
+
form) with the major components (compiler, kernel, and so on) of the
|
|
163
|
+
operating system on which the executable runs, unless that component
|
|
164
|
+
itself accompanies the executable.
|
|
165
|
+
|
|
166
|
+
If distribution of executable or object code is made by offering
|
|
167
|
+
access to copy from a designated place, then offering equivalent
|
|
168
|
+
access to copy the source code from the same place counts as
|
|
169
|
+
distribution of the source code, even though third parties are not
|
|
170
|
+
compelled to copy the source along with the object code.
|
|
171
|
+
|
|
172
|
+
4. You may not copy, modify, sublicense, or distribute the Program
|
|
173
|
+
except as expressly provided under this License. Any attempt
|
|
174
|
+
otherwise to copy, modify, sublicense or distribute the Program is
|
|
175
|
+
void, and will automatically terminate your rights under this License.
|
|
176
|
+
However, parties who have received copies, or rights, from you under
|
|
177
|
+
this License will not have their licenses terminated so long as such
|
|
178
|
+
parties remain in full compliance.
|
|
179
|
+
|
|
180
|
+
5. You are not required to accept this License, since you have not
|
|
181
|
+
signed it. However, nothing else grants you permission to modify or
|
|
182
|
+
distribute the Program or its derivative works. These actions are
|
|
183
|
+
prohibited by law if you do not accept this License. Therefore, by
|
|
184
|
+
modifying or distributing the Program (or any work based on the
|
|
185
|
+
Program), you indicate your acceptance of this License to do so, and
|
|
186
|
+
all its terms and conditions for copying, distributing or modifying
|
|
187
|
+
the Program or works based on it.
|
|
188
|
+
|
|
189
|
+
6. Each time you redistribute the Program (or any work based on the
|
|
190
|
+
Program), the recipient automatically receives a license from the
|
|
191
|
+
original licensor to copy, distribute or modify the Program subject to
|
|
192
|
+
these terms and conditions. You may not impose any further
|
|
193
|
+
restrictions on the recipients' exercise of the rights granted herein.
|
|
194
|
+
You are not responsible for enforcing compliance by third parties to
|
|
195
|
+
this License.
|
|
196
|
+
|
|
197
|
+
7. If, as a consequence of a court judgment or allegation of patent
|
|
198
|
+
infringement or for any other reason (not limited to patent issues),
|
|
199
|
+
conditions are imposed on you (whether by court order, agreement or
|
|
200
|
+
otherwise) that contradict the conditions of this License, they do not
|
|
201
|
+
excuse you from the conditions of this License. If you cannot
|
|
202
|
+
distribute so as to satisfy simultaneously your obligations under this
|
|
203
|
+
License and any other pertinent obligations, then as a consequence you
|
|
204
|
+
may not distribute the Program at all. For example, if a patent
|
|
205
|
+
license would not permit royalty-free redistribution of the Program by
|
|
206
|
+
all those who receive copies directly or indirectly through you, then
|
|
207
|
+
the only way you could satisfy both it and this License would be to
|
|
208
|
+
refrain entirely from distribution of the Program.
|
|
209
|
+
|
|
210
|
+
If any portion of this section is held invalid or unenforceable under
|
|
211
|
+
any particular circumstance, the balance of the section is intended to
|
|
212
|
+
apply and the section as a whole is intended to apply in other
|
|
213
|
+
circumstances.
|
|
214
|
+
|
|
215
|
+
It is not the purpose of this section to induce you to infringe any
|
|
216
|
+
patents or other property right claims or to contest validity of any
|
|
217
|
+
such claims; this section has the sole purpose of protecting the
|
|
218
|
+
integrity of the free software distribution system, which is
|
|
219
|
+
implemented by public license practices. Many people have made
|
|
220
|
+
generous contributions to the wide range of software distributed
|
|
221
|
+
through that system in reliance on consistent application of that
|
|
222
|
+
system; it is up to the author/donor to decide if he or she is willing
|
|
223
|
+
to distribute software through any other system and a licensee cannot
|
|
224
|
+
impose that choice.
|
|
225
|
+
|
|
226
|
+
This section is intended to make thoroughly clear what is believed to
|
|
227
|
+
be a consequence of the rest of this License.
|
|
228
|
+
|
|
229
|
+
8. If the distribution and/or use of the Program is restricted in
|
|
230
|
+
certain countries either by patents or by copyrighted interfaces, the
|
|
231
|
+
original copyright holder who places the Program under this License
|
|
232
|
+
may add an explicit geographical distribution limitation excluding
|
|
233
|
+
those countries, so that distribution is permitted only in or among
|
|
234
|
+
countries not thus excluded. In such case, this License incorporates
|
|
235
|
+
the limitation as if written in the body of this License.
|
|
236
|
+
|
|
237
|
+
9. The Free Software Foundation may publish revised and/or new versions
|
|
238
|
+
of the General Public License from time to time. Such new versions will
|
|
239
|
+
be similar in spirit to the present version, but may differ in detail to
|
|
240
|
+
address new problems or concerns.
|
|
241
|
+
|
|
242
|
+
Each version is given a distinguishing version number. If the Program
|
|
243
|
+
specifies a version number of this License which applies to it and "any
|
|
244
|
+
later version", you have the option of following the terms and conditions
|
|
245
|
+
either of that version or of any later version published by the Free
|
|
246
|
+
Software Foundation. If the Program does not specify a version number of
|
|
247
|
+
this License, you may choose any version ever published by the Free Software
|
|
248
|
+
Foundation.
|
|
249
|
+
|
|
250
|
+
10. If you wish to incorporate parts of the Program into other free
|
|
251
|
+
programs whose distribution conditions are different, write to the author
|
|
252
|
+
to ask for permission. For software which is copyrighted by the Free
|
|
253
|
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
|
254
|
+
make exceptions for this. Our decision will be guided by the two goals
|
|
255
|
+
of preserving the free status of all derivatives of our free software and
|
|
256
|
+
of promoting the sharing and reuse of software generally.
|
|
257
|
+
|
|
258
|
+
NO WARRANTY
|
|
259
|
+
|
|
260
|
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
|
261
|
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
|
262
|
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
|
263
|
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
|
264
|
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
265
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
|
266
|
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
|
267
|
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
|
268
|
+
REPAIR OR CORRECTION.
|
|
269
|
+
|
|
270
|
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
271
|
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
|
272
|
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
|
273
|
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
|
274
|
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
|
275
|
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
|
276
|
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
277
|
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
|
278
|
+
POSSIBILITY OF SUCH DAMAGES.
|
|
279
|
+
|
|
280
|
+
END OF TERMS AND CONDITIONS
|
|
281
|
+
|
|
282
|
+
How to Apply These Terms to Your New Programs
|
|
283
|
+
|
|
284
|
+
If you develop a new program, and you want it to be of the greatest
|
|
285
|
+
possible use to the public, the best way to achieve this is to make it
|
|
286
|
+
free software which everyone can redistribute and change under these terms.
|
|
287
|
+
|
|
288
|
+
To do so, attach the following notices to the program. It is safest
|
|
289
|
+
to attach them to the start of each source file to most effectively
|
|
290
|
+
convey the exclusion of warranty; and each file should have at least
|
|
291
|
+
the "copyright" line and a pointer to where the full notice is found.
|
|
292
|
+
|
|
293
|
+
<one line to give the program's name and a brief idea of what it does.>
|
|
294
|
+
Copyright (C) 19yy <name of author>
|
|
295
|
+
|
|
296
|
+
This program is free software; you can redistribute it and/or modify
|
|
297
|
+
it under the terms of the GNU General Public License as published by
|
|
298
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
299
|
+
(at your option) any later version.
|
|
300
|
+
|
|
301
|
+
This program is distributed in the hope that it will be useful,
|
|
302
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
303
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
304
|
+
GNU General Public License for more details.
|
|
305
|
+
|
|
306
|
+
You should have received a copy of the GNU General Public License
|
|
307
|
+
along with this program; if not, write to the Free Software
|
|
308
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
Also add information on how to contact you by electronic and paper mail.
|
|
312
|
+
|
|
313
|
+
If the program is interactive, make it output a short notice like this
|
|
314
|
+
when it starts in an interactive mode:
|
|
315
|
+
|
|
316
|
+
Gnomovision version 69, Copyright (C) 19yy name of author
|
|
317
|
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
318
|
+
This is free software, and you are welcome to redistribute it
|
|
319
|
+
under certain conditions; type `show c' for details.
|
|
320
|
+
|
|
321
|
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
322
|
+
parts of the General Public License. Of course, the commands you use may
|
|
323
|
+
be called something other than `show w' and `show c'; they could even be
|
|
324
|
+
mouse-clicks or menu items--whatever suits your program.
|
|
325
|
+
|
|
326
|
+
You should also get your employer (if you work as a programmer) or your
|
|
327
|
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
|
328
|
+
necessary. Here is a sample; alter the names:
|
|
329
|
+
|
|
330
|
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
|
331
|
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
|
332
|
+
|
|
333
|
+
<signature of Ty Coon>, 1 April 1989
|
|
334
|
+
Ty Coon, President of Vice
|
|
335
|
+
|
|
336
|
+
This General Public License does not permit incorporating your program into
|
|
337
|
+
proprietary programs. If your program is a subroutine library, you may
|
|
338
|
+
consider it more useful to permit linking proprietary applications with the
|
|
339
|
+
library. If this is what you want to do, use the GNU Library General
|
|
340
|
+
Public License instead of this License.
|
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# asm198x-web
|
|
2
|
+
|
|
3
|
+
The [asm198x](https://github.com/asm198x/asm198x) assembler compiled to
|
|
4
|
+
WebAssembly, with a `wasm-bindgen` surface a web page can call. Nothing is
|
|
5
|
+
uploaded anywhere: the assembler runs in the visitor's tab.
|
|
6
|
+
|
|
7
|
+
Published to npm as **`@asm198x/web`**; `scripts/build-npm.sh` builds it. The
|
|
8
|
+
crate itself stays off crates.io: a `wasm-bindgen` surface returning JavaScript
|
|
9
|
+
values has no Rust caller.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @asm198x/web
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Surface
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import init, { assemble, snapshot, listing, dialects } from '@asm198x/web';
|
|
19
|
+
|
|
20
|
+
await init();
|
|
21
|
+
|
|
22
|
+
const result = JSON.parse(assemble('sjasmplus', ' org 32768\n ld a,1\n ret\n'));
|
|
23
|
+
if (Array.isArray(result)) {
|
|
24
|
+
// The diagnostics array: `result[0].message`, `result[0].span.line`.
|
|
25
|
+
} else {
|
|
26
|
+
// The `AssemblyResult` object: `result.bytes`, `result.origin`, `result.symbols`.
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
listing('acme', '*=$c000\n lda #1\n rts\n'); // the `--listing` text, or null
|
|
30
|
+
JSON.parse(dialects()); // [{ name, aliases, blurb }, …]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`assemble` returns the string `asm198x --message-format=json` prints, so the
|
|
34
|
+
[CLI reference](https://asm198x.github.io/docs/cli/) documents the shape.
|
|
35
|
+
It returns `null` for a dialect name the table does not list.
|
|
36
|
+
|
|
37
|
+
One source file per call; an `include` reports "file not found" as a
|
|
38
|
+
diagnostic. The CLI's `--cpu` switch (sjasmplus for the Spectrum Next) is not
|
|
39
|
+
exposed yet.
|
|
40
|
+
|
|
41
|
+
## Build
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
wasm-pack build --target web crates/asm198x-web --out-dir pkg-web
|
|
45
|
+
wasm-pack test --node crates/asm198x-web
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The crate is excluded from the workspace, so it carries its own `Cargo.lock`;
|
|
49
|
+
`cargo update -p asm198x --manifest-path crates/asm198x-web/Cargo.toml`
|
|
50
|
+
refreshes the path entry after the library's version moves.
|
|
51
|
+
|
|
52
|
+
## Size
|
|
53
|
+
|
|
54
|
+
Every dialect ships in one module. Measured 2026-09-02, `opt-level = "z"`,
|
|
55
|
+
after wasm-opt: 1,451,743 bytes raw, 490,892 gzipped. A per-platform split
|
|
56
|
+
(#495) is a decision for when a consumer needs one.
|
|
57
|
+
|
|
58
|
+
## Running what you assembled
|
|
59
|
+
|
|
60
|
+
`snapshot(dialect, source)` returns a 48K `.sna` — the same bytes
|
|
61
|
+
`asm198x --dialect pasmonext --sna` writes, verified byte for byte — so a page
|
|
62
|
+
can assemble and then run the result:
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
const sna = snapshot('pasmonext', source);
|
|
66
|
+
if (sna) spectrum.loadSnapshot(sna, 'sna'); // @emu198x/zx-spectrum
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Spectrum Z80 only, and the source needs `end <addr>` for its entry point,
|
|
70
|
+
exactly as the command line demands. `null` means it did not assemble;
|
|
71
|
+
`assemble()` says why.
|
|
72
|
+
|
|
73
|
+
## Size: take one architecture
|
|
74
|
+
|
|
75
|
+
`@asm198x/web` carries every dialect — 1.4 MB raw, 480 KB gzipped. Almost none
|
|
76
|
+
of that is useful to a page teaching one machine, so the package is also built
|
|
77
|
+
per CPU architecture:
|
|
78
|
+
|
|
79
|
+
| package | raw | gzipped |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| `@asm198x/web` (all) | 1422 KB | 480 KB |
|
|
82
|
+
| `@asm198x/z80` | 416 KB | 153 KB |
|
|
83
|
+
|
|
84
|
+
`entry` is the only thing that names the library's assembler entry points, so a
|
|
85
|
+
build that does not select an architecture never references it and the linker
|
|
86
|
+
drops it. Nothing is stripped by hand.
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
scripts/build-npm.sh z80 # -> @asm198x/z80
|
|
90
|
+
scripts/build-npm.sh mos6502 # -> @asm198x/mos6502
|
|
91
|
+
scripts/build-npm.sh # -> @asm198x/web, everything
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`dialects()` reports what the build you have can actually assemble, not the
|
|
95
|
+
whole table, so a picker made from it can never offer a name `assemble` then
|
|
96
|
+
refuses.
|
|
97
|
+
|
|
98
|
+
Even at 153 KB this is bigger than an emulator embed, so a lesson page should
|
|
99
|
+
still load it lazily — on the first keystroke, not on page load.
|
package/asm198x_web.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Assemble `source` in `dialect` and hand back the CLI's `--json` payload.
|
|
6
|
+
*
|
|
7
|
+
* On success the string is the `AssemblyResult` object (bytes, origin,
|
|
8
|
+
* symbols, warnings, debug info); on failure it is the diagnostics array,
|
|
9
|
+
* each span carrying its resolved `path`. `null` in JavaScript when `dialect`
|
|
10
|
+
* is not a name `asm198x dialects` lists.
|
|
11
|
+
*/
|
|
12
|
+
export function assemble(dialect: string, source: string): string | undefined;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Every dialect *this build* accepts, as a JSON array of
|
|
16
|
+
* `{ "name", "aliases", "blurb" }` in the order the CLI reference presents
|
|
17
|
+
* them — the same table `asm198x dialects` prints, so a picker built from
|
|
18
|
+
* this can never offer a name the assembler refuses.
|
|
19
|
+
*/
|
|
20
|
+
export function dialects(): string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The `--listing` rendering of `source` in `dialect`: address, bytes, and
|
|
24
|
+
* source per line. `null` when the dialect is unknown or the source does not
|
|
25
|
+
* assemble — [`assemble`] says why.
|
|
26
|
+
*/
|
|
27
|
+
export function listing(dialect: string, source: string): string | undefined;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Assemble `source` in `dialect` and hand back a 48K `.sna` snapshot.
|
|
31
|
+
*
|
|
32
|
+
* The same bytes `asm198x --dialect pasmonext --sna` writes, so a page that
|
|
33
|
+
* assembles and then runs the result is running what the command line would
|
|
34
|
+
* have produced. Spectrum Z80 only, and the source needs `end <addr>` for its
|
|
35
|
+
* entry point, exactly as the CLI demands.
|
|
36
|
+
*
|
|
37
|
+
* `null` when the dialect is unknown, the source does not assemble, or it has
|
|
38
|
+
* no entry point — [`assemble`] says which.
|
|
39
|
+
*/
|
|
40
|
+
export function snapshot(dialect: string, source: string): Uint8Array | undefined;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Assemble `source` in `dialect` and hand back a Spectrum tape image.
|
|
44
|
+
*
|
|
45
|
+
* The same bytes `asm198x --dialect pasmonext --tapbas` writes: the program
|
|
46
|
+
* with a BASIC loader stub in front, so the machine's own ROM loads and runs
|
|
47
|
+
* it. `name` goes in the block header, where pasmo puts the output path.
|
|
48
|
+
*
|
|
49
|
+
* This is how a lesson gets a program the ROM has initialised the machine
|
|
50
|
+
* for. A snapshot skips the boot, which is faster but leaves the system
|
|
51
|
+
* variables zeroed, so the program cannot call a ROM routine afterwards —
|
|
52
|
+
* see asm198x#568. A tape costs a load and has none of that problem, because
|
|
53
|
+
* the firmware really did the work.
|
|
54
|
+
*
|
|
55
|
+
* `format` is `"tap"` or `"tzx"`. Spectrum Z80 only.
|
|
56
|
+
*
|
|
57
|
+
* `null` when the dialect or format is unknown, or the source does not
|
|
58
|
+
* assemble or does not fit below the top of memory — [`assemble`] says which.
|
|
59
|
+
*/
|
|
60
|
+
export function tape(dialect: string, source: string, name: string, format: string): Uint8Array | undefined;
|
|
61
|
+
|
|
62
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
63
|
+
|
|
64
|
+
export interface InitOutput {
|
|
65
|
+
readonly memory: WebAssembly.Memory;
|
|
66
|
+
readonly assemble: (a: number, b: number, c: number, d: number) => [number, number];
|
|
67
|
+
readonly dialects: () => [number, number];
|
|
68
|
+
readonly listing: (a: number, b: number, c: number, d: number) => [number, number];
|
|
69
|
+
readonly snapshot: (a: number, b: number, c: number, d: number) => [number, number];
|
|
70
|
+
readonly tape: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
71
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
72
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
73
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
74
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
75
|
+
readonly __wbindgen_start: () => void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
82
|
+
* a precompiled `WebAssembly.Module`.
|
|
83
|
+
*
|
|
84
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
85
|
+
*
|
|
86
|
+
* @returns {InitOutput}
|
|
87
|
+
*/
|
|
88
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
92
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
93
|
+
*
|
|
94
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
95
|
+
*
|
|
96
|
+
* @returns {Promise<InitOutput>}
|
|
97
|
+
*/
|
|
98
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/asm198x_web.js
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/* @ts-self-types="./asm198x_web.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Assemble `source` in `dialect` and hand back the CLI's `--json` payload.
|
|
5
|
+
*
|
|
6
|
+
* On success the string is the `AssemblyResult` object (bytes, origin,
|
|
7
|
+
* symbols, warnings, debug info); on failure it is the diagnostics array,
|
|
8
|
+
* each span carrying its resolved `path`. `null` in JavaScript when `dialect`
|
|
9
|
+
* is not a name `asm198x dialects` lists.
|
|
10
|
+
* @param {string} dialect
|
|
11
|
+
* @param {string} source
|
|
12
|
+
* @returns {string | undefined}
|
|
13
|
+
*/
|
|
14
|
+
export function assemble(dialect, source) {
|
|
15
|
+
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
16
|
+
const len0 = WASM_VECTOR_LEN;
|
|
17
|
+
const ptr1 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
18
|
+
const len1 = WASM_VECTOR_LEN;
|
|
19
|
+
const ret = wasm.assemble(ptr0, len0, ptr1, len1);
|
|
20
|
+
let v3;
|
|
21
|
+
if (ret[0] !== 0) {
|
|
22
|
+
v3 = getStringFromWasm0(ret[0], ret[1]);
|
|
23
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
24
|
+
}
|
|
25
|
+
return v3;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Every dialect *this build* accepts, as a JSON array of
|
|
30
|
+
* `{ "name", "aliases", "blurb" }` in the order the CLI reference presents
|
|
31
|
+
* them — the same table `asm198x dialects` prints, so a picker built from
|
|
32
|
+
* this can never offer a name the assembler refuses.
|
|
33
|
+
* @returns {string}
|
|
34
|
+
*/
|
|
35
|
+
export function dialects() {
|
|
36
|
+
let deferred1_0;
|
|
37
|
+
let deferred1_1;
|
|
38
|
+
try {
|
|
39
|
+
const ret = wasm.dialects();
|
|
40
|
+
deferred1_0 = ret[0];
|
|
41
|
+
deferred1_1 = ret[1];
|
|
42
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
43
|
+
} finally {
|
|
44
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The `--listing` rendering of `source` in `dialect`: address, bytes, and
|
|
50
|
+
* source per line. `null` when the dialect is unknown or the source does not
|
|
51
|
+
* assemble — [`assemble`] says why.
|
|
52
|
+
* @param {string} dialect
|
|
53
|
+
* @param {string} source
|
|
54
|
+
* @returns {string | undefined}
|
|
55
|
+
*/
|
|
56
|
+
export function listing(dialect, source) {
|
|
57
|
+
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
58
|
+
const len0 = WASM_VECTOR_LEN;
|
|
59
|
+
const ptr1 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
60
|
+
const len1 = WASM_VECTOR_LEN;
|
|
61
|
+
const ret = wasm.listing(ptr0, len0, ptr1, len1);
|
|
62
|
+
let v3;
|
|
63
|
+
if (ret[0] !== 0) {
|
|
64
|
+
v3 = getStringFromWasm0(ret[0], ret[1]);
|
|
65
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
66
|
+
}
|
|
67
|
+
return v3;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Assemble `source` in `dialect` and hand back a 48K `.sna` snapshot.
|
|
72
|
+
*
|
|
73
|
+
* The same bytes `asm198x --dialect pasmonext --sna` writes, so a page that
|
|
74
|
+
* assembles and then runs the result is running what the command line would
|
|
75
|
+
* have produced. Spectrum Z80 only, and the source needs `end <addr>` for its
|
|
76
|
+
* entry point, exactly as the CLI demands.
|
|
77
|
+
*
|
|
78
|
+
* `null` when the dialect is unknown, the source does not assemble, or it has
|
|
79
|
+
* no entry point — [`assemble`] says which.
|
|
80
|
+
* @param {string} dialect
|
|
81
|
+
* @param {string} source
|
|
82
|
+
* @returns {Uint8Array | undefined}
|
|
83
|
+
*/
|
|
84
|
+
export function snapshot(dialect, source) {
|
|
85
|
+
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
86
|
+
const len0 = WASM_VECTOR_LEN;
|
|
87
|
+
const ptr1 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
88
|
+
const len1 = WASM_VECTOR_LEN;
|
|
89
|
+
const ret = wasm.snapshot(ptr0, len0, ptr1, len1);
|
|
90
|
+
let v3;
|
|
91
|
+
if (ret[0] !== 0) {
|
|
92
|
+
v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
93
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
94
|
+
}
|
|
95
|
+
return v3;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Assemble `source` in `dialect` and hand back a Spectrum tape image.
|
|
100
|
+
*
|
|
101
|
+
* The same bytes `asm198x --dialect pasmonext --tapbas` writes: the program
|
|
102
|
+
* with a BASIC loader stub in front, so the machine's own ROM loads and runs
|
|
103
|
+
* it. `name` goes in the block header, where pasmo puts the output path.
|
|
104
|
+
*
|
|
105
|
+
* This is how a lesson gets a program the ROM has initialised the machine
|
|
106
|
+
* for. A snapshot skips the boot, which is faster but leaves the system
|
|
107
|
+
* variables zeroed, so the program cannot call a ROM routine afterwards —
|
|
108
|
+
* see asm198x#568. A tape costs a load and has none of that problem, because
|
|
109
|
+
* the firmware really did the work.
|
|
110
|
+
*
|
|
111
|
+
* `format` is `"tap"` or `"tzx"`. Spectrum Z80 only.
|
|
112
|
+
*
|
|
113
|
+
* `null` when the dialect or format is unknown, or the source does not
|
|
114
|
+
* assemble or does not fit below the top of memory — [`assemble`] says which.
|
|
115
|
+
* @param {string} dialect
|
|
116
|
+
* @param {string} source
|
|
117
|
+
* @param {string} name
|
|
118
|
+
* @param {string} format
|
|
119
|
+
* @returns {Uint8Array | undefined}
|
|
120
|
+
*/
|
|
121
|
+
export function tape(dialect, source, name, format) {
|
|
122
|
+
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
123
|
+
const len0 = WASM_VECTOR_LEN;
|
|
124
|
+
const ptr1 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
125
|
+
const len1 = WASM_VECTOR_LEN;
|
|
126
|
+
const ptr2 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
127
|
+
const len2 = WASM_VECTOR_LEN;
|
|
128
|
+
const ptr3 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
129
|
+
const len3 = WASM_VECTOR_LEN;
|
|
130
|
+
const ret = wasm.tape(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
131
|
+
let v5;
|
|
132
|
+
if (ret[0] !== 0) {
|
|
133
|
+
v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
134
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
135
|
+
}
|
|
136
|
+
return v5;
|
|
137
|
+
}
|
|
138
|
+
function __wbg_get_imports() {
|
|
139
|
+
const import0 = {
|
|
140
|
+
__proto__: null,
|
|
141
|
+
__wbindgen_init_externref_table: function() {
|
|
142
|
+
const table = wasm.__wbindgen_externrefs;
|
|
143
|
+
const offset = table.grow(4);
|
|
144
|
+
table.set(0, undefined);
|
|
145
|
+
table.set(offset + 0, undefined);
|
|
146
|
+
table.set(offset + 1, null);
|
|
147
|
+
table.set(offset + 2, true);
|
|
148
|
+
table.set(offset + 3, false);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
__proto__: null,
|
|
153
|
+
"./asm198x_web_bg.js": import0,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
158
|
+
ptr = ptr >>> 0;
|
|
159
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function getStringFromWasm0(ptr, len) {
|
|
163
|
+
return decodeText(ptr >>> 0, len);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
let cachedUint8ArrayMemory0 = null;
|
|
167
|
+
function getUint8ArrayMemory0() {
|
|
168
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
169
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
170
|
+
}
|
|
171
|
+
return cachedUint8ArrayMemory0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
175
|
+
if (realloc === undefined) {
|
|
176
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
177
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
178
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
179
|
+
WASM_VECTOR_LEN = buf.length;
|
|
180
|
+
return ptr;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
let len = arg.length;
|
|
184
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
185
|
+
|
|
186
|
+
const mem = getUint8ArrayMemory0();
|
|
187
|
+
|
|
188
|
+
let offset = 0;
|
|
189
|
+
|
|
190
|
+
for (; offset < len; offset++) {
|
|
191
|
+
const code = arg.charCodeAt(offset);
|
|
192
|
+
if (code > 0x7F) break;
|
|
193
|
+
mem[ptr + offset] = code;
|
|
194
|
+
}
|
|
195
|
+
if (offset !== len) {
|
|
196
|
+
if (offset !== 0) {
|
|
197
|
+
arg = arg.slice(offset);
|
|
198
|
+
}
|
|
199
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
200
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
201
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
202
|
+
|
|
203
|
+
offset += ret.written;
|
|
204
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
WASM_VECTOR_LEN = offset;
|
|
208
|
+
return ptr;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
212
|
+
cachedTextDecoder.decode();
|
|
213
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
214
|
+
let numBytesDecoded = 0;
|
|
215
|
+
function decodeText(ptr, len) {
|
|
216
|
+
numBytesDecoded += len;
|
|
217
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
218
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
219
|
+
cachedTextDecoder.decode();
|
|
220
|
+
numBytesDecoded = len;
|
|
221
|
+
}
|
|
222
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const cachedTextEncoder = new TextEncoder();
|
|
226
|
+
|
|
227
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
228
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
229
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
230
|
+
view.set(buf);
|
|
231
|
+
return {
|
|
232
|
+
read: arg.length,
|
|
233
|
+
written: buf.length
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
let WASM_VECTOR_LEN = 0;
|
|
239
|
+
|
|
240
|
+
let wasmModule, wasmInstance, wasm;
|
|
241
|
+
function __wbg_finalize_init(instance, module) {
|
|
242
|
+
wasmInstance = instance;
|
|
243
|
+
wasm = instance.exports;
|
|
244
|
+
wasmModule = module;
|
|
245
|
+
cachedUint8ArrayMemory0 = null;
|
|
246
|
+
wasm.__wbindgen_start();
|
|
247
|
+
return wasm;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async function __wbg_load(module, imports) {
|
|
251
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
252
|
+
if (!module.ok) {
|
|
253
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
257
|
+
try {
|
|
258
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
259
|
+
} catch (e) {
|
|
260
|
+
const validResponse = expectedResponseType(module.type);
|
|
261
|
+
|
|
262
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
263
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
264
|
+
|
|
265
|
+
} else { throw e; }
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const bytes = await module.arrayBuffer();
|
|
270
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
271
|
+
} else {
|
|
272
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
273
|
+
|
|
274
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
275
|
+
return { instance, module };
|
|
276
|
+
} else {
|
|
277
|
+
return instance;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function expectedResponseType(type) {
|
|
282
|
+
switch (type) {
|
|
283
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
284
|
+
}
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function initSync(module) {
|
|
290
|
+
if (wasm !== undefined) return wasm;
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
if (module !== undefined) {
|
|
294
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
295
|
+
({module} = module)
|
|
296
|
+
} else {
|
|
297
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const imports = __wbg_get_imports();
|
|
302
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
303
|
+
module = new WebAssembly.Module(module);
|
|
304
|
+
}
|
|
305
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
306
|
+
return __wbg_finalize_init(instance, module);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
async function __wbg_init(module_or_path) {
|
|
310
|
+
if (wasm !== undefined) return wasm;
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
if (module_or_path !== undefined) {
|
|
314
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
315
|
+
({module_or_path} = module_or_path)
|
|
316
|
+
} else {
|
|
317
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (module_or_path === undefined) {
|
|
322
|
+
module_or_path = new URL('asm198x_web_bg.wasm', import.meta.url);
|
|
323
|
+
}
|
|
324
|
+
const imports = __wbg_get_imports();
|
|
325
|
+
|
|
326
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
327
|
+
module_or_path = fetch(module_or_path);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
331
|
+
|
|
332
|
+
return __wbg_finalize_init(instance, module);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@asm198x/z80",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "asm198x assembler for z80, compiled to WebAssembly.",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"license": "GPL-2.0-or-later",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/asm198x/asm198x"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"asm198x_web_bg.wasm",
|
|
13
|
+
"asm198x_web.js",
|
|
14
|
+
"asm198x_web.d.ts",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"main": "asm198x_web.js",
|
|
18
|
+
"types": "asm198x_web.d.ts",
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"./snippets/*"
|
|
21
|
+
]
|
|
22
|
+
}
|