|
|
1.1 root 1: ////////
2: /
3: / Intel 8086 floating point.
4: / integer types to double.
5: / small model.
6: /
7: ////////
8:
9: .globl dicvt
10: .globl ducvt
11: .globl dlcvt
12: .globl dvcvt
13: .globl _fpac_
14:
15: ////////
16: /
17: / ** dicvt -- convert integer to double float.
18: /
19: / this routine is called directly by the compiler to convert an integer
20: / into a double precision floating point number. no checking is done if
21: / the integer overflows when it is negated.
22: /
23: / compiler calling sequence:
24: / push <int argument>
25: / call dicvt
26: / add sp,2
27: /
28: / outputs:
29: / _fpac_=result.
30: /
31: / uses:
32: / ax, bx, cx, dx
33: /
34: ////////
35:
36: i = 8 / int argument.
37:
38: dicvt: push si / standard
39: push di / c
40: push bp / function
41: mov bp,sp / linkage.
42:
43: sub dx,dx / top half = 0.
44: subb bh,bh / bh=0 (positive)
45: mov ax,i(bp) / get argument.
46: or ax,ax / check its sign,
47: jns l0 / jump if positive.
48: neg ax / negate.
49: movb bh,$0x80 / set sign flag.
50: jmp l0 / go to common code.
51:
52: ////////
53: /
54: / ** ducvt -- convert unsigned integer to double float.
55: /
56: / this routine is called directly by the compiler to convert an unsigned
57: / integer to double precision floating point. no overflows are possible.
58: /
59: / compiler calling sequence:
60: / push <unsigned argument>
61: / call ducvt
62: / add sp,2
63: /
64: / outputs:
65: / _fpac_=result.
66: /
67: / uses:
68: / ax, bx, cx, dx
69: /
70: ////////
71:
72: u = 8 / unsigned int argument.
73:
74: ducvt: push si / standard
75: push di / c
76: push bp / function
77: mov bp,sp / linkage.
78:
79: sub dx,dx / top half = 0.
80: subb bh,bh / bh=0 (positive)
81: mov ax,u(bp) / low half = argument.
82: jmp l0 / go to common code.
83:
84: ////////
85: /
86: / ** dlcvt -- convert long integer to double float.
87: /
88: / this routine is called directly by the compiler to convert a long (32
89: / bit) integer to double precision floating point. no checking is done
90: / for overflow when the long integer is negated.
91: /
92: / compiler calling sequence:
93: / push <long argument>
94: / call dlcvt
95: / add sp,4
96: /
97: / outputs:
98: / _fpac_=result.
99: /
100: / uses:
101: / ax, bx, cx, dx
102: /
103: ////////
104:
105: l = 8 / long argument.
106:
107: dlcvt: push si / stadard
108: push di / c
109: push bp / function
110: mov bp,sp / linkage.
111:
112: subb bh,bh / sign = positive.
113: mov dx,l+2(bp) / fetch.
114: mov ax,l+0(bp) / long.
115: or dx,dx / test the sign.
116: jns l0 / positive, go to common code.
117: neg dx / negate
118: neg ax / the
119: sbb dx,$0 / long int.
120: movb bh,$0x80 / set the sign flag.
121: jmp l0 / go to common code.
122:
123: ////////
124: /
125: / ** dvcvt -- convert unsigned long integer to double float
126: /
127: / this routine is called directly by the compiler to convert a long (32
128: / bit) unsigned integer to double precision floating point. no overflow
129: / is possible.
130: /
131: / compiler calling sequence:
132: / push <unsigned long argument>
133: / call dvcvt
134: / add sp,4
135: /
136: / outputs:
137: / _fpac_=result.
138: /
139: / uses:
140: / ax, bx, cx, dx
141: /
142: ////////
143:
144: v = 8 / unsigned long argument.
145:
146: dvcvt: push si / standard
147: push di / c
148: push bp / function
149: mov bp,sp / linkage.
150:
151: subb bh,bh / sign = positive.
152: mov dx,v+2(bp) / fetch
153: mov ax,v+0(bp) / unsigned long.
154:
155: l0: sub cx,cx / exp=0 (for 0)
156: mov si,dx / test for
157: or si,ax / zeroness.
158: jz l3 / jump if zero, exp=0, frac=0.
159:
160: movb cl,$128+32 / cx=binary point to right of ax.
161:
162: l1: shl ax,$1 / shift up
163: rcl dx,$1 / until
164: jc l2 / the hidden bit
165: decb cl / just
166: jmp l1 / appears.
167:
168: l2: shrb cl,$1 / make room
169: rcr dx,$1 / for the
170: rcr ax,$1 / sign bit.
171: orb cl,bh / zap in sign.
172:
173: l3: movb _fpac_+7,cl / save result
174: mov _fpac_+5,dx / into (odd)
175: mov _fpac_+3,ax / the (odd)
176: sub ax,ax / function
177: movb _fpac_+2,al / return
178: mov _fpac_+0,ax / location
179:
180: pop bp / standard
181: pop di / c
182: pop si / function
183: ret / return.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.