Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 283
» Latest member: amcomputersllc
» Forum threads: 993
» Forum posts: 6,118

Full Statistics

Online Users
There are currently 100 online users.
» 0 Member(s) | 99 Guest(s)
Bing

Latest Threads
Pascalated ZX BASIC Demo ...
Forum: Gallery
Last Post: zarsoft
05-21-2023, 01:07 PM
» Replies: 0
» Views: 22
Pascalated ZX BASIC Demo ...
Forum: Gallery
Last Post: zarsoft
05-15-2023, 02:21 PM
» Replies: 0
» Views: 49
Pascalated ZX BASIC Demo ...
Forum: Gallery
Last Post: zarsoft
05-06-2023, 07:56 PM
» Replies: 0
» Views: 50
No more loading messages ...
Forum: Help & Support
Last Post: zarsoft
05-06-2023, 10:00 AM
» Replies: 2
» Views: 99
Pascalated ZX BASIC Demo ...
Forum: Gallery
Last Post: zarsoft
04-29-2023, 04:33 PM
» Replies: 0
» Views: 60
Pascalated ZX BASIC Demo ...
Forum: Gallery
Last Post: zarsoft
04-23-2023, 05:37 PM
» Replies: 0
» Views: 53
Pascalated ZX BASIC Demo ...
Forum: Gallery
Last Post: zarsoft
04-15-2023, 03:01 PM
» Replies: 0
» Views: 86
Pascalated ZX BASIC Demo ...
Forum: Gallery
Last Post: zarsoft
04-09-2023, 01:01 PM
» Replies: 0
» Views: 88
Error: Invalid file name ...
Forum: Bug Reports
Last Post: zarsoft
04-05-2023, 09:44 AM
» Replies: 2
» Views: 198
Microsoft Windows On The ...
Forum: Gallery
Last Post: zarsoft
04-04-2023, 11:00 PM
» Replies: 2
» Views: 308

 
  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:

Code:
LET A=A+1
LET A=A*2

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
Code:
ld bc, 0
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 :-)

Print this item

  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...

Print this item

  Version 1.2.1 released!
Posted by: boriel - 05-19-2009, 11:18 PM - Forum: ZX Basic Compiler - No Replies

Changes since 1.2.0

  • ! This version just fix a possible memory corruption (reported by britlion, thanks).
    But still needs more checking...
  • ! DIM f% = <value> was not allowed. Now it is.
  • Programs can now be re-runable without having to LOAD them again once returned to BASIC.
  • * Some little improvements on memory organization. Now all user-data (HEAP and VARs) are in a single contiguous block.
    This will make possible to implement SAVE "" DATA in the near future so a program can LOAD & SAVE data.

TO DO:
... Many things! Wink

Print this item

  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

Print this item

  Making ZX Basic to work with Tommy Gun
Posted by: boriel - 05-17-2009, 12:47 PM - Forum: How-To & Tutorials - Replies (8)

Tommy Gun is a great Retro-develpment IDE.
As of version 0.9.39 it's author add some modifications so ZX Basic compiler will also work with this excelent IDE.

Just follow this steps:

  1. Download & Install Tommy Gun (v. >= 0.9.39)
  2. Download & Install ZX Basic .MSI version for Windows (see http://www.boriel.com/files/zxb)
  3. On the Tommy Gun IDE Config options, go to Build Settings, and configure builder options as shown (ZX Basic already comes pre-configured):

    .png   Captura de pantalla de 2020-05-03 11-39-58.png (Size: 53.91 KB / Downloads: 609)
  4. Save them, and you're done!

Only the remarked (in red) fields are necesary.

From now on, you have syntax highlighting and error line location. To go to an error line, just click on the compilation error message and the cursor will jump to the respective line automatically.

You might be interested in changing some command line options (to change output format, etc...). See command line options documentation for more info.

Print this item

  Version 1.2.0 released!
Posted by: boriel - 05-12-2009, 12:06 AM - Forum: ZX Basic Compiler - No Replies

Changed from Version 1.1.9 to 1.2.0

  • ! Undeclared local variables caused a compiler error.
    They should just compile (like global ones do). Thanks, LCD.
  • ! String variables used in string slices where sometimes
    optimized (ignored). Thanks, LCD, again. Wink
  • ! ELSEIF constructions were not being compiled correctly.

TODO:
  • Bitwise instructions for AND, OR, XOR, NOT
  • CLEAR to fill memory areas
  • READ, DATA and RESTORE
  • SAVE & LOAD

Print this item

  optimised INCR & DECR variable
Posted by: LCD - 05-11-2009, 10:02 PM - Forum: Wishlist - Replies (2)

Because I also coded some stuff in AMOS on Amiga: How about optimised INCR and DECR commands for variables? This can be easyly optimised because Z80 knows INC and DEC commands, and variable=variable+1 is maybe much slower.
INCR variable incrases the value by one. This will be very handy, I think Smile.

Print this item

  STR problem (*solved*)
Posted by: LCD - 05-11-2009, 01:19 PM - Forum: Bug Reports - Replies (12)

Code:
SUB MeineRoutine(x as uinteger,y as uinteger,a$ as string)
IF a$="Test" THEN erg$="Es wurde nur getestet"
ELSE erg$=a$+str(x)+" "+str(y)
end if

PRINT erg$
END SUB

MeineRoutine(30,11,"Hallo")
Compiler claims "temp.bas:48: Error: Undefined label '_MeineRoutine_erg' Errors occured, compilation failed" (No line 48 defined)
I guess, this is a Problem with STR because this:
Code:
dim a as ubyte
a=20
print str(a)
Produces a code that crashes the Emulator

BTW: should POKE STRING adr,string$ work? I mean, if POKE UINTEGER works...

Print this item

  Memory Map
Posted by: LCD - 05-11-2009, 12:22 PM - Forum: Wishlist - Replies (9)

As mentioned on WOS:
A idea for the future version: How about the compiler generating a text file with memory map (not very complex... or with selectable level of detail) I think, something like:
25000-45678 : Main Program
45679-52111 : ASM: Label GRAPHICSDATA
52112-59876 : ASM: Label LevelData
59877-60521 : Variables
or:
25000 : Main Program
45679 : ASM: Label GRAPHICSDATA
52112 : ASM: Label LevelData
59877 : Variables
Level of Detail:
0=Only Program and Variables
1=like 0, but additionaly ASM Labels
2=like 1, but additionaly Basic Labels
3=like 2, but adresses of every used variable added (HiSoft Basic Compiler does this too, this will make it easier to alter or read variables of compiled programs from BASIC Loader for example)

Using a switch like -m level, -M "Filename.txt" or similar (I do not know how the parser works, maybe this can be joined into a single switch)
Memory map can then be parsed by the editor, or the user can check the details.

Print this item

  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?

Print this item