I posted it in the channel already, trimmed to essentials:
sec
lda _dtop+1
sbc _scratch+1
bvc less_y1
eor #$80
less_y1:
bmi less_true
bvc less_y2
eor #$80
less_y2:
bne less_false
lda _dtop
sbc _scratch
bcc less_true
less_false:
less_true:
This code is intended to do signed compare of _dtop against _scratch. It mostly works, except it will jump to true if one of the operands in -32768. As I said, it is practically identical to Example 6.3 from http://www.6502.org/tutorials/compare_beyond.html. To be honest, I do not completely understand how this is supposed to work in all cases either.
I posted it in the channel already, trimmed to essentials: