Jump to content
IGNORED

CORTEX BASIC


Recommended Posts

13 hours ago, Reciprocating Bill said:

image.thumb.jpeg.cfb7f22a59d4c15a1a445de93088c8df.jpeg

 

According to this, the largest representable hex number is 0.FFFFFFFFFF16 x 1016+63 , which is ~7.237005610 x 1010+75

 

The actual precision claimed in another doc above is only 11 decimal digits. Considering that the hex mantissa above is 10 hex digits and that the decimal value (without considering the radix point) is 1099511627775 (which is 13 decimal digits), the possible, extra 2 digits must be swamped enough by rounding/calculation errors to disallow any better precision.

 

...lee

  • Like 2
Link to comment
Share on other sites

12 hours ago, Reciprocating Bill said:

So it's a binary format (right?)

 

Sort of. Hex, as I'm sure you know, has digits that are 4 binary digits each. However, you cannot say this is straight-up binary because the format of a floating point number has specific hex requirements:

  1. The exponent must be a power of 16. 
  2. The hex mantissa must be a hex fraction, normalized to have a nonzero first hex digit.

#2 means that there may be up to 3 leading zero bits.

 

All that said---yes, it is binary format.

 

Sorry for all the rambling.

 

...lee

 

 

  • Like 4
Link to comment
Share on other sites

Or, differently put, it's not a decimal format.

Over the years not even the numerical range of the TI 99/4A's floating point math is enough to count all the design decisions taken by TI that we've been critical about. But if there is one thing they did well, then that's accuracy in numerical calculations using real numbers.

Probably because this baby was literally born in the calculator division, and if there was something calculators like the TI-59 were exceptional about, it was numerical accuracy.

  • Like 5
Link to comment
Share on other sites

Nice and zippy!

I am finding out more about this unique flavour of BASIC.

It turns out you can use PASTE in Classic99 to enter a program. The first time I tried this it did not work, probably due to some error in my program. The editor in Cortex is a bit cumbersome, (just to make it interesting, sometimes the cursor disappears)  but since you can do your editing in a text editor and then paste it in, things get a lot easier.

SAVE "DSK2.LINES" will save the program, and at the end of the save you are asked if you want to auto start

LOAD "DSK2.LINES" loads the program and starts automatically if you have chosen that option when saving.

Supposedly you can have trouble if you SAVE to an existing file name, but I had no trouble doing that using Classic99.

Naturally, the syntax is different. The XB programmer will have trouble breaking the double colon habit for a statement separator.

10 IF X=7 THEN 30   This gave me fits until I realized it has to be 10 IF X=7 THEN GOTO 30. (but not GO TO 30)

It looks like variables are limited to 3 characters, and sometimes not even that, so you don't have the luxury of 16 character long variable names.

10 ABCD=1 is not accepted

10 ABC=1 is accepted

10 AB3=1 is not accepted

10 A3=1 is accepted

 

If you want to try it, here is the LINES listing that you can paste into Cortex.

 

10 COLOUR 15,1:GRAPH
20 X1=INT(RND*256):X2=INT(RND*256):Y1=INT(RND*191):Y2=INT(RND*192)
30 A1=INT(RND*16)-8:A2=INT(RND*16)-8::B1=INT(RND*16)-8:B2=INT(RND*16)-8
32 IF A1*A2*B1*B2=0 THEN GOTO 30
34 IF A1=A2 OR B1=B2 THEN GOTO 30
40 FOR I=1 TO 8:FOR J=2 TO 15:COLOUR J
50 PLOT X1,Y1 TO X2,Y2
60 X1=X1+A1:IF X1<0 OR X1>255 THEN A1=-A1:GOTO 60
70 X2=X2+A2:IF X2<0 OR X2>255 THEN A2=-A2:GOTO 70
80 Y1=Y1+B1:IF Y1<0 OR Y1>191 THEN B1=-B1:GOTO 80
90 Y2=Y2+B2:IF Y2<0 OR Y2>191 THEN B2=-B2:GOTO 90
100 NEXT J:NEXT I
110 FOR I=1 TO 6000:NEXT I:GOTO 10

 

 

  • Like 6
Link to comment
Share on other sites

Odd that the THEN does not allow program lines like TI Basic or XB does?

TI Basic or XB has IF argument THEN line-number

Cortex Basic has that strange format of IF argument THEN GOTO line-number

Link to comment
Share on other sites

I'm still interested in seeing the source to math functions in different BASICs for 9900s.

 

