Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
931 B
3
Indexable
Never
#include"xc.inc"
GLOBAL _multi_signed

PSECT mytest, local, class=CODE,reloc=2
 
_multi_signed:
    init:
	MOVFF 0x01, 0x03
	MOVFF WREG, 0x01
    ;use 0x10 zero equal it is pos
	BTFSS 0x01, 7
	    GOTO next
	GOTO makeApos
	makeApos:
	    COMF 0x01
	    INCF 0x01
	    INCF 0x10 
	next:
	BTFSS 0x03,7 ; skip if set(skip if negative)
	    GOTO next2
	GOTO makeBpos
	makeBpos:
	    COMF 0x03
	    INCF 0x03
	    DECF 0x10
	next2:	
	    INCF 0x03
    ;use 0x20, 0x21 as ans
    MOVFF 0x01,0x11
    add:
	DECFSZ 0x03
	    GOTO adding
	GOTO ending
	adding:
	    MOVFF 0x01, WREG
	    ADDWFC 0x21
	    MOVFF 0x00, WREG
	    ADDWFC 0x20
	    GOTO add
	ending:
	    TSTFSZ 0x10 ; skip if zero
		GOTO makeNeg
	    GOTO makePos
	    makeNeg:
		COMF 0x21
		MOVLW 0x01
		ADDWFC 0x21
		COMF 0x20
		MOVLW 0x00
		ADDWFC 0x20
	    makePos:
	    MOVFF 0x20, 0x02
	    MOVFF 0x21, 0x01
	    RETURN