-#ifdef DEBUG_TYPE
- emitcode("","; Type res[%d] = l[%d]&r[%d]",
- AOP_TYPE(result),
- AOP_TYPE(left), AOP_TYPE(right));
- emitcode("","; Size res[%d] = l[%d]&r[%d]",
- AOP_SIZE(result),
- AOP_SIZE(left), AOP_SIZE(right));
-#endif
-
- /* if left is a literal & right is not then exchange them */
- if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) ||
- AOP_NEEDSACC(left)) {
- operand *tmp = right ;
- right = left;
- left = tmp;
- }
-
- /* if result = right then exchange them */
- if(sameRegs(AOP(result),AOP(right))){
- operand *tmp = right ;
- right = left;
- left = tmp;
- }
-
- /* if right is bit then exchange them */
- if (AOP_TYPE(right) == AOP_CRY &&
- AOP_TYPE(left) != AOP_CRY){
- operand *tmp = right ;
- right = left;
- left = tmp;
- }
- if(AOP_TYPE(right) == AOP_LIT)
- lit = (unsigned long)floatFromVal (AOP(right)->aopu.aop_lit);
-
- size = AOP_SIZE(result);
-
- // if(bit | yy)
- // xx = bit | yy;
- if (AOP_TYPE(left) == AOP_CRY){
- if(AOP_TYPE(right) == AOP_LIT){
- // c = bit & literal;
- if(lit){
- // lit != 0 => result = 1
- if(AOP_TYPE(result) == AOP_CRY){
- if(size)
- emitcode("setb","%s",AOP(result)->aopu.aop_dir);
- else if(ifx)
- continueIfTrue(ifx);
- goto release;
- }
- emitcode("setb","c");
- } else {
- // lit == 0 => result = left
- if(size && sameRegs(AOP(result),AOP(left)))
- goto release;
- emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
- }
- } else {
- if (AOP_TYPE(right) == AOP_CRY){
- // c = bit | bit;
- emitcode("mov","c,%s",AOP(right)->aopu.aop_dir);
- emitcode("orl","c,%s",AOP(left)->aopu.aop_dir);
- }
- else{
- // c = bit | val;
- symbol *tlbl = newiTempLabel(NULL);
- if(!((AOP_TYPE(result) == AOP_CRY) && ifx))
- emitcode("setb","c");
- emitcode("jb","%s,%05d$",
- AOP(left)->aopu.aop_dir,tlbl->key+100);
- toBoolean(right);
- emitcode("jnz","%05d$",tlbl->key+100);
- if((AOP_TYPE(result) == AOP_CRY) && ifx){
- jmpTrueOrFalse(ifx, tlbl);
- goto release;
- } else {
- CLRC;
- emitcode("","%05d$:",tlbl->key+100);
- }
- }
- }
- // bit = c
- // val = c
- if(size)
- outBitC(result);
- // if(bit | ...)
- else if((AOP_TYPE(result) == AOP_CRY) && ifx)
- genIfxJump(ifx, "c");
- goto release ;
- }
-
- // if(val | 0xZZ) - size = 0, ifx != FALSE -
- // bit = val | 0xZZ - size = 1, ifx = FALSE -
- if((AOP_TYPE(right) == AOP_LIT) &&
- (AOP_TYPE(result) == AOP_CRY) &&
- (AOP_TYPE(left) != AOP_CRY)){
- if(lit){
- // result = 1
- if(size)
- emitcode("setb","%s",AOP(result)->aopu.aop_dir);
- else
- continueIfTrue(ifx);
- goto release;
- } else {
- // lit = 0, result = boolean(left)
- if(size)
- emitcode("setb","c");
- toBoolean(right);
- if(size){
- symbol *tlbl = newiTempLabel(NULL);
- emitcode("jnz","%05d$",tlbl->key+100);
- CLRC;
- emitcode("","%05d$:",tlbl->key+100);
- } else {
- genIfxJump (ifx,"a");
- goto release;
- }
- }
- outBitC(result);
- goto release ;
- }
-
- /* if left is same as result */
- if(sameRegs(AOP(result),AOP(left))){
- for(;size--; offset++) {
- if(AOP_TYPE(right) == AOP_LIT){
- if(((lit >> (offset*8)) & 0x0FFL) == 0x00L)
- continue;
- else
- if (IS_AOP_PREG(left)) {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("orl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
- aopPut(AOP(result),"a",offset);
- } else
- emitcode("orl","%s,%s",
- aopGet(AOP(left),offset,FALSE,TRUE),
- aopGet(AOP(right),offset,FALSE,FALSE));
- } else {
- if (AOP_TYPE(left) == AOP_ACC)
- emitcode("orl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
- else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- if (IS_AOP_PREG(left)) {
- emitcode("orl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
- aopPut(AOP(result),"a",offset);
- } else
- emitcode("orl","%s,a",
- aopGet(AOP(left),offset,FALSE,TRUE));
- }
- }
- }
- } else {
- // left & result in different registers
- if(AOP_TYPE(result) == AOP_CRY){
- // result = bit
- // if(size), result in bit
- // if(!size && ifx), conditional oper: if(left | right)
- symbol *tlbl = newiTempLabel(NULL);
- int sizer = max(AOP_SIZE(left),AOP_SIZE(right));
- if(size)
- emitcode("setb","c");
- while(sizer--){
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("orl","a,%s",
- aopGet(AOP(left),offset,FALSE,FALSE));
- emitcode("jnz","%05d$",tlbl->key+100);
- offset++;
- }
- if(size){
- CLRC;
- emitcode("","%05d$:",tlbl->key+100);
- outBitC(result);
- } else if(ifx)
- jmpTrueOrFalse(ifx, tlbl);
- } else for(;(size--);offset++){
- // normal case
- // result = left & right
- if(AOP_TYPE(right) == AOP_LIT){
- if(((lit >> (offset*8)) & 0x0FFL) == 0x00L){
- aopPut(AOP(result),
- aopGet(AOP(left),offset,FALSE,FALSE),
- offset);
- continue;
- }
- }
- // faster than result <- left, anl result,right
- // and better if result is SFR
- if (AOP_TYPE(left) == AOP_ACC)
- emitcode("orl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
- else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("orl","a,%s",
- aopGet(AOP(left),offset,FALSE,FALSE));
- }
- aopPut(AOP(result),"a",offset);
- }
- }