+ if (AOP_TYPE (right) == AOP_LIT)
+ {
+ litval = (int) floatFromVal (AOP (right)->aopu.aop_lit);
+
+ emitcode ((litval & 1) ? "bset" : "bclr",
+ "#%d,%s", bstr, aopAdrStr (derefaop, 0, FALSE));
+ }
+ else
+ {
+ symbol *tlbl1 = newiTempLabel (NULL);
+ symbol *tlbl2 = newiTempLabel (NULL);
+
+ loadRegFromAop (hc08_reg_a, AOP (right), 0);
+ emitcode ("bit", "#1");
+ emitBranch ("bne", tlbl1);
+ emitcode ("bclr", "#%d,%s", bstr, aopAdrStr (derefaop, 0, FALSE));
+ emitBranch ("bra", tlbl2);
+ emitLabel (tlbl1);
+ emitcode ("bset", "#%d,%s", bstr, aopAdrStr (derefaop, 0, FALSE));
+ emitLabel (tlbl2);
+ hc08_freeReg (hc08_reg_a);
+ }
+ goto release;
+ }
+
+ /* If the bitfield length is less than a byte */
+ if (blen < 8)
+ {
+ mask = ((unsigned char) (0xFF << (blen + bstr)) |
+ (unsigned char) (0xFF >> (8 - bstr)));
+
+ if (AOP_TYPE (right) == AOP_LIT)
+ {
+ /* Case with a bitfield length <8 and literal source
+ */
+ litval = (int) floatFromVal (AOP (right)->aopu.aop_lit);
+ litval <<= bstr;
+ litval &= (~mask) & 0xff;
+
+ loadRegFromAop (hc08_reg_a, derefaop, 0);
+ if ((mask|litval)!=0xff)
+ emitcode ("and","#0x%02x", mask);
+ if (litval)
+ emitcode ("ora","#0x%02x", litval);
+ hc08_dirtyReg (hc08_reg_a, FALSE);
+ storeRegToAop (hc08_reg_a, derefaop, 0);
+
+ hc08_freeReg (hc08_reg_a);
+ goto release;
+ }
+
+ /* Case with a bitfield length < 8 and arbitrary source
+ */
+ loadRegFromAop (hc08_reg_a, AOP (right), 0);
+ /* shift and mask source value */
+ AccLsh (bstr);
+ emitcode ("and", "#0x%02x", (~mask) & 0xff);
+ hc08_dirtyReg (hc08_reg_a, FALSE);
+ pushReg (hc08_reg_a, TRUE);
+
+ loadRegFromAop (hc08_reg_a, derefaop, 0);
+ emitcode ("and", "#0x%02x", mask);
+ emitcode ("ora", "1,s");
+ storeRegToAop (hc08_reg_a, derefaop, 0);
+ pullReg (hc08_reg_a);
+
+ hc08_freeReg (hc08_reg_a);
+ goto release;
+ }
+
+ /* Bit length is greater than 7 bits. In this case, copy */
+ /* all except the partial byte at the end */
+ for (rlen=blen;rlen>=8;rlen-=8)
+ {
+ transferAopAop (AOP (right), offset, derefaop, size-offset);