Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 335 online users. » 0 Member(s) | 333 Guest(s) Bing, Google
|
Latest Threads |
Printing with FZX
Forum: Help & Support
Last Post: boriel
07-17-2025, 09:08 PM
» Replies: 1
» Views: 255
|
Strange Happenings
Forum: Bug Reports
Last Post: boriel
05-23-2025, 09:15 AM
» Replies: 4
» Views: 2,344
|
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 2,589
|
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 2,177
|
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 5,047
|
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 3,563
|
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 3,282
|
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 1,840
|
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 4,464
|
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 5,281
|
|
|
Found another bug (*solved*) |
Posted by: LCD - 05-11-2009, 11:58 AM - Forum: Bug Reports
- Replies (1)
|
 |
Hi Boriel,
Code: dim a$ as string
a$="This is a test"
print a$
print a$( to 4)
print a$(5 to)
This works, but
Code: dim a$ as string
a$="This is a test"
print a$( to 4)
print a$(5 to)
This claims "Variable a never used" and compiler stops (version 1.1.9)
Edit: Btw: should POKE STRING adr,string$ and string$=PEEK STRING adr work?
|
|
|
CODE <constant string> is broken (*solved*) |
Posted by: britlion - 05-08-2009, 06:08 PM - Forum: Bug Reports
- Replies (2)
|
 |
I was playing with some complex code from the "One Liners" stuff. The following program behaves completely differently in basic as opposed to going through the compiler. Actually, it crashes when run compiled. (I tried several different types for f and g). Oddly, at the first PLOT, there appears some other changes to the screen - a few bytes of corruption. Something weird is happening there. There are more brackets than I need - mostly in an attempt to make sure the math functions are coming out clearly. Try it in BASIN and then compile it.
I know the functions are unnecessarily complex. That's the nature of the one liner type code. Nonetheless, it ought to behave when compiled just like the interpreted version. Shouldn't it?
Code: DIM f,g as UBYTE
1 PRINT AT 9,9;"SIMON"
3 FOR f=1 TO 4
4 INK f
5 FOR g=1 TO 32
6 PLOT INT ABS((SGN (f-2.5)*80)+24+g), INT (((CODE "0202"(f TO f)-49)*99)-48+g)
7 DRAW 32,0
8 NEXT g
9 goto 11
10 STOP
11 PRINT INK f; OVER 1;AT CODE "1919"(f TO f)-44,CODE "0099"(f to f)-41;f
12 NEXT f
13 LET f=1
14 goto 9
|
|
|
Version 1.1.7 released! |
Posted by: boriel - 05-03-2009, 10:27 AM - Forum: ZX Basic Compiler
- No Replies
|
 |
What's new since 1.1.4: - + Added the ELSEIF construct to the IF THEN ELSE sentence
- + Added more optimizations in some jumps
- + Added the USR function (both for Strings and Floats). Yes, you can now use USR "a" to get the address of the UDG table (instead of PEEK Uinteger 23675), and also can do RANDOMIZE USR 40000 (if you want to call a legacy machine-code routine; other than that it's useless).
- * Optimized some print string generated code (now it's smaller)
- ! Fixed many optimization bugs (almost five). Thanks to LCD
- ! Fixed ChangeLog file
- - Internal refactored code (somewhat)
- ! BOLD and ITALIC could not be used as permament attributes,
only as temporary ones. Now they are allowed as permament.
- * Some more syntax compatibility with Sinclair BASIC. Expressions
like F$(5), F$() or F$(TO) are now allowed. So expressions like PRINT ;;; are.
- ! single PRINT sentences were not working (they should print a
newline).
- * Minor grammar corrections.
- ! Using a suffix like '$' in a function declaration was being
ignored. Now this also works ok.
- + Added suport for PRINT , (Thanks to britlion and LCD for the
suggestions and bug detection)
- * Fixed a potential optimization bug for SHR and SHL
TODO:- Bitwise instructions for AND, OR, XOR, NOT
- CLEAR to fill memory areas
- READ, DATA and RESTORE
- SAVE & LOAD
|
|
|
Wish: Documentation! |
Posted by: britlion - 04-29-2009, 08:27 PM - Forum: Wishlist
- Replies (4)
|
 |
There are lots of things in the compiler that are mentioned obliquely in changelogs.
Please - at least get the list of reserved words up to date so that we know something is there.
Please, document DIM! This keyword is used in so many different ways - to set types, to dimension arrays, to set constants and to block fill arrays with =>
We're a little in the dark generally - and willing to work with that - but I think I'd like to request documentation and examples for DIM be top of the pile!
|
|
|
DIM issue |
Posted by: britlion - 04-29-2009, 08:17 PM - Forum: Wishlist
- Replies (5)
|
 |
Why does
Code: DIM list(1) AS uByte => {24,2}
compile just fine, but
Code: DIM p(1) AS String => {"Word","Word"}
Will not. I thought initializing arrays this way was a replacement for READ and DATA, which are not supported! I love being able to block fill an array at compile time with numbers. Can I not do the same thing with strings? How do I replace:
DATA "STRING","STRING","STRING" then?
|
|
|
Print issues (*fixed*) |
Posted by: britlion - 04-29-2009, 12:31 PM - Forum: Bug Reports
- Replies (3)
|
 |
Big issue: I notice print doesn't support commas.
Print "1","2" doesn't line up in columns. It won't even compile!
Print "1"+CHR$(6)+"2" does compile, but the print routine seems to ignore the tab.
I'm not sure how to work around this for spectrum programs that format text out in columns, or use commas to hop to the next line.
Optimization freak (I am. If I can save one assembler instruction, that's at least a byte saved!)
I notice that:
PRINT "1";
PRINT "2"
and PRINT "1";"2"
Produce exactly the same assembler code! Bravo. But
PRINT "1"+"2" is quite a lot shorter - the compiler sees it can combine the strings into one label.
Similarly:
PRINT INK1;"BLUE";INK 2;"RED"
is quite a lot longer in assembler than:
PRINT CHR$(16)+CHR$(1)+"BLUE"+CHR$(16)+CHR$(2)+"RED"
Your print routine parses both the above lines identically. The second, while far less decipherable to a human), to the compiler is a whole 14 bytes shorter in the assembler. Given how common print and combined color codes are in code, I suspect there is a notable size optimization that could be made in compiled code.
Off this post's topic:
The other one I noticed would be not storing a variable in a register if we don't need to:
Does Load, increment, store, multiply, store.
First up, I noticed it doesn't reload from store in the middle. It also recognizes multiply by two, and does the bitshift. That's very cool. It doesn't need to store in the middle tho!
(Is it worth optimizing double and triple bitshifts for *4 and *8 and so on? These are common multipliers, if only for screen coordinates.)
|
|
|
Feature: Italics! |
Posted by: britlion - 04-29-2009, 12:09 PM - Forum: Wishlist
- Replies (9)
|
 |
I was rummaging through the .asm code, and I note it's pretty well optimized - though I can see places that could be neater. But that's for another time.
I noticed one of the runtime code blocks was labelled Italics..
So, curious, I tried compiling:
PRINT ITALIC 1; "Italics?"
And it worked perfectly! This isn't documented anywhere! What an awesome little addition to the language.
(It prints the text with the top a pixel to the right and the bottom a pixel to the left, and the middle left alone)
This should probably be added to the reserved words list.
|
|
|
Faster multiply? |
Posted by: britlion - 04-28-2009, 09:34 PM - Forum: ZX Basic Compiler
- Replies (8)
|
 |
Okay, I confess: I'm not an assembler user. This is why I need a compiler.
That said, I love to nosey into things I don't understand. I often learn from that.
I was looking at an old piece of assembler code I found, when trying (fairly unsuccessfully) to learn Z80 code:
8 Bit number multiply
Rotates Num 1 round to examine it. Rotates Num2 up. Adds HL and DE if the bit is set.
Result is Num1 * Num2 in HL.
LD HL,0
LD DE, (NUM2)
LD A, (NUM1)
LOOP RR A (Divide A by 2 - copying the 1's column bit into the carry flag.)
JR NC, JP1 (Jump over the add if we have to)
ADD HL,DE
JP1 RET Z (Leave when we finish - A has gone to zero)
SLA E }
RL D } Multiply DE*2
JR LOOP
naturally, when I found this again, I couldn't resist comparing it to the 8 bit multiply assembler in the library. I'm not sure which is faster (Boriel's code is a little unclear in the fastcall case which registers are set with parameters; I think it's A and HL tho. I have a suspicion this code is faster, if only because it doesn't loop for a whole 8 bits if A is small - it quits as soon as A hits zero, which might optimize a few loops out.
Anyway, just for your perusal. Like I said, I'm a little beyond my depth on this one; but I love to optimize where I can!
I'm glad LCD mentioned the HISOFT compiler - because I think it does an awesome job. The limitation with it is that it's ON the spectrum, so you need room for basic + compiler + compiled code [though it can be clever and delete the basic as it goes to make more room]. I'm hoping Boriel's compiler will eventually Exceed the speed of Hisoft's - because it can be much cleverer outside the Spectrum than one locked into it!
|
|
|
String Slicing (*solved*) |
Posted by: britlion - 04-27-2009, 07:32 PM - Forum: Bug Reports
- Replies (3)
|
 |
Not sure whether this is as intended, but it's not quite compatible with Sinclair Basic:
LET K$="1234567890"
PRINT K$(TO 3)
PRINT K$( 3 TO)
All seems to compile - though strings are numbered from 0, whereas Sinclair basic numbers them from 1.
So ZX Basic gives the output:
1234, where Sinclair basic would give the output 123
If the aim is to be able to compile Sinclair Basic, we're not there with that one. (Perhaps a switch, or configurable option?)
Also:
Print K$(3) fails. We would need to use k$(3 TO 3). Is this a bug?
PRINT K$( TO ) also fails, and ZX Basic allows it. It's an unusual corner case, though - it means the same thing as just K$. If it was to be supported for compatibility, a preprocessor tweak ought to be able to optimize it to disappear before the compiler saw it.
|
|
|
|