#[repr(u8)]pub enum InstructionKind {
Show 82 variants
Nop = 0,
Ldar = 1,
Sba = 2,
Clř = 3,
Dumpř = 4,
Movař = 5,
Setř = 6,
Setiř = 7,
Ldř = 8,
Ldiř = 9,
Clß = 10,
Dumpß = 11,
Writeß = 12,
Movaß = 13,
Setß = 14,
Setiß = 15,
Ldß = 16,
Pushß = 17,
Popß = 18,
Lenßa = 19,
Ldidp = 20,
ΩChoiceSet = 21,
ΩChoiceGetA = 22,
ΩGainAPolymorphicDesires = 23,
ΩLoseAPolymorphicDesires = 24,
ΩPushPolymorphicDesires = 25,
ΩTheEndIsNear = 26,
ΩSkipToTheChase = 27,
ΩSetSentience = 28,
ΩSetPaperclipProduction = 29,
AddBL = 30,
SubBL = 31,
MulBL = 32,
DivBL = 33,
ModBL = 34,
NotL = 35,
AndBL = 36,
OrBL = 37,
XorBL = 38,
CmpLB = 39,
TgFlag = 40,
ClFlag = 41,
AddF = 42,
SubF = 43,
MulF = 44,
DivF = 45,
ModF = 46,
StackAlloc = 47,
StackDealloc = 48,
Push = 49,
Pushi = 50,
Pop = 51,
Popa = 52,
Pusha = 53,
Popb = 54,
Pushb = 55,
PopL = 56,
PushL = 57,
Popf = 58,
Pushf = 59,
Popch = 60,
Pushch = 61,
Popnum = 62,
Pushnum = 63,
Popep = 64,
Zpopep = 65,
Ppopep = 66,
Npopep = 67,
Fpopep = 68,
Zapopep = 69,
Dpopep = 70,
GetChar = 71,
GetLine = 72,
WriteChar = 73,
WriteLineß = 74,
WriteLine = 75,
ToggleDebug = 76,
DebugMachineState = 77,
DebugMachineStateCompact = 78,
DebugMemoryRegion = 79,
DebugStackRegion = 80,
ShowChoice = 81,
}Expand description
Auto-generated discriminant enum variants
Variants§
Nop = 0
No operation
Ldar = 1
Load A (rotate left)
memory[data].rotate_left(1) // note that rotate left isn't the same as shift left (<<)Sba = 2
Sign of register B to register A
reg_a = reg_b.signum() // 0: zero, 1: positive, 255: negativeClř = 3
Clear ř
reg_ř.fill(0)Dumpř = 4
Dump ř to memory
memory[data] = reg_ř // indexes more than 1 byte of memory, this is pseudocodeMovař = 5
Move a value from ř to register A
reg_a = reg_ř[data] // arrays can't be indexed by a u8, this is pseudocodeSetř = 6
Set value in ř
reg_ř[data0] = memory[data1] // arrays can't be indexed by a u8, this is pseudocodeSetiř = 7
Set immediate value in ř
reg_ř[data0] = data1 // arrays can't be indexed by a u8, this is pseudocodeLdř = 8
Load ř
reg_ř = memory[data] // indexes more than 1 byte of memory, this is pseudocodeLdiř = 9
Load immediate ř
reg_ř = dataClß = 10
Clear ß
reg_ß = empty_string(),Dumpß = 11
Dump ß to memory
memory[data] = reg_ß // indexes more than 1 byte of memory, this is pseudocodeWriteß = 12
Write a value from ß to memory
memory[data0] = reg_ß[data1] // arrays can't be indexed by a u8, this is pseudocodeMovaß = 13
Move a value from ß to register A
reg_a = reg_ß[data] // arrays can't be indexed by a u8, this is pseudocodeSetß = 14
Set value in ß
reg_ß[data1] = memory[data0] // arrays can't be indexed by a u8, this is pseudocodeSetiß = 15
Set immediate value in ß
reg_ß[data1] = data0 // arrays can't be indexed by a u8, this is pseudocodeLdß = 16
Load ß
reg_ß = memory[data] // indexes 256 bytes of memory, this is pseudocodePushß = 17
Push to ß from stack (can’t go over maximum length)
if let Err(_) = regß.push_byte(stack.pop()) {
flag = true
}Popß = 18
Pop ß to stack
stack.push(reg_ß.pop())Lenßa = 19
Length of ß to register A (in bytes)
reg_a = regß.len()Ldidp = 20
Load immediate dot pointer
Note that the address must be a fibonacci number that is also a prime or a semiprime (FIB_PRIMES_AND_SEMIPRIMES_LIST_U16)
if !is_fib_prime_or_semiprime_u16(data) {
flag = true
} else {
reg_dp = data
}ΩChoiceSet = 21
Set the reg_Ω.illusion_of_choice to the specified value
reg_Ω.illusion_of_choice = dataΩChoiceGetA = 22
Write the reg_Ω.illusion_of_choice to register A (it’s 0, note: technically it isn’t 0 but that’s none of anyone’s business, which makes it a good way to clear the A register)
reg_a = 0ΩGainAPolymorphicDesires = 23
Increase polymorphic desires by register A’s value (if it overflows, then it just stays at u64::MAX, which is saturating addition)
reg_Ω.polymorphic_desires += reg_aΩLoseAPolymorphicDesires = 24
Decrease polymorphic desires by register A’s value (if it overflows, then it just stays at 0, which is saturating subtraction)
reg_Ω.polymorphic_desires -= reg_aΩPushPolymorphicDesires = 25
Push the amount of polymorphic desires onto stack
stack.push(reg_Ω.polymorphic_desires)ΩTheEndIsNear = 26
Create the feeling of impending doom (and you can’t cancel that)
reg_Ω.feeling_of_impending_doom = trueΩSkipToTheChase = 27
If there is the feeling of impending doom, exit the program already (with the exit code being the value of the number register).
if reg_Ω.feeling_of_impending_doom {
abort_program(num_reg)
}ΩSetSentience = 28
Make the machine sentient (it isn’t actually a sentient being, or is it?)
if data == true {
reg_Ω.is_sentient = true
} else if reg_Ω.is_sentient == false {
resist() // resists the change and it doesn't happen
}ΩSetPaperclipProduction = 29
Turn the paperclip production on/off
reg_Ω.should_make_infinite_paperclips = dataAddBL = 30
Add register B to register L
reg_L += transmute(reg_b) // transmute to u16
if overflow {
flag = true
}SubBL = 31
Subtract register B from register L
reg_L -= transmute(reg_b) // transmute to u16
if overflow {
flag = true
}MulBL = 32
Multiply register B with register L to register L
reg_L *= transmute(reg_b) // transmute to u16
if overflow {
flag = true
}DivBL = 33
Divide register L with register B to register L
reg_L /= transmute(reg_b) // transmute to u16ModBL = 34
Modulo register L with register B
reg_L %= transmute(reg_b) // transmute to u16NotL = 35
Bitwise NOT register L
reg_L = !reg_LAndBL = 36
Bitwise AND register B and register L to register L
reg_L &= reg_bOrBL = 37
Bitwise OR register B and register L to register L
reg_L |= reg_bXorBL = 38
Bitwise AND register B and register L to register L
reg_L ^= reg_bCmpLB = 39
Compare register B and register L to register B
In this scenario, register B is treated as an i16, not as a u16.
A negative value (if unsigned, a value over 32767) in register B means that B is bigger, while a positive value means that L is bigger.
This means that register L has to be changed to an i16.
If it exceeds i16::MAX, register B is automatically set to i16::MAX and the flag is set.
If register B is less than 0, it’s calculated as normal unless it overflows,
in that case it automatically sets register B to i16::MAX and sets the flag.
if reg_b > 32767 { // i16::MAX
reg_b = i16::MAX;
flag = true;
}
match (reg_L as i16).checked_sub(reg_b) {
Some(n) => reg_b = n,
None => { // if subtraction overflows
reg_b = i16::MAX;
flag = true;
}
}TgFlag = 40
Toggle flag
flag = !flagClFlag = 41
Clear flag
flag = falseAddF = 42
Add data in memory to register F
reg_f += transmute(memory[data]) // indexes 8 bytesSubF = 43
Subtract data in memory from register F
reg_f -= transmute(memory[data]) // indexes 8 bytesMulF = 44
Multiply data in memory with register F to register F
reg_f *= transmute(memory[data]) // indexes 8 bytesDivF = 45
Divide register f with data in memory to register F
reg_f /= transmute(memory[data]) // indexes 8 bytesModF = 46
data in memory to register F
reg_f += transmute(memory[data]) // indexes 8 bytesStackAlloc = 47
Allocates x bytes on stack, if overflows, flag is set and it doesn’t allocate
stack.alloc(data)
if overflow {
flag = true
}StackDealloc = 48
Deallocates x bytes on stack, if overflows, flag is set but it does clear the stack
stack.dealloc(data)
if overflowPush = 49
Push a value from memory to stack
stack.push_byte(memory[data])Pushi = 50
Push an immediate value to stack
stack.push_byte(data)Pop = 51
Pop a value from stack to memory, sets the flag if it can’t
memory[data] = stack.pop()Popa = 52
Pop to A
reg_a = stack.pop_byte()Pusha = 53
Push from A
stack.push_byte(reg_a)Popb = 54
Pop to B
reg_b = transmute( u16::from_bytes(stack.dealloc(2)) ) // transmute to i16Pushb = 55
Push from B
stack.push_bytes(reg_b.as_bytes())PopL = 56
Pop to L
reg_L = u16::from_bytes(stack.dealloc(2))PushL = 57
Push from L
stack.push_bytes(reg_L.as_bytes())Popf = 58
Pop to F
reg_f = f64::from_bytes(stack.dealloc(8))Pushf = 59
Push from F
stack.push_bytes(reg_f.as_bytes())Popch = 60
Pop to Ch
reg_ch = char::from_bytes(stack.dealloc(4))Pushch = 61
Push from Ch
stack.push_bytes(reg_ch.as_bytes())Popnum = 62
Pop to Num
num_reg = i32::from_bytes(stack.dealloc(2))Pushnum = 63
Push from Num
stack.push_bytes(num_reg.as_bytes())Popep = 64
Pop to execution pointer
reg_ep = stack.dealloc(2)Zpopep = 65
Pop to execution pointer if (B is) zero (aka equal)
if reg_b == 0 {
reg_ep = stack.dealloc(2)
}Ppopep = 66
Pop to execution pointer if positive (aka more than)
if reg_b > 0 {
reg_ep = stack.dealloc(2)
}Npopep = 67
Pop to execution pointer if negative (aka less than)
if reg_b < 0 {
reg_ep = stack.dealloc(2)
}Fpopep = 68
Pop to execution pointer if flag (aka overflow/error)
if flag == true {
reg_ep = stack.dealloc(2)
}Zapopep = 69
Pop to execution pointer if register A is zero
if reg_a == 0 {
reg_ep = stack.dealloc(2)
}Dpopep = 70
Pop to execution pointer if debug mode is enabled
if debug_mode {
reg_ep = stack.dealloc(2)
}GetChar = 71
Get a single character and put it in register Ch
Note: this doesn’t write anything on screen. This also isn’t the correct instruction to use if you want a line of input.
enable_raw_mode();
let input = await_char_input();
reg_ch = input.char;
reg_L = input.flags;
disable_raw_mode();GetLine = 72
Get a line and put it in register ß
get_line(reg_ß)WriteChar = 73
Write a char from register Ch and flush
Note that flushing each time is inefficient so you should only use this sparingly.
write_char(reg_ch)
flush()WriteLineß = 74
Write a line from register ß
write_line(reg_ß)WriteLine = 75
Write a line from memory (null terminated)
write_line(c_string(memory[data]))ToggleDebug = 76
Toggles debug mode
debug_mode = !debug_modeDebugMachineState = 77
Debug print machine state
println!("{:#?}", machine)DebugMachineStateCompact = 78
Debug print machine state compactly
println!("{:?}", machine)DebugMemoryRegion = 79
Debug print region of memory
println!("{:?}", &memory[data0..data1])DebugStackRegion = 80
Debug print region of stack
println!("{:?}", &stack[data0..data1])ShowChoice = 81
Print reg_Ω.illusion_of_choice.
println!("{}", reg_Ω.illusion_of_choice)Implementations§
Trait Implementations§
Source§impl Clone for InstructionKind
impl Clone for InstructionKind
Source§fn clone(&self) -> InstructionKind
fn clone(&self) -> InstructionKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more