-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstackvm.cr
More file actions
39 lines (29 loc) · 783 Bytes
/
stackvm.cr
File metadata and controls
39 lines (29 loc) · 783 Bytes
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
require "./stackvm/**"
require "./assembler/utils.cr"
module StackVM
include Semantic
include Machine
debug_program = Array(UInt8 | UInt16 | UInt32 | UInt64){
# LOADI DWORD 1
0b00000000_00011100_u16,
0b00000000_00000000_00000000_00000100_u32,
0b00000000_00000000_00000000_11111111_u32,
# LOADI DWORD 1
0b00000000_00011100_u16,
0b00000000_00000000_00000000_00000100_u32,
0b00000000_00000000_00000000_11111111_u32,
# RPOP
0b00000000_00000001_u16,
0b11000000_u8,
# RPOP
0b00000000_00000001_u16,
0b10000000_u8,
# HALT
0b00000000_00110010_u16
}
binary = Assembler::Utils.convert_opcodes debug_program
machine = Machine::Machine.new
machine.flash binary
machine.start
machine.status STDOUT
end