peek-a-oh

Anything QL Software or Programming Related.
Post Reply
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

peek-a-oh

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


Per
dont be happy. worry
- ?
User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: peek-a-oh

Post by mk79 »

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


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: peek-a-oh

Post 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


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: peek-a-oh

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


Per
dont be happy. worry
- ?
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: peek-a-oh

Post 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!


Per
dont be happy. worry
- ?
User avatar
janbredenbeek
Super Gold Card
Posts: 629
Joined: Wed Jan 21, 2015 4:54 pm
Location: Hilversum, The Netherlands

Re: peek-a-oh

Post 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.


User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: peek-a-oh

Post 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!


Per
dont be happy. worry
- ?
Post Reply