home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 161_01 / ms_dos.d < prev    next >
Text File  |  1985-11-26  |  18KB  |  654 lines

  1. ###alltyp.bat
  2. lc -ms -i\lc\ -i \lc\s\ groups >>cc.out
  3. link c+groups+cputim+returnp+ntim_int+fround+error,groups,,lcm+lc >>cc.out
  4. lc -ms -i\lc\ -i \lc\s\ DADD >>cc.out
  5. link c+DADD+cputim+returnp+begint+ntim_int+fround+error,DADD,,lcm+lc >>cc.out
  6. DADD.exe >DADD.out
  7. groups <DADD.out >DADD.grp
  8. del DADD.obj
  9. del DADD.map
  10. del DADD.exe
  11. lc -ms -i\lc\ -i \lc\s\ DAND >>cc.out
  12. link c+DAND+cputim+returnp+begint+ntim_int+fround+error,DAND,,lcm+lc >>cc.out
  13. DAND.exe >DAND.out
  14. groups <DAND.out >DAND.grp
  15. del DAND.obj
  16. del DAND.map
  17. del DAND.exe
  18. lc -ms -i\lc\ -i \lc\s\ DBAN >>cc.out
  19. link c+DBAN+cputim+returnp+begint+ntim_int+fround+error,DBAN,,lcm+lc >>cc.out
  20. DBAN.exe >DBAN.out
  21. groups <DBAN.out >DBAN.grp
  22. del DBAN.obj
  23. del DBAN.map
  24. del DBAN.exe
  25. lc -ms -i\lc\ -i \lc\s\ DBOR >>cc.out
  26. link c+DBOR+cputim+returnp+begint+ntim_int+fround+error,DBOR,,lcm+lc >>cc.out
  27. DBOR.exe >DBOR.out
  28. groups <DBOR.out >DBOR.grp
  29. del DBOR.obj
  30. del DBOR.map
  31. del DBOR.exe
  32. lc -ms -i\lc\ -i \lc\s\ DDIV >>cc.out
  33. link c+DDIV+cputim+returnp+begint+ntim_int+fround+error,DDIV,,lcm+lc >>cc.out
  34. DDIV.exe >DDIV.out
  35. groups <DDIV.out >DDIV.grp
  36. del DDIV.obj
  37. del DDIV.map
  38. del DDIV.exe
  39. lc -ms -i\lc\ -i \lc\s\ DEOR >>cc.out
  40. link c+DEOR+cputim+returnp+begint+ntim_int+fround+error,DEOR,,lcm+lc >>cc.out
  41. DEOR.exe >DEOR.out
  42. groups <DEOR.out >DEOR.grp
  43. del DEOR.obj
  44. del DEOR.map
  45. del DEOR.exe
  46. lc -ms -i\lc\ -i \lc\s\ DEQ >>cc.out
  47. link c+DEQ+cputim+returnp+begint+ntim_int+fround+error,DEQ,,lcm+lc >>cc.out
  48. DEQ.exe >DEQ.out
  49. groups <DEQ.out >DEQ.grp
  50. del DEQ.obj
  51. del DEQ.map
  52. del DEQ.exe
  53. lc -ms -i\lc\ -i \lc\s\ DLSH >>cc.out
  54. link c+DLSH+cputim+returnp+begint+ntim_int+fround+error,DLSH,,lcm+lc >>cc.out
  55. DLSH.exe >DLSH.out
  56. groups <DLSH.out >DLSH.grp
  57. del DLSH.obj
  58. del DLSH.map
  59. del DLSH.exe
  60. lc -ms -i\lc\ -i \lc\s\ DLT >>cc.out
  61. link c+DLT+cputim+returnp+begint+ntim_int+fround+error,DLT,,lcm+lc >>cc.out
  62. DLT.exe >DLT.out
  63. groups <DLT.out >DLT.grp
  64. del DLT.obj
  65. del DLT.map
  66. del DLT.exe
  67. lc -ms -i\lc\ -i \lc\s\ DMUL >>cc.out
  68. link c+DMUL+cputim+returnp+begint+ntim_int+fround+error,DMUL,,lcm+lc >>cc.out
  69. DMUL.exe >DMUL.out
  70. groups <DMUL.out >DMUL.grp
  71. del DMUL.obj
  72. del DMUL.map
  73. del DMUL.exe
  74. lc -ms -i\lc\ -i \lc\s\ DREM >>cc.out
  75. link c+DREM+cputim+returnp+begint+ntim_int+fround+error,DREM,,lcm+lc >>cc.out
  76. DREM.exe >DREM.out
  77. groups <DREM.out >DREM.grp
  78. del DREM.obj
  79. del DREM.map
  80. del DREM.exe
  81. lc -ms -i\lc\ -i \lc\s\ DRSH >>cc.out
  82. link c+DRSH+cputim+returnp+begint+ntim_int+fround+error,DRSH,,lcm+lc >>cc.out
  83. DRSH.exe >DRSH.out
  84. groups <DRSH.out >DRSH.grp
  85. del DRSH.obj
  86. del DRSH.map
  87. del DRSH.exe
  88. lc -ms -i\lc\ -i \lc\s\ DSUB >>cc.out
  89. link c+DSUB+cputim+returnp+begint+ntim_int+fround+error,DSUB,,lcm+lc >>cc.out
  90. DSUB.exe >DSUB.out
  91. groups <DSUB.out >DSUB.grp
  92. del DSUB.obj
  93. del DSUB.map
  94. del DSUB.exe
  95. lc -ms -i\lc\ -i \lc\s\ UINC >>cc.out
  96. link c+UINC+cputim+returnp+begint+ntim_int+fround+error,UINC,,lcm+lc >>cc.out
  97. UINC.exe >UINC.out
  98. groups <UINC.out >UINC.grp
  99. del UINC.obj
  100. del UINC.map
  101. del UINC.exe
  102. lc -ms -i\lc\ -i \lc\s\ UNEG >>cc.out
  103. link c+UNEG+cputim+returnp+begint+ntim_int+fround+error,UNEG,,lcm+lc >>cc.out
  104. UNEG.exe >UNEG.out
  105. groups <UNEG.out >UNEG.grp
  106. del UNEG.obj
  107. del UNEG.map
  108. del UNEG.exe
  109. lc -ms -i\lc\ -i \lc\s\ UPIN >>cc.out
  110. link c+UPIN+cputim+returnp+begint+ntim_int+fround+error,UPIN,,lcm+lc >>cc.out
  111. UPIN.exe >UPIN.out
  112. groups <UPIN.out >UPIN.grp
  113. del UPIN.obj
  114. del UPIN.map
  115. del UPIN.exe
  116. ###install.bat
  117. lc -ms -i\lc\ -i\lc\s calib  >>icc.out
  118. lc -ms -i\lc\ -i\lc\s begint  >>icc.out
  119. lc -ms -i\lc\ -i\lc\s cputim  >>icc.out
  120. lc -ms -i\lc\ -i\lc\s returnp  >>icc.out
  121. lc -ms -i\lc\ -i\lc\s error  >>icc.out
  122. lc -ms -i\lc\ -i\lc\s fround  >>icc.out
  123. lc -ms -i\lc\ -i\lc\s intreg  >>icc.out
  124. lc -ms -i\lc\ -i\lc\s sstat  >>icc.out
  125. lc -ms -i\lc\ -i\lc\s sauto  >>icc.out
  126. lc -ms -i\lc\ -i\lc\s lauto  >>icc.out
  127. lc -ms -i\lc\ -i\lc\s dauto  >>icc.out
  128. lc -ms -i\lc\ -i\lc\s cauto  >>icc.out
  129. lc -ms -i\lc\ -i\lc\s fauto  >>icc.out
  130.  
  131.  
  132. link c+calib+cputim+returnp+begint+error+fround+ntim_int,calib,,lcm+lc >>icc.out
  133. del calib.map
  134. del calib.obj
  135.  
  136. calib.exe > parms.dat
  137.  
  138. type parms.dat
  139.  
  140.  
  141. link c+cauto+cputim+returnp+begint+error+fround+ntim_int,cauto,,lcm+lc >>icc.out
  142. cauto.exe >cauto.out
  143. del cauto.obj
  144. del cauto.map
  145. del cauto.exe
  146.  
  147.  
  148. link c+fauto+cputim+returnp+begint+error+fround+ntim_int,fauto,,lcm+lc >>icc.out
  149. fauto.exe >fauto.out
  150. del fauto.obj
  151. del dauto.map
  152. del dauto.exe
  153.  
  154.  
  155.  
  156.  
  157.  
  158. link c+intreg+cputim+returnp+begint+error+fround+ntim_int,intreg,,lcm+lc >>icc.out
  159. intreg.exe >intreg.out
  160. del intreg.obj
  161. del intreg.map
  162. del intreg.exe
  163.  
  164.  
  165. link c+sstat+cputim+returnp+begint+error+fround+ntim_int,sstat,,lcm+lc >>icc.out
  166. sstat.exe >sstat.out
  167. del sstat.obj
  168. del sstat.map
  169. del sstat.exe
  170.  
  171.  
  172. link c+sauto+cputim+returnp+begint+error+fround+ntim_int,sauto,,lcm+lc >>icc.out
  173. sauto.exe >sauto.out
  174. del sauto.obj
  175. del sauto.map
  176. del sauto.exe
  177.  
  178.  
  179. link c+lauto+cputim+returnp+begint+error+fround+ntim_int,lauto,,lcm+lc >>icc.out
  180. lauto.exe >lauto.out
  181. del lauto.obj
  182. del lauto.map
  183. del lauto.exe
  184.  
  185.  
  186. link c+dauto+cputim+returnp+begint+error+fround+ntim_int,dauto,,lcm+lc >>icc.out
  187. dauto.exe >dauto.out
  188. del dauto.obj
  189. del dauto.map
  190. del dauto.exe
  191.  
  192.  
  193. lc -ms -i\lc\ -i\lc\s fmttbl  >>icc.out
  194. link c+fmttbl+cputim+returnp+begint+error+fround+ntim_int,fmttbl,,lcm+lc >>icc.out
  195. fmttbl sauto.out cauto.out lauto.out dauto.out fauto.out
  196. ###mkavg.bat
  197. rem after running install.bat you can run mkavg.bat to compute averages
  198. lc -ms -i\lc\ -i\lc\s avg   >>avgcc.out
  199. link c+avg+cputim+returnp+begint+error+fround+ntim_int,avg,,lcm+lc  >>avgcc.out
  200.  
  201. avg intreg.out 10 >intreg.avg
  202. avg sstat.out 10 >sstat.avg
  203. avg sauto.out 10 >sauto.avg
  204. avg lauto.out 50 >lauto.avg
  205. avg dauto.out 400 >dauto.avg
  206. avg cauto.out 10 >cauto.avg
  207. avg fauto.out 400 >fauto.avg
  208. ###runmost.bat
  209. lc -ms -i\lc\ -i \lc\s\ FNCALL >>rcc.out
  210. link c+FNCALL+cputim+returnp+begint+ntim_int+fround+error,FNCALL,,lcm+lc >>rcc.out
  211. FNCALL.exe >FNCALL.out 
  212. del FNCALL.obj
  213. del FNCALL.map
  214. del FNCALL.exe
  215. lc -ms -i\lc\ -i \lc\s\ LOOPS1 >>rcc.out
  216. link c+LOOPS1+cputim+returnp+begint+ntim_int+fround+error,LOOPS1,,lcm+lc >>rcc.out
  217. LOOPS1.exe >LOOPS1.out 
  218. del LOOPS1.obj
  219. del LOOPS1.map
  220. del LOOPS1.exe
  221. lc -ms -i\lc\ -i \lc\s\ LOOPS2 >>rcc.out
  222. link c+LOOPS2+cputim+returnp+begint+ntim_int+fround+error,LOOPS2,,lcm+lc >>rcc.out
  223. LOOPS2.exe >LOOPS2.out 
  224. del LOOPS2.obj
  225. del LOOPS2.map
  226. del LOOPS2.exe
  227. lc -ms -i\lc\ -i \lc\s\ 102 >>rcc.out
  228. link c+102+cputim+returnp+begint+ntim_int+fround+error,102,,lcm+lc >>rcc.out
  229. 102.exe >102.out 
  230. del 102.obj
  231. del 102.map
  232. del 102.exe
  233. lc -ms -i\lc\ -i \lc\s\ 104 >>rcc.out
  234. link c+104+cputim+returnp+begint+ntim_int+fround+error,104,,lcm+lc >>rcc.out
  235. 104.exe >104.out 
  236. del 104.obj
  237. del 104.map
  238. del 104.exe
  239. lc -ms -i\lc\ -i \lc\s\ 105 >>rcc.out
  240. link c+105+cputim+returnp+begint+ntim_int+fround+error,105,,lcm+lc >>rcc.out
  241. 105.exe >105.out 
  242. del 105.obj
  243. del 105.map
  244. del 105.exe
  245. lc -ms -i\lc\ -i \lc\s\ 106 >>rcc.out
  246. link c+106+cputim+returnp+begint+ntim_int+fround+error,106,,lcm+lc >>rcc.out
  247. 106.exe >106.out 
  248. del 106.obj
  249. del 106.map
  250. del 106.exe
  251. lc -ms -i\lc\ -i \lc\s\ 401 >>rcc.out
  252. link c+401+cputim+returnp+begint+ntim_int+fround+error,401,,lcm+lc >>rcc.out
  253. 401.exe >401.out 
  254. del 401.obj
  255. del 401.map
  256. del 401.exe
  257. lc -ms -i\lc\ -i \lc\s\ 402 >>rcc.out
  258. link c+402+cputim+returnp+begint+ntim_int+fround+error,402,,lcm+lc >>rcc.out
  259. 402.exe >402.out 
  260. del 402.obj
  261. del 402.map
  262. del 402.exe
  263. lc -ms -i\lc\ -i \lc\s\ 403 >>rcc.out
  264. link c+403+cputim+returnp+begint+ntim_int+fround+error,403,,lcm+lc >>rcc.out
  265. 403.exe >403.out 
  266. del 403.obj
  267. del 403.map
  268. del 403.exe
  269. lc -ms -i\lc\ -i \lc\s\ 405 >>rcc.out
  270. link c+405+cputim+returnp+begint+ntim_int+fround+error,405,,lcm+lc >>rcc.out
  271. 405.exe >405.out 
  272. del 405.obj
  273. del 405.map
  274. del 405.exe
  275. lc -ms -i\lc\ -i \lc\s\ 411 >>rcc.out
  276. link c+411+cputim+returnp+begint+ntim_int+fround+error,411,,lcm+lc >>rcc.out
  277. 411.exe >411.out 
  278. del 411.obj
  279. del 411.map
  280. del 411.exe
  281. lc -ms -i\lc\ -i \lc\s\ 413 >>rcc.out
  282. link c+413+cputim+returnp+begint+ntim_int+fround+error,413,,lcm+lc >>rcc.out
  283. 413.exe >413.out 
  284. del 413.obj
  285. del 413.map
  286. del 413.exe
  287. lc -ms -i\lc\ -i \lc\s\ 501 >>rcc.out
  288. link c+501+cputim+returnp+begint+ntim_int+fround+error,501,,lcm+lc >>rcc.out
  289. 501.exe >501.out 
  290. del 501.obj
  291. del 501.map
  292. del 501.exe
  293. lc -ms -i\lc\ -i \lc\s\ 503 >>rcc.out
  294. link c+503+cputim+returnp+begint+ntim_int+fround+error,503,,lcm+lc >>rcc.out
  295. 503.exe >503.out 
  296. del 503.obj
  297. del 503.map
  298. del 503.exe
  299. lc -ms -i\lc\ -i \lc\s\ 504 >>rcc.out
  300. link c+504+cputim+returnp+begint+ntim_int+fround+error,504,,lcm+lc >>rcc.out
  301. 504.exe >504.out 
  302. del 504.obj
  303. del 504.map
  304. del 504.exe
  305. lc -ms -i\lc\ -i \lc\s\ 505 >>rcc.out
  306. link c+505+cputim+returnp+begint+ntim_int+fround+error,505,,lcm+lc >>rcc.out
  307. 505.exe >505.out 
  308. del 505.obj
  309. del 505.map
  310. del 505.exe
  311. lc -ms -i\lc\ -i \lc\s\ 506 >>rcc.out
  312. link c+506+cputim+returnp+begint+ntim_int+fround+error,506,,lcm+lc >>rcc.out
  313. 506.exe >506.out 
  314. del 506.obj
  315. del 506.map
  316. del 506.exe
  317. lc -ms -i\lc\ -i \lc\s\ 507 >>rcc.out
  318. link c+507+cputim+returnp+begint+ntim_int+fround+error,507,,lcm+lc >>rcc.out
  319. 507.exe >507.out 
  320. del 507.obj
  321. del 507.map
  322. del 507.exe
  323. lc -ms -i\lc\ -i \lc\s\ 508 >>rcc.out
  324. link c+508+cputim+returnp+begint+ntim_int+fround+error,508,,lcm+lc >>rcc.out
  325. 508.exe >508.out 
  326. del 508.obj
  327. del 508.map
  328. del 508.exe
  329. lc -ms -i\lc\ -i \lc\s\ 601 >>rcc.out
  330. link c+601+cputim+returnp+begint+ntim_int+fround+error,601,,lcm+lc >>rcc.out
  331. 601.exe >601.out 
  332. del 601.obj
  333. del 601.map
  334. del 601.exe
  335.  
  336. ###runmost2.bat
  337. lc -ms -i\lc\ -i \lc\s\ switch >>rcc2.out
  338. link c+switch+cputim+returnp+begint+ntim_int+fround+error,switch,,lcm+lc >>rcc2.out
  339. switch.exe >switch.out 
  340. del switch.obj
  341. del switch.map
  342. del switch.exe
  343.  
  344. lc -ms -i\lc\ -i \lc\s\ ctypelib >>rcc2.out
  345. link c+ctypelib+cputim+returnp+begint+ntim_int+fround+error,ctypelib,,lcm+lc >>rcc2.out
  346. ctypelib.exe >ctypelib.out 
  347. del ctypelib.obj
  348. del ctypelib.map
  349. del ctypelib.exe
  350.  
  351. lc -ms -i\lc\ -i \lc\s\ fdliblib >>rcc2.out
  352. link c+fdliblib+cputim+returnp+begint+ntim_int+fround+error,fdliblib,,lcm+lc >>rcc2.out
  353. fdliblib.exe >fdliblib.out 
  354. del fdliblib.obj
  355. del fdliblib.map
  356. del fdliblib.exe
  357.  
  358. lc -ms -i\lc\ -i \lc\s\ mathlib >>rcc2.out
  359. link c+mathlib+cputim+returnp+begint+ntim_int+fround+error,mathlib,,lcm+lc >>rcc2.out
  360. mathlib.exe >mathlib.out 
  361. del mathlib.obj
  362. del mathlib.map
  363. del mathlib.exe
  364.  
  365. lc -ms -i\lc\ -i \lc\s\ strlib >>rcc2.out
  366. link c+strlib+cputim+returnp+begint+ntim_int+fround+error,strlib,,lcm+lc >>rcc2.out
  367. strlib.exe >strlib.out 
  368. del strlib.obj
  369. del strlib.map
  370. del strlib.exe
  371.  
  372. lc -ms -i\lc\ -i \lc\s\ stdlib >>rcc2.out
  373. link c+stdlib+cputim+returnp+begint+ntim_int+fround+error,stdlib,,lcm+lc >>rcc2.out
  374. stdlib.exe >stdlib.out 
  375. del stdlib.obj
  376. del stdlib.map
  377. del stdlib.exe
  378.  
  379. lc -ms -i\lc\ -i \lc\s\ stdiolib >>rcc2.out
  380. link c+stdiolib+cputim+returnp+begint+ntim_int+fround+error,stdiolib,,lcm+lc >>rcc2.out
  381. stdiolib.exe >stdiolib.out 
  382. del stdiolib.obj
  383. del stdiolib.map
  384. del stdiolib.exe
  385.  
  386. lc -ms -i\lc\ -i \lc\s\ harness1 >>rcc2.out
  387. link c+harness1+cputim+returnp+begint+ntim_int+fround+error,harness1,,lcm+lc >>rcc2.out
  388. rem harness1
  389. time
  390. harness1.exe >harness1.out 
  391. time
  392. del harness1.obj
  393. del harness1.map
  394. del harness1.exe
  395.  
  396. lc -ms -i\lc\ -i \lc\s\ harness2 >>rcc2.out
  397. link c+harness2+cputim+returnp+begint+ntim_int+fround+error,harness2,,lcm+lc >>rcc2.out
  398. rem harness2
  399. time
  400. harness2.exe >harness2.out 
  401. time
  402. del harness2.obj
  403. del harness2.map
  404. del harness2.exe
  405.  
  406. lc -ms -i\lc\ -i \lc\s\ harness3 >>rcc2.out
  407. link c+harness3+cputim+returnp+begint+ntim_int+fround+error,harness3,,lcm+lc >>rcc2.out
  408. rem harness3
  409. time
  410. harness3.exe >harness3.out 
  411. time
  412. del harness3.obj
  413. del harness3.map
  414. del harness3.exe
  415.  
  416. lc -ms -i\lc\ -i \lc\s\ harness4 >>rcc2.out
  417. link c+harness4+cputim+returnp+begint+ntim_int+fround+error,harness4,,lcm+lc >>rcc2.out
  418. rem harness4
  419. time
  420. harness4.exe >harness4.out 
  421. time
  422. del harness4.obj
  423. del harness4.map
  424. del harness4.exe
  425.  
  426.  
  427. lc -ms -i\lc\ -i \lc\s\ optimtst >>rcc2.out
  428. link c+optimtst+cputim+returnp+begint+ntim_int+fround+error,optimtst,,lcm+lc >>rcc2.out
  429. optimtst.exe >optimtst.out 
  430. del optimtst.obj
  431. del optimtst.map
  432. del optimtst.exe
  433.  
  434. ###config.h
  435. /* config.h - configuration data for each environment
  436.  *        This file should either be customized to the intended
  437.  *        compiler/machine environment, or parameterized via -D flags
  438.  *        on the compile step:
  439.  *        -D UTINY    if compiler supports unsigned char
  440.  *        -D USHORT    if compiler supports unsigned short
  441.  *        -D ULONG    if compiler supports unsigned LONG
  442.  *        -D VOID        if compiler supports void
  443.  */
  444. /* no UTINY - Lattice PC 2.10 compiler */
  445. /* no USHORT - Lattice PC 2.10 compiler */
  446. /* no ULONG - Lattice PC 2.10 compiler */
  447. /* no VOID - Lattice PC 2.10 compiler */
  448. #ifdef USHORT
  449. typedef unsigned short ushort;
  450. #else
  451. typedef unsigned ushort;    /* assumes short == int */
  452. #endif
  453. #ifdef UTINY
  454. typedef unsigned char utiny;
  455. #endif
  456. #ifdef ULONG
  457. typedef unsigned long ulong;
  458. #endif
  459. #ifndef VOID
  460. #define void int
  461. #endif
  462. #define MINSAM 1000        /* minimum timing sample (usec) */
  463. #define NTRY 100        /* maximum no of code excerpts per file */
  464. #define FR_ANCHOR arg1    /* what is the "frame anchor": arg1 or var1 */
  465. #define RETOFFSET (-1)    /* offset of return pointer
  466.                            relative to frame anchor */
  467. #define JUNKFILE "c:junkfile"
  468. ###cputim.c
  469. /*
  470.  *   cputim.c           Christopher Skelly    
  471.  *                                    
  472.  *         Returns a long time containing the number of clock    
  473.  *         ticks since the last call of cputim. Returns zero on    
  474.  *         the first call. Clock assumes a 1.193182e+6 standard    
  475.  *         PC clockrate, and sets 8253 timer channel zero to    
  476.  *         operate in mode two on the first call.         
  477.  *                                    
  478.  */
  479. #include <stdio.h>
  480.  
  481. #define COUNTDOWN   65535
  482. #define BIOSOVHD    136        /* ticks per bios-tick overhead */
  483. #define OVHD        453        /* overhead for fn execution */
  484.  
  485. long clockfuzz = 0;            /* cumulative time correction */
  486.  
  487. /* cputim - return time (in ticks) since last call */
  488. long cputim()
  489.     {
  490.     extern ntim_int();      /* 8086 routine to load the time struct   */
  491.  
  492.     unsigned latch_dif;     /* timer latch difference since last call */
  493.     unsigned cnt_dif;        /* BIOS TIMER_LOW difference (corrected)  */
  494.     unsigned ovhd = OVHD;    /* overhead from bios-tick + fn-exec */
  495.     unsigned junk = ~0;        /* used so all calls take same time */
  496.     unsigned junk2 = ~0;    /* used so all calls take same time */
  497.     static int first = 1;    /* flag for first call        */
  498.  
  499.     static struct t
  500.         {
  501.         unsigned latch;
  502.         unsigned tlow;
  503.         unsigned thigh;
  504.         } time = {0}, oldtime = {0};
  505.     /* if first entry, initialize the clock chip */
  506.     if (first)    /* first time through */
  507.         {
  508.         /* set the 8253 timer chip:
  509.          * channel 0, mode 2, write bytes */
  510.         outp(67, 52);    /* 00110100b */
  511.         outp(64, 0);
  512.         outp(64, 0);
  513.  
  514.         first = 0;
  515.  
  516.         for (junk = 64000; junk < 65000; ++junk)
  517.             ;        /* soak up some time */
  518.         cputim();    /* make first result more reliable */
  519.         }
  520.  
  521.     ntim_int(&time);    /* 8086 routine */
  522.  
  523.     cnt_dif = time.tlow - oldtime.tlow;
  524.  
  525.     if (time.latch < oldtime.latch)
  526.         --cnt_dif, ovhd += BIOSOVHD;    /* "borrow" */
  527.     else
  528.         --junk, junk2 += BIOSOVHD;
  529.  
  530.     latch_dif = time.latch - oldtime.latch;
  531.  
  532.     oldtime.latch = time.latch;
  533.     oldtime.thigh = time.thigh;
  534.     oldtime.tlow  = time.tlow;
  535.  
  536.     clockfuzz += cnt_dif * BIOSOVHD + ovhd;
  537.  
  538.     return ((long)cnt_dif * (COUNTDOWN-BIOSOVHD) + latch_dif - ovhd);
  539.     }
  540. ###cputim.h
  541. /* cputim.h  */
  542. #ifndef TIME_H
  543. #define TIME_H
  544. #define CLOCK_TICKS_PER_SECOND 1193182
  545. typedef long cputim_t;
  546. extern cputim_t cputim();
  547. #endif
  548. ###ntim_int.asm
  549. ;
  550. ;CHEADER.INC -- HEADER FILE FOR MICROSOFT C AND LATTICE ASM ROUTINES
  551. ;
  552. PGROUP    GROUP    PROG           ; Standard heading
  553. PROG    SEGMENT BYTE PUBLIC 'PROG'
  554.     ASSUME CS:PGROUP
  555. ;
  556. REG    STRUC
  557. AXR    DW    ?
  558. TLO    DW    ?
  559. THI    DW    ?
  560. REG    ENDS
  561. ;
  562. BIOS_DATA_SEG    EQU    40H
  563. BIOS_DATA         SEGMENT AT 40H
  564.         ORG    6CH
  565. TIMER_LOW    DW    ?
  566. TIMER_HIGH    DW    ?
  567. BIOS_DATA    ENDS
  568. ;
  569. TIMER_0     EQU    40H
  570. TIMER_CTL    EQU    43H
  571. TIMER_0_LATCH    EQU    00H
  572. ;
  573.     PUBLIC    NTIM_INT
  574. NTIM_INT    PROC    NEAR
  575.     PUSH    BP
  576.     MOV    BP,  SP
  577.     MOV    SI, [BP + 4]
  578.  
  579.     PUSH    DS         ;save data segment
  580.     MOV    AX,  BIOS_DATA_SEG
  581.     MOV    DS, AX
  582.     ASSUME    DS:BIOS_DATA
  583.  
  584.     MOV    AL, TIMER_0_LATCH
  585.    ;CLI
  586.     OUT    TIMER_CTL, AL
  587.     MOV    BX, TIMER_LOW
  588.     MOV    CX, TIMER_HIGH
  589.     IN    AL, TIMER_0
  590.     MOV    AH, AL
  591.     NOP
  592.     IN    AL, TIMER_0
  593.    ;STI
  594.     XCHG    AH, AL
  595.     NEG    AX
  596.  
  597.     POP    DS
  598.     MOV    [SI].AXR,  AX
  599.     MOV    [SI].TLO, BX
  600.     MOV    [SI].THI, CX
  601.  
  602.     POP    BP
  603.     RET
  604.  
  605. NTIM_INT ENDP
  606. PROG    ENDS
  607.     END
  608.  
  609. ###readme.
  610. to run the timing suite on lattice PC
  611.  
  612. first of all, be sure that your lattice compile procedure
  613. specifies the  -c  ("standard non-nesting comments") flag.
  614.  
  615. the source disk requires these steps to run:
  616.  
  617. you will probably want all this in a hard disk directory;
  618. the procedure involves dozens of compiles.
  619. the stdiolib test needs lots of free disk space, 200 K would suffice.
  620.  
  621. assemble ntim_int.asm to produce ntim_int.obj
  622.  
  623. run  install.bat
  624.  
  625.     this produces the tables for basic operations, and creates the
  626.     object files needed for the other steps.
  627.  
  628. run  mkavg.bat
  629.  
  630.     this does some simple "cluster analysis" to produce an
  631.     "average time" estimate for each data category.  any time
  632.     that is within a factor of 3 of the average is included in
  633.     the average; the out-of-range times are listed individually.
  634.  
  635. run  runmost.bat
  636.  
  637.     this times various control structures
  638.  
  639. run  runmost2.bat
  640.  
  641.     more control structures, library tests, simple timing harnesses
  642.  
  643. run  alltyp.bat
  644.  
  645.     this times each C operator on all the basic types, and
  646.     produces a "grouping" of significantly different categories.
  647.     (in other words, what combintions of type and storage class
  648.     affect the timing of each operator.)
  649.  
  650. call with any questions.
  651.  
  652. tom plum  609-927-3770
  653. ###EOF
  654.