Commit Graph

120 Commits

Author SHA1 Message Date
054d40aa95 emu: comment remaining opcodes as todo/unimplemented 2021-04-27 02:51:48 -07:00
27aa49e249 emu: CBW/CWD sign extension operations 2021-04-27 02:29:16 -07:00
d42603501f emu: formatting 2021-04-27 01:16:01 -07:00
bd00e9ca5f emu: ADD/ADC/SUB/SBB operations 2021-04-27 01:15:30 -07:00
940f2d1d1e emu: don't branch from each modrm calculation
modrm calculation still done inline on each opcode, but later op
directives don't branch from each modrm outcome anymore. Speeds
compilation by about 30%, and decreases release binary size by about
300K currently (and presumably more when the rest of the opcodes are done)
2021-04-24 00:52:35 -07:00
19d686e7ad emu: make $name optional in step!-internal calls
Gearing up to change modrm code to no longer push its directives onto
the main processing stack. This also necessitates making the
function's $form/width/tyargs-thingy a child of $name.

It might be nice to revisit this at some point if we want to merge all
the different form=word[0,1,2,3] arities together. I had hoped that
FarPtr could become parameterized on its pointee width (u8 or u16) and
that would obviate the need for turbofishing the op function
directly. Unfortunately, the string operations need disambiguation
regardless as they construct their pointers internally. But perhaps
that could've been solved with some PhantomData. Regardless, this kind
of approach becomes more difficult after this commit as the width is
now tied to the function name.
2021-04-18 00:26:50 -07:00
c66feda360 emu: RegHalf dispatcher to re-merge @r8 op directive
Keeps the macro recursion from branching. In effect this just moves a
conditional from @r8's output to the RegHalf wrapper, so this is
usually a wash except with less code generated.
2021-04-17 23:29:34 -07:00
7b00a8e708 emu: don't macro recur on every @r8/r16 value
Avoids O(M*N) codegen blowup when paired with a modrm arg.
Probably want to do the same thing to the modrm op directives but
those cases are little more tricky and this alone gets rid of much of
the pain.
2021-04-13 14:39:10 -07:00
663fa40137 emu: AND/OR/XOR/TEST ops 2021-04-09 00:38:21 -07:00
eca60fbe45 emu: LOOP/LOOPZ/LOOPNZ ops 2021-04-08 01:18:47 -07:00
96c869f711 emu: NOT/NEG ops 2021-04-08 00:52:12 -07:00
7c2ca230ff emu: XCHG op 2021-04-07 02:06:03 -07:00
49e0132b2e emu: PUSHF/POPF ops 2021-04-07 00:38:10 -07:00
4833b44074 emu: RCL/RCR ops.
I even did some testing this time...
2021-04-06 00:53:58 -07:00
647841469d emu: CMC/CLC/STC/CLD/STC instructions. POPF flags differ from Eager 2021-04-04 00:53:05 -07:00
67b5b7a615 emu: modrm8 r8 decode had HI/LO registers backwards 2021-04-03 01:14:51 -07:00
e1c7370aa2 emu: MOV r/m, imm. Mark MOVs with [addr] as defaulting to data seg 2021-04-03 01:03:06 -07:00
a4e5d03e22 emu: use mask, not mod for ROL/ROR CF calc. No flags when SHL/SHR=0 2021-03-31 01:39:14 -07:00
a789b7e87d emu: flags: make CF & OF always lazy. Remove Flags::update_of()
Rotate ops now backup flags manually into their enum data instead of
converting everything to eager mode
2021-03-30 01:58:08 -07:00
984ff891c0 emu: Make FlagOp enum algebraic to carry op-specific data
Avoids writing operand data for lazy flags that won't be read
2021-03-30 01:35:35 -07:00
d8600151d6 emu: ROL/ROR operations 2021-03-30 01:35:29 -07:00
f5ab9cfad2 emu: terser names for form= directives 2021-03-29 00:33:53 -07:00
40fed58ecf emu: remove unsafe from {push,pop}_modrm operations 2021-03-29 00:22:56 -07:00
7c7f74a65b emu: make string ops generic over operand size
After many attempts, it turns out this is as easy as remembering that
where clauses can bound non-parameter types
2021-03-28 14:46:35 -07:00
a183a5ad38 emu: SHL/SHR/SAR opcodes (BARELY TESTED!), const Op Directive
Carry Flag as yet untested and likely to contain bugs
2021-03-28 02:08:23 -07:00
874fc6adbc emu: Make flags lazy, implement parity flag & JPE/JPO ops 2021-03-27 01:00:29 -07:00
e15fb6ae27 Squelch warning about intersperse() entering stdlib.
Presumably we'll want to switch to it when it standardizes, so we want
the build to break when it's time to move over.
2021-03-27 00:59:04 -07:00
4b5d85352a emu: move cpu Flags into own module 2021-03-27 00:58:51 -07:00
5d2fbcd01d emu: Remove LValue implementation for u16
I think this was from when registers were passed by mut ref and this
could update them in place. Now they are wrapped and those wrappers
are LValues instead.
2021-03-24 20:37:55 -07:00
8c359d2c70 emu: Use type arguments instead of PhantomData to disambiguate
Allows elision of op directive when operands are of unambiguous width
2021-03-24 20:34:08 -07:00
88166c5a85 emu: remove duplicate @rep arg decoder rule 2021-03-24 01:38:11 -07:00
017eaf2955 emu: Hack in push/pop support for ModR/M. UNSAFE, and maybe UNSOUND. 2021-03-24 01:12:32 -07:00
cf9d2dd15d emu: Pass [LR]Values by value instead of by &mut
I think this made sense originally because registers were being passed
as borrows directly out of the cpu struct. Now they have wrappers
around Cell refs, and those wrappers can be passed directly.
2021-03-22 22:21:03 -07:00
9b0b4efc40 emu: update si in cmps[bw] string loop [bugfix] 2021-03-22 22:19:48 -07:00
ff7e8a7fb9 emu: INC/DEC opcodes. width={byte,word} argtypes for disambig
Also made all LValues also RValues for brevity (so INC/DEC don't have
to bound their destination arguments by both, but this is not required
if it causes problems for some reason down the road).
2021-03-19 00:07:49 -07:00
c8d6a3312a emu: near/short JUMP instructions. Use u16+wrapping_add for all rels 2021-03-18 02:16:15 -07:00
d6e645cae7 emu: use wrapping_add in displacement address as operand can be neg 2021-03-18 01:43:22 -07:00
73c537183e emu: Rename "Addr" to "FarPtr"
It was a little confusing with the "Address" trait. And FarPtr carries
with it a segment.
2021-03-18 00:38:06 -07:00
3b746b75ec emu: PUSH/POP opcodes, reimpl RET as just "POP IP"
This also promotes CALL/RET to actually using the bus for
addressing (because it goes through the generic PUSH/POP code), which
is probably more correct anyway.
2021-03-18 00:32:08 -07:00
dcf96ec5b3 emu: Operand trait over u8/u16, d8_as_d16 argtype 2021-03-17 21:50:02 -07:00
ae1f3da4b2 emu: UNTESTED string ops, CMP instruction
Likely to be a bugfest.
There's a flags macro for now but unclear how useful it will turn out
to be in practice. Flags in particular need testing.

