Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 554 online users. » 0 Member(s) | 552 Guest(s) Bing, Yandex
|
Latest Threads |
Includes in ASM
Forum: How-To & Tutorials
Last Post: bracckets
04-04-2024, 12:17 AM
» Replies: 2
» Views: 563
|
Intermittent errors
Forum: Help & Support
Last Post: zarsoft
03-12-2024, 12:39 PM
» Replies: 0
» Views: 315
|
Store array information i...
Forum: Help & Support
Last Post: rbiondi
03-10-2024, 09:42 PM
» Replies: 0
» Views: 407
|
ScrollLeft function scrol...
Forum: Bug Reports
Last Post: rbiondi
03-07-2024, 03:57 PM
» Replies: 2
» Views: 823
|
string.bas errors when co...
Forum: Bug Reports
Last Post: rbiondi
03-01-2024, 10:10 AM
» Replies: 2
» Views: 726
|
Using Beepola with ZX BAS...
Forum: How-To & Tutorials
Last Post: edtoo
02-29-2024, 09:47 AM
» Replies: 15
» Views: 32,832
|
Johnny Bravo
Forum: Gallery
Last Post: zarsoft
02-11-2024, 11:20 PM
» Replies: 0
» Views: 485
|
Compiling +D G+DOS progra...
Forum: ZX Basic Compiler
Last Post: boriel
01-22-2024, 08:32 AM
» Replies: 4
» Views: 8,674
|
VAL = ? (solved)
Forum: Bug Reports
Last Post: zarsoft
01-03-2024, 11:44 PM
» Replies: 8
» Views: 3,243
|
Wrong math (solved)
Forum: Bug Reports
Last Post: zarsoft
01-03-2024, 11:38 PM
» Replies: 4
» Views: 1,767
|
|
|
For loops with type byte (*solved*) |
Posted by: britlion - 08-17-2009, 04:58 PM - Forum: Bug Reports
- Replies (2)
|
|
Code: dim c,b as byte
FOR c=1 TO 175
FOR b=1 TO 250
PLOT b,c
NEXT b
NEXT c
Doesn't seem to work as expected. If I make it a uinteger, it works perfectly. At first I thought it was a problem with 0=256 in a byte the original was
Code: FOR c=0 TO 175
FOR b=0 TO 255
Which I could see not terminating, since a byte can never get bigger than 255.
However the problem I have with it as written is it's skipping the loop altogether..
1> Would for/next loops with byte be faster? (I'm following the principle of smaller=faster)
2> Why isn't it running the loop?
|
|
|
CHR / CHR$ issue? (*solved*) |
Posted by: britlion - 08-15-2009, 07:51 PM - Forum: Bug Reports
- Replies (2)
|
|
I boiled the issue down to the following code
Code: DIM x,f as integer
CLS
FOR x=1 TO 4
PRINT AT 0,0;
LET f=1
170 print at 0,0;
PRINT (x+64);
IF f<704 THEN
LET f=f+1
GO TO 170
END IF
180 NEXT x
BEEP 1,1
This works perfectly. However, if we ask for the CHR of (x+64):
Code: DIM x,f as integer
CLS
FOR x=1 TO 4
PRINT AT 0,0;
LET f=1
170 print at 0,0;
PRINT CHR(x+64);
IF f<704 THEN
LET f=f+1
GO TO 170
END IF
180 NEXT x
BEEP 1,1
My produced code crashes spectacularly. Has the CHR function come up with a bug?
|
|
|
INK 8 and DIM issues (*solved*) |
Posted by: LTee - 07-07-2009, 02:57 PM - Forum: Bug Reports
- Replies (11)
|
|
Hi - I posted these in the blog comments before I realised that this forum existed, so I've reposted them here in case they go unnoticed "out there". :-D
----
Hi Boriel, just been messing around with the compiler a little with an old BASIC game I had lying around and I’m having a little trouble with the INK and PAPER commands.
In ZX Basic you can use INK 8 and PAPER 8 when printing to specify that the character should be printed in ‘whatever colour the screen currently is’, but this doesn’t seem to be supported at the minute by the compiler.
e.g.
Code: PRINT AT 0,0; INK 8; PAPER 8; “X”
… would be red/blue if position 0,0 was already red/blue, green/yellow if position 0,0 was already green/yellow, etc.
The code for setting ink and paper in the compiler appears to do an AND 7; on the passed parameter so it always gets printed as ‘black/black’.
Is there a way around this? I’m using the very latest dev version, btw. :-)
Thanks for all your hard work!
---
Actually, while I’m here… :-)
–array-base=1 seems to be broken in the latest dev build. If you use that parameter it is impossible to set the very first entry in the array (position 1) although subsequent positions are okay. A compiler warning is generated but the code crashes when it runs.
e.g.
Code: 10 DIM p$(2)
20 LET p$(1) = “A”
30 LET p$(2) = “B”
The compiler generates a warning for line 20 (but not line 30) when given –array-base=1. The code works okay if line 20 is removed.
|
|
|
Multiple Entry Points |
Posted by: LCD - 06-26-2009, 05:00 PM - Forum: Wishlist
- Replies (2)
|
|
HiSoft Basic offers this: You can define multiple entry points for the code using REM : #OPEN at every line, where a entry point is possible, then at compilation time it displays for every entry point the USR Adress.
|
|
|
Efficiency Optimizations |
Posted by: britlion - 05-21-2009, 02:27 PM - Forum: Wishlist
- Replies (1)
|
|
I know, I know - I'm always harping on about this.
1> Does setting array and string indexes to start at 1 - to make it like basic - make for less efficient code?
(that is using the new default for --sinclair that Boriel is presumably putting into the next version)
2> Boriel once mentioned that the default behavior for code like:
Was
Code: ld a, 10 ;Init
ld (_A), a ;Load
inc a ;Inc
ld (_A), a ; Store <<<<< Not needed
sla a ; Multiply
ld (_A), a ; Store
And that -O3 should remove that extra code. I actually can't tell the difference in the above with or without -O3.
What does -O3 do? My code seems to be remarkably similar. In fact, the runtime routines for almost everything are included still - most of the print system (AT, COLOR, BOLD, ITALIC) even if never used).
Is -O3 doing what it's supposed to? I find most short code seems to be just about the same size, suggesting it isn't cutting down on runtime routines at all.
Actual program used:
Code: DIM A as byte
LET A=5
LET A=A+1
LET A=A*2
PRINT A
Actual -O3 Result:
Code: E:\ZX\ZXBwork>zxb Test2.bas -A -O3
INFO: __PRINTI8 is not defined. No optimization is done.
INFO: PRINT_EOL is not defined. No optimization is done.
E:\ZX\ZXBwork>notepad Test2.asm
The produced code was 1134 bytes without -O3 and 1132 bytes with -O3.
The difference is the end of the program. Optimized it does
Unoptimized it closes out with
Code: ld hl, 0
ld b, h
ld c, l
That's the only difference.
These error messages seem a little odd. Am I misusing the -O3 option, somehow? I was expecting it to cut out all the runtimes that wouldn't be needed.
Admittedly in a larger project, most of the runtimes would likely end up being used. I was a little spoiled by the tiny code that the hisoft compiler made, I think :-)
|
|
|
Color control codes |
Posted by: LCD - 05-21-2009, 01:37 PM - Forum: ZX Basic Compiler
- Replies (7)
|
|
Hallo boriel, you wrote, the control codes can be used like in BasIn, I tested it:
Code: print at 0,0;"\{i7}\{p2}\{b1}Test"
works fine, but BasIn allows this too:
Code: print at 0,0;"\{i7p2b1}Test"
which does not work. Is this a bug?
Quote:The escape sequences for control characters are as follows:
\{in}
Ink colour n, where n is in the range 0 to 7.
\{pn}
Paper colour n, where n is in the range 0 to 7.
\{bn}
Bright n, where n is 0 or 1.
\{fn}
Flash n, where n is 0 or 1.
Note: Control character escape sequences can be combined, so that for instance \{i6p1f1} is equivalent to \{i6}\{p1}\{f1} - flashing yellow ink on blue paper.
Btw: Release 1.2.1 is excellent. My latest test Program needed 8 Kb before, now it is only 4 Kb...
|
|
|
Bug: String Slicing (*solved*) |
Posted by: britlion - 05-19-2009, 07:42 PM - Forum: Bug Reports
- Replies (7)
|
|
I think string slicing still has bugs in it. Not quite sure why this fails, but it produces code that runs briefly and crashes, running in Spectaculator:
(fails with or without the DIM statements, but crashes differently in each case)
Code: DIM A$,p$ as string
DIM start,fin as integer
10 LET a$="This is a very long scrolly string that I am going to print"
20 LET start=1
30 LET fin=32
40 LET p$=a$(start TO fin)
50 LET start=start+1
60 LET fin=fin+1
70 IF fin>LEN a$ THEN LET fin=1 : END IF
80 IF start>LEN a$ THEN LET start=1 : END IF
90 PRINT AT 0,0;p$
100 IF start<fin THEN GO TO 40 : END IF
110 LET p$=a$(start TO )+a$( TO fin)
120 GO TO 50
Correcting the 1 to Zero (Since in compiled code the strings begin slicing at zero) has no effect other than change the way it crashes:
Code: DIM A$,p$ as string
DIM start,fin as integer
10 LET a$="This is a very long scrolly string that I am going to print"
20 LET start=0
30 LET fin=31
40 LET p$=a$(start TO fin)
50 LET start=start+1
60 LET fin=fin+1
70 IF fin>LEN a$ THEN LET fin=0 : END IF
80 IF start>LEN a$ THEN LET start=0 : END IF
90 PRINT AT 0,0;p$
100 IF start<fin THEN GO TO 40 : END IF
110 LET p$=a$(start TO )+a$( TO fin)
120 GO TO 50
|
|
|
|