Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for low-memory boards (STM32VLDISCOVERY) #145

Closed
gfwilliams opened this issue Dec 24, 2013 · 0 comments
Closed

Better support for low-memory boards (STM32VLDISCOVERY) #145

gfwilliams opened this issue Dec 24, 2013 · 0 comments

Comments

@gfwilliams
Copy link
Member

Currently, chips with 8kB RAM are stuck in a nasty middle-ground. Some of that 8kB (maybe 3kB) is needed for buffers and stack, but the other 5kB is available. However Espruino has 3 compilation modes:

  • 8 bit addresses: max 255 vars, each var is 16 bytes
  • 16 bit addresses: max 65535 vars, each var is 20 bytes
  • 32 bit addresses: billions of vars, each var is 28 bytes

5kB/16 = 320 vars (too many for our 255 limit), but 5kB/20 = 256. So really we're better off using 8 bit addresses and having more stack space free.

The best solution here would be to add 9 bit addresses (storing the extra bit for each of the 4 'pointers' in the variable flags). Worst case this would push the size of the flags up and make vars 17 bytes, but even so we could use 60 extra variables.

It'd be great if there could be a solution that could use 10 or 11 bits if needed too. Other devices (20kB ones) would really benefit from that.

IMO it's probably not a big deal - replace all references to firstChild/etc with preprocessor macros a bit like:

#define GET_FIRSTCHILD(var) (var->firstChild | (((var->flags)>>FIRSTCHILD_OFFSET_&1)<<8))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant