Jump to content
IGNORED

CORTEX BASIC


senior_falcon

Recommended Posts

i have been playing around with Cortex BASIC to get an idea of what it is capable of doing. Here is a video showing it running a LINES program. It appears that the Cortex interpreter is contained within expansion ram. If so, it may be possible to save a Cortex BASIC program as an EA5 program. If that is possible, then it may be possible to save a Cortex program as a cartridge. But that is a lot of ifs and only time will tell.

CORTEXLINES.GIF.a5f83dc9db3dd0dc31e7ad02ad99bf08.GIF

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

4 hours ago, Asmusr said:

Unfortunately it only frees up 14K.

Cortex BASIC includes a system command ("NEW sys(7)") that frees an additional 1K of RAM, leaving a total of 15,446 bytes free when running from FinalGROM, 6358 bytes when running entirely from RAM (very desirable vis performance when running on a console equipped with 16-bit RAM). Combining the latter with a SuperCart for 8K of fast integer storage opens up a lot of possibilities - successfully running the full BYTE sieve using an 8192 element array, for example, which can't be done in Extended BASIC even with expansion RAM. 

 

Also - Running Cortex is probably the fastest way to do floating point math on the TI - much faster than calling console routines in Forth or assembly. 

  • Like 1
Link to comment
Share on other sites

48 minutes ago, Reciprocating Bill said:

Also - Running Cortex is probably the fastest way to do floating point math on the TI - much faster than calling console routines in Forth or assembly. 

Is it using a much smaller floating point number format Bill? 

Link to comment
Share on other sites

Three times is a charm!

When I looked at it with the debugger, it looked like a normal TI format number, but of course, I wasn't paying attention to how many bytes were used. Is this Radix 100 like the TI uses, but with 6 bytes total instead of 8?

 

Edited by senior_falcon
Link to comment
Share on other sites

I actually found the 'maths' a bit surprising. If you print powers of 2 you get:

2

4

8.0000000001

16

32

64

128

256

512.00000001

1024

2048

4096.0000001

8192.0000001

16384

32768.000001

65535.999999

 

Although the errors are very small, I'm just used to the values being correct as per TI BASIC.

  • Like 1
Link to comment
Share on other sites

25 minutes ago, Stuart said:

I actually found the 'maths' a bit surprising. If you print powers of 2 you get:

 

 

Are you multiplying by constant 2, or taking 2^n?

 

2 has an exact representation: it's just exponent 1 and mantissa 1.
 

But 2^n is likely done by a power series approximation of log2. Can you show the source for ^ / pow /exp?


It may be the decimal format: if it prints  more decimal digits than the mantissa implies. It happens when the last remainder that  is partly beyond the precision. . 

 

Link to comment
Share on other sites

13 minutes ago, FarmerPotato said:

Are you multiplying by constant 2, or taking 2^n?

 

2 has an exact representation: it's just exponent 1 and mantissa 1.
 

But 2^n is likely done by a power series approximation of log2. Can you show the source for ^ / pow /exp?


It may be the decimal format: if it prints  more decimal digits than the mantissa implies. It happens when the last remainder that  is partly beyond the precision. . 

 

I was doing 2^n. Source says "Raise (R1) to the power (R2) using log and exponential functions" and I can see a hard-coded value for log2 in the source. So would TI BASIC do it the same way?

Link to comment
Share on other sites

One of the great things about BASIC on the TI99 is the numerical accuracy.

10 X=0

20 X=X+.1

30 PRINT X

40 IF X=1 THEN 60

50 GOTO 20

60 END

On the TI this stops when X=1. On the TRS80 this does not stop because X never equals 1 exactly. I think this is true for Apple 2 and the Commodores as well.

I haven't tested Cortex yet to see how it behaves.

 

  • Like 2
Link to comment
Share on other sites

25 minutes ago, senior_falcon said:

One of the great things about BASIC on the TI99 is the numerical accuracy.

...

On the TI this stops when X=1. On the TRS80 this does not stop because X never equals 1 exactly. I think this is true for Apple 2 and the Commodores as well.

 

This is the usual IEEE 754 disease. People are often surprised to hear that all the single-decimal numbers  0.1, ... 0.9 are approximations with the exception of 0.5 which is precisely representable ... and that our TI, in contrast, can encode all of them exactly.

 

While the radix 100 format is utterly slow, it allows us to encode all interesting numbers without approximation - interesting in the sense that I'd like to use them as a numerical constant in the program. I'm not interested in 0.02734375, although this can be done with IEEE, but rather in 0.1 or 3.21 or the like.

  • Like 3
Link to comment
Share on other sites

7 minutes ago, senior_falcon said:

In my post above, the program stops when X=1, just like in TI BASIC/XB.

However, if you remove line 40 so the program does not stop, by the time you get to 2, the value printed is 1.999999999

Interesting...

How did that happen?

countto2by.1.thumb.png.d28c40477b2e5a0fc3dc9755ba91a36c.png

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