-
Notifications
You must be signed in to change notification settings - Fork 0
/
as.c
43 lines (33 loc) · 758 Bytes
/
as.c
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
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include "src/stack_cpu.h"
#include "src/asmr.h"
extern bool debug;
int
main(int argc, char *argv[])
{
int ch;
char *fn = "progs/forth.asmr";
while ((ch = getopt(argc, argv, "vf:")) != -1) {
switch (ch) {
case 'v':
debug = true;
break;
case 'f':
fn = optarg;
break;
}
}
// assemble it
asmr_t *asmr = init_asmr();
stack_cpu_asm(asmr, fn);
for (size_t i = 0; i < asmr->prog_len; i++) {
if (i % 16 == 0)
printf("\ndata %06lx: ", i);
printf(MEM_FMT " ", asmr->prog[i]);
}
printf("\n");
free(asmr);
return 0;
}