Re: 8051 Speed Optimization
alexmchale@xxxxxxxxx wrote:
I'm working on optimizing code for a C8051F120 that needs to run at an
extremely fast clip. The following few lines are repeated over, as
fast as possible. The looping is a straightforward djnz. The bulk of
the cpu time is spent on the following lines. This is repeated (cut
and paste, but with the binary value changed) 8 times per loop.
; for reference
rLEVEL equ R0
mDATAOUT DATA 64
; the code
row0:
movx A, @DPTR
inc DPTR
subb A, rLEVEL
jc row1
orl mDATAOUT, #00000001b
row1:
how about having mDATAOUT in bit addressable area
and then doing:
subb A,rLEVEL
mov C,mDATAOUT.0
row1:
Note, the subb you are using depends on the state of Carry,
so your present code has some LSB strangeness:^)
(you eventually could use an add instruction and
then complement mDATAOUT after you processed all 8 bits)
Greetings,
Frieder
.