Because that would generate more than double ASM instructions. Lets compare ASM for your code and mine.
Here is your code
compiled:Code:LATB = LATB & $0F 'strip upper 4 bits LATB = LATB | Control << 4 'add new control bits
If you look close there is RCALL SHIFTL.Code:Line Address Opcode Label DisAssy 468 03A6 0E0F Z00039 MOVLW 0xF 469 03A8 168A ANDWF LATB, F, ACCESS 470 03AA C03D Z0003A MOVFF Control, R0 471 03AC F013 NOP 472 03AE 6A14 CLRF 0x14, ACCESS 473 03B0 6A15 CLRF 0x15, ACCESS 474 03B2 6A16 CLRF 0x16, ACCESS 475 03B4 0E04 MOVLW 0x4 476 03B6 DEAE RCALL SHIFTL 477 03B8 6E23 MOVWF 0x23, ACCESS 478 03BA C014 MOVFF 0x14, 0x24 479 03BC F024 NOP 480 03BE C015 MOVFF 0x15, 0x25 481 03C0 F025 NOP 482 03C2 C016 MOVFF 0x16, 0x26 483 03C4 F026 NOP 484 03C6 5023 MOVF 0x23, W, ACCESS 485 03C8 128A IORWF LATB, F, ACCESS
Code for that:
Then there is GOTO 0x31CCode:Line Address Opcode Label DisAssy 139 0114 0FFF SHIFTL ADDLW 0xFF 140 0116 E2F9 BC shiftlloop 141 0118 5013 MOVF R0, W, ACCESS 142 011A EF8E GOTO 0x31C 143 011C F001 NOP
Code for that:
Then there is also BC shiftlloopCode:Line Address Opcode Label DisAssy 399 031C 0100 DUNN MOVLB 0x0 400 031E 0000 DUNN5 NOP 401 0320 0012 RETURN 0
My code:Code:Line Address Opcode Label DisAssy 134 010A 90D8 shiftlloop BCF STATUS, 0, ACCESS 135 010C 3613 RLCF R0, F, ACCESS 136 010E 3614 RLCF 0x14, F, ACCESS 137 0110 3615 RLCF 0x15, F, ACCESS 138 0112 3616 RLCF 0x16, F, ACCESS 139 0114 0FFF SHIFTL ADDLW 0xFF 140 0116 E2F9 BC shiftlloop 141 0118 5013 MOVF R0, W, ACCESS 142 011A EF8E GOTO 0x31C 143 011C F001 NOP
Compiled:Code:LATB.4=Control.0 LATB.5=Control.1 LATB.6=Control.2 LATB.7=Control.3
in my code there is only 16 instruction. In worst case 12 is executed, in best case 8.Code:Line Address Opcode Label DisAssy 458 0392 B035 Z00039 BTFSC Control, 0, ACCESS 459 0394 888A BSF LATB, 4, ACCESS 460 0396 A035 BTFSS Control, 0, ACCESS 461 0398 988A BCF LATB, 4, ACCESS 462 039A B235 Z0003A BTFSC Control, 1, ACCESS 463 039C 8A8A BSF LATB, 5, ACCESS 464 039E A235 BTFSS Control, 1, ACCESS 465 03A0 9A8A BCF LATB, 5, ACCESS 466 03A2 B435 Z0003B BTFSC Control, 2, ACCESS 467 03A4 8C8A BSF LATB, 6, ACCESS 468 03A6 A435 BTFSS Control, 2, ACCESS 469 03A8 9C8A BCF LATB, 6, ACCESS 470 03AA B635 Z0003C BTFSC Control, 3, ACCESS 471 03AC 8E8A BSF LATB, 7, ACCESS 472 03AE A635 BTFSS Control, 3, ACCESS 473 03B0 9E8A BCF LATB, 7, ACCESS
Can you calculate best and worse case for your code? Then compare it
This is depends lot of internal PBP optimization, and lib structure.
Another example is to use nested IFs instead of AND. Also I found way to use some temporally variable and single condition IF, and to get complex IFs that are fraction of size PBP's single line IF with multiple condition.
There is somewhere example on forum.
Same apply to math formula, tend to use single operation per line, and multiple lines...
Then compiler doesn't have to store bunch or intermediate results.
Sometimes less is more, and more is less.
If you write more lines of simple code then compiler have less to do. And tend to get better result(smaller code, less ram for lib's, faster execution times)
EDIT:
I'm using long, so there is little overhead like this
472 03AE 6A14 CLRF 0x14, ACCESS
473 03B0 6A15 CLRF 0x15, ACCESS
474 03B2 6A16 CLRF 0x16, ACCESS
to clear rest of R0 internal register.





Bookmarks