Pristine Ack-5.5
[Ack-5.5.git] / mach / i86 / libem / libem_s.a
1 eÿadi.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0 \ 1.sect .text; .sect .rom; .sect .data; .sect .bss
2 .define .adi
3
4         ! #bytes in cx , top of stack in ax
5         .sect .text
6 .adi:
7         pop     bx              ! return address
8         cmp     cx,2
9         jne     1f
10         pop     cx
11         add     ax,cx
12         jmp     bx
13 1:
14         cmp     cx,4
15         jne     9f
16         pop     dx
17         pop     cx
18         add     ax,cx
19         pop     cx
20         adc     dx,cx
21         push    dx
22         jmp     bx
23 9:
24 .extern EODDZ
25 .extern .trp
26         mov     ax,EODDZ
27         push    bx
28         jmp     .trp
29 and.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\ e\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
30 .define .and
31
32         ! #bytes in cx
33         ! save di; it might be a register variable
34
35         .sect .text
36 .and:
37         pop     bx              ! return address
38         mov     dx,di
39         mov     di,sp
40         add     di,cx
41         sar     cx,1
42 1:
43         pop     ax
44         and     ax,(di)
45         stos
46         loop    1b
47         mov     di,dx
48         jmp     bx
49 cii.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\00\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
50 .define .cii
51
52 .sect .text
53 .cii:
54         pop     bx              ! return address
55                                 ! pop     cx, dest. size
56                                 ! pop     dx, src. size
57                                 ! ax is first word of source
58         cmp     dx,1
59         jne     2f
60         cbw
61         mov     dx,2
62 2:
63         cmp     dx,cx
64         je      8f
65         cmp     dx,2
66         je      1f
67         cmp     dx,4
68         jne     9f
69         cmp     cx,2
70         jne     9f
71         pop     dx
72 8:
73         jmp     bx
74 1:
75         cmp     cx,4
76         jne     9f
77         cwd
78         push    dx
79         jmp     bx
80 9:
81         push    ax              ! push low source
82 .extern EILLINS
83 .extern .fat
84         mov     ax,EILLINS
85         push    ax
86         jmp     .fat
87 cms.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0H\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
88 .define .cms
89
90         ! #bytes in cx
91         .sect .text
92 .cms:
93         pop     bx              ! return address
94         mov     dx,sp
95         push    si
96         push    di
97         mov     si,dx
98         add     dx,cx
99         mov     di,dx
100         add     dx,cx
101         sar     cx,1
102         repe cmps
103         je      1f
104         inc     cx
105 1:
106         pop     di
107         pop     si
108         mov     sp,dx
109         jmp     bx
110 cmi4.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0R\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
111 .define .cmi4
112
113 .sect .text
114 .cmi4:
115         pop     bx              ! return address
116         pop     cx
117         pop     dx
118         pop     ax
119         push    si
120         mov     si,sp
121         xchg    bx,2(si)
122         pop     si
123         cmp     bx,dx
124         jg      1f
125         jl      2f
126         cmp     ax,cx
127         ja      1f
128         je      3f
129 2:
130         mov     ax,-1
131         ret
132 3:
133         xor     ax,ax
134         ret
135 1:
136         mov     ax,1
137         ret
138 cmu4.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0R\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
139 .define .cmu4
140
141 .sect .text
142 .cmu4:
143         pop     bx              ! return address
144         pop     cx
145         pop     dx
146         pop     ax
147         push    si
148         mov     si,sp
149         xchg    bx,2(si)
150         pop     si
151         cmp     bx,dx
152         ja      1f
153         jb      2f
154         cmp     ax,cx
155         ja      1f
156         je      3f
157 2:
158         mov     ax,-1
159         ret
160 3:
161         xor     ax,ax
162         ret
163 1:
164         mov     ax,1
165         ret
166 com.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0¬\0.sect .text; .sect .rom; .sect .data; .sect .bss
167 .define .com
168
169         ! #bytes in cx
170         .sect .text
171 .com:
172         mov     bx,sp
173         add     bx,2
174         sar     cx,1
175 1:
176         not     (bx)
177         inc     bx
178         inc     bx
179         loop    1b
180         ret
181 csa2.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\9c\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
182 .define .csa2
183
184 .sect .text
185 .csa2:
186                                 ! bx, descriptor address
187                                 ! ax, index
188         mov     dx,(bx)         ! default
189         sub     ax,2(bx)
190         cmp     ax,4(bx)
191         ja      1f
192         sal     ax,1
193         add     bx,ax
194         mov     bx,6(bx)
195         test    bx,bx
196         jnz     2f
197 1:
198         mov     bx,dx
199         test    bx,bx
200         jnz     2f
201 .extern ECASE
202 .extern .fat
203         mov     ax,ECASE
204         push    ax
205         jmp     .fat
206 2:
207         jmp     bx
208 csb2.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0t\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
209 .define .csb2
210
211 .sect .text
212 .csb2:
213                                 !bx, descriptor address
214                                 !ax,  index
215         mov     dx,(bx)
216         mov     cx,2(bx)
217 1:
218         add     bx,4
219         dec     cx
220         jl      4f
221         cmp     ax,(bx)
222         jne     1b
223         mov     bx,2(bx)
224 2:
225         test    bx,bx
226         jnz     3f
227 .extern ECASE
228 .extern .fat
229         mov     ax,ECASE
230         push    ax
231         jmp     .fat
232 3:
233         jmp     bx
234 4:
235         mov     bx,dx
236         jmp     2b
237 csa4.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0í\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
238 .define .csa4
239
240 .sect .text
241 .csa4:
242                                 ! bx, descriptor address
243                                 ! ax, dx: index
244         mov     cx,(bx)         ! default
245         sub     ax,2(bx)
246                                 ! ignore high order word; if non-zero, the
247                                 ! case descriptor would not fit anyway
248         cmp     ax,6(bx)
249         ja      1f
250 2:
251         sal     ax,1
252         add     bx,ax
253         mov     bx,10(bx)
254         test    bx,bx
255         jnz     2f
256 1:
257         mov     bx,cx
258         test    bx,bx
259         jnz     2f
260 .extern ECASE
261 .extern .fat
262         mov     ax,ECASE
263         push    ax
264         jmp     .fat
265 2:
266         jmp     bx
267 Ecsb4.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0è\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
268 .define .csb4
269
270 .sect .text
271 .csb4:
272                                 !bx: descriptor address
273                                 !ax, dx:  index
274         push    (bx)            ! default
275         mov     cx,2(bx)        ! count (ignore high order word, the descriptor
276                                 ! would not fit anyway)
277 1:
278         add     bx,6
279         dec     cx
280         jl      4f
281         cmp     ax,(bx)
282         jne     1b
283         cmp     dx,2(bx)
284         jne     1b
285         pop     bx
286         mov     bx,4(bx)
287 2:
288         test    bx,bx
289         jnz     3f
290 .extern ECASE
291 .extern .fat
292         mov     ax,ECASE
293         push    ax
294         jmp     .fat
295 3:
296         jmp     bx
297 4:
298         pop     bx
299         jmp     2b
300 cuu.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0@\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
301 .define .ciu
302 .define .cui
303 .define .cuu
304
305 .sect .text
306 .ciu:
307 .cui:
308 .cuu:
309         pop     bx              ! return address
310                                 ! pop     cx, dest. size
311                                 ! pop     dx, source size
312                                 ! ax is low word of source
313         cmp     dx,cx
314         je      8f
315         cmp     dx,2
316         je      1f
317         cmp     dx,4
318         jne     9f
319         cmp     cx,2
320         jne     9f
321         pop     dx
322 8:
323         jmp     bx
324 1:
325         cmp     cx,4
326         jne     9f
327         xor     dx,dx
328         push    dx
329         jmp     bx
330 9:
331         push    ax              ! to help debugging ?
332 .extern EILLINS
333 .extern .fat
334         mov     ax,EILLINS
335         push    ax
336         jmp     .fat
337 dup.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0å\0.sect .text; .sect .rom; .sect .data; .sect .bss
338 .define .dup
339
340         ! #bytes in cx
341         .sect .text
342 .dup:
343         pop     bx              ! return address
344         mov     ax,si
345         mov     dx,di
346         mov     si,sp
347         sub     sp,cx
348         mov     di,sp
349         sar     cx,1
350         rep movs
351         mov     si,ax
352         mov     di,dx
353         jmp     bx
354 idvi.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ñ\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
355 .define .dvi
356
357         ! #bytes in ax
358         .sect .text
359 .dvi:
360         pop     bx              ! return address
361         cmp     ax,2
362         jne     1f
363         pop     ax
364         cwd
365         pop     cx
366         idiv    cx
367         push    ax
368         jmp     bx
369 1:
370         cmp     ax,4
371         jne     9f
372         pop     ax
373         pop     dx
374         pop     si
375         pop     di
376         push    bx
377         push    di
378         push    si
379         push    dx
380         push    ax
381 .extern .dvi4
382         call   .dvi4
383         pop     bx
384         push    dx
385         push    ax
386         jmp     bx
387 9:
388 .extern EODDZ
389 .extern .trp
390         mov     ax,EODDZ
391         push    bx
392         jmp     .trp
393 \0dvi4.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0÷\ 4.sect .text; .sect .rom; .sect .data; .sect .bss
394 .define .dvi4
395
396 yl=6
397 yh=8
398 xl=10
399 xh=12
400
401 .sect .text
402 .dvi4:
403         push    si
404         push    di
405         mov     si,sp           ! copy of sp
406         mov     bx,yl(si)
407         mov     ax,yh(si)
408         cwd
409         mov     di,dx
410         cmp     dx,ax
411         jne     7f
412         and     dx,dx
413         jge     1f
414         neg     bx
415         je      7f
416 1:
417         xor     dx,dx
418         mov     cx,xl(si)
419         mov     ax,xh(si)
420         and     ax,ax
421         jge     2f
422         neg     ax
423         neg     cx
424         sbb     ax,dx
425         not     di
426 2:
427         div     bx
428         xchg    ax,cx
429         div     bx              ! cx = high abs(result), ax=low abs(result)
430 9:
431         and     di,di
432         jge     1f
433         neg     cx
434         neg     ax
435         sbb     cx,0
436 1:
437                         ! cx is high order result
438                         ! ax is low order result
439         mov     dx,cx
440         pop     di
441         pop     si
442         ret     8       ! result in ax/dx
443
444 7:
445         push    dx              ! sign of y
446         mov     di,ax
447         xor     bx,bx
448         and     di,di
449         jge     1f
450         neg     di
451         neg     yl(si)
452         sbb     di,bx
453 1:
454         mov     ax,xl(si)
455         mov     dx,xh(si)
456         and     dx,dx
457         jge     1f
458         neg     dx
459         neg     ax
460         sbb     dx,bx
461         not     -2(si)
462 1:
463         mov     cx,16
464 1:
465         shl     ax,1
466         rcl     dx,1
467         rcl     bx,1
468         cmp     di,bx
469         ja      3f
470         jb      2f
471         cmp     yl(si),dx
472         jbe     2f
473 3:
474         loop    1b
475         jmp     1f
476 2:
477         sub     dx,yl(si)
478         sbb     bx,di
479         inc     ax
480         loop    1b
481 1:
482         pop     di              ! di=sign of result,ax= result
483         jmp     9b
484 \0dvu.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\10\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
485 .define .dvu
486
487         ! #bytes in ax
488         .sect .text
489 .dvu:
490         pop     bx              ! return address
491         cmp     ax,2
492         jne     1f
493         pop     ax
494         xor     dx,dx
495         pop     cx
496         div     cx
497         push    ax
498         jmp     bx
499 1:
500         cmp     ax,4
501         jne     9f
502         pop     ax
503         pop     dx
504         pop     si
505         pop     di
506         push    bx
507         push    di
508         push    si
509         push    dx
510         push    ax
511 .extern .dvu4
512         call   .dvu4
513         pop     bx
514         push    dx
515         push    ax
516         jmp     bx
517 9:
518 .extern EODDZ
519 .extern .trp
520         mov     ax,EODDZ
521         push    bx
522         jmp     .trp
523 dvu4.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0á\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
524 .define .dvu4
525
526 yl=6
527 yh=8
528 xl=10
529 xh=12
530
531 .sect .text
532 .dvu4:
533         push    si
534         push    di
535         mov     si,sp           ! copy of sp
536         mov     bx,yl(si)
537         mov     ax,yh(si)
538         or      ax,ax
539         jne     7f
540         xor     dx,dx
541         mov     cx,xl(si)
542         mov     ax,xh(si)
543         div     bx
544         xchg    ax,cx
545         div     bx
546 9:
547                         ! cx is high order result
548                         ! ax is low order result
549         mov     dx,cx
550         pop     di
551         pop     si
552         ret     8       ! result in ax/dx
553
554 7:
555         mov     di,ax
556         xor     bx,bx
557         mov     ax,xl(si)
558         mov     dx,xh(si)
559         mov     cx,16
560 1:
561         shl     ax,1
562         rcl     dx,1
563         rcl     bx,1
564         cmp     di,bx
565         ja      3f
566         jb      2f
567         cmp     yl(si),dx
568         jbe     2f
569 3:
570         loop    1b
571         jmp     9b
572 2:
573         sub     dx,yl(si)
574         sbb     bx,di
575         inc     ax
576         loop    1b
577         jmp     9b
578  exg.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0û\0.sect .text; .sect .rom; .sect .data; .sect .bss
579 .define .exg
580
581         ! #bytes in cx
582 .sect .text
583 .exg:
584         push    di
585         mov     di,sp
586         add     di,4
587         mov     bx,di
588         add     bx,cx
589         sar     cx,1
590 1:
591         mov     ax,(bx)
592         xchg    ax,(di)
593         mov     (bx),ax
594         add     di,2
595         add     bx,2
596         loop    1b
597 2:
598         pop     di
599         ret
600 cfp8087.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0e\1c.define .adf4, .adf8, .sbf4, .sbf8, .mlf4, .mlf8, .dvf4, .dvf8
601 .define .ngf4, .ngf8, .fif4, .fif8, .fef4, .fef8
602 .define .cif4, .cif8, .cuf4, .cuf8, .cfi, .cfu, .cff4, .cff8
603 .define .cmf4, .cmf8
604 .sect .text; .sect .rom; .sect .data; .sect .bss
605
606 !       $Id: fp8087.s,v 1.6 1994/06/24 12:59:42 ceriel Exp $
607
608 !       Implement interface to floating point package for Intel 8087
609
610         .sect .rom
611 one:
612         .data2  1
613 two:
614         .data2  2
615 bigmin:
616         .data2  0, -32768
617
618         .sect .text
619 .adf4:
620         mov     bx,sp
621         wait
622         flds    2(bx)
623         wait
624         fadds   6(bx)
625         wait
626         fstps   6(bx)
627         wait
628         ret
629 .adf8:
630         mov     bx,sp
631         wait
632         fldd    2(bx)
633         wait
634         faddd   10(bx)
635         wait
636         fstpd   10(bx)
637         wait
638         ret
639
640 .sbf4:
641         mov     bx,sp
642         wait
643         flds    6(bx)
644         wait
645         fsubs   2(bx)
646         wait
647         fstps   6(bx)
648         wait
649         ret
650
651 .sbf8:
652         mov     bx,sp
653         wait
654         fldd    10(bx)
655         wait
656         fsubd   2(bx)
657         wait
658         fstpd   10(bx)
659         wait
660         ret
661
662 .mlf4:
663         mov     bx,sp
664         wait
665         flds    2(bx)
666         wait
667         fmuls   6(bx)
668         wait
669         fstps   6(bx)
670         wait
671         ret
672 .mlf8:
673         mov     bx,sp
674         wait
675         fldd    2(bx)
676         wait
677         fmuld   10(bx)
678         wait
679         fstpd   10(bx)
680         wait
681         ret
682
683 .dvf4:
684         mov     bx,sp
685         wait
686         flds    6(bx)
687         wait
688         fdivs   2(bx)
689         wait
690         fstps   6(bx)
691         wait
692         ret
693
694 .dvf8:
695         mov     bx,sp
696         wait
697         fldd    10(bx)
698         wait
699         fdivd   2(bx)
700         wait
701         fstpd   10(bx)
702         wait
703         ret
704
705 .ngf4:
706         mov     bx,sp
707         wait
708         flds    2(bx)
709         wait
710         fchs
711         wait
712         fstps   2(bx)
713         wait
714         ret
715
716 .ngf8:
717         mov     bx,sp
718         wait
719         fldd    2(bx)
720         wait
721         fchs
722         wait
723         fstpd   2(bx)
724         wait
725         ret
726
727 .fif4:
728         mov     bx,sp
729         push    bx              ! make room for FP status word
730         wait
731         flds    4(bx)
732         wait
733         fmuls   8(bx)           ! multiply
734         wait
735         fld     st              ! copy result
736         wait
737         ftst                    ! test sign; handle negative separately
738         wait
739         fstsw   -2(bx)
740         wait
741         mov     ax,-2(bx)
742         sahf                    ! result of test in condition codes
743         jb      1f
744         frndint                 ! this one rounds (?)
745         wait
746         fcom    st(1)           ! compare with original; if <=, then OK
747         wait
748         fstsw   -2(bx)
749         wait
750         mov     ax,-2(bx)
751         sahf
752         jbe     2f
753         fisubs  (one)           ! else subtract 1
754         wait
755         jmp     2f
756 1:                              ! here, negative case
757         frndint                 ! this one rounds (?)
758         wait
759         fcom    st(1)           ! compare with original; if >=, then OK
760         wait
761         fstsw   -2(bx)
762         wait
763         mov     ax,-2(bx)
764         sahf
765         jae     2f
766         fiadds  (one)           ! else add 1
767         wait
768 2:
769         fsub    st(1),st        ! subtract integer part
770         wait
771         mov     bx,2(bx)
772         fstps   (bx)
773         wait
774         fstps   4(bx)
775         wait
776         pop     bx
777         ret
778
779 .fif8:
780         mov     bx,sp
781         push    bx              ! make room for FP status word
782         wait
783         fldd    4(bx)
784         wait
785         fmuld   12(bx)          ! multiply
786         wait
787         fld     st              ! and copy result
788         wait
789         ftst                    ! test sign; handle negative separately
790         wait
791         fstsw   -2(bx)
792         wait
793         mov     ax,-2(bx)
794         sahf                    ! result of test in condition codes
795         jb      1f
796         frndint                 ! this one rounds (?)
797         wait
798         fcom    st(1)           ! compare with original; if <=, then OK
799         wait
800         fstsw   -2(bx)
801         wait
802         mov     ax,-2(bx)
803         sahf
804         jbe     2f
805         fisubs  (one)           ! else subtract 1
806         wait
807         jmp     2f
808 1:                              ! here, negative case
809         frndint                 ! this one rounds (?)
810         wait
811         fcom    st(1)           ! compare with original; if >=, then OK
812         wait
813         fstsw   -2(bx)
814         wait
815         mov     ax,-2(bx)
816         sahf
817         jae     2f
818         fiadds  (one)           ! else add 1
819         wait
820 2:
821         fsub    st(1),st        ! subtract integer part
822         mov     bx,2(bx)
823         fstpd   (bx)
824         wait
825         fstpd   8(bx)
826         wait
827         pop     bx
828         ret
829
830 .fef4:
831                                 ! this could be simpler, if only the
832                                 ! fxtract instruction was emulated properly
833         mov     bx,sp
834         mov     ax,6(bx)
835         and     ax,077600
836         je      1f              ! zero exponent
837         mov     cx,7
838         shr     ax,cl
839         sub     ax,126
840         mov     cx,ax           ! exponent in cx
841         mov     ax,6(bx)
842         and     ax,0100177
843         or      ax,0037400      ! load -1 exponent
844         mov     dx,4(bx)
845         mov     bx,2(bx)
846         mov     4(bx),ax
847         mov     2(bx),dx
848         mov     (bx),cx
849         ret
850 1:                              ! we get here on zero exp
851         mov     ax,6(bx)
852         and     ax,0177
853         or      ax,4(bx)
854         jne     1f              ! zero result
855         xor     ax,ax
856         mov     bx,2(bx)
857         mov     (bx),ax
858         mov     2(bx),ax
859         mov     4(bx),ax
860         ret
861 1:                              ! otherwise unnormalized number
862         mov     cx,6(bx)
863         and     cx,0100177
864         mov     dx,cx
865         and     cx,0x8000
866         mov     ax,-125
867 2:
868         test    dx,0x80
869         jne     1f
870         dec     ax
871         shl     4(bx),1
872         rcl     dx,1
873         or      dx,cx
874         jmp     2b
875 1:
876         mov     cx,4(bx)
877         mov     bx,2(bx)
878         mov     (bx),ax
879         mov     2(bx),cx
880         and     dx,0100177
881         or      dx,0037400      ! load -1 exponent
882         mov     4(bx),dx
883         ret
884
885 .fef8:
886                                 ! this could be simpler, if only the
887                                 ! fxtract instruction was emulated properly
888         mov     bx,sp
889         mov     ax,10(bx)
890         and     ax,077760
891         je      1f              ! zero exponent
892         mov     cx,4
893         shr     ax,cl
894         sub     ax,1022
895         mov     cx,ax           ! exponent in cx
896         mov     ax,10(bx)
897         and     ax,0100017
898         or      ax,0037740      ! load -1 exponent
899         push    8(bx)
900         push    6(bx)
901         push    4(bx)
902         mov     bx,2(bx)
903         pop     2(bx)
904         pop     4(bx)
905         pop     6(bx)
906         mov     8(bx),ax
907         mov     (bx),cx
908         ret
909 1:                              ! we get here on zero exp
910         mov     ax,10(bx)
911         and     ax,017
912         or      ax,8(bx)
913         or      ax,6(bx)
914         or      ax,4(bx)
915         jne     1f              ! zero result
916         xor     ax,ax
917         mov     bx,2(bx)
918         mov     (bx),ax
919         mov     2(bx),ax
920         mov     4(bx),ax
921         mov     6(bx),ax
922         mov     8(bx),ax
923         ret
924 1:                              ! otherwise unnormalized number
925         mov     cx,10(bx)
926         and     cx,0100017
927         mov     dx,cx
928         and     cx,0x8000
929         mov     ax,-1021
930 2:
931         test    dx,0x10
932         jne     1f
933         dec     ax
934         shl     4(bx),1
935         rcl     6(bx),1
936         rcl     8(bx),1
937         rcl     dx,1
938         or      dx,cx
939         jmp     2b
940 1:
941         and     dx,0100017
942         or      dx,0037740      ! load -1 exponent
943         mov     cx,8(bx)
944         push    6(bx)
945         push    4(bx)
946         mov     bx,2(bx)
947         mov     (bx),ax
948         mov     8(bx),dx
949         mov     6(bx),cx
950         pop     2(bx)
951         pop     4(bx)
952         ret
953
954 .cif4:
955         mov     bx,sp
956         cmp     2(bx),2
957         jne     1f
958         wait
959         filds   4(bx)
960         wait
961         fstps   2(bx)
962         wait
963         ret
964 1:
965         wait
966         fildl   4(bx)
967         wait
968         fstps   4(bx)
969         wait
970         ret
971
972 .cif8:
973         mov     bx,sp
974         cmp     2(bx),2
975         jne     1f
976         wait
977         filds   4(bx)
978         wait
979         fstpd   2(bx)
980         wait
981         ret
982 1:
983         wait
984         fildl   4(bx)
985         wait
986         fstpd   2(bx)
987         wait
988         ret
989
990 .cuf4:
991         mov     bx,sp
992         cmp     2(bx),2
993         jne     1f
994         mov     ax,4(bx)
995         mov     2(bx),ax
996         mov     4(bx),0
997         wait
998         fildl   2(bx)
999         wait
1000         fstps   2(bx)
1001         wait
1002         ret
1003 1:
1004         wait
1005         fildl   4(bx)
1006         wait
1007         cmp     6(bx),0
1008         jge     1f
1009 2:
1010         wait
1011         fisubl  (bigmin)
1012         wait
1013         fisubl  (bigmin)
1014 1:
1015         wait
1016         fstps   4(bx)
1017         wait
1018         ret
1019
1020 .cuf8:
1021         mov     bx,sp
1022         cmp     2(bx),2
1023         jne     1f
1024         mov     6(bx),0
1025 1:
1026         wait
1027         fildl   4(bx)
1028         wait
1029         cmp     6(bx),0
1030         jge     1f
1031 2:
1032         wait
1033         fisubl  (bigmin)
1034         wait
1035         fisubl  (bigmin)
1036 1:
1037         wait
1038         fstpd   2(bx)
1039         wait
1040         ret
1041
1042 .cfi:
1043         mov     bx,sp
1044         push    bx
1045         wait
1046         fstcw   -2(bx)
1047         wait
1048         mov     dx,-2(bx)
1049         or      -2(bx),0xc00    ! truncating mode
1050         wait
1051         fldcw   -2(bx)
1052         pop     ax
1053         cmp     4(bx),4
1054         jne     2f
1055                                 ! loc 4 loc ? cfi
1056         wait
1057         flds    6(bx)
1058         wait
1059         fistpl  6(bx)
1060         wait
1061         cmp     2(bx),2
1062         jne     1f
1063         mov     ax,6(bx)
1064 1:
1065         mov     4(bx),dx
1066         wait
1067         fldcw   4(bx)
1068         wait
1069         ret
1070 2:
1071                                 ! loc 8 loc ? cfi
1072         wait
1073         fldd    6(bx)
1074         wait
1075         fistpl  10(bx)
1076         wait
1077         cmp     2(bx),2
1078         jne     1b
1079         mov     ax,10(bx)
1080         jmp     1b
1081
1082 .cfu:
1083         mov     bx,sp
1084         push    bx
1085         wait
1086         fstcw   -2(bx)
1087         wait
1088         mov     dx,-2(bx)
1089         and     -2(bx),0xf3ff
1090         or      -2(bx),0x400    ! to -infinity
1091         wait
1092         fldcw   -2(bx)
1093         wait
1094         pop     ax
1095         cmp     4(bx),4
1096         jne     2f
1097                                 ! loc 4 loc ? cfu
1098         flds    6(bx)
1099         wait
1100         fabs                    ! ???
1101         wait
1102         fiaddl  (bigmin)
1103         fistpl  6(bx)
1104         wait
1105         mov     ax,8(bx)
1106         sub     ax,(bigmin+2)
1107         mov     8(bx),ax
1108         cmp     2(bx),2
1109         jne     1f
1110         mov     ax,6(bx)
1111 1:
1112         mov     4(bx),dx
1113         wait
1114         fldcw   4(bx)
1115         wait
1116         ret
1117 2:
1118         wait
1119                                 ! loc 8 loc ? cfu
1120         fldd    6(bx)
1121         wait
1122         fabs                    ! ???
1123         wait
1124         fiaddl  (bigmin)
1125         fistpl  10(bx)
1126         wait
1127         mov     ax,12(bx)
1128         sub     ax,(bigmin+2)
1129         mov     12(bx),ax
1130         cmp     2(bx),2
1131         jne     1b
1132         mov     ax,10(bx)
1133         jmp     1b
1134
1135 .cff4:
1136         mov     bx,sp
1137         wait
1138         fldd    2(bx)
1139         wait
1140         fstcw   2(bx)
1141         wait
1142         mov     dx,2(bx)
1143         and     2(bx),0xf3ff    ! set to rounding mode
1144         wait
1145         fldcw   2(bx)
1146         wait
1147         fstps   6(bx)
1148         mov     2(bx),dx
1149         wait
1150         fldcw   2(bx)
1151         wait
1152         ret
1153
1154 .cff8:
1155         mov     bx,sp
1156         wait
1157         flds    2(bx)
1158         wait
1159         fstpd   2(bx)
1160         wait
1161         ret
1162
1163 .cmf4:
1164         mov     bx,sp
1165         push    bx              ! room for 8087 status word
1166         xor     cx,cx
1167         wait
1168         flds    6(bx)
1169         wait
1170         flds    2(bx)
1171         wait
1172         fcompp                  ! compare and pop operands
1173         wait
1174         fstsw   -2(bx)
1175         wait
1176         mov     ax,-2(bx)
1177         sahf
1178         je      1f
1179         jb      2f
1180         dec     cx
1181         jmp     1f
1182 2:
1183         inc     cx
1184 1:
1185         mov     ax,cx
1186         pop     bx
1187         ret
1188
1189
1190 .cmf8:
1191         mov     bx,sp
1192         push    bx              ! room for 8087 status word
1193         xor     cx,cx
1194         wait
1195         fldd    10(bx)
1196         wait
1197         fldd    2(bx)
1198         wait
1199         fcompp                  ! compare and pop operands
1200         wait
1201         fstsw   -2(bx)
1202         wait
1203         mov     ax,-2(bx)
1204         sahf
1205         je      1f
1206         jb      2f
1207         dec     cx
1208         jmp     1f
1209 2:
1210         inc     cx
1211 1:
1212         mov     ax,cx
1213         pop     bx
1214         ret
1215 \0gto.s\0.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\83\0.sect .text; .sect .rom; .sect .data; .sect .bss
1216 .sect .text
1217 .define .gto
1218
1219 .gto:
1220         mov     bp,4(bx)
1221         mov     sp,2(bx)
1222         jmp     (bx)
1223 8iaar.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0/\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1224 .sect .text
1225 .define .iaar
1226
1227 .iaar:
1228         pop     cx
1229         pop     dx
1230         cmp     dx,2
1231 .extern .unknown
1232         jne     .unknown
1233         pop     bx      ! descriptor address
1234         pop     ax      ! index
1235         sub     ax,(bx)
1236         mul     4(bx)
1237         pop     bx      ! base address
1238         add     bx,ax
1239         push    cx
1240         ret
1241 milar.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\ 3\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1242 .sect .text
1243 .define .ilar
1244
1245 .ilar:
1246         pop     cx
1247         pop     dx
1248 .extern .unknown
1249         cmp     dx,2
1250         jne     .unknown
1251         pop     bx      ! descriptor address
1252         pop     ax      ! index
1253         push    cx
1254 .extern .lar2
1255         jmp    .lar2
1256 !inn.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\9d\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1257 .sect .text
1258 .define .inn
1259
1260         ! #bytes in cx
1261         ! bit # in ax
1262 .inn:
1263         xor     dx,dx
1264         mov     bx,8
1265         div     bx
1266         mov     bx,sp
1267         add     bx,2
1268         add     bx,ax
1269         cmp     ax,cx
1270         jae     1f
1271         movb    al,(bx)
1272         mov     bx,dx
1273         testb   al,bits(bx)
1274         jz      1f
1275         mov     ax,1
1276         jmp     2f
1277 1:
1278         xor     ax,ax
1279 2:
1280         pop     bx
1281         add     sp,cx
1282         ! ax is result
1283         jmp     bx
1284
1285         .sect .data
1286 bits:
1287         .data1 1,2,4,8,16,32,64,128
1288
1289 ior.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ß\0.sect .text; .sect .rom; .sect .data; .sect .bss
1290 .sect .text
1291 .define .ior
1292
1293         ! #bytes in cx
1294 .ior:
1295         pop     bx              ! return address
1296         mov     dx,di
1297         mov     di,sp
1298         add     di,cx
1299         sar     cx,1
1300 1:
1301         pop     ax
1302         or      ax,(di)
1303         stos
1304         loop    1b
1305         mov     di,dx
1306         jmp     bx
1307 visar.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\ 3\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1308 .sect .text
1309 .define .isar
1310
1311 .isar:
1312         pop     cx
1313         pop     ax
1314         cmp     ax,2
1315 .extern .unknown
1316         jne     .unknown
1317         pop     bx      ! descriptor address
1318         pop     ax      ! index
1319         push    cx
1320 .extern .sar2
1321         jmp    .sar2
1322 tlar2.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ò\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1323 .sect .text
1324 .define .lar2
1325
1326 .lar2:
1327                                 ! bx, descriptor address
1328                                 ! ax, index
1329         pop     cx
1330         pop     dx              ! base address
1331         push    cx
1332         push    si
1333         mov     si,dx
1334         sub     ax,(bx)
1335         mov     cx,4(bx)
1336         imul    cx
1337         add     si,ax
1338         sar     cx,1
1339         jnb     1f
1340         xorb    ah,ah
1341         lodsb
1342         pop     si
1343         pop     bx
1344         push    ax
1345         jmp     bx
1346 1:
1347         pop     dx              ! saved si
1348         mov     ax,4(bx)
1349         pop     bx              ! return address
1350         sub     sp,ax
1351         mov     ax,di           ! save di
1352         mov     di,sp
1353         rep movs
1354         mov     di,ax
1355         mov     si,dx
1356         jmp     bx
1357 loi.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0é\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1358 .sect .text
1359 .define .loi
1360 .define .los
1361
1362         ! #bytes in cx
1363         ! address in bx
1364         ! save si/di. they might be register variables
1365 .los:
1366         mov     dx,si
1367         mov     si,bx
1368         pop     bx
1369         mov     ax,cx
1370         sar     cx,1
1371         jnb     1f
1372         xorb    ah,ah
1373         lodsb
1374         mov     si,dx
1375         push    ax
1376         jmp     bx
1377 1:
1378         sub     sp,ax
1379         jmp     1f
1380
1381 .loi:
1382         ! only called with size > 4
1383         mov     dx,si
1384         mov     si,bx
1385         pop     bx
1386         sub     sp,cx
1387         sar     cx,1
1388 1:
1389         mov     ax,di
1390         mov     di,sp
1391         rep movs
1392         mov     si,dx
1393         mov     di,ax
1394         jmp     bx
1395 pmli.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0$\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
1396 .sect .text
1397 .define .mli
1398
1399         ! #bytes in ax
1400 .mli:
1401         pop     bx              ! return address
1402         cmp     ax,2
1403         jne     1f
1404         pop     ax
1405         pop     cx
1406         mul     cx
1407         push    ax
1408         jmp     bx
1409 1:
1410         cmp     ax,4
1411         jne     9f
1412         push    bx
1413         mov     cx,bx
1414         mov     bx,sp
1415         mov     ax,2(bx)
1416         mov     (bx),ax
1417         mov     ax,4(bx)
1418         mov     2(bx),ax
1419         mov     ax,6(bx)
1420         mov     4(bx),ax
1421         mov     ax,8(bx)
1422         mov     6(bx),ax
1423         mov     8(bx),cx
1424         pop     ax
1425         pop     dx
1426         call   .mli4
1427         pop     bx
1428         push    dx
1429         push    ax
1430         jmp     bx
1431 9:
1432 .extern EODDZ
1433 .extern .trp
1434         mov     ax,EODDZ
1435         push    bx
1436         jmp     .trp
1437 mli4.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0p\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1438 .sect .text
1439 .define .mli4
1440
1441 yl=2
1442 yh=4
1443         ! x * y
1444         ! xl in ax
1445         ! xh in dx
1446
1447 .mli4:
1448         mov     bx,sp
1449         push    dx
1450         mov     cx,ax
1451         mul     yh(bx)           ! xl*yh
1452         pop     dx
1453         push    ax
1454         mov     ax,dx
1455         mul     yl(bx)          ! xh * yl
1456         pop     dx
1457         add     dx,ax           ! xh*yl+xl*yh
1458         mov     ax,cx
1459         mov     cx,dx
1460         mul     yl(bx)           ! xl*yl
1461         add     dx,cx
1462         ret     4
1463 mon.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0n\0.sect .text; .sect .rom; .sect .data; .sect .bss
1464 .sect .text
1465 .define .mon
1466
1467 .mon:
1468 .extern .stop
1469         call    .stop
1470 ngi.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\9e\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1471 .sect .text
1472 .define .ngi
1473
1474         ! #bytes in ax
1475 .ngi:
1476         pop     bx              ! return address
1477         cmp     ax,2
1478         jne     1f
1479         pop     cx
1480         neg     cx
1481         push    cx
1482         jmp     bx
1483 1:
1484         cmp     ax,4
1485         jne     9f
1486         pop     dx
1487         pop     ax
1488         neg     ax
1489         neg     dx
1490         sbb     ax,0
1491         push    dx
1492         push    ax
1493         jmp     bx
1494 9:
1495 .extern EODDZ
1496 .extern .trp
1497         mov     ax,EODDZ
1498         push    bx
1499         jmp     .trp
1500 nop.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Æ\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1501 .sect .text
1502 .define .nop
1503 .extern printd, printc, hol0
1504
1505 SIO_S           = 0xDA
1506 SIO_D           = 0xD8
1507 RXRDY           = 0x02
1508
1509 .nop:
1510         mov     ax,(hol0)
1511         call    printd
1512 !       movb    al,' '
1513 !       call    printc
1514 !       mov     ax,sp
1515 !       call    printd
1516 !1:
1517 !       inb     SIO_S
1518 !       andb    al,RXRDY
1519 !       jz      1b
1520 !       inb     SIO_D
1521 !       call    printc
1522         movb    al,'\n'
1523         jmp     printc
1524 rck.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\01\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1525 .sect .text
1526 .define .rck
1527
1528         ! descriptor address in bx
1529         ! value in ax, must be left there
1530 .rck:
1531         cmp     ax,(bx)
1532         jl      2f
1533         cmp     ax,2(bx)
1534         jg      2f
1535         ret
1536 2:
1537         push    ax
1538 .extern ERANGE
1539 .extern .error
1540         mov     ax,ERANGE
1541         call    .error
1542         pop     ax
1543         ret
1544
1545 rmi.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\ 5\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
1546 .sect .text
1547 .define .rmi
1548
1549         ! #bytes in ax
1550 .rmi:
1551         pop     bx              ! return address
1552         cmp     ax,2
1553         jne     1f
1554         pop     ax
1555         cwd
1556         pop     cx
1557         idiv    cx
1558         push    dx
1559         jmp     bx
1560 1:
1561         cmp     ax,4
1562         jne     9f
1563         pop     ax
1564         pop     dx
1565         pop     si
1566         pop     di
1567         push    bx
1568         push    di
1569         push    si
1570         push    dx
1571         push    ax
1572 .extern .rmi4
1573         call   .rmi4
1574         pop     bx
1575         push    dx
1576         push    ax
1577         jmp     bx
1578 9:
1579 .extern EODDZ
1580 .extern .trp
1581         mov     ax,EODDZ
1582         push    bx
1583         jmp     .trp
1584 Ormi4.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ê\ 4.sect .text; .sect .rom; .sect .data; .sect .bss
1585 .sect .text
1586 .define .rmi4
1587
1588 yl=6
1589 yh=8
1590 xl=10
1591 xh=12
1592
1593 .rmi4:
1594         push    si
1595         push    di
1596         mov     si,sp           ! copy of sp
1597         mov     bx,yl(si)
1598         mov     ax,yh(si)
1599         cwd
1600         cmp     dx,ax
1601         jne     7f
1602         and     dx,dx
1603         jge     1f
1604         neg     bx
1605         je      7f
1606 1:
1607         xor     dx,dx
1608         mov     cx,xl(si)
1609         mov     ax,xh(si)
1610         and     ax,ax
1611         jge     2f
1612         neg     ax
1613         neg     cx
1614         sbb     ax,dx
1615 2:
1616         div     bx
1617         xchg    ax,cx
1618         div     bx              ! dx= result(low), 0=result(high)
1619         xor     bx,bx
1620 9:
1621         cmp     xh(si),0
1622         jge     1f
1623         neg     bx
1624         neg     dx
1625         sbb     bx,0
1626 1:
1627                         ! bx is high order result
1628                         ! dx is low order result
1629         mov     ax,dx
1630         mov     dx,bx   ! result in ax/dx
1631         pop     di
1632         pop     si
1633         ret     8
1634
1635 7:
1636         mov     di,ax
1637         xor     bx,bx
1638         and     di,di
1639         jge     1f
1640         neg     di
1641         neg     yl(si)
1642         sbb     di,bx
1643 1:
1644         mov     ax,xl(si)
1645         mov     dx,xh(si)
1646         and     dx,dx
1647         jge     1f
1648         neg     dx
1649         neg     ax
1650         sbb     dx,bx
1651 1:
1652         mov     cx,16
1653 1:
1654         shl     ax,1
1655         rcl     dx,1
1656         rcl     bx,1
1657         cmp     di,bx
1658         ja      3f
1659         jb      2f
1660         cmp     yl(si),dx
1661         jbe     2f
1662 3:
1663         loop    1b
1664                 ! dx=result(low), bx=result(high)
1665         jmp     9b
1666 2:
1667         sub     dx,yl(si)
1668         sbb     bx,di
1669         inc     ax
1670         loop    1b
1671 1:
1672                 ! dx=result(low), bx=result(high)
1673         jmp     9b
1674 rmu.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\ f\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
1675 .sect .text
1676 .define .rmu
1677
1678         ! #bytes in ax
1679 .rmu:
1680         pop     bx              ! return address
1681         cmp     ax,2
1682         jne     1f
1683         pop     ax
1684         xor     dx,dx
1685         pop     cx
1686         idiv    cx
1687         push    dx
1688         jmp     bx
1689 1:
1690         cmp     ax,4
1691         jne     9f
1692         pop     ax
1693         pop     dx
1694         pop     si
1695         pop     di
1696         push    bx
1697         push    di
1698         push    si
1699         push    dx
1700         push    ax
1701 .extern .rmu4
1702         call   .rmu4
1703         pop     bx
1704         push    dx
1705         push    ax
1706         jmp     bx
1707 9:
1708 .extern EODDZ
1709 .extern .trp
1710         mov     ax,EODDZ
1711         push    bx
1712         jmp     .trp
1713 ,rmu4.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0L\ 3.sect .text; .sect .rom; .sect .data; .sect .bss
1714 .sect .text
1715 .define .rmu4
1716
1717 yl=6
1718 yh=8
1719 xl=10
1720 xh=12
1721
1722 .rmu4:
1723         push    si
1724         push    di
1725         mov     si,sp           ! copy of sp
1726         mov     bx,yl(si)
1727         mov     ax,yh(si)
1728         or      ax,ax
1729         jne     7f
1730 1:
1731         xor     dx,dx
1732         mov     cx,xl(si)
1733         mov     ax,xh(si)
1734 2:
1735         div     bx
1736         xchg    ax,cx
1737         div     bx
1738         xor     bx,bx
1739 9:
1740                         ! bx is high order result
1741                         ! dx is low order result
1742         mov     ax,dx
1743         mov     dx,bx
1744         pop     di
1745         pop     si
1746         ret     8       ! result in ax/dx
1747
1748 7:
1749         mov     di,ax
1750         xor     bx,bx
1751         mov     ax,xl(si)
1752         mov     dx,xh(si)
1753         mov     cx,16
1754 1:
1755         shl     ax,1
1756         rcl     dx,1
1757         rcl     bx,1
1758         cmp     di,bx
1759         ja      3f
1760         jb      2f
1761         cmp     yl(si),dx
1762         jbe     2f
1763 3:
1764         loop    1b
1765                 ! dx=result(low), bx=result(high)
1766         jmp     9b
1767 2:
1768         sub     dx,yl(si)
1769         sbb     bx,di
1770         inc     ax
1771         loop    1b
1772 1:
1773                 ! dx=result(low), bx=result(high)
1774         jmp     9b
1775 rol.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Û\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1776 .sect .text
1777 .define .rol
1778
1779         ! #bytes in ax
1780 .rol:
1781         pop     dx              ! return address
1782         cmp     ax,2
1783         jne     1f
1784         pop     ax
1785         pop     cx
1786         rol     ax,cl
1787         push    ax
1788         jmp     dx
1789 1:
1790         cmp     ax,4
1791         jne     9f
1792         pop     cx
1793         jcxz    2f
1794         pop     ax
1795         pop     bx
1796 3:
1797         sal     ax,1
1798         rcl     bx,1
1799         adc     ax,0
1800         loop    3b
1801         push    bx
1802         push    ax
1803 2:
1804         jmp     dx
1805 9:
1806 .extern EODDZ
1807 .extern .trp
1808         mov     ax,EODDZ
1809         push    dx
1810         jmp     .trp
1811  ror.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0è\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1812 .sect .text
1813 .define .ror
1814
1815         ! #bytes in ax
1816 .ror:
1817         pop     dx              ! return address
1818         cmp     ax,2
1819         jne     1f
1820         pop     ax
1821         pop     cx
1822         ror     ax,cl
1823         push    ax
1824         jmp     dx
1825 1:
1826         cmp     ax,4
1827         jne     9f
1828         pop     cx
1829         jcxz    2f
1830         neg     cx
1831         add     cx,32
1832         pop     ax
1833         pop     bx
1834 3:
1835         sar     bx,1
1836         rcr     ax,1
1837         loop    3b
1838         push    bx
1839         push    ax
1840 2:
1841         jmp     dx
1842 9:
1843 .extern EODDZ
1844 .extern .trp
1845         mov     ax,EODDZ
1846         push    dx
1847         jmp     .trp
1848 sar2.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Õ\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1849 .sect .text
1850 .define .sar2
1851
1852 .sar2:
1853                                 ! bx, descriptor address
1854                                 ! ax, index
1855         pop     cx
1856         pop     dx              ! base address
1857         push    cx
1858         xchg    di,dx           ! di = base address, dx is saved di
1859         sub     ax,(bx)
1860         mov     cx,4(bx)
1861         push    dx
1862         imul    cx
1863         pop     dx
1864         add     di,ax
1865         sar     cx,1
1866         jnb     1f
1867         pop     bx
1868         pop     ax
1869         stosb
1870         mov     di,dx
1871         jmp     bx
1872 1:
1873         pop     bx
1874         mov     ax,si
1875         mov     si,sp
1876         rep movs
1877         mov     sp,si
1878         mov     si,ax
1879         mov     di,dx
1880         jmp     bx
1881  sbi.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0½\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1882 .sect .text
1883 .define .sbi
1884
1885         ! #bytes in cx , top of stack in ax
1886 .sbi:
1887         pop     bx              ! return subress
1888         cmp     cx,2
1889         jne     1f
1890         pop     cx
1891         sub     ax,cx
1892         neg     ax
1893         jmp     bx
1894 1:
1895         cmp     cx,4
1896         jne     9f
1897         pop     dx
1898         pop     cx
1899         sub     cx,ax
1900         mov     ax,cx
1901         pop     cx
1902         sbb     cx,dx
1903         push    cx
1904         jmp     bx
1905 9:
1906 .extern EODDZ
1907 .extern .trp
1908         mov     ax,EODDZ
1909         push    bx
1910         jmp     .trp
1911
1912 set.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\05\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
1913 .sect .text
1914 .define .set
1915
1916         ! #bytes in cx
1917         ! bit # in ax
1918 .set:
1919         pop     bx              ! return address
1920         xor     dx,dx
1921 !ifdef create set
1922         sub     sp,cx
1923         push    bx
1924         push    di
1925         mov     bx,sp
1926         xor     di,di
1927         sar     cx,1
1928 1:
1929         mov     4(bx)(di),dx
1930         add     di,2
1931         loop    1b
1932 !endif
1933         mov     bx,8
1934         div     bx
1935         cmp     ax,di
1936         jae     2f
1937         mov     di,dx
1938         movb    dl,bits(di)
1939         mov     di,sp
1940         add     di,ax
1941         orb     4(di),dl
1942         pop     di
1943         ret
1944 2:
1945 .extern ESET
1946 .extern .trp
1947         pop     di
1948         mov     ax,ESET
1949         jmp     .trp
1950
1951         .sect .data
1952 bits:
1953         .data1   1,2,4,8,16,32,64,128
1954  sli.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Í\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1955 .sect .text
1956 .define .sli
1957
1958         ! #bytes in ax
1959 .sli:
1960         pop     dx              ! return address
1961         cmp     ax,2
1962         jne     1f
1963         pop     ax
1964         pop     cx
1965         sal     ax,cl
1966         push    ax
1967         jmp     dx
1968 1:
1969         cmp     ax,4
1970         jne     9f
1971         pop     cx
1972         jcxz    2f
1973         pop     ax
1974         pop     bx
1975 3:
1976         sal     ax,1
1977         rcl     bx,1
1978         loop    3b
1979         push    bx
1980         push    ax
1981 2:
1982         jmp     dx
1983 9:
1984 .extern EODDZ
1985 .extern .trp
1986         mov     ax,EODDZ
1987         push    dx
1988         jmp     .trp
1989
1990 sri.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Í\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1991 .sect .text
1992 .define .sri
1993
1994         ! #bytes in ax
1995 .sri:
1996         pop     dx              ! return address
1997         cmp     ax,2
1998         jne     1f
1999         pop     ax
2000         pop     cx
2001         sar     ax,cl
2002         push    ax
2003         jmp     dx
2004 1:
2005         cmp     ax,4
2006         jne     9f
2007         pop     cx
2008         jcxz    2f
2009         pop     ax
2010         pop     bx
2011 3:
2012         sar     bx,1
2013         rcr     ax,1
2014         loop    3b
2015         push    bx
2016         push    ax
2017 2:
2018         jmp     dx
2019 9:
2020 .extern EODDZ
2021 .extern .trp
2022         mov     ax,EODDZ
2023         push    dx
2024         jmp     .trp
2025
2026 sti.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0À\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
2027 .sect .text
2028 .define .sti
2029 .define .sts
2030
2031         ! #bytes in cx
2032         ! address in bx
2033         ! save di/si. they might be register variables
2034 .sts:
2035         mov     dx,di           ! save di
2036         mov     di,bx
2037         pop     bx
2038         sar     cx,1
2039         jnb     1f
2040         pop     ax
2041         stosb
2042         mov     di,dx
2043         jmp     bx
2044 .sti:
2045         ! only called with count > 4
2046         mov     dx,di
2047         mov     di,bx
2048         pop     bx
2049         sar     cx,1
2050 1:
2051         mov     ax,si
2052         mov     si,sp
2053         rep movs
2054         mov     sp,si
2055         mov     di,dx
2056         mov     si,ax
2057         jmp     bx
2058 strhp.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0L\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
2059 .sect .text
2060 .define .strhp
2061 .extern .reghp, .limhp, EHEAP, .trp
2062
2063 .strhp:
2064         pop     bx
2065         pop     ax
2066         mov     (.reghp),ax
2067         cmp     ax,(.limhp)
2068         jb      1f
2069         add     ax,02000
2070         and     ax,~0777
2071         push    bx
2072         push    ax
2073         call    BRK
2074         pop     cx
2075         pop     bx
2076         cmp     ax,-1
2077         je      2f
2078 1:
2079         mov     (.limhp),cx
2080         jmp     bx
2081 2:
2082         mov     ax,EHEAP
2083         push    bx
2084         jmp     .trp
2085 xor.s\0s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0à\0.sect .text; .sect .rom; .sect .data; .sect .bss
2086 .sect .text
2087 .define .xor
2088
2089         ! #bytes in cx
2090 .xor:
2091         pop     bx              ! return address
2092         mov     dx,di
2093         mov     di,sp
2094         add     di,cx
2095         sar     cx,1
2096 1:
2097         pop     ax
2098         xor     ax,(di)
2099         stos
2100         loop    1b
2101         mov     di,dx
2102         jmp     bx
2103 error.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\v\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
2104 .define .error
2105 .define .Xtrp
2106
2107         ! ax is trap number
2108         ! all registers must be saved
2109         ! because return is possible
2110         ! May only be called with error no's <16
2111 .sect .text
2112 .error:
2113         push bp
2114         push si
2115         push di
2116         push dx
2117         push cx
2118         push bx
2119         push ax
2120         mov  cx,ax
2121         mov  bx,1
2122         sal  bx,cl
2123 .extern .ignmask
2124 .extern .trp
2125         test bx,(.ignmask)
2126         jne  2f
2127         call    .trp
2128 2:
2129         pop  ax
2130         pop  bx
2131         pop  cx
2132         pop  dx
2133         pop  di
2134         pop  si
2135         pop  bp
2136         ret
2137
2138 .Xtrp:
2139         cmp     ax,16
2140         jge     1f
2141         call    .error
2142         ret
2143 1:
2144         jmp     .trp
2145 dunknown.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\94\0.sect .text; .sect .rom; .sect .data; .sect .bss
2146 .sect .text
2147 .define .unknown
2148 .extern EILLINS, .fat
2149
2150 .unknown:
2151         mov  ax,EILLINS
2152         push ax
2153         jmp  .fat
2154 fat.s\0n.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\96\0.sect .text; .sect .rom; .sect .data; .sect .bss
2155 .sect .text
2156 .define .fat
2157
2158 .fat:
2159 .extern .trp
2160 .extern .stop
2161         call    .trp
2162         call    .stop
2163         ! no return
2164 trp.s\0n.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\r\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
2165 .sect .text
2166 .define .trp
2167 .define .stop
2168 .extern .trppc
2169
2170                 ! ax is trap number
2171 .trp:
2172         xor     bx,bx
2173         xchg    bx,(.trppc)
2174         test    bx,bx
2175         jz      2f
2176         push    ax
2177         call    bx
2178         pop     ax
2179         ret
2180 2:
2181         call    .stop
2182
2183 .stop:
2184         jmp     EXIT
2185 pprint.s\0s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0õ\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
2186 .sect .text
2187 .define printc,printd,prints
2188
2189         ! argument in ax
2190         ! uses bx
2191 prints:
2192         xchg    ax,bx
2193 1:
2194         movb    al,(bx)
2195         inc     bx
2196         testb   al,al
2197         jz      2f
2198         call    printc
2199         jmp     1b
2200 2:
2201         ret
2202
2203         ! argument in ax
2204         ! uses cx and dx
2205 printd:
2206         xor     dx,dx
2207         mov     cx,10
2208         div     cx
2209         test    ax,ax
2210         jz      1f
2211         push    dx
2212         call    printd
2213         pop     dx
2214 1:
2215         xchg    ax,dx
2216         addb    al,'0'
2217
2218         ! argument in ax
2219 printc:
2220         push    ax
2221         mov     bx,sp
2222         mov     ax,1
2223         push    ax
2224         push    bx
2225         push    ax
2226         call    __write
2227         pop     bx
2228         pop     bx
2229         pop     bx
2230         pop     bx
2231         ret
2232 rret6.s\0\0s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0w\0.sect .text
2233 .define .ret6
2234 .extern .retarea
2235
2236 .ret6:
2237         pop     bx
2238         pop     (.retarea)
2239         pop     (.retarea+2)
2240         pop     (.retarea+4)
2241         jmp     bx
2242
2243 ret8.s\0\0s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\89\0.sect .text
2244 .define .ret8
2245 .extern .retarea
2246
2247 .ret8:
2248         pop     bx
2249         pop     (.retarea)
2250         pop     (.retarea+2)
2251         pop     (.retarea+4)
2252         pop     (.retarea+6)
2253         jmp     bx
2254 blfr6.s\0\0s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0z\0.sect .text
2255 .define .lfr6
2256 .extern .retarea
2257
2258 .lfr6:
2259         pop     bx
2260         push    (.retarea+4)
2261         push    (.retarea+2)
2262         push    (.retarea)
2263         jmp     bx
2264 lfr8.s\0\0s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\8d\0.sect .text
2265 .define .lfr8
2266 .extern .retarea
2267
2268 .lfr8:
2269         pop     bx
2270         push    (.retarea+6)
2271         push    (.retarea+4)
2272         push    (.retarea+2)
2273         push    (.retarea)
2274         jmp     bx
2275 :retarea.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0W\0.sect .text; .sect .rom; .sect .data; .sect .bss
2276 .define .retarea
2277
2278 .retarea:
2279         .space 8
2280 eblm.s\0a.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\9b\0.sect .text
2281 .define .blm
2282
2283         ! cx: count in words
2284 .blm:
2285         mov     bx,sp
2286         mov     ax,si
2287         mov     dx,di
2288         mov     di,2(bx)
2289         mov     si,4(bx)
2290         rep     movs
2291         mov     si,ax
2292         mov     di,dx
2293         ret     4
2294
2295 )return.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0£\0.define .sdret, .dsret, .sret, .dret, .cret 
2296 .sect .text
2297
2298 .dsret:
2299         pop     di
2300 .sret:
2301         pop     si
2302 .cret:
2303         mov     sp,bp
2304         pop     bp
2305         ret
2306
2307 .sdret:
2308         pop     si
2309 .dret:
2310         pop     di
2311         jmp     .cret
2312 x