Posts: 615
Threads: 49
Joined: Feb 2009
Reputation:
2
Hi Boriel, I just trying to write some stuff in ZX Basic compiler 1.1.0, but I ran into some problems:
Code: x=0
if x=1 then
print "1"
else if x=0 then
print "0"
end if
I got the message "Unexpected end of file", so if it is a part of FOR NEXT Loop, I got the message "Unexpected Token 'NEXT' <NEXT>". ELSE alone works, but I was sure, ELSE IF should work too, Or maybe I'm wrong?
Another one: the program does not accept Exponents: 2e4 (=2000) or similar.
And finally:
Negative STEP does not work with integers or long, only with floats or byte:
Code: dim x as integer
for x=7 to 1 step -1
print x
next x
The compiler is otherwise fantastic! Please continue your great work!
Posts: 1,774
Threads: 55
Joined: Aug 2019
Reputation:
24
LCD Wrote:Hi Boriel, I just trying to write some stuff in ZX Basic compiler 1.1.0, but I ran into some problems:
Code: x=0
if x=1 then
print "1"
else if x=0 then
print "0"
end if
I got the message "Unexpected end of file", so if it is a part of FOR NEXT Loop, I got the message "Unexpected Token 'NEXT' <NEXT>". ELSE alone works, but I was sure, ELSE IF should work too, Or maybe I'm wrong?
[/code] Hmmm. Every if should be closed with END IF, so another END IF is missing in your code. Try this way:
Code: x=0
if x=1 then
print "1"
else
if x=0 then
print "0"
end if
end if
Maybe you were expecting to use ElseIf which has the same syntax you expected. I'll see if I can change the grammar to include it.
Quote:Another one: the program does not accept Exponents: 2e4 (=2000) or similar.
Yes, I also find out yesterday. Will be fixed in 1.1.2.
Quote:And finally:
Negative STEP does not work with integers or long, only with floats or byte:
Code: dim x as integer
for x=7 to 1 step -1
print x
next x
Oops! :? This is very important. I will check this immediately.
Quote:The compiler is otherwise fantastic! Please continue your great work!
Thanks a lot for your feedback :!: I will replay when this is Fixed (ASAP).
By the way, version 1.1.1 is out. I suggest you to try it and check if this bug is still there, because I fixed many things.
Posts: 615
Threads: 49
Joined: Feb 2009
Reputation:
2
boriel Wrote:Hmmm. Every if should be closed with END IF, so another END IF is missing in your code. Try this way:
Code: x=0
if x=1 then
print "1"
else
if x=0 then
print "0"
end if
end if
Maybe you were expecting to use ElseIf which has the same syntax you expected. I'll see if I can change the grammar to include it.
In fact I tried ELSEIF too, but it was not working too (I prefer Syntax like ELSEIF or ENDIF much more than ELSE IF or END IF), but you are absolutly right, I was expecting, it works like you displayed in the link, where only one ENDIF is needed for one IF...THEN...ELSEIF...ELSE...ENDIF block
Quote:Yes, I also find out yesterday. Will be fixed in 1.1.2.
Great!
Quote:Quote:And finally:
Negative STEP does not work with integers or long, only with floats or byte:
Code: dim x as integer
for x=7 to 1 step -1
print x
next x
Oops! :? This is very important. I will check this immediately.
Quote:The compiler is otherwise fantastic! Please continue your great work!
Thanks a lot for your feedback :!: I will replay when this is Fixed (ASAP).
By the way, version 1.1.1 is out. I suggest you to try it and check if this bug is still there, because I fixed many things.
Just downloaded the new version.
This loop works still only with Byte or Float definition for x, and not with ubyte, integer, uinteger, long or ulong. I guess unsigned types are not suitable for negative steps even if the value does not reach negative numbers.
BTW: does Memory Allocation mean, it will utilise 128K Spectrum (Maybe later SAM Coupé) memory one day?
Posts: 1,774
Threads: 55
Joined: Aug 2019
Reputation:
24
Well, I've released 1.1.2 (in .zip and .tar.gz format only). It fixes the FOR issue and also the scientific notation number issue. It also adds PRINT TAB compatibility. You can check it out to see if it works now.
Thanks a lot! :!:
Posts: 615
Threads: 49
Joined: Feb 2009
Reputation:
2
boriel Wrote:Well, I've released 1.1.2 (in .zip and .tar.gz format only). It fixes the FOR issue and also the scientific notation number issue. It also adds PRINT TAB compatibility. You can check it out to see if it works now.
Thanks a lot! :!: Thanks!
I just downloaded python and the new zxb, but I can`t get ConText to work with it again (the PATH is entered in config). Maybe it is a bit unhealthy to use msi and py version at the same time... Maybe it will work better after restarting the computer...
Posts: 1,774
Threads: 55
Joined: Aug 2019
Reputation:
24
LCD Wrote:boriel Wrote:Well, I've released 1.1.2 (in .zip and .tar.gz format only). It fixes the FOR issue and also the scientific notation number issue. It also adds PRINT TAB compatibility. You can check it out to see if it works now.
Thanks a lot! :!: Thanks!
I just downloaded python and the new zxb, but I can`t get ConText to work with it again (the PATH is entered in config). Maybe it is a bit unhealthy to use msi and py version at the same time... Maybe it will work better after restarting the computer... Ok, I've created and uploaded the .MSI package, so if you want to give it a try... download it form the installation page.
I didn't wanted to upload the .msi until you tested it a bit more... but it's ok anyway.
Posts: 615
Threads: 49
Joined: Feb 2009
Reputation:
2
Wonderfull! now it works perfectly, thanks!
The best way to find bugs, is to write some games. So I will continue now one of my projects...
Posts: 1,774
Threads: 55
Joined: Aug 2019
Reputation:
24
LCD Wrote:Wonderfull! now it works perfectly, thanks!
The best way to find bugs, is to write some games. So I will continue now one of my projects... Please, give a try to the just new release 1.1.4, since it used (finally) a peephole optimizer (use -O3). Maybe you will notice a faster program execution with this flag.
Posts: 615
Threads: 49
Joined: Feb 2009
Reputation:
2
Thanks! Downloading it... Btw: I think, it will be possible to change SpLib (Sprite Library from <!-- m --><a class="postlink" href="http://www.geocities.com/aralbrec/">http://www.geocities.com/aralbrec/</a><!-- m -->) from Z88dk to your compiler and write a wrapper, after removing Hires and hicolor code. The only problem I ecountered, is the transfer of parameters, even without optimisations switched on, it often do not work, even not with dummy variables. Example:
Code: Sub PutGfx(x,y,adr)
dummy=adr
dummy=x
dummy=y
asm
ld hl,(_adr)
ld b,(_x)
ld c,(_y)
....
end asm
end sub
I was checking how you do transfer parameters to ASM in Librarys, and you are using the stack pointer. Clever! I will try the new version out later today.
Thanks!
Posts: 1,774
Threads: 55
Joined: Aug 2019
Reputation:
24
LCD Wrote:Thanks! Downloading it... Btw: I think, it will be possible to change SpLib (Sprite Library from <!-- m --><a class="postlink" href="http://www.geocities.com/aralbrec/">http://www.geocities.com/aralbrec/</a><!-- m -->) from Z88dk to your compiler and write a wrapper, after removing Hires and hicolor code. The only problem I ecountered, is the transfer of parameters, even without optimisations switched on, it often do not work, even not with dummy variables. Example:
Code: Sub PutGfx(x,y,adr)
dummy=adr
dummy=x
dummy=y
asm
ld hl,(_adr)
ld b,(_x)
ld c,(_y)
....
end asm
end sub
I was checking how you do transfer parameters to ASM in Librarys, and you are using the stack pointer. Clever! I will try the new version out later today.
Thanks!
Yes, that's it. I use IX as a stack pointer. A tip to guess the parameter address:
Code: Sub PutGfx(x,y,adr)
dummy=adr
dummy=x
dummy=y
Compile with -A flag only. This will give you unoptimized assebler code. Now edit the generated .asm file and you will see there the addresses of parameters adr, x and y. I think I need to write a tutorial. :!:
Posts: 615
Threads: 49
Joined: Feb 2009
Reputation:
2
Just tested some stuff. Wow, it is much faster!!! Still a little bit slower than HiSoft Basic, but this does not matter anymore. It is the best Compiler around!
I know the option to use -A flag to create the assembly, and used it often, but that is not the best solution. I test my programs often, and using -A causes slow down in the development process because there are some additional steps like checking the adress, editing and recompiling the code. I personally think, each DIM'ed variable should create a label in any case. At least there could be a option to do so.
Anyway, your work is great!!! I thank you very much for all efforts, you put into this software, as it turns slowly out, to be my favorite software on PC.
Posts: 1,774
Threads: 55
Joined: Aug 2019
Reputation:
24
LCD Wrote:DIM'ed variable should create a label in any case. At least there could be a option to do so. Hey! That's a GREAT idea! :!: Thanks a lot. I think I could implement them as a macro so you cuould do something like:
Code: Function f
DIM a as byte
...
End Function
The local variable 'a' (parameters are also local variables in the end) could be translated as:
Notice the _f (function name) is prepended to the variable names defined into that funcion. This is because there could be more than one "a" variable (one in the global scope and another in the local scope). So now you can do this:
Code: ld a, (_f_a)
add a, 2
ld (_f_a), a ; LET a = a + 2
¿What do you think?
Posts: 615
Threads: 49
Joined: Feb 2009
Reputation:
2
boriel Wrote:Hey! That's a GREAT idea! :!: Thanks a lot. I think I could implement them as a macro so you cuould do something like:
Code: Function f
DIM a as byte
...
End Function
The local variable 'a' (parameters are also local variables in the end) could be translated as:
Notice the _f (function name) is prepended to the variable names defined into that funcion. This is because there could be more than one "a" variable (one in the global scope and another in the local scope). So now you can do this:
Code: ld a, (_f_a)
add a, 2
ld (_f_a), a ; LET a = a + 2
¿What do you think? I think, this could work, but it maybe could also be forced using this syntax
where "a as integer" does not force the label creation, "_a as integer" does it. Maybe this will be simpler to implement and to use. I would be happy with any of the solutions. It is unusual for most users to access functions from assembly, and maybe not very easy to do, but it should be easy to tell the compiler in a DIM statement: If you see a variable with underscore as the first char, you must create a label for this variable in any case. Local scope variables could be defined in a similar way.
Thats just a idea, sorry, but I never created a compiler myself yet.
|