Useful SuperBASIC POKEs and PEEKs?

Anything QL Software or Programming Related.
Post Reply
User avatar
TMD2003
Trump Card
Posts: 168
Joined: Sat Oct 10, 2020 12:18 pm

Useful SuperBASIC POKEs and PEEKs?

Post by TMD2003 »

The thought has just occurred: is there a list of POKEs and PEEKs for the (original black box) QL out there anywhere?

I have a fairly chunky list for the Spectrum, as you might expect - from POKE 23658,8 (which everyone knows - this forces CAPS LOCK on) to PEEK 2899 (=165 for a 16K/48K Spectrum, =159 for a toastrack/+2, =126 for a +2A/+3, and this is far less well known). I found myself thinking: "wouldn't it be great if the Spectrum (and ZX81 and ZX80) had a POKE_W and PEEK_W so that poking a two-byte number into two addresses without having to calculate the two bytes manually in BASIC?"

For instance: if I want to know the bytes of memory remaining (very important on a 16K Spectrum), I need to type this:
PRINT (PEEK 23730+256*PEEK 23731)-(PEEK 23653+256*PEEK 23654)
This is PEEKing the system variables RAMTOP and STKEND and subtracting the second from the first. But wouldn't this be great:
PRINT (PEEK_W 23730-PEEK_W 23653)
And yes, I know, odd numbers won't work with PEEK_W on the QL, this is merely an illustration.

Likewise: I wrote a short machine code routine to convert decimal into hex and binary in one shot, and started with a two-byte equivalent. The BASIC proof-of-concept program to get the value for conversion starts with:
10 INPUT d
20 POKE 60003,INT(d/256): POKE 60002,d-256*PEEK 60003

I'd find 20 POKE_W d to be a lot more convenient.

So I think of the QL more times than you'd realise when programming its predecessors, but I know little about the QL's own equivalents. And if anyone is ever going to say "RTFM", then the famous Spectrum POKE I've just given above would not have been even slightly obvious from the manual - all it says in the list of system variables is that 23658 is "various flags". It makes no mention of bit 3 showing whether the CAPS LOCK is on or off.


Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
tofro
Font of All Knowledge
Posts: 2702
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Useful SuperBASIC POKEs and PEEKs?

Post by tofro »

TMD2003 wrote: I found myself thinking: "wouldn't it be great if the Spectrum (and ZX81 and ZX80) had a POKE_W and PEEK_W so that poking a two-byte number into two addresses without having to calculate the two bytes manually in BASIC?"
Beta Basic for the Spectrum has, amongst lots of other goodies, a DPOKE command that pokes a 16-bit-value into two consecutive adresses (and yes, it can even do odd addresses ;) )


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
TMD2003
Trump Card
Posts: 168
Joined: Sat Oct 10, 2020 12:18 pm

Re: Useful SuperBASIC POKEs and PEEKs?

Post by TMD2003 »

That could be handy. There's still so much more to explore... there's this, there's Boriel BASIC, there's NextBASIC (when my Next arrives...)

I'm going to have to live far beyond the life expectancy I already have if I want to fit it all in!


Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
TMD2003
Trump Card
Posts: 168
Joined: Sat Oct 10, 2020 12:18 pm

Re: Useful SuperBASIC POKEs and PEEKs?

Post by TMD2003 »

Also, while I'm here: I have never looked into 68000 assembly language before, any more than a brief cursory glance over some of the opcodes in... some documents that Dilwyn might be hosting, or could have been somewhere else.

But one of you is sure to know: does the 68000 have its own equivalent of LDIR (or LDDR, or preferably both)?


Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
tofro
Font of All Knowledge
Posts: 2702
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Useful SuperBASIC POKEs and PEEKs?

Post by tofro »

It sortof has, but not as a single command (but also more flexible). You would use the DBRA opcode and a load-store operation.

Code: Select all

	move.w.	#100-1,d0	; loop count -1
	lea		source,a5		; source pointer
	lea 		dest,a6		; destination pointer
loop
	move.l 	(a5)+,(a6)+	; the data movement, also increments pointers
	dbra 	d0,loop		; counts down loop counter to -1. If not met, loop around
	


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
nitrofurano
Chuggy Microdrive
Posts: 53
Joined: Sat Nov 16, 2013 10:48 am

Re: Useful SuperBASIC POKEs and PEEKs?

Post by nitrofurano »

and back to the first message of this thread, i think that the context would be the system variables area from superbasic, as we have the same from all, or almost all basic interpreters (like zx-spectrum, msx, and so on)? so, where can we find superbasic system variables area documented? and also the i/o memory map, and the relevant parts of rom memory (from the original unexpanded ql)?


User avatar
NormanDunbar
Forum Moderator
Posts: 2274
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Useful SuperBASIC POKEs and PEEKs?

Post by NormanDunbar »

https://www.wlenerz.com/qlstuff/QDOSMSQE_Guide_4.7.zip has a PDF and an ODF version of the QDOS/SMSQ Technical Manual, which explains in gruesome details, everything you never knew you wanted to know about QDOS and/or SMSQ/E.

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Post Reply