FAQ  •  Register  •  Login

Efficiency Optimizations



Posts: 766

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Thu May 21, 2009 2:27 pm

Efficiency Optimizations

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:



   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:

DIM A as byte



Actual -O3 Result:

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

Unoptimized it closes out with
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 :-)


Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Thu May 21, 2009 6:47 pm

Re: Efficiency Optimizations

I think, this is best moved to "Whishlist" (TO DO list, wishes, suggestions, etc...) so it won't get buried among other threads. :)

Return to Wishlist

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.