asmtest.S 7.1 KB

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