SDCC is a good help for me. Time to time I check the code generated by the SDCC. I didn't think before, that the bit transfer between to file registers is requires so many steps. I counted it and the number is 23 steps. I am sure, that I don't use the ideal code for it, but my soultion is using less steps. SDCC is using a template register betwen reading the bit from input, and writing it to the output. I would like to ask for changing it. Not using a general template register.
To avoid a lot of BANKSEL macro, I propose to use STATUS register bits during the transfer if it is possible.
For example moving Porta.0 bits into a flag.0 bits in 11 steps:
2 BANKSEL _PORTA_bits
3 BCF STATUS,0
4 BTFSC _PORTA_bits,0
5 BSF STATUS,0
7 BANKSEL _flags
8 BTFSS STATUS,0 ; This line needs for not doing more then 1 change on the output
9 BCF _flags,0
10 BTFSC STATUS,0
11 BSF _flags,0
Additionally this solution doesn't use GOTO.
Log in to post a comment.