mfld-fr / emu86

Intel IA16 emulator for embedded development
36 stars 6 forks source link

Add IMUL 0x69 and 0x6B op-codes #81

Closed ftapajos closed 2 years ago

ftapajos commented 2 years ago

I need to emulate a 80C188EB for a legacy code which uses the 0x6B instruction inside a microcontroller. I have never done anything like, so I have no idea if this is the proper approach. I am more interested in comments about the implementation than the pull of this request

mfld-fr commented 2 years ago

Hello @ftapajos !

Looks like quite correct at a first glance (edit : NOT correct, see below). Let me test your changes on my side (planned for a next weekend)...

mfld-fr commented 2 years ago

Reference: https://www.felixcloutier.com/x86/imul

mfld-fr commented 2 years ago

@ftapajos : Sorry, but after spending more time on your PR, I am now realizing that there is a misunderstanding of the special IMUL operation as implemented in the 80186.

The encoding of that operation is : 011010s1 | mod reg r/m | data | data if s=0. Destination is the reg word register, and sources are mod r/m (that could be memory) and data (imm16 or imm8 extended to imm16 depending on the s flag).

Implementing that special IMUL with 3 operands requires at least to add a third variable to the op_desc structure, a specific decoding class, and a kind of calc_3 routine in op-exec to handle these 3 operands.

mfld-fr commented 2 years ago

@ftapajos : please tell me if you intend to continue the implementation after I pushed the decoding part. If yes, I would keep this PR opened. Otherwise, no problem, I would merge this PR to keep that decoding for a later implementation.