nukeykt / Nuked-SC55

Roland SC-55 series emulation
Other
285 stars 33 forks source link

Add sign extension to H8/500 CMP:G.W #imm8,<EAd> instruction #43

Closed myon98 closed 2 months ago

myon98 commented 2 months ago

I wasn't able to find documentation on what happenes when the operand size and immediate size of CMP:G.W mismatches. (The disassembler DASMH85 that I was using also choked on such opcode.)

However in the ROM code handling DRUM SysEx parameters, there was an instruction that was comparing a word sized memory containing 0xFFFF with a byte sized immediate 0xFF. When I changed the H8/500 emulation to sign extend the immediate byte in such cases, the "DT1 Data Error" (#20, #21) disappeared.

myon98 commented 2 months ago

https://evoecu.logic.net/mirror/cpudocs/h8539f/H8%205XX%20Programming.pdf#page=83

MOV:G.W #imm, <EAd> seems to share the same structure of EA and opcode being able to specify operand width independently. And in the case of MOV the manual explicitly says that the 8-bit immediate gets sign extended in case the target is a word.

Also I found out that binutils up to 2.30 also supports H8/500 that results in a working h8500-coff-objdump, but fails to decode CMP:G.W #imm8, <EAd> as well.

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=opcodes/h8500-opc.h;h=347e36f60bf74d4874455d7db332e3c63c5779b7;hb=fe0bf0fd57ea3ef8458d2e8661b428110fc026e2