PLT generation fix
[tinycc.git] / asmtest.S
blob9e3d543e722311c4dffd851795e9b4da908f2d79
2 /* some directive tests */
4    .byte 0xff
5    .byte 1, 2, 3
6    .short 1, 2, 3
7    .word 1, 2, 3
8    .long 1, 2, 3
9    .int 1, 2, 3
10    .align 8
11    .byte 1
12    .align 16, 0x90
13    .skip 3
14    .skip 15, 0x90
16 /* some label tests */
18         movl %eax, %ebx
19 L1:
20         movl %eax, %ebx
21         mov 0x10000, %eax
22 L2:
23         movl $L2 - L1, %ecx
24 var1:
25         nop ; nop ; nop ; nop
27         mov var1, %eax
29 /* instruction tests */
30 movl %eax, %ebx
31 mov 0x10000, %eax
32 mov 0x10000, %ax
33 mov 0x10000, %al
34 mov %al, 0x10000
35                 
36 mov $1, %edx
37 mov $1, %dx
38 mov $1, %dl
39 movb $2, 0x100(%ebx,%edx,2)
40 movw $2, 0x100(%ebx,%edx,2)
41 movl $2, 0x100(%ebx,%edx,2)
42 movl %eax, 0x100(%ebx,%edx,2)
43 movl 0x100(%ebx,%edx,2), %edx
44 movw %ax, 0x100(%ebx,%edx,2)
45         
46 mov %cr3, %edx
47 mov %ecx, %cr3
48 movl %cr3, %eax
49 movl %tr3, %eax
50 movl %db3, %ebx
51 movl %dr6, %eax
52 movl %fs, %ecx
53 movl %ebx, %fs
55      movsbl 0x1000, %eax
56      movsbw 0x1000, %ax
57      movswl 0x1000, %eax
59      movzbl 0x1000, %eax
60      movzbw 0x1000, %ax
61      movzwl 0x1000, %eax
62             
63      movzb 0x1000, %eax
64      movzb 0x1000, %ax
65                 
66         
67   pushl %eax
68   pushw %ax
69   push %eax
70   push %cs
71   push %gs
72   push $1
73   push $100
74                                                 
75   popl %eax
76   popw %ax
77   pop %eax
78   pop %ds
79   pop %fs
80           
81   xchg %eax, %ecx
82   xchg %edx, %eax
83   xchg %bx, 0x10000
84   xchg 0x10000, %ebx
85   xchg 0x10000, %dl
87   in $100, %al               
88   in $100, %ax               
89   in $100, %eax
90   in %dx, %al
91   in %dx, %ax               
92   in %dx, %eax
93   inb %dx
94   inw %dx               
95   inl %dx
97   out %al, $100                       
98   out %ax, $100                       
99   out %eax, $100                       
101   /* NOTE: gas is bugged here, so size must be added */
102   outb %al, %dx                       
103   outw %ax, %dx                       
104   outl %eax, %dx                       
106   leal 0x1000(%ebx), %ecx
107   lea 0x1000(%ebx), %ecx
109   les 0x2000, %eax
110   lds 0x2000, %ebx
111   lfs 0x2000, %ecx
112   lgs 0x2000, %edx
113   lss 0x2000, %edx
115 addl $0x123, %eax
116 add $0x123, %ebx
117 addl $0x123, 0x100
118 addl $0x123, 0x100(%ebx)
119 addl $0x123, 0x100(%ebx,%edx,2)
120 addl $0x123, 0x100(%esp)
121 addl $0x123, (%ebp)
122 addl $0x123, (%esp)
123 cmpl $0x123, (%esp)
125 add %eax, (%ebx)
126 add (%ebx), %eax
127                 
128 or %dx, (%ebx)
129 or (%ebx), %si
130         
131 add %cl, (%ebx)
132 add (%ebx), %dl
134     inc %edx
135     incl 0x10000
136     incb 0x10000
137     dec %dx
138   
139   test $1, %al
140   test $1, %cl
142   testl $1, 0x1000
143   testb $1, 0x1000
144   testw $1, 0x1000
145   test %eax, %ebx
146   test %eax, 0x1000
147   test 0x1000, %edx
149     not %edx
150     notw 0x10000
151     notl 0x10000
152     notb 0x10000
154     neg %edx
155     negw 0x10000
156     negl 0x10000
157     negb 0x10000
159     imul %ecx
160     mul %edx
161     mulb %cl
163     imul %eax, %ecx
164     imul 0x1000, %cx
165     imul $10, %eax, %ecx
166     imul $10, %ax, %cx
167     imul $10, %eax
168     imul $0x1100000, %eax
169     imul $1, %eax
170     
171     idivw 0x1000
172     div %ecx
173     div %bl
174     div %ecx, %eax
177 shl %edx
178 shl $10, %edx
179 shl %cl, %edx
181 shld $1, %eax, %edx
182 shld %cl, %eax, %edx
183 shld %eax, %edx
185 shrd $1, %eax, %edx
186 shrd %cl, %eax, %edx
187 shrd %eax, %edx
190 call 0x1000
191 call L4
192 call *%eax
193 call *0x1000
194 call func1
196 lcall $0x100, $0x1000
198 jmp 0x1000
199 jmp *%eax
200 jmp *0x1000
202 ljmp $0x100, $0x1000
206 ret $10
208 lret
210 lret $10
212 enter $1234, $10
215  jo 0x1000
216  jnp 0x1001
217  jne 0x1002
218  jg 0x1003
220  jo L3
221  jnp L3
222  jne L3
223  jg L3
225  loopne L3
226  loopnz L3
227  loope L3
228  loopz L3
229  loop L3
230  jecxz L3
232         
233  seto %al
234  setnp 0x1000
235  setl 0xaaaa
236  setg %dl
238  fadd
239  fadd %st(1), %st
240  fadd %st(3)
242  faddp %st(5)
243  faddp
244  faddp %st(1), %st
246  fadds 0x1000
247  fiadds 0x1002
248  faddl 0x1004
249  fiaddl 0x1006
251  fmul
252  fmul %st(1), %st
253  fmul %st(3)
255  fmulp %st(5)
256  fmulp
257  fmulp %st(1), %st
259  fmuls 0x1000
260  fimuls 0x1002
261  fmull 0x1004
262  fimull 0x1006
264  fsub
265  fsub %st(1), %st
266  fsub %st(3)
268  fsubp %st(5)
269  fsubp
270  fsubp %st(1), %st
272  fsubs 0x1000
273  fisubs 0x1002
274  fsubl 0x1004
275  fisubl 0x1006
277  fsubr
278  fsubr %st(1), %st
279  fsubr %st(3)
281  fsubrp %st(5)
282  fsubrp
283  fsubrp %st(1), %st
285  fsubrs 0x1000
286  fisubrs 0x1002
287  fsubrl 0x1004
288  fisubrl 0x1006
290  fdiv
291  fdiv %st(1), %st
292  fdiv %st(3)
294  fdivp %st(5)
295  fdivp
296  fdivp %st(1), %st
298  fdivs 0x1000
299  fidivs 0x1002
300  fdivl 0x1004
301  fidivl 0x1006
303  fcom %st(3)
305  fcoms 0x1000
306  ficoms 0x1002
307  fcoml 0x1004
308  ficoml 0x1006
310  fcomp %st(5)
311  fcomp
312  fcompp
314  fcomps 0x1000
315  ficomps 0x1002
316  fcompl 0x1004
317  ficompl 0x1006
319  fld %st(5)
320  fldl 0x1000
321  flds 0x1002
322  fildl 0x1004
323  fst %st(4)
324  fstp %st(6)
325  fstpt 0x1006
326  fbstp 0x1008
328  fxch
329  fxch %st(4)
331  fucom %st(6)
332  fucomp %st(3)
333  fucompp
335  finit
336  fninit
337  fldcw 0x1000
338  fnstcw 0x1002
339  fstcw 0x1002
340  fnstsw 0x1004
341  fnstsw %eax
342  fstsw 0x1004
343  fstsw %eax
344  fnclex
345  fclex
346  fnstenv 0x1000
347  fstenv 0x1000
348  fldenv 0x1000
349  fnsave 0x1002
350  fsave 0x1000
351  frstor 0x1000
352  ffree %st(7)
353  ffreep %st(6)
355     ftst
356     fxam
357     fld1
358     fldl2t
359     fldl2e
360     fldpi
361     fldlg2
362     fldln2
363     fldz
365     f2xm1
366     fyl2x
367     fptan
368     fpatan
369     fxtract
370     fprem1
371     fdecstp
372     fincstp
373     fprem
374     fyl2xp1
375     fsqrt
376     fsincos
377     frndint
378     fscale
379     fsin
380     fcos
381     fchs
382     fabs
383     fnop
384     fwait
386 bswap %edx
387 xadd %ecx, %edx
388 xaddb %dl, 0x1000
389 xaddw %ax, 0x1000
390 xaddl %eax, 0x1000
391 cmpxchg %ecx, %edx
392 cmpxchgb %dl, 0x1000
393 cmpxchgw %ax, 0x1000
394 cmpxchgl %eax, 0x1000
395 invlpg 0x1000
396 cmpxchg8b 0x1002
398 fcmovb %st(5), %st
399 fcmove %st(5), %st
400 fcmovbe %st(5), %st
401 fcmovu %st(5), %st
402 fcmovnb %st(5), %st
403 fcmovne %st(5), %st
404 fcmovnbe %st(5), %st
405 fcmovnu %st(5), %st
406 fcomi %st(5), %st
407 fucomi %st(5), %st
408 fcomip %st(5), %st
409 fucomip %st(5), %st
413  cmovo 0x1000, %eax
414  cmovs 0x1000, %eax
415  cmovns %edx, %edi
417 int $3
418 int $0x10
420     pusha
421     popa
422     clc
423     cld
424     cli
425     clts
426     cmc
427     lahf
428     sahf
429     pushfl
430     popfl
431     pushf
432     popf
433     stc
434     std
435     sti
436     aaa
437     aas
438     daa
439     das
440     aad
441     aam
442     cbw
443     cwd
444     cwde
445     cdq
446     cbtw
447     cwtd
448     cwtl
449     cltd
450     leave
451     int3
452     into
453     iret
454     rsm
455     hlt
456     wait
457     nop
459     /* XXX: handle prefixes */
460 #if 0
461     aword
462     addr16
463 #endif
464     lock
465     rep
466     repe
467     repz
468     repne
469     repnz
470     
471     invd
472     wbinvd
473     cpuid
474     wrmsr
475     rdtsc
476     rdmsr
477     rdpmc
478     ud2
480     emms
481     movd %edx, %mm3
482     movd 0x1000, %mm2
483     movd %mm4, %ecx
484     movd %mm5, 0x1000
485                     
486     movq 0x1000, %mm2
487     movq %mm4, 0x1000
488     
489     pand 0x1000, %mm3
490     pand %mm4, %mm5
491     
492     psllw $1, %mm6
493     psllw 0x1000, %mm7
494     psllw %mm2, %mm7
496     xlat
497     cmpsb
498     scmpw
499     insl
500     outsw
501     lodsb
502     slodl
503     movsb
504     movsl
505     smovb
506     scasb
507     sscaw
508     stosw
509     sstol
511     bsf 0x1000, %ebx
512     bsr 0x1000, %ebx
513     bt %edx, 0x1000
514     btl $2, 0x1000
515     btc %edx, 0x1000
516     btcl $2, 0x1000
517     btr %edx, 0x1000
518     btrl $2, 0x1000
519     bts %edx, 0x1000
520     btsl $2, 0x1000
522     boundl %edx, 0x10000
523     boundw %bx, 0x1000
524     
525     arpl %bx, 0x1000
526     lar 0x1000, %eax
527     lgdt 0x1000
528     lidt 0x1000
529     lldt 0x1000
530     lmsw 0x1000
531     lsl 0x1000, %ecx
532     ltr 0x1000
533     
534     sgdt 0x1000
535     sidt 0x1000
536     sldt 0x1000
537     smsw 0x1000
538     str 0x1000
539     
540     verr 0x1000
541     verw 0x1000