<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">;*******************************************************************
;                 Double Precision Addition &amp; Subtraction
;
;*******************************************************************;
;   Addition :  ACCb(16 bits) + ACCa(16 bits) -&gt; ACCb(16 bits)
;      (a) Load the 1st operand in location ACCaLO &amp; ACCaHI ( 16 bits )
;      (b) Load the 2nd operand in location ACCbLO &amp; ACCbHI ( 16 bits )
;      (c) CALL D_add
;      (d) The result is in location ACCbLO &amp; ACCbHI ( 16 bits )
;
;   Performance :
;               Program Memory  :       07
;               Clock Cycles    :       08
;*******************************************************************;
;   Subtraction : ACCb(16 bits) - ACCa(16 bits) -&gt; ACCb(16 bits)
;      (a) Load the 1st operand in location ACCaLO &amp; ACCaHI ( 16 bits )
;      (b) Load the 2nd operand in location ACCbLO &amp; ACCbHI ( 16 bits )
;      (c) CALL D_sub
;      (d) The result is in location ACCbLO &amp; ACCbHI ( 16 bits )
;
;   Performance :
;               Program Memory  :       14
;               Clock Cycles    :       17
;*******************************************************************;
;
ACCaLO  equ     10
ACCaHI  equ     11
ACCbLO  equ     12
ACCbHI  equ     13
;
	include "picreg.h"
	org     0
;*******************************************************************
;         Double Precision Subtraction ( ACCb - ACCa -&gt; ACCb )
;
D_sub   call    neg_A           ; At first negate ACCa; Then add
;
;*******************************************************************
;       Double Precision  Addition ( ACCb + ACCa -&gt; ACCb )
;
D_add   movf    ACCaLO,w
	addwf   ACCbLO          ;add lsb
	btfsc   STATUS,CARRY    ;add in carry
	incf    ACCbHI
	movf    ACCaHI,w
	addwf   ACCbHI            ;add msb
	retlw   0
;
;
neg_A   comf    ACCaLO          ; negate ACCa ( -ACCa -&gt; ACCa )
	incf    ACCaLO
	btfsc   STATUS,Z_bit
	decf    ACCaHI
	comf    ACCaHI
	retlw   0
;
;*******************************************************************
;                       Test Program
;*******************************************************************
;    Load constant values to ACCa &amp; ACCb for testing
;
loadAB  movlw   1
	movwf   ACCaHI
	movlw   0FF             ; loads ACCa = 01FF
	movwf   ACCaLO
;
	movlw   07F
	movwf   ACCbHI
	movlw   0FF             ; loads ACCb = 7FFF
	movwf   ACCbLO
	retlw   0
;
main    nop
;
	call    loadAB          ; result of adding ACCb+ACCa-&gt;ACCb
	call    D_add           ; Here Accb = 81FE
;
	call    loadAB          ; result of subtracting ACCb - ACCa-&gt;ACCb
	call    D_sub           ; Here Accb = 7E00
;
self    goto    self
;
	org     PIC54
	goto    main
	END
;****************************************************************
</pre></body></html>