HP Forums
Really really fast BASIC handheld - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not quite HP Calculators - but related (/forum-8.html)
+--- Thread: Really really fast BASIC handheld (/thread-12144.html)

Pages: 1 2 3


Really really fast BASIC handheld - berndpr - 01-09-2019 04:03 PM

Hallo,

I tried something from which I have never expacted to be much much faster as the HP Prime.

And it's using interpreted BASIC on a small handheld:

Tada: The New Nintendo 2DS XL (release 2017) with SmileBasic (you can get this like games from the Nintendo Store).

It's fast!
Very Fast!

Example:
The Summation Benchmark:
CLS
M=MAINCNT 'Frames since start of Basic with 60 per second
A=0
FOR X=1 TO 100000
A=A+POW(EXP(SIN(ATAN(RAD(X)))),1/3)
' pow is used because 3. Root doesn't exist
' RAD is used to change degree to radian because all trig function use radian
NEXT
PRINT A
PRINT ROUND(10/6*(MAINCNT-M))/100; " sec" 'rounded of 2 decimal digits

The result:
0.55 secunds, Result 139536.56649434
compare this with the other handhelds like:

max = 100000
~ 7.7s - HW-Prime G2 , sum function http://www.hpmuseum.org/forum/thread-975...#pid102818
~ 9s - TI Nspire CX CAS, hardware version N-0118AB (2018), OS 4.5.0.1180 (2017):
C with Ndless. Post #147
...

This is 14 times faster then the fastest calculator the HP Prime!

And with max=1000000 (1 million) you get:
5.53 seconds with 1395587.74219818
And the precision of the calculation is not bad.

It's an interpreted program language, which support all feature of the 3DS (like backgrund music, 2 color display with 3d, sprites, aninimation, WIFI, gyroscope, mic, touch screen controls etc.) and all important mathematical functions you need for science.

And the RAM for the BASIC is big: more than 8 Megabyte.

