]> gitweb.factorcode.org Git - factor.git/commitdiff
cpu.x86.assembler: add support for absolute addressing on x86-64; [RIP+] now behaves...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 4 Apr 2010 23:42:57 +0000 (19:42 -0400)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 4 Apr 2010 23:42:57 +0000 (19:42 -0400)
basis/cpu/x86/64/64.factor
basis/cpu/x86/64/bootstrap.factor
basis/cpu/x86/assembler/assembler-tests.factor
basis/cpu/x86/assembler/assembler.factor
basis/cpu/x86/assembler/operands/operands.factor

index 7e1c5c1f48fe6cd8ceb00624c640a7ce7702ce92..4dfb250348f1a62026ccb694343494222fb9deb8 100644 (file)
@@ -55,13 +55,13 @@ M: x86.64 %vm-field-ptr ( dst offset -- )
 : param@ ( n -- op ) reserved-stack-space + stack@ ;
 
 M: x86.64 %prologue ( n -- )
-    temp-reg -7 [] LEA
+    temp-reg -7 [RIP+] LEA
     dup PUSH
     temp-reg PUSH
     stack-reg swap 3 cells - SUB ;
 
 M: x86.64 %prepare-jump
-    pic-tail-reg xt-tail-pic-offset [] LEA ;
+    pic-tail-reg xt-tail-pic-offset [RIP+] LEA ;
 
 : load-cards-offset ( dst -- )
     0 MOV rc-absolute-cell rel-cards-offset ;
index a82c8c17e2b8d844ffb4581ef694bac928a54645..69734df225140c3ebc6e82728b043eab245d103f 100644 (file)
@@ -47,7 +47,7 @@ IN: bootstrap.x86
 ] jit-prolog jit-define
 
 [
-    temp3 5 [] LEA
+    temp3 5 [RIP+] LEA
     0 JMP rc-relative rt-entry-point-pic-tail jit-rel
 ] jit-word-jump jit-define
 
index 0a6ae5a48464bccbf24a4f7fce93267e8f526029..8ed789f392e317d269aae787c903a075a9093f9f 100644 (file)
@@ -1,5 +1,5 @@
 USING: cpu.x86.assembler cpu.x86.assembler.operands
-kernel tools.test namespaces make ;
+kernel tools.test namespaces make layouts ;
 IN: cpu.x86.assembler.tests
 
 [ { HEX: 40 HEX: 8a HEX: 2a } ] [ [ BPL RDX [] MOV ] { } make ] unit-test
@@ -164,5 +164,11 @@ IN: cpu.x86.assembler.tests
 
 [ { 15 183 195 } ] [ [ EAX BX MOVZX ] { } make ] unit-test
 
-[ { 100 199 5 0 0 0 0 123 0 0 0 } ] [ [ 0 [] FS 123 MOV ] { } make ] unit-test
+bootstrap-cell 4 = [
+    [ { 100 199 5 0 0 0 0 123 0 0 0 } ] [ [ 0 [] FS 123 MOV ] { } make ] unit-test
+] when
 
+bootstrap-cell 8 = [
+    [ { 72 137 13 123 0 0 0 } ] [ [ 123 [RIP+] RCX MOV ] { } make ] unit-test
+    [ { 101 72 137 12 37 123 0 0 0 } ] [ [ 123 [] GS RCX MOV ] { } make ] unit-test
+] when
index 32eeaaad1d76a0aa9ff60518592926005b6174dc..b91083dad1f64345b727ecc2330d403c61e63a4c 100644 (file)
@@ -1,9 +1,9 @@
-! Copyright (C) 2005, 2009 Slava Pestov, Joe Groff.
+! Copyright (C) 2005, 2010 Slava Pestov, Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays io.binary kernel combinators kernel.private math
-math.bitwise locals namespaces make sequences words system
-layouts math.order accessors cpu.x86.assembler.operands
-cpu.x86.assembler.operands.private ;
+USING: arrays io.binary kernel combinators
+combinators.short-circuit math math.bitwise locals namespaces
+make sequences words system layouts math.order accessors
+cpu.x86.assembler.operands cpu.x86.assembler.operands.private ;
 QUALIFIED: sequences
 IN: cpu.x86.assembler
 
@@ -22,7 +22,11 @@ IN: cpu.x86.assembler
 GENERIC: sib-present? ( op -- ? )
 
 M: indirect sib-present?
-    [ base>> { ESP RSP R12 } member? ] [ index>> ] [ scale>> ] tri or or ;
+    {
+        [ base>> { ESP RSP R12 } member? ]
+        [ index>> ]
+        [ scale>> ]
+    } 1|| ;
 
 M: register sib-present? drop f ;
 
index bd9a3f6cddff869c2b899b93f8ceca6d2a302636..e8d98cde1730e240779d9d350d8e9a2c05cef439 100644 (file)
@@ -1,13 +1,9 @@
-! Copyright (C) 2008, 2009 Slava Pestov, Joe Groff.
+! Copyright (C) 2008, 2010 Slava Pestov, Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel words math accessors sequences namespaces
 assocs layouts cpu.x86.assembler.syntax ;
 IN: cpu.x86.assembler.operands
 
-! In 32-bit mode, { 1234 } is absolute indirect addressing.
-! In 64-bit mode, { 1234 } is RIP-relative.
-! Beware!
-
 REGISTERS: 8 AL CL DL BL SPL BPL SIL DIL R8B R9B R10B R11B R12B R13B R14B R15B ;
 
 ALIAS: AH SPL
@@ -90,7 +86,13 @@ M: object operand-64? drop f ;
 PRIVATE>
 
 : [] ( reg/displacement -- indirect )
-    dup integer? [ [ f f f ] dip ] [ f f f ] if <indirect> ;
+    dup integer?
+    [ [ f f bootstrap-cell 8 = 0 f ? ] dip <indirect> ]
+    [ f f f <indirect> ]
+    if ;
+
+: [RIP+] ( displacement -- indirect )
+    [ f f f ] dip <indirect> ;
 
 : [+] ( reg displacement -- indirect )
     dup integer?