News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_cpcitor

JavaScript on less than 64kb of RAM

Started by cpcitor, 14:11, 18 October 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cpcitor

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.

Munchausen

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

pelrun

Quote from: Munchausen on 08:58, 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?

PulkoMandy

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?

SRS

#4
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 :)

Sykobee (Briggsy)

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.

PulkoMandy

Well, there are Forth implementations available if you look for an interpreted language. And there is BASIC and LOGO, of course.

AMSDOS

#7
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.  :)
* 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

Powered by SMFPacks Menu Editor Mod