Cmpsubx
ericball
Posts: 774
I've been working on a divide routine (to calculate FRQA) and I noticed that CMPSUBX would give a better result than CMPSUB for the following routine:
:shmax··SHL·ofrac, #1·wc·' maximize the two values
··RCL·ofreq, #1
··SHL·ifrac, #1·wc
··RCL·ifreq, #1·wc
·IF_NC·JMP·#:shmax
··RCR·ifreq, #1··' undo overshoot
:div··CMPSUBX·ofreq, ifreq·wc·' do division
··RCL·pfreq, #1
··SHR·ifreq, #1·wz,wc
·IF_NZ·JMP·#:div
Unfortunately, CMPSUBX doesn't seem to exist, nor does it appear that it could exist as an undocumented opcode based on SUB/CMP vs SUBX/CMPX.· Or might it?
·
:shmax··SHL·ofrac, #1·wc·' maximize the two values
··RCL·ofreq, #1
··SHL·ifrac, #1·wc
··RCL·ifreq, #1·wc
·IF_NC·JMP·#:shmax
··RCR·ifreq, #1··' undo overshoot
:div··CMPSUBX·ofreq, ifreq·wc·' do division
··RCL·pfreq, #1
··SHR·ifreq, #1·wz,wc
·IF_NZ·JMP·#:div
Unfortunately, CMPSUBX doesn't seem to exist, nor does it appear that it could exist as an undocumented opcode based on SUB/CMP vs SUBX/CMPX.· Or might it?
·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Hmm... your code is interesting since it uses the same register for both the divisor and the quotient/remainder. Ahh... I see it now. Since the divisor is shifted to y[noparse][[/noparse]30..15] the remainer isn't impacted by the CMPSUB.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.