~vdupras/duskos

58df023daf6219f2dc750cd44f199a77169c7fd9 — Virgil Dupras 12 days ago 6420850
hal i386: add inc/dec special cases to W+n, A+n, and [+n],
2 files changed, 14 insertions(+), 4 deletions(-)

M fs/asm/i386.fs
M fs/xcomp/i386/kernel.fs
M fs/asm/i386.fs => fs/asm/i386.fs +5 -1
@@ 297,7 297,11 @@ op &, and,         op |, or,           op ^, xor,
  dup imm? not if cx swap mov, cl then | execute ;
op <<, shl,        op >>, shr,

: [+n], ( n halop -- ) halop>dstsrc nip swap i) add, ;
: [+n], ( n halop -- )
  halop>dstsrc nip swap case ( op )
    1 of = inc, endof
    -1 of = dec, endof
    r@ i) add, endcase ;
: _ ( halop -- dst src )
  dup 16b? >r dup 8b? >r 32b)
  halop>dstsrc bx swap mov, ( dst )

M fs/xcomp/i386/kernel.fs => fs/xcomp/i386/kernel.fs +9 -3
@@ 205,10 205,14 @@ xcode LIT>W, ( n -- ) \ ax XX i) mov,
xcode LIT>A, ( n -- ) \ di XX i) mov,
  $bf i) cwrite, L1 absjmp,

xcode W+n, ( n -- ) \ ax XX i) add,
xcode W+n, ( n -- ) \ ax XX i) add, OR ax inc,/dec,
  ax 1 i) cmp, forward8 jnz, $40 i) cwrite, xdrop, ret, forward!
  ax -1 i) cmp, forward8 jnz, $48 i) cwrite, xdrop, ret, forward!
  $05 i) cwrite, L1 absjmp,

xcode A+n, ( n -- ) \ di XX i) add,
xcode A+n, ( n -- ) \ di XX i) add, OR di inc,/dec,
  ax 1 i) cmp, forward8 jnz, $47 i) cwrite, xdrop, ret, forward!
  ax -1 i) cmp, forward8 jnz, $4f i) cwrite, xdrop, ret, forward!
  $c781 i) wwrite, L1 absjmp,

xcode W>A, ( n -- ) \ di ax mov,


@@ 271,7 275,9 @@ xcode [!], ( operand -- )
  al $03 i) mov, \ keep size, but modrm is for bx 0 d) ax mov,
  L1 absjmp,

xcode [+n], ( n operand -- ) \ operand n i) add,
xcode [+n], ( n operand -- ) \ operand n i) add, OR operand inc,/dec,
  si 0 d) 1 i) cmp, forward8 jnz, xnip, ax $fe00 i) or, L1 absjmp, forward!
  si 0 d) -1 i) cmp, forward8 jnz, xnip, ax $fe08 i) or, L1 absjmp, forward!
  ax $8000 i) or, L1 abscall, ( n -- )
  ax dwrite, xdrop, ret,