peek-a-oh

Anything QL Software or Programming Related.
User avatar
pjw
Gold Card
Posts: 380
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

peek-a-oh

Postby pjw » Tue Feb 06, 2018 12:07 pm

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?)


Per
For every complex problem there is an answer that is clear, simple, and wrong.
- H. L. Mencken
User avatar
mk79
Over Heated PSU
Posts: 142
Joined: Sun Feb 02, 2014 10:54 am

Re: peek-a-oh

Postby mk79 » Tue Feb 06, 2018 5:20 pm

I almost fear the answer, but... why???


User avatar
tofro
QL Wafer Drive
Posts: 1377
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: peek-a-oh

Postby tofro » Tue Feb 06, 2018 5:45 pm

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


User avatar
pjw
Gold Card
Posts: 380
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: peek-a-oh

Postby pjw » Tue Feb 06, 2018 6:02 pm

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 ;)


Per
For every complex problem there is an answer that is clear, simple, and wrong.
- H. L. Mencken
User avatar
pjw
Gold Card
Posts: 380
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: peek-a-oh

Postby pjw » Tue Feb 06, 2018 6:26 pm

On the QL there used to be a "safe" zero word at 163842, but thats gone now ;) Not my algorithm, not my idea!


Per
For every complex problem there is an answer that is clear, simple, and wrong.
- H. L. Mencken
User avatar
janbredenbeek
Gold Card
Posts: 254
Joined: Wed Jan 21, 2015 4:54 pm
Location: Hilversum, The Netherlands

Re: peek-a-oh

Postby janbredenbeek » Wed Feb 07, 2018 12:29 pm

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.


User avatar
pjw
Gold Card
Posts: 380
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: peek-a-oh

Postby pjw » Wed Feb 07, 2018 4:07 pm

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!


Per
For every complex problem there is an answer that is clear, simple, and wrong.
- H. L. Mencken

Return to “Software & Programming”

Who is online

Users browsing this forum: janbredenbeek and 4 guests