Remove vestiges of earlier type merger
[tinycc.git] / tests / asmtest.S
blobfd0629ccc95bc3d06fdedfd05a72027cad5ab83b
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, %cl
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 movw $0x1122,%si
50 movl $0x112233,%edx
51 #ifdef __x86_64__
52 mov $0x11223344,%rbx
53 movq $0x11223344,%rbx
54 mov $0x1122334455,%rbx
55 movq $0x1122334455,%rbx
56 movl $0x11334455,(%rbx)
57 #endif
59 mov %eax, 0x12(,%edx,2)
60         
61 #ifdef __i386__
62 mov %cr3, %edx
63 mov %ecx, %cr3
64 movl %cr3, %eax
65 movl %tr3, %eax
66 movl %db3, %ebx
67 movl %dr6, %eax
68 #else
69 mov %cr3, %rdx
70 mov %rcx, %cr3
71 movq %cr3, %rax
72 movq %db3, %rbx
73 movq %dr6, %rax
74 #endif
75 movl %fs, %ecx
76 movl %ebx, %fs
78      movsbl 0x1000, %eax
79      movsbw 0x1000, %ax
80      movswl 0x1000, %eax
82      movzbl 0x1000, %eax
83      movzbw 0x1000, %ax
84      movzwl 0x1000, %eax
85             
86      movzb 0x1000, %eax
87      movzb 0x1000, %ax
88                 
89 #ifdef __x86_64__
90      movzb 0x1000, %rax
91      movzbq 0x1000, %rbx
92      movsbq 0x1000, %rdx
93      movzwq 0x1000, %rdi
94      movswq 0x1000, %rdx
95 #endif
96         
97 #ifdef __i386__
98   pushl %eax
99   push %eax
100   push %cs
101 #else
102   pushq %rax
103   push %rax
104 #endif
105   pushw %ax
106   push %gs
107   push $1
108   push $100
109                                                 
110 #ifdef __i386__
111   popl %eax
112   pop %eax
113   pop %ds
114 #else
115   popq %rax
116   pop %rax
117 #endif
118   popw %ax
119   pop %fs
120           
121   xchg %eax, %ecx
122   xchg %edx, %eax
123   xchg %bx, 0x10000
124   xchg 0x10000, %ebx
125   xchg 0x10000, %dl
127   in $100, %al               
128   in $100, %ax               
129   in $100, %eax
130   in %dx, %al
131   in %dx, %ax               
132   in %dx, %eax
133   inb %dx
134   inw %dx               
135   inl %dx
137   out %al, $100                       
138   out %ax, $100                       
139   out %eax, $100                       
141   /* NOTE: gas is bugged here, so size must be added */
142   outb %al, %dx                       
143   outw %ax, %dx                       
144   outl %eax, %dx                       
146   leal 0x1000(%ebx), %ecx
147   lea 0x1000(%ebx), %ecx
149 #ifdef __i386__
150   les 0x2000, %eax
151   lds 0x2000, %ebx
152   lss 0x2000, %edx
153 #endif
154   lfs 0x2000, %ecx
155   lgs 0x2000, %edx
157 addl $0x123, %eax
158 add $0x123, %ebx
159 add $-16, %ecx
160 add $-0x123, %esi
161 add $1, %bx
162 add $1, %ebx
163 add $-1, %bx
164 add $-1, %ebx
165 add $127, %bx
166 addl $127, %ebx
167 addl $-128, %ebx
168 addl $-128, %ebx
169 addl $-129, %ebx
170 addl $128, %ebx
171 addl $255, %ebx
172 addl $256, %ebx
173 andb $0xf, %ah
174 andb $-15, %cl
175 xorb $127, %dh
176 cmpb $42, (%eax)
177 addl $0x123, 0x100
178 addl $0x123, 0x100(%ebx)
179 addl $0x123, 0x100(%ebx,%edx,2)
180 addl $0x123, 0x100(%esp)
181 addl $0x123, (3*8)(%esp)
182 addl $0x123, (%ebp)
183 addl $0x123, (%esp)
184 cmpl $0x123, (%esp)
186 add %eax, (%ebx)
187 add (%ebx), %eax
188                 
189 or %dx, (%ebx)
190 or (%ebx), %si
191         
192 add %cl, (%ebx)
193 add (%ebx), %dl
195     inc %edx
196     incl 0x10000
197     incb 0x10000
198     dec %dx
199   
200   test $1, %al
201   test $1, %cl
203   testl $1, 0x1000
204   testb $1, 0x1000
205   testw $1, 0x1000
206   test %eax, %ebx
207   test %eax, 0x1000
208   test 0x1000, %edx
210     not %edx
211     notw 0x10000
212     notl 0x10000
213     notb 0x10000
215     neg %edx
216     negw 0x10000
217     negl 0x10000
218     negb 0x10000
220     imul %ecx
221     mul %edx
222     mulb %cl
224     imul %eax, %ecx
225     imul 0x1000, %cx
226     imul $10, %eax, %ecx
227     imul $10, %ax, %cx
228     imul $10, %eax
229     imul $0x1100000, %eax
230     imul $1, %eax
231     
232     idivw 0x1000
233     div %ecx
234     div %bl
235     div %ecx, %eax
237 and $15,%bx
238 and $-20,%edx
240 shl %edx
241 shl $10, %edx
242 shl %cl, %edx
244 shld $1, %eax, %edx
245 shld %cl, %eax, %edx
246 shld %eax, %edx
248 shrd $1, %eax, %edx
249 shrd %cl, %eax, %edx
250 shrd %eax, %edx
253 call 0x1000
254 call L4
255 #ifdef __i386__
256 call *%eax
257 #else
258 call *%rax
259 #endif
260 call *0x1000
261 call func1
263 .global L5,L6
268 #ifdef __i386__
269 lcall $0x100, $0x1000
270 #else
271 lcall *0x100
272 lcall *(%rax)
273 #endif
275 jmp 0x1000
276 jmp *(%edi)
277 #ifdef __i386__
278 jmp *%eax
279 #else
280 jmp *%rax
281 #endif
282 jmp *0x1000
284 #ifdef __i386__
285 ljmp $0x100, $0x1000
286 #else
287 ljmp *0x100
288 ljmp *(%rdi)
289 #endif
292 ret $10
293 #ifdef __i386__
294 retl
295 retl $10
296 #else
297 retq
298 retq $10
299 #endif
301 lret
303 lret $10
305 enter $1234, $10
308  jo 0x1000
309  jnp 0x1001
310  jne 0x1002
311  jg 0x1003
313  jo L3
314  jnp L3
315  jne L3
316  jg L3
318  loopne L3
319  loopnz L3
320  loope L3
321  loopz L3
322  loop L3
323  jecxz L3
325         
326  seto %al
327  setc %al
328  setcb %al
329  setnp 0x1000
330  setl 0xaaaa
331  setg %dl
333  fadd
334  fadd %st(1), %st
335  fadd %st(0), %st(1)
336  fadd %st(3)
338  fmul %st(0),%st(0)
339  fmul %st(0),%st(1)
341  faddp %st(5)
342  faddp
343  faddp %st(1), %st
345  fadds 0x1000
346  fiadds 0x1002
347  faddl 0x1004
348  fiaddl 0x1006
350  fmul
351  fmul %st(1), %st
352  fmul %st(3)
354  fmulp %st(5)
355  fmulp
356  fmulp %st(1), %st
358  fmuls 0x1000
359  fimuls 0x1002
360  fmull 0x1004
361  fimull 0x1006
363  fsub
364  fsub %st(1), %st
365  fsub %st(3)
367  fsubp %st(5)
368  fsubp
369  fsubp %st(1), %st
371  fsubs 0x1000
372  fisubs 0x1002
373  fsubl 0x1004
374  fisubl 0x1006
376  fsubr
377  fsubr %st(1), %st
378  fsubr %st(3)
380  fsubrp %st(5)
381  fsubrp
382  fsubrp %st(1), %st
384  fsubrs 0x1000
385  fisubrs 0x1002
386  fsubrl 0x1004
387  fisubrl 0x1006
389  fdiv
390  fdiv %st(1), %st
391  fdiv %st(3)
393  fdivp %st(5)
394  fdivp
395  fdivp %st(1), %st
397  fdivs 0x1000
398  fidivs 0x1002
399  fdivl 0x1004
400  fidivl 0x1006
402  fcom %st(3)
404  fcoms 0x1000
405  ficoms 0x1002
406  fcoml 0x1004
407  ficoml 0x1006
409  fcomp %st(5)
410  fcomp
411  fcompp
413  fcomps 0x1000
414  ficomps 0x1002
415  fcompl 0x1004
416  ficompl 0x1006
418  fld %st(5)
419  fldl 0x1000
420  flds 0x1002
421  fildl 0x1004
422  fst %st(4)
423  fstp %st(6)
424  fstpt 0x1006
425  fbstp 0x1008
427  fxch
428  fxch %st(4)
430  fucom %st(6)
431  fucomp %st(3)
432  fucompp
434  finit
435  fninit
436  fldcw 0x1000
437  fnstcw 0x1002
438  fstcw 0x1002
439  fnstsw 0x1004
440  fnstsw (%eax)
441  fstsw 0x1004
442  fstsw (%eax)
443  fnclex
444  fclex
445  fnstenv 0x1000
446  fstenv 0x1000
447  fldenv 0x1000
448  fnsave 0x1002
449  fsave 0x1000
450  frstor 0x1000
451  ffree %st(7)
452  ffreep %st(6)
454     ftst
455     fxam
456     fld1
457     fldl2t
458     fldl2e
459     fldpi
460     fldlg2
461     fldln2
462     fldz
464     f2xm1
465     fyl2x
466     fptan
467     fpatan
468     fxtract
469     fprem1
470     fdecstp
471     fincstp
472     fprem
473     fyl2xp1
474     fsqrt
475     fsincos
476     frndint
477     fscale
478     fsin
479     fcos
480     fchs
481     fabs
482     fnop
483     fwait
485 bswap %edx
486 xadd %ecx, %edx
487 xaddb %dl, 0x1000
488 xaddw %ax, 0x1000
489 xaddl %eax, 0x1000
490 cmpxchg %ecx, %edx
491 cmpxchgb %dl, 0x1000
492 cmpxchgw %ax, 0x1000
493 cmpxchgl %eax, 0x1000
494 invlpg 0x1000
495 cmpxchg8b 0x1002
497 fcmovb %st(5), %st
498 fcmove %st(5), %st
499 fcmovbe %st(5), %st
500 fcmovu %st(5), %st
501 fcmovnb %st(5), %st
502 fcmovne %st(5), %st
503 fcmovnbe %st(5), %st
504 fcmovnu %st(5), %st
505 fcomi %st(5), %st
506 fucomi %st(5), %st
507 fcomip %st(5), %st
508 fucomip %st(5), %st
512  cmovo 0x1000, %eax
513  cmovs 0x1000, %eax
514  cmovns %edx, %edi
515  cmovne %ax, %si
516 #ifdef __x86_64__
517  cmovz %rdi,%rbx
518 #endif
520 int $3
521 int $0x10
523 #ifdef __i386__
524     pusha
525     popa
526 #endif
527     clc
528     cld
529     cli
530     clts
531     cmc
532     lahf
533     sahf
534 #ifdef __i386__
535     pushfl
536     popfl
537 #else
538     pushfq
539     popfq
540 #endif
541     pushf
542     popf
543     stc
544     std
545     sti
546 #ifdef __i386__
547     aaa
548     aas
549     daa
550     das
551     aad
552     aam
553     into
554 #endif
555     cbw
556     cwd
557     cwde
558     cdq
559     cbtw
560     cwtd
561     cwtl
562     cltd
563     leave
564     int3
565     iret
566     rsm
567     hlt
568     wait
569     nop
571     /* XXX: handle prefixes */
572 #if 0
573     aword
574     addr16
575 #endif
576     lock
577     rep
578     repe
579     repz
580     repne
581     repnz
582     nop
584     lock ;negl (%eax)
585     wait ;pushf
586     rep  ;stosb
587     repe ;lodsb
588     repz ;cmpsb
589     repne;movsb
590     repnz;outsb
592     /* handle one-line prefix + ops */
593     lock  negl (%eax)
594     wait  pushf
595     rep   stosb
596     repe  lodsb
597     repz  cmpsb
598     repne movsb
599     repnz outsb
600     
601     invd
602     wbinvd
603     cpuid
604     wrmsr
605     rdtsc
606     rdmsr
607     rdpmc
608     ud2
610     emms
611     movd %edx, %mm3
612     movd 0x1000, %mm2
613     movd %mm4, %ecx
614     movd %mm5, 0x1000
615                     
616     movq 0x1000, %mm2
617     movq %mm4, 0x1000
618     
619     pand 0x1000, %mm3
620     pand %mm4, %mm5
621     
622     psllw $1, %mm6
623     psllw 0x1000, %mm7
624     psllw %mm2, %mm7
626     xlat
627     cmpsb
628     scmpw
629     insl
630     outsw
631     lodsb
632     slodl
633     movsb
634     movsl
635     smovb
636     scasb
637     sscaw
638     stosw
639     sstol
641     bsf 0x1000, %ebx
642     bsr 0x1000, %ebx
643     bt %edx, 0x1000
644     btl $2, 0x1000
645     btc %edx, 0x1000
646     btcl $2, 0x1000
647     btr %edx, 0x1000
648     btrl $2, 0x1000
649     bts %edx, 0x1000
650     btsl $2, 0x1000
652         
653         
654 #ifdef __i386__
655     boundl %edx, 0x10000
656     boundw %bx, 0x1000
658     arpl %bx, 0x1000
659 #endif
660     lar 0x1000, %eax
661     lgdt 0x1000
662     lidt 0x1000
663     lldt 0x1000
664     lmsw 0x1000
665     lsl 0x1000, %ecx
666     ltr 0x1000
667     
668     sgdt 0x1000
669     sidt 0x1000
670     sldt 0x1000
671     smsw 0x1000
672     str 0x1000
673     
674     verr 0x1000
675     verw 0x1000
676   
677 #ifdef __i386__
678     push %ds
679     pushw %ds
680     pushl %ds
681     pop %ds
682     popw %ds
683     popl %ds
684 #endif
685     fxsave 1(%ebx)
686     fxrstor 1(%ecx)
687 #ifdef __i386__
688     pushl $1
689 #else
690     pushq $1
691 #endif
692     pushw $1
693     push $1
695 #ifdef __ASSEMBLER__ // should be defined, for S files
696     inc %eax
697 #endif
699 ft1: ft2: ft3: ft4: ft5: ft6: ft7: ft8: ft9:
700     xor %eax, %eax
701     ret
703 .type ft1,STT_FUNC
704 .type ft2,@STT_FUNC
705 .type ft3,%STT_FUNC
706 .type ft4,"STT_FUNC"
707 .type ft5,function
708 .type ft6,@function
709 .type ft7,%function
710 .type ft8,"function"
712     pause
713 .rept 6
714     nop
715 .endr
716 .fill 4,1,0x90