Jump to content
OLD CS1

BASIC and Extended BASIC subprogram and function execution times

Recommended Posts

1 hour ago, RXB said:

Luckily it only fetches ROW and COLUMN once from Floating Point, and you can speed this up a little bit in GPL by using same routine that fetches in INVERSE.

No need for Floating point in these so you can just read the value 2 bytes that would be integer values converted from floating point XML SPEED

DATA >00EC says check if number or string value and if string error if number 

  Reveal hidden contents

[4286]               ***********************************************************
[4287]               * CALL INVERSE(char#[,...])                                
[4288]               ***********************************************************
[4289] BC9A 06,A9,81 INVERS     CALL COMB             * INVERSE(CHAR#)
[4290] BC9D 0F,79    INVAGN       XML  PGMCHR
[4291] BC9F D6,42,EC                 CEQ  ALLZ,@CHAT
[4292] BCA2 5C,B6                      BR   INOALL
[4293] BCA4 0F,7E                       XML  SPEED
[4294] BCA6 00,EC                      DATA >00EC
[4295] BCA8 BF,4A,00                  DST  >001E,@FAC    * ALL token?
       BCAB 1E
[4296] BCAC E3,4A,00                  DSLL 3,@FAC
       BCAF 03
[4297] BCB0 BF,54,01                  DST  >01C8,@TEMP1
       BCB3 C8
[4298] BCB4 5C,C4                     BR   INVLP
[4299] BCB6 0F,74    INOALL       XML  PARSE
[4300] BCB8 B6                         BYTE RPARZ
[4301] BCB9 06,BD,75               CALL S1ET9F
[4302] BCBC E3,4A,00               DSLL 3,@FAC
       BCBF 03
[4303] BCC0 BF,54,00                DST  >0004,@TEMP1
       BCC3 04
[4304] BCC4 85,E3,00 INVLP     DINV [email protected]>0300(@FAC)
       BCC7 4A
[4305] BCC8 A3,4A,00              DADD >0002,@FAC
       BCCB 02
[4306] BCCC 93,54                   DDEC @TEMP1
[4307] BCCE 5C,C4                  BR   INVLP
[4308] BCD0 D6,42,B3 INVNOK CEQ  COMMAZ,@CHAT
[4309] BCD3 7C,9D                  BS   INVAGN
[4310] BCD5 4A,96                  BR   LNKRTN
[4311]               ***********************************************************

 

[4370]               *****************************************
[4371] BD75 0F,7E    S1ET9F   XML  SPEED  * CHECK FROM
[4372] BD77 02,1E                 DATA >021E  * 30 TO 159
[4373] BD79 00,9F                 DATA >009F  *
[4374] BD7B 00                     RTN         *
[4375]               ******************************************

I should test this to see if this is true as I have always just taken for granted looking at XB ROMs that it does not do CFI ever.

As the VALUE in FAC is not changed using DEBUG in Classic99 you see >10 if do a CALL INVERSE(32) that is not a Floating Point value.

Well just check with Debugger and if you put a break point at >12B8 (this is CFI) it never breaks so never used CFI XML in console routine.

Thus I should change most RXB routines that do not need Floating Point to this version and that should speed up XB by a marked amount.

I stand corrected. The line below is what threw me:

  HCHAR1 BYTE >08,>E0,>00,>FB  * FMT '@VAR0'   Display horizo

I assumed format fetched VAR0 from XB and did the floating point conversion to it, but it turns out VAR0 is the value at >8300

 

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, senior_falcon said:

I stand corrected. The line below is what threw me:

  HCHAR1 BYTE >08,>E0,>00,>FB  * FMT '@VAR0'   Display horizo

I assumed format fetched VAR0 from XB and did the floating point conversion to it, but it turns out VAR0 is the value at >8300

 

Actually you have helped me look at the code of XB and realize I can modify all access to Variables and remove FP from them.

Example is right now I am working on CALLL PEEK so it will not do Floating Point for address and it should only care about -32767 to 32768.

In this case only works with Integer (Hex >0000 to >FFFF) and will do a timed test in 10,000 loops to see how much it is speeded up.

  • Like 1

Share this post


Link to post
Share on other sites

Be sure you don't break things that matter to people. For example, this peeks the DEF table in XB:


5 CALL PEEK(8196,A,B):: L=A*256+B
10 FOR I=16376 TO L STEP -8
20 CALL PEEK(I,A,B,C,D,E,F,G,H):: PRINT CHR$(A);CHR$(B);CHR$(C);CHR$(D);CHR$(E);CHR$(F),G*256+H
30 NEXT I

 

The variable I is the address to peek from. It's hard to see how to do this without using a variable, which are always floating point in XB

Share this post


Link to post
Share on other sites
1 hour ago, senior_falcon said:

Be sure you don't break things that matter to people. For example, this peeks the DEF table in XB:


5 CALL PEEK(8196,A,B):: L=A*256+B
10 FOR I=16376 TO L STEP -8
20 CALL PEEK(I,A,B,C,D,E,F,G,H):: PRINT CHR$(A);CHR$(B);CHR$(C);CHR$(D);CHR$(E);CHR$(F),G*256+H
30 NEXT I

 

The variable I is the address to peek from. It's hard to see how to do this without using a variable, which are always floating point in XB

First off why and where is Floating Point needed here?

Also strange result removing Floating Point actually slowed down the results.

It took 20 seconds longer with Integer then Floating Point in 10,000 loops? 5 runs same result each time.

Cut the amount of code in half, but XML SPEED for some reason has a huge impact on speed of XB even when it is not doing anything useful.

Share this post


Link to post
Share on other sites
1 hour ago, RXB said:

First off why and where is Floating Point needed here?

 

To answer your question of "why," to my knowledge, every number in TI BASIC/XB is a floating point number. Whether it is 3 or 3.14159265, it is a floating point number that uses 8 bytes.

For your question of "where," the variables A,B,C,D,E,F,G,H,I, and L are all floating point.

In theory you could take CALL LOAD(8194,100) and go directly to a 2 byte integer. But with CALL LOAD(X,Y) you have to fetch X and Y from BASIC where they are floating point and need to be converted to integer.

Unless RXB has provision for both floating point and integer variables.

  • Thanks 1

Share this post


Link to post
Share on other sites
5 hours ago, senior_falcon said:

To answer your question of "why," to my knowledge, every number in TI BASIC/XB is a floating point number. Whether it is 3 or 3.14159265, it is a floating point number that uses 8 bytes.

For your question of "where," the variables A,B,C,D,E,F,G,H,I, and L are all floating point.

In theory you could take CALL LOAD(8194,100) and go directly to a 2 byte integer. But with CALL LOAD(X,Y) you have to fetch X and Y from BASIC where they are floating point and need to be converted to integer.

Unless RXB has provision for both floating point and integer variables.

Hmmm PI is a Floating point number as it has a decimal point in it.

And yes I can fix this if I added in a token to denote this change.

[0332]               ***********************************************************
[0333]               *    BASIC TOKEN TABLE
[0334]               *      EQU  >80               spare token
[0335] 0081          ELSEZ  EQU  >81               ELSE
[0336] 0082          SSEPZ  EQU  >82               ::
[0337] 0083          TREMZ  EQU  >83               $
[0338] 0084          IFZ    EQU  >84               IF
[0339] 0085          GOZ    EQU  >85               GO
[0340] 0086          GOTOZ  EQU  >86               GOTO
[0341] 0087          GOSUBZ EQU  >87               GOSUB
[0342] 0088          RETURZ EQU  >88               RETURN
[0343] 0089          DEFZ   EQU  >89               DEF
[0344] 008A          DIMZ   EQU  >8A               DIM
[0345] 008B          ENDZ   EQU  >8B               END
[0346] 008C          FORZ   EQU  >8C               FOR
[0347]               LETZ   EQU  >8D               LET     * RXB REMOVED
[0348] 008E          BREAKZ EQU  >8E               BREAK
[0349] 008F          UNBREZ EQU  >8F               UNBREAK
[0350] 0090          TRACEZ EQU  >90               TRACE
[0351] 0091          UNTRAZ EQU  >91               UNTRACE
[0352] 0092          INPUTZ EQU  >92               INPUT
[0353] 0093          DATAZ  EQU  >93               DATA
[0354] 0094          RESTOZ EQU  >94               RESTORE
[0355] 0095          RANDOZ EQU  >95               RANDOMIZE
[0356] 0096          NEXTZ  EQU  >96               NEXT
[0357] 0097          READZ  EQU  >97               READ
[0358] 0098          STOPZ  EQU  >98               STOP
[0359] 0099          DELETZ EQU  >99               DELETE
[0360] 009A          REMZ   EQU  >9A               REM
[0361] 009B          ONZ    EQU  >9B               ON
[0362] 009C          PRINTZ EQU  >9C               PRINT
[0363] 009D          CALLZ  EQU  >9D               CALL
[0364] 009E          OPTIOZ EQU  >9E               OPTION
[0365] 009F          OPENZ  EQU  >9F               OPEN
[0366] 00A0          CLOSEZ EQU  >A0               CLOSE
[0367] 00A1          SUBZ   EQU  >A1               SUB
[0368] 00A2          DISPLZ EQU  >A2               DISPLAY
[0369] 00A3          IMAGEZ EQU  >A3               IMAGE
[0370] 00A4          ACCEPZ EQU  >A4               ACCEPT
[0371] 00A5          ERRORZ EQU  >A5               ERROR
[0372] 00A6          WARNZ  EQU  >A6               WARNING
[0373] 00A7          SUBXTZ EQU  >A7               SUBEXIT
[0374] 00A8          SUBNDZ EQU  >A8               SUBEND
[0375] 00A9          RUNZ   EQU  >A9               RUN
[0376] 00AA          LINPUZ EQU  >AA               LINPUT
[0377]               *      EQU  >AB               Zpare token (LIBRARY)
[0378]               *      EQU  >AC               Zpare token (REAL)
[0379]               *      EQU  >AD               Zpare token (INTEGER)
[0380]               *      EQU  >AE               Zpare token (SCRATCH)
[0381]               *      EQU  >AF               Zpare token
[0382] 00B0          THENZ  EQU  >B0               THEN
[0383] 00B1          TOZ    EQU  >B1               TO
[0384] 00B2          STEPZ  EQU  >B2               STEP
[0385] 00B3          COMMAZ EQU  >B3               ,
[0386] 00B4          SEMICZ EQU  >B4               ;
[0387] 00B5          COLONZ EQU  >B5               :
[0388] 00B6          RPARZ  EQU  >B6               )
[0389] 00B7          LPARZ  EQU  >B7               (
[0390] 00B8          CONCZ  EQU  >B8               &          (CONCATENATE)
[0391]               *      EQU  >B9               spare token
[0392] 00BA          ORZ    EQU  >BA               OR
[0393] 00BB          ANDZ   EQU  >BB               AND
[0394] 00BC          XORZ   EQU  >BC               XOR
[0395] 00BD          NOTZ   EQU  >BD               NOT
[0396] 00BE          EQUALZ EQU  >BE               =
[0397] 00BF          LESSZ  EQU  >BF               <
[0398] 00C0          GREATZ EQU  >C0               >
[0399] 00C1          PLUSZ  EQU  >C1               +
[0400] 00C2          MINUSZ EQU  >C2               -
[0401] 00C3          MULTZ  EQU  >C3               *
[0402] 00C4          DIVIZ  EQU  >C4               /
[0403] 00C5          CIRCUZ EQU  >C5               ^
[0404]               *      EQU  >C6               spare token
[0405] 00C7          STRINZ EQU  >C7               QUOTED STRING
[0406] 00C8          UNQSTZ EQU  >C8               UNQUOTED STRING
[0407] 00C8          NUMZ   EQU  >C8               ALSO NUMERICAL STRING
[0408] 00C8          NUMCOZ EQU  >C8               ALSO UNQUOTED STRING
[0409] 00C9          LNZ    EQU  >C9               LINE NUMBER CONSTANT
[0410]               *      EQU  >CA               spare token
[0411] 00CB          ABSZ   EQU  >CB               ABS
[0412] 00CC          ATNZ   EQU  >CC               ATN
[0413] 00CD          COSZ   EQU  >CD               COS
[0414] 00CE          EXPZZ  EQU  >CE               EXP
[0415] 00CF          INTZ   EQU  >CF               INT
[0416] 00D0          LOGZ   EQU  >D0               LOG
[0417] 00D1          SGNZZ  EQU  >D1               SGN
[0418] 00D2          SINZ   EQU  >D2               SIN
[0419] 00D3          SQRZ   EQU  >D3               SQR
[0420] 00D4          TANZ   EQU  >D4               TAN
[0421] 00D5          LENZ   EQU  >D5               LEN
[0422] 00D6          CHRZZ  EQU  >D6               CHR$
[0423] 00D7          RNDZ   EQU  >D7               RND
[0424] 00D8          SEGZZ  EQU  >D8               SEG$
[0425] 00D9          POSZ   EQU  >D9               POS
[0426] 00DA          VAL    EQU  >DA               VAL
[0427] 00DB          STRZZ  EQU  >DB               STR$
[0428] 00DC          ASCZ   EQU  >DC               ASC
[0429] 00DD          PIZ    EQU  >DD               PI
[0430] 00DE          RECZ   EQU  >DE               REC
[0431] 00DF          MAXZ   EQU  >DF               MAX
[0432] 00E0          MINZ   EQU  >E0               MIN
[0433] 00E1          RPTZZ  EQU  >E1               RPT$
[0434]               *      EQU  >E2               unused
[0435]               *      EQU  >E2               unused
[0436]               *      EQU  >E3               unused
[0437]               *      EQU  >E4               unused
[0438]               *      EQU  >E5               unused
[0439]               *      EQU  >E6               unused
[0440]               *      EQU  >E7               unused
[0441] 00E8          NUMERZ EQU  >E8               NUMERIC
[0442] 00E9          DIGITZ EQU  >E9               DIGIT
[0443] 00EA          UALPHZ EQU  >EA               UALPHA
[0444] 00EB          SIZEZ  EQU  >EB               SIZE
[0445] 00EC          ALLZ   EQU  >EC               ALL
[0446] 00ED          USINGZ EQU  >ED               USING
[0447] 00EE          BEEPZ  EQU  >EE               BEEP
[0448] 00EF          ERASEZ EQU  >EF               ERASE
[0449] 00F0          ATZ    EQU  >F0               AT
[0450] 00F1          BASEZ  EQU  >F1               BASE
[0451]               *      EQU  >F2               spare token (TEMPORARY)
[0452]               *      EQU  >F3               spare token (VARIABLE)
[0453]               *      EQU  >F4               spare token (RELATIVE)
[0454]               *      EQU  >F5               spare token (INTERNAL)
[0455] 00F6          SEQUEZ EQU  >F6               SEQUENTIAL
[0456] 00F7          OUTPUZ EQU  >F7               OUTPUT
[0457] 00F8          UPDATZ EQU  >F8               UPDATE
[0458] 00F9          APPENZ EQU  >F9               APPEND
[0459] 00FA          FIXEDZ EQU  >FA               FIXED
[0460] 00FB          PERMAZ EQU  >FB               PERMANENT
[0461] 00FC          TABZ   EQU  >FC               TAB
[0462] 00FD          NUMBEZ EQU  >FD               #
[0463] 00FE          VALIDZ EQU  >FE               VALIDATE
[0464]               *      EQU  >FF               ILLEGAL VALUE
[0465]               ***************************************************

See there are a whole bunch of tokens that have not been used yet in XB so room for 22 tokens currently unused.

The problem starts when you enter a line with a number in it and the program editor itself put token >C8 (Token NUMZ) in front of that number.

Idiocy of how it works is >C8 can be a Unquoted String or a Number or Numerical String....see the insane problem?

A solution is to fix the XB ROMs and GPL to use >C7 for integer numbers. This would mostly maintain backward compatibility.

A really boost to speed in XB would result.

Share this post


Link to post
Share on other sites

CBM BASIC uses the % character to denote integer variables.  So, B% is the B-Integer variable, which takes up fewer bytes than a floating point and is quicker to use and manipulate.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, OLD CS1 said:

CBM BASIC uses the % character to denote integer variables.  So, B% is the B-Integer variable, which takes up fewer bytes than a floating point and is quicker to use and manipulate.

The game plan would be all Integers could only be two byte values 0 to >FFFF in Hex or in Decimal 0 to 65535 or -32767 to 0 to 32768

I think the last would be best as then you have negative and positive integers this would be 15 bits with a negative / positive bit.

% would be a good solution.

 

  • Like 2

Share this post


Link to post
Share on other sites

Here's something to chew on. Variables must start with an alphabetic character, or @ or _. You could use @ or _ as the first character in a variable name to indicate an integer. For example:

CALL HCHAR(@1,@1,@42,@768) When the XB interpreter sees @ as the first character in the variable name it knows that a 2 byte integer is to be used instead of the usual procedure of reading the characters, converting to FP, converting to integers, and using them.

Or CALL HCHAR(@ROW,@COL,@CH)   Of course, this must be preceded with @ROW=1::@COL=1::@CH=42 so XB knows what the values of the variables are.

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, senior_falcon said:

Here's something to chew on. Variables must start with an alphabetic character, or @ or _. You could use @ or _ as the first character in a variable name to indicate an integer. For example:

CALL HCHAR(@1,@1,@42,@768) When the XB interpreter sees @ as the first character in the variable name it knows that a 2 byte integer is to be used instead of the usual procedure of reading the characters, converting to FP, converting to integers, and using them.

Or CALL HCHAR(@ROW,@COL,@CH)   Of course, this must be preceded with @ROW=1::@COL=1::@CH=42 so XB knows what the values of the variables are.

 

 

 

 

I am forced to be backwards compatible and people have a habit of using @ and _ as variable names.

In XB you can use INT(value) but it takes time in ROM to convert from FP to Integer but this runs from INTERPETER.

Example is currently if you want a INTEGER you have to use INT(value) and be interpreted takes TIME TO RUN!

 

What I need to do it before the program is saved in Editor is put a token before that so it never needs to be converted.

W is common symbol for WHOLE numbers that is also INTEGER numbers so W is possible.

N is another common symbol for WHOLE and INTEGER numbers.

I personally favor syntax in math for WHOLE numbers {value} as an INTEGER/WHOLE number.

{ can be a flag to avoid ever needing to look at the number as a FP number so no need to convert wasting time.

I could parse the value up to the } and just go to next comma or ) in command with no penalty in speed.

 

There would be a problem in that Variables usually are in FP so have to figure a solution for this.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...