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