I just typed in the 1k version of pumpkin for the zx81 and have a question:
I noticed that this version is using a lot of VAL statements but where is the information coming from
Logic would dictate that the CPU would be getting the info from data statements. Obviously sinclair basic lacks this (until the speccy anyway) so how exactly does this code function? What's happening here. can someone break this down step by step?
https://archive.org/details/syncmagazin ... ew=theater
page 11
what is this code doing exactly?
what is this code doing exactly?
In Heck, there are two options for perpetual torment:
Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
Re: what is this code doing exactly?
VAL interprets the string as a number or expression of a number (i.e. with functions and other calculations). Most of the use was to save memory (i.e. VAL "5" is the same as 5 but, but the first is 4 bytes and the second is 7 bytes). The most complicated is line 15, but you could remove the VAL and quotes and would run just fine, just may not fit in 1K.
- 1024MAK
- Posts: 5189
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: what is this code doing exactly?
This may sound strange, but it is due to the way that numbers are stored.
A numerical constant in the program, both the visible “text” is stored and also an internal floating point representation of it (which is hidden during listing) which takes up six bytes. Hence the number 5 takes up a total of seven bytes in memory. See also the chapter 27 in the manual here. The link to the full manual is here.
However numbers in between double quotes like “5” are treated as plain text. So VAL “5” uses four bytes (including one byte for the keyword ’token’ used for ‘VAL’.
The advantage as SafePit says, is by using VAL you save memory compared to not doing so. Very useful for a machine that only has 1K bytes of RAM. The downside is that using VAL in this way is slower.
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.