|
|
1.1 ! root 1: //////// ! 2: / ! 3: / Intel 8086 floating point. ! 4: / double to long and unsigned long. ! 5: / small model. ! 6: / ! 7: //////// ! 8: ! 9: .globl ldcvt ! 10: .globl vdcvt ! 11: .globl _fpac_ ! 12: ! 13: //////// ! 14: / ! 15: / ldcvt - double to long integer. ! 16: / vdcvt - double to unsigned long integer. ! 17: / ! 18: / compiler calling sequence: ! 19: / push <double argument> ! 20: / call [lv]dcvt ! 21: / add sp,8 ! 22: / ! 23: / outputs: ! 24: / dx:ax=long or unsigned long result. ! 25: / ! 26: / uses: ! 27: / ax, bx, cx, dx ! 28: / ! 29: //////// ! 30: ! 31: n = 8 / double argument. ! 32: ! 33: ldcvt: push si / standard ! 34: push di / c ! 35: push bp / function ! 36: mov bp,sp / linkage ! 37: ! 38: mov si,$31 / si=largest exponent. ! 39: jmp l0 / go to common code. ! 40: ! 41: vdcvt: push si / standard ! 42: push di / c ! 43: push bp / function ! 44: mov bp,sp / linkage ! 45: ! 46: testb n+7(bp),$0x80 / double < 0 ?? ! 47: jnz l3 / (error) yes, return 0. ! 48: mov si,$32 / si=largest exponant. ! 49: ! 50: l0: mov bx,n+6(bp) / scoop ! 51: mov dx,n+4(bp) / up the front of ! 52: mov ax,n+2(bp) / the double. ! 53: ! 54: shl ax,$1 / slide ! 55: rcl dx,$1 / off the ! 56: rcl bx,$1 / sign. ! 57: ! 58: movb cl,bh / cl=biased exponant. ! 59: and cx,$0xFF / extract, test for all zeros. ! 60: jz l3 / if exp=0, it's 0. ! 61: sub cx,$0x81 / unbias. ! 62: jl l3 / if small, it's 0. ! 63: cmp cx,si / legal range ?? ! 64: jge l3 / (error) nope, return 0. ! 65: ! 66: movb bh,dh / get ! 67: xchgb bh,bl / 32 bits ! 68: movb dh,ah / into ! 69: xchgb dh,dl / the ! 70: mov si,dx / bx:si pair. ! 71: ! 72: sub dx,dx / set up dx:ax with the ! 73: mov ax,$0x01 / hidden bit. ! 74: jcxz l2 / skip if done. ! 75: ! 76: l1: shl si,$1 / shift ! 77: rcl bx,$1 / up ! 78: rcl ax,$1 / the ! 79: rcl dx,$1 / long. ! 80: loop l1 / do all bits. ! 81: ! 82: l2: testb n+7(bp),$0x80 / check sign. ! 83: jz l4 / jump if pos. ! 84: neg dx / convert ! 85: neg ax / to ! 86: sbb dx,$0 / correct sign. ! 87: jmp l4 / done. ! 88: ! 89: l3: sub dx,dx / make up a 0 to ! 90: mov ax,dx / pass back. ! 91: ! 92: l4: pop bp / standard ! 93: pop di / c ! 94: pop si / function ! 95: ret / return.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.