先求倒数,在再进行乘法运算。
*---------------------------------
* subrouting invf
* typical calling sequence:
* LDF V,R0
* CALL INVF
* register used as input:R0
* register modified:R0,R1,R2,R3
* register containing result:R0
*----------------------------------
.FILE "INVF"
.GLOBAL INVF
INVF:
LDF R0,R3
ABSF R0
PUSHF R0
POP R1
ASH -24,R1
NEGI R1
SUBI 1,R1
ASH 24,R1
PUSH R1
POPF R1
LDI @ITER,RC
RPTB LOOP
MPYF R1,R0,R2
SUBRF 2.0,R2
LOOP MPYF R2,R1
RND R1
MPYF R1,R0,R2
SUBRF 1.0,R2
MPYF R1,R2
ADDF R2,R1
RND R1,R0
NEGF R0,R2
LDF R3,R3
LDFN R2,R0
RETS
.DATA
ITER .WORD 4
.end