+ /* save the signs of the operands */
+ if (AOP_TYPE(right) == AOP_LIT)
+ {
+ signed char val = (char) floatFromVal (AOP (right)->aopu.aop_lit);
+
+ if (!rUnsigned && val < 0)
+ emitcode ("ldx", "#0x%02x", -val);
+ else
+ emitcode ("ldx", "#0x%02x", (unsigned char) val);
+ }
+ else /* ! literal */
+ {
+ loadRegFromAop (hc08_reg_x, AOP (right), 0);
+ if (!rUnsigned)
+ {
+ tlbl1 = newiTempLabel (NULL);
+ emitcode ("tstx", "");
+ emitBranch ("bpl", tlbl1);
+ emitcode ("inc", "1,s");
+ rmwWithReg ("neg", hc08_reg_x);
+ emitLabel (tlbl1);
+ }
+ }
+
+ if (AOP_TYPE(left) == AOP_LIT)
+ {
+ signed char val = (char) floatFromVal (AOP (left)->aopu.aop_lit);
+
+ if (!lUnsigned && val < 0)
+ emitcode ("lda", "#0x%02x", -val);
+ else
+ emitcode ("lda", "#0x%02x", (unsigned char) val);
+ }
+ else /* ! literal */
+ {
+ loadRegFromAop (hc08_reg_a, AOP (left), 0);
+ if (!lUnsigned)
+ {
+ tlbl2 = newiTempLabel (NULL);
+ emitcode ("tsta", "");
+ emitBranch ("bpl", tlbl2);
+ emitcode ("inc", "1,s");
+ rmwWithReg ("neg", hc08_reg_a);
+ emitLabel (tlbl2);
+ }
+ }
+
+ loadRegFromConst (hc08_reg_h, zero);
+ emitcode ("div", "");
+ hc08_dirtyReg (hc08_reg_x, FALSE);
+ hc08_dirtyReg (hc08_reg_a, FALSE);
+ hc08_dirtyReg (hc08_reg_h, FALSE);
+
+ if (runtimeSign || compiletimeSign)
+ {
+ tlbl3 = newiTempLabel (NULL);
+ if (runtimeSign)
+ {
+ pullReg (hc08_reg_x);
+ rmwWithReg ("lsr", hc08_reg_x);
+ rmwWithReg ("ror", hc08_reg_x);
+ emitBranch ("bpl", tlbl3);
+ }
+
+ rmwWithReg ("neg", hc08_reg_a);
+ if (runtimeSign)
+ emitLabel (tlbl3);
+
+ storeRegToAop (hc08_reg_a, AOP (result), 0);
+
+ if (size > 1)
+ {
+ /* msb is 0x00 or 0xff depending on the sign */
+ if (runtimeSign)
+ {
+ rmwWithReg ("lsl", hc08_reg_x);
+ emitcode ("clra", "");
+ emitcode ("sbc", "#0");
+ while (--size)
+ storeRegToAop (hc08_reg_a, AOP (result), ++offset);
+ }
+ else /* compiletimeSign */
+ while (--size)
+ storeConstToAop ("#0xff", AOP (result), ++offset);
+ }
+ }
+ else
+ {
+ storeRegToFullAop (hc08_reg_a, AOP (result), FALSE);
+ }