Page 1 of 1

peek-a-oh

Posted: Tue Feb 06, 2018 12:07 pm
by pjw
Could someone please tell me whether there is a location in QDOS/SMSQ guaranteed
to always yield a zero word? Ie PEEK_W(<location>) = 0. (And while were at it, for a
rainy day, a long word?)

Re: peek-a-oh

Posted: Tue Feb 06, 2018 5:20 pm
by mk79
I almost fear the answer, but... why???

Re: peek-a-oh

Posted: Tue Feb 06, 2018 5:45 pm
by tofro
The best place to PEEK_W a zero from is one you POKE_Wd a zero before.

(I'm a bit lost on what this could be good for, though)

Tobias

Re: peek-a-oh

Posted: Tue Feb 06, 2018 6:02 pm
by pjw
Hehe. Its no big deal, but a certain algorithm Im using requires a sentinel; a pointer to
some lowest value in memory. I thought if there were any spare zeros kicking around it
would save me the trouble (code and two bytes) to use that instead. I assumed
(erroneously, it appears) that such a technique would not be considered bizarre in this
august company ;)

Re: peek-a-oh

Posted: Tue Feb 06, 2018 6:26 pm
by pjw
On the QL there used to be a "safe" zero word at 163842, but thats gone now ;) Not my algorithm, not my idea!

Re: peek-a-oh

Posted: Wed Feb 07, 2018 12:29 pm
by janbredenbeek
You could try the first entry of the slave block table, which is pointed to by SV.BTBAS ($28058). This will always be marked 'unusable' (all zeroes) since this entry corresponds to the first slave block in RAM, which starts at $28000 (or $30000 with dual-screen Minerva) and is unusable because the system variables start there. I cannot give any guarantee that this works in every version of SMSQ/E though...
One method that is guaranteed to work is calling MT.ALCHP with a small value (16 or so) which returns a pointer to an allocated area that is guaranteed to contain zeroes.

Jan.

Re: peek-a-oh

Posted: Wed Feb 07, 2018 4:07 pm
by pjw
janbredenbeek wrote:You could try the first entry of the slave block table, which is pointed to by SV.BTBAS ($28058). <>
Thanks for the tip! However, I sensed such a chill wind of disapproval at the notion, that I quickly had to disown the idea (Not my pig, not my farm..)! So I re-wrote the whole thing and eliminated the problem :)
One method that is guaranteed to work is calling MT.ALCHP with a small value (16 or so) which returns a pointer to an allocated area that is guaranteed to contain zeroes.
Yes, I guess were not poking Spectrums anymore, so throwing away a few good bytes - who cares? ;)
Thanks for all replies!