bdiv_s32.inc 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. type
  2. { TSInt32Bit1Test }
  3. TSInt32Bit1Test = class(TSInt32DivTest)
  4. protected
  5. function GetDivisor: Integer; override;
  6. procedure DoTestIteration(Iteration: Integer); override;
  7. public
  8. function TestTitle: shortstring; override;
  9. end;
  10. { TSInt32Bit1ModTest }
  11. TSInt32Bit1ModTest = class(TSInt32ModTest)
  12. protected
  13. function GetDivisor: Integer; override;
  14. procedure DoTestIteration(Iteration: Integer); override;
  15. public
  16. function TestTitle: shortstring; override;
  17. end;
  18. { TSInt32Bit100Test }
  19. TSInt32Bit100Test = class(TSInt32DivTest)
  20. protected
  21. function GetDivisor: Integer; override;
  22. procedure DoTestIteration(Iteration: Integer); override;
  23. public
  24. function TestTitle: shortstring; override;
  25. end;
  26. { TSInt32Bit100ModTest }
  27. TSInt32Bit100ModTest = class(TSInt32ModTest)
  28. protected
  29. function GetDivisor: Integer; override;
  30. procedure DoTestIteration(Iteration: Integer); override;
  31. public
  32. function TestTitle: shortstring; override;
  33. end;
  34. { TSInt32Bit3ModCmpTest }
  35. TSInt32Bit3ModCmpTest = class(TSInt32ModCmpTest)
  36. protected
  37. function GetDivisor: Integer; override;
  38. procedure DoTestIteration(Iteration: Integer); override;
  39. public
  40. function TestTitle: shortstring; override;
  41. end;
  42. { TSInt32Bit10ModCmpTest }
  43. TSInt32Bit10ModCmpTest = class(TSInt32ModCmpTest)
  44. protected
  45. function GetDivisor: Integer; override;
  46. procedure DoTestIteration(Iteration: Integer); override;
  47. public
  48. function TestTitle: shortstring; override;
  49. end;
  50. { TSInt32Bit100ModCmpTest }
  51. TSInt32Bit100ModCmpTest = class(TSInt32ModCmpTest)
  52. protected
  53. function GetDivisor: Integer; override;
  54. procedure DoTestIteration(Iteration: Integer); override;
  55. public
  56. function TestTitle: shortstring; override;
  57. end;
  58. { TSInt32Bit1Test }
  59. function TSInt32Bit1Test.TestTitle: shortstring;
  60. begin
  61. Result := 'Signed 32-bit division by 1';
  62. end;
  63. function TSInt32Bit1Test.GetDivisor: Integer;
  64. begin
  65. Result := 1;
  66. end;
  67. procedure TSInt32Bit1Test.DoTestIteration(Iteration: Integer);
  68. var
  69. Numerator, Answer: Integer;
  70. Index, X: Integer;
  71. begin
  72. Index := Iteration and $FF;
  73. case Index of
  74. 0:
  75. Numerator := -2147483648;
  76. 1:
  77. Numerator := -2147483600;
  78. 2:
  79. Numerator := -2147483599;
  80. 253:
  81. Numerator := 2147483599;
  82. 254:
  83. Numerator := 2147483600;
  84. 255:
  85. Numerator := 2147483647;
  86. else
  87. Numerator := Index - 128;
  88. end;
  89. FInputArray[Index] := Numerator;
  90. for X := 0 to INTERNAL_LOOPS - 1 do
  91. Answer := Numerator div 1;
  92. FResultArray[Index] := Answer;
  93. end;
  94. { TSInt32Bit1ModTest }
  95. function TSInt32Bit1ModTest.TestTitle: shortstring;
  96. begin
  97. Result := 'Signed 32-bit modulus by 1';
  98. end;
  99. function TSInt32Bit1ModTest.GetDivisor: Integer;
  100. begin
  101. Result := 1;
  102. end;
  103. procedure TSInt32Bit1ModTest.DoTestIteration(Iteration: Integer);
  104. var
  105. Numerator, Answer: Integer;
  106. Index, X: Integer;
  107. begin
  108. Index := Iteration and $FF;
  109. case Index of
  110. 0:
  111. Numerator := -2147483648;
  112. 1:
  113. Numerator := -2147483600;
  114. 2:
  115. Numerator := -2147483599;
  116. 253:
  117. Numerator := 2147483599;
  118. 254:
  119. Numerator := 2147483600;
  120. 255:
  121. Numerator := 2147483647;
  122. else
  123. Numerator := Index - 128;
  124. end;
  125. FInputArray[Index] := Numerator;
  126. for X := 0 to INTERNAL_LOOPS - 1 do
  127. Answer := Numerator mod 1;
  128. FResultArray[Index] := Answer;
  129. end;
  130. { TSInt32Bit100Test }
  131. function TSInt32Bit100Test.TestTitle: shortstring;
  132. begin
  133. Result := 'Signed 32-bit division by 100';
  134. end;
  135. function TSInt32Bit100Test.GetDivisor: Integer;
  136. begin
  137. Result := 100;
  138. end;
  139. procedure TSInt32Bit100Test.DoTestIteration(Iteration: Integer);
  140. var
  141. Numerator, Answer: Integer;
  142. Index, X: Integer;
  143. begin
  144. Index := Iteration and $FF;
  145. case Index of
  146. 0:
  147. Numerator := -2147483648;
  148. 1:
  149. Numerator := -2147483600;
  150. 2:
  151. Numerator := -2147483599;
  152. 253:
  153. Numerator := 2147483599;
  154. 254:
  155. Numerator := 2147483600;
  156. 255:
  157. Numerator := 2147483647;
  158. else
  159. Numerator := Index - 128;
  160. end;
  161. FInputArray[Index] := Numerator;
  162. for X := 0 to INTERNAL_LOOPS - 1 do
  163. Answer := Numerator div 100;
  164. FResultArray[Index] := Answer;
  165. end;
  166. { TSInt32Bit100ModTest }
  167. function TSInt32Bit100ModTest.TestTitle: shortstring;
  168. begin
  169. Result := 'Signed 32-bit modulus by 100';
  170. end;
  171. function TSInt32Bit100ModTest.GetDivisor: Integer;
  172. begin
  173. Result := 100;
  174. end;
  175. procedure TSInt32Bit100ModTest.DoTestIteration(Iteration: Integer);
  176. var
  177. Numerator, Answer: Integer;
  178. Index, X: Integer;
  179. begin
  180. Index := Iteration and $FF;
  181. case Index of
  182. 0:
  183. Numerator := -2147483648;
  184. 1:
  185. Numerator := -2147483600;
  186. 2:
  187. Numerator := -2147483599;
  188. 253:
  189. Numerator := 2147483599;
  190. 254:
  191. Numerator := 2147483600;
  192. 255:
  193. Numerator := 2147483647;
  194. else
  195. Numerator := Index - 128;
  196. end;
  197. FInputArray[Index] := Numerator;
  198. for X := 0 to INTERNAL_LOOPS - 1 do
  199. Answer := Numerator mod 100;
  200. FResultArray[Index] := Answer;
  201. end;
  202. { TSInt32Bit3ModCmpTest }
  203. function TSInt32Bit3ModCmpTest.TestTitle: shortstring;
  204. begin
  205. Result := 'Signed 32-bit (n mod 3) = 0';
  206. end;
  207. function TSInt32Bit3ModCmpTest.GetDivisor: Integer;
  208. begin
  209. Result := 3;
  210. end;
  211. procedure TSInt32Bit3ModCmpTest.DoTestIteration(Iteration: Integer);
  212. var
  213. Numerator: Integer; Answer: Boolean;
  214. Index, X: Integer;
  215. begin
  216. Index := Iteration and $FF;
  217. case Index of
  218. 0:
  219. Numerator := -2147483648;
  220. 1:
  221. Numerator := -2147483600;
  222. 2:
  223. Numerator := -2147483599;
  224. 253:
  225. Numerator := 2147483599;
  226. 254:
  227. Numerator := 2147483600;
  228. 255:
  229. Numerator := 2147483647;
  230. else
  231. Numerator := Index - 128;
  232. end;
  233. FInputArray[Index] := Numerator;
  234. for X := 0 to INTERNAL_LOOPS - 1 do
  235. Answer := (Numerator mod 3) = 0;
  236. FResultArray[Index] := Answer;
  237. end;
  238. { TSInt32Bit10ModCmpTest }
  239. function TSInt32Bit10ModCmpTest.TestTitle: shortstring;
  240. begin
  241. Result := 'Signed 32-bit (n mod 10) = 0';
  242. end;
  243. function TSInt32Bit10ModCmpTest.GetDivisor: Integer;
  244. begin
  245. Result := 10;
  246. end;
  247. procedure TSInt32Bit10ModCmpTest.DoTestIteration(Iteration: Integer);
  248. var
  249. Numerator: Integer; Answer: Boolean;
  250. Index, X: Integer;
  251. begin
  252. Index := Iteration and $FF;
  253. case Index of
  254. 0:
  255. Numerator := -2147483648;
  256. 1:
  257. Numerator := -2147483600;
  258. 2:
  259. Numerator := -2147483599;
  260. 253:
  261. Numerator := 2147483599;
  262. 254:
  263. Numerator := 2147483600;
  264. 255:
  265. Numerator := 2147483647;
  266. else
  267. Numerator := Index - 128;
  268. end;
  269. FInputArray[Index] := Numerator;
  270. for X := 0 to INTERNAL_LOOPS - 1 do
  271. Answer := (Numerator mod 10) = 0;
  272. FResultArray[Index] := Answer;
  273. end;
  274. { TSInt32Bit100ModCmpTest }
  275. function TSInt32Bit100ModCmpTest.TestTitle: shortstring;
  276. begin
  277. Result := 'Signed 32-bit (n mod 100) = 0';
  278. end;
  279. function TSInt32Bit100ModCmpTest.GetDivisor: Integer;
  280. begin
  281. Result := 100;
  282. end;
  283. procedure TSInt32Bit100ModCmpTest.DoTestIteration(Iteration: Integer);
  284. var
  285. Numerator: Integer; Answer: Boolean;
  286. Index, X: Integer;
  287. begin
  288. Index := Iteration and $FF;
  289. case Index of
  290. 0:
  291. Numerator := -2147483648;
  292. 1:
  293. Numerator := -2147483600;
  294. 2:
  295. Numerator := -2147483599;
  296. 253:
  297. Numerator := 2147483599;
  298. 254:
  299. Numerator := 2147483600;
  300. 255:
  301. Numerator := 2147483647;
  302. else
  303. Numerator := Index - 128;
  304. end;
  305. FInputArray[Index] := Numerator;
  306. for X := 0 to INTERNAL_LOOPS - 1 do
  307. Answer := (Numerator mod 100) = 0;
  308. FResultArray[Index] := Answer;
  309. end;