|
|
1.1 ! root 1: ////////// ! 2: / libm 8087 ! 3: / ceil(d), floor(d) ! 4: ////////// ! 5: ! 6: #include "larges.h" ! 7: #include "ifno8087.h" ! 8: ! 9: .globl ceil_ ! 10: .globl floor_ ! 11: .globl floor ! 12: ! 13: ////////// ! 14: / double ! 15: / ceil(d) ! 16: / double d; ! 17: ////////// ! 18: ! 19: cwup = 0xBFF / round up 8087 control word ! 20: d = 2+RASIZE / arg offset ! 21: ! 22: ceil_: ! 23: ifno8087(_ceil_) ! 24: push bp ! 25: mov bp, sp ! 26: ! 27: fdld d(bp) / Load argument d. ! 28: mov ax, $cwup / Round up control word to AX. ! 29: jmp 1f ! 30: ! 31: ////////// ! 32: / double ! 33: / floor(d) ! 34: / double d; ! 35: / ! 36: / floor() rounds 8087 stacktop down to the int below. ! 37: / It saves and restores the current 8087 control word. ! 38: ////////// ! 39: ! 40: cwdown = 0x7FF / round down 8087 control word ! 41: d = 2+RASIZE / arg offset ! 42: autos = 4 / auto space needed ! 43: oldcw = -2 / saved 8087 control word ! 44: newcw = -4 / new 8087 control word ! 45: ! 46: floor_: ! 47: ifno8087(_floor_) ! 48: push bp ! 49: mov bp, sp ! 50: ! 51: fdld d(bp) / Load argument d. ! 52: jmp 0f ! 53: ! 54: floor: / d ! 55: push bp ! 56: mov bp, sp ! 57: ! 58: 0: mov ax, $cwdown / Round down control word to AX. ! 59: ! 60: 1: sub sp, $autos / Claim two words of auto space. ! 61: ! 62: mov newcw(bp), ax / Store new control word. ! 63: fstcw oldcw(bp) / Save old control word. ! 64: fldcw newcw(bp) / Load new control word. ! 65: frndint / int(d) ! 66: fldcw oldcw(bp) / Restore saved control word. ! 67: ! 68: mov sp, bp ! 69: pop bp ! 70: Gret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.