|
|
1.1 ! root 1: //////// ! 2: / ! 3: / Intel 8086 floating point. ! 4: / Double multiply. ! 5: / SMALL model. ! 6: / ! 7: //////// ! 8: ! 9: .globl drmul ! 10: .globl dlmul ! 11: .globl _fpac_ ! 12: .globl dzero ! 13: ! 14: //////// ! 15: / ! 16: / drmul - double multiply (rvalue) ! 17: / dlmul - double multiply (lvalue) ! 18: / ! 19: / compiler calling sequences: ! 20: / push <right double argument> ! 21: / push <left double argument> ! 22: / call drmul ! 23: / add sp, $16 ! 24: / ! 25: / mov ax,offset <right double argument> ! 26: / push ax ! 27: / push <left double argument> ! 28: / call dlmul ! 29: / add sp, $10 ! 30: / ! 31: / outputs: ! 32: / _fpac_ = result. ! 33: / ! 34: //////// ! 35: ! 36: l = 8 / left argument. ! 37: r = 16 / right argument (rvalue) ! 38: rp = 16 / right argument (lvalue) ! 39: ! 40: sign = -2 / sign of result ! 41: r0 = -4 / hi fraction of r arg has implicit bit ! 42: s3 = -6 ! 43: exp = -8 / exponent of result ! 44: ! 45: claim = 8 ! 46: ! 47: drmul: push si ! 48: push di ! 49: push bp ! 50: mov bp,sp ! 51: ! 52: lea si, r(bp) / si = pointer to right op. ! 53: jmp 0f ! 54: ! 55: dlmul: push si ! 56: push di ! 57: push bp ! 58: mov bp,sp ! 59: ! 60: mov si, rp(bp) / si = ptr to r op ! 61: ! 62: 0: sub sp, $claim ! 63: ! 64: mov ax, l+6(bp) ! 65: shl ax, $1 / ah = l exp ! 66: jne 0f ! 67: retz: ! 68: call dzero ! 69: jmp done ! 70: 0: ! 71: rclb dh, $1 / l sign ! 72: mov cx, 6(si) ! 73: shl cx, $1 / ch = r exp ! 74: je retz ! 75: ! 76: adcb dh, $0 / result sign ! 77: movb sign(bp), dh ! 78: ! 79: movb al, ah ! 80: movb cl, ch ! 81: subb ah, ah ! 82: subb ch, ch ! 83: add ax, cx ! 84: sub ax, $128 / result exp ! 85: jng retz ! 86: ! 87: cmp ax, $256 / will decrease by at most 1 ! 88: ja retinf ! 89: ! 90: mov exp(bp), ax ! 91: orb l+6(bp), $128 / set implicit bit of l arg ! 92: mov cx, 5(si) ! 93: orb ch, $128 / cx = r0 = hi word of r fraction ! 94: sub bx, bx / bx = s2 ! 95: ! 96: movb ah, l(bp) / compute r0 * l3 ! 97: subb al, al ! 98: mul cx ! 99: mov di, dx / di = s3 ! 100: ! 101: mov ax, 3(si) / r1 * l2 ! 102: mul l+1(bp) ! 103: add di, dx ! 104: adcb bl, bh ! 105: ! 106: mov ax, 1(si) / r2 * l1 ! 107: mul l+3(bp) ! 108: add di, dx ! 109: adcb bl, bh ! 110: ! 111: subb al, al / r3 * l0 ! 112: movb ah, (si) ! 113: mul l+5(bp) ! 114: add di, dx ! 115: adcb bl, bh ! 116: ! 117: mov ax, l+1(bp) / r0 * l2 ! 118: mul cx ! 119: mov r0(bp), cx / save ! 120: sub cx, cx / cx = s1 ! 121: add di, ax ! 122: adc bx, dx ! 123: adcb cl, ch ! 124: ! 125: mov ax, 3(si) / r1 * l1 ! 126: mul l+3(bp) ! 127: add di, ax ! 128: adc bx, dx ! 129: adcb cl, ch ! 130: ! 131: mov ax, 1(si) / r2 * l0 ! 132: mul l+5(bp) ! 133: add di, ax ! 134: adc bx, dx ! 135: adcb cl, ch ! 136: ! 137: mov s3(bp), di ! 138: sub di, di / di = s0 ! 139: ! 140: mov ax, r0(bp) / r0 * l1 ! 141: mul l+3(bp) ! 142: add bx, ax ! 143: adc cx, dx ! 144: adc di, di ! 145: ! 146: mov ax, 3(si) / r1 * l0 ! 147: mul l+5(bp) ! 148: add bx, ax ! 149: adc cx, dx ! 150: adc di, $0 ! 151: ! 152: mov ax, r0(bp) / r0 * l0 ! 153: mul l+5(bp) ! 154: add cx, ax ! 155: adc di, dx ! 156: ! 157: js 0f / no adjust ! 158: ! 159: sub exp(bp), $1 ! 160: ! 161: shl s3(bp), $1 ! 162: rcl bx, $1 ! 163: rcl cx, $1 ! 164: rcl di, $1 ! 165: 0: ! 166: sub ax, ax ! 167: sub dx, dx ! 168: shlb s3(bp), $1 / round ! 169: adcb ah, s3+1(bp) ! 170: adc bx, dx ! 171: adc cx, dx ! 172: adc di, dx ! 173: adc exp(bp), $0 ! 174: ! 175: movb _fpac_, ah / store fraction in _fpac_ ! 176: mov _fpac_+1, bx / s2 ! 177: mov _fpac_+3, cx / s1 ! 178: ! 179: mov ax, exp(bp) ! 180: je retz ! 181: orb ah, ah ! 182: jne retinf ! 183: ! 184: shl di, $1 / punt implicit bit ! 185: movb ah, sign(bp) ! 186: shr ax, $1 ! 187: rcr di, $1 ! 188: ! 189: mov _fpac_+5, di / and store ! 190: movb _fpac_+7, al ! 191: done: ! 192: mov sp, bp ! 193: pop bp ! 194: pop di ! 195: pop si ! 196: ret ! 197: retinf: ! 198: mov ax, $-1 ! 199: mov _fpac_, ax ! 200: mov _fpac_+2, ax ! 201: mov _fpac_+4, ax ! 202: shr sign(bp), $1 ! 203: rcr ax, $1 ! 204: mov _fpac_+6, ax ! 205: jmp done ! 206: ! 207:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.