diff --git a/basis/cpu/x86/x86-tests.factor b/basis/cpu/x86/x86-tests.factor index bc00d5ba3c..b224efa62a 100644 --- a/basis/cpu/x86/x86-tests.factor +++ b/basis/cpu/x86/x86-tests.factor @@ -1,8 +1,8 @@ USING: compiler.cfg.debugger compiler.cfg.instructions compiler.cfg.registers compiler.codegen.gc-maps compiler.codegen.relocation cpu.architecture cpu.x86 cpu.x86.assembler -cpu.x86.features kernel kernel.private layouts make math math.libm -namespaces sequences system tools.test ; +cpu.x86.assembler.operands cpu.x86.features kernel kernel.private +layouts make math math.libm namespaces sequences system tools.test ; IN: cpu.x86.tests { } [ @@ -12,6 +12,15 @@ IN: cpu.x86.tests assert= ] unit-test +! %add-imm +{ + B{ 72 255 192 } + B{ 72 131 192 29 } +} [ + [ RAX RAX 1 %add-imm ] B{ } make + [ RAX RAX 29 %add-imm ] B{ } make +] unit-test + ! %call-gc { V{ } } [ init-relocation init-gc-maps diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index e3125ecc30..2507365b15 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -130,9 +130,17 @@ M: x86 %set-slot-imm ( src obj slot tag -- ) (%slot-imm) swap MOV ; dst ; inline M: x86 %add 2over eq? [ nip ADD ] [ [+] LEA ] if ; -M: x86 %add-imm 2over eq? [ nip ADD ] [ [+] LEA ] if ; +M: x86 %add-imm ( dst src1 src2 -- ) + 2over eq? [ + nip { { 1 [ INC ] } { -1 [ DEC ] } [ ADD ] } case + ] [ [+] LEA ] if ; + M: x86 %sub int-rep two-operand SUB ; -M: x86 %sub-imm 2over eq? [ nip SUB ] [ neg [+] LEA ] if ; +M: x86 %sub-imm ( dst src1 src2 -- ) + 2over eq? [ + nip { { 1 [ DEC ] } { -1 [ INC ] } [ SUB ] } case + ] [ neg [+] LEA ] if ; + M: x86 %mul int-rep two-operand IMUL2 ; M: x86 %mul-imm IMUL3 ; M: x86 %and int-rep two-operand AND ;