-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasm.c
57 lines (46 loc) · 1.29 KB
/
asm.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* MIX simulator, copyright 1994 by Darius Bacon */
#include "mix.h"
#include "asm.h"
#include "run.h" /* for memory_fetch(), memory_store() */
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
/* --- The assembly buffer --- */
Address here = 0;
Cell asm_fetch_field(Address address, unsigned L, unsigned R)
{
assert(address < memory_size);
return field(make_field_spec(L, R), memory_fetch(address));
}
#include <stdio.h>
void asm_store_field(Address address, unsigned L, unsigned R, Cell cell)
{
// assert(address < memory_size);
if (VERBOSE) {
char temp[16];
unparse_cell(temp, cell, false);
printf("%s(%u,%u): %s\n", address_to_string(address), L, R, temp);
}
memory_store(address, set_field(cell, make_field_spec(L, R), memory_fetch(address)));
}
void assemble(Cell cell)
{
if (VERBOSE) {
char temp[16];
unparse_cell(temp, cell, true);
printf("%s: %s %s\n", address_to_string(here), temp, current_line);
}
// if (here < memory_size)
// memory[here] = cell;
// else
// error("Address out of range");
memory_store(here, cell);
++here;
}
Address entry_point;
void set_entry_point(Address address)
{
assert(abs(address) < memory_size);
entry_point = address;
}
/* vim: set ts=4 sw=4 et: */