I have programmed the ULAM spiral (https://en.wikipedia.org/wiki/Ulam_spiral) with changing the starting center and 240 by 240 numbers. The calculation of the first 110000 numbers if they are primes don't need not more than 1 second. And the print of the spiral is done several time per second.

If you knew any handheld (NOT PC) with a buildin language and editor let me know please!

(No, IDE on an external PC is something like cheating for me. I think that's reason to use a handheld or I can use a PC directly).

I hope this will show an alternative way to use existing devices!

Bye
Bernd


RE: Really really fast BASIC handheld - Dan - 01-10-2019 01:10 AM

I was about to ask if you can do plots on it, but after reading again I see you already have. Do you know what processor it uses?


RE: Really really fast BASIC handheld - ijabbott - 01-10-2019 08:16 AM

(01-09-2019 04:03 PM)berndpr Wrote:  A=A+POW(EXP(SIN(ATAN(RAD(X)))),1/3)
' pow is used because 3. Root doesn't exist
' RAD is used to change degree to radian because all trig function use radian

You shouldn't need to use RAD(X). X isn't an angle, so converting it from degrees to radians doesn't make sense.


RE: Really really fast BASIC handheld - berndpr - 01-10-2019 08:31 AM

(01-10-2019 01:10 AM)Dan Wrote:  I was about to ask if you can do plots on it, but after reading again I see you already have. Do you know what processor it uses?

But you must write a little program to plot your function.

As far as I know a quad core ARM (from german wikipedia).

I have made a Mandelbrot program like in numworks (https://workshop.numworks.com/python/numworks/mandelbrot) and compared it with the benchmark test of numworks and HP prime at youtube.
3DS needs 5 seconds with 20 iteration,
numworks and prime needs minutes with 10 iteration.

I think I have found my portable number cruncher for the next year.

Bernd


RE: Really really fast BASIC handheld - berndpr - 01-10-2019 08:37 AM

(01-10-2019 08:16 AM)ijabbott Wrote:  
(01-09-2019 04:03 PM)berndpr Wrote:  A=A+POW(EXP(SIN(ATAN(RAD(X)))),1/3)
' pow is used because 3. Root doesn't exist
' RAD is used to change degree to radian because all trig function use radian

You shouldn't need to use RAD(X). X isn't an angle, so converting it from degrees to radians doesn't make sense.

Yes, I know. But as far as I understand the benchmark is using degree as input for the sin function. For comparing the results I thought I use the same input, even this is mathematical not necessary.

Bernd


RE: Really really fast BASIC handheld - ijabbott - 01-10-2019 08:54 AM

(01-10-2019 08:37 AM)berndpr Wrote:  
(01-10-2019 08:16 AM)ijabbott Wrote:  You shouldn't need to use RAD(X). X isn't an angle, so converting it from degrees to radians doesn't make sense.

Yes, I know. But as far as I understand the benchmark is using degree as input for the sin function. For comparing the results I thought I use the same input, even this is mathematical not necessary.

Bernd

But X isn't in degrees or radians. It is the tangent of an angle. SIN(ATAN(X)) is the sine of the same angle and should give the same result (subject to minor rounding errors) on a calculator set to degrees or radians. By replacing X with RAD(X) you are passing the wrong values to the SIN(ATAN(x)) function.

I'm not sure if the benchmark specifies degrees or radians mode to be used. There might be a slight difference in speed between the two for a particular machine, but the final resulting value should be more or less the same (subject to accumulated rounding errors).


RE: Really really fast BASIC handheld - berndpr - 01-11-2019 06:27 AM

(01-10-2019 08:54 AM)ijabbott Wrote:  
(01-10-2019 08:37 AM)berndpr Wrote:  Yes, I know. But as far as I understand the benchmark is using degree as input for the sin function. For comparing the results I thought I use the same input, even this is mathematical not necessary.

Bernd

But X isn't in degrees or radians. It is the tangent of an angle. SIN(ATAN(X)) is the sine of the same angle and should give the same result (subject to minor rounding errors) on a calculator set to degrees or radians. By replacing X with RAD(X) you are passing the wrong values to the SIN(ATAN(x)) function.

I'm not sure if the benchmark specifies degrees or radians mode to be used. There might be a slight difference in speed between the two for a particular machine, but the final resulting value should be more or less the same (subject to accumulated rounding errors).

OK, you are right.

I have delete the RAD function:
I got this results for 100000:
Time 0.53 and 139560.97614105.
So it's faster and the result is different.

I hope this satisfy you now.

Bernd


RE: Really really fast BASIC handheld - Dan - 01-11-2019 06:40 AM

(01-10-2019 08:31 AM)berndpr Wrote:  As far as I know a quad core ARM (from german wikipedia).

I think I have found my portable number cruncher for the next year.

Bernd

I haven't been following the HP Prime, but I would guess the quad core processor is the reason why - the mathematical algorithms are probably similar.

Sounds like a cool device, have fun!


RE: Really really fast BASIC handheld - berndpr - 01-11-2019 07:11 AM

Hallo!

I have tried the N-Queen Benchmarks.

The unstructured BASIC version with labels, because SmileBasic has no line numbers.
With OPTION DEFINT and a outer loop of 1000 I got this this time:
11.97 seconds, so less than 12 msecs for one run.
No bad for an interpreted language.

And I tried the structured version in BASIC with same conditions:
OPTION DEFINT and outer loop of 1000
12.52 sec, so 12.5 msec for one run.

Funny, the goto version is faster than the version with repeat, while and for.

And I have tried the Savage Benchmarks.

I have found 2 versions in this forum (why using 2 definitions?):
FOR I = 1 TO 2499
A=TAN(ATAN(EXP(LOG(SQR(POW(A+1,2))))))
NEXT
Time with a outer loop of 1000: 14.75 sec, so 14.75 msec per run.

2. Version:
FOR I = 1 TO 2499
A=TAN(ATAN(EXP(LOG(SQR(A*A)))))+1
NEXT
Time with a outer loop of 1000: 13.42 sec, so 13.42 msec per run.

The result of A is 2500 in both cases. And I have tried to find the error with
2500-A. But it shows than 0.

I have found the first quirk of this BASIC. It show the floating point number with zeros and not a EE or so. If you calculate 69! the answer is several lines along with the many trailing zeros. Strange!

But the precision inside is good. I have calculate PI or e with several thousand digits. And there is no problem as far as I know.

I using the 3DS for fast grafic output, so the big or very small number output is not a problem.

If you are interested in the codes, I can post it here.

Bernd


RE: Really really fast BASIC handheld - ijabbott - 01-11-2019 10:34 AM

(01-11-2019 06:27 AM)berndpr Wrote:  I have delete the RAD function:
I got this results for 100000:
Time 0.53 and 139560.97614105.
So it's faster and the result is different.

Faster and more accurate! Smile


RE: Really really fast BASIC handheld - Maximilian Hohmann - 01-11-2019 12:05 PM

Hello!

Interesting. I guess that BASIC interpreter was developed to encourage the (mostly yonug I suppose) users of these Nintendo toys to make their own games - just as in the old days of the C64.

Is it possible to connect a keyboard of some kind, via Bloetooth maybe, to the device? Because if it is anything like the Nintendos our son used to play with when he was younger, then one would need to "type" in the programs using a ridiculously small stylus on a very low resolution even more ridiculously small touch display... All the precious lifetime gained by the fast program execution speed will be lost by fiddling around whilst entering the commands!

Regards
May


RE: Really really fast BASIC handheld - xerxes - 01-11-2019 01:34 PM

(01-11-2019 07:11 AM)berndpr Wrote:  The unstructured BASIC version with labels, because SmileBasic has no line numbers.
With OPTION DEFINT and a outer loop of 1000 I got this this time:
11.97 seconds, so less than 12 msecs for one run.
No bad for an interpreted language.

Thank you for testing SmileBasic, that turns the Nintendo into a very powerful pocket computer like device.
Thats pretty fast for a bytecode interpreter. The german wiki mentions a CPU clock switch in the home menue,
but I guess it's running at 804 MHz already.

(01-11-2019 07:11 AM)berndpr Wrote:  And I tried the structured version in BASIC with same conditions:
OPTION DEFINT and outer loop of 1000
12.52 sec, so 12.5 msec for one run.

Funny, the goto version is faster than the version with repeat, while and for.

I've made the same observation on many languages.

(01-11-2019 07:11 AM)berndpr Wrote:  If you are interested in the codes, I can post it here.

Yes please. I guess you have tested ver.3.6.0?


RE: Really really fast BASIC handheld - Dave Britten - 01-11-2019 04:20 PM

I'd be curious to know if Smilebasic runs the CPU at 804 MHz on the New 3DS/2DS. If not, then it's possible to use custom firmware to force the CPU up to 804 MHz from the default 264 MHz, as well as enable the L2 cache that was added to the "New" models. It makes a noticeable difference in some games; Code of Princess gets a massive frame rate boost. (They also went from 2 cores to 4 cores, I believe, but depending on how many threads Smilebasic runs, that might not make any difference.)


RE: Really really fast BASIC handheld - smp - 01-11-2019 04:21 PM

(01-09-2019 04:03 PM)berndpr Wrote:  <...snip...>

The New Nintendo 2DS XL (release 2017) with SmileBasic (you can get this like games from the Nintendo Store).

It's fast!
Very Fast!

<...snip...>

Hi Bernd,

I looked up that machine and I see a handheld gaming device. Can you post a picture of what it looks like when running SmileBasic? Does the screen turn into a keyboard? How do you enter your program?

Thanks!

smp


RE: Really really fast BASIC handheld - hp41cx - 01-11-2019 10:48 PM

smilebasic Nintendo DS


RE: Really really fast BASIC handheld - Stevetuc - 01-12-2019 08:03 AM

(01-09-2019 04:03 PM)berndpr Wrote:  Hallo,

I tried something from which I have never expacted to be much much faster as the HP Prime.

And it's using interpreted BASIC on a small handheld:

Tada: The New Nintendo 2DS XL (release 2017) with SmileBasic (you can get this like games from the Nintendo Store).

It's fast!
Very Fast!
[....]
This is 14 times faster then the fastest calculator the HP Prime!



Bye
Bernd

And if you want really fast:

There's already a C library for writing user mode arm11 code for the 3DS/2DS
https://github.com/smealum/ctrulib

3DS homebrew coming soon?
https://twitter.com/smealum/status/523002877514493952


RE: Really really fast BASIC handheld - StephenG1CMZ - 01-12-2019 10:21 AM

I thought Smilebasic was built-in, like on old DOS PCs.

But this website says "how to purchase" http://smilebasic.com/en/

From a very quick read, it seems it can be purchased and downloaded straight onto Nintendo - no idea if Nintendo require a credit card or whether a gift card can be used.
(Update- A more thorough perusal of the eShop gives no clues as to whether kids, or those cautious about credit card numbers, can buy it... But, UK supermarkets do sell Nintendo gift cards).

The instruction manual says to start SmileBasic by select Start Basic from a menu - I didn't see any mention of buying a game cartridge, either for basic or your programs. But I did glimpse a worrying mention of 4 slots - does that mean you can only have 3 programs? (One of the 4 slots is used for animation).

The spec for a DS in the shop makes no mention of it being able to compile or run Basic...just think how many sales they might have lost.


RE: Really really fast BASIC handheld - pier4r - 01-12-2019 02:41 PM

nice find! question: could you send / save programs to and from the pc?

Because for me having an external repository that survives is a must have Smile .


Furthermore I believe the extended math library of high end calculators is missing. Rebuilding it should be no joke. Unless smile basic is like the basic of the hp 71b, glorious.


RE: Really really fast BASIC handheld - mfleming - 01-12-2019 04:56 PM

Skimming through the online manual for more information, a "slot" seems to correspond to a project, which can hold multiple text and data files. Basic programs are saved as text files. It would seem you are not limited to just four programs.

A slot or project can be saved to or loaded from an SD card, so you can transfer to or from a PC. They specify the Unicode character set used by Basic and provide a downloadable font set, so I assume a suitable editor could work with a Basic program file.

Hummm, 3D Free42 anyone? Smile
~Mark


RE: Really really fast BASIC handheld - StephenG1CMZ - 01-12-2019 09:41 PM

Actually, on one of the sites it was suggested that the SD cards are encrypted... Someone even wrote a cassette modem type program to transfer files as audio as a workaround. So editing on a PC might not be straightforward.
https://smilebasicsource.com/forum?ftid=7.