[pypy-svn] r56876 - in pypy/branch/oo-jit/pypy/jit/codegen/x86_64: . test

witulski at codespeak.net witulski at codespeak.net
Thu Jul 31 15:42:40 CEST 2008


Author: witulski
Date: Thu Jul 31 15:42:39 2008
New Revision: 56876

Modified:
   pypy/branch/oo-jit/pypy/jit/codegen/x86_64/assembler.py
   pypy/branch/oo-jit/pypy/jit/codegen/x86_64/test/test_assembler.py
Log:
(cfBolz, witulski) 
Changed ADD. created MOV


Modified: pypy/branch/oo-jit/pypy/jit/codegen/x86_64/assembler.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/x86_64/assembler.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/x86_64/assembler.py	Thu Jul 31 15:42:39 2008
@@ -18,6 +18,18 @@
                 "r15": (1, 7),
                 }                  
 
+def make_two_quadreg_instr(opcode):
+    # XXX for now, arg1 and arg2 are registers
+    def quadreg_instr(self, arg1, arg2):
+        rexR, modrm1 = self.get_register_bits(arg1)
+        rexB, modrm2 = self.get_register_bits(arg2)
+        #rexW(1) = 64bitMode rexX(0) = doesn't matter
+        self.write_rex_byte(1, rexR, 0, rexB)
+        self.write(opcode)
+        self.write_modRM_byte(3, modrm1, modrm2)
+    return quadreg_instr
+
+
 class X86_64CodeBuilder(object):
     """ creats x86_64 opcodes"""
     def write(self, data):
@@ -28,15 +40,9 @@
         """ tells the current position in memory"""
         raise NotImplementedError
     
-    # XXX for now, arg1 and arg2 are registers
-    def ADD(self, arg1, arg2):
-        rexR, modrm1 = self.get_register_bits(arg1)
-        rexB, modrm2 = self.get_register_bits(arg2)
-        #rexW(1) = 64bitMode rexX(0) = doesn't matter
-        self.write_rex_byte(1, rexR, 0, rexB)
-        self.write('\x00')
-        self.write_modRM_byte(3, modrm1, modrm2)
-               
+    ADD = make_two_quadreg_instr("\x00")
+    MOV = make_two_quadreg_instr("\x8B")
+        
     def get_register_bits(self, register):
         return REGISTER_MAP[register]
     
@@ -47,4 +53,5 @@
         
     def write_modRM_byte(self, mod, reg, rm):
         byte = mod << 6 | (reg << 3) | rm
-        self.write(chr(byte))
\ No newline at end of file
+        self.write(chr(byte))
+        

Modified: pypy/branch/oo-jit/pypy/jit/codegen/x86_64/test/test_assembler.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/x86_64/test/test_assembler.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/x86_64/test/test_assembler.py	Thu Jul 31 15:42:39 2008
@@ -15,4 +15,9 @@
     mc.ADD("rax", "r11")
     assert mc.get_as_string() == "\x49\x00\xC3"
     mc.ADD("rbx", "rbx")
-    assert mc.get_as_string() == "\x49\x00\xC3\x48\x00\xDB"
\ No newline at end of file
+    assert mc.get_as_string() == "\x49\x00\xC3\x48\x00\xDB"
+    
+def test_mov():
+    mc = AsmTest()
+    mc.MOV("r15","rsp")
+    assert mc.get_as_string() == "\x4C\x8B\xFC"
\ No newline at end of file



More information about the Pypy-commit mailing list