tshlshr.pp 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. {***********************************************************}
  2. { CODE GENERATOR TEST SUITE *}
  3. {***********************************************************}
  4. { NODE TESTED : secondshlshr() *}
  5. {***********************************************************}
  6. { PRE-REQUISITES: secondload() }
  7. { secondassign() }
  8. { secondtypeconv() }
  9. { secondinline() with strings only! }
  10. { secondadd() comparison }
  11. { secondifn() }
  12. {***********************************************************}
  13. { DEFINES : FPC if target is Free Pascal compiler }
  14. {***********************************************************}
  15. { REMARKS: None }
  16. {***********************************************************}
  17. Program tshlshr;
  18. {----------------------------------------------------}
  19. { Cases to test: }
  20. { RIGHT NODE (shift count value) }
  21. { - LOC_CREGISTER }
  22. { - LOC_REFERENCE / LOC_MEM }
  23. { - LOC_REGISTER }
  24. { - numeric constant }
  25. { LEFT NODE (value to shift) }
  26. { - LOC_CREGISTER }
  27. { - LOC_REFERENCE / LOC_MEM }
  28. { - LOC_REGISTER }
  29. {----------------------------------------------------}
  30. var
  31. longres : longint;
  32. longcnt : longint;
  33. bytecnt : shortint;
  34. byteres : shortint;
  35. {$IFDEF FPC}
  36. int64res : int64;
  37. int64cnt : int64;
  38. {$ENDIF}
  39. Begin
  40. WriteLn('------------------------------ LONGINT --------------------------------');
  41. { left : LOC_REFERENCE }
  42. { right : numeric constant }
  43. WriteLn('(left) : LOC_REFERENCE; (right) : ordinal constant');
  44. longres:=1;
  45. longres := longres shl 15;
  46. Write('(SHL) Value should be 32768...');
  47. if longres = 32768 then
  48. WriteLn('Success.')
  49. else
  50. WriteLn('Failure.');
  51. longres:=-1;
  52. longres := longres shl 15;
  53. Write('(SHL) Value should be -32768...');
  54. if longres = -32768 then
  55. WriteLn('Success.')
  56. else
  57. WriteLn('Failure.');
  58. longres:=1;
  59. longres := longres shl 33;
  60. Write('(SHL) Value should be 2...');
  61. if longres = 2 then
  62. WriteLn('Success.')
  63. else
  64. WriteLn('Failure.');
  65. longres:=$8000;
  66. longres := longres shr 15;
  67. Write('(SHR) Value should be 1...');
  68. if longres = 1 then
  69. WriteLn('Success.')
  70. else
  71. WriteLn('Failure.');
  72. longres:=-1;
  73. longres := longres shr 15;
  74. Write('(SHR) Value should be 131071...');
  75. if longres = 131071 then
  76. WriteLn('Success.')
  77. else
  78. WriteLn('Failure.');
  79. longres:=$FFFF;
  80. longres := longres shr 33;
  81. Write('(SHR) Value should be 32767...');
  82. if longres = 32767 then
  83. WriteLn('Success.')
  84. else
  85. WriteLn('Failure.');
  86. { left : LOC_REFERENCE }
  87. { right : LOC_REFERENCE }
  88. WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REFERENCE');
  89. longres := 1;
  90. longcnt := -2;
  91. longres:=longres shl longcnt ;
  92. Write('(SHL) Value should be 1073741824...');
  93. if longres = 1073741824 then
  94. WriteLn('Success.')
  95. else
  96. WriteLn('Failure.');
  97. longres:=1;
  98. longcnt:=15;
  99. longres := longres shl longcnt;
  100. Write('(SHL) Value should be 32768...');
  101. if longres = 32768 then
  102. WriteLn('Success.')
  103. else
  104. WriteLn('Failure.');
  105. longres:=-1;
  106. longcnt := 15;
  107. longres := longres shl longcnt;
  108. Write('(SHL) Value should be -32768...');
  109. if longres = -32768 then
  110. WriteLn('Success.')
  111. else
  112. WriteLn('Failure.');
  113. longres := 1;
  114. longcnt := -2;
  115. longres:=longres shr longcnt ;
  116. Write('(SHR) Value should be 0...');
  117. if longres = 0 then
  118. WriteLn('Success.')
  119. else
  120. WriteLn('Failure.');
  121. longres:=32768;
  122. longcnt:=15;
  123. longres := longres shr longcnt;
  124. Write('(SHR) Value should be 1...');
  125. if longres = 1 then
  126. WriteLn('Success.')
  127. else
  128. WriteLn('Failure.');
  129. longres:=-1;
  130. longcnt := 15;
  131. longres := longres shl longcnt;
  132. Write('(SHR) Value should be -32768...');
  133. if longres = -32768 then
  134. WriteLn('Success.')
  135. else
  136. WriteLn('Failure.');
  137. { left : LOC_REFERENCE }
  138. { right : LOC_REGISRER }
  139. WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REGISTER');
  140. longres := 1;
  141. bytecnt := -2;
  142. longres:=longres shl bytecnt ;
  143. Write('(SHL) Value should be 1073741824...');
  144. if longres = 1073741824 then
  145. WriteLn('Success.')
  146. else
  147. WriteLn('Failure.');
  148. longres:=1;
  149. bytecnt:=15;
  150. longres := longres shl bytecnt;
  151. Write('(SHL) Value should be 32768...');
  152. if longres = 32768 then
  153. WriteLn('Success.')
  154. else
  155. WriteLn('Failure.');
  156. longres:=-1;
  157. bytecnt := 15;
  158. longres := longres shl bytecnt;
  159. Write('(SHL) Value should be -32768...');
  160. if longres = -32768 then
  161. WriteLn('Success.')
  162. else
  163. WriteLn('Failure.');
  164. longres := 1;
  165. bytecnt := -2;
  166. longres:=longres shr bytecnt ;
  167. Write('(SHR) Value should be 0...');
  168. if longres = 0 then
  169. WriteLn('Success.')
  170. else
  171. WriteLn('Failure.');
  172. longres:=32768;
  173. bytecnt:=15;
  174. longres := longres shr bytecnt;
  175. Write('(SHR) Value should be 1...');
  176. if longres = 1 then
  177. WriteLn('Success.')
  178. else
  179. WriteLn('Failure.');
  180. longres:=-1;
  181. bytecnt := 15;
  182. longres := longres shr bytecnt;
  183. Write('(SHR) Value should be 131071...');
  184. if longres = 131071 then
  185. WriteLn('Success.')
  186. else
  187. WriteLn('Failure.');
  188. WriteLn('(left) : LOC_REGISTER; (right) : LOC_REGISTER');
  189. byteres := 1;
  190. bytecnt := 2;
  191. byteres := byteres shl bytecnt;
  192. Write('(SHL) Value should be 4...');
  193. if longres = 4 then
  194. WriteLn('Success.')
  195. else
  196. WriteLn('Failure.');
  197. byteres := 4;
  198. bytecnt := 2;
  199. byteres := byteres shr bytecnt;
  200. Write('(SHR) Value should be 1...');
  201. if longres = 1 then
  202. WriteLn('Success.')
  203. else
  204. WriteLn('Failure.');
  205. {$IFDEF FPC}
  206. WriteLn('------------------------------ INT64 --------------------------------');
  207. { left : LOC_REFERENCE }
  208. { right : numeric constant }
  209. WriteLn('(left) : LOC_REFERENCE; (right) : ordinal constant');
  210. int64res:=1;
  211. int64res := int64res shl 15;
  212. Write('(SHL) Value should be 32768...');
  213. if int64res = 32768 then
  214. WriteLn('Success.')
  215. else
  216. WriteLn('Failure.');
  217. int64res:=-1;
  218. int64res := int64res shl 15;
  219. Write('(SHL) Value should be -32768...');
  220. if int64res = -32768 then
  221. WriteLn('Success.')
  222. else
  223. WriteLn('Failure.');
  224. int64res:=1;
  225. int64res := int64res shl 65;
  226. Write('(SHL) Value should be 2...');
  227. if int64res = 2 then
  228. WriteLn('Success.')
  229. else
  230. WriteLn('Failure.');
  231. int64res:=$8000;
  232. int64res := int64res shr 15;
  233. Write('(SHR) Value should be 1...');
  234. if int64res = 1 then
  235. WriteLn('Success.')
  236. else
  237. WriteLn('Failure.');
  238. { int64res:=-1;
  239. int64res := int64res shr 15;
  240. Write('(SHR) Value should be 131071...');}
  241. int64res:=$FFFF;
  242. int64res := int64res shr 65;
  243. Write('(SHR) Value should be 0...');
  244. if int64res = 0 then
  245. WriteLn('Success.')
  246. else
  247. WriteLn('Failure.');
  248. { left : LOC_REFERENCE }
  249. { right : LOC_REFERENCE }
  250. WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REFERENCE');
  251. int64res := 1;
  252. int64cnt := -2;
  253. int64res:=int64res shl int64cnt ;
  254. Write('(SHL) Value should be 1073741824...');
  255. if int64res = 1073741824 then
  256. WriteLn('Success.')
  257. else
  258. WriteLn('Failure.');
  259. int64res:=1;
  260. int64cnt:=15;
  261. int64res := int64res shl int64cnt;
  262. Write('(SHL) Value should be 32768...');
  263. if int64res = 32768 then
  264. WriteLn('Success.')
  265. else
  266. WriteLn('Failure.');
  267. int64res:=-1;
  268. int64cnt := 15;
  269. int64res := int64res shl int64cnt;
  270. Write('(SHL) Value should be -32768...');
  271. if int64res = -32768 then
  272. WriteLn('Success.')
  273. else
  274. WriteLn('Failure.');
  275. int64res := 1;
  276. int64cnt := -2;
  277. int64res:=int64res shr int64cnt ;
  278. Write('(SHR) Value should be 0...');
  279. if int64res = 0 then
  280. WriteLn('Success.')
  281. else
  282. WriteLn('Failure.');
  283. int64res:=32768;
  284. int64cnt:=15;
  285. int64res := int64res shr int64cnt;
  286. Write('(SHR) Value should be 1...');
  287. if int64res = 1 then
  288. WriteLn('Success.')
  289. else
  290. WriteLn('Failure.');
  291. int64res:=-1;
  292. int64cnt := 15;
  293. int64res := int64res shl int64cnt;
  294. Write('(SHR) Value should be -32768...');
  295. if int64res = -32768 then
  296. WriteLn('Success.')
  297. else
  298. WriteLn('Failure.');
  299. { left : LOC_REFERENCE }
  300. { right : LOC_REGISRER }
  301. WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REGISTER');
  302. int64res := 1;
  303. bytecnt := -2;
  304. int64res:=int64res shl bytecnt ;
  305. Write('(SHL) Value should be 1073741824...');
  306. if int64res = 1073741824 then
  307. WriteLn('Success.')
  308. else
  309. WriteLn('Failure.');
  310. int64res:=1;
  311. bytecnt:=15;
  312. int64res := int64res shl bytecnt;
  313. Write('(SHL) Value should be 32768...');
  314. if int64res = 32768 then
  315. WriteLn('Success.')
  316. else
  317. WriteLn('Failure.');
  318. int64res:=-1;
  319. bytecnt := 15;
  320. int64res := int64res shl bytecnt;
  321. Write('(SHL) Value should be -32768...');
  322. if int64res = -32768 then
  323. WriteLn('Success.')
  324. else
  325. WriteLn('Failure.');
  326. int64res := 1;
  327. bytecnt := -2;
  328. int64res:=int64res shr bytecnt ;
  329. Write('(SHR) Value should be 0...');
  330. if int64res = 0 then
  331. WriteLn('Success.')
  332. else
  333. WriteLn('Failure.');
  334. int64res:=32768;
  335. bytecnt:=15;
  336. int64res := int64res shr bytecnt;
  337. Write('(SHR) Value should be 1...');
  338. if int64res = 1 then
  339. WriteLn('Success.')
  340. else
  341. WriteLn('Failure.');
  342. { int64res:=-1;
  343. bytecnt := 15;
  344. int64res := int64res shr bytecnt;
  345. WriteLn('(SHR) Value should be 131071...',int64res);}
  346. {$ENDIF}
  347. end.