I found the math.src I was thinking of.  It's from TI's Microprocessor Pascal for the TM990/101 microcomputer.   I put it over in the Pascal 99/4A thread. 

 

The Microprocessor Pascal math library implements ARCTAN SIN COS EXP LN SQRT

 

It is based on Computer Approximations, John F. Hart, et.al., John Wiley & Sons, 1968.  

 

The functions are Taylor series expansions, with coefficients C0, C1, C2, C3 etc.  
I expect any implementation (of Taylor series) to have the same coefficients, but only as many as needed for the floating point precision.  (each additional term reduces the error.)

 

Another way to implement SIN, COS is the CORDIC algorithm.

 

The Pascal math.src would be from around 1980.

 

https://forums.atariage.com/topic/193355-pascal-on-the-994a/?do=findComment&comment=5293404

 

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, RXB said:

Odd that the THEN does not allow program lines like TI Basic or XB does?

TI Basic or XB has IF argument THEN line-number

Cortex Basic has that strange format of IF argument THEN GOTO line-number

It keeps the code for THEN simpler I suspect.  In the CORTEX scheme, THEN only has one purpose; resolving where IF has to branch to. 

There always is a GOTO in BASIC so the designer elected to let GOTO do the job it was made for in every case. 

It's a fair trade-off, but is probably something the interpreter writer believes in versus it being better or worse. 

 

 

  • Like 1
Link to comment
Share on other sites

As long as you know what syntax is expected by Cortex, then you can adapt your programming to work with it. The manual is 210 pages long, which is the reason I am figuring it out as I go along.

Like taxes and colonoscopies, reading the manual is an unpleasant task, but one that I guess I will have to do at some point.

  • Like 1
Link to comment
Share on other sites

2 hours ago, apersson850 said:

Yes. The Cortex version is at least more logical, since it does say exactly what happens.

XB has the added feature of using a CALL SUBPROGRAM(variables) so does Cortex have that feature?

 

XB has IF argument THEN subprogram-name(variables-list)

Link to comment
Share on other sites

24 minutes ago, RXB said:

XB has the added feature of using a CALL SUBPROGRAM(variables) so does Cortex have that feature?

 

XB has IF argument THEN subprogram-name(variables-list)

Each BASIC has features that the other doesn't - different BASICs for different audiences.

  • Like 1
Link to comment
Share on other sites

Cortex BASIC does not feature named subprograms with local variables. (What other BASIC of that era did?). Indeed, Extended BASIC has many rich hardware features that Cortex BASIC lacks. Which makes sense, because CBASIC did not originate on the 99/4a.

 

But what it does have should be evident here (keep in mind that this is on a 16-bit console):

 

 

 

 

Link to comment
Share on other sites

34 minutes ago, Reciprocating Bill said:

Cortex BASIC does not feature named subprograms with local variables. (What other BASIC of that era did?). Indeed, Extended BASIC has many rich hardware features that Cortex BASIC lacks. Which makes sense, because CBASIC did not originate on the 99/4a.

 

But what it does have should be evident here (keep in mind that this is on a 16-bit console):

 

 

 

 

In a sense, TI BASIC didn't originate on the TI/99/4A either. 
 

It's distinctive features like SUB, CALL match features of TI BASIC for the 990.

 

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, Reciprocating Bill said:

Cortex BASIC does not feature named subprograms with local variables. (What other BASIC of that era did?)

 

Amiga BASIC, for one:

 

Quote

Subprograms
Amiga Basic allows subprograms that have their own local variables. Using
subprograms, you can build a library of BASIC routines that can be used
with different programs. You can do this without concern about duplicating
variable names in the main program.

 

Also GFA BASIC.  But, to be fair, these are structured BASICs.

  • Like 1
Link to comment
Share on other sites

Yes, there were many different extensions to BASIC. The TI Extended BASIC has some advanced features not found in many versions. Some similarities with Fortran can be found.

 

What I was referring to was that IF condition THEN GOTO line-number more accurately depicts what's going on than IF condition THEN line-number where the GOTO is implied.

Many BASIC dialects which do allow omitting the GOTO when jumping to another line does allow including it too.

Best is of course when you always can do IF condition THEN statement, as you can in TI Extended BASIC (but not in TI BASIC).

 

It was the same with programmable calculators of the era. Some allowed to do a test followed by any instruction (like TI 57), where others implied a jump to some location if the test came out true (TI 59).

  • Like 2
