cpu.x86.assembler: add support for absolute addressing on x86-64; [RIP+] now behaves like [] did, and [] now does absolute addressing just like in 32-bit mode
parent
ce16c4ec2c
commit
c0af678c5b
|
@ -55,13 +55,13 @@ M: x86.64 %vm-field-ptr ( dst offset -- )
|
||||||
: param@ ( n -- op ) reserved-stack-space + stack@ ;
|
: param@ ( n -- op ) reserved-stack-space + stack@ ;
|
||||||
|
|
||||||
M: x86.64 %prologue ( n -- )
|
M: x86.64 %prologue ( n -- )
|
||||||
temp-reg -7 [] LEA
|
temp-reg -7 [RIP+] LEA
|
||||||
dup PUSH
|
dup PUSH
|
||||||
temp-reg PUSH
|
temp-reg PUSH
|
||||||
stack-reg swap 3 cells - SUB ;
|
stack-reg swap 3 cells - SUB ;
|
||||||
|
|
||||||
M: x86.64 %prepare-jump
|
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 -- )
|
: load-cards-offset ( dst -- )
|
||||||
0 MOV rc-absolute-cell rel-cards-offset ;
|
0 MOV rc-absolute-cell rel-cards-offset ;
|
||||||
|
|
|
@ -47,7 +47,7 @@ IN: bootstrap.x86
|
||||||
] jit-prolog jit-define
|
] jit-prolog jit-define
|
||||||
|
|
||||||
[
|
[
|
||||||
temp3 5 [] LEA
|
temp3 5 [RIP+] LEA
|
||||||
0 JMP rc-relative rt-entry-point-pic-tail jit-rel
|
0 JMP rc-relative rt-entry-point-pic-tail jit-rel
|
||||||
] jit-word-jump jit-define
|
] jit-word-jump jit-define
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: cpu.x86.assembler cpu.x86.assembler.operands
|
USING: cpu.x86.assembler cpu.x86.assembler.operands
|
||||||
kernel tools.test namespaces make ;
|
kernel tools.test namespaces make layouts ;
|
||||||
IN: cpu.x86.assembler.tests
|
IN: cpu.x86.assembler.tests
|
||||||
|
|
||||||
[ { HEX: 40 HEX: 8a HEX: 2a } ] [ [ BPL RDX [] MOV ] { } make ] unit-test
|
[ { 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
|
[ { 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
|
||||||
|
|
|
@ -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.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: arrays io.binary kernel combinators kernel.private math
|
USING: arrays io.binary kernel combinators
|
||||||
math.bitwise locals namespaces make sequences words system
|
combinators.short-circuit math math.bitwise locals namespaces
|
||||||
layouts math.order accessors cpu.x86.assembler.operands
|
make sequences words system layouts math.order accessors
|
||||||
cpu.x86.assembler.operands.private ;
|
cpu.x86.assembler.operands cpu.x86.assembler.operands.private ;
|
||||||
QUALIFIED: sequences
|
QUALIFIED: sequences
|
||||||
IN: cpu.x86.assembler
|
IN: cpu.x86.assembler
|
||||||
|
|
||||||
|
@ -22,7 +22,11 @@ IN: cpu.x86.assembler
|
||||||
GENERIC: sib-present? ( op -- ? )
|
GENERIC: sib-present? ( op -- ? )
|
||||||
|
|
||||||
M: indirect sib-present?
|
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 ;
|
M: register sib-present? drop f ;
|
||||||
|
|
||||||
|
|
|
@ -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.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel words math accessors sequences namespaces
|
USING: kernel words math accessors sequences namespaces
|
||||||
assocs layouts cpu.x86.assembler.syntax ;
|
assocs layouts cpu.x86.assembler.syntax ;
|
||||||
IN: cpu.x86.assembler.operands
|
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 ;
|
REGISTERS: 8 AL CL DL BL SPL BPL SIL DIL R8B R9B R10B R11B R12B R13B R14B R15B ;
|
||||||
|
|
||||||
ALIAS: AH SPL
|
ALIAS: AH SPL
|
||||||
|
@ -90,7 +86,13 @@ M: object operand-64? drop f ;
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: [] ( reg/displacement -- indirect )
|
: [] ( 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 )
|
: [+] ( reg displacement -- indirect )
|
||||||
dup integer?
|
dup integer?
|
||||||
|
|
Loading…
Reference in New Issue