aboutsummaryrefslogtreecommitdiffgithub
path: root/novice/assembler/opspec/opspec.ts
blob: 8b9945b9fd0fbade84417885831cbfb643629e81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Isa, SymbTable } from '../../isa';

interface AsmContext {
    isa: Isa;
    symbtable: SymbTable;
}

interface OpOperandSpec {
    kind: 'int'|'label'|'string';
    name: string;
}

interface OpOperands {
    ints: {[s: string]: number};
    labels: {[s: string]: string};
    strings: {[s: string]: string};
}

interface OpSpec {
    op: string;
    operands: OpOperandSpec[];
    asm: (ctx: AsmContext, operands: OpOperands) => number[];
    size?: (isa: Isa) => number;
}

interface PseudoOpSpec {
    ops: OpSpec[];
}

// Size is one word
function oneWord(isa: Isa) {
    return isa.mem.word / isa.mem.addressability;
}

export { AsmContext, OpOperands, PseudoOpSpec, OpSpec, oneWord };