8086asm: begin adding MODRM-enabled ops

This commit is contained in:
Virgil Dupras 2020-06-12 12:07:48 -04:00
parent 749fdf1b18
commit 210b833c71
4 changed files with 17 additions and 4 deletions

View File

@ -3,7 +3,12 @@ JMP8, L1 FWR8 ( start )
L2 BSET ( msg ) L2 BSET ( msg )
," Hello, World!" 0 A, ," Hello, World!" 0 A,
L1 FSET ( start ) L1 FSET ( start )
AH 0x42 MOVri, CLI,
AH 0 MOVri,
AL 2 MOVri,
0x10 INT, 0x10 INT,
SI L2 @ ( msg ) MOVrI, SI L2 @ ( msg ) MOVrI,
AH 0x0e MOVri,
LODSB,
AL AL ORrr,
PC ORG @ DUMP PC ORG @ DUMP

View File

@ -1,2 +1,8 @@
( Splits word into msb/lsb, lsb being on TOS )
: SPLITB
256 /MOD SWAP
;
: PC H@ ORG @ - ; : PC H@ ORG @ - ;
: A, C, ; : A, C, ;
( dst8 src8 -- modrm )
: MODRMrr 0x7 AND 3 LSHIFT SWAP 0x7 AND OR 0xc0 OR ;

View File

@ -1,6 +1,9 @@
: MOVri, SWAP 0xb0 OR A, A, ; : MOVri, SWAP 0xb0 OR A, A, ;
: MOVrI, SWAP 0xb0 OR A, 256 /MOD A, A, ; : MOVrI, SWAP 0xb0 OR A, SPLITB A, A, ;
: INT, 0xcd A, A, ; : INT, 0xcd A, A, ;
( no argument, flow ops are special ) ( no argument, flow ops are special )
: JMP8, 0xeb A, ; : JMP8, 0xeb A, ;
: JMP16, 0xe9 A, ; : JMP16, 0xe9 A, ;
: LODSB, 0xac A, ;
: CLI, 0xfa A, ;
: ORrr, 0x08 A, MODRMrr A, ;

View File

@ -10,8 +10,7 @@
: IFNC, JRC, FJR, ; ) : IFNC, JRC, FJR, ; )
: THEN, : THEN,
DUP PC ( l l pc ) DUP PC ( l l pc )
-^ ( l off ) -^ 1- ( l off )
( warning: l is a PC offset, not a mem addr! ) ( warning: l is a PC offset, not a mem addr! )
SWAP ORG @ + ( BIN( @ - ) ( off addr ) SWAP ORG @ + ( BIN( @ - ) ( off addr )
C! ; C! ;