home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / articles / archives / limanews.exe / PASCAL2.TXT < prev    next >
Text File  |  2006-10-19  |  13KB  |  359 lines

  1. ORIGINALLY PUBLISHED IN
  2. LIMA NEWSLETTER MARCH 1994
  3.  
  4.     PASCAL WITH THE TI 99  
  5.   by Anders Persson 
  6.  
  7.   Charles Good wrote an article in the
  8. January issue of the Lima newsletter
  9. this year, concerning the p-code card
  10. for the TI 99/4A. When reviewing
  11. software, it's usually impossible to
  12. use it enough to really find out how to
  13. take the best advantage of the program.
  14. That's especially true when the review
  15. concerns something as complex as the
  16. UCSD p-system.  Since I was mentioned
  17. in that article, I couldn't restrain
  18. from adding some of my own comments. 
  19.    
  20.   The idea of the p-system 
  21.    
  22.   Charles asks what's portable with
  23. UCSD Pascal? As things has turned out,
  24. the answer to that question is,
  25. unfortunately, nothing. Due to the
  26. problem with different disk formats,
  27. there has never really been any
  28. portability between different
  29. implementations of UCSD Pascal. It's of
  30. course possible to transmit the source
  31. code via serial ports, with or without
  32. modems, between different computers,
  33. but that's about it. 
  34.   However, there is something that
  35. really is portable with UCSD Pascal.
  36. The original Pascal definition, by
  37. Nicklaus Wirth, is practically useless
  38. for real world interactive programming.
  39. That led to different, more or less
  40. clever extensions to the original.
  41. Some extensions were targeted to
  42. improvement of the language's behavior
  43. in limited memories, while others
  44. improved the ability to program
  45. operating systems in Pascal. 
  46.   Since features introduced with
  47. version IV.0 (the one implemented on
  48. the TI 99) has been an inspiration for
  49. various designers of Pascal compilers,
  50. a lot of Pascal code can be typed in
  51. and executed on the TI.  This is true
  52. also for code neither originally
  53. intended for the UCSD system in
  54. general, nor for the TI in particular.
  55. I have myself transferred a substantial
  56. program (compiled EXE file on the PC is
  57. 55 kbytes) from the TI to Turbo Pascal
  58. version 4, with only minor source code
  59. changes. These were mainly related to
  60. the 80 character wide PC screen and
  61. somewhat different file handling
  62. procedures. 
  63.   Since Turbo Pascal is continually
  64. being developed, in order to meet both
  65. new hardware (faster, bigger) and new
  66. operating environments (like Windows),
  67. the difference does of course grow with
  68. time. As Charles pointed out in his
  69. article, there is no current
  70. development of the p-system. 
  71.    
  72.   The TI implementation  
  73.    
  74.   The unique feature of the TI
  75. implementation is the p-code card
  76. itself. One reason for this card was
  77. probably the always apparent fear that,
  78. unless it was made impossible, people
  79. might copy software and execute it on
  80. their 4A's. By making the hardware
  81. p-code card an essential part of the
  82. Pascal system, that was much more
  83. difficult. But an advantage with this
  84. idea is that you get a ROM-disk,
  85. containing the operating system and the
  86. p-code interpreter, without wasting
  87. valuable RAM memory. We must remember
  88. that this was more than ten years ago,
  89. when 64 kbytes of RAM in a
  90. microcomputer was about as much as
  91. anyone had ever heard about. This was
  92. also a time, when running Pascal on a
  93. home computer, resulted in an impressed
  94. "Wow" from all computer friends that
  95. looked at it. 
  96.   Since UCSD Pascal IV.0 wants to do a
  97. lot of things, it depends heavily on
  98. its memory management. There simply
  99. isn't room for everything at the same
  100. time.  This results in a lot of disk
  101. activity when using the system. In the
  102. beginning, that was quite a nuisance,
  103. but since I made a RAM disk for my
  104. computer, that problem isn't so severe
  105. any longer. Adding four 360 kbyte disk
  106. drives (CorComp controller) also makes
  107. the system run better, since all system
  108. software can be on line at the same
  109. time, together with the application
  110. under development. 
  111.   With this system, I've done the major
  112. part of all software development on my
  113. computer. Built in memory management,
  114. the capabilities for structuring your
  115. programs that's inherent in Pascal,
  116. easy assembly interface and the
  117. adaptability of the system are some of
  118. the reasons. I've modified the p-system
  119. to include true pre-emptive
  120. multitasking, full screen turtle
  121. graphics and to take advantage of my
  122. redesigned 80 kbyte RAM console. 
  123.   A disadvantage of the TI
  124. implementation is that it's not
  125. complete. The unit KERNEL, for example,
  126. isn't included on the disks, at least
  127. not with the interface section intact.
  128. That unit is essential for easy system
  129. programming. Another program that's
  130. missing is the Native Code Generator,
  131. which converts p-code programs to the
  132. assembly instructions of the processor
  133. used with the target machine, the 9900
  134. in this case. This utility, when
  135. available, is used to speed execution
  136. of programs at the cost of code size. 
  137.    
  138.   To use the p-system 
  139.    
  140.   To make the system run faster, the
  141. SYSTEM.STARTUP program should copy all
  142. essential system files to a RAM disk,
  143. to begin with. That makes loading the
  144. Filer, a disk manager with features
  145. still difficult to find in later
  146. programs, fast enough. 
  147.   I haven't had the chance to run any
  148. of the never released programs that
  149. Charles obviously has access to, but I
  150. can at least sort one thing out. A
  151. "fixed pitch printer" is one that
  152. prints like a typewriter, while a
  153. "variable pitch printer" is one capable
  154. of proportional spacing in its
  155. printout. Not an obvious feature for
  156. all low cost printers more than ten
  157. years ago. 
  158.   It's not necessary to press "I" to
  159. initialize each time disks are
  160. replaced. The p-system allows you to
  161. refer to disks by name, not by number,
  162. and automatically tracks where a
  163. particular disk is located. If you move
  164. a disk to another drive, the system
  165. will look for it only once, and then
  166. remember where it's inserted. Myself, I
  167. rarely use the drive numbers, but refer
  168. to my disks with their names. Together
  169. with the ability to refer to the system
  170. disk with an asterisk and a prefixed
  171. disk with a dollar sign, you actually
  172. end up typing less than you do with the
  173. DSK# system. 
  174.   It's true that you first have to
  175. format a disk and then Z(ero its
  176. directory before you can use it with
  177. the p-system, but you don't need an
  178. ordinary disk manager to accomplish
  179. that. The DFORMAT utility takes care of
  180. formatting a disk. Unfortunately, the
  181. original DFORMAT program, supplied on
  182. the Utilities disk, can't handle double
  183. sided disks, although it claims it can.
  184. I've developed an alternative, which
  185. handles every disk format supported by
  186. TI and CorComp controllers, including
  187. utilizing the CorComp variable
  188. interlacing feature. That means
  189. creating disks that are speed optimized
  190. for Pascal. 
  191.   The V(olume command displays all
  192. units currently available to the
  193. p-system. Unit 1, CONSOLE, is the
  194. keyboard and computer screen. Number 2
  195. is SYSTERM (SYStem TERMinal), which is
  196. the same thing as CONSOLE, except that
  197. there is no implied echo on the screen
  198. of characters typed on the keyboard.
  199. Good if you want to read a key without
  200. displaying the character, since there
  201. is no equivalence to the CALL KEY
  202. statement in Pascal. Better still is to
  203. use an assembly routine that looks into
  204. the type ahead queue, to see if there
  205. is a new character stored there. 
  206.   Units 7, REMIN (REMote INput), and
  207. 8, REMOUT (REMote OUTput), refer to the
  208. same physical port. Usually this is a
  209. serial port. On the TI, that's RS232/1
  210. or RS232/2, dependent on where you have
  211. your printer connected. Setting the
  212. name of the physical port used for
  213. these units, as well as for unit 6,
  214. PRINTER, is done by the MODRS232
  215. program on the Utilities disk. The
  216. source code of this program is
  217. included, together with the suggestion
  218. (in the manual) to use this procedure
  219. when you want to change the
  220. configuration within your own program.
  221. The REMOTE unit is mainly intended for
  222. communication purposes other than
  223. printing. 
  224.   Unit 14, OS, contains the procedures
  225. that actually are the operating system.
  226. Most of these reside in a file called
  227. SYSTEM.PASCAL. From a hardware point of
  228. view, this is the GROM chips on the
  229. p-code card. The ROM chips contains the
  230. PME (P Machine Emulator, that
  231. interprets p-code) and low level I/O
  232. routines. 
  233.    
  234.   Pascal programs 
  235.    
  236.   Charles mentioned in his article that
  237. the p-system editor is an 80 column
  238. editor, using windowing left/right.
  239. That's true, but it's also true for the
  240. entire p-system. All programs executing
  241. under the p-system, has access to an 80
  242. column screen. 
  243.   It's a common misunderstanding that
  244. the eventual structure of a Pascal
  245. program should depend upon the
  246. structure of the language itself.
  247. That's absolutely untrue. It's
  248. perfectly possible to misuse Pascal to
  249. such an extent, that the resulting code
  250. couldn't be understood even by the
  251. original creator. The structure of a
  252. program is always a result of a
  253. structured programmer, not any
  254. particular language. However, Pascal
  255. delivers the tools a structured
  256. programmer may need to accomplish his
  257. task, of writing understandable code.
  258. The main benefit of Pascal is not the
  259. indentations that are allowed (but not
  260. compulsory), but the data structure
  261. concept. Unlike traditional BASIC,
  262. which knows nothing more complex than
  263. the array, Pascal allows a programmer
  264. to declare his own data structures,
  265. containing any mixture of data types
  266. required to handle a specific problem. 
  267.   In conjunction with the separately
  268. compiled unit concept, designed mainly
  269. to facilitate memory management, it's
  270. also possible to declare a package of
  271. procedures and data structures. The
  272. benefit of this construction is, that
  273. these procedures work only with their
  274. intended data structures. That reduces
  275. the risk of hard to find errors,
  276. resulting from the correct procedure
  277. applied to wrong data. Apart from the
  278. fact that the unit is static (new
  279. copies can't be created during
  280. execution), this is similair to the
  281. class concept, found in many more
  282. modern and object oriented languages. 
  283.   Charles states that he has found the
  284. p-code card as useful as the Thermal
  285. Printer, which I understand wasn't used
  286. too much. I fully agree with him in
  287. that there isn't much ready to run
  288. software available. Still I think it's
  289. the p-code card that has motivated the
  290. existence of my 99/4A. But that's only
  291. because of its overall performance as a
  292. development system for complex
  293. software. The p-system gives quite a
  294. lot of useful things, like a library
  295. system for commonly used procedures,
  296. memory management with automatic roll
  297. in and roll out of code segments, easy
  298. assembly language interface, floating
  299. point capability when needed and
  300. integers elsewhere and a lot of
  301. technical information about how it
  302. works. It also gives compatibility with
  303. , if not portability between, Pascal
  304. compilers designed for other computer
  305. systems. 
  306.                          
  307.   Getting technical 
  308.    
  309.   The p-code card is located at CRU
  310. address 1F00. The reason for this is
  311. simply the fact that the p-system never
  312. releases control, once it's got it.  In
  313. order to allow all other cards to
  314. execute their power up routines, the
  315. p-code card was best placed last in the
  316. search chain. What about the CorComp
  317. controller, then? 
  318.   Well, since the disk controller is
  319. allocated CRU address 1100, another
  320. solution was used with the CorComp
  321. controller. That card takes command,
  322. but also takes responsibility for
  323. executing the power up routines of all
  324. other cards. The CorComp card assumes
  325. these cards to behave nicely, i.e.
  326. release control to the caller upon
  327. completition of their tasks. Usually,
  328. the only drawback with this scheme is
  329. that power up routines in GROMs are
  330. never found. These routines are rare,
  331. but do exist, for example in the
  332. Terminal Emulator II module. 
  333.   When confronted with the p-code card,
  334. the usual takeover by the CorComp disk
  335. controller is prevented. The p-code
  336. card never returns from its power up
  337. routine. This explains how the p-code
  338. card appears to take control before the
  339. CorComp disk controller. 
  340.   My solution to the somewhat
  341. egocentric behaviour of the CorComp
  342. controller is new EPROMs. These were
  343. once available on the market. Together
  344. with some other minor modifications,
  345. they put an end to the idea of taking
  346. control of the 99/4A before anything
  347. else. Definitely recommended. 
  348.  
  349.   If anyone are interested in
  350. commenting this article, you are
  351. welcomed. Either in Bits, Bytes &
  352. Pixels, or directly to me: 
  353.    
  354.   Anders Persson 
  355.   Drottninggatan 35 
  356.   S-341 36 LJUNGBY 
  357.   Sweden 
  358. .PL 1 
  359.