Wow. Crazy fast. I've been schooled for sure. For a program with no
whitespace to speak of, it's pretty straightforward (not that I would
have come up with it anytime soon, but it reads well). Thanks for taking
the time and providing it... along with the comments!Lots of things to
think about and learn about here.
Will
On 10/29/22 4:07 AM, MikeS wrote:
Verbose ruminations? We doan need no steenkin' documentation!
Here's my latest (final?) version incorporating some of the ideas and
hopefully a little less esoteric. Time to print 50 lines from 61 seconds
down to 34, size from 635 bytes down to 406. Funny to watch it dump
itself ;-)
BTW, just to repeat: LOADing from a PC using TEXT runs flawlessly at
9600bd whereas loading from BASIC definitely drops characters.
It's actually sorta been fun programming on the 'real' M100; I left a
download running on the PC and every time I wanted to backup an interim
version just in case, I just pressed F3 and F7 (which I'd programmed
with the COM stats).
As usual, constructive criticism welcome.
1 DEFINTJ-Z:DIMH$(15):FORI=0TO15:REM V3
10 H$(I)=CHR$(48+I-(7*(I>9))):NEXT:CLS
15 INPUT"From";A:INPUT"to";B:T$=TIME$
20 FORI=ATOBSTEP8:K=I/4096:PRINTH$(K);
25 L=(I-K*4096):PRINTH$(L\256);
30 PRINTH$((LMOD256)\16)H$(LMOD16)" ";
40 L$="":FORJ=0TO7:X=PEEK(I+J)
50 PRINTH$(X\16);H$(XMOD16)" ";
60 Y$=".":IFX>31ANDX<127THENY$=CHR$(X)
70 L$=L$+Y$:NEXT:PRINTL$:NEXT
80 E$=TIME$:PRINTT$+" to "+E$:END
---------
1 Initialize
10 Load H$( array with 1-F
15 Get range, start timer
20-30 Convert & print every 8th address
40 PEEK 8 bytes
50 Convert & print bytes
60 Replace invalid chars with '.'
70 Assemble and print text
80 Print elapsed time
----- Original Message -----
*From:* Will Senn <mailto:[email protected]>
*To:* [email protected]
*Sent:* Friday, October 28, 2022 1:54 PM
*Subject:* Re: [M100] Notoriously S.L.O.W BASIC posted - help
speeding it up appreciated
Oh yes, am I ever. A bit overwhelmed, actually. It'll take me a
month to work through all of these suggestions and potential
optimizations :). I suspected there were folks in the world who took
BASIC to its edges, but I had no idea :). The thread on that weird
listing a while back should have been a clue, but I thought it was a
one-off. I'm in awe of y'all's grasp of the finer points and look
forward to learning more. I tend to try to avoid the more esoteric
optimizations in favor of clarity, but in this case, so long as I
notate appropriately, I'll get over it! It seems like folks tend to
move their more verbose ruminations out of the BASIC files and into
accompanying .DO files, that about right?
Thanks,
Will
On 10/28/22 2:07 AM, MikeS wrote:
Thanks for that; I'll have to check it out later. Meanwhile, I
think if we're going to use a lookup table at all then I also
prefer your use of an array for H$, but I'd load it a little
differently (as John and I were discussing):
5 DIM H$(15):FOR T=0 TO 15:H$(T)=CHR$(48+T-(7*(T>9))):NEXT
Tsk, tsk; you're cheating by inputting the range in decimal so you
don't have to do a HEX to decimal conversion ;-) I suppose it
makes sense though...
More serious, using integers for the addresses restricts the dump
to <8000H; I had the same problem first time around.
Enjoying the thread... wonder if Will's getting anything out of it ;-)
m
----- Original Message -----
*From:* B 9 <mailto:[email protected]>
*To:* [email protected]
*Sent:* Thursday, October 27, 2022 11:38 PM
*Subject:* Re: [M100] Notoriously S.L.O.W BASIC posted - help
speeding it up appreciated
On Thu, Oct 27, 2022 at 3:04 PM John R. Hogerhuis
<[email protected]> wrote:
With hex it's a question though since MOD 16 can be done
with AND 15 which is probably faster than a general
integer 16 modulus. There's no bitshift operator so you
still need a integer divide by 16%. Who knows how
efficient an integer divide by 16 is in the interpreter
versus 4096 (integer) divides.
That's a good question about efficiency. Integer division by
4096 seems reasonably quick, but it would have been nice if
BASIC had exposed the bit shift operators. (I'm presuming the
8085 had some, right?)
I'm not sure it'd be any faster than division by 4096, but one
could use the fact that we're using a 2-byte integer for the
address and just look at each byte.
hexit.do
1 TS$=TIME$
5 DIM H$(15):*FOR* T=0*TO* 9:H$(T)=CHR$(48+T):*NEXT* T:*FOR* T=ASC("A")*TO*
ASC("F"): H$(T-55)=CHR$(T):*NEXT*
6 DIM R$(7):*FOR* T=0*TO* 7: R$(T)=" ":*NEXT*
10 DEFINT A-F, P: D=0: P=VARPTR(D)
15 INPUT "Start"; ST%
16 INPUT "End"; EN%
20*FOR* D=ST%*TO* EN%
30*IF* (D MOD 8) = 0*THEN* *PRINT*" ";:*FOR* T=0*TO* 7:*PRINT*
R$(T);:*NEXT*:*PRINT*: S=0:*GOSUB* 400
40*GOSUB* 200
90*NEXT*
100 REM Timing
110 TE$=TIME$
115*PRINT*
120*PRINT* TS$ " to " TE$
199*END*
200 REM Print 2 hexits
201*' *Input: D is address of an 8-bit integer**202*'* Output: None,
but 2 hexits are printed followed by a space
210 A=PEEK(D)
220*PRINT *H$(A\16); H$(A MOD 16); " ";
230*IF* A<32*THEN* A=46
240 R$(S)=CHR$(A)
250 S=S+1
260*RETURN*
400 REM Print 4 hexits
401*' *Input: P is address of a 16-bit little endian integer
402*'* Output: None, but 4 hexits are printed followed by a space
410 A=PEEK(P+1): B=PEEK(P)
420*PRINT *H$(A\16); H$(A MOD 16); H$(B\16); H$(B MOD 16); " ";
430*RETURN*
------------------------------------------------------------------------
—b9