- lbl = newiTempLabel (NULL);
- emitcode ("xch", "a,%s", aopGet (AOP (left), 0, FALSE, FALSE));
- emitcode ("cjne", "a,#0x80,%05d$", (lbl->key + 100));
- emitcode ("", "%05d$:", (lbl->key + 100));
- emitcode ("xch", "a,%s", aopGet (AOP (left), 0, FALSE, FALSE));
- lbl = newiTempLabel (NULL);
- emitcode ("jc", "%05d$", (lbl->key + 100));
- emitcode ("subb", "a,%s", aopGet (AOP (right), 0, FALSE, FALSE));
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitcode ("", "%05d$:", lbl->key+100);
+
+ /* if literal */
+ if (AOP_TYPE(right)==AOP_LIT) {
+ signed char val=floatFromVal (AOP (right)->aopu.aop_lit);
+ /* AND literal negative */
+ if (val < 0) {
+ emitcode ("cpl", "F0"); // complement sign flag
+ emitcode ("mov", "b,#0x%02x", -val);
+ } else {
+ emitcode ("mov", "b,#0x%02x", val);
+ }
+ } else {
+ lbl=newiTempLabel(NULL);
+ emitcode ("mov", "b,a");
+ emitcode ("mov", "a,%s", aopGet (AOP (right), 0, FALSE, FALSE));
+ emitcode ("jnb", "acc.7,%05d$", lbl->key+100);
+ // right side is negative, 8-bit two's complement
+ emitcode ("cpl", "F0"); // complement sign flag
+ emitcode ("cpl", "a");
+ emitcode ("inc", "a");
+ emitcode ("", "%05d$:", lbl->key+100);
+ }
+ emitcode ("mul", "ab");
+
+ lbl=newiTempLabel(NULL);
+ emitcode ("jnb", "F0,%05d$", lbl->key+100);
+ // only ONE op was negative, we have to do a 8/16-bit two's complement
+ emitcode ("cpl", "a"); // lsb
+ if (size==1) {
+ emitcode ("inc", "a");
+ } else {
+ emitcode ("add", "a,#1");
+ emitcode ("xch", "a,b");
+ emitcode ("cpl", "a"); // msb
+ emitcode ("addc", "a,#0");
+ emitcode ("xch", "a,b");
+ }