Author Topic: JavaScript on less than 64kb of RAM  (Read 1218 times)

0 Members and 1 Guest are viewing this topic.

Offline cpcitor

  • The user previously known as FindYWay
  • 464 Plus
  • *****
  • Posts: 321
  • Country: fr
  • My heart still runs on traditional CPC.
    • My code for the CPC.
  • Liked: 163
  • Likes Given: 418
Had a CPC since 1985, currently software dev professional, including embedded systems.

I made in 2013 the first CPC cross-dev environment that auto-installs C compiler and tools: cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC, later forked into CPCTelera.

Offline Munchausen

  • 6128 Plus
  • ******
  • Posts: 777
  • Country: gb
  • Liked: 213
  • Likes Given: 216
Re: JavaScript on less than 64kb of RAM
« Reply #1 on: 10:58, 19 October 16 »
While this is kind of cool, surely there are more suitable interpreted languages for something like a CPC?

Unfortunately, I think the 64K RAM requirement is misleading when comparing to a Z80. ARM MCUs normally have separate code and data storage (Harvard architecture ish), while the CPC code and data both have to be stored in RAM. The binary (code) size is 160K for their javascript interpreter. I don't know how ARM thumb2 instruction sizes/density compare to z80, but this is also going to create a huge challenge because the CPC will need 64K for data and then space for code as well, and have to do bank switching on it all.
« Last Edit: 11:12, 19 October 16 by Munchausen »

Offline pelrun

  • Supporter
  • 6128 Plus
  • *
  • Posts: 717
  • Country: au
    • index.php?action=treasury
  • Liked: 385
  • Likes Given: 253
Re: JavaScript on less than 64kb of RAM
« Reply #2 on: 13:38, 19 October 16 »
ARM MCUs normally have separate code and data storage (Harvard architecture ish)


What? The harvard architecture on ARM only applies to the caches - the address space is still unified. Are you confusing it with 8-bit AVR, which needs special instructions to read data from code memory?

Offline PulkoMandy

  • 464 Plus
  • *****
  • Posts: 423
  • Country: fr
  • Liked: 342
  • Likes Given: 3
Re: JavaScript on less than 64kb of RAM
« Reply #3 on: 14:27, 19 October 16 »
It's not because of the Harvard architecture, but in microcontrollers world, 64KB of RAM means just that: the RAM. All the code will be in ROM and is probably much larger.


Note that it would be possible to do the same on CPC: we also have ROMs. But, it will require to play with memory banks, not necessarily easy with the way they are managed on CPC (but very well possible).


z80 code would be more compact, unless you have to do 32bit math and other stuff the ARM is better at.


And finally, there is the concern of CPU speed. Can you make it as fast as the BASIC?

Offline SRS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 634
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 634
  • Likes Given: 368
Re: JavaScript on less than 64kb of RAM
« Reply #4 on: 15:22, 19 October 16 »
Hmm, after investing a lot of time and brain to help bringing JAVA to the CPC (which is still not yet complete) I do not think I'll need JavaScript, too.

But hey, if you like, give it a try. The experience gained during trying to compile it with sdcc or so may help in future projects. And everybody feel free to
bring JAVA into better shape for CPC :)
« Last Edit: 15:25, 19 October 16 by SRS »

Offline Sykobee (Briggsy)

  • 6128 Plus
  • ******
  • Posts: 821
  • Country: gb
  • Liked: 313
  • Likes Given: 480
Re: JavaScript on less than 64kb of RAM
« Reply #5 on: 18:10, 19 October 16 »
I suspect a CPC dedicated LISP variant would be easier. Something like Clojure but with CPC hardware specific libraries beyond the core datatypes and functions.

Offline PulkoMandy

  • 464 Plus
  • *****
  • Posts: 423
  • Country: fr
  • Liked: 342
  • Likes Given: 3
Re: JavaScript on less than 64kb of RAM
« Reply #6 on: 10:11, 20 October 16 »
Well, there are Forth implementations available if you look for an interpreted language. And there is BASIC and LOGO, of course.

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1157
  • Likes Given: 1924
Re: JavaScript on less than 64kb of RAM
« Reply #7 on: 12:08, 20 October 16 »
The novelty of writing programs on an Amstrad is nice in terms of seeing it all happen on a CPC. But a language like JavaScript maybe doable as a Cross Compiler because you then need to get the program in there.


My Pascal game ended up taking 16Kb (not bad given 7K of it is Library), I had one main file declaring all the variables and then loading in all the different parts for of that game. Each of those files was tokenised, similar to how BASIC tokenises it's BASIC files. According to the Pascal manual, it would allow 19Kb, though towards the end of me programming that game, the compiler was getting so far and reporting I had No Table Space (and cease compilation). Fortunately I was able to allocate more Table Space to get the thing to compile, I'm still not totally sure how it this works, though Devpac also works in the same fashion.


But anything's possible on a CPC. Writing a JavaScript based language to operate from the second 64k block and having the program code reside there leaving the main 64k available for the code would be great.  :)
« Last Edit: 23:34, 21 October 16 by AMSDOS »
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3