bcase.pp 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671
  1. {$goto on}
  2. program bcase;
  3. {$mode objfpc}{$H+}
  4. uses
  5. SysUtils;
  6. { Utility functions }
  7. function GetRealTime(const st: TSystemTime): Real;
  8. begin
  9. Result := st.Hour*3600.0 + st.Minute*60.0 + st.Second + st.MilliSecond/1000.0;
  10. end;
  11. {$push}
  12. {$warn 5057 off}
  13. function GetRealTime : Real;
  14. var
  15. st:TSystemTime;
  16. begin
  17. GetLocalTime(st);
  18. result:=GetRealTime(st);
  19. end;
  20. {$pop}
  21. function IIf(Condition: Boolean; TrueRes, FalseRes: Integer): Integer; inline;
  22. begin
  23. if Condition then
  24. Result := TrueRes
  25. else
  26. Result := FalseRes;
  27. end;
  28. const
  29. {$ifdef IN_TESTS}
  30. ITERATIONS = $10000;
  31. {$else not IN_TESTS}
  32. ITERATIONS = 33554432;
  33. {$endif not IN_TESTS}
  34. AES_S_Box: array[Byte] of Byte = (
  35. $63, $7c, $77, $7b, $f2, $6b, $6f, $c5, $30, $01, $67, $2b, $fe, $d7, $ab, $76,
  36. $ca, $82, $c9, $7d, $fa, $59, $47, $f0, $ad, $d4, $a2, $af, $9c, $a4, $72, $c0,
  37. $b7, $fd, $93, $26, $36, $3f, $f7, $cc, $34, $a5, $e5, $f1, $71, $d8, $31, $15,
  38. $04, $c7, $23, $c3, $18, $96, $05, $9a, $07, $12, $80, $e2, $eb, $27, $b2, $75,
  39. $09, $83, $2c, $1a, $1b, $6e, $5a, $a0, $52, $3b, $d6, $b3, $29, $e3, $2f, $84,
  40. $53, $d1, $00, $ed, $20, $fc, $b1, $5b, $6a, $cb, $be, $39, $4a, $4c, $58, $cf,
  41. $d0, $ef, $aa, $fb, $43, $4d, $33, $85, $45, $f9, $02, $7f, $50, $3c, $9f, $a8,
  42. $51, $a3, $40, $8f, $92, $9d, $38, $f5, $bc, $b6, $da, $21, $10, $ff, $f3, $d2,
  43. $cd, $0c, $13, $ec, $5f, $97, $44, $17, $c4, $a7, $7e, $3d, $64, $5d, $19, $73,
  44. $60, $81, $4f, $dc, $22, $2a, $90, $88, $46, $ee, $b8, $14, $de, $5e, $0b, $db,
  45. $e0, $32, $3a, $0a, $49, $06, $24, $5c, $c2, $d3, $ac, $62, $91, $95, $e4, $79,
  46. $e7, $c8, $37, $6d, $8d, $d5, $4e, $a9, $6c, $56, $f4, $ea, $65, $7a, $ae, $08,
  47. $ba, $78, $25, $2e, $1c, $a6, $b4, $c6, $e8, $dd, $74, $1f, $4b, $bd, $8b, $8a,
  48. $70, $3e, $b5, $66, $48, $03, $f6, $0e, $61, $35, $57, $b9, $86, $c1, $1d, $9e,
  49. $e1, $f8, $98, $11, $69, $d9, $8e, $94, $9b, $1e, $87, $e9, $ce, $55, $28, $df,
  50. $8c, $a1, $89, $0d, $bf, $e6, $42, $68, $41, $99, $2d, $0f, $b0, $54, $bb, $16
  51. );
  52. FirstWeighted: array[0..255] of Byte = (
  53. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  54. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  55. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  56. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  57. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  58. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  59. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  60. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  61. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  62. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  63. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  64. $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63, $63,
  65. $ba, $78, $25, $2e, $1c, $a6, $b4, $c6, $e8, $dd, $74, $1f, $4b, $bd, $8b, $8a,
  66. $70, $3e, $b5, $66, $48, $03, $f6, $0e, $61, $35, $57, $b9, $86, $c1, $1d, $9e,
  67. $e1, $f8, $98, $11, $69, $d9, $8e, $94, $9b, $1e, $87, $e9, $ce, $55, $28, $df,
  68. $8c, $a1, $89, $0d, $bf, $e6, $42, $68, $41, $99, $2d, $0f, $b0, $54, $bb, $16
  69. );
  70. LastWeighted: array[0..255] of Byte = (
  71. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  72. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  73. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  74. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  75. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  76. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  77. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  78. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  79. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  80. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  81. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  82. $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16, $16,
  83. $ba, $78, $25, $2e, $1c, $a6, $b4, $c6, $e8, $dd, $74, $1f, $4b, $bd, $8b, $8a,
  84. $70, $3e, $b5, $66, $48, $03, $f6, $0e, $61, $35, $57, $b9, $86, $c1, $1d, $9e,
  85. $e1, $f8, $98, $11, $69, $d9, $8e, $94, $9b, $1e, $87, $e9, $ce, $55, $28, $df,
  86. $8c, $a1, $89, $0d, $bf, $e6, $42, $68, $41, $99, $2d, $0f, $b0, $54, $bb, $16
  87. );
  88. AlmostFullExpected: array[0..255] of Byte = (
  89. $63, $7c, $77, $7b, $f2, $6b, $6f, $c5, $30, $01, $67, $2b, $fe, $d7, $ab, $76,
  90. $ca, $82, $c9, $7d, $fa, $59, $47, $f0, $ad, $d4, $a2, $af, $9c, $a4, $72, $c0,
  91. $b7, $fd, $93, $26, $36, $3f, $f7, $cc, $34, $a5, $e5, $f1, $71, $d8, $31, $15,
  92. $04, $c7, $23, $c3, $18, $96, $05, $9a, $07, $12, $80, $e2, $eb, $27, $b2, $75,
  93. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
  94. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
  95. $d0, $ef, $aa, $fb, $43, $4d, $33, $85, $45, $f9, $02, $7f, $50, $3c, $9f, $a8,
  96. $51, $a3, $40, $8f, $92, $9d, $38, $f5, $bc, $b6, $da, $21, $10, $ff, $f3, $d2,
  97. $cd, $0c, $13, $ec, $5f, $97, $44, $17, $c4, $a7, $7e, $3d, $64, $5d, $19, $73,
  98. $60, $81, $4f, $dc, $22, $2a, $90, $88, $46, $ee, $b8, $14, $de, $5e, $0b, $db,
  99. $e0, $32, $3a, $0a, $49, $06, $24, $5c, $c2, $d3, $ac, $62, $91, $95, $e4, $79,
  100. $e7, $c8, $37, $6d, $8d, $d5, $4e, $a9, $6c, $56, $f4, $ea, $65, $7a, $ae, $08,
  101. $ba, $78, $25, $2e, $1c, $a6, $b4, $c6, $e8, $dd, $74, $1f, $4b, $bd, $8b, $8a,
  102. $70, $3e, $b5, $66, $48, $03, $f6, $0e, $61, $35, $57, $b9, $86, $c1, $1d, $9e,
  103. $e1, $f8, $98, $11, $69, $d9, $8e, $94, $9b, $1e, $87, $e9, $ce, $55, $28, $df,
  104. $8c, $a1, $89, $0d, $bf, $e6, $42, $68, $41, $99, $2d, $0f, $b0, $54, $bb, $16
  105. );
  106. type
  107. TInstructionSet = ( { Truncated to 1024 entries }
  108. A_NONE = -512, A_ADC, A_ADD, A_AND, A_BSF, A_BSR, A_BSWAP, A_BT, A_BTC, A_BTR, A_BTS,
  109. A_CALL, A_CBW, A_CDQ, A_CLC, A_CLD, A_CLI, A_CLTS, A_CMC, A_CMP, A_CMPSB,
  110. A_CMPSD, A_CMPSW, A_CMPXCHG, A_CMPXCHG486, A_CMPXCHG8B, A_CPUID, A_CWD, A_CWDE,
  111. A_DEC, A_DIV, A_EMMS, A_ENTER, A_F2XM1, A_FABS, A_FADD, A_FADDP, A_FBLD, A_FBSTP,
  112. A_FCHS, A_FCLEX,A_FCMOVB, A_FCMOVBE, A_FCMOVE, A_FCMOVNB, A_FCMOVNBE, A_FCMOVNE,
  113. A_FCMOVNU, A_FCMOVU, A_FCOM, A_FCOMI, A_FCOMIP, A_FCOMP, A_FCOMPP, A_FCOS,
  114. A_FDECSTP, A_FDISI, A_FDIV, A_FDIVP, A_FDIVR, A_FDIVRP, A_FEMMS, A_FENI, A_FFREE,
  115. A_FIADD, A_FICOM, A_FICOMP, A_FIDIV, A_FIDIVR, A_FILD, A_FIMUL, A_FINCSTP,
  116. A_FINIT, A_FIST, A_FISTP, A_FISTTP, A_FISUB, A_FISUBR, A_FLD, A_FLD1, A_FLDCW,
  117. A_FLDENV, A_FLDL2E, A_FLDL2T, A_FLDLG2, A_FLDLN2, A_FLDPI, A_FLDZ, A_FMUL,
  118. A_FMULP, A_FNCLEX, A_FNDISI, A_FNENI, A_FNINIT, A_FNOP, A_FNSAVE, A_FNSTCW,
  119. A_FNSTENV, A_FNSTSW, A_FPATAN, A_FPREM, A_FPREM1, A_FPTAN, A_FRNDINT, A_FRSTOR,
  120. A_FSAVE, A_FSCALE, A_FSETPM, A_FSIN, A_FSINCOS, A_FSQRT, A_FST, A_FSTCW,
  121. A_FSTENV, A_FSTP, A_FSTSW, A_FSUB, A_FSUBP, A_FSUBR, A_FSUBRP, A_FTST, A_FUCOM,
  122. A_FUCOMI, A_FUCOMIP, A_FUCOMP, A_FUCOMPP, A_FWAIT, A_FXAM, A_FXCH, A_FXTRACT,
  123. A_FYL2X, A_FYL2XP1, A_HLT, A_IBTS, A_ICEBP, A_IDIV, A_IMUL, A_IN, A_INC, A_INSB,
  124. A_INSD, A_INSW, A_INT, A_INT01, A_INT1, A_INT03, A_INT3, A_INVD, A_INVLPG,
  125. A_IRET, A_IRETD, A_IRETW, A_IRETQ, A_JECXZ, A_JRCXZ, A_JMP, A_LAHF, A_LAR,
  126. A_LCALL, A_LEA, A_LEAVE, A_LFS, A_LGDT, A_LGS, A_LIDT, A_LJMP, A_LLDT, A_LMSW,
  127. A_LOADALL, A_LOADALL286, A_LOCK, A_LODSB, A_LODSD, A_LODSW, A_LOOP, A_LOOPE,
  128. A_LOOPNE, A_LOOPNZ, A_LOOPZ, A_LSL, A_LSS, A_LTR, A_MONITOR, A_MOV, A_MOVD,
  129. A_MOVQ, A_MOVSB, A_MOVSD, A_MOVSQ, A_MOVSW, A_MOVSX, A_MOVZX, A_MUL, A_MWAIT,
  130. A_NEG, A_NOP, A_NOT, A_OR, A_OUT, A_OUTSB, A_OUTSD, A_OUTSW, A_PACKSSDW,
  131. A_PACKSSWB, A_PACKUSWB, A_PADDB, A_PADDD, A_PADDSB, A_PADDSIW, A_PADDSW,
  132. A_PADDUSB, A_PADDUSW, A_PADDW, A_PAND, A_PANDN, A_PAVEB, A_PAVGUSB, A_PCMPEQB,
  133. A_PCMPEQD, A_PCMPEQW, A_PCMPGTB, A_PCMPGTD, A_PCMPGTW, A_PDISTIB, A_PF2ID,
  134. A_PFACC, A_PFADD, A_PFCMPEQ, A_PFCMPGE, A_PFCMPGT, A_PFMAX, A_PFMIN, A_PFMUL,
  135. A_PFRCP, A_PFRCPIT1, A_PFRCPIT2, A_PFRSQIT1, A_PFRSQRT, A_PFSUB, A_PFSUBR,
  136. A_PI2FD, A_PMACHRIW, A_PMADDWD, A_PMAGW, A_PMULHRIW, A_PMULHRWA, A_PMULHRWC,
  137. A_PMULHW, A_PMULLW, A_PMVGEZB, A_PMVLZB, A_PMVNZB, A_PMVZB, A_POP, A_POPF,
  138. A_POPFW, A_POPFQ, A_POR, A_PREFETCH, A_PREFETCHW, A_PSLLD, A_PSLLDQ, A_PSLLQ,
  139. A_PSLLW, A_PSRAD, A_PSRAW, A_PSRLD, A_PSRLQ, A_PSRLW, A_PSUBB, A_PSUBD, A_PSUBSB,
  140. A_PSUBSIW, A_PSUBSW, A_PSUBUSB, A_PSUBUSW, A_PSUBW, A_PUNPCKHBW, A_PUNPCKHDQ,
  141. A_PUNPCKHWD, A_PUNPCKLBW, A_PUNPCKLDQ, A_PUNPCKLWD, A_PUSH, A_PUSHF, A_PUSHFW,
  142. A_PUSHFQ, A_PXOR, A_RCL, A_RCR, A_RDSHR, A_RDMSR, A_RDPMC, A_RDTSC, A_REP,
  143. A_REPE, A_REPNE, A_REPNZ, A_REPZ, A_RET, A_RETF, A_RETN, A_RETW, A_RETFW,
  144. A_RETNW, A_RETFD, A_RETQ, A_RETFQ, A_RETNQ, A_ROL, A_ROR, A_RSDC, A_RSLDT, A_RSM,
  145. A_SAHF, A_SAL, A_SAR, A_SBB, A_SCASB, A_SCASD, A_SCASQ, A_SCASW, A_SEGCS,
  146. A_SEGDS, A_SEGES, A_SEGFS, A_SEGGS, A_SEGSS, A_SGDT, A_SHL, A_SHLD, A_SHR,
  147. A_SHRD, A_SIDT, A_SLDT, A_SMI, A_SMINT, A_SMINTOLD, A_SMSW, A_STC, A_STD, A_STI,
  148. A_STOSB, A_STOSD, A_STOSW, A_STR, A_SUB, A_SVDC, A_SVLDT, A_SVTS, A_SYSCALL,
  149. A_SYSENTER, A_SYSEXIT, A_SYSRET, A_TEST, A_UD1, A_UD2, A_UMOV, A_VERR, A_VERW,
  150. A_WAIT, A_WBINVD, A_WRSHR, A_WRMSR, A_XADD, A_XBTS, A_XCHG, A_XLAT, A_XLATB,
  151. A_XOR, A_XSTORE, A_XCRYPTECB, A_XCRYPTCBC, A_XCRYPTCFB, A_XCRYPTOFB, A_CMOVcc,
  152. A_Jcc, A_SETcc, A_MOVS, A_CMPS, A_SCAS, A_LODS, A_STOS, A_INS, A_OUTS, A_ADDPS,
  153. A_ADDSS, A_ANDNPS, A_ANDPS, A_CMPEQPS, A_CMPEQSS, A_CMPLEPS, A_CMPLESS,
  154. A_CMPLTPS, A_CMPLTSS, A_CMPNEQPS, A_CMPNEQSS, A_CMPNLEPS, A_CMPNLESS,
  155. A_CMPNLTPS, A_CMPNLTSS, A_CMPORDPS, A_CMPORDSS, A_CMPUNORDPS, A_CMPUNORDSS,
  156. A_CMPPS, A_CMPSS, A_COMISS, A_CVTPI2PS, A_CVTPS2PI, A_CVTSI2SS, A_CVTSS2SI,
  157. A_CVTTPS2PI, A_CVTTSS2SI, A_DIVPS, A_DIVSS, A_LDMXCSR, A_MAXPS, A_MAXSS, A_MINPS,
  158. A_MINSS, A_MOVAPS, A_MOVHPS, A_MOVLHPS, A_MOVLPS, A_MOVHLPS, A_MOVMSKPS,
  159. A_MOVNTPS, A_MOVSS, A_MOVUPS, A_MULPS, A_MULSS, A_ORPS, A_RCPPS, A_RCPSS,
  160. A_RSQRTPS, A_RSQRTSS, A_SHUFPS, A_SQRTPS, A_SQRTSS, A_STMXCSR, A_SUBPS, A_SUBSS,
  161. A_UCOMISS, A_UNPCKHPS, A_UNPCKLPS, A_XORPS, A_FXRSTOR, A_FXSAVE, A_PREFETCHNTA,
  162. A_PREFETCHT0, A_PREFETCHT1, A_PREFETCHT2, A_SFENCE, A_MASKMOVQ, A_MOVNTQ,
  163. A_PAVGB, A_PAVGW, A_PEXTRW, A_PINSRW, A_PMAXSW, A_PMAXUB, A_PMINSW, A_PMINUB,
  164. A_PMOVMSKB, A_PMULHUW, A_PSADBW, A_PSHUFW, A_PFNACC, A_PFPNACC, A_PI2FW, A_PF2IW,
  165. A_PSWAPD, A_FFREEP, A_MASKMOVDQU, A_CLFLUSH, A_MOVNTDQ, A_MOVNTI, A_MOVNTPD,
  166. A_PAUSE, A_LFENCE, A_MFENCE, A_MOVDQA, A_MOVDQU, A_MOVDQ2Q, A_MOVQ2DQ, A_PADDQ,
  167. A_PMULUDQ, A_PSHUFD, A_PSHUFHW, A_PSHUFLW, A_PSRLDQ, A_PSUBQ, A_PUNPCKHQDQ,
  168. A_PUNPCKLQDQ, A_ADDPD, A_ADDSD, A_ANDNPD, A_ANDPD, A_CMPEQPD, A_CMPEQSD,
  169. A_CMPLEPD, A_CMPLESD, A_CMPLTPD, A_CMPLTSD, A_CMPNEQPD, A_CMPNEQSD, A_CMPNLEPD,
  170. A_CMPNLESD, A_CMPNLTPD, A_CMPNLTSD, A_CMPORDPD, A_CMPORDSD, A_CMPUNORDPD,
  171. A_CMPUNORDSD, A_CMPPD, A_COMISD, A_CVTDQ2PD, A_CVTDQ2PS, A_CVTPD2DQ, A_CVTPD2PI,
  172. A_CVTPD2PS, A_CVTPI2PD, A_CVTPS2DQ, A_CVTPS2PD, A_CVTSD2SI, A_CVTSD2SS,
  173. A_CVTSI2SD, A_CVTSS2SD, A_CVTTPD2PI, A_CVTTPD2DQ, A_CVTTPS2DQ, A_CVTTSD2SI,
  174. A_DIVPD, A_DIVSD, A_MAXPD, A_MAXSD, A_MINPD, A_MINSD, A_MOVAPD, A_MOVHPD,
  175. A_MOVLPD, A_MOVMSKPD, A_MOVUPD, A_MULPD, A_MULSD, A_ORPD, A_SHUFPD, A_SQRTPD,
  176. A_SQRTSD, A_SUBPD, A_SUBSD, A_UCOMISD, A_UNPCKHPD, A_UNPCKLPD, A_XORPD,
  177. A_ADDSUBPD, A_ADDSUBPS, A_HADDPD, A_HADDPS, A_HSUBPD, A_HSUBPS, A_LDDQU,
  178. A_MOVDDUP, A_MOVSHDUP, A_MOVSLDUP, A_VMREAD, A_VMWRITE, A_VMCALL, A_VMLAUNCH,
  179. A_VMRESUME, A_VMXOFF, A_VMXON, A_VMCLEAR, A_VMPTRLD, A_VMPTRST, A_VMRUN,
  180. A_VMMCALL, A_VMLOAD, A_VMSAVE, A_STGI, A_CLGI, A_SKINIT, A_INVLPGA, A_MONTMUL,
  181. A_XSHA1, A_XSHA256, A_DMINT, A_RDM, A_MOVABS, A_MOVSXD, A_CQO, A_CDQE,
  182. A_CMPXCHG16B, A_MOVNTSS, A_MOVNTSD, A_INSERTQ, A_EXTRQ, A_LZCNT, A_PABSB,
  183. A_PABSW, A_PABSD, A_PALIGNR, A_PHADDW, A_PHADDD, A_PHADDSW, A_PHSUBW, A_PHSUBD,
  184. A_PHSUBSW, A_PMADDUBSW, A_PMULHRSW, A_PSHUFB, A_PSIGNB, A_PSIGNW, A_PSIGND,
  185. A_BLENDPS, A_BLENDPD, A_BLENDVPS, A_BLENDVPD, A_DPPS, A_DPPD, A_EXTRACTPS,
  186. A_INSERTPS, A_MOVNTDQA, A_MPSADBW, A_PACKUSDW, A_PBLENDVB, A_PBLENDW, A_PCMPEQQ,
  187. A_PEXTRB, A_PEXTRD, A_PEXTRQ, A_PHMINPOSUW, A_PINSRB, A_PINSRD, A_PINSRQ, A_PMAXSB,
  188. A_PMAXSD, A_PMAXUD, A_PMAXUW, A_PMINSB, A_PMINSD, A_PMINUW, A_PMINUD, A_PMOVSXBW,
  189. A_PMOVSXBD, A_PMOVSXBQ, A_PMOVSXWD, A_PMOVSXWQ, A_PMOVSXDQ, A_PMOVZXBW, A_PMOVZXBD,
  190. A_PMOVZXBQ, A_PMOVZXWD, A_PMOVZXWQ, A_PMOVZXDQ, A_PMULDQ, A_PMULLD, A_PTEST,
  191. A_ROUNDPS, A_ROUNDPD, A_ROUNDSS, A_ROUNDSD, A_CRC32, A_PCMPESTRI, A_PCMPESTRM,
  192. A_PCMPISTRI, A_PCMPISTRM, A_PCMPGTQ, A_POPCNT, A_AESENC, A_AESENCLAST, A_AESDEC,
  193. A_AESDECLAST, A_AESIMC, A_AESKEYGENASSIST, A_RDTSCP, A_STOSQ, A_LODSQ, A_CMPSQ,
  194. A_VADDPD, A_VADDPS, A_VADDSD, A_VADDSS, A_VADDSUBPD, A_VADDSUBPS, A_VAESDEC,
  195. A_VAESDECLAST, A_VAESENC, A_VAESENCLAST, A_VAESIMC, A_VAESKEYGENASSIST, A_VANDNPD,
  196. A_VANDNPS, A_VANDPD, A_VANDPS, A_VBLENDPD, A_VBLENDPS, A_VBLENDVPD, A_VBLENDVPS,
  197. A_VBROADCASTF128, A_VBROADCASTSD, A_VBROADCASTSS, A_VCMPEQPS, A_VCMPLTPS,
  198. A_VCMPLEPS, A_VCMPUNORDPS, A_VCMPNEQPS, A_VCMPNLTPS, A_VCMPNLEPS, A_VCMPORDPS,
  199. A_VCMPEQ_UQPS, A_VCMPNGEPS, A_VCMPNGTPS, A_VCMPFALSEPS, A_VCMPNEQ_OQPS,
  200. A_VCMPGEPS, A_VCMPGTPS, A_VCMPTRUEPS, A_VCMPEQ_OSPS, A_VCMPLT_OQPS, A_VCMPLE_OQPS,
  201. A_VCMPUNORD_SPS, A_VCMPNEQ_USPS, A_VCMPNLT_UQPS, A_VCMPNLE_UQPS, A_VCMPORD_SPS,
  202. A_VCMPEQ_USPS, A_VCMPNGE_UQPS, A_VCMPNGT_UQPS, A_VCMPFALSE_OSPS, A_VCMPNEQ_OSPS,
  203. A_VCMPGE_OQPS, A_VCMPGT_OQPS, A_VCMPTRUE_USPS, A_VCMPEQPD, A_VCMPLTPD, A_VCMPLEPD,
  204. A_VCMPUNORDPD, A_VCMPNEQPD, A_VCMPNLTPD, A_VCMPNLEPD, A_VCMPORDPD, A_VCMPEQ_UQPD,
  205. A_VCMPNGEPD, A_VCMPNGTPD, A_VCMPFALSEPD, A_VCMPNEQ_OQPD, A_VCMPGEPD, A_VCMPGTPD,
  206. A_VCMPTRUEPD, A_VCMPEQ_OSPD, A_VCMPLT_OQPD, A_VCMPLE_OQPD, A_VCMPUNORD_SPD,
  207. A_VCMPNEQ_USPD, A_VCMPNLT_UQPD, A_VCMPNLE_UQPD, A_VCMPORD_SPD, A_VCMPEQ_USPD,
  208. A_VCMPNGE_UQPD, A_VCMPNGT_UQPD, A_VCMPFALSE_OSPD, A_VCMPNEQ_OSPD, A_VCMPGE_OQPD,
  209. A_VCMPGT_OQPD, A_VCMPTRUE_USPD, A_VCMPPD, A_VCMPPS, A_VCMPSD, A_VCMPSS, A_VCOMISD,
  210. A_VCOMISS, A_VCVTDQ2PD, A_VCVTDQ2PS, A_VCVTPD2DQ, A_VCVTPD2PS, A_VCVTPS2DQ,
  211. A_VCVTPS2PD, A_VCVTSD2SI, A_VCVTSD2SS, A_VCVTSI2SD, A_VCVTSI2SS, A_VCVTSS2SD,
  212. A_VCVTSS2SI, A_VCVTTPD2DQ, A_VCVTTPS2DQ, A_VCVTTSD2SI, A_VCVTTSS2SI, A_VDIVPD,
  213. A_VDIVPS, A_VDIVSD, A_VDIVSS, A_VDPPD, A_VDPPS, A_VEXTRACTF128, A_VEXTRACTPS,
  214. A_VHADDPD, A_VHADDPS, A_VHSUBPD, A_VHSUBPS, A_VINSERTF128, A_VINSERTPS, A_VLDDQU,
  215. A_VLDMXCSR, A_VMASKMOVDQU, A_VMASKMOVPD, A_VMASKMOVPS, A_VMAXPD, A_VMAXPS,
  216. A_VMAXSD, A_VMAXSS, A_VMINPD, A_VMINPS, A_VMINSD, A_VMINSS, A_VMOVAPD, A_VMOVAPS,
  217. A_VMOVD, A_VMOVDDUP, A_VMOVDQA, A_VMOVDQU, A_VMOVHLPS, A_VMOVHPD, A_VMOVHPS,
  218. A_VMOVLHPS, A_VMOVLPD, A_VMOVLPS, A_VMOVMSKPD, A_VMOVMSKPS, A_VMOVNTDQ,
  219. A_VMOVNTDQA, A_VMOVNTPD, A_VMOVNTPS, A_VMOVQ, A_VMOVSD, A_VMOVSHDUP, A_VMOVSLDUP,
  220. A_VMOVSS, A_VMOVUPD, A_VMOVUPS, A_VMPSADBW, A_VMULPD, A_VMULPS, A_VMULSD,
  221. A_VMULSS, A_VORPD, A_VORPS, A_VPABSB, A_VPABSD, A_VPABSW, A_VPACKSSDW,
  222. A_VPACKSSWB, A_VPACKUSDW, A_VPACKUSWB, A_VPADDB, A_VPADDD, A_VPADDQ, A_VPADDSB,
  223. A_VPADDSW, A_VPADDUSB, A_VPADDUSW, A_VPADDW, A_VPALIGNR, A_VPAND, A_VPANDN,
  224. A_VPAVGB, A_VPAVGW, A_VPBLENDVB, A_VPBLENDW, A_VPCLMULQDQ, A_VPCMPEQB, A_VPCMPEQD,
  225. A_VPCMPEQQ, A_VPCMPEQW, A_VPCMPESTRI, A_VPCMPESTRM, A_VPCMPGTB, A_VPCMPGTD,
  226. A_VPCMPGTQ, A_VPCMPGTW, A_VPCMPISTRI, A_VPCMPISTRM, A_VPERM2F128, A_VPERMILPD,
  227. A_VPERMILPS, A_VPEXTRB, A_VPEXTRD, A_VPEXTRQ, A_VPEXTRW, A_VPHADDD, A_VPHADDSW,
  228. A_VPHADDW, A_VPHMINPOSUW, A_VPHSUBD, A_VPHSUBSW, A_VPHSUBW, A_VPINSRB, A_VPINSRD,
  229. A_VPINSRQ, A_VPINSRW, A_VPMADDUBSW, A_VPMADDWD, A_VPMAXSB, A_VPMAXSD, A_VPMAXSW,
  230. A_VPMAXUB, A_VPMAXUD, A_VPMAXUW, A_VPMINSB, A_VPMINSD, A_VPMINSW, A_VPMINUB,
  231. A_VPMINUD, A_VPMINUW, A_VPMOVMSKB, A_VPMOVSXBD, A_VPMOVSXBQ, A_VPMOVSXBW,
  232. A_VPMOVSXDQ, A_VPMOVSXWD, A_VPMOVSXWQ, A_VPMOVZXBD, A_VPMOVZXBQ, A_VPMOVZXBW,
  233. A_VPMOVZXDQ, A_VPMOVZXWD, A_VPMOVZXWQ, A_VPMULDQ, A_VPMULHRSW, A_VPMULHUW,
  234. A_VPMULHW, A_VPMULLD, A_VPMULLW, A_VPMULUDQ, A_VPOR, A_VPSADBW, A_VPSHUFB,
  235. A_VPSHUFD, A_VPSHUFHW, A_VPSHUFLW, A_VPSIGNB, A_VPSIGND, A_VPSIGNW, A_VPSLLD,
  236. A_VPSLLDQ, A_VPSLLQ, A_VPSLLW, A_VPSRAD, A_VPSRAW, A_VPSRLD, A_VPSRLDQ, A_VPSRLQ,
  237. A_VPSRLW, A_VPSUBB, A_VPSUBD, A_VPSUBQ, A_VPSUBSB, A_VPSUBSW, A_VPSUBUSB,
  238. A_VPSUBUSW, A_VPSUBW, A_VPTEST, A_VPUNPCKHBW, A_VPUNPCKHDQ, A_VPUNPCKHQDQ,
  239. A_VPUNPCKHWD, A_VPUNPCKLBW, A_VPUNPCKLDQ, A_VPUNPCKLQDQ, A_VPUNPCKLWD, A_VPXOR,
  240. A_VRCPPS, A_VRCPSS, A_VROUNDPD, A_VROUNDPS, A_VROUNDSD, A_VROUNDSS, A_VRSQRTPS,
  241. A_VRSQRTSS, A_VSHUFPD, A_VSHUFPS, A_VSQRTPD, A_VSQRTPS, A_VSQRTSD, A_VSQRTSS,
  242. A_VSTMXCSR, A_VSUBPD, A_VSUBPS, A_VSUBSD, A_VSUBSS, A_VTESTPD, A_VTESTPS,
  243. A_VUCOMISD, A_VUCOMISS, A_VUNPCKHPD, A_VUNPCKHPS, A_VUNPCKLPD, A_VUNPCKLPS,
  244. A_VXORPD, A_VXORPS, A_VZEROALL, A_VZEROUPPER, A_ANDN, A_BEXTR, A_TZCNT, A_BZHI,
  245. A_MULX, A_PDEP, A_PEXT, A_RORX, A_SARX, A_SHLX, A_SHRX, A_VBROADCASTI128,
  246. A_VEXTRACTI128, A_VINSERTI128, A_VPBLENDD, A_VPBROADCASTB, A_VPBROADCASTD,
  247. A_VPBROADCASTQ, A_VPBROADCASTW, A_VPERM2I128, A_VPERMD);
  248. const
  249. ExtremeRange1Expected: array[0..1023] of Byte = (
  250. $00, $00, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 0 }
  251. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 16 }
  252. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 32 }
  253. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 48 }
  254. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 64 }
  255. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 80 }
  256. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 96 }
  257. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 112 }
  258. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 128 }
  259. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $09, { 144 }
  260. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 160 }
  261. $00, $00, $00, $00, $00, $00, $00, $02, $00, $00, $00, $08, $00, $00, $03, $03, { 176 }
  262. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 192 }
  263. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 208 }
  264. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 224 }
  265. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 240 }
  266. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 256 }
  267. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 272 }
  268. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 288 }
  269. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $0B, $00, $00, $00, $00, { 304 }
  270. $00, $00, $00, $00, $00, $00, $00, $00, $00, $0B, $00, $00, $00, $00, $00, $00, { 320 }
  271. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $0A, $00, $00, $00, $00, $00, { 336 }
  272. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 352 }
  273. $00, $00, $00, $00, $00, $00, $00, $00, $00, $0C, $00, $00, $00, $00, $00, $00, { 368 }
  274. $00, $00, $07, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 384 }
  275. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 400 }
  276. $00, $00, $00, $00, $00, $05, $00, $00, $00, $00, $00, $00, $08, $05, $00, $07, { 416 }
  277. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 432 }
  278. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 448 }
  279. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 464 }
  280. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 480 }
  281. $07, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 496 }
  282. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 512 }
  283. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $05, $00, $00, $00, $05, { 528 }
  284. $00, $07, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 544 }
  285. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 560 }
  286. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 576 }
  287. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 592 }
  288. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 608 }
  289. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 624 }
  290. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 640 }
  291. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 656 }
  292. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $06, $06, $00, $00, $00, $00, { 672 }
  293. $00, $00, $00, $00, $00, $00, $06, $06, $00, $00, $00, $00, $00, $00, $00, $00, { 688 }
  294. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 704 }
  295. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 720 }
  296. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 736 }
  297. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 752 }
  298. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 768 }
  299. $00, $00, $00, $00, $00, $00, $00, $06, $06, $00, $00, $00, $00, $00, $00, $00, { 784 }
  300. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 800 }
  301. $04, $04, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 816 }
  302. $00, $00, $00, $08, $00, $00, $08, $04, $04, $00, $00, $00, $06, $06, $06, $06, { 832 }
  303. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 848 }
  304. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 864 }
  305. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 880 }
  306. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 896 }
  307. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 912 }
  308. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 928 }
  309. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 944 }
  310. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 960 }
  311. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $06, $06, $00, { 976 }
  312. $00, $00, $00, $00, $00, $00, $00, $06, $06, $00, $00, $00, $00, $00, $00, $00, { 992 }
  313. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 { 1008 }
  314. );
  315. ExtremeRange2Expected: array[0..1023] of Byte = (
  316. $00, $00, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 0 }
  317. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 16 }
  318. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 32 }
  319. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 48 }
  320. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 64 }
  321. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 80 }
  322. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 96 }
  323. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 112 }
  324. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 128 }
  325. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $09, { 144 }
  326. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 160 }
  327. $00, $00, $00, $00, $00, $00, $00, $02, $00, $00, $00, $26, $00, $00, $0D, $03, { 176 }
  328. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 192 }
  329. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 208 }
  330. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 224 }
  331. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 240 }
  332. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 256 }
  333. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 272 }
  334. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 288 }
  335. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $0B, $00, $00, $00, $00, { 304 }
  336. $00, $00, $00, $00, $00, $00, $00, $00, $00, $27, $00, $00, $00, $00, $00, $00, { 320 }
  337. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $0A, $00, $00, $00, $00, $00, { 336 }
  338. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 352 }
  339. $00, $00, $00, $00, $00, $00, $00, $00, $00, $0C, $00, $00, $00, $00, $00, $00, { 368 }
  340. $00, $00, $07, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 384 }
  341. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 400 }
  342. $00, $00, $00, $00, $00, $12, $00, $00, $00, $00, $00, $00, $08, $05, $00, $22, { 416 }
  343. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 432 }
  344. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 448 }
  345. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 464 }
  346. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 480 }
  347. $23, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 496 }
  348. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 512 }
  349. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $11, $00, $00, $00, $13, { 528 }
  350. $00, $21, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 544 }
  351. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 560 }
  352. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 576 }
  353. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 592 }
  354. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 608 }
  355. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 624 }
  356. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 640 }
  357. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 656 }
  358. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $1A, $1B, $00, $00, $00, $00, { 672 }
  359. $00, $00, $00, $00, $00, $00, $1C, $1D, $00, $00, $00, $00, $00, $00, $00, $00, { 688 }
  360. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 704 }
  361. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 720 }
  362. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 736 }
  363. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 752 }
  364. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 768 }
  365. $00, $00, $00, $00, $00, $00, $00, $14, $15, $00, $00, $00, $00, $00, $00, $00, { 784 }
  366. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 800 }
  367. $0F, $0E, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 816 }
  368. $00, $00, $00, $24, $00, $00, $25, $04, $10, $00, $00, $00, $18, $19, $1E, $1F, { 832 }
  369. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 848 }
  370. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 864 }
  371. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 880 }
  372. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 896 }
  373. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 912 }
  374. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 928 }
  375. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 944 }
  376. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 960 }
  377. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $16, $17, $00, { 976 }
  378. $00, $00, $00, $00, $00, $00, $00, $20, $06, $00, $00, $00, $00, $00, $00, $00, { 992 }
  379. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 { 1008 }
  380. );
  381. ExtremeRange3Expected: array[0..1023] of Byte = (
  382. $00, $00, $44, $01, $3F, $40, $00, $00, $00, $41, $42, $00, $00, $00, $00, $00, { 0 }
  383. $00, $00, $00, $45, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 16 }
  384. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 32 }
  385. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 48 }
  386. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 64 }
  387. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 80 }
  388. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 96 }
  389. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 112 }
  390. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 128 }
  391. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $09, { 144 }
  392. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 160 }
  393. $00, $00, $00, $00, $00, $00, $00, $02, $00, $00, $00, $26, $00, $00, $0D, $03, { 176 }
  394. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 192 }
  395. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 208 }
  396. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 224 }
  397. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 240 }
  398. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 256 }
  399. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 272 }
  400. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 288 }
  401. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $0B, $00, $00, $00, $00, { 304 }
  402. $00, $00, $00, $00, $00, $00, $00, $00, $00, $27, $00, $00, $00, $00, $00, $00, { 320 }
  403. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $0A, $00, $00, $00, $00, $00, { 336 }
  404. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 352 }
  405. $00, $43, $00, $00, $00, $00, $00, $00, $00, $0C, $00, $00, $00, $00, $00, $00, { 368 }
  406. $00, $00, $07, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 384 }
  407. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 400 }
  408. $00, $00, $00, $00, $00, $12, $00, $00, $00, $00, $00, $00, $08, $05, $00, $22, { 416 }
  409. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 432 }
  410. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 448 }
  411. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 464 }
  412. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 480 }
  413. $23, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 496 }
  414. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 512 }
  415. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $11, $00, $00, $00, $13, { 528 }
  416. $00, $21, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 544 }
  417. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 560 }
  418. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 576 }
  419. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 592 }
  420. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $33, $34, $00, $00, $00, { 608 }
  421. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 624 }
  422. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 640 }
  423. $00, $00, $00, $2E, $2F, $30, $31, $32, $00, $00, $00, $00, $00, $00, $00, $00, { 656 }
  424. $00, $00, $00, $00, $00, $00, $00, $00, $2C, $2D, $1A, $1B, $00, $00, $35, $36, { 672 }
  425. $37, $38, $39, $3A, $00, $00, $1C, $1D, $00, $00, $00, $00, $29, $00, $00, $00, { 688 }
  426. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 704 }
  427. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 720 }
  428. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 736 }
  429. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 752 }
  430. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 768 }
  431. $00, $00, $00, $00, $00, $00, $00, $14, $15, $00, $00, $00, $00, $00, $00, $00, { 784 }
  432. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 800 }
  433. $0F, $0E, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 816 }
  434. $00, $00, $00, $24, $00, $00, $25, $04, $10, $00, $00, $00, $18, $19, $1E, $1F, { 832 }
  435. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 848 }
  436. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 864 }
  437. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 880 }
  438. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 896 }
  439. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 912 }
  440. $00, $00, $00, $00, $00, $00, $00, $00, $00, $3B, $3C, $3D, $3E, $00, $00, $00, { 928 }
  441. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 944 }
  442. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, { 960 }
  443. $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $16, $17, $00, { 976 }
  444. $00, $00, $00, $00, $00, $00, $00, $20, $06, $00, $00, $00, $00, $00, $00, $28, { 992 }
  445. $00, $00, $00, $00, $46, $47, $2A, $00, $00, $00, $00, $00, $00, $00, $00, $2B { 1008 }
  446. );
  447. { TTestAncestor }
  448. type
  449. TTestAncestor = class
  450. private
  451. FStartTime: Real;
  452. FEndTime: Real;
  453. FAvgTime: Real;
  454. procedure SetStartTime;
  455. procedure SetEndTime;
  456. protected
  457. procedure DoTestIteration(Iteration: Integer); virtual; abstract;
  458. public
  459. constructor Create; virtual;
  460. destructor Destroy; override;
  461. procedure Run;
  462. function TestTitle: shortstring; virtual; abstract;
  463. function WriteResults: Boolean; virtual; abstract;
  464. property RunTime: Real read FAvgTime;
  465. end;
  466. TTestClass = class of TTestAncestor;
  467. TByteTest = class(TTestAncestor)
  468. protected
  469. FResultStorage: array[Byte] of Byte;
  470. end;
  471. TWordTest = class(TTestAncestor)
  472. protected
  473. FResultStorage: array[Word] of Byte;
  474. end;
  475. TMappedTest = class(TByteTest)
  476. protected
  477. procedure DoMapping(Index, Input: Integer); virtual; abstract;
  478. end;
  479. TCompleteByteRange = class(TMappedTest)
  480. protected
  481. procedure DoTestIteration(Iteration: Integer); override;
  482. procedure DoMapping(Index, Input: Integer); override;
  483. public
  484. function TestTitle: shortstring; override;
  485. function WriteResults: Boolean; override;
  486. end;
  487. TCompleteByteRangeFirstWeighted = class(TCompleteByteRange)
  488. protected
  489. procedure DoTestIteration(Iteration: Integer); override;
  490. public
  491. function TestTitle: shortstring; override;
  492. function WriteResults: Boolean; override;
  493. end;
  494. TCompleteByteRangeLastWeighted = class(TCompleteByteRange)
  495. protected
  496. procedure DoTestIteration(Iteration: Integer); override;
  497. public
  498. function TestTitle: shortstring; override;
  499. function WriteResults: Boolean; override;
  500. end;
  501. TAlmostFullByteRange = class(TMappedTest)
  502. protected
  503. procedure DoTestIteration(Iteration: Integer); override;
  504. procedure DoMapping(Index, Input: Integer); override;
  505. public
  506. function TestTitle: shortstring; override;
  507. function WriteResults: Boolean; override;
  508. end;
  509. TAlmostFullByteRangeFirstWeighted = class(TAlmostFullByteRange)
  510. protected
  511. procedure DoTestIteration(Iteration: Integer); override;
  512. public
  513. function TestTitle: shortstring; override;
  514. function WriteResults: Boolean; override;
  515. end;
  516. TAlmostFullByteRangeLastWeighted = class(TAlmostFullByteRange)
  517. protected
  518. procedure DoTestIteration(Iteration: Integer); override;
  519. public
  520. function TestTitle: shortstring; override;
  521. function WriteResults: Boolean; override;
  522. end;
  523. TSingleEntryWithDefault = class(TByteTest)
  524. protected
  525. procedure DoTestIteration(Iteration: Integer); override;
  526. public
  527. function TestTitle: shortstring; override;
  528. function WriteResults: Boolean; override;
  529. end;
  530. TSingleEntryWithDefaultUnlikely = class(TByteTest)
  531. protected
  532. procedure DoTestIteration(Iteration: Integer); override;
  533. public
  534. function TestTitle: shortstring; override;
  535. function WriteResults: Boolean; override;
  536. end;
  537. TSingleEntryWithDefaultWeighted = class(TByteTest)
  538. protected
  539. procedure DoTestIteration(Iteration: Integer); override;
  540. public
  541. function TestTitle: shortstring; override;
  542. function WriteResults: Boolean; override;
  543. end;
  544. TSingleEntryWithElse = class(TSingleEntryWithDefault)
  545. protected
  546. procedure DoTestIteration(Iteration: Integer); override;
  547. public
  548. function TestTitle: shortstring; override;
  549. end;
  550. TSingleEntryWithElseUnlikely = class(TSingleEntryWithDefaultUnlikely)
  551. protected
  552. procedure DoTestIteration(Iteration: Integer); override;
  553. public
  554. function TestTitle: shortstring; override;
  555. end;
  556. TSingleEntryWithElseWeighted = class(TSingleEntryWithDefaultWeighted)
  557. protected
  558. procedure DoTestIteration(Iteration: Integer); override;
  559. public
  560. function TestTitle: shortstring; override;
  561. end;
  562. TSingleEntryAtZeroWithElse = class(TByteTest)
  563. protected
  564. procedure DoTestIteration(Iteration: Integer); override;
  565. public
  566. function TestTitle: shortstring; override;
  567. function WriteResults: Boolean; override;
  568. end;
  569. TSingleEntryAtMinus1WithDefault = class(TByteTest)
  570. protected
  571. procedure DoTestIteration(Iteration: Integer); override;
  572. public
  573. function TestTitle: shortstring; override;
  574. function WriteResults: Boolean; override;
  575. end;
  576. TSingleEntryAtMinus4WithElse = class(TByteTest)
  577. protected
  578. procedure DoTestIteration(Iteration: Integer); override;
  579. public
  580. function TestTitle: shortstring; override;
  581. function WriteResults: Boolean; override;
  582. end;
  583. TSingleEntryWith0To5RangeWithElse = class(TByteTest)
  584. protected
  585. procedure DoTestIteration(Iteration: Integer); override;
  586. public
  587. function TestTitle: shortstring; override;
  588. function WriteResults: Boolean; override;
  589. end;
  590. TSingleEntryWith0To50RangeWithElse = class(TByteTest)
  591. protected
  592. procedure DoTestIteration(Iteration: Integer); override;
  593. public
  594. function TestTitle: shortstring; override;
  595. function WriteResults: Boolean; override;
  596. end;
  597. TSingleEntryWith1To5RangeWithElse = class(TByteTest)
  598. protected
  599. procedure DoTestIteration(Iteration: Integer); override;
  600. public
  601. function TestTitle: shortstring; override;
  602. function WriteResults: Boolean; override;
  603. end;
  604. TSingleEntryWith1To50RangeWithElse = class(TByteTest)
  605. protected
  606. procedure DoTestIteration(Iteration: Integer); override;
  607. public
  608. function TestTitle: shortstring; override;
  609. function WriteResults: Boolean; override;
  610. end;
  611. TSingleEntryWithMinus1To5RangeWithElse = class(TByteTest)
  612. protected
  613. procedure DoTestIteration(Iteration: Integer); override;
  614. public
  615. function TestTitle: shortstring; override;
  616. function WriteResults: Boolean; override;
  617. end;
  618. TSingleEntryWithMinus1To50RangeWithElse = class(TByteTest)
  619. protected
  620. procedure DoTestIteration(Iteration: Integer); override;
  621. public
  622. function TestTitle: shortstring; override;
  623. function WriteResults: Boolean; override;
  624. end;
  625. TExtremeRange1 = class(TWordTest)
  626. protected
  627. procedure DoTestIteration(Iteration: Integer); override;
  628. public
  629. function TestTitle: shortstring; override;
  630. function WriteResults: Boolean; override;
  631. end;
  632. TExtremeRange2 = class(TWordTest)
  633. protected
  634. procedure DoTestIteration(Iteration: Integer); override;
  635. public
  636. function TestTitle: shortstring; override;
  637. function WriteResults: Boolean; override;
  638. end;
  639. TExtremeRange3 = class(TWordTest)
  640. protected
  641. procedure DoTestIteration(Iteration: Integer); override;
  642. public
  643. function TestTitle: shortstring; override;
  644. function WriteResults: Boolean; override;
  645. end;
  646. TExtremeRange4 = class(TWordTest)
  647. protected
  648. procedure DoTestIteration(Iteration: Integer); override;
  649. public
  650. function TestTitle: shortstring; override;
  651. function WriteResults: Boolean; override;
  652. end;
  653. TSparseDataTest1 = class(TWordTest)
  654. protected
  655. procedure DoCaseBlock(Index: Integer; Input: TInstructionSet); inline;
  656. end;
  657. TSparseDataEqual1 = class(TSparseDataTest1)
  658. protected
  659. procedure DoTestIteration(Iteration: Integer); override;
  660. public
  661. function TestTitle: shortstring; override;
  662. function WriteResults: Boolean; override;
  663. end;
  664. TSparseDataMOVWeighted1 = class(TSparseDataTest1)
  665. protected
  666. procedure DoTestIteration(Iteration: Integer); override;
  667. public
  668. function TestTitle: shortstring; override;
  669. function WriteResults: Boolean; override;
  670. end;
  671. TSparseDataMidpointWeighted1 = class(TSparseDataTest1)
  672. protected
  673. procedure DoTestIteration(Iteration: Integer); override;
  674. public
  675. function TestTitle: shortstring; override;
  676. function WriteResults: Boolean; override;
  677. end;
  678. TSparseDataTest2 = class(TWordTest)
  679. protected
  680. procedure DoCaseBlock(Index: Integer; Input: TInstructionSet); inline;
  681. end;
  682. TSparseDataEqual2 = class(TSparseDataTest2)
  683. protected
  684. procedure DoTestIteration(Iteration: Integer); override;
  685. public
  686. function TestTitle: shortstring; override;
  687. function WriteResults: Boolean; override;
  688. end;
  689. TSparseDataMOVWeighted2 = class(TSparseDataTest2)
  690. protected
  691. procedure DoTestIteration(Iteration: Integer); override;
  692. public
  693. function TestTitle: shortstring; override;
  694. function WriteResults: Boolean; override;
  695. end;
  696. TSparseDataMidpointWeighted2 = class(TSparseDataTest2)
  697. protected
  698. procedure DoTestIteration(Iteration: Integer); override;
  699. public
  700. function TestTitle: shortstring; override;
  701. function WriteResults: Boolean; override;
  702. end;
  703. TSparseDataTest3 = class(TWordTest)
  704. protected
  705. procedure DoCaseBlock(Index: Integer; Input: TInstructionSet); inline;
  706. end;
  707. TSparseDataEqual3 = class(TSparseDataTest3)
  708. protected
  709. procedure DoTestIteration(Iteration: Integer); override;
  710. public
  711. function TestTitle: shortstring; override;
  712. function WriteResults: Boolean; override;
  713. end;
  714. TSparseDataMOVWeighted3 = class(TSparseDataTest3)
  715. protected
  716. procedure DoTestIteration(Iteration: Integer); override;
  717. public
  718. function TestTitle: shortstring; override;
  719. function WriteResults: Boolean; override;
  720. end;
  721. TSparseDataMidpointWeighted3 = class(TSparseDataTest3)
  722. protected
  723. procedure DoTestIteration(Iteration: Integer); override;
  724. public
  725. function TestTitle: shortstring; override;
  726. function WriteResults: Boolean; override;
  727. end;
  728. TLinearListDependsOnInput = class(TByteTest)
  729. protected
  730. procedure DoTestIteration(Iteration: Integer); override;
  731. public
  732. function TestTitle: shortstring; override;
  733. function WriteResults: Boolean; override;
  734. end;
  735. TCStyleCascade = class(TByteTest)
  736. protected
  737. procedure DoTestIteration(Iteration: Integer); override;
  738. public
  739. function TestTitle: shortstring; override;
  740. function WriteResults: Boolean; override;
  741. end;
  742. { TTestAncestor }
  743. constructor TTestAncestor.Create;
  744. begin
  745. FStartTime := 0;
  746. FEndTime := 0;
  747. FAvgTime := 0;
  748. end;
  749. destructor TTestAncestor.Destroy;
  750. begin
  751. inherited Destroy;
  752. end;
  753. procedure TTestAncestor.SetStartTime;
  754. begin
  755. FStartTime := GetRealTime();
  756. end;
  757. procedure TTestAncestor.SetEndTime;
  758. begin
  759. FEndTime := GetRealTime();
  760. if FEndTime < FStartTime then { Happens if the test runs past midnight }
  761. FEndTime := FEndTime + 86400.0;
  762. end;
  763. procedure TTestAncestor.Run;
  764. var
  765. X: Integer;
  766. begin
  767. SetStartTime;
  768. for X := 0 to ITERATIONS - 1 do
  769. DoTestIteration(X);
  770. SetEndTime;
  771. FAvgTime := FEndTime - FStartTime;
  772. end;
  773. { TCompleteByteRange }
  774. function TCompleteByteRange.TestTitle: shortstring;
  775. begin
  776. Result := 'Byte domain, entirely covered; equal polling';
  777. end;
  778. function TCompleteByteRange.WriteResults: Boolean;
  779. var
  780. X: Byte;
  781. begin
  782. Result := True;
  783. for X := 0 to 255 do
  784. if FResultStorage[X] <> AES_S_Box[X] then
  785. begin
  786. WriteLn('FAIL - Index ', X, '; expected $', hexstr(AES_S_Box[X], 2), ' got $', hexstr(FResultStorage[X], 2));
  787. Result := False;
  788. Exit;
  789. end;
  790. end;
  791. procedure TCompleteByteRange.DoMapping(Index, Input: Integer);
  792. begin
  793. case Input of
  794. { First row of S-Box (except zero) }
  795. $00: FResultStorage[Index] := $63;
  796. $01: FResultStorage[Index] := $7c;
  797. $02: FResultStorage[Index] := $77;
  798. $03: FResultStorage[Index] := $7b;
  799. $04: FResultStorage[Index] := $f2;
  800. $05: FResultStorage[Index] := $6b;
  801. $06: FResultStorage[Index] := $6f;
  802. $07: FResultStorage[Index] := $c5;
  803. $08: FResultStorage[Index] := $30;
  804. $09: FResultStorage[Index] := $01;
  805. $0A: FResultStorage[Index] := $67;
  806. $0B: FResultStorage[Index] := $2b;
  807. $0C: FResultStorage[Index] := $fe;
  808. $0D: FResultStorage[Index] := $d7;
  809. $0E: FResultStorage[Index] := $ab;
  810. $0F: FResultStorage[Index] := $76;
  811. {Last row of S-Box }
  812. $F0: FResultStorage[Index] := $8c;
  813. $F1: FResultStorage[Index] := $a1;
  814. $F2: FResultStorage[Index] := $89;
  815. $F3: FResultStorage[Index] := $0d;
  816. $F4: FResultStorage[Index] := $bf;
  817. $F5: FResultStorage[Index] := $e6;
  818. $F6: FResultStorage[Index] := $42;
  819. $F7: FResultStorage[Index] := $68;
  820. $F8: FResultStorage[Index] := $41;
  821. $F9: FResultStorage[Index] := $99;
  822. $FA: FResultStorage[Index] := $2d;
  823. $FB: FResultStorage[Index] := $0f;
  824. $FC: FResultStorage[Index] := $b0;
  825. $FD: FResultStorage[Index] := $54;
  826. $FE: FResultStorage[Index] := $bb;
  827. $FF: FResultStorage[Index] := $16;
  828. { Everything else }
  829. $10..$EF: FResultStorage[Index] := AES_S_Box[Input];
  830. end;
  831. end;
  832. procedure TCompleteByteRange.DoTestIteration(Iteration: Integer);
  833. var
  834. Input: Byte;
  835. begin
  836. Input := Iteration and $FF;
  837. DoMapping(Input, Input);
  838. end;
  839. { TCompleteByteRangeFirstWeighted }
  840. function TCompleteByteRangeFirstWeighted.TestTitle: shortstring;
  841. begin
  842. Result := 'Byte domain, entirely covered; first weighted';
  843. end;
  844. function TCompleteByteRangeFirstWeighted.WriteResults: Boolean;
  845. var
  846. X: Byte;
  847. begin
  848. Result := True;
  849. for X := 0 to 255 do
  850. if FResultStorage[X] <> FirstWeighted[X] then
  851. begin
  852. WriteLn('FAIL - Index ', X, '; expected $', hexstr(FirstWeighted[X], 2), ' got $', hexstr(FResultStorage[X], 2));
  853. Result := False;
  854. Exit;
  855. end;
  856. end;
  857. procedure TCompleteByteRangeFirstWeighted.DoTestIteration(Iteration: Integer);
  858. var
  859. Input: Byte;
  860. begin
  861. Input := Iteration and $FF;
  862. if Input < $C0 then
  863. DoMapping(Input, 0)
  864. else
  865. DoMapping(Input, Input);
  866. end;
  867. { TCompleteByteRangeLastWeighted }
  868. function TCompleteByteRangeLastWeighted.TestTitle: shortstring;
  869. begin
  870. Result := 'Byte domain, entirely covered; last weighted';
  871. end;
  872. function TCompleteByteRangeLastWeighted.WriteResults: Boolean;
  873. var
  874. X: Byte;
  875. begin
  876. Result := True;
  877. for X := 0 to 255 do
  878. if FResultStorage[X] <> LastWeighted[X] then
  879. begin
  880. WriteLn('FAIL - Index ', X, '; expected $', hexstr(LastWeighted[X], 2), ' got $', hexstr(FResultStorage[X], 2));
  881. Result := False;
  882. Exit;
  883. end;
  884. end;
  885. procedure TCompleteByteRangeLastWeighted.DoTestIteration(Iteration: Integer);
  886. var
  887. Input: Byte;
  888. begin
  889. Input := Iteration and $FF;
  890. if Input < $C0 then
  891. DoMapping(Input, $FF)
  892. else
  893. DoMapping(Input, Input);
  894. end;
  895. { TAlmostFullByteRange }
  896. function TAlmostFullByteRange.TestTitle: shortstring;
  897. begin
  898. Result := 'Byte domain, almost entirely covered; equal polling';
  899. end;
  900. function TAlmostFullByteRange.WriteResults: Boolean;
  901. var
  902. X: Byte;
  903. begin
  904. Result := True;
  905. for X := 0 to 255 do
  906. if FResultStorage[X] <> AlmostFullExpected[X] then
  907. begin
  908. WriteLn('FAIL - Index ', X, '; expected $', hexstr(AlmostFullExpected[X], 2), ' got $', hexstr(FResultStorage[X], 2));
  909. Result := False;
  910. Exit;
  911. end;
  912. end;
  913. procedure TAlmostFullByteRange.DoMapping(Index, Input: Integer);
  914. begin
  915. case Input of
  916. { First row of S-Box }
  917. $00: FResultStorage[Index] := $63;
  918. $01: FResultStorage[Index] := $7c;
  919. $02: FResultStorage[Index] := $77;
  920. $03: FResultStorage[Index] := $7b;
  921. $04: FResultStorage[Index] := $f2;
  922. $05: FResultStorage[Index] := $6b;
  923. $06: FResultStorage[Index] := $6f;
  924. $07: FResultStorage[Index] := $c5;
  925. $08: FResultStorage[Index] := $30;
  926. $09: FResultStorage[Index] := $01;
  927. $0A: FResultStorage[Index] := $67;
  928. $0B: FResultStorage[Index] := $2b;
  929. $0C: FResultStorage[Index] := $fe;
  930. $0D: FResultStorage[Index] := $d7;
  931. $0E: FResultStorage[Index] := $ab;
  932. $0F: FResultStorage[Index] := $76;
  933. { Other rows }
  934. $10..$3F: FResultStorage[Index] := AES_S_Box[Input];
  935. $60..$FF: FResultStorage[Index] := AES_S_Box[Input];
  936. { Zeroed rows }
  937. else FResultStorage[Index] := $00;
  938. end;
  939. end;
  940. procedure TAlmostFullByteRange.DoTestIteration(Iteration: Integer);
  941. var
  942. Input: Byte;
  943. begin
  944. Input := Iteration and $FF;
  945. DoMapping(Input, Input);
  946. end;
  947. { TAlmostFullByteRangeFirstWeighted }
  948. function TAlmostFullByteRangeFirstWeighted.TestTitle: shortstring;
  949. begin
  950. Result := 'Byte domain, almost entirely covered; first weighted';
  951. end;
  952. function TAlmostFullByteRangeFirstWeighted.WriteResults: Boolean;
  953. var
  954. X: Byte;
  955. begin
  956. Result := True;
  957. for X := 0 to 255 do
  958. if FResultStorage[X] <> FirstWeighted[X] then
  959. begin
  960. WriteLn('FAIL - Index ', X, '; expected $', hexstr(FirstWeighted[X], 2), ' got $', hexstr(FResultStorage[X], 2));
  961. Result := False;
  962. Exit;
  963. end;
  964. end;
  965. procedure TAlmostFullByteRangeFirstWeighted.DoTestIteration(Iteration: Integer);
  966. var
  967. Input: Byte;
  968. begin
  969. Input := Iteration and $FF;
  970. if Input < $C0 then
  971. DoMapping(Input, 0)
  972. else
  973. DoMapping(Input, Input);
  974. end;
  975. { TAlmostFullByteRangeLastWeighted }
  976. function TAlmostFullByteRangeLastWeighted.TestTitle: shortstring;
  977. begin
  978. Result := 'Byte domain, almost entirely covered; last weighted';
  979. end;
  980. function TAlmostFullByteRangeLastWeighted.WriteResults: Boolean;
  981. var
  982. X: Byte;
  983. begin
  984. Result := True;
  985. for X := 0 to 255 do
  986. if FResultStorage[X] <> LastWeighted[X] then
  987. begin
  988. WriteLn('FAIL - Index ', X, '; expected $', hexstr(LastWeighted[X], 2), ' got $', hexstr(FResultStorage[X], 2));
  989. Result := False;
  990. Exit;
  991. end;
  992. end;
  993. procedure TAlmostFullByteRangeLastWeighted.DoTestIteration(Iteration: Integer);
  994. var
  995. Input: Byte;
  996. begin
  997. Input := Iteration and $FF;
  998. if Input < $C0 then
  999. DoMapping(Input, $FF)
  1000. else
  1001. DoMapping(Input, Input);
  1002. end;
  1003. { TSingleEntryWithDefault }
  1004. function TSingleEntryWithDefault.TestTitle: shortstring;
  1005. begin
  1006. Result := 'Single entry with default value; 1/256 match chance';
  1007. end;
  1008. function TSingleEntryWithDefault.WriteResults: Boolean;
  1009. var
  1010. X: Byte;
  1011. begin
  1012. Result := True;
  1013. for X := 0 to 255 do
  1014. if FResultStorage[X] <> IIf(X = 71, 1, 0) then
  1015. begin
  1016. WriteLn('FAIL - Index ', X, '; expected $', hexstr(IIf(X = 71, 1, 0), 2), ' got $', hexstr(FResultStorage[X], 2));
  1017. Result := False;
  1018. Exit;
  1019. end;
  1020. end;
  1021. procedure TSingleEntryWithDefault.DoTestIteration(Iteration: Integer);
  1022. var
  1023. Index: Byte;
  1024. begin
  1025. Index := Iteration and $FF;
  1026. FResultStorage[Index] := 0;
  1027. case Index of
  1028. 71: FResultStorage[Index] := 1;
  1029. end;
  1030. end;
  1031. { TSingleEntryWithDefaultUnlikely }
  1032. function TSingleEntryWithDefaultUnlikely.TestTitle: shortstring;
  1033. begin
  1034. Result := 'Single entry with default value; 75% match chance';
  1035. end;
  1036. function TSingleEntryWithDefaultUnlikely.WriteResults: Boolean;
  1037. var
  1038. X: Byte;
  1039. begin
  1040. Result := True;
  1041. for X := 0 to 255 do
  1042. if FResultStorage[X] <> IIf(((X and $2) shr 1) or (X and $1) = 1, 1, 0) then
  1043. begin
  1044. WriteLn('FAIL - Index ', X, '; expected $', hexstr(IIf(((X and $2) shr 1) or (X and $1) = 1, 1, 0), 2), ' got $', hexstr(FResultStorage[X], 2));
  1045. Result := False;
  1046. Exit;
  1047. end;
  1048. end;
  1049. procedure TSingleEntryWithDefaultUnlikely.DoTestIteration(Iteration: Integer);
  1050. var
  1051. Index: Byte;
  1052. begin
  1053. Index := Iteration and $FF;
  1054. FResultStorage[Index] := 0;
  1055. case ((Index and $2) shr 1) or (Index and $1) of
  1056. 1: FResultStorage[Index] := 1;
  1057. end;
  1058. end;
  1059. { TSingleEntryWithDefaultWeighted }
  1060. function TSingleEntryWithDefaultWeighted.TestTitle: shortstring;
  1061. begin
  1062. Result := 'Single entry with default value; 25% match chance';
  1063. end;
  1064. function TSingleEntryWithDefaultWeighted.WriteResults: Boolean;
  1065. var
  1066. X: Byte;
  1067. begin
  1068. Result := True;
  1069. for X := 0 to 255 do
  1070. if FResultStorage[X] <> IIf(((X and $2) shr 1) and (X and $1) = 1, 1, 0) then
  1071. begin
  1072. WriteLn('FAIL - Index ', X, '; expected $', hexstr(IIf(((X and $2) shr 1) and (X and $1) = 1, 1, 0), 2), ' got $', hexstr(FResultStorage[X], 2));
  1073. Result := False;
  1074. Exit;
  1075. end;
  1076. end;
  1077. procedure TSingleEntryWithDefaultWeighted.DoTestIteration(Iteration: Integer);
  1078. var
  1079. Index: Byte;
  1080. begin
  1081. Index := Iteration and $FF;
  1082. FResultStorage[Index] := 0;
  1083. case ((Index and $2) shr 1) and (Index and $1) of
  1084. 1: FResultStorage[Index] := 1;
  1085. end;
  1086. end;
  1087. { TSingleEntryWithElse }
  1088. function TSingleEntryWithElse.TestTitle: shortstring;
  1089. begin
  1090. Result := 'Single entry with else block; 1/256 match chance';
  1091. end;
  1092. procedure TSingleEntryWithElse.DoTestIteration(Iteration: Integer);
  1093. var
  1094. Index: Byte;
  1095. begin
  1096. Index := Iteration and $FF;
  1097. { This helps catch errors where all branches, including else, are skipped }
  1098. FResultStorage[Index] := $FF;
  1099. case Index of
  1100. 71: FResultStorage[Index] := 1;
  1101. else FResultStorage[Index] := 0;
  1102. end;
  1103. end;
  1104. { TSingleEntryWithElseUnlikely }
  1105. function TSingleEntryWithElseUnlikely.TestTitle: shortstring;
  1106. begin
  1107. Result := 'Single entry with else block; 75% match chance';
  1108. end;
  1109. procedure TSingleEntryWithElseUnlikely.DoTestIteration(Iteration: Integer);
  1110. var
  1111. Index: Byte;
  1112. begin
  1113. Index := Iteration and $FF;
  1114. { This helps catch errors where all branches, including else, are skipped }
  1115. FResultStorage[Index] := $FF;
  1116. case ((Index and $2) shr 1) or (Index and $1) of
  1117. 1: FResultStorage[Index] := 1;
  1118. else FResultStorage[Index] := 0;
  1119. end;
  1120. end;
  1121. { TSingleEntryWithElseWeighted }
  1122. function TSingleEntryWithElseWeighted.TestTitle: shortstring;
  1123. begin
  1124. Result := 'Single entry with else block; 25% match chance';
  1125. end;
  1126. procedure TSingleEntryWithElseWeighted.DoTestIteration(Iteration: Integer);
  1127. var
  1128. Index: Byte;
  1129. begin
  1130. Index := Iteration and $FF;
  1131. { This helps catch errors where all branches, including else, are skipped }
  1132. FResultStorage[Index] := $FF;
  1133. case ((Index and $2) shr 1) and (Index and $1) of
  1134. 1: FResultStorage[Index] := 1;
  1135. else FResultStorage[Index] := 0;
  1136. end;
  1137. end;
  1138. { TSingleEntryAtZeroWithElse }
  1139. function TSingleEntryAtZeroWithElse.TestTitle: shortstring;
  1140. begin
  1141. Result := 'Single entry of "0:" and else block';
  1142. end;
  1143. function TSingleEntryAtZeroWithElse.WriteResults: Boolean;
  1144. var
  1145. X: Word;
  1146. begin
  1147. Result := True;
  1148. if FResultStorage[0] <> 1 then
  1149. begin
  1150. WriteLn('FAIL - Index 0; expected $01 got $', hexstr(FResultStorage[0], 2));
  1151. Result := False;
  1152. Exit;
  1153. end;
  1154. for X := 1 to $FF do
  1155. if FResultStorage[X] <> 0 then
  1156. begin
  1157. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  1158. Result := False;
  1159. Exit;
  1160. end;
  1161. end;
  1162. procedure TSingleEntryAtZeroWithElse.DoTestIteration(Iteration: Integer);
  1163. var
  1164. Index: Byte;
  1165. begin
  1166. Index := Iteration and $FF;
  1167. { This helps catch errors where all branches, including else, are skipped }
  1168. FResultStorage[Index] := $FF;
  1169. case Index of
  1170. 0: FResultStorage[Index] := 1;
  1171. else FResultStorage[Index] := 0;
  1172. end;
  1173. end;
  1174. { TSingleEntryAtMinus1WithDefault }
  1175. function TSingleEntryAtMinus1WithDefault.TestTitle: shortstring;
  1176. begin
  1177. Result := 'Single entry of "-1:" with default value';
  1178. end;
  1179. function TSingleEntryAtMinus1WithDefault.WriteResults: Boolean;
  1180. var
  1181. X: Word;
  1182. begin
  1183. Result := True;
  1184. for X := 0 to $FE do
  1185. if FResultStorage[X] <> 0 then
  1186. begin
  1187. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  1188. Result := False;
  1189. Exit;
  1190. end;
  1191. if FResultStorage[255] <> 1 then
  1192. begin
  1193. WriteLn('FAIL - Index 255; expected $01 got $', hexstr(FResultStorage[0], 2));
  1194. Result := False;
  1195. Exit;
  1196. end;
  1197. end;
  1198. procedure TSingleEntryAtMinus1WithDefault.DoTestIteration(Iteration: Integer);
  1199. var
  1200. Index: ShortInt;
  1201. begin
  1202. Index := ShortInt(Iteration and $FF);
  1203. FResultStorage[Byte(Index)] := 0;
  1204. case Index of
  1205. -1: FResultStorage[255] := 1;
  1206. end;
  1207. end;
  1208. { TSingleEntryAtMinus4WithElse }
  1209. function TSingleEntryAtMinus4WithElse.TestTitle: shortstring;
  1210. begin
  1211. Result := 'Single entry of "-4:" and else block';
  1212. end;
  1213. function TSingleEntryAtMinus4WithElse.WriteResults: Boolean;
  1214. var
  1215. X: Word;
  1216. begin
  1217. Result := True;
  1218. for X := 0 to 251 do
  1219. if FResultStorage[X] <> 0 then
  1220. begin
  1221. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  1222. Result := False;
  1223. Exit;
  1224. end;
  1225. if FResultStorage[252] <> 1 then
  1226. begin
  1227. WriteLn('FAIL - Index 0; expected $01 got $', hexstr(FResultStorage[252], 2));
  1228. Result := False;
  1229. Exit;
  1230. end;
  1231. for X := 253 to 255 do
  1232. if FResultStorage[X] <> 0 then
  1233. begin
  1234. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  1235. Result := False;
  1236. Exit;
  1237. end;
  1238. end;
  1239. procedure TSingleEntryAtMinus4WithElse.DoTestIteration(Iteration: Integer);
  1240. var
  1241. Index: ShortInt;
  1242. begin
  1243. Index := ShortInt(Iteration and $FF);
  1244. { This helps catch errors where all branches, including else, are skipped }
  1245. FResultStorage[Byte(Index)] := $FF;
  1246. case Index of
  1247. -4: FResultStorage[Byte(Index)] := 1;
  1248. else FResultStorage[Byte(Index)] := 0;
  1249. end;
  1250. end;
  1251. { TSingleEntryWith0To5RangeWithElse }
  1252. function TSingleEntryWith0To5RangeWithElse.TestTitle: shortstring;
  1253. begin
  1254. Result := 'Single entry of "0..5" and else block';
  1255. end;
  1256. function TSingleEntryWith0To5RangeWithElse.WriteResults: Boolean;
  1257. var
  1258. X: Word;
  1259. begin
  1260. Result := True;
  1261. for X := 0 to 5 do
  1262. if FResultStorage[X] <> 1 then
  1263. begin
  1264. WriteLn('FAIL - Index ', X, '; expected $01 got $', hexstr(FResultStorage[X], 2));
  1265. Result := False;
  1266. Exit;
  1267. end;
  1268. for X := 6 to $FF do
  1269. if FResultStorage[X] <> 0 then
  1270. begin
  1271. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  1272. Result := False;
  1273. Exit;
  1274. end;
  1275. end;
  1276. procedure TSingleEntryWith0To5RangeWithElse.DoTestIteration(Iteration: Integer);
  1277. var
  1278. Index: Byte;
  1279. begin
  1280. Index := Iteration and $FF;
  1281. { This helps catch errors where all branches, including else, are skipped }
  1282. FResultStorage[Index] := $FF;
  1283. case Index of
  1284. 0..5: FResultStorage[Index] := 1;
  1285. else FResultStorage[Index] := 0;
  1286. end;
  1287. end;
  1288. { TSingleEntryWith0To50RangeWithElse }
  1289. function TSingleEntryWith0To50RangeWithElse.TestTitle: shortstring;
  1290. begin
  1291. Result := 'Single entry of "0..50" and else block';
  1292. end;
  1293. function TSingleEntryWith0To50RangeWithElse.WriteResults: Boolean;
  1294. var
  1295. X: Word;
  1296. begin
  1297. Result := True;
  1298. for X := 0 to 50 do
  1299. if FResultStorage[X] <> 1 then
  1300. begin
  1301. WriteLn('FAIL - Index ', X, '; expected $01 got $', hexstr(FResultStorage[X], 2));
  1302. Result := False;
  1303. Exit;
  1304. end;
  1305. for X := 51 to $FF do
  1306. if FResultStorage[X] <> 0 then
  1307. begin
  1308. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  1309. Result := False;
  1310. Exit;
  1311. end;
  1312. end;
  1313. procedure TSingleEntryWith0To50RangeWithElse.DoTestIteration(Iteration: Integer);
  1314. var
  1315. Index: Byte;
  1316. begin
  1317. Index := Iteration and $FF;
  1318. { This helps catch errors where all branches, including else, are skipped }
  1319. FResultStorage[Index] := $FF;
  1320. case Index of
  1321. 0..50: FResultStorage[Index] := 1;
  1322. else FResultStorage[Index] := 0;
  1323. end;
  1324. end;
  1325. { TSingleEntryWith1To5RangeWithElse }
  1326. function TSingleEntryWith1To5RangeWithElse.TestTitle: shortstring;
  1327. begin
  1328. Result := 'Single entry of "1..5" and else block';
  1329. end;
  1330. function TSingleEntryWith1To5RangeWithElse.WriteResults: Boolean;
  1331. var
  1332. X: Word;
  1333. begin
  1334. Result := True;
  1335. if FResultStorage[0] <> 0 then
  1336. begin
  1337. WriteLn('FAIL - Index 0; expected $00 got $', hexstr(FResultStorage[0], 2));
  1338. Result := False;
  1339. Exit;
  1340. end;
  1341. for X := 1 to 5 do
  1342. if FResultStorage[X] <> 1 then
  1343. begin
  1344. WriteLn('FAIL - Index ', X, '; expected $01 got $', hexstr(FResultStorage[X], 2));
  1345. Result := False;
  1346. Exit;
  1347. end;
  1348. for X := 6 to $FF do
  1349. if FResultStorage[X] <> 0 then
  1350. begin
  1351. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  1352. Result := False;
  1353. Exit;
  1354. end;
  1355. end;
  1356. procedure TSingleEntryWith1To5RangeWithElse.DoTestIteration(Iteration: Integer);
  1357. var
  1358. Index: Byte;
  1359. begin
  1360. Index := Iteration and $FF;
  1361. { This helps catch errors where all branches, including else, are skipped }
  1362. FResultStorage[Index] := $FF;
  1363. case Index of
  1364. 1..5: FResultStorage[Index] := 1;
  1365. else FResultStorage[Index] := 0;
  1366. end;
  1367. end;
  1368. { TSingleEntryWith1To50RangeWithElse }
  1369. function TSingleEntryWith1To50RangeWithElse.TestTitle: shortstring;
  1370. begin
  1371. Result := 'Single entry of "1..50" and else block';
  1372. end;
  1373. function TSingleEntryWith1To50RangeWithElse.WriteResults: Boolean;
  1374. var
  1375. X: Word;
  1376. begin
  1377. Result := True;
  1378. if FResultStorage[0] <> 0 then
  1379. begin
  1380. WriteLn('FAIL - Index 0; expected $00 got $', hexstr(FResultStorage[0], 2));
  1381. Result := False;
  1382. Exit;
  1383. end;
  1384. for X := 1 to 50 do
  1385. if FResultStorage[X] <> 1 then
  1386. begin
  1387. WriteLn('FAIL - Index ', X, '; expected $01 got $', hexstr(FResultStorage[X], 2));
  1388. Result := False;
  1389. Exit;
  1390. end;
  1391. for X := 51 to $FF do
  1392. if FResultStorage[X] <> 0 then
  1393. begin
  1394. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  1395. Result := False;
  1396. Exit;
  1397. end;
  1398. end;
  1399. procedure TSingleEntryWith1To50RangeWithElse.DoTestIteration(Iteration: Integer);
  1400. var
  1401. Index: Byte;
  1402. begin
  1403. Index := Iteration and $FF;
  1404. { This helps catch errors where all branches, including else, are skipped }
  1405. FResultStorage[Index] := $FF;
  1406. case Index of
  1407. 1..50: FResultStorage[Index] := 1;
  1408. else FResultStorage[Index] := 0;
  1409. end;
  1410. end;
  1411. { TSingleEntryWithMinus1To5RangeWithElse }
  1412. function TSingleEntryWithMinus1To5RangeWithElse.TestTitle: shortstring;
  1413. begin
  1414. Result := 'Single entry of "-1..5" and else block';
  1415. end;
  1416. function TSingleEntryWithMinus1To5RangeWithElse.WriteResults: Boolean;
  1417. var
  1418. X: Word;
  1419. begin
  1420. Result := True;
  1421. for X := 0 to 5 do
  1422. if FResultStorage[X] <> 1 then
  1423. begin
  1424. WriteLn('FAIL - Index ', X, '; expected $01 got $', hexstr(FResultStorage[X], 2));
  1425. Result := False;
  1426. Exit;
  1427. end;
  1428. for X := 6 to $FE do
  1429. if FResultStorage[X] <> 0 then
  1430. begin
  1431. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  1432. Result := False;
  1433. Exit;
  1434. end;
  1435. if FResultStorage[$FF] <> 1 then
  1436. begin
  1437. WriteLn('FAIL - Index 255; expected $00 got $', hexstr(FResultStorage[0], 2));
  1438. Result := False;
  1439. Exit;
  1440. end;
  1441. end;
  1442. procedure TSingleEntryWithMinus1To5RangeWithElse.DoTestIteration(Iteration: Integer);
  1443. var
  1444. Index: ShortInt;
  1445. begin
  1446. Index := ShortInt(Iteration and $FF);
  1447. { This helps catch errors where all branches, including else, are skipped }
  1448. FResultStorage[Byte(Index)] := $FF;
  1449. case Index of
  1450. -1..5: FResultStorage[Byte(Index)] := 1;
  1451. else FResultStorage[Byte(Index)] := 0;
  1452. end;
  1453. end;
  1454. { TSingleEntryWithMinus1To50RangeWithElse }
  1455. function TSingleEntryWithMinus1To50RangeWithElse.TestTitle: shortstring;
  1456. begin
  1457. Result := 'Single entry of "-1..50" and else block';
  1458. end;
  1459. function TSingleEntryWithMinus1To50RangeWithElse.WriteResults: Boolean;
  1460. var
  1461. X: Word;
  1462. begin
  1463. Result := True;
  1464. for X := 0 to 50 do
  1465. if FResultStorage[X] <> 1 then
  1466. begin
  1467. WriteLn('FAIL - Index ', X, '; expected $01 got $', hexstr(FResultStorage[X], 2));
  1468. Result := False;
  1469. Exit;
  1470. end;
  1471. for X := 51 to $FE do
  1472. if FResultStorage[X] <> 0 then
  1473. begin
  1474. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  1475. Result := False;
  1476. Exit;
  1477. end;
  1478. if FResultStorage[$FF] <> 1 then
  1479. begin
  1480. WriteLn('FAIL - Index 255; expected $00 got $', hexstr(FResultStorage[0], 2));
  1481. Result := False;
  1482. Exit;
  1483. end;
  1484. end;
  1485. procedure TSingleEntryWithMinus1To50RangeWithElse.DoTestIteration(Iteration: Integer);
  1486. var
  1487. Index: ShortInt;
  1488. begin
  1489. Index := ShortInt(Iteration and $FF);
  1490. { This helps catch errors where all branches, including else, are skipped }
  1491. FResultStorage[Byte(Index)] := $FF;
  1492. case Index of
  1493. -1..50: FResultStorage[Byte(Index)] := 1;
  1494. else FResultStorage[Byte(Index)] := 0;
  1495. end;
  1496. end;
  1497. { TExtremeRange1 }
  1498. function TExtremeRange1.TestTitle: shortstring;
  1499. begin
  1500. Result := 'Two labels, one with extreme spread, equal polling';
  1501. end;
  1502. function TExtremeRange1.WriteResults: Boolean;
  1503. var
  1504. X: Word;
  1505. begin
  1506. Result := True;
  1507. if FResultStorage[0] <> 1 then
  1508. begin
  1509. WriteLn('FAIL - Index 0; expected $01 got $', hexstr(FResultStorage[0], 2));
  1510. Result := False;
  1511. Exit;
  1512. end;
  1513. for X := 1 to $FFFE do
  1514. if FResultStorage[X] <> 2 then
  1515. begin
  1516. WriteLn('FAIL - Index ', X, '; expected $02 got $', hexstr(FResultStorage[X], 2));
  1517. Result := False;
  1518. Exit;
  1519. end;
  1520. if FResultStorage[65535] <> 0 then
  1521. begin
  1522. WriteLn('FAIL - Index 65535; expected $02 got $', hexstr(FResultStorage[65535], 2));
  1523. Result := False;
  1524. Exit;
  1525. end;
  1526. end;
  1527. procedure TExtremeRange1.DoTestIteration(Iteration: Integer);
  1528. var
  1529. Index: Word;
  1530. begin
  1531. Index := Iteration and $FFFF;
  1532. FResultStorage[Index] := 0; { Covers $FFFF }
  1533. case Index of
  1534. 0:
  1535. FResultStorage[Index] := 1;
  1536. 1..$FFFE:
  1537. FResultStorage[Index] := 2;
  1538. end;
  1539. end;
  1540. { TExtremeRange2 }
  1541. function TExtremeRange2.TestTitle: shortstring;
  1542. begin
  1543. Result := 'Two labels, one with extreme spread, 50% else chance';
  1544. end;
  1545. function TExtremeRange2.WriteResults: Boolean;
  1546. var
  1547. X: Word;
  1548. begin
  1549. Result := True;
  1550. for X := 0 to $FFFF do
  1551. if FResultStorage[X] <> (X and $1) then
  1552. begin
  1553. WriteLn('FAIL - Index ', X, '; expected $', hexstr(X and $1, 2), ' got $', hexstr(FResultStorage[X], 2));
  1554. Result := False;
  1555. Exit;
  1556. end;
  1557. end;
  1558. procedure TExtremeRange2.DoTestIteration(Iteration: Integer);
  1559. var
  1560. Index, Input: Word;
  1561. begin
  1562. {$push}
  1563. {$r-}
  1564. Index := (Iteration and $FFFF);
  1565. Input := (Iteration and $1) - 1;
  1566. {$pop}
  1567. FResultStorage[Index] := 0; { Covers $FFFF }
  1568. case Input of
  1569. 0..$FFFD:
  1570. FResultStorage[Index] := 1;
  1571. $FFFE:
  1572. FResultStorage[Index] := 2;
  1573. end;
  1574. end;
  1575. { TExtremeRange3 }
  1576. function TExtremeRange3.TestTitle: shortstring;
  1577. begin
  1578. Result := 'Two labels, sparse values, equal polling across range';
  1579. end;
  1580. function TExtremeRange3.WriteResults: Boolean;
  1581. var
  1582. X: Word;
  1583. begin
  1584. Result := True;
  1585. if FResultStorage[0] <> 1 then
  1586. begin
  1587. WriteLn('FAIL - Index 0; expected $01 got $', hexstr(FResultStorage[0], 2));
  1588. Result := False;
  1589. Exit;
  1590. end;
  1591. for X := 1 to $FFFE do
  1592. if FResultStorage[X] <> 2 then
  1593. begin
  1594. WriteLn('FAIL - Index ', X, '; expected $02 got $', hexstr(FResultStorage[X], 2));
  1595. Result := False;
  1596. Exit;
  1597. end;
  1598. if FResultStorage[65535] <> 0 then
  1599. begin
  1600. WriteLn('FAIL - Index 65535; expected $02 got $', hexstr(FResultStorage[65535], 2));
  1601. Result := False;
  1602. Exit;
  1603. end;
  1604. end;
  1605. procedure TExtremeRange3.DoTestIteration(Iteration: Integer);
  1606. var
  1607. Index: Word;
  1608. begin
  1609. Index := Iteration and $FFFF;
  1610. FResultStorage[Index] := 2; { Covers 1..$FFFE }
  1611. case Index of
  1612. 0:
  1613. FResultStorage[Index] := 1;
  1614. $FFFF:
  1615. FResultStorage[Index] := 0;
  1616. end;
  1617. end;
  1618. { TExtremeRange4 }
  1619. function TExtremeRange4.TestTitle: shortstring;
  1620. begin
  1621. Result := 'Two labels, sparse values, always triggered';
  1622. end;
  1623. function TExtremeRange4.WriteResults: Boolean;
  1624. var
  1625. X: Word;
  1626. begin
  1627. Result := True;
  1628. for X := 0 to $FFFF do
  1629. if FResultStorage[X] <> (X and $1) then
  1630. begin
  1631. WriteLn('FAIL - Index ', X, '; expected $', hexstr(X and $1, 2), ' got $', hexstr(FResultStorage[X], 2));
  1632. Result := False;
  1633. Exit;
  1634. end;
  1635. end;
  1636. procedure TExtremeRange4.DoTestIteration(Iteration: Integer);
  1637. var
  1638. Index, Input: Word;
  1639. begin
  1640. {$push}
  1641. {$r-}
  1642. Index := (Iteration and $FFFF);
  1643. Input := (Iteration and $1) - 1;
  1644. {$pop}
  1645. FResultStorage[Index] := 2; { Covers 1..$FFFE }
  1646. case Input of
  1647. 0:
  1648. FResultStorage[Index] := 1;
  1649. $FFFF:
  1650. FResultStorage[Index] := 0;
  1651. end;
  1652. end;
  1653. { TSparseDataTest1 }
  1654. procedure TSparseDataTest1.DoCaseBlock(Index: Integer; Input: TInstructionSet);
  1655. begin
  1656. case Input of
  1657. A_AND:
  1658. FResultStorage[Index] := 1;
  1659. A_MOV:
  1660. FResultStorage[Index] := 2;
  1661. A_MOVSX,
  1662. A_MOVZX:
  1663. FResultStorage[Index] := 3;
  1664. A_VMOVAPS,
  1665. A_VMOVAPD,
  1666. A_VMOVUPS,
  1667. A_VMOVUPD:
  1668. FResultStorage[Index] := 4;
  1669. A_MOVAPD,
  1670. A_MOVAPS,
  1671. A_MOVUPD,
  1672. A_MOVUPS:
  1673. FResultStorage[Index] := 5;
  1674. A_VDIVSD,
  1675. A_VDIVSS,
  1676. A_VSUBSD,
  1677. A_VSUBSS,
  1678. A_VMULSD,
  1679. A_VMULSS,
  1680. A_VADDSD,
  1681. A_VADDSS,
  1682. A_VANDPD,
  1683. A_VANDPS,
  1684. A_VORPD,
  1685. A_VORPS,
  1686. A_VXORPD,
  1687. A_VXORPS:
  1688. FResultStorage[Index] := 6;
  1689. A_MULSD,
  1690. A_MULSS,
  1691. A_ADDSD,
  1692. A_ADDSS:
  1693. FResultStorage[Index] := 7;
  1694. A_VMOVSD,
  1695. A_VMOVSS,
  1696. A_MOVSD,
  1697. A_MOVSS:
  1698. FResultStorage[Index] := 8;
  1699. A_LEA:
  1700. FResultStorage[Index] := 9;
  1701. A_SUB:
  1702. FResultStorage[Index] := 10;
  1703. A_SHL,A_SAL:
  1704. FResultStorage[Index] := 11;
  1705. A_SETcc:
  1706. FResultStorage[Index] := 12;
  1707. else
  1708. FResultStorage[Index] := 0;
  1709. end;
  1710. end;
  1711. { TSparseDataEqual1 }
  1712. function TSparseDataEqual1.TestTitle: shortstring;
  1713. begin
  1714. Result := 'Domain of 1024, 12 sparse labels, equal polling';
  1715. end;
  1716. function TSparseDataEqual1.WriteResults: Boolean;
  1717. var
  1718. X: Word;
  1719. begin
  1720. Result := True;
  1721. for X := 0 to 1023 do
  1722. if FResultStorage[X] <> ExtremeRange1Expected[X] then
  1723. begin
  1724. WriteLn('FAIL - Index ', X, '; expected $', hexstr(ExtremeRange1Expected[X], 2), ' got $', hexstr(FResultStorage[X], 2));
  1725. Result := False;
  1726. Exit;
  1727. end;
  1728. end;
  1729. procedure TSparseDataEqual1.DoTestIteration(Iteration: Integer);
  1730. var
  1731. X: SmallInt;
  1732. begin
  1733. X := Iteration and 1023;
  1734. DoCaseBlock(X, TInstructionSet(X - 512))
  1735. end;
  1736. { TSparseDataMOVWeightedl }
  1737. function TSparseDataMOVWeighted1.TestTitle: shortstring;
  1738. begin
  1739. Result := 'Domain of 1024, 12 sparse labels, 75% particular match';
  1740. end;
  1741. function TSparseDataMOVWeighted1.WriteResults: Boolean;
  1742. var
  1743. X, Expected: Word;
  1744. begin
  1745. Result := True;
  1746. for X := 0 to 1023 do
  1747. begin
  1748. Expected := IIf((X and $3) = 0, ExtremeRange1Expected[X], 2);
  1749. if FResultStorage[X] <> Expected then
  1750. begin
  1751. WriteLn('FAIL - Index ', X, '; expected $', hexstr(Expected, 2), ' got $', hexstr(FResultStorage[X], 2));
  1752. Result := False;
  1753. Exit;
  1754. end;
  1755. end;
  1756. end;
  1757. procedure TSparseDataMOVWeighted1.DoTestIteration(Iteration: Integer);
  1758. var
  1759. X: SmallInt; P: TInstructionSet;
  1760. begin
  1761. X := Iteration and 1023;
  1762. P := TInstructionSet(IIf((X and $3) = 0, X - 512, Ord(A_MOV)));
  1763. DoCaseBlock(X, P);
  1764. end;
  1765. { TSparseDataMidpointWeighted1 }
  1766. function TSparseDataMidpointWeighted1.TestTitle: shortstring;
  1767. begin
  1768. Result := 'Domain of 1024, 12 sparse labels, 75% midpoint match';
  1769. end;
  1770. function TSparseDataMidpointWeighted1.WriteResults: Boolean;
  1771. var
  1772. X, Expected: Word;
  1773. begin
  1774. Result := True;
  1775. for X := 0 to 1023 do
  1776. begin
  1777. Expected := IIf((X and $3) = 0, ExtremeRange1Expected[X], 6);
  1778. if FResultStorage[X] <> Expected then
  1779. begin
  1780. WriteLn('FAIL - Index ', X, '; expected $', hexstr(Expected, 2), ' got $', hexstr(FResultStorage[X], 2));
  1781. Result := False;
  1782. Exit;
  1783. end;
  1784. end;
  1785. end;
  1786. procedure TSparseDataMidpointWeighted1.DoTestIteration(Iteration: Integer);
  1787. var
  1788. X: Word; P: TInstructionSet;
  1789. begin
  1790. X := Iteration and 1023;
  1791. P := TInstructionSet(IIf((X and $3) = 0, X - 512, Ord(A_VADDSD)));
  1792. DoCaseBlock(X, P);
  1793. end;
  1794. { TSparseDataTest2 }
  1795. procedure TSparseDataTest2.DoCaseBlock(Index: Integer; Input: TInstructionSet);
  1796. begin
  1797. case Input of
  1798. A_AND:
  1799. FResultStorage[Index] := 1;
  1800. A_MOV:
  1801. FResultStorage[Index] := 2;
  1802. A_MOVSX:
  1803. FResultStorage[Index] := 13;
  1804. A_MOVZX:
  1805. FResultStorage[Index] := 3;
  1806. A_VMOVAPS:
  1807. FResultStorage[Index] := 14;
  1808. A_VMOVAPD:
  1809. FResultStorage[Index] := 15;
  1810. A_VMOVUPS:
  1811. FResultStorage[Index] := 16;
  1812. A_VMOVUPD:
  1813. FResultStorage[Index] := 4;
  1814. A_MOVAPD:
  1815. FResultStorage[Index] := 17;
  1816. A_MOVAPS:
  1817. FResultStorage[Index] := 18;
  1818. A_MOVUPD:
  1819. FResultStorage[Index] := 19;
  1820. A_MOVUPS:
  1821. FResultStorage[Index] := 5;
  1822. A_VDIVSD:
  1823. FResultStorage[Index] := 20;
  1824. A_VDIVSS:
  1825. FResultStorage[Index] := 21;
  1826. A_VSUBSD:
  1827. FResultStorage[Index] := 22;
  1828. A_VSUBSS:
  1829. FResultStorage[Index] := 23;
  1830. A_VMULSD:
  1831. FResultStorage[Index] := 24;
  1832. A_VMULSS:
  1833. FResultStorage[Index] := 25;
  1834. A_VADDSD:
  1835. FResultStorage[Index] := 26;
  1836. A_VADDSS:
  1837. FResultStorage[Index] := 27;
  1838. A_VANDPD:
  1839. FResultStorage[Index] := 28;
  1840. A_VANDPS:
  1841. FResultStorage[Index] := 29;
  1842. A_VORPD:
  1843. FResultStorage[Index] := 30;
  1844. A_VORPS:
  1845. FResultStorage[Index] := 31;
  1846. A_VXORPD:
  1847. FResultStorage[Index] := 32;
  1848. A_VXORPS:
  1849. FResultStorage[Index] := 6;
  1850. A_MULSD:
  1851. FResultStorage[Index] := 33;
  1852. A_MULSS:
  1853. FResultStorage[Index] := 34;
  1854. A_ADDSD:
  1855. FResultStorage[Index] := 35;
  1856. A_ADDSS:
  1857. FResultStorage[Index] := 7;
  1858. A_VMOVSD:
  1859. FResultStorage[Index] := 36;
  1860. A_VMOVSS:
  1861. FResultStorage[Index] := 37;
  1862. A_MOVSD:
  1863. FResultStorage[Index] := 38;
  1864. A_MOVSS:
  1865. FResultStorage[Index] := 8;
  1866. A_LEA:
  1867. FResultStorage[Index] := 9;
  1868. A_SUB:
  1869. FResultStorage[Index] := 10;
  1870. A_SHL:
  1871. FResultStorage[Index] := 39;
  1872. A_SAL:
  1873. FResultStorage[Index] := 11;
  1874. A_SETcc:
  1875. FResultStorage[Index] := 12;
  1876. else
  1877. FResultStorage[Index] := 0;
  1878. end;
  1879. end;
  1880. { TSparseDataEqual2 }
  1881. function TSparseDataEqual2.TestTitle: shortstring;
  1882. begin
  1883. Result := 'Domain of 1024, 39 sparse labels, equal polling';
  1884. end;
  1885. function TSparseDataEqual2.WriteResults: Boolean;
  1886. var
  1887. X: Word;
  1888. begin
  1889. Result := True;
  1890. for X := 0 to 1023 do
  1891. if FResultStorage[X] <> ExtremeRange2Expected[X] then
  1892. begin
  1893. WriteLn('FAIL - Index ', X, '; expected $', hexstr(ExtremeRange2Expected[X], 2), ' got $', hexstr(FResultStorage[X], 2));
  1894. Result := False;
  1895. Exit;
  1896. end;
  1897. end;
  1898. procedure TSparseDataEqual2.DoTestIteration(Iteration: Integer);
  1899. var
  1900. X: SmallInt;
  1901. begin
  1902. X := Iteration and 1023;
  1903. DoCaseBlock(X, TInstructionSet(X - 512))
  1904. end;
  1905. { TSparseDataMOVWeighted2 }
  1906. function TSparseDataMOVWeighted2.TestTitle: shortstring;
  1907. begin
  1908. Result := 'Domain of 1024, 39 sparse labels, 75% particular match';
  1909. end;
  1910. function TSparseDataMOVWeighted2.WriteResults: Boolean;
  1911. var
  1912. X, Expected: Word;
  1913. begin
  1914. Result := True;
  1915. for X := 0 to 1023 do
  1916. begin
  1917. Expected := IIf((X and $3) = 0, ExtremeRange2Expected[X], 2);
  1918. if FResultStorage[X] <> Expected then
  1919. begin
  1920. WriteLn('FAIL - Index ', X, '; expected $', hexstr(Expected, 2), ' got $', hexstr(FResultStorage[X], 2));
  1921. Result := False;
  1922. Exit;
  1923. end;
  1924. end;
  1925. end;
  1926. procedure TSparseDataMOVWeighted2.DoTestIteration(Iteration: Integer);
  1927. var
  1928. X: SmallInt; P: TInstructionSet;
  1929. begin
  1930. X := Iteration and 1023;
  1931. P := TInstructionSet(IIf((X and $3) = 0, X - 512, Ord(A_MOV)));
  1932. DoCaseBlock(X, P);
  1933. end;
  1934. { TSparseDataMidpointWeighted2 }
  1935. function TSparseDataMidpointWeighted2.TestTitle: shortstring;
  1936. begin
  1937. Result := 'Domain of 1024, 39 sparse labels, 75% midpoint match';
  1938. end;
  1939. function TSparseDataMidpointWeighted2.WriteResults: Boolean;
  1940. var
  1941. X, Expected: Word;
  1942. begin
  1943. Result := True;
  1944. for X := 0 to 1023 do
  1945. begin
  1946. Expected := IIf((X and $3) = 0, ExtremeRange2Expected[X], 26);
  1947. if FResultStorage[X] <> Expected then
  1948. begin
  1949. WriteLn('FAIL - Index ', X, '; expected $', hexstr(Expected, 2), ' got $', hexstr(FResultStorage[X], 2));
  1950. Result := False;
  1951. Exit;
  1952. end;
  1953. end;
  1954. end;
  1955. procedure TSparseDataMidpointWeighted2.DoTestIteration(Iteration: Integer);
  1956. var
  1957. X: SmallInt; P: TInstructionSet;
  1958. begin
  1959. X := Iteration and 1023;
  1960. P := TInstructionSet(IIf((X and $3) = 0, X - 512, Ord(A_VADDSD)));
  1961. DoCaseBlock(X, P);
  1962. end;
  1963. { TSparseDataTest3 }
  1964. procedure TSparseDataTest3.DoCaseBlock(Index: Integer; Input: TInstructionSet);
  1965. begin
  1966. case Input of
  1967. A_AND:
  1968. FResultStorage[Index] := 1;
  1969. A_MOV:
  1970. FResultStorage[Index] := 2;
  1971. A_MOVSX:
  1972. FResultStorage[Index] := 13;
  1973. A_MOVZX:
  1974. FResultStorage[Index] := 3;
  1975. A_VMOVAPS:
  1976. FResultStorage[Index] := 14;
  1977. A_VMOVAPD:
  1978. FResultStorage[Index] := 15;
  1979. A_VMOVUPS:
  1980. FResultStorage[Index] := 16;
  1981. A_VMOVUPD:
  1982. FResultStorage[Index] := 4;
  1983. A_MOVAPD:
  1984. FResultStorage[Index] := 17;
  1985. A_MOVAPS:
  1986. FResultStorage[Index] := 18;
  1987. A_MOVUPD:
  1988. FResultStorage[Index] := 19;
  1989. A_MOVUPS:
  1990. FResultStorage[Index] := 5;
  1991. A_VDIVSD:
  1992. FResultStorage[Index] := 20;
  1993. A_VDIVSS:
  1994. FResultStorage[Index] := 21;
  1995. A_VSUBSD:
  1996. FResultStorage[Index] := 22;
  1997. A_VSUBSS:
  1998. FResultStorage[Index] := 23;
  1999. A_VMULSD:
  2000. FResultStorage[Index] := 24;
  2001. A_VMULSS:
  2002. FResultStorage[Index] := 25;
  2003. A_VADDSD:
  2004. FResultStorage[Index] := 26;
  2005. A_VADDSS:
  2006. FResultStorage[Index] := 27;
  2007. A_VANDPD:
  2008. FResultStorage[Index] := 28;
  2009. A_VANDPS:
  2010. FResultStorage[Index] := 29;
  2011. A_VORPD:
  2012. FResultStorage[Index] := 30;
  2013. A_VORPS:
  2014. FResultStorage[Index] := 31;
  2015. A_VXORPD:
  2016. FResultStorage[Index] := 32;
  2017. A_VXORPS:
  2018. FResultStorage[Index] := 6;
  2019. A_MULSD:
  2020. FResultStorage[Index] := 33;
  2021. A_MULSS:
  2022. FResultStorage[Index] := 34;
  2023. A_ADDSD:
  2024. FResultStorage[Index] := 35;
  2025. A_ADDSS:
  2026. FResultStorage[Index] := 7;
  2027. A_VMOVSD:
  2028. FResultStorage[Index] := 36;
  2029. A_VMOVSS:
  2030. FResultStorage[Index] := 37;
  2031. A_MOVSD:
  2032. FResultStorage[Index] := 38;
  2033. A_MOVSS:
  2034. FResultStorage[Index] := 8;
  2035. A_LEA:
  2036. FResultStorage[Index] := 9;
  2037. A_SUB:
  2038. FResultStorage[Index] := 10;
  2039. A_SHL:
  2040. FResultStorage[Index] := 39;
  2041. A_SAL:
  2042. FResultStorage[Index] := 11;
  2043. A_SETcc:
  2044. FResultStorage[Index] := 12;
  2045. A_MULX:
  2046. FResultStorage[Index] := 40;
  2047. A_VBROADCASTF128:
  2048. FResultStorage[Index] := 41;
  2049. A_VBROADCASTI128:
  2050. FResultStorage[Index] := 42;
  2051. A_VPERMD:
  2052. FResultStorage[Index] := 43;
  2053. A_VADDPD:
  2054. FResultStorage[Index] := 44;
  2055. A_VADDPS:
  2056. FResultStorage[Index] := 45;
  2057. A_ROUNDPS:
  2058. FResultStorage[Index] := 46;
  2059. A_ROUNDPD:
  2060. FResultStorage[Index] := 47;
  2061. A_ROUNDSS:
  2062. FResultStorage[Index] := 48;
  2063. A_ROUNDSD:
  2064. FResultStorage[Index] := 49;
  2065. A_CRC32:
  2066. FResultStorage[Index] := 50;
  2067. A_DPPS:
  2068. FResultStorage[Index] := 51;
  2069. A_DPPD:
  2070. FResultStorage[Index] := 52;
  2071. A_VAESDEC:
  2072. FResultStorage[Index] := 53;
  2073. A_VAESDECLAST:
  2074. FResultStorage[Index] := 54;
  2075. A_VAESENC:
  2076. FResultStorage[Index] := 55;
  2077. A_VAESENCLAST:
  2078. FResultStorage[Index] := 56;
  2079. A_VAESIMC:
  2080. FResultStorage[Index] := 57;
  2081. A_VAESKEYGENASSIST:
  2082. FResultStorage[Index] := 58;
  2083. A_VPSHUFB:
  2084. FResultStorage[Index] := 59;
  2085. A_VPSHUFD:
  2086. FResultStorage[Index] := 60;
  2087. A_VPSHUFHW:
  2088. FResultStorage[Index] := 61;
  2089. A_VPSHUFLW:
  2090. FResultStorage[Index] := 62;
  2091. A_BSF:
  2092. FResultStorage[Index] := 63;
  2093. A_BSR:
  2094. FResultStorage[Index] := 64;
  2095. A_BTR:
  2096. FResultStorage[Index] := 65;
  2097. A_BTS:
  2098. FResultStorage[Index] := 66;
  2099. A_XOR:
  2100. FResultStorage[Index] := 67;
  2101. A_ADD:
  2102. FResultStorage[Index] := 68;
  2103. A_CMP:
  2104. FResultStorage[Index] := 69;
  2105. A_SHLX:
  2106. FResultStorage[Index] := 70;
  2107. A_SHRX:
  2108. FResultStorage[Index] := 71;
  2109. else
  2110. FResultStorage[Index] := 0;
  2111. end;
  2112. end;
  2113. { TSparseDataEqual3 }
  2114. function TSparseDataEqual3.TestTitle: shortstring;
  2115. begin
  2116. Result := 'Domain of 1024, 71 sparse labels, equal polling';
  2117. end;
  2118. function TSparseDataEqual3.WriteResults: Boolean;
  2119. var
  2120. X: Word;
  2121. begin
  2122. Result := True;
  2123. for X := 0 to 1023 do
  2124. if FResultStorage[X] <> ExtremeRange3Expected[X] then
  2125. begin
  2126. WriteLn('FAIL - Index ', X, '; expected $', hexstr(ExtremeRange3Expected[X], 2), ' got $', hexstr(FResultStorage[X], 2));
  2127. Result := False;
  2128. Exit;
  2129. end;
  2130. end;
  2131. procedure TSparseDataEqual3.DoTestIteration(Iteration: Integer);
  2132. var
  2133. X: SmallInt;
  2134. begin
  2135. X := Iteration and 1023;
  2136. DoCaseBlock(X, TInstructionSet(X - 512))
  2137. end;
  2138. { TSparseDataMOVWeightedl }
  2139. function TSparseDataMOVWeighted3.TestTitle: shortstring;
  2140. begin
  2141. Result := 'Domain of 1024, 71 sparse labels, 75% particular match';
  2142. end;
  2143. function TSparseDataMOVWeighted3.WriteResults: Boolean;
  2144. var
  2145. X, Expected: Word;
  2146. begin
  2147. Result := True;
  2148. for X := 0 to 1023 do
  2149. begin
  2150. Expected := IIf((X and $3) = 0, ExtremeRange3Expected[X], 2);
  2151. if FResultStorage[X] <> Expected then
  2152. begin
  2153. WriteLn('FAIL - Index ', X, '; expected $', hexstr(Expected, 2), ' got $', hexstr(FResultStorage[X], 2));
  2154. Result := False;
  2155. Exit;
  2156. end;
  2157. end;
  2158. end;
  2159. procedure TSparseDataMOVWeighted3.DoTestIteration(Iteration: Integer);
  2160. var
  2161. X: SmallInt; P: TInstructionSet;
  2162. begin
  2163. X := Iteration and 1023;
  2164. P := TInstructionSet(IIf((X and $3) = 0, X - 512, Ord(A_MOV)));
  2165. DoCaseBlock(X, P);
  2166. end;
  2167. { TSparseDataMidpointWeighted3 }
  2168. function TSparseDataMidpointWeighted3.TestTitle: shortstring;
  2169. begin
  2170. Result := 'Domain of 1024, 71 sparse labels, 75% midpoint match';
  2171. end;
  2172. function TSparseDataMidpointWeighted3.WriteResults: Boolean;
  2173. var
  2174. X, Expected: Word;
  2175. begin
  2176. Result := True;
  2177. for X := 0 to 1023 do
  2178. begin
  2179. Expected := IIf((X and $3) = 0, ExtremeRange3Expected[X], 26);
  2180. if FResultStorage[X] <> Expected then
  2181. begin
  2182. WriteLn('FAIL - Index ', X, '; expected $', hexstr(Expected, 2), ' got $', hexstr(FResultStorage[X], 2));
  2183. Result := False;
  2184. Exit;
  2185. end;
  2186. end;
  2187. end;
  2188. procedure TSparseDataMidpointWeighted3.DoTestIteration(Iteration: Integer);
  2189. var
  2190. X: SmallInt; P: TInstructionSet;
  2191. begin
  2192. X := Iteration and 1023;
  2193. P := TInstructionSet(IIf((X and $3) = 0, X - 512, Ord(A_VADDSD)));
  2194. DoCaseBlock(X, P);
  2195. end;
  2196. { TLinearListDependsOnInput }
  2197. function TLinearListDependsOnInput.TestTitle: shortstring;
  2198. begin
  2199. Result := 'Linear list depends on input';
  2200. end;
  2201. function TLinearListDependsOnInput.WriteResults: Boolean;
  2202. var
  2203. X: Word;
  2204. begin
  2205. Result := True;
  2206. if FResultStorage[0] <> 0 then
  2207. begin
  2208. WriteLn('FAIL - Index 0; expected $00 got $', hexstr(FResultStorage[0], 2));
  2209. Result := False;
  2210. Exit;
  2211. end;
  2212. for X := 1 to 7 do
  2213. if FResultStorage[X] <> (X and $3) then
  2214. begin
  2215. WriteLn('FAIL - Index ', X, '; expected $', hexstr(X and $3, 2), ' got $', hexstr(FResultStorage[X], 2));
  2216. Result := False;
  2217. Exit;
  2218. end;
  2219. for X := 8 to 11 do
  2220. if FResultStorage[X] <> 0 then
  2221. begin
  2222. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  2223. Result := False;
  2224. Exit;
  2225. end;
  2226. if FResultStorage[12] <> $10 then
  2227. begin
  2228. WriteLn('FAIL - Index 12; expected $10 got $', hexstr(FResultStorage[12], 2));
  2229. Result := False;
  2230. Exit;
  2231. end;
  2232. for X := 13 to $FF do
  2233. if FResultStorage[X] <> 0 then
  2234. begin
  2235. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  2236. Result := False;
  2237. Exit;
  2238. end;
  2239. end;
  2240. procedure TLinearListDependsOnInput.DoTestIteration(Iteration: Integer);
  2241. var
  2242. Index: Byte;
  2243. begin
  2244. Index := Iteration and $FF;
  2245. { This helps catch errors where all branches, including else, are skipped }
  2246. FResultStorage[Index] := $FF;
  2247. case Index of
  2248. 1..3: FResultStorage[Index] := Index;
  2249. 4..7: FResultStorage[Index] := Index - 4;
  2250. 12: FResultStorage[Index] := $10;
  2251. else FResultStorage[Index] := 0;
  2252. end;
  2253. end;
  2254. { TCStyleCascade }
  2255. function TCStyleCascade.TestTitle: shortstring;
  2256. begin
  2257. Result := 'C-style cascade using ''goto''';
  2258. end;
  2259. function TCStyleCascade.WriteResults: Boolean;
  2260. var
  2261. X: Byte;
  2262. begin
  2263. Result := True;
  2264. for X := 0 to 5 do
  2265. if FResultStorage[X] <> ((1 shl X) - 1) then
  2266. begin
  2267. WriteLn('FAIL - Index ', X, '; expected $', hexstr((1 shl X) - 1, 2), ' got $', hexstr(FResultStorage[X], 2));
  2268. Result := False;
  2269. Exit;
  2270. end;
  2271. for X := 6 to $FF do
  2272. if FResultStorage[X] <> 0 then
  2273. begin
  2274. WriteLn('FAIL - Index ', X, '; expected $00 got $', hexstr(FResultStorage[X], 2));
  2275. Result := False;
  2276. Exit;
  2277. end;
  2278. end;
  2279. procedure TCStyleCascade.DoTestIteration(Iteration: Integer);
  2280. var
  2281. X, Tmp: Byte;
  2282. label
  2283. Set1, Set2, Set3, Set4, Default;
  2284. begin
  2285. X := Iteration and $FF;
  2286. Tmp := 0;
  2287. case X of
  2288. $1: goto Set1;
  2289. $2: goto Set2;
  2290. $3: goto Set3;
  2291. $4: goto Set4;
  2292. $5: Tmp := 16;
  2293. else
  2294. goto Default;
  2295. end;
  2296. Set4:
  2297. Tmp := Tmp or $8;
  2298. Set3:
  2299. Tmp := Tmp or $4;
  2300. Set2:
  2301. Tmp := Tmp or $2;
  2302. Set1:
  2303. Tmp := Tmp or $1;
  2304. Default:
  2305. FResultStorage[X] := Tmp;
  2306. end;
  2307. { Main function }
  2308. const
  2309. { TCompleteByteRange and descendants
  2310. - Entirely-covered jump tree
  2311. - 33 labels, no else block; full coverage (all 256 byte values covered)
  2312. - Root: values are polled with equal probability
  2313. - FirstWeighted: first branch is polled 3 times as often
  2314. - LastWeighted: last branch is polled 3 times as often
  2315. TAlmostFullByteRange
  2316. - Almost full jump tree - 18 labels, else block covers 32 values; 224 byte values covered
  2317. - Root: values are polled with equal probability
  2318. - FirstWeighted: first branch is polled 3 times as often
  2319. - LastWeighted: last branch is polled 3 times as often
  2320. }
  2321. TestClasses: array[0..35] of TTestClass = (
  2322. TCompleteByteRange,
  2323. TCompleteByteRangeFirstWeighted,
  2324. TCompleteByteRangeLastWeighted,
  2325. TAlmostFullByteRange,
  2326. TAlmostFullByteRangeFirstWeighted,
  2327. TAlmostFullByteRangeLastWeighted,
  2328. TSingleEntryWithDefault,
  2329. TSingleEntryWithDefaultUnlikely,
  2330. TSingleEntryWithDefaultWeighted,
  2331. TSingleEntryWithElse,
  2332. TSingleEntryWithElseUnlikely,
  2333. TSingleEntryWithElseWeighted,
  2334. TSingleEntryAtZeroWithElse,
  2335. TSingleEntryAtMinus1WithDefault,
  2336. TSingleEntryAtMinus4WithElse,
  2337. TSingleEntryWith0To5RangeWithElse,
  2338. TSingleEntryWith0To50RangeWithElse,
  2339. TSingleEntryWith1To5RangeWithElse,
  2340. TSingleEntryWith1To50RangeWithElse,
  2341. TSingleEntryWithMinus1To5RangeWithElse,
  2342. TSingleEntryWithMinus1To50RangeWithElse,
  2343. TExtremeRange1,
  2344. TExtremeRange2,
  2345. TExtremeRange3,
  2346. TExtremeRange4,
  2347. TSparseDataEqual1,
  2348. TSparseDataMOVWeighted1,
  2349. TSparseDataMidpointWeighted1,
  2350. TSparseDataEqual2,
  2351. TSparseDataMOVWeighted2,
  2352. TSparseDataMidpointWeighted2,
  2353. TSparseDataEqual3,
  2354. TSparseDataMOVWeighted3,
  2355. TSparseDataMidpointWeighted3,
  2356. TLinearListDependsOnInput,
  2357. TCStyleCascade
  2358. );
  2359. var
  2360. CurrentObject: TTestAncestor;
  2361. Failed: Boolean;
  2362. X: Integer;
  2363. SummedUpAverageDuration, AverageDuration : Double;
  2364. begin
  2365. SummedUpAverageDuration := 0.0;
  2366. Failed := False;
  2367. WriteLn('Case node compilation and timing test');
  2368. WriteLn('-------------------------------------');
  2369. for X := low(TestClasses) to High(TestClasses) do
  2370. begin
  2371. try
  2372. CurrentObject := TestClasses[X].Create;
  2373. try
  2374. Write(CurrentObject.TestTitle:56, ' - ');
  2375. CurrentObject.Run;
  2376. if CurrentObject.WriteResults then
  2377. begin
  2378. AverageDuration := ((CurrentObject.RunTime * 1000000000.0) / ITERATIONS);
  2379. WriteLn('Pass - average iteration duration: ', AverageDuration:1:3, ' ns');
  2380. SummedUpAverageDuration := SummedUpAverageDuration + AverageDuration;
  2381. end
  2382. else
  2383. { Final average isn't processed if a test failed, so there's no need
  2384. to calculate and add the average duration to it }
  2385. Failed := True;
  2386. finally
  2387. CurrentObject.Free;
  2388. end;
  2389. except on E: Exception do
  2390. begin
  2391. WriteLn('Exception "', E.ClassName, '" raised while running test object of class "', TestClasses[X].ClassName, '"');
  2392. Failed := True;
  2393. end;
  2394. end;
  2395. end;
  2396. if Failed then
  2397. Halt(1);
  2398. WriteLn(#10'ok');
  2399. WriteLn('- Sum of average durations: ', SummedUpAverageDuration:1:3, ' ns');
  2400. WriteLn('- Overall average duration: ', (SummedUpAverageDuration / Length(TestClasses)):1:3, ' ns');
  2401. end.