Link to comment
Share on other sites

On 8/2/2023 at 1:45 AM, Asmusr said:

Unfortunately it only frees up 14K.

Isn't that out of 24k? ;) that's significant.

 

(edit: Ah, actual memory was covered back on the first page ;) )

 

Edited by Tursi
Link to comment
Share on other sites

On 8/3/2023 at 2:50 PM, Stuart said:

Each BASIC has features that the other doesn't - different BASICs for different audiences.

Do you have the source code for Cortex Basic for the 9900?

As I am working on XB ROMs being modified this might be helpful?

  • Like 4
Link to comment
Share on other sites

12 hours ago, RXB said:

Do you have the source code for Cortex Basic for the 9900?

As I am working on XB ROMs being modified this might be helpful?

I would also be very interested in that. Seeing how the cortex implementation looks like from the inside and what can be learnt from that.

In the last 2 years I’ve started collecting as much assembly language source code for the TMS9900 as I can.

 

  • Like 2
Link to comment
Share on other sites

2 hours ago, retroclouds said:

I would also be very interested in that. Seeing how the cortex implementation looks like from the inside and what can be learnt from that.

In the last 2 years I’ve started collecting as much assembly language source code for the TMS9900 as I can.

 

In the Documentation folder at www.powertrancortex.com.

  • Like 3
  • Thanks 2
Link to comment
Share on other sites

Thanks Stuart. So I presume that you OCR'ed the PDF to extract the source code, did manual adjustment where OCR failed and started from there?

Reason for asking is, because the TI version has file loading/saving support you added? Do you have any plans to release your source code branch or if there are reasons preventing you from doing that?

 

Either way, thanks for pointing to the source PDF. It's much appreciated 8)

 

 

  • Like 2
Link to comment
Share on other sites

8 hours ago, retroclouds said:

Thanks Stuart. So I presume that you OCR'ed the PDF to extract the source code, did manual adjustment where OCR failed and started from there?

Reason for asking is, because the TI version has file loading/saving support you added? Do you have any plans to release your source code branch or if there are reasons preventing you from doing that?

 

Either way, thanks for pointing to the source PDF. It's much appreciated 8)

 

 

I actually started with a hard-copy printout and a marker pen, and typed it all in by hand. I started with the initialisation code and the 'boot' code near the end of the listing to get that working on the TM990 architecture, and added in the rest bit by bit, testing it as I went (the original code makes a lot of use of the TMS9995 MID feature, which had to be changed to BLWPs for the 9900). And marking which lines I had entered in the printout along with various notes. I then added in the extra bits for the TI-99.

  • Like 7
Link to comment
Share on other sites

Posted (edited)

I have successfully made a "proof of concept" cartridge that contains both Cortex BASIC and a short graphics demo program. Cartridges made from compiled programs are similar to this in that both the interpreter and the program are contained in the same cartridge.

 

Some polishing must be done to make this more useful. As it stands now there are four 8K banks in the cartridge.  This gives enough room for an 8K BASIC program. The max in Cortex is about 14K, so with 8K available, a 4 bank cartridge will come up short. There is about 16K of code in the Cortex BASIC interperter that is moved to the 32K memory. The Dan2 compression utility can shrink that to about 12K. Doing this would free up enough memory to allow a BASIC program of just under 12K to be added to the cart, but this still falls short of the 14K maximum program size. 

By going to a 5 bank cart everything gets a lot simpler and there is no problem fitting in up to about 16K of basic program, which is longer than Cortex allows. That seems like the best approach. There would be 4 banks if the BASIC program was <8k, and 5 banks if it was larger.

Opinions?

Cortex BASIC modified v1_7.bin

CORTEXCART.GIF.ff440d593e38541e57790fa23f74f0cd.GIF

 

Edited by senior_falcon
  • Like 1
Link to comment
Share on other sites

28 minutes ago, senior_falcon said:

By going to a 5 bank cart everything gets a lot simpler and there is no problem fitting in up to about 16K of basic program, which is longer Cortex allows. That seems like the best approach. There would be 4 banks if the BASIC program was <8k, and 5 banks if it was larger.

 

Generally, for the Guidry/Fetzner-type cartridges, EPROMs double in size for the next size up. This would mean that the next size beyond a 32 KiB EPROM (4 8-KiB banks) would be a 64 KiB EPROM (8 8-KiB banks), which should handle all you are currently looking to throw at it.

 

...lee

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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...