bcase.pp 95 KB

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