(04-21-2016 05:49 PM)Gene Wrote: [ -> ]Couple of items from PPC Journal issues, just for the fun of it.
Thanks, Gene!
The first two are sequential, so I won't consider them.
The third is really interesting, but fails for SIZE 0 and SIZE 257 (possibly more).
And the last is shorter only because the label is shorter ;-)) It's an exact match of what I used to have. Perhaps I found it in the PPC Journal myself ;-)
Thanks,
Werner
If speed is what you're after, then this is probably better:
(number entry is slow on a 41 compared to other instructions)
(38 bytes without END, 29 without LBL and END)
Code:
>LBL"SIZE?"
255
ABS
50
LASTX
ISG X
>LBL 01
SF 25
ARCL IND Z
%
FC?C 25
CHS
ST+ Z
ABS
INT
X>0?
GTO 01
LASTX
RUP
+
CLA
END
Cheers, Werner
(04-22-2016 06:57 AM)Werner Wrote: [ -> ]If speed is what you're after, then this is probably better:
(number entry is slow on a 41 compared to other instructions)
(38 bytes without END, 29 without LBL and END)
Code:
>LBL"SIZE?"
255
ABS
50
LASTX
ISG X
>LBL 01
SF 25
ARCL IND Z
%
FC?C 25
CHS
ST+ Z
ABS
IP
X>0?
GTO 01
X<>Y
RDN
+
CLA
END
Cheers, Werner
Something is wrong here. What is IP? If you meant INT, then program ends up with 99.5 registers. So half a register got lost? No good!
It isn't quicker than the previous one either. I'm getting 4 seconds within a tolerance of .05 sec timing it by hand. All measured with 100 regs currently allocated.
Cheers
The wrapup code at the end was wrong, I corrected it.
I use Free42 on my phone to test these things, and there INT is IP..
and it's true I didn't do a speed test - the difference would've been small, but should still be noticeable, or so I thought.
Werner