cpu.x86.assembler: AH CH DH BH register operands now work properly
parent
05f98a184c
commit
f5a951801e
|
@ -2,6 +2,15 @@ USING: cpu.x86.assembler cpu.x86.assembler.operands
|
|||
kernel tools.test namespaces make layouts ;
|
||||
IN: cpu.x86.assembler.tests
|
||||
|
||||
! small registers
|
||||
[ { 128 192 12 } ] [ [ AL 12 <byte> ADD ] { } make ] unit-test
|
||||
[ { 128 196 12 } ] [ [ AH 12 <byte> ADD ] { } make ] unit-test
|
||||
[ { 176 12 } ] [ [ AL 12 <byte> MOV ] { } make ] unit-test
|
||||
[ { 180 12 } ] [ [ AH 12 <byte> MOV ] { } make ] unit-test
|
||||
[ { 198 0 12 } ] [ [ EAX [] 12 <byte> MOV ] { } make ] unit-test
|
||||
[ { 0 235 } ] [ [ BL CH ADD ] { } make ] unit-test
|
||||
[ { 136 235 } ] [ [ BL CH MOV ] { } make ] unit-test
|
||||
|
||||
! immediate operands
|
||||
cell 4 = [
|
||||
[ { HEX: b9 HEX: 01 HEX: 00 HEX: 00 HEX: 00 } ] [ [ ECX 1 MOV ] { } make ] unit-test
|
||||
|
@ -205,7 +214,6 @@ cell 4 = [
|
|||
[ { HEX: 0f HEX: a3 HEX: 18 } ] [ [ EAX [] EBX BT ] { } make ] unit-test
|
||||
|
||||
! x87 instructions
|
||||
|
||||
[ { HEX: D8 HEX: C5 } ] [ [ ST0 ST5 FADD ] { } make ] unit-test
|
||||
[ { HEX: DC HEX: C5 } ] [ [ ST5 ST0 FADD ] { } make ] unit-test
|
||||
[ { HEX: D8 HEX: 00 } ] [ [ ST0 EAX [] FADD ] { } make ] unit-test
|
||||
|
|
|
@ -214,7 +214,13 @@ M: operand POP { BIN: 000 f HEX: 8f } 1-operand ;
|
|||
<PRIVATE
|
||||
|
||||
GENERIC# (MOV-I) 1 ( dst src -- )
|
||||
M: register (MOV-I) [ t HEX: b8 short-operand ] [ cell, ] bi* ;
|
||||
|
||||
M: register (MOV-I)
|
||||
dup byte?
|
||||
[ [ t HEX: b0 short-operand ] [ 1, ] bi* ]
|
||||
[ [ t HEX: b8 short-operand ] [ cell, ] bi* ]
|
||||
if ;
|
||||
|
||||
M: operand (MOV-I)
|
||||
{ BIN: 000 t HEX: c6 }
|
||||
over byte? [ immediate-1 ] [ immediate-4 ] if ;
|
||||
|
|
|
@ -6,10 +6,7 @@ IN: cpu.x86.assembler.operands
|
|||
|
||||
REGISTERS: 8 AL CL DL BL SPL BPL SIL DIL R8B R9B R10B R11B R12B R13B R14B R15B ;
|
||||
|
||||
ALIAS: AH SPL
|
||||
ALIAS: CH BPL
|
||||
ALIAS: DH SIL
|
||||
ALIAS: BH DIL
|
||||
HI-REGISTERS: 8 AH CH DH BH ;
|
||||
|
||||
REGISTERS: 16 AX CX DX BX SP BP SI DI R8W R9W R10W R11W R12W R13W R14W R15W ;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2008, 2009 Slava Pestov.
|
||||
! Copyright (C) 2008, 2010 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel words words.symbol sequences lexer parser fry
|
||||
namespaces combinators assocs ;
|
||||
namespaces combinators assocs math ;
|
||||
IN: cpu.x86.assembler.syntax
|
||||
|
||||
SYMBOL: registers
|
||||
|
@ -9,15 +9,21 @@ SYMBOL: registers
|
|||
registers [ H{ } clone ] initialize
|
||||
|
||||
: define-register ( name num size -- word )
|
||||
[ "cpu.x86.assembler.operands" create ] 2dip {
|
||||
[ create-in ] 2dip {
|
||||
[ 2drop ]
|
||||
[ 2drop define-symbol ]
|
||||
[ drop "register" set-word-prop ]
|
||||
[ nip "register-size" set-word-prop ]
|
||||
} 3cleave ;
|
||||
|
||||
: define-registers ( size names -- )
|
||||
[ swap '[ _ define-register ] map-index ] [ drop ] 2bi
|
||||
registers get set-at ;
|
||||
: (define-registers) ( names start size -- seq )
|
||||
'[ _ + _ define-register ] map-index ;
|
||||
|
||||
SYNTAX: REGISTERS: scan-word ";" parse-tokens define-registers ;
|
||||
: define-registers ( names size -- )
|
||||
[ [ 0 ] dip (define-registers) ] [ drop ] 2bi registers get set-at ;
|
||||
|
||||
SYNTAX: REGISTERS:
|
||||
scan-word [ ";" parse-tokens ] dip define-registers ;
|
||||
|
||||
SYNTAX: HI-REGISTERS:
|
||||
scan-word [ ";" parse-tokens 4 ] dip (define-registers) drop ;
|
||||
|
|
Loading…
Reference in New Issue