How does the 8-bit BASIC perform on Famicom Clone – Subor SB2000 – FBasic – Compute PI approximation using Monte-Carlo method


Have you ever wondered how fast is a 8-bit CPU (such as 6502 used by famicom and the clones)?

Well, i can’t have a direct comparison for you for now, but for the BASIC programming language (many famicom clones do have this shipped onboard with keyboard), we can have a little experiment.

SB2000, the famicom clone (with keyboard), as described here, will be our testbed. We are going to write a small piece of code, to roughly test the performance, at least have an idea of how fast the 8-bit CPU is (on F-BASIC, floating point BASIC)

Let’s launch the FBASIC from the SB-DOS command line (or you can double click the icon on SB-WIN)

ee4897fb2d8b40270549fbbc036103a4.jpg How does the 8-bit BASIC perform on Famicom Clone - Subor SB2000 - FBasic - Compute PI approximation using Monte-Carlo method 8 bit algorithms hardware math monte carlo Monte Carlo Simulation Monte Carlo Simulation Algorithm Nintendo Entertainment System Subor vbscript

A welcome window (splash) is shown for a couple of seconds:

99fed2b87a6f67977682e886e9b66979.jpg How does the 8-bit BASIC perform on Famicom Clone - Subor SB2000 - FBasic - Compute PI approximation using Monte-Carlo method 8 bit algorithms hardware math monte carlo Monte Carlo Simulation Monte Carlo Simulation Algorithm Nintendo Entertainment System Subor vbscript

And finally we arrive at the main window of SB2000 FBASIC.

e585ebc81abb87b93e037dbf7b794f4f.jpg How does the 8-bit BASIC perform on Famicom Clone - Subor SB2000 - FBasic - Compute PI approximation using Monte-Carlo method 8 bit algorithms hardware math monte carlo Monte Carlo Simulation Monte Carlo Simulation Algorithm Nintendo Entertainment System Subor vbscript

Look, we have a dropdown menu at the above, which is considered quite advanced at that time. You can select the menu items using the mouse.

And there is an online inbuilt help system (Chinese of course)

87ed41aee5dd89dd440144cd60f6666a.jpg How does the 8-bit BASIC perform on Famicom Clone - Subor SB2000 - FBasic - Compute PI approximation using Monte-Carlo method 8 bit algorithms hardware math monte carlo Monte Carlo Simulation Monte Carlo Simulation Algorithm Nintendo Entertainment System Subor vbscript

Let’s write a small piece of code to compute the approximation of the PI constant using Monte-Carlo simulation random method.

04fb2d52da8bc285739a3974cbbe35b2.jpg How does the 8-bit BASIC perform on Famicom Clone - Subor SB2000 - FBasic - Compute PI approximation using Monte-Carlo method 8 bit algorithms hardware math monte carlo Monte Carlo Simulation Monte Carlo Simulation Algorithm Nintendo Entertainment System Subor vbscript

Well, I set the N=10000 in the first place, and I found out it took ages to run, therefore, 100 is reasonable for the time being.

The FBASIC source code is:

1
2
3
4
5
6
7
8
10 N=100
20 C=0
30 FOR I=1 TO N
40 X=RND(1000)/1000.0
50 Y=RND(1000)/1000.0
60 IF X*X+Y*Y<=1.0 THEN C=C+1
70 NEXT I
80 PRINT 4.0*C/N
10 N=100
20 C=0
30 FOR I=1 TO N
40 X=RND(1000)/1000.0
50 Y=RND(1000)/1000.0
60 IF X*X+Y*Y<=1.0 THEN C=C+1
70 NEXT I
80 PRINT 4.0*C/N

For N=100 it even took a couple of seconds! With such small iterations, you can’t really find a good approximation value for tex_af13d5f3905a7f5cfa284795beaccdb6 How does the 8-bit BASIC perform on Famicom Clone - Subor SB2000 - FBasic - Compute PI approximation using Monte-Carlo method 8 bit algorithms hardware math monte carlo Monte Carlo Simulation Monte Carlo Simulation Algorithm Nintendo Entertainment System Subor vbscript .

F-BASIC is really really slow, because of 1. it is 8-bit, 2, it is an interpreting language (not assembly).

There is even no such thing date, time available so you can’t really know how to time your program! Also, peek, poke are not available. These functions are used to read and write to memory address, which are considered the useful powerful methods (for instance, you can dump the BIOS in BASIC). Also, the play is not possible. The play will trigger the speaker to play some tones…

One last thing, the maximum length of a string in SB2000-FBASIC is 28. The interpreter will complain and throw a error message during runtime whenever a string exceeds 28 characters.

Monte Carlo Simulation Algorithms to compute the Pi based on Randomness:

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
a WordPress rating system
1021 words
Last Post: C/C++ Coding Exercise - Finding Approximation of Pi using Monto-Carlo Algorithm
Next Post: C/C++ Coding Exercise, Valid Parentheses - LeetCode Online Judge - Using Stack

The Permanent URL is: How does the 8-bit BASIC perform on Famicom Clone – Subor SB2000 – FBasic – Compute PI approximation using Monte-Carlo method

One Response

Leave a Reply