@andrivet/z80-assembler 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/index.js +1 -1
- package/index.mjs +474 -380
- package/lib/compiler/Ast.d.ts +12 -2
- package/lib/compiler/Compiler.d.ts +1 -1
- package/lib/compiler/Formatter.d.ts +1 -1
- package/lib/compiler/Labels.d.ts +19 -2
- package/lib/grammar/LowLevel.d.ts +38 -10
- package/lib/grammar/Parse.d.ts +21 -1
- package/lib/grammar/z80.d.ts +208 -208
- package/lib/types/Error.d.ts +26 -6
- package/lib/types/Types.d.ts +6 -1
- package/package.json +1 -1
package/lib/compiler/Ast.d.ts
CHANGED
|
@@ -28,7 +28,17 @@ export type EvalFunc = () => number | null;
|
|
|
28
28
|
* Un élément abstrait générà par l'analyseur.
|
|
29
29
|
*/
|
|
30
30
|
export interface AstBase {
|
|
31
|
+
/**
|
|
32
|
+
* The number of bytes that will be generated by this element.
|
|
33
|
+
* Le nombre d'octets générés par cet élément.
|
|
34
|
+
*/
|
|
31
35
|
get size(): number;
|
|
36
|
+
/**
|
|
37
|
+
* Generate actual bytes.
|
|
38
|
+
* Génération des octets
|
|
39
|
+
* @param instructionAddress Address of the next byte to generate,
|
|
40
|
+
* Adresse du prochain octet à générer.
|
|
41
|
+
*/
|
|
32
42
|
generate(instructionAddress: number): bytes;
|
|
33
43
|
}
|
|
34
44
|
/**
|
|
@@ -91,7 +101,7 @@ type UnaryOperation = (a: number) => number;
|
|
|
91
101
|
* @param op Operation to be applied to the left and right side.
|
|
92
102
|
* L'opération à appliquer aux opérandes
|
|
93
103
|
*/
|
|
94
|
-
export declare function binaryOperation<Operation extends BinaryOperation, Inner extends Evaluable, Left extends InnerExpression<Inner>, Right extends Evaluable>(left: Left |
|
|
104
|
+
export declare function binaryOperation<Operation extends BinaryOperation, Inner extends Evaluable, Left extends InnerExpression<Inner>, Right extends Evaluable>(left: Left | null, right: Right, op: Operation): EvalFunc;
|
|
95
105
|
/**
|
|
96
106
|
* A map of strings versus binary operations. For example: '*' => operatorMul
|
|
97
107
|
*/
|
|
@@ -120,7 +130,7 @@ interface InnerOp<E extends Evaluable> extends InnerExpression<E> {
|
|
|
120
130
|
* @param map Map the operations to be applied to the left and right side.
|
|
121
131
|
* Une correspondance pour les opérations à appliquer aux opérandes.
|
|
122
132
|
*/
|
|
123
|
-
export declare function binaryOperations<Inner extends Evaluable, Left extends InnerOp<Inner>, Right extends Evaluable>(left: Left, right: Right, map: BinaryOperationsMap): EvalFunc;
|
|
133
|
+
export declare function binaryOperations<Inner extends Evaluable, Left extends InnerOp<Inner>, Right extends Evaluable>(left: Left | null, right: Right, map: BinaryOperationsMap): EvalFunc;
|
|
124
134
|
/**
|
|
125
135
|
* A Unary operation.
|
|
126
136
|
* @param e The argument.
|
|
@@ -45,7 +45,7 @@ declare const parseData: ParseDate;
|
|
|
45
45
|
* @param filename Filename for the binary.
|
|
46
46
|
* Nom de fichier pour le binaire.
|
|
47
47
|
* @param sld Filename for the SLD.
|
|
48
|
-
* Nom de
|
|
48
|
+
* Nom de fichier pour le SLD.
|
|
49
49
|
*/
|
|
50
50
|
declare function setOutputName(filename: string, sld?: string): void;
|
|
51
51
|
/**
|
|
@@ -26,7 +26,7 @@ interface Chunk {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Format bytes to display them.
|
|
29
|
-
*
|
|
29
|
+
* Formate des octets pour les afficher.
|
|
30
30
|
* @param bytes An array of bytes.
|
|
31
31
|
* Un tableau d'octets.
|
|
32
32
|
* @param perLine Number of bytes per line.
|
package/lib/compiler/Labels.d.ts
CHANGED
|
@@ -19,37 +19,54 @@
|
|
|
19
19
|
import { Expression, PosInfo } from "../grammar/z80";
|
|
20
20
|
/**
|
|
21
21
|
* Reset the labels.
|
|
22
|
+
* Supprime toutes les étiquettes.
|
|
22
23
|
*/
|
|
23
24
|
declare function resetLabels(): void;
|
|
24
25
|
/**
|
|
25
26
|
* Add a label.
|
|
27
|
+
* Ajoute une étiquette.
|
|
26
28
|
* @param pos The position of the label in the source code.
|
|
29
|
+
* La position de l'étiquette dans le code source.
|
|
27
30
|
* @param name The name of the label.
|
|
28
|
-
*
|
|
31
|
+
* Le nom de l'étiquette.
|
|
32
|
+
* @param value The value of the label (if known) or null (if unknown).
|
|
33
|
+
* La valeur de l'étiquette (si connue) ou null (si inconnue).
|
|
29
34
|
*/
|
|
30
35
|
declare function addLabel(pos: PosInfo, name: string, value: number | null): void;
|
|
31
36
|
/**
|
|
32
37
|
* Add a label and its associated expression.
|
|
38
|
+
* Ajoute une étiquette et son expression associée.
|
|
33
39
|
* @param _ The position of the label in the source code.
|
|
40
|
+
* La position de l'étiquette dans le code source.
|
|
34
41
|
* @param name The name of the label.
|
|
42
|
+
* Le nom de l'étiquette.
|
|
35
43
|
* @param expression The expression that gives that value of the label.
|
|
44
|
+
* L'expression qui donne la valeur de l'étiquette.
|
|
36
45
|
*/
|
|
37
46
|
declare function addLabelExpression(_: PosInfo, name: string, expression: Expression): void;
|
|
38
47
|
/**
|
|
39
48
|
* Get the value associated with a label.
|
|
49
|
+
* Obtient la valeur associée avec une étiquette.
|
|
40
50
|
* @param name The name of the label.
|
|
51
|
+
* Le nom de l'étiquette.
|
|
41
52
|
* @param setUsed Set the used flag or not.
|
|
53
|
+
* Est-ce que l'on doit lever le drapeau d'utilisation ?
|
|
42
54
|
* @return The value associated with a label or null if it is unknown.
|
|
55
|
+
* La valeur associée avec l'étiquette ou null si elle est inconnue.
|
|
43
56
|
*/
|
|
44
57
|
declare function getLabelValue(name: string, setUsed?: boolean): number | null;
|
|
45
58
|
/**
|
|
46
59
|
* Is a label used in the program or only declared?
|
|
60
|
+
* Est-ce qu'une étiquette a été utilisée ou seulement déclarée ?
|
|
47
61
|
* @param name The name of the label.
|
|
48
|
-
*
|
|
62
|
+
* Le nom de l'étiquette.
|
|
63
|
+
* @return true if the label is used, false otherwise.
|
|
64
|
+
* true si l'étiquette a été utilisée, false sinon.
|
|
49
65
|
*/
|
|
50
66
|
declare function isLabelUsed(name: string): boolean | undefined;
|
|
51
67
|
/**
|
|
52
68
|
* Get the list of labels with an unknown value.
|
|
69
|
+
* Retourne la liste des étiquettes avec une valeur inconnue.
|
|
53
70
|
*/
|
|
54
71
|
declare function getUnknownLabels(): string[];
|
|
55
72
|
export { resetLabels, addLabel, addLabelExpression, getLabelValue, isLabelUsed, getUnknownLabels };
|
|
@@ -19,59 +19,87 @@
|
|
|
19
19
|
import { byte } from "../types/Types";
|
|
20
20
|
/**
|
|
21
21
|
* Compute the binary representation of the r argument.
|
|
22
|
-
*
|
|
22
|
+
* Calcule la représentation binaire de l'argument r.
|
|
23
|
+
* @param r The argument of the opcode.
|
|
24
|
+
* L'argument du code assembleur.
|
|
23
25
|
* @param offset The number of bits to shift to the left.
|
|
26
|
+
* Le nombre de bits à décaler vers la gauche.
|
|
24
27
|
*/
|
|
25
28
|
export declare function r_bits(r: string, offset?: number): byte;
|
|
26
29
|
/**
|
|
27
30
|
* Compute the binary representation of the dd argument.
|
|
28
|
-
*
|
|
31
|
+
* Calcule la représentation binaire de l'argument dd.
|
|
32
|
+
* @param dd The argument of the opcode.
|
|
33
|
+
* L'argument du code assembleur.
|
|
29
34
|
* @param offset The number of bits to shift to the left.
|
|
35
|
+
* Le nombre de bits à décaler vers la gauche.
|
|
30
36
|
*/
|
|
31
37
|
export declare function dd_bits(dd: string, offset?: number): byte;
|
|
32
38
|
/**
|
|
33
39
|
* Compute the binary representation of the qq argument.
|
|
34
|
-
*
|
|
40
|
+
* Calcule la représentation binaire de l'argument qq.
|
|
41
|
+
* @param qq The argument of the opcode.
|
|
42
|
+
* L'argument du code assembleur.
|
|
35
43
|
* @param offset The number of bits to shift to the left.
|
|
44
|
+
* Le nombre de bits à décaler vers la gauche.
|
|
36
45
|
*/
|
|
37
46
|
export declare function qq_bits(qq: string, offset?: number): byte;
|
|
38
47
|
/**
|
|
39
48
|
* Compute the binary representation of the ss argument.
|
|
40
|
-
*
|
|
49
|
+
* Calcule la représentation binaire de l'argument ss.
|
|
50
|
+
* @param ss The argument of the opcode.
|
|
51
|
+
* L'argument du code assembleur.
|
|
41
52
|
* @param offset The number of bits to shift to the left.
|
|
53
|
+
* Le nombre de bits à décaler vers la gauche.
|
|
42
54
|
*/
|
|
43
55
|
export declare function ss_bits(ss: string, offset?: number): byte;
|
|
44
56
|
/**
|
|
45
57
|
* Compute the binary representation of the pp argument.
|
|
46
|
-
*
|
|
58
|
+
* Calcule la représentation binaire de l'argument pp.
|
|
59
|
+
* @param pp The argument of the opcode.
|
|
60
|
+
* L'argument du code assembleur.
|
|
47
61
|
* @param offset The number of bits to shift to the left.
|
|
62
|
+
* Le nombre de bits à décaler vers la gauche.
|
|
48
63
|
*/
|
|
49
64
|
export declare function pp_bits(pp: string, offset?: number): byte;
|
|
50
65
|
/**
|
|
51
66
|
* Compute the binary representation of the rr argument.
|
|
52
|
-
*
|
|
67
|
+
* Calcule la représentation binaire de l'argument rr.
|
|
68
|
+
* @param rr The argument of the opcode.
|
|
69
|
+
* L'argument du code assembleur.
|
|
53
70
|
* @param offset The number of bits to shift to the left.
|
|
71
|
+
* Le nombre de bits à décaler vers la gauche.
|
|
54
72
|
*/
|
|
55
73
|
export declare function rr_bits(rr: string, offset?: number): byte;
|
|
56
74
|
/**
|
|
57
75
|
* Compute the binary representation of the cc argument.
|
|
58
|
-
*
|
|
76
|
+
* Calcule la représentation binaire de l'argument cc.
|
|
77
|
+
* @param cc The argument of the opcode.
|
|
78
|
+
* L'argument du code assembleur.
|
|
59
79
|
* @param offset The number of bits to shift to the left.
|
|
80
|
+
* Le nombre de bits à décaler vers la gauche.
|
|
60
81
|
*/
|
|
61
82
|
export declare function cc_bits(cc: string, offset?: number): byte;
|
|
62
83
|
/**
|
|
63
84
|
* Compute the binary representation of the jj argument.
|
|
64
|
-
*
|
|
85
|
+
* Calcule la représentation binaire de l'argument jj.
|
|
86
|
+
* @param jj The argument of the opcode.
|
|
87
|
+
* L'argument du code assembleur.
|
|
65
88
|
*/
|
|
66
89
|
export declare function jj_bits(jj?: string): byte;
|
|
67
90
|
/**
|
|
68
91
|
* Compute the binary representation of the p argument.
|
|
69
|
-
*
|
|
92
|
+
* Calcule la représentation binaire de l'argument p.
|
|
93
|
+
* @param p The argument of the opcode.
|
|
94
|
+
* L'argument du code assembleur.
|
|
70
95
|
* @param offset The number of bits to shift to the left.
|
|
96
|
+
* Le nombre de bits à décaler vers la gauche.
|
|
71
97
|
*/
|
|
72
98
|
export declare function p_bits(p: number, offset?: number): byte;
|
|
73
99
|
/**
|
|
74
100
|
* Compute the binary representation of the mode argument.
|
|
75
|
-
*
|
|
101
|
+
* Calcule la représentation binaire de l'argument mode.
|
|
102
|
+
* @param mode The argument of the opcode.
|
|
103
|
+
* L'argument du code assembleur.
|
|
76
104
|
*/
|
|
77
105
|
export declare function imode(mode: string): byte;
|
package/lib/grammar/Parse.d.ts
CHANGED
|
@@ -19,39 +19,59 @@
|
|
|
19
19
|
import { PosInfo } from "./z80";
|
|
20
20
|
/**
|
|
21
21
|
* Parse a number.
|
|
22
|
+
* Analyse un nombre.
|
|
22
23
|
* @param pos Position of the number in the source code.
|
|
24
|
+
* Position du nombre dans le code source.
|
|
23
25
|
* @param str The characters of the number.
|
|
26
|
+
* Les caractères du nombre.
|
|
24
27
|
* @param base The base of the number.
|
|
28
|
+
* La base du nombre.
|
|
25
29
|
* @param nbBytes The number of bytes to represent this number (1 or 2)
|
|
30
|
+
* Le nombre d'octets pour représenter ce nombre (1 ou 2)
|
|
26
31
|
*/
|
|
27
32
|
export declare function parseNumber(pos: PosInfo, str: string, base: number, nbBytes: number): number;
|
|
28
33
|
/**
|
|
29
34
|
* Parse a simple escape, i.e. a backslash followed by a character.
|
|
35
|
+
* Analyse un échappement simple, c.-à-d. une barre oblique inversée suivie d'un caractère.
|
|
30
36
|
* @param pos Position of the character in the source code.
|
|
37
|
+
* Position du caractère dans le code source.
|
|
31
38
|
* @param c The character after the backslash.
|
|
39
|
+
* Le caractère après la barre oblique inversée.
|
|
32
40
|
*/
|
|
33
41
|
export declare function parseSimpleEscape(pos: PosInfo, c: string): number[];
|
|
34
42
|
/**
|
|
35
43
|
* Parse an octal value.
|
|
44
|
+
* Analyse une valeur octale.
|
|
36
45
|
* @param pos Position of the value in the source code.
|
|
46
|
+
* Position de la valeur dans le code source.
|
|
37
47
|
* @param value The characters representing the value.
|
|
48
|
+
* Les caractères représentant la valeur.
|
|
38
49
|
*/
|
|
39
50
|
export declare function parseOctalEscape(pos: PosInfo, value: string): number[];
|
|
40
51
|
/**
|
|
41
52
|
* Parse a hexadecimal value.
|
|
53
|
+
* Analyse une valeur hexadécimale.
|
|
42
54
|
* @param pos Position of the value in the source code.
|
|
55
|
+
* Position de la valeur dans le code source.
|
|
43
56
|
* @param value The characters representing the value.
|
|
57
|
+
* Les caractères représentant la valeur.
|
|
44
58
|
*/
|
|
45
59
|
export declare function parseHexadecimalEscape(pos: PosInfo, value: string): number[];
|
|
46
60
|
/**
|
|
47
61
|
* Parse a ZX81 character written in ASCII.
|
|
62
|
+
* Analyse un caractère ZX81 écrit en ASCII.
|
|
48
63
|
* @param pos Position of the character in the source code.
|
|
64
|
+
* Position du caractère dans le code source.
|
|
49
65
|
* @param c The ASCII character.
|
|
66
|
+
* Le caractère ASCII.
|
|
50
67
|
*/
|
|
51
|
-
export declare function parseZX81Char(pos: PosInfo, c: string): number;
|
|
68
|
+
export declare function parseZX81Char(pos: PosInfo, c: string): [number];
|
|
52
69
|
/**
|
|
53
70
|
* Parse a ZX81 string written in ASCII.
|
|
71
|
+
* Analyse un chaine ZX81 écrit en ASCII.
|
|
54
72
|
* @param pos Position of the string in the source code.
|
|
73
|
+
* Position de la chaine dans le code source.
|
|
55
74
|
* @param str The ASCII string.
|
|
75
|
+
* La chaine ASCII.
|
|
56
76
|
*/
|
|
57
77
|
export declare function parseZX81String(pos: PosInfo, str: string): number[];
|