Also disappointing that I couldn't make instructions generic across
u8/u16, especially for ordinary, non-string CMP. Need to look into
this more to see if it can be done with num-traits or some other
trickery.
2021-03-17 21:37:03 -07:00
04348a816e emu: Fake opcode ASSERT for testing 2021-03-12 22:19:45 -08:00
0c55ff9b36 emu: modrm displacement, LEA instruction 2021-03-12 08:01:28 -08:00
adb7e672d9 emu: accept cycle cost for modrm spec (and ignore for now) 2021-03-12 04:10:15 -08:00
c372a96b7c emu: all MOV opcodes (no modrm base/index/displacement modes yet) 2021-03-12 04:02:27 -08:00
0a4b240974 emu: fix copypasta where write_lo actually did write_hi 2021-03-12 02:54:44 -08:00
ac7b3b16a1 emu: factor out utils into own module 2021-03-12 02:27:00 -08:00
27bc36f9d2 emu: factor out operations and operands into own module 2021-03-11 22:55:51 -08:00
b950a56d26 emu: segment prefix, addr Arg decoder, Addr arg trait, NOP opcode 2021-03-11 05:55:07 -08:00
71bcec1574 emu: wrap cpu regs in Cell. r16 addr mode.
r16 + modrm16 allowed cpu regs to alias. Wrap them in Cell to allow
this. We also create a Reg wrapper when passing regs so that we can
pass as &mut while simultaneously having other references to the same
reg.
2021-03-10 07:16:08 -08:00