-
Notifications
You must be signed in to change notification settings - Fork 18
Register Machine Code Format
<Here goes a description of the register machine code format, similar to Section 5.1.5 of SICP JS>
Based on SICP Instruction Summary 5.1.5:
This section is still work in progress.
Assigning a value from register 'register-name-from' to 'register-name-to':
assign(register-name-to, reg(register-name-from))For example, if you assign contents from register D to register C:
assign("C", reg("D"))Assigns a constant value to 'register-name'. Constant value is predefined.
assign(register-name, constant(constant-value))During the treatment of a self-evaluating expression, we can also treat the expression as a constant value. Examples include:
Assignment of numeric values:
assign("A", constant(100))Assignment of booleans:
assign("B", constant(true))
assign("C", constant(false))- "register-name" seen in round brackets are just the actual register names in strings.
Even though SICP Instruction Summary 5.1.5 is already listed some instructions, we will remention it here as some instrcution APIs are not consistent.
Perform an operation:
perform(list(op(operation_name), inputs...))Test an operation:
test(list(op(operation_name), inputs...))make a branch with a label:
branch(label(label_name))Go to corresponding label_name value:
go_to(label(label_name))Go to corredponding register value:
go_to(reg(register_name))Save the register value into stack:
save(register_name)Restore the value from stack to register:
restore(register_name)Get the Nth element of the vector:
vector_ref(vector,n) Set the Nth element of the vector with a value:
vector_set(vector, n, value)