Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Efficiency Optimizations
#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 :-)
Reply
#2
I think, this is best moved to "Whishlist" (TO DO list, wishes, suggestions, etc...) so it won't get buried among other threads. Smile
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)