-static void genMultTwoByte (operand *left, operand *right,
- operand *result, iCode *ic)
-{
- sym_link *retype = getSpec(operandType(right));
- sym_link *letype = getSpec(operandType(left));
- int umult = SPEC_USIGN(retype) | SPEC_USIGN(letype);
- symbol *lbl;
-
- if (AOP_TYPE (left) == AOP_LIT) {
- operand *t = right;
- right = left;
- left = t;
- }
- /* save EA bit in F1 */
- lbl = newiTempLabel(NULL);
- emitcode ("setb","F1");
- emitcode ("jbc","EA,!tlabel",lbl->key+100);
- emitcode ("clr","F1");
- emitcode("","!tlabeldef",lbl->key+100);
-
- /* load up MB with right */
- if (!umult) {
- emitcode("clr","F0");
- if (AOP_TYPE(right) == AOP_LIT) {
- int val=(int)floatFromVal (AOP (right)->aopu.aop_lit);
- if (val < 0) {
- emitcode("setb","F0");
- val = -val;
- }
- emitcode ("mov","mb,#!constbyte",val & 0xff);
- emitcode ("mov","mb,#!constbyte",(val >> 8) & 0xff);
- } else {
- lbl = newiTempLabel(NULL);
- emitcode ("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE,NULL));
- emitcode ("mov","a,%s",aopGet(AOP(right),1,FALSE,FALSE,NULL));
- emitcode ("jnb","acc.7,!tlabel",lbl->key+100);
- emitcode ("xch", "a,b");
- emitcode ("cpl","a");
- emitcode ("add", "a,#1");
- emitcode ("xch", "a,b");
- emitcode ("cpl", "a"); // msb
- emitcode ("addc", "a,#0");
- emitcode ("setb","F0");
- emitcode ("","!tlabeldef",lbl->key+100);
- emitcode ("mov","mb,b");
- emitcode ("mov","mb,a");
- }
- } else {
- emitcode ("mov","mb,%s",aopGet(AOP(right),0,FALSE,FALSE,NULL));
- emitcode ("mov","mb,%s",aopGet(AOP(right),1,FALSE,FALSE,NULL));
- }
- /* load up MA with left */
- if (!umult) {
- lbl = newiTempLabel(NULL);
- emitcode ("mov","b,%s",aopGet(AOP(left),0,FALSE,FALSE,NULL));
- emitcode ("mov","a,%s",aopGet(AOP(left),1,FALSE,FALSE,NULL));
- emitcode ("jnb","acc.7,!tlabel",lbl->key+100);
- emitcode ("xch", "a,b");
- emitcode ("cpl","a");
- emitcode ("add", "a,#1");
- emitcode ("xch", "a,b");
- emitcode ("cpl", "a"); // msb
- emitcode ("addc","a,#0");
- emitcode ("jbc","F0,!tlabel",lbl->key+100);
- emitcode ("setb","F0");
- emitcode ("","!tlabeldef",lbl->key+100);
- emitcode ("mov","ma,b");
- emitcode ("mov","ma,a");
- } else {
- emitcode ("mov","ma,%s",aopGet(AOP(left),0,FALSE,FALSE,NULL));
- emitcode ("mov","ma,%s",aopGet(AOP(left),1,FALSE,FALSE,NULL));
- }
- /* wait for multiplication to finish */
- lbl = newiTempLabel(NULL);
- emitcode("","!tlabeldef", lbl->key+100);
- emitcode("mov","a,mcnt1");
- emitcode("anl","a,#!constbyte",0x80);
- emitcode("jnz","!tlabel",lbl->key+100);
-
- freeAsmop (left, NULL, ic, TRUE);
- freeAsmop (right, NULL, ic,TRUE);
- aopOp(result, ic, TRUE, FALSE);
-
- /* if unsigned then simple */
- if (umult) {
- emitcode ("mov","a,ma");
- if (AOP_SIZE(result) >= 4) aopPut(AOP(result),"a",3);
- emitcode ("mov","a,ma");
- if (AOP_SIZE(result) >= 3) aopPut(AOP(result),"a",2);
- aopPut(AOP(result),"ma",1);
- aopPut(AOP(result),"ma",0);
- } else {
- emitcode("push","ma");
- emitcode("push","ma");
- emitcode("push","ma");
- MOVA("ma");
- /* negate result if needed */
- lbl = newiTempLabel(NULL);
- emitcode("jnb","F0,!tlabel",lbl->key+100);
- emitcode("cpl","a");
- emitcode("add","a,#1");
- emitcode("","!tlabeldef", lbl->key+100);
- if (AOP_TYPE(result) == AOP_ACC)
- {
- D(emitcode(";", "ACC special case."););
- /* We know result is the only live aop, and
- * it's obviously not a DPTR2, so AP is available.
- */
- emitcode("mov", "%s,acc", DP2_RESULT_REG);
- }
- else
- {
- aopPut(AOP(result),"a",0);
- }
-
- emitcode("pop","acc");
- lbl = newiTempLabel(NULL);
- emitcode("jnb","F0,!tlabel",lbl->key+100);
- emitcode("cpl","a");
- emitcode("addc","a,#0");
- emitcode("","!tlabeldef", lbl->key+100);
- aopPut(AOP(result),"a",1);
- emitcode("pop","acc");
- if (AOP_SIZE(result) >= 3) {
- lbl = newiTempLabel(NULL);
- emitcode("jnb","F0,!tlabel",lbl->key+100);
- emitcode("cpl","a");
- emitcode("addc","a,#0");
- emitcode("","!tlabeldef", lbl->key+100);
- aopPut(AOP(result),"a",2);
- }
- emitcode("pop","acc");
- if (AOP_SIZE(result) >= 4) {
- lbl = newiTempLabel(NULL);
- emitcode("jnb","F0,!tlabel",lbl->key+100);
- emitcode("cpl","a");
- emitcode("addc","a,#0");
- emitcode("","!tlabeldef", lbl->key+100);
- aopPut(AOP(result),"a",3);
- }
- if (AOP_TYPE(result) == AOP_ACC)
- {
- /* We stashed the result away above. */
- emitcode("mov", "acc,%s", DP2_RESULT_REG);
- }
-
- }
- freeAsmop (result, NULL, ic, TRUE);
-
- /* restore EA bit in F1 */
- lbl = newiTempLabel(NULL);
- emitcode ("jnb","F1,!tlabel",lbl->key+100);
- emitcode ("setb","EA");
- emitcode("","!tlabeldef",lbl->key+100);
- return ;
+static void genMultTwoByte (operand *left, operand *right,
+ operand *result, iCode *ic)
+{
+ sym_link *retype = getSpec(operandType(right));
+ sym_link *letype = getSpec(operandType(left));
+ int umult = SPEC_USIGN(retype) | SPEC_USIGN(letype);
+ symbol *lbl;
+
+ if (AOP_TYPE (left) == AOP_LIT) {
+ operand *t = right;
+ right = left;
+ left = t;
+ }
+ /* save EA bit in F1 */
+ lbl = newiTempLabel(NULL);
+ emitcode ("setb","F1");
+ emitcode ("jbc","EA,!tlabel",lbl->key+100);
+ emitcode ("clr","F1");
+ emitLabel (lbl);
+
+ /* load up MB with right */
+ if (!umult) {
+ emitcode("clr","F0");
+ if (AOP_TYPE(right) == AOP_LIT) {
+ int val=(int)floatFromVal (AOP (right)->aopu.aop_lit);
+ if (val < 0) {
+ emitcode("setb","F0");
+ val = -val;
+ }
+ emitcode ("mov","mb,#!constbyte",val & 0xff);
+ emitcode ("mov","mb,#!constbyte",(val >> 8) & 0xff);
+ } else {
+ lbl = newiTempLabel(NULL);
+ emitcode ("mov","b,%s",aopGet(right,0,FALSE,FALSE,NULL));
+ emitcode ("mov","a,%s",aopGet(right,1,FALSE,FALSE,NULL));
+ emitcode ("jnb","acc.7,!tlabel",lbl->key+100);
+ emitcode ("xch", "a,b");
+ emitcode ("cpl","a");
+ emitcode ("add", "a,#1");
+ emitcode ("xch", "a,b");
+ emitcode ("cpl", "a"); // msb
+ emitcode ("addc", "a,#0");
+ emitcode ("setb","F0");
+ emitLabel (lbl);
+ emitcode ("mov","mb,b");
+ emitcode ("mov","mb,a");
+ }
+ } else {
+ emitcode ("mov","mb,%s",aopGet(right,0,FALSE,FALSE,NULL));
+ emitcode ("mov","mb,%s",aopGet(right,1,FALSE,FALSE,NULL));
+ }
+ /* load up MA with left */
+ if (!umult) {
+ lbl = newiTempLabel(NULL);
+ emitcode ("mov","b,%s",aopGet(left,0,FALSE,FALSE,NULL));
+ emitcode ("mov","a,%s",aopGet(left,1,FALSE,FALSE,NULL));
+ emitcode ("jnb","acc.7,!tlabel",lbl->key+100);
+ emitcode ("xch", "a,b");
+ emitcode ("cpl","a");
+ emitcode ("add", "a,#1");
+ emitcode ("xch", "a,b");
+ emitcode ("cpl", "a"); // msb
+ emitcode ("addc","a,#0");
+ emitcode ("jbc","F0,!tlabel",lbl->key+100);
+ emitcode ("setb","F0");
+ emitLabel (lbl);
+ emitcode ("mov","ma,b");
+ emitcode ("mov","ma,a");
+ } else {
+ emitcode ("mov","ma,%s",aopGet(left,0,FALSE,FALSE,NULL));
+ emitcode ("mov","ma,%s",aopGet(left,1,FALSE,FALSE,NULL));
+ }
+ /* wait for multiplication to finish */
+ lbl = newiTempLabel(NULL);
+ emitLabel (lbl);
+ emitcode("mov","a,mcnt1");
+ emitcode("anl","a,#!constbyte",0x80);
+ emitcode("jnz","!tlabel",lbl->key+100);
+
+ freeAsmop (left, NULL, ic, TRUE);
+ freeAsmop (right, NULL, ic,TRUE);
+ aopOp(result, ic, TRUE, FALSE);
+
+ /* if unsigned then simple */
+ if (umult) {
+ emitcode ("mov","a,ma");
+ if (AOP_SIZE(result) >= 4) aopPut(result,"a",3);
+ emitcode ("mov","a,ma");
+ if (AOP_SIZE(result) >= 3) aopPut(result,"a",2);
+ aopPut(result,"ma",1);
+ aopPut(result,"ma",0);
+ } else {
+ emitcode("push","ma");
+ emitcode("push","ma");
+ emitcode("push","ma");
+ MOVA("ma");
+ /* negate result if needed */
+ lbl = newiTempLabel(NULL);
+ emitcode("jnb","F0,!tlabel",lbl->key+100);
+ emitcode("cpl","a");
+ emitcode("add","a,#1");
+ emitLabel (lbl);
+ if (AOP_TYPE(result) == AOP_ACC)
+ {
+ D (emitcode(";", "ACC special case."));
+ /* We know result is the only live aop, and
+ * it's obviously not a DPTR2, so AP is available.
+ */
+ emitcode("mov", "%s,acc", DP2_RESULT_REG);
+ }
+ else
+ {
+ aopPut(result,"a",0);
+ }
+
+ emitcode("pop","acc");
+ lbl = newiTempLabel(NULL);
+ emitcode("jnb","F0,!tlabel",lbl->key+100);
+ emitcode("cpl","a");
+ emitcode("addc","a,#0");
+ emitLabel (lbl);
+ aopPut(result,"a",1);
+ emitcode("pop","acc");
+ if (AOP_SIZE(result) >= 3) {
+ lbl = newiTempLabel(NULL);
+ emitcode("jnb","F0,!tlabel",lbl->key+100);
+ emitcode("cpl","a");
+ emitcode("addc","a,#0");
+ emitLabel (lbl);
+ aopPut(result,"a",2);
+ }
+ emitcode("pop","acc");
+ if (AOP_SIZE(result) >= 4) {
+ lbl = newiTempLabel(NULL);
+ emitcode("jnb","F0,!tlabel",lbl->key+100);
+ emitcode("cpl","a");
+ emitcode("addc","a,#0");
+ emitLabel (lbl);
+ aopPut(result,"a",3);
+ }
+ if (AOP_TYPE(result) == AOP_ACC)
+ {
+ /* We stashed the result away above. */
+ emitcode("mov", "acc,%s", DP2_RESULT_REG);
+ }
+
+ }
+ freeAsmop (result, NULL, ic, TRUE);
+
+ /* restore EA bit in F1 */
+ lbl = newiTempLabel(NULL);
+ emitcode ("jnb","F1,!tlabel",lbl->key+100);
+ emitcode ("setb","EA");
+ emitLabel (lbl);
+ return ;