fix installation amd bcheck for Windows
[tinycc.git] / tests / asmtest.S
blobe235c802a007a851969482451876b0cda3e1f409
1 # gas comment with ``gnu'' style quotes
3 /* some directive tests */
5    .byte 0xff
6    .byte 1, 2, 3
7    .short 1, 2, 3
8    .word 1, 2, 3
9    .long 1, 2, 3
10    .int 1, 2, 3
11    .align 8
12    .byte 1
13 /* .align 16, 0x90 gas is too clever for us with 0x90 fill */
14    .align 16, 0x91 /* 0x91 tests the non-clever behaviour */
15    .skip 3
16    .skip 15, 0x90
17    .string "hello\0world"
19 /* some label tests */
21         movl %eax, %ebx
22 L1:
23         movl %eax, %ebx
24         mov 0x10000, %eax
25 L2:
26         movl $L2 - L1, %ecx
27 var1:
28         nop ; nop ; nop ; nop
30         mov var1, %eax
32 /* instruction tests */
33 movl %eax, %ebx
34 mov 0x10000, %eax
35 mov 0x10000, %ax
36 mov 0x10000, %al
37 mov %al, 0x10000
38                 
39 mov $1, %edx
40 mov $1, %dx
41 mov $1, %dl
42 movb $2, 0x100(%ebx,%edx,2)
43 movw $2, 0x100(%ebx,%edx,2)
44 movl $2, 0x100(%ebx,%edx,2)
45 movl %eax, 0x100(%ebx,%edx,2)
46 movl 0x100(%ebx,%edx,2), %edx
47 movw %ax, 0x100(%ebx,%edx,2)
49 mov %eax, 0x12(,%edx,2)
50         
51 mov %cr3, %edx
52 mov %ecx, %cr3
53 movl %cr3, %eax
54 movl %tr3, %eax
55 movl %db3, %ebx
56 movl %dr6, %eax
57 movl %fs, %ecx
58 movl %ebx, %fs
60      movsbl 0x1000, %eax
61      movsbw 0x1000, %ax
62      movswl 0x1000, %eax
64      movzbl 0x1000, %eax
65      movzbw 0x1000, %ax
66      movzwl 0x1000, %eax
67             
68      movzb 0x1000, %eax
69      movzb 0x1000, %ax
70                 
71         
72   pushl %eax
73   pushw %ax
74   push %eax
75   push %cs
76   push %gs
77   push $1
78   push $100
79                                                 
80   popl %eax
81   popw %ax
82   pop %eax
83   pop %ds
84   pop %fs
85           
86   xchg %eax, %ecx
87   xchg %edx, %eax
88   xchg %bx, 0x10000
89   xchg 0x10000, %ebx
90   xchg 0x10000, %dl
92   in $100, %al               
93   in $100, %ax               
94   in $100, %eax
95   in %dx, %al
96   in %dx, %ax               
97   in %dx, %eax
98   inb %dx
99   inw %dx               
100   inl %dx
102   out %al, $100                       
103   out %ax, $100                       
104   out %eax, $100                       
106   /* NOTE: gas is bugged here, so size must be added */
107   outb %al, %dx                       
108   outw %ax, %dx                       
109   outl %eax, %dx                       
111   leal 0x1000(%ebx), %ecx
112   lea 0x1000(%ebx), %ecx
114   les 0x2000, %eax
115   lds 0x2000, %ebx
116   lfs 0x2000, %ecx
117   lgs 0x2000, %edx
118   lss 0x2000, %edx
120 addl $0x123, %eax
121 add $0x123, %ebx
122 addl $0x123, 0x100
123 addl $0x123, 0x100(%ebx)
124 addl $0x123, 0x100(%ebx,%edx,2)
125 addl $0x123, 0x100(%esp)
126 addl $0x123, (3*8)(%esp)
127 addl $0x123, (%ebp)
128 addl $0x123, (%esp)
129 cmpl $0x123, (%esp)
131 add %eax, (%ebx)
132 add (%ebx), %eax
133                 
134 or %dx, (%ebx)
135 or (%ebx), %si
136         
137 add %cl, (%ebx)
138 add (%ebx), %dl
140     inc %edx
141     incl 0x10000
142     incb 0x10000
143     dec %dx
144   
145   test $1, %al
146   test $1, %cl
148   testl $1, 0x1000
149   testb $1, 0x1000
150   testw $1, 0x1000
151   test %eax, %ebx
152   test %eax, 0x1000
153   test 0x1000, %edx
155     not %edx
156     notw 0x10000
157     notl 0x10000
158     notb 0x10000
160     neg %edx
161     negw 0x10000
162     negl 0x10000
163     negb 0x10000
165     imul %ecx
166     mul %edx
167     mulb %cl
169     imul %eax, %ecx
170     imul 0x1000, %cx
171     imul $10, %eax, %ecx
172     imul $10, %ax, %cx
173     imul $10, %eax
174     imul $0x1100000, %eax
175     imul $1, %eax
176     
177     idivw 0x1000
178     div %ecx
179     div %bl
180     div %ecx, %eax
183 shl %edx
184 shl $10, %edx
185 shl %cl, %edx
187 shld $1, %eax, %edx
188 shld %cl, %eax, %edx
189 shld %eax, %edx
191 shrd $1, %eax, %edx
192 shrd %cl, %eax, %edx
193 shrd %eax, %edx
196 call 0x1000
197 call L4
198 call *%eax
199 call *0x1000
200 call func1
202 .global L5,L6
207 lcall $0x100, $0x1000
209 jmp 0x1000
210 jmp *%eax
211 jmp *0x1000
213 ljmp $0x100, $0x1000
216 retl
218 ret $10
219 retl $10
221 lret
223 lret $10
225 enter $1234, $10
228  jo 0x1000
229  jnp 0x1001
230  jne 0x1002
231  jg 0x1003
233  jo L3
234  jnp L3
235  jne L3
236  jg L3
238  loopne L3
239  loopnz L3
240  loope L3
241  loopz L3
242  loop L3
243  jecxz L3
245         
246  seto %al
247  setc %al
248  setcb %al
249  setnp 0x1000
250  setl 0xaaaa
251  setg %dl
253  fadd
254  fadd %st(1), %st
255  fadd %st(0), %st(1)
256  fadd %st(3)
258  fmul %st(0),%st(0)
259  fmul %st(0),%st(1)
261  faddp %st(5)
262  faddp
263  faddp %st(1), %st
265  fadds 0x1000
266  fiadds 0x1002
267  faddl 0x1004
268  fiaddl 0x1006
270  fmul
271  fmul %st(1), %st
272  fmul %st(3)
274  fmulp %st(5)
275  fmulp
276  fmulp %st(1), %st
278  fmuls 0x1000
279  fimuls 0x1002
280  fmull 0x1004
281  fimull 0x1006
283  fsub
284  fsub %st(1), %st
285  fsub %st(3)
287  fsubp %st(5)
288  fsubp
289  fsubp %st(1), %st
291  fsubs 0x1000
292  fisubs 0x1002
293  fsubl 0x1004
294  fisubl 0x1006
296  fsubr
297  fsubr %st(1), %st
298  fsubr %st(3)
300  fsubrp %st(5)
301  fsubrp
302  fsubrp %st(1), %st
304  fsubrs 0x1000
305  fisubrs 0x1002
306  fsubrl 0x1004
307  fisubrl 0x1006
309  fdiv
310  fdiv %st(1), %st
311  fdiv %st(3)
313  fdivp %st(5)
314  fdivp
315  fdivp %st(1), %st
317  fdivs 0x1000
318  fidivs 0x1002
319  fdivl 0x1004
320  fidivl 0x1006
322  fcom %st(3)
324  fcoms 0x1000
325  ficoms 0x1002
326  fcoml 0x1004
327  ficoml 0x1006
329  fcomp %st(5)
330  fcomp
331  fcompp
333  fcomps 0x1000
334  ficomps 0x1002
335  fcompl 0x1004
336  ficompl 0x1006
338  fld %st(5)
339  fldl 0x1000
340  flds 0x1002
341  fildl 0x1004
342  fst %st(4)
343  fstp %st(6)
344  fstpt 0x1006
345  fbstp 0x1008
347  fxch
348  fxch %st(4)
350  fucom %st(6)
351  fucomp %st(3)
352  fucompp
354  finit
355  fninit
356  fldcw 0x1000
357  fnstcw 0x1002
358  fstcw 0x1002
359  fnstsw 0x1004
360  fnstsw (%eax)
361  fstsw 0x1004
362  fstsw (%eax)
363  fnclex
364  fclex
365  fnstenv 0x1000
366  fstenv 0x1000
367  fldenv 0x1000
368  fnsave 0x1002
369  fsave 0x1000
370  frstor 0x1000
371  ffree %st(7)
372  ffreep %st(6)
374     ftst
375     fxam
376     fld1
377     fldl2t
378     fldl2e
379     fldpi
380     fldlg2
381     fldln2
382     fldz
384     f2xm1
385     fyl2x
386     fptan
387     fpatan
388     fxtract
389     fprem1
390     fdecstp
391     fincstp
392     fprem
393     fyl2xp1
394     fsqrt
395     fsincos
396     frndint
397     fscale
398     fsin
399     fcos
400     fchs
401     fabs
402     fnop
403     fwait
405 bswap %edx
406 xadd %ecx, %edx
407 xaddb %dl, 0x1000
408 xaddw %ax, 0x1000
409 xaddl %eax, 0x1000
410 cmpxchg %ecx, %edx
411 cmpxchgb %dl, 0x1000
412 cmpxchgw %ax, 0x1000
413 cmpxchgl %eax, 0x1000
414 invlpg 0x1000
415 cmpxchg8b 0x1002
417 fcmovb %st(5), %st
418 fcmove %st(5), %st
419 fcmovbe %st(5), %st
420 fcmovu %st(5), %st
421 fcmovnb %st(5), %st
422 fcmovne %st(5), %st
423 fcmovnbe %st(5), %st
424 fcmovnu %st(5), %st
425 fcomi %st(5), %st
426 fucomi %st(5), %st
427 fcomip %st(5), %st
428 fucomip %st(5), %st
432  cmovo 0x1000, %eax
433  cmovs 0x1000, %eax
434  cmovns %edx, %edi
436 int $3
437 int $0x10
439     pusha
440     popa
441     clc
442     cld
443     cli
444     clts
445     cmc
446     lahf
447     sahf
448     pushfl
449     popfl
450     pushf
451     popf
452     stc
453     std
454     sti
455     aaa
456     aas
457     daa
458     das
459     aad
460     aam
461     cbw
462     cwd
463     cwde
464     cdq
465     cbtw
466     cwtd
467     cwtl
468     cltd
469     leave
470     int3
471     into
472     iret
473     rsm
474     hlt
475     wait
476     nop
478     /* XXX: handle prefixes */
479 #if 0
480     aword
481     addr16
482 #endif
483     lock
484     rep
485     repe
486     repz
487     repne
488     repnz
489     nop
491     lock ;negl (%eax)
492     wait ;pushf
493     rep  ;stosb
494     repe ;lodsb
495     repz ;cmpsb
496     repne;movsb
497     repnz;outsb
499     /* handle one-line prefix + ops */
500     lock  negl (%eax)
501     wait  pushf
502     rep   stosb
503     repe  lodsb
504     repz  cmpsb
505     repne movsb
506     repnz outsb
507     
508     invd
509     wbinvd
510     cpuid
511     wrmsr
512     rdtsc
513     rdmsr
514     rdpmc
515     ud2
517     emms
518     movd %edx, %mm3
519     movd 0x1000, %mm2
520     movd %mm4, %ecx
521     movd %mm5, 0x1000
522                     
523     movq 0x1000, %mm2
524     movq %mm4, 0x1000
525     
526     pand 0x1000, %mm3
527     pand %mm4, %mm5
528     
529     psllw $1, %mm6
530     psllw 0x1000, %mm7
531     psllw %mm2, %mm7
533     xlat
534     cmpsb
535     scmpw
536     insl
537     outsw
538     lodsb
539     slodl
540     movsb
541     movsl
542     smovb
543     scasb
544     sscaw
545     stosw
546     sstol
548     bsf 0x1000, %ebx
549     bsr 0x1000, %ebx
550     bt %edx, 0x1000
551     btl $2, 0x1000
552     btc %edx, 0x1000
553     btcl $2, 0x1000
554     btr %edx, 0x1000
555     btrl $2, 0x1000
556     bts %edx, 0x1000
557     btsl $2, 0x1000
559         
560         
561     boundl %edx, 0x10000
562     boundw %bx, 0x1000
563     
564     arpl %bx, 0x1000
565     lar 0x1000, %eax
566     lgdt 0x1000
567     lidt 0x1000
568     lldt 0x1000
569     lmsw 0x1000
570     lsl 0x1000, %ecx
571     ltr 0x1000
572     
573     sgdt 0x1000
574     sidt 0x1000
575     sldt 0x1000
576     smsw 0x1000
577     str 0x1000
578     
579     verr 0x1000
580     verw 0x1000
581   
582     push %ds
583     pushw %ds
584     pushl %ds
585     pop %ds
586     popw %ds
587     popl %ds
588     fxsave 1(%ebx)
589     fxrstor 1(%ecx)
590     pushl $1
591     pushw $1
592     push $1
594 #ifdef __ASSEMBLER__ // should be defined, for S files
595     inc %eax
596 #endif
598 ft1: ft2: ft3: ft4: ft5: ft6: ft7: ft8: ft9:
599     xor %eax, %eax
600     ret
602 .type ft1,STT_FUNC
603 .type ft2,@STT_FUNC
604 .type ft3,%STT_FUNC
605 .type ft4,"STT_FUNC"
606 .type ft5,function
607 .type ft6,@function
608 .type ft7,%function
609 .type ft8,"function"
611     pause