Pristine Ack-5.5
[Ack-5.5.git] / mach / i386 / 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\03\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
2 .define .adi
3
4         ! #bytes in ecx , top of stack in eax
5         .sect .text
6 .adi:
7         pop     ebx              ! return address
8         cmp     ecx,4
9         jne     9f
10         pop     ecx
11         add     eax,ecx
12         jmp     ebx
13 9:
14 .extern EODDZ
15 .extern .trp
16         mov     eax,EODDZ
17         push    ebx
18         jmp     .trp
19 \0and.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\1e\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
20 .define .and
21
22         ! #bytes in ecx
23         ! save edi; it might be a register variable
24
25         .sect .text
26 .and:
27         pop     ebx             ! return address
28         mov     edx,edi
29         mov     edi,esp
30         add     edi,ecx
31         sar     ecx,2
32 1:
33         pop     eax
34         and     eax,(edi)
35         stos
36         loop    1b
37         mov     edi,edx
38         jmp     ebx
39 blm.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ª\0.sect .text
40 .define .blm
41
42         ! ecx: count in words
43 .blm:
44         mov     ebx,esp
45         mov     eax,esi
46         mov     edx,edi
47         mov     edi,4(ebx)
48         mov     esi,8(ebx)
49         rep     movs
50         mov     esi,eax
51         mov     edi,edx
52         ret     8
53
54 cii.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
55 .define .cii
56
57 .sect .text
58 .cii:
59         pop     ebx              ! return address
60                                 ! pop     ecx, dest. size
61                                 ! pop     edx, src. size
62                                 ! eax is source
63         cmp     edx,1
64         jne     2f
65         movsxb  eax,al
66         mov     edx,4
67         jmp     1f
68 2:
69         cmp     edx,2
70         jne     1f
71         cwde                    ! convert from 2 to 4 bytes
72         mov     edx,4
73 1:
74         cmp     edx,ecx
75         jne     9f
76         cmp     edx,4
77         jne     9f
78         jmp     ebx
79 9:
80 .extern EILLINS
81 .extern .fat
82         mov     eax,EILLINS
83         push    eax
84         jmp     .fat
85 \0cms.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
86 .define .cms
87
88         ! #bytes in ecx
89         .sect .text
90 .cms:
91         pop     ebx              ! return address
92         mov     edx,esp
93         push    esi
94         push    edi
95         mov     esi,edx
96         add     edx,ecx
97         mov     edi,edx
98         add     edx,ecx
99         sar     ecx,2
100         repe cmps
101         je      1f
102         inc     ecx
103 1:
104         pop     edi
105         pop     esi
106         mov     esp,edx
107         jmp     ebx
108  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
109 .define .com
110
111         ! #bytes in ecx
112         .sect .text
113 .com:
114         mov     ebx,esp
115         add     ebx,4
116         sar     ecx,2
117 1:
118         not     (ebx)
119         add     ebx,4
120         loop    1b
121         ret
122 hcsa4.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
123 .define .csa4
124
125 .sect .text
126 .csa4:
127                                 ! ebx, descriptor address
128                                 ! eax, index
129         mov     edx,(ebx)         ! default
130         sub     eax,4(ebx)
131         cmp     eax,8(ebx)
132         ja      1f
133         sal     eax,2
134         add     ebx,eax
135         mov     ebx,12(ebx)
136         test    ebx,ebx
137         jnz     2f
138 1:
139         mov     ebx,edx
140         test    ebx,ebx
141         jnz     2f
142 .extern ECASE
143 .extern .fat
144         mov     eax,ECASE
145         push    eax
146         jmp     .fat
147 2:
148         jmp     ebx
149 Icsb4.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\87\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
150 .define .csb4
151
152 .sect .text
153 .csb4:
154                                 !ebx, descriptor address
155                                 !eax,  index
156         mov     edx,(ebx)
157         mov     ecx,4(ebx)
158 1:
159         add     ebx,8
160         dec     ecx
161         jl      4f
162         cmp     eax,(ebx)
163         jne     1b
164         mov     ebx,4(ebx)
165 2:
166         test    ebx,ebx
167         jnz     3f
168 .extern ECASE
169 .extern .fat
170         mov     eax,ECASE
171         push    eax
172         jmp     .fat
173 3:
174         jmp     ebx
175 4:
176         mov     ebx,edx
177         jmp     2b
178
179 cuu.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0m\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
180 .define .ciu
181 .define .cui
182 .define .cuu
183
184 .sect .text
185 .ciu:
186 .cui:
187 .cuu:
188         pop     ebx              ! return address
189                                 ! pop     ecx, dest. size
190                                 ! pop     edx, source size
191                                 ! eax is source
192         cmp     edx,ecx
193         jne     8f
194         jmp     ebx
195 8:
196 .extern EILLINS
197 .extern .fat
198         mov     eax,EILLINS
199         push    eax
200         jmp     .fat
201 xdup.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
202 .define .dup
203
204         ! #bytes in ecx
205         .sect .text
206 .dup:
207         pop     ebx             ! return address
208         mov     eax,esi
209         mov     edx,edi
210         mov     esi,esp
211         sub     esp,ecx
212         mov     edi,esp
213         sar     ecx,2
214         rep movs
215         mov     esi,eax
216         mov     edi,edx
217         jmp     ebx
218  dvi.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\96\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
219 .define .dvi
220
221         ! #bytes in eax
222         .sect .text
223 .dvi:
224         pop     ebx              ! return address
225         cmp     eax,4
226         jne     1f
227         pop     eax
228         cwd
229         pop     ecx
230         idiv    ecx
231         push    eax
232         jmp     ebx
233 1:
234 .extern EODDZ
235 .extern .trp
236         mov     eax,EODDZ
237         push    ebx
238         jmp     .trp
239 dvu.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0G\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
240 .define .dvu
241
242         ! #bytes in eax
243         .sect .text
244 .dvu:
245         pop     ebx              ! return address
246         cmp     eax,4
247         jne     1f
248         pop     eax
249         xor     edx,edx
250         pop     ecx
251         div     ecx
252         push    eax
253         jmp     ebx
254 1:
255 .extern EODDZ
256 .extern .trp
257         mov     eax,EODDZ
258         push    ebx
259         jmp     .trp
260 eerror.s\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
261 .define .error
262 .define .Xtrp
263
264         ! eax is trap number
265         ! all registers must be saved
266         ! because return is possible
267         ! May only be called with error no's <16
268 .sect .text
269 .error:
270         mov  ecx,eax
271         mov  ebx,1
272         sal  ebx,cl
273 .extern .ignmask
274 .extern .trp
275         test ebx,(.ignmask)
276         jne  2f
277         call    .trp
278 2:
279         ret
280
281 .Xtrp:
282         pusha
283         cmp     eax,16
284         jge     1f
285         call    .error
286         popa
287         ret
288 1:
289         call    .trp
290         popa
291         ret
292  exg.s\0s\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
293 .define .exg
294
295         ! #bytes in ecx
296 .sect .text
297 .exg:
298         push    edi
299         mov     edi,esp
300         add     edi,8
301         mov     ebx,edi
302         add     ebx,ecx
303         sar     ecx,2
304 1:
305         mov     eax,(ebx)
306         xchg    eax,(edi)
307         mov     (ebx),eax
308         add     edi,4
309         add     ebx,4
310         loop    1b
311 2:
312         pop     edi
313         ret
314 fp8087.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ò\15.define .adf4, .adf8, .sbf4, .sbf8, .mlf4, .mlf8, .dvf4, .dvf8
315 .define .ngf4, .ngf8, .fif4, .fif8, .fef4, .fef8
316 .define .cif4, .cif8, .cuf4, .cuf8, .cfi, .cfu, .cff4, .cff8
317 .define .cmf4, .cmf8
318 .sect .text; .sect .rom; .sect .data; .sect .bss
319
320 !       $Id: fp8087.s,v 1.3 1994/06/24 13:01:43 ceriel Exp $
321
322 !       Implement interface to floating point package for Intel 8087
323
324         .sect .rom
325 one:
326         .data2  1
327 two:
328         .data2  2
329 bigmin:
330         .data4  -2147483648
331
332         .sect .text
333 .adf4:
334         mov     bx,sp
335         flds    4(bx)
336         fadds   8(bx)
337         fstps   8(bx)
338         wait
339         ret
340 .adf8:
341         mov     bx,sp
342         fldd    4(bx)
343         faddd   12(bx)
344         fstpd   12(bx)
345         wait
346         ret
347
348 .sbf4:
349         mov     bx,sp
350         flds    8(bx)
351         fsubs   4(bx)
352         fstps   8(bx)
353         wait
354         ret
355
356 .sbf8:
357         mov     bx,sp
358         fldd    12(bx)
359         fsubd   4(bx)
360         fstpd   12(bx)
361         wait
362         ret
363
364 .mlf4:
365         mov     bx,sp
366         flds    4(bx)
367         fmuls   8(bx)
368         fstps   8(bx)
369         wait
370         ret
371 .mlf8:
372         mov     bx,sp
373         fldd    4(bx)
374         fmuld   12(bx)
375         fstpd   12(bx)
376         wait
377         ret
378
379 .dvf4:
380         mov     bx,sp
381         flds    8(bx)
382         fdivs   4(bx)
383         fstps   8(bx)
384         wait
385         ret
386
387 .dvf8:
388         mov     bx,sp
389         fldd    12(bx)
390         fdivd   4(bx)
391         fstpd   12(bx)
392         wait
393         ret
394
395 .ngf4:
396         mov     bx,sp
397         flds    4(bx)
398         fchs
399         fstps   4(bx)
400         wait
401         ret
402
403 .ngf8:
404         mov     bx,sp
405         fldd    4(bx)
406         fchs
407         fstpd   4(bx)
408         wait
409         ret
410
411 .fif4:
412         mov     bx,sp
413         flds    8(bx)
414         fmuls   12(bx)          ! multiply
415         fld     st              ! copy result
416         ftst                    ! test sign; handle negative separately
417         fstsw   ax
418         wait
419         sahf                    ! result of test in condition codes
420         jb      1f
421         frndint                 ! this one rounds (?)
422         fcom    st(1)           ! compare with original; if <=, then OK
423         fstsw   ax
424         wait
425         sahf
426         jbe     2f
427         fisubs  (one)           ! else subtract 1
428         jmp     2f
429 1:                              ! here, negative case
430         frndint                 ! this one rounds (?)
431         fcom    st(1)           ! compare with original; if >=, then OK
432         fstsw   ax
433         wait
434         sahf
435         jae     2f
436         fiadds  (one)           ! else add 1
437 2:
438         fsub    st(1),st        ! subtract integer part
439         mov     bx,4(bx)
440         fstps   (bx)
441         fstps   4(bx)
442         wait
443         ret
444
445 .fif8:
446         mov     bx,sp
447         fldd    8(bx)
448         fmuld   16(bx)          ! multiply
449         fld     st              ! and copy result
450         ftst                    ! test sign; handle negative separately
451         fstsw   ax
452         wait
453         sahf                    ! result of test in condition codes
454         jb      1f
455         frndint                 ! this one rounds (?)
456         fcom    st(1)           ! compare with original; if <=, then OK
457         fstsw   ax
458         wait
459         sahf
460         jbe     2f
461         fisubs  (one)           ! else subtract 1
462         jmp     2f
463 1:                              ! here, negative case
464         frndint                 ! this one rounds (?)
465         fcom    st(1)           ! compare with original; if >=, then OK
466         fstsw   ax
467         wait
468         sahf
469         jae     2f
470         fiadds  (one)           ! else add 1
471 2:
472         fsub    st(1),st        ! subtract integer part
473         mov     bx,4(bx)
474         fstpd   (bx)
475         fstpd   8(bx)
476         wait
477         ret
478
479 .fef4:
480                                 ! this could be simpler, if only the
481                                 ! fxtract instruction was emulated properly
482         mov     bx,sp
483         mov     ax,8(bx)
484         and     ax,0x7f800000
485         je      1f              ! zero exponent
486         shr     ax,23
487         sub     ax,126
488         mov     cx,ax           ! exponent in cx
489         mov     ax,8(bx)
490         and     ax,0x807fffff
491         or      ax,0x3f000000   ! load -1 exponent
492         mov     bx,4(bx)
493         mov     4(bx),ax
494         mov     (bx),cx
495         ret
496 1:                              ! we get here on zero exp
497         mov     ax,8(bx)
498         and     ax,0x007fffff
499         jne     1f              ! zero result
500         mov     bx,4(bx)
501         mov     (bx),ax
502         mov     4(bx),ax
503         ret
504 1:                              ! otherwise unnormalized number
505         mov     cx,8(bx)
506         and     cx,0x807fffff
507         mov     dx,cx
508         and     cx,0x80000000
509         mov     ax,-125
510 2:
511         test    dx,0x800000
512         jne     1f
513         dec     ax
514         shl     dx,1
515         or      dx,cx
516         jmp     2b
517 1:
518         mov     bx,4(bx)
519         mov     (bx),ax
520         and     dx,0x807fffff
521         or      dx,0x3f000000   ! load -1 exponent
522         mov     4(bx),dx
523         ret
524
525 .fef8:
526                                 ! this could be simpler, if only the
527                                 ! fxtract instruction was emulated properly
528         mov     bx,sp
529         mov     ax,12(bx)
530         and     ax,0x7ff00000
531         je      1f              ! zero exponent
532         shr     ax,20
533         sub     ax,1022
534         mov     cx,ax           ! exponent in cx
535         mov     ax,12(bx)
536         and     ax,0x800fffff
537         or      ax,0x3fe00000   ! load -1 exponent
538         mov     dx,8(bx)
539         mov     bx,4(bx)
540         mov     4(bx),dx
541         mov     8(bx),ax
542         mov     (bx),cx
543         ret
544 1:                              ! we get here on zero exp
545         mov     ax,12(bx)
546         and     ax,0xfffff
547         or      ax,8(bx)
548         jne     1f              ! zero result
549         mov     bx,4(bx)
550         mov     (bx),ax
551         mov     4(bx),ax
552         mov     8(bx),ax
553         ret
554 1:                              ! otherwise unnormalized number
555         mov     cx,12(bx)
556         and     cx,0x800fffff
557         mov     dx,cx
558         and     cx,0x80000000
559         mov     ax,-1021
560 2:
561         test    dx,0x100000
562         jne     1f
563         dec     ax
564         shl     8(bx),1
565         rcl     dx,1
566         or      dx,cx
567         jmp     2b
568 1:
569         and     dx,0x800fffff
570         or      dx,0x3fe00000   ! load -1 exponent
571         mov     cx,8(bx)
572         mov     bx,4(bx)
573         mov     (bx),ax
574         mov     8(bx),dx
575         mov     4(bx),cx
576         ret
577
578 .cif4:
579         mov     bx,sp
580         fildl   8(bx)
581         fstps   8(bx)
582         wait
583         ret
584
585 .cif8:
586         mov     bx,sp
587         fildl   8(bx)
588         fstpd   4(bx)
589         wait
590         ret
591
592 .cuf4:
593         mov     bx,sp
594         fildl   8(bx)
595         cmp     8(bx),0
596         jge     1f
597         fisubl  (bigmin)
598         fisubl  (bigmin)
599 1:
600         fstps   8(bx)
601         wait
602         ret
603
604 .cuf8:
605         mov     bx,sp
606         fildl   8(bx)
607         cmp     8(bx),0
608         jge     1f
609         fisubl  (bigmin)
610         fisubl  (bigmin)
611 1:
612         fstpd   4(bx)
613         wait
614         ret
615
616 .cfi:
617         mov     bx,sp
618         fstcw   4(bx)
619         wait
620         mov     dx,4(bx)
621         or      4(bx),0xc00     ! truncating mode
622         wait
623         fldcw   4(bx)
624         cmp     8(bx),4
625         jne     2f
626                                 ! loc 4 loc ? cfi
627         flds    12(bx)
628         fistpl  12(bx)
629 1:
630         mov     4(bx),dx
631         wait
632         fldcw   4(bx)
633         ret
634 2:
635                                 ! loc 8 loc ? cfi
636         fldd    12(bx)
637         fistpl  16(bx)
638         jmp     1b
639
640 .cfu:
641         mov     bx,sp
642         fstcw   4(bx)
643         wait
644         mov     dx,4(bx)
645         and     4(bx),0xf3ff
646         or      4(bx),0x400     ! to -infinity
647         wait
648         fldcw   4(bx)
649         cmp     8(bx),4
650         jne     2f
651                                 ! loc 4 loc ? cfu
652         flds    12(bx)
653         fabs                    ! ???
654         fiaddl  (bigmin)
655         fistpl  12(bx)
656         wait
657         mov     ax,12(bx)
658         sub     ax,(bigmin)
659         mov     12(bx),ax
660 1:
661         mov     4(bx),dx
662         wait
663         fldcw   4(bx)
664         ret
665 2:
666                                 ! loc 8 loc ? cfu
667         fldd    12(bx)
668         fabs                    ! ???
669         fiaddl  (bigmin)
670         fistpl  16(bx)
671         wait
672         mov     ax,16(bx)
673         sub     ax,(bigmin)
674         mov     16(bx),ax
675         jmp     1b
676
677 .cff4:
678         mov     bx,sp
679         fldd    4(bx)
680         fstcw   4(bx)
681         wait
682         mov     dx,4(bx)
683         and     4(bx),0xf3ff    ! set to rounding mode
684         wait
685         fldcw   4(bx)
686         fstps   8(bx)
687         mov     4(bx),dx
688         wait
689         fldcw   4(bx)
690         wait
691         ret
692
693 .cff8:
694         mov     bx,sp
695         flds    4(bx)
696         fstpd   4(bx)
697         wait
698         ret
699
700 .cmf4:
701         mov     bx,sp
702         xor     cx,cx
703         flds    8(bx)
704         flds    4(bx)
705         fcompp                  ! compare and pop operands
706         fstsw   ax
707         wait
708         sahf
709         je      1f
710         jb      2f
711         dec     cx
712         jmp     1f
713 2:
714         inc     cx
715 1:
716         mov     ax,cx
717         ret
718
719
720 .cmf8:
721         mov     bx,sp
722         xor     cx,cx
723         fldd    12(bx)
724         fldd    4(bx)
725         fcompp                  ! compare and pop operands
726         fstsw   ax
727         wait
728         sahf
729         je      1f
730         jb      2f
731         dec     cx
732         jmp     1f
733 2:
734         inc     cx
735 1:
736         mov     ax,cx
737         ret
738 fat.s\0.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\94\0.sect .text; .sect .rom; .sect .data; .sect .bss
739 .sect .text
740 .define .fat
741
742 .fat:
743 .extern .trp
744 .extern EXIT
745         call    .trp
746         jmp     EXIT
747         ! no return
748 gto.s\0.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\88\0.sect .text; .sect .rom; .sect .data; .sect .bss
749 .sect .text
750 .define .gto
751
752 .gto:
753         mov     ebp,8(ebx)
754         mov     esp,4(ebx)
755         jmp     (ebx)
756 iaar.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\07\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
757 .sect .text
758 .define .iaar
759
760 .iaar:
761         pop     ecx
762         pop     edx
763         cmp     edx,4
764 .extern .unknown
765         jne     .unknown
766         pop     ebx     ! descriptor address
767         pop     eax     ! index
768         sub     eax,(ebx)
769         mul     8(ebx)
770         pop     ebx     ! array base
771         add     ebx,eax
772         push    ecx
773         ret
774  ilar.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
775 .sect .text
776 .define .ilar
777
778 .ilar:
779         pop     ecx
780         pop     edx
781 .extern .unknown
782         cmp     edx,4
783         jne     .unknown
784         pop     ebx      ! descriptor address
785         pop     eax      ! index
786         push    ecx
787 .extern .lar4
788         jmp    .lar4
789         inn.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
790 .sect .text
791 .define .inn
792
793         ! #bytes in ecx
794         ! bit # in eax
795 .inn:
796         xor     edx,edx
797         mov     ebx,8
798         div     ebx
799         mov     ebx,esp
800         add     ebx,4
801         add     ebx,eax
802         cmp     eax,ecx
803         jae     1f
804         movb    al,(ebx)
805         mov     ebx,edx
806         testb   al,bits(ebx)
807         jz      1f
808         mov     eax,1
809         jmp     2f
810 1:
811         xor     eax,eax
812 2:
813         pop     ebx
814         add     esp,ecx
815         ! eax is result
816         jmp     ebx
817
818         .sect .rom
819 bits:
820         .data1 1,2,4,8,16,32,64,128
821 .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
822 .sect .text
823 .define .ior
824
825         ! #bytes in ecx
826 .ior:
827         pop     ebx             ! return address
828         mov     edx,edi
829         mov     edi,esp
830         add     edi,ecx
831         sar     ecx,2
832 1:
833         pop     eax
834         or      eax,(edi)
835         stos
836         loop    1b
837         mov     edi,edx
838         jmp     ebx
839 isar.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
840 .sect .text
841 .define .isar
842
843 .isar:
844         pop     ecx
845         pop     eax
846         cmp     eax,4
847 .extern .unknown
848         jne     .unknown
849         pop     ebx      ! descriptor address
850         pop     eax      ! index
851         push    ecx
852 .extern .sar4
853         jmp    .sar4
854 tlar4.s\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
855 .sect .text
856 .define .lar4
857
858 .lar4:
859                                 ! ebx, descriptor address
860                                 ! eax, index
861         sub     eax,(ebx)
862         mov     ecx,8(ebx)
863         imul    ecx
864         pop     ebx
865         pop     edx             ! base address
866         add     edx,eax
867         sar     ecx,1
868         jnb     1f
869         xor     eax,eax
870         movb    al,(edx)
871         push    eax
872         jmp     ebx
873 1:
874         sar     ecx,1
875         jnb     1f
876         xor     eax,eax
877         o16 mov ax,(edx)
878         push    eax
879         jmp     ebx
880 1:
881         xchg    edx,esi         ! saved esi
882         mov     eax,ecx
883         sal     eax,2
884         sub     esp,eax
885         mov     eax,edi         ! save edi
886         mov     edi,esp
887         rep movs
888         mov     edi,eax
889         mov     esi,edx
890         jmp     ebx
891 xloi.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0X\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
892 .sect .text
893 .define .loi
894 .define .los
895
896         ! #bytes in ecx
897         ! address in ebx
898         ! save esi/edi. they might be register variables
899 .los:
900         pop     edx
901         mov     eax,ecx
902         sar     ecx,1
903         jnb     1f
904         movsxb  eax,(ebx)
905         push    eax
906         jmp     edx
907 1:
908         sar     ecx,1
909         jnb     1f
910         movsx   eax,(ebx)
911         push    eax
912         jmp     edx
913 1:
914         push    edx
915         mov     edx,esi
916         mov     esi,ebx
917         pop     ebx
918         sub     esp,eax
919         jmp     1f
920
921 .loi:
922         ! only called with size >= 4
923         mov     edx,esi
924         mov     esi,ebx
925         pop     ebx
926         sub     esp,ecx
927         sar     ecx,2
928 1:
929         mov     eax,edi
930         mov     edi,esp
931         rep movs
932         mov     esi,edx
933         mov     edi,eax
934         jmp     ebx
935 mli.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\05\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
936 .sect .text
937 .define .mli
938
939         ! #bytes in eax
940 .mli:
941         pop     ebx              ! return address
942         cmp     eax,4
943         jne     1f
944         pop     eax
945         pop     ecx
946         mul     ecx
947         push    eax
948         jmp     ebx
949 1:
950 .extern EODDZ
951 .extern .trp
952         mov     eax,EODDZ
953         push    ebx
954         jmp     .trp
955 vmon.s\0\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0k\0.sect .text; .sect .rom; .sect .data; .sect .bss
956 .sect .text
957 .define .mon
958
959 .mon:
960 .extern EXIT
961         jmp    EXIT
962 engi.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
963 .sect .text
964 .define .ngi
965
966         ! #bytes in eax
967 .ngi:
968         pop     ebx              ! return address
969         cmp     eax,4
970         jne     1f
971         pop     ecx
972         neg     ecx
973         push    ecx
974         jmp     ebx
975 1:
976 .extern EODDZ
977 .extern .trp
978         mov     eax,EODDZ
979         push    ebx
980         jmp     .trp
981 nop.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
982 .sect .text
983 .define .nop
984 .extern printd, printc, hol0
985
986 .nop:
987         mov     eax,(hol0)
988         call    printd
989         movb    al,'\n'
990         jmp     printc
991 xprint.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\14\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
992 .sect .text
993 .define printc,printd,prints
994
995         ! argument in eax
996         ! uses ebx
997 prints:
998         xchg    eax,ebx
999 1:
1000         movb    al,(ebx)
1001         inc     ebx
1002         testb   al,al
1003         jz      2f
1004         call    printc
1005         jmp     1b
1006 2:
1007         ret
1008
1009         ! argument in eax
1010         ! uses ecx and edx
1011 printd:
1012         xor     edx,edx
1013         mov     ecx,10
1014         div     ecx
1015         test    eax,eax
1016         jz      1f
1017         push    edx
1018         call    printd
1019         pop     edx
1020 1:
1021         xchg    eax,edx
1022         addb    al,'0'
1023
1024         ! argument in eax
1025 printc:
1026         push    eax
1027         mov     ebx,esp
1028         mov     eax,1
1029         push    eax
1030         push    ebx
1031         push    eax
1032         call    __write
1033         pop     ebx
1034         pop     ebx
1035         pop     ebx
1036         pop     ebx
1037         ret
1038 rck.s\0s\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
1039 .sect .text
1040 .define .rck
1041
1042         ! descriptor address in ebx
1043         ! value in eax, must be left there
1044 .rck:
1045         cmp     eax,(ebx)
1046         jl      2f
1047         cmp     eax,4(ebx)
1048         jg      2f
1049         ret
1050 2:
1051         push    eax
1052 .extern ERANGE
1053 .extern .error
1054         mov     eax,ERANGE
1055         call    .error
1056         pop     eax
1057         ret
1058 rmi.s\0s\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
1059 .sect .text
1060 .define .rmi
1061
1062         ! #bytes in eax
1063 .rmi:
1064         pop     ebx              ! return address
1065         cmp     eax,4
1066         jne     1f
1067         pop     eax
1068         cwd
1069         pop     ecx
1070         idiv    ecx
1071         push    edx
1072         jmp     ebx
1073 1:
1074 .extern EODDZ
1075 .extern .trp
1076         mov     eax,EODDZ
1077         push    ebx
1078         jmp     .trp
1079 rmu.s\0s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0F\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1080 .sect .text
1081 .define .rmu
1082
1083         ! #bytes in eax
1084 .rmu:
1085         pop     ebx              ! return address
1086         cmp     eax,4
1087         jne     1f
1088         pop     eax
1089         xor     edx,edx
1090         pop     ecx
1091         idiv    ecx
1092         push    edx
1093         jmp     ebx
1094 1:
1095 .extern EODDZ
1096 .extern .trp
1097         mov     eax,EODDZ
1098         push    ebx
1099         jmp     .trp
1100 rol.s\0s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\08\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1101 .sect .text
1102 .define .rol
1103
1104         ! #bytes in eax
1105 .rol:
1106         pop     edx              ! return address
1107         cmp     eax,4
1108         jne     1f
1109         pop     eax
1110         pop     ecx
1111         rol     eax,cl
1112         push    eax
1113         jmp     edx
1114 1:
1115 .extern EODDZ
1116 .extern .trp
1117         mov     eax,EODDZ
1118         push    edx
1119         jmp     .trp
1120 ror.s\0s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\08\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1121 .sect .text
1122 .define .ror
1123
1124         ! #bytes in eax
1125 .ror:
1126         pop     edx              ! return address
1127         cmp     eax,4
1128         jne     1f
1129         pop     eax
1130         pop     ecx
1131         ror     eax,cl
1132         push    eax
1133         jmp     edx
1134 1:
1135 .extern EODDZ
1136 .extern .trp
1137         mov     eax,EODDZ
1138         push    edx
1139         jmp     .trp
1140 sar4.s\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
1141 .sect .text
1142 .define .sar4
1143
1144 .sar4:
1145                                 ! ebx, descriptor address
1146                                 ! eax, index
1147         sub     eax,(ebx)
1148         mov     ecx,8(ebx)
1149         imul    ecx
1150         pop     ebx
1151         pop     edx             ! base address
1152         add     edx,eax
1153         sar     ecx,1
1154         jnb     1f
1155         pop     eax
1156         movb    (edx),al
1157         jmp     ebx
1158 1:
1159         sar     ecx,1
1160         jnb     1f
1161         pop     eax
1162         o16 mov (edx),ax
1163         jmp     ebx
1164 1:
1165         xchg    edi,edx         ! edi = base address, edx is saved edi
1166         mov     eax,esi
1167         mov     esi,esp
1168         rep movs
1169         mov     esp,esi
1170         mov     esi,eax
1171         mov     edi,edx
1172         jmp     ebx
1173 sbi.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0B\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1174 .sect .text
1175 .define .sbi
1176
1177         ! #bytes in ecx , top of stack in eax
1178 .sbi:
1179         pop     ebx              ! return subress
1180         cmp     ecx,4
1181         jne     1f
1182         pop     ecx
1183         sub     eax,ecx
1184         neg     eax
1185         jmp     ebx
1186 1:
1187 .extern EODDZ
1188 .extern .trp
1189         mov     eax,EODDZ
1190         push    ebx
1191         jmp     .trp
1192 set.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0U\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
1193 .sect .text
1194 .define .set
1195
1196         ! #bytes in ecx
1197         ! bit # in eax
1198 .set:
1199         pop     ebx              ! return address
1200         xor     edx,edx
1201 !ifdef create set
1202         sub     esp,ecx
1203         push    ebx
1204         push    edi
1205         mov     ebx,esp
1206         xor     edi,edi
1207         sar     ecx,2
1208 1:
1209         mov     8(ebx)(edi),edx
1210         add     edi,4
1211         loop    1b
1212 !endif
1213         mov     ebx,8
1214         div     ebx
1215         cmp     eax,edi
1216         jae     2f
1217         mov     edi,edx
1218         movb    dl,bits(edi)
1219         mov     edi,esp
1220         add     edi,eax
1221         orb     8(edi),dl
1222         pop     edi
1223         ret
1224 2:
1225 .extern ESET
1226 .extern .trp
1227         pop     edi
1228         mov     eax,ESET
1229         jmp     .trp
1230
1231         .sect .rom
1232 bits:
1233         .data1   1,2,4,8,16,32,64,128
1234 bsli.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\08\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1235 .sect .text
1236 .define .sli
1237
1238         ! #bytes in eax
1239 .sli:
1240         pop     edx              ! return address
1241         cmp     eax,4
1242         jne     1f
1243         pop     eax
1244         pop     ecx
1245         sal     eax,cl
1246         push    eax
1247         jmp     edx
1248 1:
1249 .extern EODDZ
1250 .extern .trp
1251         mov     eax,EODDZ
1252         push    edx
1253         jmp     .trp
1254 sri.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\08\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1255 .sect .text
1256 .define .sri
1257
1258         ! #bytes in eax
1259 .sri:
1260         pop     edx              ! return address
1261         cmp     eax,4
1262         jne     1f
1263         pop     eax
1264         pop     ecx
1265         sar     eax,cl
1266         push    eax
1267         jmp     edx
1268 1:
1269 .extern EODDZ
1270 .extern .trp
1271         mov     eax,EODDZ
1272         push    edx
1273         jmp     .trp
1274 sti.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\08\ 2.sect .text; .sect .rom; .sect .data; .sect .bss
1275 .sect .text
1276 .define .sti
1277 .define .sts
1278
1279         ! #bytes in ecx
1280         ! address in ebx
1281         ! save edi/esi. they might be register variables
1282 .sts:
1283         pop     edx
1284         sar     ecx,1
1285         jnb     1f
1286         pop     eax
1287         movb    (ebx),al
1288         jmp     edx
1289 1:
1290         sar     ecx,1
1291         jnb     1f
1292         pop     eax
1293         o16 mov (ebx),ax
1294         jmp     edx
1295 1:
1296         push    edx
1297         mov     edx,edi
1298         mov     edi,ebx
1299         pop     ebx
1300         jmp     1f
1301 .sti:
1302         ! only called with count >> 4
1303         mov     edx,edi
1304         mov     edi,ebx
1305         pop     ebx
1306         sar     ecx,2
1307 1:
1308         mov     eax,esi
1309         mov     esi,esp
1310         rep movs
1311         mov     esp,esi
1312         mov     edi,edx
1313         mov     esi,eax
1314         jmp     ebx
1315 strhp.s\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
1316 .sect .text
1317 .define .strhp
1318 .extern .reghp, .limhp, EHEAP, .trp
1319
1320 .strhp:
1321         pop     ebx
1322         pop     eax
1323         mov     (.reghp),eax
1324         cmp     eax,(.limhp)
1325         jb      1f
1326         add     eax,02000
1327         and     eax,~0777
1328         push    ebx
1329         push    eax
1330         call    BRK
1331         pop     ecx
1332         pop     ebx
1333         cmp     eax,-1
1334         je      2f
1335 1:
1336         mov     (.limhp),ecx
1337         jmp     ebx
1338 2:
1339         mov     eax,EHEAP
1340         push    ebx
1341         jmp     .trp
1342         trp.s\0s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\ 4\ 1.sect .text; .sect .rom; .sect .data; .sect .bss
1343 .sect .text
1344 .define .trp
1345 .extern .trppc, EXIT
1346
1347                 ! eax is trap number
1348 .trp:
1349         xor     ebx,ebx
1350         xchg    ebx,(.trppc)
1351         test    ebx,ebx
1352         jz      2f
1353         push    eax
1354         call    ebx
1355         pop     eax
1356         ret
1357 2:
1358         push    eax
1359         jmp     EXIT
1360 unknown.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
1361 .sect .text
1362 .define .unknown
1363 .extern EILLINS, .fat
1364
1365 .unknown:
1366         mov  eax,EILLINS
1367         push eax
1368         jmp  .fat
1369 xor.s\0n.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ï\0.sect .text; .sect .rom; .sect .data; .sect .bss
1370 .sect .text
1371 .define .xor
1372
1373         ! #bytes in ecx
1374 .xor:
1375         pop     ebx             ! return address
1376         mov     edx,edi
1377         mov     edi,esp
1378         add     edi,ecx
1379         sar     ecx,2
1380 1:
1381         pop     eax
1382         xor     eax,(edi)
1383         stos
1384         loop    1b
1385         mov     edi,edx
1386         jmp     ebx
1387