-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcpu.py
53 lines (36 loc) · 1.14 KB
/
cpu.py
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
from register import register, buffer
from memory import memory
from controller import controller
from IOmanagement import IOmanagement
from assembler import compile
from stringtable import maketable
#####################################
pc = register("PC")
ix = register("IX")
sp = register("SP")
regA = register("regA")
regB = register("regB")
regR = register("regR")
regIO = register("regIO")
plotter = buffer("plotter")
kbd = buffer("kbd")
myASCII = maketable()
memsize = 128 * 5
MEMORY = memory(memsize)
CONTROLLER = controller(pc, ix, sp, regA, regB, regR, regIO, MEMORY)
IO_MANAGER = IOmanagement(myASCII, regIO, kbd, plotter)
loaderstart = 0
progstart = loaderstart +64
varaddress = memsize -192
symbols = {}
files = [('loader.asm', loaderstart), ('program2.asm', progstart)]
for file in files:
bin, varaddress, symbols = compile(file[0], file[1], varaddress, symbols, myASCII)
for line in bin:
# print(line)
MEMORY.do("write",line[0], line[1])
halted = False
IOack = False
while not halted:
halted, zero, IOadr = CONTROLLER.do(progstart, IOack)
IOack = IO_MANAGER.do(IOadr)