Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
GRASS (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Description == :''This description is based on the original Bally manuals as well as the ACM description.{{sfn|DeFanti|Fenton|Donato|1978}} Zgrass was based on a standard set of BASIC commands and used most of its syntax. Where Zgrass differed from BASIC was that all commands were in fact [[function (programming)|function]]s and returned values, similar to the [[C (programming language)|C programming language]]. If there was no obvious return value it was expected that a function would return 1 if it succeeded, and 0 if it failed. For instance, the command <code>PRINT PRINT 10</code> would be illegal in BASIC, but in Zgrass this would print <code>10 1</code>, the 1 being the value returned by second <code>PRINT</code>, meaning "I successfully output the string '10'". Programs in Zgrass were referred to as "macros", and stored as strings. Both of these oddities were deliberate, as Zgrass allowed any string to become a program. For instance, <code>MYBOX="BOX 0,0,100,100,2"</code> defines a string (no need for a $ on the variable as in [[Microsoft BASIC]]s) containing a snippet of Zgrass code. Simply typing {{code|MYBOX}} from that point on would run the command(s) inside. This feature can be used in place of the more traditional <code>GOSUB</code> command from BASIC, but has the added advantage of having a well-defined name as opposed to an opaque line number. In addition, the command remains in the form of a string in memory and can be manipulated at runtime with standard string operations. Most BASIC [[interpreter (computing)|interpreters]] of the era converted the input text into a ''[[Lexical analysis|tokenized]]'' version in which each of the commands was replaced by a single number (typically one [[byte]] long). This made the program run faster because it didn't have to continually decode the commands from the strings every time. Zgrass's use of string-based macros made this difficult, so they didn't bother with tokenization. Instead, they included a [[compiler]] which could be used on any particular macro, speeding it up many times. Programs would often consist of a mix of compiled and uncompiled macros. Line numbers were optional in Zgrass, and typically only appeared on lines that were the target of a <code>GOTO</code>. Most BASIC interpreters required line numbers for every line of code, but this was due to their use in the "line editor"–if you needed to edit a particular line, the only way to refer to it was by number. Zgrass used a more advanced full-screen editor that eliminated this need. Zgrass allowed any string to act as a "line number", {{code|GOTO 10}} and {{code|GOTO MARKER}} were both valid. Zgrass also included nameless branches, using the {{code|SKIP}} instruction, which would move forward or back a given number of lines. This is important in Zgrass as the line numbers were optional and different macros might make use of the same labels. For instance, some variation on {{code|LOOPSTART}} is likely to be found in many bits of code, and thus {{code|GOTO LOOPSTART}} might result in a name clash. Using {{code|SKIP}} avoided this possibility. In keeping with its original purpose as a graphics language, Zgrass included numerous commands for simple drawing. Zgrass's coordinate system had one point for each pixel in the high-resolution mode of Nutting's graphics chip, giving a 320Γ202 grid. The Astrocade, by design, could only use that chip's low-resolution mode, a 160Γ101 display. To avoid potential mapping problems, the coordinate space's zero point was placed in the center of the screen. −160 to 160 were valid X locations, and -101 to 101 valid Y locations. For use on the Astrocade you used the positive locations only, whereas on the UV-1 the entire space was available. Zgrass added a fairly complete set of array functions, as arrays are widely used in graphics. This included the ability to "capture" parts of the display into an array as a [[bitmap]], which could then be manipulated as any other graphic item. This allowed Zgrass to include sprite-like functionality in the language, something the Nutting hardware did not directly include. Another feature the Astrocade did not include was the ability to process arrays with any reasonable speed, so the UV-1 included a Zilog supplied [[floating-point unit|FPU]] for added performance. Zgrass included three priorities (called ''levels'') that allowed macros to be run normally, or in "foreground" or "background" levels. This added a simple form of [[computer multitasking|multitasking]] which was tremendously useful in an animation-oriented language. Game authors could place joystick-reading routines in a macro set to run in the background, and then the joystick would be read automatically whenever the current drawing macro completed. Functions placed in the foreground ran before either, and was often used for timers and other "low latency" needs. Zgrass included a {{code|TIMEOUT}} function that would call macros on a timed basis, making the implementation of timers very easy. Zgrass also included a series of commands that "covered" CP/M, which allowed the disk to be accessed without exiting to the command prompt. You could easily save out macros to named files, and load them in the same way, allowing you to construct programs by loading up various macros from the disk into one large program. The commands also automatically made a backup copy of every save. Similar features were supported for [[Compact Cassette (data)|Compact Cassette]] storage, but oddly the syntax was not parallel: disk commands were D-something, like {{code|DPUT}}, but tape commands were not T-something, like {{code|TPUT}}, but rather something-TAPE, like {{code|PUTTAPE}}. With programs constructed from arbitrarily selected modules, Zgrass needed to have better control over its variables than BASIC. In BASIC all variables are "global", so if two subroutines both use the variable {{code|I}}, which is very commonly used as a loop index variable, then they could set each other's values which leads to hard-to-debug problems. Under Zgrass a programmer loading up two modules could easily find that both used {{code|I}} as a loop counter, which could cause problems. To address this issue, Zgrass considered variables named with [[lowercase]] letters to be local only to that macro, so {{code|I}} and {{code|i}} were different variables, global and local respectively. Oddly, the examples provided with the language do not make widespread use of this feature, potentially confusing new programmers who might not be aware the feature exists.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)