|
|
1.1 ! root 1: ////////// ! 2: / libm 8087 ! 3: / log(x), log10(x), ylog2x ! 4: ////////// ! 5: ! 6: #include "larges.h" ! 7: #include "ifno8087.h" ! 8: ! 9: .globl log10_ ! 10: .globl log_ ! 11: .globl ylog2x ! 12: .globl cfcc87 ! 13: .globl tstcc ! 14: .globl edomain ! 15: ! 16: ////////// ! 17: / double ! 18: / log(x) ! 19: / double x; ! 20: / ! 21: / double ! 22: / log10(x) ! 23: / double x; ! 24: / ! 25: / ylog2x does the work for log functions and pow(). ! 26: / Passed args x, y on the 8087 stack, ! 27: / it pops both and returns y * log base 2 of x on the 8087 stack. ! 28: / ! 29: / Useful identity: ! 30: / log base n of x = log base n of 2 * log base 2 of x. ! 31: / Uses fyl2x, which requires x > 0. ! 32: ////////// ! 33: ! 34: x = RASIZE / arg offset ! 35: ! 36: log10_: ! 37: ifno8087(_log10_) ! 38: fldlg2 / Load y = log base 10 of 2. ! 39: jmp 1f ! 40: ! 41: log_: ! 42: ifno8087(_log_) ! 43: fldln2 / Load y = log base e of 2. ! 44: ! 45: 1: mov bx, sp ! 46: fdld Pss x(bx) / Load argument x. ! 47: ! 48: ylog2x: / x, y ! 49: Gcall tstcc / Check sign of x. ! 50: ja 2f / x > 0., ok. ! 51: fstp st / x <= 0, pop y. ! 52: Gjmp edomain / Issue EDOM error and return 0. ! 53: ! 54: 2: ! 55: ////////// ! 56: / The code below uses ! 57: / fyl2x if d <= 1 or d >= 2-sqrt(2)/2, ! 58: / fyl2xp1 if 1 < d < 2-sqrt(2)/2. ! 59: / Since the precision fyl2xp1 purports to save is already lost, ! 60: / this appears to make no difference in the result. ! 61: / The code is commented out for now and should be removed eventually. ! 62: / fdcom cs:near1 ! 63: / Gcall cfcc87 / Compare d to 2+sqrt(2)/2. ! 64: / jae 4f / d >= 2+sqrt(2)/2, use fyl2x. ! 65: / fld1 / Load 1. ! 66: / fcom ! 67: / Gcall cfcc87 / Compare 1 to d. ! 68: / jae 3f / 1 >= d, use fyl2x. ! 69: / fsub / d = d-1 and pop off the 1. ! 70: / fyl2xp1 / result = y * log base 2 of d+1. ! 71: / Gret ! 72: / ! 73: /3: fstp st / Pop off the 1. ! 74: / ! 75: /4: ! 76: ////////// ! 77: fyl2x / result = y * log base 2 of x. ! 78: Gret ! 79: ! 80: ////////// ! 81: / Commented out as above... ! 82: /near1: .byte 0x1A, 0x62, 0xC0, 0xCC, 0xB0, 0xAF, 0xF4, 0x3F / 2 - sqrt(2)/2 ! 83: //////////
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.