aboutsummaryrefslogtreecommitdiffgithub
path: root/novice/assembler/opspec/word.ts
blob: d9866ffae1d59a7cd628137ad28f7d865344c47e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { maskTo } from '../../util';
import { AsmContext, oneWord, OpOperands, PseudoOpSpec } from './opspec';

const wordOpSpec: PseudoOpSpec = {
    ops: [
        {op: 'word',
         operands: [{kind: 'int', name: 'num'}],
         asm: (ctx: AsmContext, operands: OpOperands) =>
            // TODO: complain if too big
            [maskTo(operands.ints.num, ctx.isa.mem.addressability)]},

        {op: 'word',
         operands: [{kind: 'label', name: 'label'}],
         size: oneWord,
         asm: (ctx: AsmContext, operands: OpOperands) =>
            // TODO: complain if nonexistent
            [ctx.symbtable[operands.labels.label]]},
    ],
};

export { wordOpSpec };