1 /* MIX simulator, copyright 1994 by Darius Bacon */
2 #include "mix.h"
3 
4 #include "asm.h"
5 #include "run.h"    /* for memory[] */
6 
7 /* --- The assembly buffer --- */
8 
9 Address here = 0;
10 
asm_fetch_field(Address address,unsigned L,unsigned R)11 Cell asm_fetch_field(Address address, unsigned L, unsigned R)
12 {
13     assert(address < memory_size);
14     return field(make_field_spec(L, R), memory[address]);
15 }
16 
17 #include <stdio.h>
18 
asm_store_field(Address address,unsigned L,unsigned R,Cell cell)19 void asm_store_field(Address address, unsigned L, unsigned R, Cell cell)
20 {
21     assert(address < memory_size);
22     if (VERBOSE) {
23 	char temp[12];
24 	unparse_cell(temp, cell);
25 	printf("%4o(%u,%u): %s\n", address, L, R, temp);
26     }
27     memory[address] = set_field(cell, make_field_spec(L, R), memory[address]);
28 }
29 
assemble(Cell cell)30 void assemble(Cell cell)
31 {
32     if (VERBOSE) {
33         char temp[12];
34 	unparse_cell(temp, cell);
35 	printf("%4o: %s\n", here, temp);
36     }
37     if (here < memory_size)
38 	memory[here] = cell;
39     else
40 	error("Address out of range");
41     ++here;
42 }
43 
44 Address entry_point;
45 
set_entry_point(Address address)46 void set_entry_point(Address address)
47 {
48     assert(address < memory_size);
49     if (VERBOSE)
50         printf("entry point: %4o\n", address);
51     entry_point = address;
52 }
53