Nicolas Winkler 5 роки тому
батько
коміт
d7d585f5de
2 змінених файлів з 21 додано та 3 видалено
  1. 19 1
      src/compile.rs
  2. 2 2
      src/main.rs

+ 19 - 1
src/compile.rs

@@ -116,7 +116,7 @@ impl ir::ConstVisitor for CodeGenerator {
             if factors.len() > 1 ||
                 factors.len() >= 1 && !factors.contains_key(&0) {
                 dynasm!(self.buffer
-                    ; mov cl, BYTE [rdi]
+                    ; movzx ecx, BYTE [rdi]
                 );
             }
             for (&offset, &factor) in factors {
@@ -136,6 +136,24 @@ impl ir::ConstVisitor for CodeGenerator {
                         ; sub BYTE [rdi + offset as i32], cl
                     );
                 }
+                else if factor == 3 {
+                    dynasm!(self.buffer
+                        ; lea ebx, [rcx + rcx * 2]
+                        ; mov [rdi + offset as i32], bl
+                    );
+                }
+                else if factor == 5 {
+                    dynasm!(self.buffer
+                        ; lea ebx, [rcx + rcx * 4]
+                        ; mov [rdi + offset as i32], bl
+                    );
+                }
+                else if factor == 9 {
+                    dynasm!(self.buffer
+                        ; lea ebx, [rcx + rcx * 8]
+                        ; mov [rdi + offset as i32], bl
+                    );
+                }
                 else if factor.count_ones() == 1 {
                     dynasm!(self.buffer
                         ; mov bl, cl

+ 2 - 2
src/main.rs

@@ -43,9 +43,9 @@ fn main() -> io::Result<()> {
         for ref inst in &insts {
             //println!("{}\n", inst.to_string());
         }
-        println!("{}", transpile_c::transpile_c(&insts));
+        //println!("{}", transpile_c::transpile_c(&insts));
 
-        //let code = compile::compile(&insts);
+        let code = compile::compile(&insts);
     }
     else if let Err(msg) = insts {
         println!("error parsing: {}", msg);