| Welcome, Guest |
You have to register before you can post on our site.
|
| Online Users |
There are currently 198 online users. » 0 Member(s) | 196 Guest(s) Baidu, Google
|
| Latest Threads |
Old zxbasic game errors
Forum: Help & Support
Last Post: boriel
2025-11-09, 11:52 AM
» Replies: 7
» Views: 145
|
Error: Undefined GLOBAL l...
Forum: Help & Support
Last Post: ardentcrest
2025-11-04, 05:46 PM
» Replies: 3
» Views: 110
|
A Fast(er) Plot Routine f...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-30, 03:16 PM
» Replies: 2
» Views: 167
|
Hall of Fame - Include fo...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-28, 03:48 PM
» Replies: 0
» Views: 93
|
[SOLVED] Array layout bug...
Forum: Bug Reports
Last Post: Zoran
2025-10-25, 05:48 PM
» Replies: 2
» Views: 221
|
3DOS Commands?
Forum: Help & Support
Last Post: boriel
2025-10-06, 02:54 PM
» Replies: 3
» Views: 383
|
How to open fuse as an ex...
Forum: How-To & Tutorials
Last Post: zedex82
2025-10-05, 07:36 PM
» Replies: 2
» Views: 281
|
CLS/Fade out ASM Sub-rout...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-05, 03:39 PM
» Replies: 2
» Views: 275
|
ZX Basic Studio Bugs
Forum: Bug Reports
Last Post: Duefectu
2025-09-23, 04:07 PM
» Replies: 5
» Views: 1,084
|
Printing with FZX
Forum: Help & Support
Last Post: boriel
2025-07-17, 10:08 PM
» Replies: 1
» Views: 1,967
|
|
|
| Optimizer bug (*solved*) |
|
Posted by: einar - 2014-10-17, 08:50 PM - Forum: Bug Reports
- Replies (2)
|
 |
I found an error in ZX BASIC optimizer. Take a look at this test program:
Code: GO TO 10
sub FASTCALL test(flag AS UBYTE)
asm
cp 1
jp m,45000
jp 50000
end asm
end sub
10 POKE 50000,201: POKE 45000,201
test(1)
This program produces the expected result if you compile it as follows:
Code: zxb.exe -t -O2 prog.bas
However it will refuse to compile if you use this instead:
Code: zxb.exe -t -O3 prog.bas
In this latter case it will produce this error message:
Code: C:>zxb.exe -t -O3 prog.bas
Traceback (most recent call last):
File "zxb.py", line 348, in <module>
File "zxb.py", line 301, in main
File "optimizer.pyc", line 2287, in optimize
File "optimizer.pyc", line 1493, in update_goes_and_comes
KeyError: '45000'
EDIT: Tested using latest ZX BASIC version 1.4.0s1898.
|
|
|
| Serious bug indexing arrays (*solved*) |
|
Posted by: einar - 2014-09-29, 04:48 AM - Forum: Bug Reports
- Replies (4)
|
 |
Try running this program:
Code: DIM score(1 TO 2) AS UBYTE
DIM player AS UBYTE
LET score(1)=0
LET score(2)=0
LET player = 1
LET score(player)=score(player)+1
PRINT "SCORE ";score(1);"x";score(2)
The result will be "SCORE 0x1". This code was supposed to increment the score for player 1, but it will increment it for player 2 instead!
Now try changing this program as follows:
Code: DIM score(1 TO 2) AS UBYTE
DIM player AS UBYTE
LET score(1)=0
LET score(2)=0
LET player = 1
LET score(1)=score(1)+1
PRINT "SCORE ";score(1);"x";score(2)
Now it will give the correct result "SCORE 1x0".
Tested using latest ZX BASIC release 1.4.0s1893.
|
|
|
| Conditional operator? |
|
Posted by: einar - 2014-09-16, 09:57 PM - Forum: Wishlist
- Replies (8)
|
 |
Whenever I'm programming anything in ZX BASIC that involves non-trivial calculations, I really miss the conditional operator from C. So much that I finally decided to post a request here...
Since ZX BASIC already incorporates many useful operators from C like << (binary shift) and & (binary and), could you please consider incorporating C conditional operator also? What I mean is allowing code like this:
Code: IF (a < 30) THEN
LET a = a + 2
ELSE
LET a = a + 1
END IF
To be written like this:
Code: LET a = a + (a < 30 ? 2 : 1)
Those unfamiliar with C programming may not recognize it at first, but after you get used to it, the latter version is a lot easier to read. It's also easier for a compiler to optimize a single expression using conditional operators, instead of multiple IFs. Also this kind of feature would not introduce any problems or ambiguity in the parser.
For more complex expressions it makes a huge difference. Here's another example:
Code: IF (row > 0) THEN
LET pos = pos | (move & UP)
ELSE
LET pos = pos | TOP
END IF
IF (row < 21) THEN
LET pos = pos | (move & DOWN)
ELSE
LET pos = pos | BOTTOM
END IF
IF (col > 0) THEN
LET pos = pos | (move & LEFT)
ELSE
LET pos = pos | LEFTMOST
END IF
IF (col < 31) THEN
LET pos = pos | (move & RIGHT)
ELSE
LET pos = pos | RIGHTMOST
END IF
Using conditional operators, all this code above would be simplified to this:
Code: LET pos = pos | (row > 0 ? move & UP : TOP) |
(row < 21 ? move & DOWN : BOTTOM) |
(col > 0 ? move & LEFT : LEFTMOST) |
(col < 31 ? move & RIGHT : RIGHTMOST)
Makes sense?
|
|
|
|