; Comba/KCM Macros for C ; ; ** if mr_qltype is defined in mirdef.h use c2.mcs ** ; ; Scheduled Version ; ; Note that: ; mr_small is a word length unsigned type ; mr_large is a double word length unsigned type ; ; Triple register is extra|sum ; The test "extra+=(sum>MIRACL); b[%d]=0; c[%d]=(mr_small)u; ENDM MACRO PMUL_END u=(mr_large)carry*sn; b[0]=(mr_small)u; b[1]=(mr_small)(u>>MIRACL); ENDM MACRO MUL_START extra=0; sum=0; ENDM ; ; STEP macros ; MACRO STEP pp1=(mr_large)a[%d]*b[%d]; sum+=pp1; extra+=(sum>MIRACL)|((mr_large)extra<>MIRACL)|((mr_large)extra<>MIRACL)|((mr_large)extra<>MIRACL)|((mr_large)extra<>MIRACL); ENDM ; ; ADD_START macro ; MACRO ADD_START u=(mr_large)a[0]+b[0]; c[0]=(mr_small)u; carry=(mr_small)(u>>MIRACL); ENDM ; ; ADD macro - c[.]=a[.]+b[.] ; MACRO ADD u=(mr_large)carry+a[%d]+b[%d]; c[%d]=(mr_small)u; carry=(mr_small)(u>>MIRACL); ENDM ; ; ADD_END macro. ; MACRO ADD_END ENDM ; ; DOUBLE_START macro ; MACRO DOUBLE_START u=(mr_large)a[0]+a[0]; a[0]=(mr_small)u; carry=(mr_small)(u>>MIRACL); ENDM ; ; DOUBLE macro ; MACRO DOUBLE u=(mr_large)a[%d]; u+=u; u+=carry; a[%d]=(mr_small)u; carry=(mr_small)(u>>MIRACL); ENDM ; ; DOUBLE_END ; MACRO DOUBLE_END ENDM ; ; INC_START macro. Do first one. ; MACRO INC_START u=(mr_large)a[0]+b[0]; a[0]=(mr_small)u; carry=(mr_small)(u>>MIRACL); ENDM ; ; INC macro a[.]+=b[.] ; MACRO INC u=(mr_large)carry+a[%d]+b[%d]; a[%d]=(mr_small)u; carry=(mr_small)(u>>MIRACL); ENDM MACRO INC_END ENDM MACRO SUB_START u=(mr_large)a[0]-b[0]; c[0]=(mr_small)u; carry=0-(mr_small)(u>>MIRACL); ENDM ; ; SUB macro - c[.]=a[.]-b[.] ; MACRO SUB u=(mr_large)a[%d]-b[%d]-carry; c[%d]=(mr_small)u; carry=0-(mr_small)(u>>MIRACL); ENDM MACRO SUB_END ENDM ; ; DEC_START macro ; MACRO DEC_START u=(mr_large)a[0]-b[0]; a[0]=(mr_small)u; carry=0-(mr_small)(u>>MIRACL); ENDM ; ; DEC macro a[.]-=b[.] ; MACRO DEC u=(mr_large)a[%d]-b[%d]-carry; a[%d]=(mr_small)u; carry=0-(mr_small)(u>>MIRACL); ENDM ; ; DEC_END macro ; MACRO DEC_END ENDM ; ; KADD_START macro. Zero Carry ; MACRO KADD_START carry=0; k%d: ENDM ; ; KASL macro ; MACRO KASL n--; if (n==0) goto k%d; a+=%d; b+=%d; c+=%d; goto k%d; k%d: ENDM ; ; KADD_END macro ; MACRO KADD_END ENDM ; ; KINC_START macro ; MACRO KINC_START carry=0; k%d: ENDM ; ; KIDL macro ; MACRO KIDL n--; if (n==0) goto k%d; a+=%d; b+=%d; goto k%d; k%d: ENDM ; ; KINC_END macro ; MACRO KINC_END ENDM ; ; KDEC_START macro. Zero carry ; MACRO KDEC_START carry=0; k%d: ENDM ; ; KDEC_END macro ; MACRO KDEC_END ENDM