What ways are there to “PEEK” memory sections in (different) BASIC(s)Saving screen pixels to string in ZX BasicWhy were early versions of BASIC different?What is the format of the syntax tables in Apple II Integer BASIC?What books did schools use to teach BASIC?What are the rules for Applesoft BASIC formatting for code?Early BASIC memory managementAre there any old and nowadays active Operating Systems which has only BASIC Programming Language?Strange math syntax in old basic listingWas self-modifying code possible using BASIC?String libraries for BASIC
Looking for a plural noun related to ‘fulcrum’ or ‘pivot’ that denotes multiple things as crucial to success
In Endgame, wouldn't Stark have remembered Hulk busting out of the stairwell?
How many petaflops does it take to land on the moon? What does Artemis need with an Aitken?
Did ancient peoples ever hide their treasure behind puzzles?
Spicing up a moment of peace
Is it unusual for a math department not to have a mail/web server?
Are sweatpants frowned upon on flights?
Normalized Malbolge to Malbolge translator
Is this password scheme legit?
Number of Fingers for a Math Oriented Race
Pen test results for web application include a file from a forbidden directory that is not even used or referenced
Can I lend a small amount of my own money to a bank at the federal funds rate?
Which polygons can be turned inside out by a smooth deformation?
Did the Apollo Guidance Computer really use 60% of the world's ICs in 1963?
The meaning of asynchronous vs synchronous
Why does a sticker slowly peel off, but if it is pulled quickly it tears?
Is it true that different variants of the same model aircraft don't require pilot retraining?
How to handle inventory and story of a player leaving
Why is there not a willingness from the world to step in between Pakistan and India?
Can you illusion a window out of a solid wall?
Does the Tribal card type have inherent mechanical implications?
Should I ask for a raise one month before the end of an internship?
Is the internet in Madagascar faster than in UK?
What's the point of fighting monsters in Zelda BotW?
What ways are there to “PEEK” memory sections in (different) BASIC(s)
Saving screen pixels to string in ZX BasicWhy were early versions of BASIC different?What is the format of the syntax tables in Apple II Integer BASIC?What books did schools use to teach BASIC?What are the rules for Applesoft BASIC formatting for code?Early BASIC memory managementAre there any old and nowadays active Operating Systems which has only BASIC Programming Language?Strange math syntax in old basic listingWas self-modifying code possible using BASIC?String libraries for BASIC
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Question
Was there any BASIC or extension or toolbox for BASIC allowing to PEEK multiple bytes from memory in one instruction - beside the often used DPEEK (or alike) to read a word.
I'm asking specifically for a PEEK alike general purpose function, not specialized ones like for screen access or similar.
Giving examples of specialized functions in addition will still be nice for comparison.
Background
I just learned an awesome new piece of ancient, ancient usage from an answer given by Tofro. There has been a BASIC extension for the Sinclair Spectrum allowing to POKE whole byte sequences to memory. In Beta BASIC a line like
40 POKE 16384,A$
will poke the content of A$ into address 4000h and follow up memory.
This is such a genuine simple and perfect sensible implementation. By now I'm mad at myself. Over the years I created many solutions beating around that bush, but that I've never thought about utilizing PEEK that way. It's brilliant.
Sure, it introduces a little bit of polymorphism into BASIC, which otherwise only goes for a fixed type and optional conversion, like float to int with conventional PEEK/POKE, but that has been done in other places as well.
Now while extending POKE is straight forward (from a language point), the much needed counter part of PEEK is not. That's mainly due the fact that BASIC strings are by default of variable length, thus the interpreter can not take the length to be read from the string (*1,2). Tofro cites in his answer a special access function:
20 LET A$=MEMORY$()(16384 TO 22527)
Not that I would call this elegant, but more important, it's a quite Sinclair-ish notation. So my desire would be to find something more generic with a syntax compatible to more .. lets say standard BASIC.
And that's what I'm looking for
P.S.:
A descovery like this tickles my urge to code. I want this. So far my own approach would be an extension to PEEK like
<var> = PEEK(<adr> [,<len])
Here compatibility is maintained by having an implied length of 1 if not given. In addition it also needs to act different on what type a receiving variable is.
If it's an integer (A%) then the bytes addressed get assigned as integer, so optional twisted for byte order (replacing the DPEEK as well).
If it's a string (A$) then they get just assigned there.
If it's a float (A, A!) everything gets blurry and must be settled by definition.
In fact, having such a function adds several possible errors - like selecting a range to large for the string data type (many BASICS can do only 255 char), or for an integer selecting more bytes than fit in one, and so on.
So I'm even more interested in what kind of solutions in that area were available back then (or today) in BASIC.
*1 - Ignoring for the moment, that this again would be a violation of the basic BASIC design.
*2 - Yes, it would be possible to make the string to contain the wanted amount of bytes beforehand (like in A$=SPACE$(16)) but that'S not only clumsy but as well a horrible design, quite hard to read and error prone.
basic language-design
add a comment |
Question
Was there any BASIC or extension or toolbox for BASIC allowing to PEEK multiple bytes from memory in one instruction - beside the often used DPEEK (or alike) to read a word.
I'm asking specifically for a PEEK alike general purpose function, not specialized ones like for screen access or similar.
Giving examples of specialized functions in addition will still be nice for comparison.
Background
I just learned an awesome new piece of ancient, ancient usage from an answer given by Tofro. There has been a BASIC extension for the Sinclair Spectrum allowing to POKE whole byte sequences to memory. In Beta BASIC a line like
40 POKE 16384,A$
will poke the content of A$ into address 4000h and follow up memory.
This is such a genuine simple and perfect sensible implementation. By now I'm mad at myself. Over the years I created many solutions beating around that bush, but that I've never thought about utilizing PEEK that way. It's brilliant.
Sure, it introduces a little bit of polymorphism into BASIC, which otherwise only goes for a fixed type and optional conversion, like float to int with conventional PEEK/POKE, but that has been done in other places as well.
Now while extending POKE is straight forward (from a language point), the much needed counter part of PEEK is not. That's mainly due the fact that BASIC strings are by default of variable length, thus the interpreter can not take the length to be read from the string (*1,2). Tofro cites in his answer a special access function:
20 LET A$=MEMORY$()(16384 TO 22527)
Not that I would call this elegant, but more important, it's a quite Sinclair-ish notation. So my desire would be to find something more generic with a syntax compatible to more .. lets say standard BASIC.
And that's what I'm looking for
P.S.:
A descovery like this tickles my urge to code. I want this. So far my own approach would be an extension to PEEK like
<var> = PEEK(<adr> [,<len])
Here compatibility is maintained by having an implied length of 1 if not given. In addition it also needs to act different on what type a receiving variable is.
If it's an integer (A%) then the bytes addressed get assigned as integer, so optional twisted for byte order (replacing the DPEEK as well).
If it's a string (A$) then they get just assigned there.
If it's a float (A, A!) everything gets blurry and must be settled by definition.
In fact, having such a function adds several possible errors - like selecting a range to large for the string data type (many BASICS can do only 255 char), or for an integer selecting more bytes than fit in one, and so on.
So I'm even more interested in what kind of solutions in that area were available back then (or today) in BASIC.
*1 - Ignoring for the moment, that this again would be a violation of the basic BASIC design.
*2 - Yes, it would be possible to make the string to contain the wanted amount of bytes beforehand (like in A$=SPACE$(16)) but that'S not only clumsy but as well a horrible design, quite hard to read and error prone.
basic language-design
when designing something yourself, reading into an array comes to mind as well. or maybe mapping as an array, to avoid copying...
– Felix Palmen
11 hours ago
@FelixPalmen Hmm, I usually would envision an array as some kind of multiple instance of single variables. So assigning memory data to a string arra seams overly complex. Mapping is a complete different issue. Great idea, and some BASIC like QL?) do allow similar tricks, but thats past the PEEK idea here, This is really about something as basic as PEEK for memory access.
– Raffzahn
10 hours ago
Just an array of integers of course, similar to abyte[]in some more recent languages. Could allow direct access to a table with less overhead (indexing).
– Felix Palmen
10 hours ago
@FelixPalmen Jup, that's mustly like the BetterBasic notation of indexing. Here in place operation (aliasing) instead of assigning of values is a great plus. Having such will be useful. Still that's not what I'm looking for. this is really about a factual assignment like PEEK does
– Raffzahn
10 hours ago
1
In my opinion, the MEM device is even more flexible (provided your BASIC/OS can handle random access files well). Beyond strings, it allows to PEEK and POKE other non-scalar types like (multi-dimensional) arrays and other structures in case your BASIC knows such things.
– tofro
10 hours ago
add a comment |
Question
Was there any BASIC or extension or toolbox for BASIC allowing to PEEK multiple bytes from memory in one instruction - beside the often used DPEEK (or alike) to read a word.
I'm asking specifically for a PEEK alike general purpose function, not specialized ones like for screen access or similar.
Giving examples of specialized functions in addition will still be nice for comparison.
Background
I just learned an awesome new piece of ancient, ancient usage from an answer given by Tofro. There has been a BASIC extension for the Sinclair Spectrum allowing to POKE whole byte sequences to memory. In Beta BASIC a line like
40 POKE 16384,A$
will poke the content of A$ into address 4000h and follow up memory.
This is such a genuine simple and perfect sensible implementation. By now I'm mad at myself. Over the years I created many solutions beating around that bush, but that I've never thought about utilizing PEEK that way. It's brilliant.
Sure, it introduces a little bit of polymorphism into BASIC, which otherwise only goes for a fixed type and optional conversion, like float to int with conventional PEEK/POKE, but that has been done in other places as well.
Now while extending POKE is straight forward (from a language point), the much needed counter part of PEEK is not. That's mainly due the fact that BASIC strings are by default of variable length, thus the interpreter can not take the length to be read from the string (*1,2). Tofro cites in his answer a special access function:
20 LET A$=MEMORY$()(16384 TO 22527)
Not that I would call this elegant, but more important, it's a quite Sinclair-ish notation. So my desire would be to find something more generic with a syntax compatible to more .. lets say standard BASIC.
And that's what I'm looking for
P.S.:
A descovery like this tickles my urge to code. I want this. So far my own approach would be an extension to PEEK like
<var> = PEEK(<adr> [,<len])
Here compatibility is maintained by having an implied length of 1 if not given. In addition it also needs to act different on what type a receiving variable is.
If it's an integer (A%) then the bytes addressed get assigned as integer, so optional twisted for byte order (replacing the DPEEK as well).
If it's a string (A$) then they get just assigned there.
If it's a float (A, A!) everything gets blurry and must be settled by definition.
In fact, having such a function adds several possible errors - like selecting a range to large for the string data type (many BASICS can do only 255 char), or for an integer selecting more bytes than fit in one, and so on.
So I'm even more interested in what kind of solutions in that area were available back then (or today) in BASIC.
*1 - Ignoring for the moment, that this again would be a violation of the basic BASIC design.
*2 - Yes, it would be possible to make the string to contain the wanted amount of bytes beforehand (like in A$=SPACE$(16)) but that'S not only clumsy but as well a horrible design, quite hard to read and error prone.
basic language-design
Question
Was there any BASIC or extension or toolbox for BASIC allowing to PEEK multiple bytes from memory in one instruction - beside the often used DPEEK (or alike) to read a word.
I'm asking specifically for a PEEK alike general purpose function, not specialized ones like for screen access or similar.
Giving examples of specialized functions in addition will still be nice for comparison.
Background
I just learned an awesome new piece of ancient, ancient usage from an answer given by Tofro. There has been a BASIC extension for the Sinclair Spectrum allowing to POKE whole byte sequences to memory. In Beta BASIC a line like
40 POKE 16384,A$
will poke the content of A$ into address 4000h and follow up memory.
This is such a genuine simple and perfect sensible implementation. By now I'm mad at myself. Over the years I created many solutions beating around that bush, but that I've never thought about utilizing PEEK that way. It's brilliant.
Sure, it introduces a little bit of polymorphism into BASIC, which otherwise only goes for a fixed type and optional conversion, like float to int with conventional PEEK/POKE, but that has been done in other places as well.
Now while extending POKE is straight forward (from a language point), the much needed counter part of PEEK is not. That's mainly due the fact that BASIC strings are by default of variable length, thus the interpreter can not take the length to be read from the string (*1,2). Tofro cites in his answer a special access function:
20 LET A$=MEMORY$()(16384 TO 22527)
Not that I would call this elegant, but more important, it's a quite Sinclair-ish notation. So my desire would be to find something more generic with a syntax compatible to more .. lets say standard BASIC.
And that's what I'm looking for
P.S.:
A descovery like this tickles my urge to code. I want this. So far my own approach would be an extension to PEEK like
<var> = PEEK(<adr> [,<len])
Here compatibility is maintained by having an implied length of 1 if not given. In addition it also needs to act different on what type a receiving variable is.
If it's an integer (A%) then the bytes addressed get assigned as integer, so optional twisted for byte order (replacing the DPEEK as well).
If it's a string (A$) then they get just assigned there.
If it's a float (A, A!) everything gets blurry and must be settled by definition.
In fact, having such a function adds several possible errors - like selecting a range to large for the string data type (many BASICS can do only 255 char), or for an integer selecting more bytes than fit in one, and so on.
So I'm even more interested in what kind of solutions in that area were available back then (or today) in BASIC.
*1 - Ignoring for the moment, that this again would be a violation of the basic BASIC design.
*2 - Yes, it would be possible to make the string to contain the wanted amount of bytes beforehand (like in A$=SPACE$(16)) but that'S not only clumsy but as well a horrible design, quite hard to read and error prone.
basic language-design
basic language-design
edited 2 hours ago
Raffzahn
asked 11 hours ago
RaffzahnRaffzahn
67.8k6 gold badges168 silver badges280 bronze badges
67.8k6 gold badges168 silver badges280 bronze badges
when designing something yourself, reading into an array comes to mind as well. or maybe mapping as an array, to avoid copying...
– Felix Palmen
11 hours ago
@FelixPalmen Hmm, I usually would envision an array as some kind of multiple instance of single variables. So assigning memory data to a string arra seams overly complex. Mapping is a complete different issue. Great idea, and some BASIC like QL?) do allow similar tricks, but thats past the PEEK idea here, This is really about something as basic as PEEK for memory access.
– Raffzahn
10 hours ago
Just an array of integers of course, similar to abyte[]in some more recent languages. Could allow direct access to a table with less overhead (indexing).
– Felix Palmen
10 hours ago
@FelixPalmen Jup, that's mustly like the BetterBasic notation of indexing. Here in place operation (aliasing) instead of assigning of values is a great plus. Having such will be useful. Still that's not what I'm looking for. this is really about a factual assignment like PEEK does
– Raffzahn
10 hours ago
1
In my opinion, the MEM device is even more flexible (provided your BASIC/OS can handle random access files well). Beyond strings, it allows to PEEK and POKE other non-scalar types like (multi-dimensional) arrays and other structures in case your BASIC knows such things.
– tofro
10 hours ago
add a comment |
when designing something yourself, reading into an array comes to mind as well. or maybe mapping as an array, to avoid copying...
– Felix Palmen
11 hours ago
@FelixPalmen Hmm, I usually would envision an array as some kind of multiple instance of single variables. So assigning memory data to a string arra seams overly complex. Mapping is a complete different issue. Great idea, and some BASIC like QL?) do allow similar tricks, but thats past the PEEK idea here, This is really about something as basic as PEEK for memory access.
– Raffzahn
10 hours ago
Just an array of integers of course, similar to abyte[]in some more recent languages. Could allow direct access to a table with less overhead (indexing).
– Felix Palmen
10 hours ago
@FelixPalmen Jup, that's mustly like the BetterBasic notation of indexing. Here in place operation (aliasing) instead of assigning of values is a great plus. Having such will be useful. Still that's not what I'm looking for. this is really about a factual assignment like PEEK does
– Raffzahn
10 hours ago
1
In my opinion, the MEM device is even more flexible (provided your BASIC/OS can handle random access files well). Beyond strings, it allows to PEEK and POKE other non-scalar types like (multi-dimensional) arrays and other structures in case your BASIC knows such things.
– tofro
10 hours ago
when designing something yourself, reading into an array comes to mind as well. or maybe mapping as an array, to avoid copying...
– Felix Palmen
11 hours ago
when designing something yourself, reading into an array comes to mind as well. or maybe mapping as an array, to avoid copying...
– Felix Palmen
11 hours ago
@FelixPalmen Hmm, I usually would envision an array as some kind of multiple instance of single variables. So assigning memory data to a string arra seams overly complex. Mapping is a complete different issue. Great idea, and some BASIC like QL?) do allow similar tricks, but thats past the PEEK idea here, This is really about something as basic as PEEK for memory access.
– Raffzahn
10 hours ago
@FelixPalmen Hmm, I usually would envision an array as some kind of multiple instance of single variables. So assigning memory data to a string arra seams overly complex. Mapping is a complete different issue. Great idea, and some BASIC like QL?) do allow similar tricks, but thats past the PEEK idea here, This is really about something as basic as PEEK for memory access.
– Raffzahn
10 hours ago
Just an array of integers of course, similar to a
byte[] in some more recent languages. Could allow direct access to a table with less overhead (indexing).– Felix Palmen
10 hours ago
Just an array of integers of course, similar to a
byte[] in some more recent languages. Could allow direct access to a table with less overhead (indexing).– Felix Palmen
10 hours ago
@FelixPalmen Jup, that's mustly like the BetterBasic notation of indexing. Here in place operation (aliasing) instead of assigning of values is a great plus. Having such will be useful. Still that's not what I'm looking for. this is really about a factual assignment like PEEK does
– Raffzahn
10 hours ago
@FelixPalmen Jup, that's mustly like the BetterBasic notation of indexing. Here in place operation (aliasing) instead of assigning of values is a great plus. Having such will be useful. Still that's not what I'm looking for. this is really about a factual assignment like PEEK does
– Raffzahn
10 hours ago
1
1
In my opinion, the MEM device is even more flexible (provided your BASIC/OS can handle random access files well). Beyond strings, it allows to PEEK and POKE other non-scalar types like (multi-dimensional) arrays and other structures in case your BASIC knows such things.
– tofro
10 hours ago
In my opinion, the MEM device is even more flexible (provided your BASIC/OS can handle random access files well). Beyond strings, it allows to PEEK and POKE other non-scalar types like (multi-dimensional) arrays and other structures in case your BASIC knows such things.
– tofro
10 hours ago
add a comment |
3 Answers
3
active
oldest
votes
BBC BASIC didn't use the PEEK or POKE keywords, but had the ? operator and statement which had the same effect. So the statement ?128 = 0 is equivalent to POKE 128, 0, and the expression ?128 is equivalent to PEEK 128. However, it also had ! and $ which did 32-bit and string peeks and pokes and e.g. $128 = "HELLO" would write the ASCII bytes of "HELLO" into locations 128–132, and terminate the string with a carriage-return (0x0D) terminator in location 133.
Syntax such as A?3 could also be used and was equivalent to ?(A+3). This is obviously useful for packing and unpacking structures. This also leads to confusing syntax such as A$1 = "foo". (BBC BASIC written with all of the efficiency tricks turned up to eleven could be hard to read.)
The terminator in the string operation was occasionally undesired, since it might either be unnecessary and clobbering something else in memory, or was the wrong terminator and required a bit of a dance to work around. Such strange limitations quickly push people towards the assembler...
I'm a bit confused as how that works with the basic use of '?' in BASIC as abrevation of print. ?128 should print out a line spelled "128<cr>", souldn't it?
– Raffzahn
10 hours ago
1
@Raffzahn Apparently it's known as the query operator. That said, I don't remember if it existed or not on the actual machines. My fuzzy memories of using BBC Basic years ago and wanting direct memory access involved using inline assembly. Or rather, copying inline assembly out of magazines, because at that young age I knew enough to do Basic but not assembly.
– Dranon
8 hours ago
1
BBC Basic usedP.for the print abbreviation. IIRC, most of BBC Basic shortcuts were of the letter +.variety
– SeanC
2 hours ago
add a comment |
ZX Spectrum Beta Basic
MEMORY$ is a pseudo-variable that considers the whole 64k of memory a string. By slicing it (Sinclair's way of implementing LEFT$, RIGHT$,...) you can pick memory areas into string variables.
10 REM Move memory to a string
20 LET a$=MEMORY$()(16384 TO 22527)
30 REM Move back
40 POKE 16384,a$
Sinclair QL SuperBASIC and Turbo Toolkit Basic extension
Standard QL BASIC nows how to PEEK and POKE scalar integer types to/from memory
10 x$ = PEEK (x) : REMark PEEK a byte
20 POKE x, x$ : REMark POKE it back
30 x% = PEEK_W (x) : REMark PEEK a 16-bit word
40 POKE_W (x, x%) : REMark POKE it back
45 REMark Note Sinclair QL BASIC doesn't have a 32-bit int type
50 x = PEEK_L (y) : REMark PEEK a 32-bit long, convert it to float
60 POKE_L (y, x) : REMark convert float to long, poke it
70 : REMark last two obviously only work on even addresses
Some toolkits (BASIC extensions) did the logical thing and implemented the same for strings (just like you proposed):
10 x$ = PEEK$ (x) : REMark assume x holds a string in standard QL format
20 : REMark (word length, then characters), fill x$ with it
30 POKE$ (x, x$) : REMark POKE it back
40 x$ = PEEK$ (x, len) : REMark Does the same thing, but takes the string length
50 : REMark as an argument, and PEEKs only the characters
You also had the same for floating point variables
10 x = PEEK_F (y) : REMark assumes y holds 6-byte FP in QL native format
20 POKE_F (y, x) : REMark poke it back without first converting to byte
Sinclair QL MEM pseudo-device
Another elegant (in my opinion, even more elegant than the above) approach to do the same thing is to supply a pseudo-device driver that pretends the memory is a random-access device:
10 OPEN #4, MEM
20 GET #4x,x$ : REMark position file pointer (i.e. address) to x, then read string x$
30 PUT #4x,x$ : REMark put it back
40 CLOSE #4 : REMark close the "file"
Note this works with any other type as well, including arrays (and is, thus, way more flexible than the above approach of extending PEEK and POKE). The MEM device driver I am working with has the added feature that you can add an address to the device name like
10 a = ALCHP (1024) : REMark allocate 1k of common heap, put the address into a
20 OPEN #4,"MEM_" & a : REMark device name is now MEM_<address>.
30 : REMark You can now work with relative offsets from a
40 : REMark and not from 0
Because the QL had some rudimentary network and a file server function, you could even open the "MEM" pseudo device on a server, and "PEEK and POKE" there:
10 OPEN #4,NET1_MEM_131072
Would open #4 to the screen memory of the QL with network station address 1. You could then save (or modify) the screen from the other box on a file on your local drives. Not extactly "safe", but nerdy ;)
Oops? why deleting it? Anyway, Thanks a lot. great writeup. So sinclair used different PEEKs. Ok. The Memory-Device is cool. But when using with a base address, tehre is no upper likint, right? Allocating 1K on the heap would still allow it to write past that length?
– Raffzahn
10 hours ago
1
Somehow created a duplicate answer. Yes to your question: No airbags, no belts, no braces in that specific driver. You could, however, extend the device name encoding to implement an upper limit, like "MEM_<lower>_<upper>" and range check access - The QL's device name encoding allowed that. But that was not part of that specific implementation.
– tofro
10 hours ago
add a comment |
POKE and PEEK were used a lot in the Commodore 64 BASIC V2, as it was completely lacking in high-level commands to manipulate the screen, sprites, IO and so on.
For example:
POKE 53281, 0
would set the screen background to black.
Conversely
C = PEEK(53281)
would return an integer corresponding to the screen background colour and place it in variable 'C'.
How is this related to the question?
– Felix Palmen
8 hours ago
1
I probably misunderstood the question title now that I read it again.
– Alan B
8 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "648"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f12168%2fwhat-ways-are-there-to-peek-memory-sections-in-different-basics%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
BBC BASIC didn't use the PEEK or POKE keywords, but had the ? operator and statement which had the same effect. So the statement ?128 = 0 is equivalent to POKE 128, 0, and the expression ?128 is equivalent to PEEK 128. However, it also had ! and $ which did 32-bit and string peeks and pokes and e.g. $128 = "HELLO" would write the ASCII bytes of "HELLO" into locations 128–132, and terminate the string with a carriage-return (0x0D) terminator in location 133.
Syntax such as A?3 could also be used and was equivalent to ?(A+3). This is obviously useful for packing and unpacking structures. This also leads to confusing syntax such as A$1 = "foo". (BBC BASIC written with all of the efficiency tricks turned up to eleven could be hard to read.)
The terminator in the string operation was occasionally undesired, since it might either be unnecessary and clobbering something else in memory, or was the wrong terminator and required a bit of a dance to work around. Such strange limitations quickly push people towards the assembler...
I'm a bit confused as how that works with the basic use of '?' in BASIC as abrevation of print. ?128 should print out a line spelled "128<cr>", souldn't it?
– Raffzahn
10 hours ago
1
@Raffzahn Apparently it's known as the query operator. That said, I don't remember if it existed or not on the actual machines. My fuzzy memories of using BBC Basic years ago and wanting direct memory access involved using inline assembly. Or rather, copying inline assembly out of magazines, because at that young age I knew enough to do Basic but not assembly.
– Dranon
8 hours ago
1
BBC Basic usedP.for the print abbreviation. IIRC, most of BBC Basic shortcuts were of the letter +.variety
– SeanC
2 hours ago
add a comment |
BBC BASIC didn't use the PEEK or POKE keywords, but had the ? operator and statement which had the same effect. So the statement ?128 = 0 is equivalent to POKE 128, 0, and the expression ?128 is equivalent to PEEK 128. However, it also had ! and $ which did 32-bit and string peeks and pokes and e.g. $128 = "HELLO" would write the ASCII bytes of "HELLO" into locations 128–132, and terminate the string with a carriage-return (0x0D) terminator in location 133.
Syntax such as A?3 could also be used and was equivalent to ?(A+3). This is obviously useful for packing and unpacking structures. This also leads to confusing syntax such as A$1 = "foo". (BBC BASIC written with all of the efficiency tricks turned up to eleven could be hard to read.)
The terminator in the string operation was occasionally undesired, since it might either be unnecessary and clobbering something else in memory, or was the wrong terminator and required a bit of a dance to work around. Such strange limitations quickly push people towards the assembler...
I'm a bit confused as how that works with the basic use of '?' in BASIC as abrevation of print. ?128 should print out a line spelled "128<cr>", souldn't it?
– Raffzahn
10 hours ago
1
@Raffzahn Apparently it's known as the query operator. That said, I don't remember if it existed or not on the actual machines. My fuzzy memories of using BBC Basic years ago and wanting direct memory access involved using inline assembly. Or rather, copying inline assembly out of magazines, because at that young age I knew enough to do Basic but not assembly.
– Dranon
8 hours ago
1
BBC Basic usedP.for the print abbreviation. IIRC, most of BBC Basic shortcuts were of the letter +.variety
– SeanC
2 hours ago
add a comment |
BBC BASIC didn't use the PEEK or POKE keywords, but had the ? operator and statement which had the same effect. So the statement ?128 = 0 is equivalent to POKE 128, 0, and the expression ?128 is equivalent to PEEK 128. However, it also had ! and $ which did 32-bit and string peeks and pokes and e.g. $128 = "HELLO" would write the ASCII bytes of "HELLO" into locations 128–132, and terminate the string with a carriage-return (0x0D) terminator in location 133.
Syntax such as A?3 could also be used and was equivalent to ?(A+3). This is obviously useful for packing and unpacking structures. This also leads to confusing syntax such as A$1 = "foo". (BBC BASIC written with all of the efficiency tricks turned up to eleven could be hard to read.)
The terminator in the string operation was occasionally undesired, since it might either be unnecessary and clobbering something else in memory, or was the wrong terminator and required a bit of a dance to work around. Such strange limitations quickly push people towards the assembler...
BBC BASIC didn't use the PEEK or POKE keywords, but had the ? operator and statement which had the same effect. So the statement ?128 = 0 is equivalent to POKE 128, 0, and the expression ?128 is equivalent to PEEK 128. However, it also had ! and $ which did 32-bit and string peeks and pokes and e.g. $128 = "HELLO" would write the ASCII bytes of "HELLO" into locations 128–132, and terminate the string with a carriage-return (0x0D) terminator in location 133.
Syntax such as A?3 could also be used and was equivalent to ?(A+3). This is obviously useful for packing and unpacking structures. This also leads to confusing syntax such as A$1 = "foo". (BBC BASIC written with all of the efficiency tricks turned up to eleven could be hard to read.)
The terminator in the string operation was occasionally undesired, since it might either be unnecessary and clobbering something else in memory, or was the wrong terminator and required a bit of a dance to work around. Such strange limitations quickly push people towards the assembler...
answered 11 hours ago
pndcpndc
6,4352 gold badges28 silver badges42 bronze badges
6,4352 gold badges28 silver badges42 bronze badges
I'm a bit confused as how that works with the basic use of '?' in BASIC as abrevation of print. ?128 should print out a line spelled "128<cr>", souldn't it?
– Raffzahn
10 hours ago
1
@Raffzahn Apparently it's known as the query operator. That said, I don't remember if it existed or not on the actual machines. My fuzzy memories of using BBC Basic years ago and wanting direct memory access involved using inline assembly. Or rather, copying inline assembly out of magazines, because at that young age I knew enough to do Basic but not assembly.
– Dranon
8 hours ago
1
BBC Basic usedP.for the print abbreviation. IIRC, most of BBC Basic shortcuts were of the letter +.variety
– SeanC
2 hours ago
add a comment |
I'm a bit confused as how that works with the basic use of '?' in BASIC as abrevation of print. ?128 should print out a line spelled "128<cr>", souldn't it?
– Raffzahn
10 hours ago
1
@Raffzahn Apparently it's known as the query operator. That said, I don't remember if it existed or not on the actual machines. My fuzzy memories of using BBC Basic years ago and wanting direct memory access involved using inline assembly. Or rather, copying inline assembly out of magazines, because at that young age I knew enough to do Basic but not assembly.
– Dranon
8 hours ago
1
BBC Basic usedP.for the print abbreviation. IIRC, most of BBC Basic shortcuts were of the letter +.variety
– SeanC
2 hours ago
I'm a bit confused as how that works with the basic use of '?' in BASIC as abrevation of print. ?128 should print out a line spelled "128<cr>", souldn't it?
– Raffzahn
10 hours ago
I'm a bit confused as how that works with the basic use of '?' in BASIC as abrevation of print. ?128 should print out a line spelled "128<cr>", souldn't it?
– Raffzahn
10 hours ago
1
1
@Raffzahn Apparently it's known as the query operator. That said, I don't remember if it existed or not on the actual machines. My fuzzy memories of using BBC Basic years ago and wanting direct memory access involved using inline assembly. Or rather, copying inline assembly out of magazines, because at that young age I knew enough to do Basic but not assembly.
– Dranon
8 hours ago
@Raffzahn Apparently it's known as the query operator. That said, I don't remember if it existed or not on the actual machines. My fuzzy memories of using BBC Basic years ago and wanting direct memory access involved using inline assembly. Or rather, copying inline assembly out of magazines, because at that young age I knew enough to do Basic but not assembly.
– Dranon
8 hours ago
1
1
BBC Basic used
P. for the print abbreviation. IIRC, most of BBC Basic shortcuts were of the letter + . variety– SeanC
2 hours ago
BBC Basic used
P. for the print abbreviation. IIRC, most of BBC Basic shortcuts were of the letter + . variety– SeanC
2 hours ago
add a comment |
ZX Spectrum Beta Basic
MEMORY$ is a pseudo-variable that considers the whole 64k of memory a string. By slicing it (Sinclair's way of implementing LEFT$, RIGHT$,...) you can pick memory areas into string variables.
10 REM Move memory to a string
20 LET a$=MEMORY$()(16384 TO 22527)
30 REM Move back
40 POKE 16384,a$
Sinclair QL SuperBASIC and Turbo Toolkit Basic extension
Standard QL BASIC nows how to PEEK and POKE scalar integer types to/from memory
10 x$ = PEEK (x) : REMark PEEK a byte
20 POKE x, x$ : REMark POKE it back
30 x% = PEEK_W (x) : REMark PEEK a 16-bit word
40 POKE_W (x, x%) : REMark POKE it back
45 REMark Note Sinclair QL BASIC doesn't have a 32-bit int type
50 x = PEEK_L (y) : REMark PEEK a 32-bit long, convert it to float
60 POKE_L (y, x) : REMark convert float to long, poke it
70 : REMark last two obviously only work on even addresses
Some toolkits (BASIC extensions) did the logical thing and implemented the same for strings (just like you proposed):
10 x$ = PEEK$ (x) : REMark assume x holds a string in standard QL format
20 : REMark (word length, then characters), fill x$ with it
30 POKE$ (x, x$) : REMark POKE it back
40 x$ = PEEK$ (x, len) : REMark Does the same thing, but takes the string length
50 : REMark as an argument, and PEEKs only the characters
You also had the same for floating point variables
10 x = PEEK_F (y) : REMark assumes y holds 6-byte FP in QL native format
20 POKE_F (y, x) : REMark poke it back without first converting to byte
Sinclair QL MEM pseudo-device
Another elegant (in my opinion, even more elegant than the above) approach to do the same thing is to supply a pseudo-device driver that pretends the memory is a random-access device:
10 OPEN #4, MEM
20 GET #4x,x$ : REMark position file pointer (i.e. address) to x, then read string x$
30 PUT #4x,x$ : REMark put it back
40 CLOSE #4 : REMark close the "file"
Note this works with any other type as well, including arrays (and is, thus, way more flexible than the above approach of extending PEEK and POKE). The MEM device driver I am working with has the added feature that you can add an address to the device name like
10 a = ALCHP (1024) : REMark allocate 1k of common heap, put the address into a
20 OPEN #4,"MEM_" & a : REMark device name is now MEM_<address>.
30 : REMark You can now work with relative offsets from a
40 : REMark and not from 0
Because the QL had some rudimentary network and a file server function, you could even open the "MEM" pseudo device on a server, and "PEEK and POKE" there:
10 OPEN #4,NET1_MEM_131072
Would open #4 to the screen memory of the QL with network station address 1. You could then save (or modify) the screen from the other box on a file on your local drives. Not extactly "safe", but nerdy ;)
Oops? why deleting it? Anyway, Thanks a lot. great writeup. So sinclair used different PEEKs. Ok. The Memory-Device is cool. But when using with a base address, tehre is no upper likint, right? Allocating 1K on the heap would still allow it to write past that length?
– Raffzahn
10 hours ago
1
Somehow created a duplicate answer. Yes to your question: No airbags, no belts, no braces in that specific driver. You could, however, extend the device name encoding to implement an upper limit, like "MEM_<lower>_<upper>" and range check access - The QL's device name encoding allowed that. But that was not part of that specific implementation.
– tofro
10 hours ago
add a comment |
ZX Spectrum Beta Basic
MEMORY$ is a pseudo-variable that considers the whole 64k of memory a string. By slicing it (Sinclair's way of implementing LEFT$, RIGHT$,...) you can pick memory areas into string variables.
10 REM Move memory to a string
20 LET a$=MEMORY$()(16384 TO 22527)
30 REM Move back
40 POKE 16384,a$
Sinclair QL SuperBASIC and Turbo Toolkit Basic extension
Standard QL BASIC nows how to PEEK and POKE scalar integer types to/from memory
10 x$ = PEEK (x) : REMark PEEK a byte
20 POKE x, x$ : REMark POKE it back
30 x% = PEEK_W (x) : REMark PEEK a 16-bit word
40 POKE_W (x, x%) : REMark POKE it back
45 REMark Note Sinclair QL BASIC doesn't have a 32-bit int type
50 x = PEEK_L (y) : REMark PEEK a 32-bit long, convert it to float
60 POKE_L (y, x) : REMark convert float to long, poke it
70 : REMark last two obviously only work on even addresses
Some toolkits (BASIC extensions) did the logical thing and implemented the same for strings (just like you proposed):
10 x$ = PEEK$ (x) : REMark assume x holds a string in standard QL format
20 : REMark (word length, then characters), fill x$ with it
30 POKE$ (x, x$) : REMark POKE it back
40 x$ = PEEK$ (x, len) : REMark Does the same thing, but takes the string length
50 : REMark as an argument, and PEEKs only the characters
You also had the same for floating point variables
10 x = PEEK_F (y) : REMark assumes y holds 6-byte FP in QL native format
20 POKE_F (y, x) : REMark poke it back without first converting to byte
Sinclair QL MEM pseudo-device
Another elegant (in my opinion, even more elegant than the above) approach to do the same thing is to supply a pseudo-device driver that pretends the memory is a random-access device:
10 OPEN #4, MEM
20 GET #4x,x$ : REMark position file pointer (i.e. address) to x, then read string x$
30 PUT #4x,x$ : REMark put it back
40 CLOSE #4 : REMark close the "file"
Note this works with any other type as well, including arrays (and is, thus, way more flexible than the above approach of extending PEEK and POKE). The MEM device driver I am working with has the added feature that you can add an address to the device name like
10 a = ALCHP (1024) : REMark allocate 1k of common heap, put the address into a
20 OPEN #4,"MEM_" & a : REMark device name is now MEM_<address>.
30 : REMark You can now work with relative offsets from a
40 : REMark and not from 0
Because the QL had some rudimentary network and a file server function, you could even open the "MEM" pseudo device on a server, and "PEEK and POKE" there:
10 OPEN #4,NET1_MEM_131072
Would open #4 to the screen memory of the QL with network station address 1. You could then save (or modify) the screen from the other box on a file on your local drives. Not extactly "safe", but nerdy ;)
Oops? why deleting it? Anyway, Thanks a lot. great writeup. So sinclair used different PEEKs. Ok. The Memory-Device is cool. But when using with a base address, tehre is no upper likint, right? Allocating 1K on the heap would still allow it to write past that length?
– Raffzahn
10 hours ago
1
Somehow created a duplicate answer. Yes to your question: No airbags, no belts, no braces in that specific driver. You could, however, extend the device name encoding to implement an upper limit, like "MEM_<lower>_<upper>" and range check access - The QL's device name encoding allowed that. But that was not part of that specific implementation.
– tofro
10 hours ago
add a comment |
ZX Spectrum Beta Basic
MEMORY$ is a pseudo-variable that considers the whole 64k of memory a string. By slicing it (Sinclair's way of implementing LEFT$, RIGHT$,...) you can pick memory areas into string variables.
10 REM Move memory to a string
20 LET a$=MEMORY$()(16384 TO 22527)
30 REM Move back
40 POKE 16384,a$
Sinclair QL SuperBASIC and Turbo Toolkit Basic extension
Standard QL BASIC nows how to PEEK and POKE scalar integer types to/from memory
10 x$ = PEEK (x) : REMark PEEK a byte
20 POKE x, x$ : REMark POKE it back
30 x% = PEEK_W (x) : REMark PEEK a 16-bit word
40 POKE_W (x, x%) : REMark POKE it back
45 REMark Note Sinclair QL BASIC doesn't have a 32-bit int type
50 x = PEEK_L (y) : REMark PEEK a 32-bit long, convert it to float
60 POKE_L (y, x) : REMark convert float to long, poke it
70 : REMark last two obviously only work on even addresses
Some toolkits (BASIC extensions) did the logical thing and implemented the same for strings (just like you proposed):
10 x$ = PEEK$ (x) : REMark assume x holds a string in standard QL format
20 : REMark (word length, then characters), fill x$ with it
30 POKE$ (x, x$) : REMark POKE it back
40 x$ = PEEK$ (x, len) : REMark Does the same thing, but takes the string length
50 : REMark as an argument, and PEEKs only the characters
You also had the same for floating point variables
10 x = PEEK_F (y) : REMark assumes y holds 6-byte FP in QL native format
20 POKE_F (y, x) : REMark poke it back without first converting to byte
Sinclair QL MEM pseudo-device
Another elegant (in my opinion, even more elegant than the above) approach to do the same thing is to supply a pseudo-device driver that pretends the memory is a random-access device:
10 OPEN #4, MEM
20 GET #4x,x$ : REMark position file pointer (i.e. address) to x, then read string x$
30 PUT #4x,x$ : REMark put it back
40 CLOSE #4 : REMark close the "file"
Note this works with any other type as well, including arrays (and is, thus, way more flexible than the above approach of extending PEEK and POKE). The MEM device driver I am working with has the added feature that you can add an address to the device name like
10 a = ALCHP (1024) : REMark allocate 1k of common heap, put the address into a
20 OPEN #4,"MEM_" & a : REMark device name is now MEM_<address>.
30 : REMark You can now work with relative offsets from a
40 : REMark and not from 0
Because the QL had some rudimentary network and a file server function, you could even open the "MEM" pseudo device on a server, and "PEEK and POKE" there:
10 OPEN #4,NET1_MEM_131072
Would open #4 to the screen memory of the QL with network station address 1. You could then save (or modify) the screen from the other box on a file on your local drives. Not extactly "safe", but nerdy ;)
ZX Spectrum Beta Basic
MEMORY$ is a pseudo-variable that considers the whole 64k of memory a string. By slicing it (Sinclair's way of implementing LEFT$, RIGHT$,...) you can pick memory areas into string variables.
10 REM Move memory to a string
20 LET a$=MEMORY$()(16384 TO 22527)
30 REM Move back
40 POKE 16384,a$
Sinclair QL SuperBASIC and Turbo Toolkit Basic extension
Standard QL BASIC nows how to PEEK and POKE scalar integer types to/from memory
10 x$ = PEEK (x) : REMark PEEK a byte
20 POKE x, x$ : REMark POKE it back
30 x% = PEEK_W (x) : REMark PEEK a 16-bit word
40 POKE_W (x, x%) : REMark POKE it back
45 REMark Note Sinclair QL BASIC doesn't have a 32-bit int type
50 x = PEEK_L (y) : REMark PEEK a 32-bit long, convert it to float
60 POKE_L (y, x) : REMark convert float to long, poke it
70 : REMark last two obviously only work on even addresses
Some toolkits (BASIC extensions) did the logical thing and implemented the same for strings (just like you proposed):
10 x$ = PEEK$ (x) : REMark assume x holds a string in standard QL format
20 : REMark (word length, then characters), fill x$ with it
30 POKE$ (x, x$) : REMark POKE it back
40 x$ = PEEK$ (x, len) : REMark Does the same thing, but takes the string length
50 : REMark as an argument, and PEEKs only the characters
You also had the same for floating point variables
10 x = PEEK_F (y) : REMark assumes y holds 6-byte FP in QL native format
20 POKE_F (y, x) : REMark poke it back without first converting to byte
Sinclair QL MEM pseudo-device
Another elegant (in my opinion, even more elegant than the above) approach to do the same thing is to supply a pseudo-device driver that pretends the memory is a random-access device:
10 OPEN #4, MEM
20 GET #4x,x$ : REMark position file pointer (i.e. address) to x, then read string x$
30 PUT #4x,x$ : REMark put it back
40 CLOSE #4 : REMark close the "file"
Note this works with any other type as well, including arrays (and is, thus, way more flexible than the above approach of extending PEEK and POKE). The MEM device driver I am working with has the added feature that you can add an address to the device name like
10 a = ALCHP (1024) : REMark allocate 1k of common heap, put the address into a
20 OPEN #4,"MEM_" & a : REMark device name is now MEM_<address>.
30 : REMark You can now work with relative offsets from a
40 : REMark and not from 0
Because the QL had some rudimentary network and a file server function, you could even open the "MEM" pseudo device on a server, and "PEEK and POKE" there:
10 OPEN #4,NET1_MEM_131072
Would open #4 to the screen memory of the QL with network station address 1. You could then save (or modify) the screen from the other box on a file on your local drives. Not extactly "safe", but nerdy ;)
edited 9 hours ago
answered 11 hours ago
tofrotofro
18k3 gold badges38 silver badges101 bronze badges
18k3 gold badges38 silver badges101 bronze badges
Oops? why deleting it? Anyway, Thanks a lot. great writeup. So sinclair used different PEEKs. Ok. The Memory-Device is cool. But when using with a base address, tehre is no upper likint, right? Allocating 1K on the heap would still allow it to write past that length?
– Raffzahn
10 hours ago
1
Somehow created a duplicate answer. Yes to your question: No airbags, no belts, no braces in that specific driver. You could, however, extend the device name encoding to implement an upper limit, like "MEM_<lower>_<upper>" and range check access - The QL's device name encoding allowed that. But that was not part of that specific implementation.
– tofro
10 hours ago
add a comment |
Oops? why deleting it? Anyway, Thanks a lot. great writeup. So sinclair used different PEEKs. Ok. The Memory-Device is cool. But when using with a base address, tehre is no upper likint, right? Allocating 1K on the heap would still allow it to write past that length?
– Raffzahn
10 hours ago
1
Somehow created a duplicate answer. Yes to your question: No airbags, no belts, no braces in that specific driver. You could, however, extend the device name encoding to implement an upper limit, like "MEM_<lower>_<upper>" and range check access - The QL's device name encoding allowed that. But that was not part of that specific implementation.
– tofro
10 hours ago
Oops? why deleting it? Anyway, Thanks a lot. great writeup. So sinclair used different PEEKs. Ok. The Memory-Device is cool. But when using with a base address, tehre is no upper likint, right? Allocating 1K on the heap would still allow it to write past that length?
– Raffzahn
10 hours ago
Oops? why deleting it? Anyway, Thanks a lot. great writeup. So sinclair used different PEEKs. Ok. The Memory-Device is cool. But when using with a base address, tehre is no upper likint, right? Allocating 1K on the heap would still allow it to write past that length?
– Raffzahn
10 hours ago
1
1
Somehow created a duplicate answer. Yes to your question: No airbags, no belts, no braces in that specific driver. You could, however, extend the device name encoding to implement an upper limit, like "MEM_<lower>_<upper>" and range check access - The QL's device name encoding allowed that. But that was not part of that specific implementation.
– tofro
10 hours ago
Somehow created a duplicate answer. Yes to your question: No airbags, no belts, no braces in that specific driver. You could, however, extend the device name encoding to implement an upper limit, like "MEM_<lower>_<upper>" and range check access - The QL's device name encoding allowed that. But that was not part of that specific implementation.
– tofro
10 hours ago
add a comment |
POKE and PEEK were used a lot in the Commodore 64 BASIC V2, as it was completely lacking in high-level commands to manipulate the screen, sprites, IO and so on.
For example:
POKE 53281, 0
would set the screen background to black.
Conversely
C = PEEK(53281)
would return an integer corresponding to the screen background colour and place it in variable 'C'.
How is this related to the question?
– Felix Palmen
8 hours ago
1
I probably misunderstood the question title now that I read it again.
– Alan B
8 hours ago
add a comment |
POKE and PEEK were used a lot in the Commodore 64 BASIC V2, as it was completely lacking in high-level commands to manipulate the screen, sprites, IO and so on.
For example:
POKE 53281, 0
would set the screen background to black.
Conversely
C = PEEK(53281)
would return an integer corresponding to the screen background colour and place it in variable 'C'.
How is this related to the question?
– Felix Palmen
8 hours ago
1
I probably misunderstood the question title now that I read it again.
– Alan B
8 hours ago
add a comment |
POKE and PEEK were used a lot in the Commodore 64 BASIC V2, as it was completely lacking in high-level commands to manipulate the screen, sprites, IO and so on.
For example:
POKE 53281, 0
would set the screen background to black.
Conversely
C = PEEK(53281)
would return an integer corresponding to the screen background colour and place it in variable 'C'.
POKE and PEEK were used a lot in the Commodore 64 BASIC V2, as it was completely lacking in high-level commands to manipulate the screen, sprites, IO and so on.
For example:
POKE 53281, 0
would set the screen background to black.
Conversely
C = PEEK(53281)
would return an integer corresponding to the screen background colour and place it in variable 'C'.
answered 8 hours ago
Alan BAlan B
6953 silver badges9 bronze badges
6953 silver badges9 bronze badges
How is this related to the question?
– Felix Palmen
8 hours ago
1
I probably misunderstood the question title now that I read it again.
– Alan B
8 hours ago
add a comment |
How is this related to the question?
– Felix Palmen
8 hours ago
1
I probably misunderstood the question title now that I read it again.
– Alan B
8 hours ago
How is this related to the question?
– Felix Palmen
8 hours ago
How is this related to the question?
– Felix Palmen
8 hours ago
1
1
I probably misunderstood the question title now that I read it again.
– Alan B
8 hours ago
I probably misunderstood the question title now that I read it again.
– Alan B
8 hours ago
add a comment |
Thanks for contributing an answer to Retrocomputing Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f12168%2fwhat-ways-are-there-to-peek-memory-sections-in-different-basics%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
when designing something yourself, reading into an array comes to mind as well. or maybe mapping as an array, to avoid copying...
– Felix Palmen
11 hours ago
@FelixPalmen Hmm, I usually would envision an array as some kind of multiple instance of single variables. So assigning memory data to a string arra seams overly complex. Mapping is a complete different issue. Great idea, and some BASIC like QL?) do allow similar tricks, but thats past the PEEK idea here, This is really about something as basic as PEEK for memory access.
– Raffzahn
10 hours ago
Just an array of integers of course, similar to a
byte[]in some more recent languages. Could allow direct access to a table with less overhead (indexing).– Felix Palmen
10 hours ago
@FelixPalmen Jup, that's mustly like the BetterBasic notation of indexing. Here in place operation (aliasing) instead of assigning of values is a great plus. Having such will be useful. Still that's not what I'm looking for. this is really about a factual assignment like PEEK does
– Raffzahn
10 hours ago
1
In my opinion, the MEM device is even more flexible (provided your BASIC/OS can handle random access files well). Beyond strings, it allows to PEEK and POKE other non-scalar types like (multi-dimensional) arrays and other structures in case your BASIC knows such things.
– tofro
10 hours ago