STU_InstructAndDecode.c 14 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. //#include "main.h"
  2. #include "STU_InstructAndDecode.h"
  3. uint8_t STU_InstructAndDecode(void)
  4. {
  5. uint8_t uc_operand;
  6. uint32_t uw_operand1,uw_operand2,uw_result;
  7. int32_t w_operand1,w_operand2,w_result;
  8. /**************************赋值指令******************************/
  9. uc_operand = 0x55;
  10. if(uc_operand != 0x55)
  11. {
  12. return(ERROR);
  13. }
  14. uc_operand = 0xAA;
  15. if(uc_operand != 0xAA)
  16. {
  17. return(ERROR);
  18. }
  19. uw_operand1 = 0x55555555;
  20. if(uw_operand1 != 0x55555555)
  21. {
  22. return(ERROR);
  23. }
  24. uw_operand1 = 0xAAAAAAAA;
  25. if(uw_operand1 != 0xAAAAAAAA)
  26. {
  27. return(ERROR);
  28. }
  29. /**************************加法指令******************************/
  30. uw_operand1 = 1000;
  31. uw_operand2 = 2000;
  32. uw_result = uw_operand1 + uw_operand2;
  33. if(uw_result != 3000)
  34. {
  35. return(ERROR);
  36. }
  37. uw_operand1 = 0xFFFFFFFF;
  38. uw_operand2 = 0x02;
  39. uw_result = uw_operand1 + uw_operand2;
  40. if(uw_result != 0x01)
  41. {
  42. return(ERROR);
  43. }
  44. w_operand1 = 1000;
  45. w_operand2 = -2000;
  46. w_result = w_operand1 + w_operand2;
  47. if(w_result != -1000)
  48. {
  49. return(ERROR);
  50. }
  51. w_operand1 = 0x7FFFFFFF;
  52. w_operand2 = 0x01;
  53. w_result = w_operand1 + w_operand2;
  54. if(w_result != (int32_t)0x80000000)
  55. {
  56. return(ERROR);
  57. }
  58. w_operand1 = 0x7FFFFFFF;
  59. w_operand2 = 0x02;
  60. w_result = w_operand1 + w_operand2;
  61. if(w_result != (int32_t)-0x7FFFFFFF)
  62. {
  63. return(ERROR);
  64. }
  65. w_operand1 = 0x7FFFFFFF;
  66. w_operand2 = 0x03;
  67. w_result = w_operand1 + w_operand2;
  68. if(w_result != (int32_t)-0x7FFFFFFE)
  69. {
  70. return(ERROR);
  71. }
  72. /**************************减法指令******************************/
  73. uw_operand1 = 2000;
  74. uw_operand2 = 1000;
  75. uw_result = uw_operand1 - uw_operand2;
  76. if(uw_result != 1000)
  77. {
  78. return(ERROR);
  79. }
  80. uw_operand1 = 2000;
  81. uw_operand2 = 2001;
  82. uw_result = uw_operand1 - uw_operand2;
  83. if(uw_result != 0xFFFFFFFF)
  84. {
  85. return(ERROR);
  86. }
  87. uw_operand1 = 0;
  88. uw_operand2 = 1;
  89. uw_result = uw_operand1 - uw_operand2;
  90. if(uw_result != 0xFFFFFFFF)
  91. {
  92. return(ERROR);
  93. }
  94. w_operand1 = 1000;
  95. w_operand2 = 2000;
  96. w_result = w_operand1 - w_operand2;
  97. if(w_result != (int32_t)-1000)
  98. {
  99. return(ERROR);
  100. }
  101. w_operand1 = 0;
  102. w_operand2 = 1;
  103. w_result = w_operand1 - w_operand2;
  104. if(w_result != (int32_t)-1)
  105. {
  106. return(ERROR);
  107. }
  108. w_operand1 = 0x80000000;
  109. w_operand2 = 1;
  110. w_result = w_operand1 - w_operand2;
  111. if(w_result != (int32_t)0x7FFFFFFF)
  112. {
  113. return(ERROR);
  114. }
  115. /**************************自加“++”指令******************************/
  116. uw_operand1 = 1000;
  117. uw_operand1++;
  118. if(uw_operand1 != 1001)
  119. {
  120. return(ERROR);
  121. }
  122. uw_operand1 = 0xFFFFFFFF;
  123. uw_operand1++;
  124. if(uw_operand1 != 0)
  125. {
  126. return(ERROR);
  127. }
  128. uw_operand1 = 0x00;
  129. uw_operand1++;
  130. if(uw_operand1 != 0x01)
  131. {
  132. return(ERROR);
  133. }
  134. w_operand1 = 1000;
  135. w_operand1++;
  136. if(w_operand1 != 1001)
  137. {
  138. return(ERROR);
  139. }
  140. w_operand1 = 0x00;
  141. w_operand1++;
  142. if(w_operand1 != 0x01)
  143. {
  144. return(ERROR);
  145. }
  146. w_operand1 = 0x7FFFFFFF;
  147. w_operand1++;
  148. if(w_operand1 != 0x80000000)
  149. {
  150. return(ERROR);
  151. }
  152. w_operand1 = 0x80000000;
  153. w_operand1++;
  154. if(w_operand1 != 0x80000001)
  155. {
  156. return(ERROR);
  157. }
  158. /**************************自减“--”指令******************************/
  159. uw_operand1 = 1000;
  160. uw_operand1--;
  161. if(uw_operand1 != 999)
  162. {
  163. return(ERROR);
  164. }
  165. uw_operand1 = 0x0;
  166. uw_operand1--;
  167. if(uw_operand1 != 0xFFFFFFFF)
  168. {
  169. return(ERROR);
  170. }
  171. uw_operand1 = 0xFFFFFFFF;
  172. uw_operand1--;
  173. if(uw_operand1 != 0xFFFFFFFE)
  174. {
  175. return(ERROR);
  176. }
  177. w_operand1 = 1000;
  178. w_operand1--;
  179. if(w_operand1 != 999)
  180. {
  181. return(ERROR);
  182. }
  183. w_operand1 = 0x80000000;
  184. w_operand1--;
  185. if(w_operand1 != 0x7FFFFFFF)
  186. {
  187. return(ERROR);
  188. }
  189. w_operand1 = 0x7FFFFFFF;
  190. w_operand1--;
  191. if(w_operand1 != 0x7FFFFFFE)
  192. {
  193. return(ERROR);
  194. }
  195. w_operand1 = 0x0;
  196. w_operand1--;
  197. if(w_operand1 != 0xFFFFFFFF)
  198. {
  199. return(ERROR);
  200. }
  201. /**************************乘法指令******************************/
  202. uw_operand1 = 100;
  203. uw_operand2 = 10;
  204. uw_result = uw_operand1 * uw_operand2;
  205. if(uw_result != 1000)
  206. {
  207. return(ERROR);
  208. }
  209. uw_operand1 = 0x0FFFFFFF;
  210. uw_operand2 = 0x11;
  211. uw_result = uw_operand1 * uw_operand2;
  212. if(uw_result != 0x0FFFFFEF)
  213. {
  214. return(ERROR);
  215. }
  216. uw_operand1 = 0xFFFFFFFF;
  217. uw_operand2 = 0x1;
  218. uw_result = uw_operand1 * uw_operand2;
  219. if(uw_result != 0xFFFFFFFF)
  220. {
  221. return(ERROR);
  222. }
  223. uw_operand1 = 100;
  224. uw_operand2 = 0;
  225. uw_result = uw_operand1 * uw_operand2;
  226. if(uw_result != 0)
  227. {
  228. return(ERROR);
  229. }
  230. /**************************除法指令******************************/
  231. uw_operand1 = 1000;
  232. uw_operand2 = 10;
  233. uw_result = uw_operand1 / uw_operand2;
  234. if(uw_result != 100)
  235. {
  236. return(ERROR);
  237. }
  238. uw_operand1 = 1;
  239. uw_operand2 = 10;
  240. uw_result = uw_operand1 / uw_operand2;
  241. if(uw_result != 0)
  242. {
  243. return(ERROR);
  244. }
  245. uw_operand1 = 0;
  246. uw_operand2 = 10;
  247. uw_result = uw_operand1 / uw_operand2;
  248. if(uw_result != 0)
  249. {
  250. return(ERROR);
  251. }
  252. uw_operand1 = 1000;
  253. uw_operand2 = 0;
  254. uw_result = uw_operand1 / uw_operand2;
  255. if(uw_result != 0)
  256. {
  257. return(ERROR);
  258. }
  259. uw_operand1 = 0xFFFFFFFF;
  260. uw_operand2 = 1;
  261. uw_result = uw_operand1 / uw_operand2;
  262. if(uw_result != 0xFFFFFFFF)
  263. {
  264. return(ERROR);
  265. }
  266. /**************************左移指令******************************/
  267. uw_operand1 = 0x2;
  268. uw_result = uw_operand1 << 1;
  269. if(uw_result != 0x4)
  270. {
  271. return(ERROR);
  272. }
  273. uw_operand1 = 0x2;
  274. uw_result = uw_operand1 << 8;
  275. if(uw_result != 0x200)
  276. {
  277. return(ERROR);
  278. }
  279. uw_operand1 = 0x2;
  280. uw_result = uw_operand1 << 31;
  281. if(uw_result != 0x0)
  282. {
  283. return(ERROR);
  284. }
  285. /**************************右移指令******************************/
  286. uw_operand1 = 0xFFFF;
  287. uw_result = uw_operand1 >> 1;
  288. if(uw_result != 0x7FFF)
  289. {
  290. return(ERROR);
  291. }
  292. uw_operand1 = 0xFFFF;
  293. uw_result = uw_operand1 >> 8;
  294. if(uw_result != 0xFF)
  295. {
  296. return(ERROR);
  297. }
  298. uw_operand1 = 0xFFFF;
  299. uw_result = uw_operand1 >> 31;
  300. if(uw_result != 0x0)
  301. {
  302. return(ERROR);
  303. }
  304. /**************************if else指令******************************/
  305. uw_operand1 = 1;
  306. if(uw_operand1)
  307. {
  308. //ok
  309. }
  310. else
  311. {
  312. return(ERROR);
  313. }
  314. uw_operand1 = 0;
  315. if(uw_operand1)
  316. {
  317. return(ERROR);
  318. }
  319. else
  320. {
  321. //ok
  322. }
  323. uw_operand1 = 0xFF;
  324. if(uw_operand1)
  325. {
  326. //ok
  327. }
  328. else
  329. {
  330. return(ERROR);
  331. }
  332. /**************************大于指令******************************/
  333. uw_operand1 = 100;
  334. uw_operand2 = 10;
  335. if(uw_operand1 > uw_operand2)
  336. {
  337. //ok
  338. }
  339. else
  340. {
  341. return(ERROR);
  342. }
  343. uw_operand1 = 100;
  344. uw_operand2 = 100;
  345. if(uw_operand1 > uw_operand2)
  346. {
  347. return(ERROR);
  348. }
  349. else
  350. {
  351. //ok
  352. }
  353. uw_operand1 = 10;
  354. uw_operand2 = 100;
  355. if(uw_operand1 > uw_operand2)
  356. {
  357. return(ERROR);
  358. }
  359. else
  360. {
  361. //ok
  362. }
  363. uw_operand1 = 0xFFFFFFFF;
  364. uw_operand2 = 0;
  365. if(uw_operand1 > uw_operand2)
  366. {
  367. //ok
  368. }
  369. else
  370. {
  371. return(ERROR);
  372. }
  373. w_operand1 = 0x7FFFFFFF;
  374. w_operand2 = 0x80000000;
  375. if(w_operand1 > w_operand2)
  376. {
  377. //ok
  378. }
  379. else
  380. {
  381. return(ERROR);
  382. }
  383. /**************************小于指令******************************/
  384. uw_operand1 = 10;
  385. uw_operand2 = 100;
  386. if(uw_operand1 < uw_operand2)
  387. {
  388. //ok
  389. }
  390. else
  391. {
  392. return(ERROR);
  393. }
  394. uw_operand1 = 100;
  395. uw_operand2 = 100;
  396. if(uw_operand1 < uw_operand2)
  397. {
  398. return(ERROR);
  399. }
  400. else
  401. {
  402. //ok
  403. }
  404. uw_operand1 = 100;
  405. uw_operand2 = 10;
  406. if(uw_operand1 < uw_operand2)
  407. {
  408. return(ERROR);
  409. }
  410. else
  411. {
  412. //ok
  413. }
  414. uw_operand1 = 0;
  415. uw_operand2 = 0xFFFFFFFF;
  416. if(uw_operand1 < uw_operand2)
  417. {
  418. //ok
  419. }
  420. else
  421. {
  422. return(ERROR);
  423. }
  424. w_operand1 = 0x80000000;
  425. w_operand2 = 0x7FFFFFFF;
  426. if(w_operand1 < w_operand2)
  427. {
  428. //ok
  429. }
  430. else
  431. {
  432. return(ERROR);
  433. }
  434. /**************************大于等于指令******************************/
  435. uw_operand1 = 100;
  436. uw_operand2 = 10;
  437. if(uw_operand1 >= uw_operand2)
  438. {
  439. //ok
  440. }
  441. else
  442. {
  443. return(ERROR);
  444. }
  445. uw_operand1 = 100;
  446. uw_operand2 = 100;
  447. if(uw_operand1 >= uw_operand2)
  448. {
  449. //ok
  450. }
  451. else
  452. {
  453. return(ERROR);
  454. }
  455. uw_operand1 = 10;
  456. uw_operand2 = 100;
  457. if(uw_operand1 >= uw_operand2)
  458. {
  459. return(ERROR);
  460. }
  461. else
  462. {
  463. //ok
  464. }
  465. uw_operand1 = 0xFFFFFFFF;
  466. uw_operand2 = 0;
  467. if(uw_operand1 >= uw_operand2)
  468. {
  469. //ok
  470. }
  471. else
  472. {
  473. return(ERROR);
  474. }
  475. w_operand1 = 0x7FFFFFFF;
  476. w_operand2 = 0x80000000;
  477. if(w_operand1 >= w_operand2)
  478. {
  479. //ok
  480. }
  481. else
  482. {
  483. return(ERROR);
  484. }
  485. /**************************小于等于指令******************************/
  486. uw_operand1 = 10;
  487. uw_operand2 = 100;
  488. if(uw_operand1 <= uw_operand2)
  489. {
  490. //ok
  491. }
  492. else
  493. {
  494. return(ERROR);
  495. }
  496. uw_operand1 = 100;
  497. uw_operand2 = 100;
  498. if(uw_operand1 <= uw_operand2)
  499. {
  500. //ok
  501. }
  502. else
  503. {
  504. return(ERROR);
  505. }
  506. uw_operand1 = 100;
  507. uw_operand2 = 10;
  508. if(uw_operand1 <= uw_operand2)
  509. {
  510. return(ERROR);
  511. }
  512. else
  513. {
  514. //ok
  515. }
  516. uw_operand1 = 0;
  517. uw_operand2 = 0xFFFFFFFF;
  518. if(uw_operand1 <= uw_operand2)
  519. {
  520. //ok
  521. }
  522. else
  523. {
  524. return(ERROR);
  525. }
  526. w_operand1 = 0x80000000;
  527. w_operand2 = 0x7FFFFFFF;
  528. if(w_operand1 <= w_operand2)
  529. {
  530. //ok
  531. }
  532. else
  533. {
  534. return(ERROR);
  535. }
  536. /**************************等于指令******************************/
  537. uw_operand1 = 100;
  538. uw_operand2 = 100;
  539. if(uw_operand1 == uw_operand2)
  540. {
  541. //ok
  542. }
  543. else
  544. {
  545. return(ERROR);
  546. }
  547. uw_operand1 = 0xFFFFFFFF;
  548. uw_operand2 = 0xFFFFFFFF;
  549. if(uw_operand1 == uw_operand2)
  550. {
  551. }
  552. else
  553. {
  554. return(ERROR);
  555. }
  556. uw_operand1 = 0;
  557. uw_operand2 = 0;
  558. if(uw_operand1 == uw_operand2)
  559. {
  560. }
  561. else
  562. {
  563. return(ERROR);
  564. }
  565. w_operand1 = 0x80000000;
  566. w_operand2 = 0x80000000;
  567. if(w_operand1 == w_operand2)
  568. {
  569. }
  570. else
  571. {
  572. return(ERROR);
  573. }
  574. w_operand1 = 0;
  575. w_operand2 = 0;
  576. if(w_operand1 == w_operand2)
  577. {
  578. }
  579. else
  580. {
  581. return(ERROR);
  582. }
  583. w_operand1 = 0x7FFFFFFF;
  584. w_operand2 = 0x7FFFFFFF;
  585. if(w_operand1 == w_operand2)
  586. {
  587. }
  588. else
  589. {
  590. return(ERROR);
  591. }
  592. /**************************不等于指令******************************/
  593. uw_operand1 = 100;
  594. uw_operand2 = 100;
  595. if(uw_operand1 != uw_operand2)
  596. {
  597. return(ERROR);
  598. }
  599. else
  600. {
  601. }
  602. uw_operand1 = 0xFFFFFFFF;
  603. uw_operand2 = 0xFFFFFFFF;
  604. if(uw_operand1 != uw_operand2)
  605. {
  606. return(ERROR);
  607. }
  608. else
  609. {
  610. }
  611. uw_operand1 = 0;
  612. uw_operand2 = 0;
  613. if(uw_operand1 != uw_operand2)
  614. {
  615. return(ERROR);
  616. }
  617. else
  618. {
  619. }
  620. w_operand1 = 0x80000000;
  621. w_operand2 = 0x80000000;
  622. if(w_operand1 != w_operand2)
  623. {
  624. return(ERROR);
  625. }
  626. else
  627. {
  628. }
  629. w_operand1 = 0;
  630. w_operand2 = 0;
  631. if(w_operand1 != w_operand2)
  632. {
  633. return(ERROR);
  634. }
  635. else
  636. {
  637. }
  638. w_operand1 = 0x7FFFFFFF;
  639. w_operand2 = 0x7FFFFFFF;
  640. if(w_operand1 != w_operand2)
  641. {
  642. return(ERROR);
  643. }
  644. else
  645. {
  646. }
  647. /**************************SWITCH 指令******************************/
  648. uw_operand1 = 1;
  649. uw_operand2 = 0;
  650. switch(uw_operand1)
  651. {
  652. case 1:
  653. uw_operand2 = uw_operand2 + 2;
  654. break;
  655. case 2:
  656. uw_operand2 = uw_operand2 + 4;
  657. break;
  658. case 3:
  659. uw_operand2 = uw_operand2 + 8;
  660. break;
  661. default : break;
  662. }
  663. if(uw_operand2 != 2)
  664. {
  665. return(ERROR);
  666. }
  667. uw_operand1 = 2;
  668. uw_operand2 = 0;
  669. switch(uw_operand1)
  670. {
  671. case 1:
  672. uw_operand2 = uw_operand2 + 2;
  673. break;
  674. case 2:
  675. uw_operand2 = uw_operand2 + 4;
  676. break;
  677. case 3:
  678. uw_operand2 = uw_operand2 + 8;
  679. break;
  680. default : break;
  681. }
  682. if(uw_operand2 != 4)
  683. {
  684. return(ERROR);
  685. }
  686. uw_operand1 = 3;
  687. uw_operand2 = 0;
  688. switch(uw_operand1)
  689. {
  690. case 1:
  691. uw_operand2 = uw_operand2 + 2;
  692. break;
  693. case 2:
  694. uw_operand2 = uw_operand2 + 4;
  695. break;
  696. case 3:
  697. uw_operand2 = uw_operand2 + 8;
  698. break;
  699. default : break;
  700. }
  701. if(uw_operand2 != 8)
  702. {
  703. return(ERROR);
  704. }
  705. uw_operand1 = 4;
  706. uw_operand2 = 0;
  707. switch(uw_operand1)
  708. {
  709. case 1:
  710. uw_operand2 = uw_operand2 + 2;
  711. break;
  712. case 2:
  713. uw_operand2 = uw_operand2 + 4;
  714. break;
  715. case 3:
  716. uw_operand2 = uw_operand2 + 8;
  717. break;
  718. default : break;
  719. }
  720. if(uw_operand2 != 0)
  721. {
  722. return(ERROR);
  723. }
  724. /**************************与 或 指令******************************/
  725. uw_operand1 = 0;
  726. uw_operand2 = 0;
  727. if( uw_operand1 && uw_operand2 )
  728. {
  729. return(ERROR);
  730. }
  731. else
  732. {
  733. //ok
  734. }
  735. if( uw_operand1 || uw_operand2 )
  736. {
  737. return(ERROR);
  738. }
  739. else
  740. {
  741. //ok
  742. }
  743. uw_operand1 = 0;
  744. uw_operand2 = 1;
  745. if( uw_operand1 && uw_operand2 )
  746. {
  747. return(ERROR);
  748. }
  749. else
  750. {
  751. //ok
  752. }
  753. if( uw_operand1 || uw_operand2 )
  754. {
  755. //ok
  756. }
  757. else
  758. {
  759. return(ERROR);
  760. }
  761. uw_operand1 = 1;
  762. uw_operand2 = 1;
  763. if( uw_operand1 && uw_operand2 )
  764. {
  765. //ok
  766. }
  767. else
  768. {
  769. return(ERROR);
  770. }
  771. if( uw_operand1 || uw_operand2 )
  772. {
  773. //ok
  774. }
  775. else
  776. {
  777. return(ERROR);
  778. }
  779. uw_operand1 = 1;
  780. uw_operand2 = 0xFF;
  781. if( uw_operand1 && uw_operand2 )
  782. {
  783. //ok
  784. }
  785. else
  786. {
  787. return(ERROR);
  788. }
  789. if( uw_operand1 || uw_operand2 )
  790. {
  791. //ok
  792. }
  793. else
  794. {
  795. return(ERROR);
  796. }
  797. uw_operand1 = 0;
  798. uw_operand2 = 0xFF;
  799. if( uw_operand1 && uw_operand2 )
  800. {
  801. return(ERROR);
  802. }
  803. else
  804. {
  805. //OK
  806. }
  807. if( uw_operand1 || uw_operand2 )
  808. {
  809. //ok
  810. }
  811. else
  812. {
  813. return(ERROR);
  814. }
  815. /**************************异或运算指令******************************/
  816. uw_operand1 = 0x55555555;
  817. uw_operand2 = 0x55555555;
  818. uw_result = uw_operand1 ^ uw_operand2;
  819. if(uw_result != 0x0)
  820. {
  821. return(ERROR);
  822. }
  823. uw_operand1 = 0x55555555;
  824. uw_operand2 = 0xAAAAAAAA;
  825. uw_result = uw_operand1 ^ uw_operand2;
  826. if(uw_result != 0xFFFFFFFF)
  827. {
  828. return(ERROR);
  829. }
  830. uw_operand1 = 0x00000000;
  831. uw_operand2 = 0x00000000;
  832. uw_result = uw_operand1 ^ uw_operand2;
  833. if(uw_result != 0x00000000)
  834. {
  835. return(ERROR);
  836. }
  837. uw_operand1 = 0xFFFFFFFF;
  838. uw_operand2 = 0xFFFFFFFF;
  839. uw_result = uw_operand1 ^ uw_operand2;
  840. if(uw_result != 0x00000000)
  841. {
  842. return(ERROR);
  843. }
  844. uw_operand1 = 0x00000000;
  845. uw_operand2 = 0xFFFFFFFF;
  846. uw_result = uw_operand1 ^ uw_operand2;
  847. if(uw_result != 0xFFFFFFFF)
  848. {
  849. return(ERROR);
  850. }
  851. /**************************取反运算指令******************************/
  852. uw_operand1 = 0x55555555;
  853. uw_result = ~uw_operand1;
  854. if(uw_result != 0xAAAAAAAA)
  855. {
  856. return(ERROR);
  857. }
  858. uw_result = ~uw_result;
  859. if(uw_result != 0x55555555)
  860. {
  861. return(ERROR);
  862. }
  863. uw_operand1 = 0x00000000;
  864. uw_result = ~uw_operand1;
  865. if(uw_result != 0xFFFFFFFF)
  866. {
  867. return(ERROR);
  868. }
  869. uw_result = ~uw_result;
  870. if(uw_result != 0x00000000)
  871. {
  872. return(ERROR);
  873. }
  874. return (SUCCESS);
  875. }//STU_InstructAndDecode