SX Microcontroller Math Method

16 bit subtraction with borrow

Translated and optimized for the Scenix SX by Nikolai Golovchenko

From Rudy Wieser

;----------------------------
; 16-bit Subtraction-with-Borrow
;       SourceH:SourceL - Number to be subtracted
;       Carry - NOT( Borrow to be subtracted )
;       DestH:DestL - Number to be subtracted FROM
;Out    DestH:DestL - Result
;       Carry - NOT( Borrow result)

	mov	W, SourceL
	sub	DestL, W
	mov	W, SourceH
	sb	C
	movsz	W, ++SourceH
	sub	DestH, W	;dest = dest - source, WITH VALID CARRY
				;(although the Z flag is not valid).

;----------------------------