Hello,

I have found an old email I wanted to send to the forum last year but wasn't able to send it because of the forum, so here is it:

J is fine for most operations.... But there is case where I would like to use it but I can't...

For example, I wanted to emulate a Ricoh 6502 RP2A03G 8-bit NMOS chip [used in old nintendo 8 bit system] for a good exercise to learn electronic, assembler, low level programming of video, sound, serial port, etc... This chip is running at 1.7897725 MHz. This is very slow. While trying to find some information to start this project, I found example source code in almost any language C, VB and even the old QuickBasic... Minimum specification of a 386 DX 25mhz.

I started with the sound channel emulation, the easiest thing.... I had to create 2 square wave channel, 1 triangle channel, 1 white noise channel... I did not find a way to do in J so I created a C++ DLL with DirectSound at this time which worked well.... Then, the real thing... The function to read the next op code and emulate each one.

Most people would code it like this :

DO
  READ NEXT OPCODE
  SELECT CASE OPCODE
     CASE 1:
           EMULATION FOR OPCODE 1...
     CASE 2:
           EMULATION FOR OPCODE 2...
     ....
WHILE (EOF)

It give a clear code easy to follow....

J in loop is extremely slow, but creating a DLL in C for this part is useless since it will contains the entire project.

I tryed to optimize my J code... Cut the rom file in opcode in advance with the length of each operation, But still, would have to call a function to emulate each opcode one at a time since the content of the registers are changed.

I started to read Henry Rich book "from c++ to j..." to see how to achieve a better solution...

But then I realized my J code would probably end up in a very "custom" solution to this problem....

My final reflexion concludes that J has speed limits to interpret every lines of the code until it's run on the computer... Decode, validate, convert the code..... which set speed limits. If I could decode, validate and convert (compile the code myself) before execution, I would have the ideal environment for developping and when using the compiler software it would become very fast.

So I started to write a compiler software, A C++ class for a J variable. A byte buffer array that records the data (type, shape, value) the same way J stores them with 3!:1 var. Then replaced some operator like = with basic types of variables that J support (bool, char*, int, double...) to fill the buffer... I saw a possibility there, but thousand of hours to write the whole thing...

I wanted to know :

- Is there a J solution ? What other programmer does with the same context? Another language? Extreme optimization?

- If not, is there anyone working on a compiler solution? I saw some email on the forum in oct. 2005 about this subject but no development in progress...

Simon

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to