Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with POKE B and POKE W #2

Closed
snoopy-f64 opened this issue May 26, 2022 · 4 comments
Closed

Problems with POKE B and POKE W #2

snoopy-f64 opened this issue May 26, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@snoopy-f64
Copy link

snoopy-f64 commented May 26, 2022

When POKE is used in conjunction with variable names that begin with B or W, mostly undesirable side effects occur.

The problem came to the attention of a user by chance, because he wondered why PRINT BF(BZ) works in his program and outputs 2594, but a POKE BF(BZ),1 does not put a 1 in the place of 2594. However, a POKE 2594,1 does work.

https://www.forum64.de/index.php?thread/118911-der-mega65-laber-stammtisch/&postID=1843717#post1843717

The reason is that POKE interprets the B of BF as a "POKE byte" and thus undesirably executes POKEB F(BZ),1.

The problem also occurs with variable names that begin with W because of POKE W.

pokebw_a

The line POKE WF,65 lets crash the system!

pokebw_b

For most people it will be not clear, why line 40 sends a syntax error, but line 20 not?

@snoopy-f64 snoopy-f64 added the new New report, not classified yet label May 26, 2022
@EgonOlsen71
Copy link

EgonOlsen71 commented May 26, 2022

Something similar applies to the corresponding PEEKW-Function. This code should give you 128 read from memory location 5000, but it gives you 320 read from 1000/1001 instead:

10 DIM W(1000)
20 POKE 1000,64: POKE 1001,1
30 POKE 5000,128
40 W(1000)=5000
50 PRINT PEEK W(1000)

@Edilbert
Copy link
Collaborator

Edilbert commented May 26, 2022

If you want to peek the contents of W(1000), the above syntax is wrong.
All functions require an opening parenthesis '(' after the function name, so you can write
PEEK(arg) or
PEEKW(arg)
but never write the argument directly after the keyword.
so line 50 would be correct:
50 PRINT PEEK(W(1000))
to print the value of the address held in W(1000)

@EgonOlsen71
Copy link

EgonOlsen71 commented May 26, 2022

If you want to peek the contents of W(1000), the above syntax is wrong.

True, I guess I was confused by the whole issue, which is something that others might be as well when looking at code like PEEK W(1000) thinking that it should be wrong just as PEEK V(1000) would be. I would still prefer that this gets changed to something like WPOKE/WPEEK instead, which wouldn't suffer from these issues.

@lydon42 lydon42 added enhancement New feature or request and removed new New report, not classified yet labels May 27, 2022
@lydon42
Copy link
Member

lydon42 commented May 27, 2022

Fixed in V920356 by renaming POKEW -> WPOKE and removing POKEB (just use POKE).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants