bcase.pp 92 KB

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