80-Bus News

  

May–June 1983 · Volume 2 · Issue 3

Page 55 of 59

Both manuals give formal definitions of the syntax of the Pascal the compilers will accept. Hisoft use these syntax diagrams with one way arrows to show you what can go where, while Compas have done a very careful job of writing out a full Backus Naur definition of the language. In case you are not familiar with BNF, it tends to look like this:–

(program) ::= (program heading) (black) .
(program heading) ::= (empty) | PROGRAM (file and so on and so on…

I find syntax diagrams a million times easier to ready even though they are not as pleasing to the mathematical minds and I believe they are a better wav of doing things. You may disagrees if you are fond of mathematical formalism for its own sake, rather than where it is useful. Both compilers come complete with example programs. The ones Hisoft give you are printed in the manual, so you have to type them in for yourself, if you want to use them. One of them, which is supposed to be able to read a CP/M disc directory into memory, doesn’t work with my CP/M, although I am told it does with others. Compas’s examples are already on the discs so all you have to do is compile them and run them. They are very nice examples, too. One of them is a calculator program, which makes your expensive Nascom [or similar] work just like a £5 pocket calculator. Another is a quite useful address and telephone number file handling program, and there is also one that can do hex dumps of files from disc.

The precision of real number calculations is not the same in both systems. Hisoft gives you seven significant figures, while Compas gives you eleven. Of course, if you need even more precise figures than that, you can program your way round the restriction with either compiler, as I mentioned in a previous article. They both use two bytes to store an integer, which gives you the usual −32768 to 32767 range of values. Compas doesn’t tell you if an integer variable has overflowed, whereas Hisoft does, unless you set a compiler option to omit overflow checks. This would make the program run faster, but I usually forget to do it, and I have no complaints about the speed Hisoft programs run at! With Compas, you have to set a compiler option if you want to use recursion. I used to think using recursion was just showing off, until I needed it once or twice.

Compas has a data type that is not used in standard Pascal, or Hisoft for that matters and it is the string. Normally, in Pascal, one uses arrays of characters, and writes routines to manipulate them. It can be done, although I never finished the set of routines I was working on a while ago. The lack of strings in Pascal is a real downer. Compas strings are very much like BASIC strings, although the way it chops strings up [equivalent to left$, right$, and mid$] uses a notation like that of the peculiar BASIC in the Sinclair ZX81. Still, it is there, and strings can be cut up, concatenated and generally messed around as much as you like.

Extensions to Pascal.

Both compilers give you direct access to the contents of memory, Compas does it by means of what they call “the memory array”, which behaves much like an ordinary Pascal array, whose contents are the Z80’s address space. Hisoft have added the words PEEK and POKE to the language, but these are not the single byte operations users of non structured BASIC know and love. If you poke an address with a data type that takes more than one byte, all the bytes of the source item are poked into successive memory locations. In other words, POKE(£F80A,'Heading') would put the word “Heading” on the top line of the screen. This is very useful!

The Z80 ports can also be accessed using either compiler. Hisoft have the reserved words IN and OUT, while Compas uses another of its special arrays which is referred to as the port array.

Page 55 of 59