1: .globl log, _log 2: ldfps = 170100^tst 3: stfps = 170200^tst 4: ldexp = 176400^movif 5: stexp = 175000^movfi 6: / 7: / log accepts its argument and returns its result 8: / in fr0. The carry bit is set if the argument is 9: / zero or negative. 10: / The coefficients are #2705 from Hart & Cheney. 11: / 12: / movf arg,fr0 13: / jsr pc,log 14: / movf fr0,... 15: / 16: _log: 17: mov r5,-(sp) 18: mov sp,r5 19: movf 4(r5),fr0 20: jsr pc,log 21: mov (sp)+,r5 22: rts pc 23: 24: log: 25: tstf fr0 26: cfcc 27: bgt 1f 28: movf $bigneg,fr0 /return -(big) on error 29: sec 30: rts pc 31: 1: 32: stfps -(sp) 33: ldfps $200 /di mode 34: movf fr2,-(sp) 35: movf fr1,-(sp) 36: / 37: stexp fr0,-(sp) /scale 38: ldexp $0,fr0 39: cmpf sqrt2o2,fr0 40: cfcc 41: blt 1f 42: ldexp $1,fr0 43: dec (sp) 44: 1: 45: movf fr0,fr1 /(1/2)^(1/2) < x < 2^(1/2) 46: subf $one,fr0 47: addf $one,fr1 48: divf fr1,fr0 /z = (x-1)/(x+1) 49: movf fr0,fr1 50: mulf fr0,fr1 /z^2 51: / 52: movf p3,fr2 53: mulf fr1,fr2 54: addf p2,fr2 55: mulf fr1,fr2 56: addf p1,fr2 57: mulf fr1,fr2 58: addf p0,fr2 59: mulf fr2,fr0 /zP(z) 60: / 61: movf fr1,fr2 62: addf q2,fr2 63: mulf fr1,fr2 64: addf q1,fr2 65: mulf fr1,fr2 66: addf q0,fr2 /Q(z) 67: / 68: divf fr2,fr0 /zP(z)/Q(z) 69: movif (sp)+,fr1 70: mulf log2,fr1 71: addf fr1,fr0 72: / 73: movf (sp)+,fr1 74: movf (sp)+,fr2 75: ldfps (sp)+ 76: rts pc 77: / 78: / 79: one = 40200 80: bigneg = 177777 81: / 82: .data 83: sqrt2o2: 40065; 02363; 31771; 157145 84: log2: 40061; 71027;173721;147572 85: / 86: p0: 141300; 16201; 02154; 10216 87: p1: 41367;124211; 21611;114442 88: p2: 141032; 31773; 64222; 40261 89: p3: 37727;114303;110107;114145 90: / 91: q0: 141100; 16201; 02154; 10216 92: q1: 41233;154404;136454; 22153 93: q2: 141016;111747; 07541; 52530 94: / 95: / 96: /p0 = -.24013 91795 59210 50986 8484 d2 97: /p1 = .30957 29282 15376 50062 264 d2 98: /p2 = -.96376 90933 68686 59324 d1 99: /p3 = .42108 73712 17979 7145 d0 100: / 101: /q0 = -.12006 95897 79605 25471 7525 d2 102: /q1 = .19480 96607 00889 73051 623 d2 103: /q2 = -.89111 09027 93783 12337 d1 104: /q3 = .1 d1 105: /