self.copy_to_top_of_stack("t0");
},
IR::Store8 => { // ( x addr -- )
+ self.label("# store 8");
self.pop_some_to("t0 t1");
self.line("sb t0, 0(t1)"); // store x at addr
},
IR::Store16 => { // ( x addr -- )
+ self.label("# store 16");
self.pop_some_to("t0 t1");
self.line("sh t0, 0(t1)"); // store x at addr
},
IR::Store32 => { // ( x addr -- )
+ self.label("# store 32");
self.pop_some_to("t0 t1");
self.line("sw t0, 0(t1)"); // store x at addr
},
IR::Store => { // ( x addr -- )
+ self.label("# store 64");
self.pop_some_to("t0 t1");
self.line("sd t0, 0(t1)"); // store x at addr
},
self.pop_call_push("t0 t1", "sub t0, t0, t1", "t0");
},
IR::MultiplyU64 => {
+ self.label("# multiply");
self.pop_call_push("t0 t1", "mul t0, t0, t1", "t0");
},
IR::DivideU64 => {
+ self.label("# divide");
self.pop_call_push("t0 t1", "div t0, t0, t1", "t0");
},
IR::ModU64 => {
+ self.label("# mod");
self.pop_call_push("t0 t1", "rem t0, t0, t1", "t0");
},
IR::Dup => {
self.move_stack_ptr_by_cells(1);
},
IR::Equals => {
+ self.label("# equals");
// Yes, this is the same as subtract, since we're treating 0 as true, and
// others as false.
self.pop_call_push("t0 t1", "sub t0, t0, t1", "t0");
self.push_from("t0");
},
IR::BitwiseOr => {
+ self.label("# |");
self.pop_call_push("t0 t1", "or t0, t0, t1", "t0");
},
IR::Sys0 => {
+ self.label("# syscall 0 args");
self.pop_call_push("a7", "ecall", "a0");
},
IR::Sys1 => {
+ self.label("# syscall 1 arg");
self.pop_call_push("a0 a7", "ecall", "a0");
},
IR::Sys2 => {
+ self.label("# syscall 2 args");
self.pop_call_push("a0 a1 a7", "ecall", "a0");
},
IR::Sys3 => {
+ self.label("# syscall 3 args");
self.pop_call_push("a0 a1 a2 a7", "ecall", "a0");
},
IR::Sys4 => {
+ self.label("# syscall 4 args");
self.pop_call_push("a0 a1 a2 a3 a7", "ecall", "a0");
},
IR::Sys5 => {
+ self.label("# syscall 5 args");
self.pop_call_push("a0 a1 a2 a3 a4 a7", "ecall", "a0");
},
IR::Sys6 => {
+ self.label("# syscall 6 args");
self.pop_call_push("a0 a1 a2 a3 a4 a5 a7", "ecall", "a0");
},
// https://cmput229.github.io/229-labs-RISCV/RISC-V-Examples_Public/03-Conditionals/03b-If_Else.html