瀏覽代碼

implement load

jmelesky 4 年之前
父節點
當前提交
fbdc9b618b
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      src/main.rs

+ 7 - 0
src/main.rs

@@ -178,6 +178,7 @@ fn um_step(um: &mut UMState, op: UMOp) {
             let new_arr = vec![032; um.regs[c as usize] as usize];
             let new_arr_add = um.mem.len() as u32;
             um.mem.push(new_arr);
+            um.arrmap.insert(new_arr_add, new_arr_add as usize);
             um.regs[b as usize] = new_arr_add;
         },
         UMOp::Abandon(c) => {
@@ -196,6 +197,12 @@ fn um_step(um: &mut UMState, op: UMOp) {
             }
         },
         UMOp::Load(b, c) => {
+            let new_arr = um.mem[um.arrmap[&um.regs[b as usize]]].clone();
+            let new_arr_add = um.mem.len() as u32;
+            um.mem.push(new_arr);
+            um.arrmap.remove(&0);
+            um.arrmap.insert(0,new_arr_add as usize);
+            um.pc = um.regs[c as usize] as usize;
         },
         UMOp::Value(a, val) => {
             um.regs[a as usize] = val