(sw hex-menemo optimized opcodes, 16bit immediates, generally RV32EM asm-src compatible, but different encoding)
and I have tested on MANY compilers, 32/16/8 bit including cc65 this engine, as it has tests battery included. Everywhere is anything related to code below without modification okay, but for BOTH compilers from z88dk for z80/cpm/zxs I experienced issue with simple "unsigned >" comparison of dereferenced pointers - as I debugged test fail, I found that "unsigned >" doest work well here below, so I reversed the operation to use "<" operator
( REGU_TYPE is finally uint32_t and types or _rs1_ _rs2_ are int32_t* )
BLTU - branch less than unsigned - okay
BGTU - branch greater than unsigned (z88dk code FAILs in case natural ">" is used)
Code: Select all
case OPSBA_BLTU:
if ((REGU_TYPE) *_rs1_ < (REGU_TYPE) *_rs2_) { core.pc += imm << LSHIFT; }
break;
case OPSBB_BLEU: //pseudo
if ((REGU_TYPE) *_rs1_ <= (REGU_TYPE) *_rs2_) { core.pc += imm << LSHIFT; }
break;
case OPSBC_BGEU:
if ((REGU_TYPE) *_rs1_ >= (REGU_TYPE) *_rs2_) { core.pc += imm << LSHIFT; }
break;
case OPSBD_BGTU: //pseudo
//HACK for Z88DK Z80 compiler - "unsigned >" FAILS !!!
//HACK - we use reversed registers and "<" here !!!
if ((REGU_TYPE) *_rs2_ < (REGU_TYPE) *_rs1_) { core.pc += imm << LSHIFT; }
break;
Petr