nocrew / ostis

Atari ST Emulator
GNU Lesser General Public License v2.1
20 stars 4 forks source link

Clocked instructions: CMP, NOT, NEG, NEGX, LEA #136

Closed larsbrinkhoff closed 8 years ago

larsbrinkhoff commented 8 years ago

Make the existing CMP use the EA state machine.

Add state machines for NEG, NEG, and NEGX.

Tested with Desktop, Phalanx Demo, BIG Demo.

stefanberndtsson commented 8 years ago

Possibly something for this PR, or maybe a separate one, but it would be helpful when reading and understanding the code if the yacht-block for each instruction is put in the code as a comment.

larsbrinkhoff commented 8 years ago

Here's another one: LEA.

larsbrinkhoff commented 8 years ago

Maybe I should explain the many Fall through comments.

The instruction state machines begin with calling ea_begin_read. Then it goes directly into the next state, which waits for the EA calculation to finish. But this state may exit immediately, because the register addressing modes do not add any cycles to the instruction time.

stefanberndtsson commented 8 years ago

Yes, I was thinking maybe the case sections should be reordered, so that the actual fall-through occurs at the end of the case, and the path that breaks is above.

Also, I think I'd rather see {} around single line statements in if/else's too. They make things a bit more consistent, and they also make it easier when inserting the generic debug code.

larsbrinkhoff commented 8 years ago

Like that?

stefanberndtsson commented 8 years ago

Yes, like that.

larsbrinkhoff commented 8 years ago

I added a cpu_prefetch to the last instruction, LEA. Seemlingly without any ill effects.

stefanberndtsson commented 8 years ago

cpu_prefetch should be fine as long as it's only called once during the instruction execution. fetch_instr will check the prefetch value and not do a new fetch. If cpu_prefetch is called multiple times, the previous value will be lost. In reality it should propagate down through IRC/IR/IRD as you know.

larsbrinkhoff commented 8 years ago

Right. I was planning to some prefetch work in another branch, so I wasn't too careful with that here.