Module: MicroCisc
- Defined in:
- lib/micro_cisc.rb,
lib/micro_cisc/version.rb,
lib/micro_cisc/vm/device.rb,
lib/micro_cisc/vm/processor.rb,
lib/micro_cisc/vm/term_device.rb,
lib/micro_cisc/vm/empty_device.rb,
lib/micro_cisc/compile/compiler.rb,
lib/micro_cisc/compile/statement.rb,
lib/micro_cisc/compile/instruction.rb,
lib/micro_cisc/vm/color_lcd_display.rb,
lib/micro_cisc/compile/label_generator.rb
Defined Under Namespace
Modules: Compile, Vm
Classes: Error
Constant Summary
collapse
- VERSION =
"0.1.4"
Class Method Summary
collapse
Class Method Details
.load(file_names) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/micro_cisc.rb', line 21
def self.load(file_names)
text = ""
file_names.each do |file_name|
text += File.read(file_name)
end
MicroCisc::Compile::Compiler.new(text)
end
|
.logger ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/micro_cisc.rb', line 61
def self.logger
@logger ||=
begin
logger = Logger.new(STDOUT)
logger.formatter = proc do |severity, datetime, progname, msg|
"#{severity}: #{msg}\n"
end
logger
end
end
|
.run(data) ⇒ Object
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
58
59
|
# File 'lib/micro_cisc.rb', line 29
def self.run(data)
blocks = data.size / 256 + 1
rom_blocks = []
(0...blocks).each do |block|
rom = Array.new(256).map { 0 }
size = data.size - block * 256
size = 256 if size > 256
rom[0...size] = data[(block * 256)...((block + 1) * 256)]
rom_blocks << rom
end
terminal = MicroCisc::Vm::TermDevice.new(5)
screen = MicroCisc::Vm::EmptyDevice.new
init_screen = ARGV.include?('-s')
if(init_screen)
screen = MicroCisc::Vm::ColorLcdDisplay.new(
6, 40, 128, 72, MicroCisc::Vm::ColorLcdDisplay::COLOR_MODE_12BIT
)
end
devices = Array.new(17).map { MicroCisc::Vm::EmptyDevice.new }
devices[15] = terminal devices[16] = screen
processor = MicroCisc::Vm::Processor.new(1, 256, rom_blocks)
processor.devices = devices
processor.start(ARGV.include?('-d'))
screen.join if(init_screen)
processor
end
|