Futher changes to casts
[tinycc/daniel.git] / asmtest.S
blob358a8239f3a85910c35bdb986d8f9abdbe048f7f
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)
47 mov %eax, 0x12(,%edx,2)
48         
49 mov %cr3, %edx
50 mov %ecx, %cr3
51 movl %cr3, %eax
52 movl %tr3, %eax
53 movl %db3, %ebx
54 movl %dr6, %eax
55 movl %fs, %ecx
56 movl %ebx, %fs
58      movsbl 0x1000, %eax
59      movsbw 0x1000, %ax
60      movswl 0x1000, %eax
62      movzbl 0x1000, %eax
63      movzbw 0x1000, %ax
64      movzwl 0x1000, %eax
65             
66      movzb 0x1000, %eax
67      movzb 0x1000, %ax
68                 
69         
70   pushl %eax
71   pushw %ax
72   push %eax
73   push %cs
74   push %gs
75   push $1
76   push $100
77                                                 
78   popl %eax
79   popw %ax
80   pop %eax
81   pop %ds
82   pop %fs
83           
84   xchg %eax, %ecx
85   xchg %edx, %eax
86   xchg %bx, 0x10000
87   xchg 0x10000, %ebx
88   xchg 0x10000, %dl
90   in $100, %al               
91   in $100, %ax               
92   in $100, %eax
93   in %dx, %al
94   in %dx, %ax               
95   in %dx, %eax
96   inb %dx
97   inw %dx               
98   inl %dx
100   out %al, $100                       
101   out %ax, $100                       
102   out %eax, $100                       
104   /* NOTE: gas is bugged here, so size must be added */
105   outb %al, %dx                       
106   outw %ax, %dx                       
107   outl %eax, %dx                       
109   leal 0x1000(%ebx), %ecx
110   lea 0x1000(%ebx), %ecx
112   les 0x2000, %eax
113   lds 0x2000, %ebx
114   lfs 0x2000, %ecx
115   lgs 0x2000, %edx
116   lss 0x2000, %edx
118 addl $0x123, %eax
119 add $0x123, %ebx
120 addl $0x123, 0x100
121 addl $0x123, 0x100(%ebx)
122 addl $0x123, 0x100(%ebx,%edx,2)
123 addl $0x123, 0x100(%esp)
124 addl $0x123, (%ebp)
125 addl $0x123, (%esp)
126 cmpl $0x123, (%esp)
128 add %eax, (%ebx)
129 add (%ebx), %eax
130                 
131 or %dx, (%ebx)
132 or (%ebx), %si
133         
134 add %cl, (%ebx)
135 add (%ebx), %dl
137     inc %edx
138     incl 0x10000
139     incb 0x10000
140     dec %dx
141   
142   test $1, %al
143   test $1, %cl
145   testl $1, 0x1000
146   testb $1, 0x1000
147   testw $1, 0x1000
148   test %eax, %ebx
149   test %eax, 0x1000
150   test 0x1000, %edx
152     not %edx
153     notw 0x10000
154     notl 0x10000
155     notb 0x10000
157     neg %edx
158     negw 0x10000
159     negl 0x10000
160     negb 0x10000
162     imul %ecx
163     mul %edx
164     mulb %cl
166     imul %eax, %ecx
167     imul 0x1000, %cx
168     imul $10, %eax, %ecx
169     imul $10, %ax, %cx
170     imul $10, %eax
171     imul $0x1100000, %eax
172     imul $1, %eax
173     
174     idivw 0x1000
175     div %ecx
176     div %bl
177     div %ecx, %eax
180 shl %edx
181 shl $10, %edx
182 shl %cl, %edx
184 shld $1, %eax, %edx
185 shld %cl, %eax, %edx
186 shld %eax, %edx
188 shrd $1, %eax, %edx
189 shrd %cl, %eax, %edx
190 shrd %eax, %edx
193 call 0x1000
194 call L4
195 call *%eax
196 call *0x1000
197 call func1
199 lcall $0x100, $0x1000
201 jmp 0x1000
202 jmp *%eax
203 jmp *0x1000
205 ljmp $0x100, $0x1000
209 ret $10
211 lret
213 lret $10
215 enter $1234, $10
218  jo 0x1000
219  jnp 0x1001
220  jne 0x1002
221  jg 0x1003
223  jo L3
224  jnp L3
225  jne L3
226  jg L3
228  loopne L3
229  loopnz L3
230  loope L3
231  loopz L3
232  loop L3
233  jecxz L3
235         
236  seto %al
237  setnp 0x1000
238  setl 0xaaaa
239  setg %dl
241  fadd
242  fadd %st(1), %st
243  fadd %st(3)
245  faddp %st(5)
246  faddp
247  faddp %st(1), %st
249  fadds 0x1000
250  fiadds 0x1002
251  faddl 0x1004
252  fiaddl 0x1006
254  fmul
255  fmul %st(1), %st
256  fmul %st(3)
258  fmulp %st(5)
259  fmulp
260  fmulp %st(1), %st
262  fmuls 0x1000
263  fimuls 0x1002
264  fmull 0x1004
265  fimull 0x1006
267  fsub
268  fsub %st(1), %st
269  fsub %st(3)
271  fsubp %st(5)
272  fsubp
273  fsubp %st(1), %st
275  fsubs 0x1000
276  fisubs 0x1002
277  fsubl 0x1004
278  fisubl 0x1006
280  fsubr
281  fsubr %st(1), %st
282  fsubr %st(3)
284  fsubrp %st(5)
285  fsubrp
286  fsubrp %st(1), %st
288  fsubrs 0x1000
289  fisubrs 0x1002
290  fsubrl 0x1004
291  fisubrl 0x1006
293  fdiv
294  fdiv %st(1), %st
295  fdiv %st(3)
297  fdivp %st(5)
298  fdivp
299  fdivp %st(1), %st
301  fdivs 0x1000
302  fidivs 0x1002
303  fdivl 0x1004
304  fidivl 0x1006
306  fcom %st(3)
308  fcoms 0x1000
309  ficoms 0x1002
310  fcoml 0x1004
311  ficoml 0x1006
313  fcomp %st(5)
314  fcomp
315  fcompp
317  fcomps 0x1000
318  ficomps 0x1002
319  fcompl 0x1004
320  ficompl 0x1006
322  fld %st(5)
323  fldl 0x1000
324  flds 0x1002
325  fildl 0x1004
326  fst %st(4)
327  fstp %st(6)
328  fstpt 0x1006
329  fbstp 0x1008
331  fxch
332  fxch %st(4)
334  fucom %st(6)
335  fucomp %st(3)
336  fucompp
338  finit
339  fninit
340  fldcw 0x1000
341  fnstcw 0x1002
342  fstcw 0x1002
343  fnstsw 0x1004
344  fnstsw %eax
345  fstsw 0x1004
346  fstsw %eax
347  fnclex
348  fclex
349  fnstenv 0x1000
350  fstenv 0x1000
351  fldenv 0x1000
352  fnsave 0x1002
353  fsave 0x1000
354  frstor 0x1000
355  ffree %st(7)
356  ffreep %st(6)
358     ftst
359     fxam
360     fld1
361     fldl2t
362     fldl2e
363     fldpi
364     fldlg2
365     fldln2
366     fldz
368     f2xm1
369     fyl2x
370     fptan
371     fpatan
372     fxtract
373     fprem1
374     fdecstp
375     fincstp
376     fprem
377     fyl2xp1
378     fsqrt
379     fsincos
380     frndint
381     fscale
382     fsin
383     fcos
384     fchs
385     fabs
386     fnop
387     fwait
389 bswap %edx
390 xadd %ecx, %edx
391 xaddb %dl, 0x1000
392 xaddw %ax, 0x1000
393 xaddl %eax, 0x1000
394 cmpxchg %ecx, %edx
395 cmpxchgb %dl, 0x1000
396 cmpxchgw %ax, 0x1000
397 cmpxchgl %eax, 0x1000
398 invlpg 0x1000
399 cmpxchg8b 0x1002
401 fcmovb %st(5), %st
402 fcmove %st(5), %st
403 fcmovbe %st(5), %st
404 fcmovu %st(5), %st
405 fcmovnb %st(5), %st
406 fcmovne %st(5), %st
407 fcmovnbe %st(5), %st
408 fcmovnu %st(5), %st
409 fcomi %st(5), %st
410 fucomi %st(5), %st
411 fcomip %st(5), %st
412 fucomip %st(5), %st
416  cmovo 0x1000, %eax
417  cmovs 0x1000, %eax
418  cmovns %edx, %edi
420 int $3
421 int $0x10
423     pusha
424     popa
425     clc
426     cld
427     cli
428     clts
429     cmc
430     lahf
431     sahf
432     pushfl
433     popfl
434     pushf
435     popf
436     stc
437     std
438     sti
439     aaa
440     aas
441     daa
442     das
443     aad
444     aam
445     cbw
446     cwd
447     cwde
448     cdq
449     cbtw
450     cwtd
451     cwtl
452     cltd
453     leave
454     int3
455     into
456     iret
457     rsm
458     hlt
459     wait
460     nop
462     /* XXX: handle prefixes */
463 #if 0
464     aword
465     addr16
466 #endif
467     lock
468     rep
469     repe
470     repz
471     repne
472     repnz
473     
474     invd
475     wbinvd
476     cpuid
477     wrmsr
478     rdtsc
479     rdmsr
480     rdpmc
481     ud2
483     emms
484     movd %edx, %mm3
485     movd 0x1000, %mm2
486     movd %mm4, %ecx
487     movd %mm5, 0x1000
488                     
489     movq 0x1000, %mm2
490     movq %mm4, 0x1000
491     
492     pand 0x1000, %mm3
493     pand %mm4, %mm5
494     
495     psllw $1, %mm6
496     psllw 0x1000, %mm7
497     psllw %mm2, %mm7
499     xlat
500     cmpsb
501     scmpw
502     insl
503     outsw
504     lodsb
505     slodl
506     movsb
507     movsl
508     smovb
509     scasb
510     sscaw
511     stosw
512     sstol
514     bsf 0x1000, %ebx
515     bsr 0x1000, %ebx
516     bt %edx, 0x1000
517     btl $2, 0x1000
518     btc %edx, 0x1000
519     btcl $2, 0x1000
520     btr %edx, 0x1000
521     btrl $2, 0x1000
522     bts %edx, 0x1000
523     btsl $2, 0x1000
525         
526         
527     boundl %edx, 0x10000
528     boundw %bx, 0x1000
529     
530     arpl %bx, 0x1000
531     lar 0x1000, %eax
532     lgdt 0x1000
533     lidt 0x1000
534     lldt 0x1000
535     lmsw 0x1000
536     lsl 0x1000, %ecx
537     ltr 0x1000
538     
539     sgdt 0x1000
540     sidt 0x1000
541     sldt 0x1000
542     smsw 0x1000
543     str 0x1000
544     
545     verr 0x1000
546     verw 0x1000
547   
548     push %ds
549     pushw %ds
550     pushl %ds
551     pop %ds
552     popw %ds
553     popl %ds
554     fxsave 1(%ebx)
555     fxrstor 1(%ecx)
556     pushl $1
557     pushw $1
558     push $1