class Synacor::VM

Defined in:

synacor/vm.cr

Constant Summary

INVALID_VALUE = MAX_VALUE + 8
MAX_VALUE = (2 ** 15).to_u16
REGISTERS = MAX_VALUE...INVALID_VALUE

Constructors

Instance Method Summary

Constructor Detail

def self.new(input : IO::Memory, output : Athena::Console::Output::Interface) #

[View source]

Instance Method Detail

def input : IO::Memory #

[View source]
def input=(input : IO::Memory) #

[View source]
def load(binary_path : String) #

[View source]
def main_loop #

[View source]
def main_loop(&block : Int32, Int32 -> Bool) #

[View source]
def memory : StaticArray(UInt16, 32768) #

memory with 15-bit address space storing 16-bit values


[View source]
def memory=(memory : StaticArray(UInt16, 32768)) #

memory with 15-bit address space storing 16-bit values


[View source]
def op_add(reg : Int32, a : UInt16, b : UInt16, &) #

[View source]
def op_and(reg : Int32, a : UInt16, b : UInt16, &) #

[View source]
def op_call(a : UInt16) #

[View source]
def op_eq(reg : Int32, a : UInt16, b : UInt16, &) #

[View source]
def op_gt(reg : Int32, a : UInt16, b : UInt16, &) #

[View source]
def op_halt #

[View source]
def op_in(reg : Int32, &) #

[View source]
def op_jf(a : UInt16, b : UInt16, &block : -> ) #

[View source]
def op_jmp(value : UInt16) #

[View source]
def op_jt(a : UInt16, b : UInt16, &block : -> ) #

[View source]
def op_mod(reg : Int32, a : UInt16, b : UInt16, &) #

[View source]
def op_mult(reg : Int32, a : UInt16, b : UInt16, &) #

[View source]
def op_noop(&) #

[View source]
def op_not(reg : Int32, value : UInt16, &) #

[View source]
def op_or(reg : Int32, a : UInt16, b : UInt16, &) #

[View source]
def op_out(value : UInt16, &) #

[View source]
def op_pop(reg : Int32, &block : -> ) #

[View source]
def op_push(value : UInt16, &) #

[View source]
def op_ret #

[View source]
def op_rmem(reg : Int32, addr : UInt16, &) #

[View source]
def op_set(reg : Int32, value : UInt16, &) #

[View source]
def op_wmem(addr : UInt16, value : UInt16, &) #

[View source]
def output : ACON::Output::Interface #

[View source]
def output=(output : ACON::Output::Interface) #

[View source]
def pc : Int32 #

program counter


[View source]
def pc=(pc : Int32) #

program counter


[View source]
def register_at(index : Int32) : Int32 #

[View source]
def registers : StaticArray(UInt16, 8) #

eight registers


[View source]
def registers=(registers : StaticArray(UInt16, 8)) #

eight registers


[View source]
def stack : Deque(UInt16) #

unbounded stack which holds individual 16-bit values


[View source]
def stack=(stack : Deque(UInt16)) #

unbounded stack which holds individual 16-bit values


[View source]
def to_register(value : UInt16) : Int32 #

[View source]
def to_value(value : UInt16) : UInt16 #

[View source]
def value_at(index : Int32) : UInt16 #

[View source]