blob: ed49a4883af7b1fb5b5a578bffdb637d24c5b453 (
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
|
#include <stdint.h>
#include <stdio.h>
#include "mnemonics.h"
#include "nqasm.h"
#include "lexer.h"
#include "parser.h"
void add_instruction(const struct instruction *inst)
{
const struct mnemonic *mnem = &mnemonics[inst->mnem];
uint16_t bits = mnem->bits;
const struct operand *ops = mnem->operands;
const struct argument *args = inst->args.args;
for (int i = 0; i < 3 && ops[i].type; i++) {
bits |= args[i].value << ops[i].shift;
}
printf("%04x\n", bits);
}
int main(int argc, char **argv)
{
yyparse();
return 0;
}
|