Optimizing Lua for embedded processor? [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am embedding Lua in a programm for no-eabi device with 16Mhz 32-bit ARM7TDMI processor and 256Kb RAM (yes, that's GBA). Currently it's working flawlessly (thank you, StackOveflow users, for answering my questions), doing easy tasks, but what optimizations I can do to perform overall efficiency? Here's some of my thoughts:
Currently I am storing my Lua code as constant char array (there's separate ROM up to 32Mb, so it helps to free RAM). When I want to run it I just push this string to Lua stack and "pcall" it. But as I know, Lua builds that code into byte-code in RAM. I thoght that can be some problems with big Lua files too. Any way-to precompile that byte-code and save it to constant container too?
Which asm command set is better for running Lua - THUMB or ARM?
EDIT: Maybe, changing vanilla Lua to LuaJIT? As I know, LuaJIT has many assembly lines of code (which makes it less portable), any chance to perform successful build to old ARM7 processors?

Related

How to create a multistage bootloader with asm and c? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to create a simple 32-bit text-based operating system.
Bootloader :
Firstly I want to create a multistage bootloader.
Stage 1 : Assembly code (NASM-Compiler)
Stage 2 : C (GCC-Compiler)
Kernel:
Then it should load Kernel which should be written in C (GCC-Compiler)
I would also like to know how to properly compile and execute it.
Emulator should be Qemu
A sample 32-bit Operating System that displays "Hello world" would be helpful.
Don't write your own bootloader. Configure and use an existing bootloader, probably GRUB. This would make using your toy OS much easier (both for you and for other users).
Read http://osdev.org/ since they have a lot of resources about OS building on PCs (including a hello world OS).
Read also some good operating system book (e.g. Operating Systems: Three Easy Pieces). You'll find out that there cannot be very simple OSes. See also this answer.
Also, be at least quite fluent with POSIX and with Linux system programming (read Advanced Linux Programming at first).

Compiler for custom cpu architecture [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Is there a tool that will convert C to assembly that will run on Windows?
The cpu architecture (8 bit and 16 bit) is in-house meaning that it has it own instruction set.
The C compiler should use our in-house assembly language. The language is not based on x86 nor ARM. I can not provide too many further details because it is company's Intellectual Property.
You will have to learn one of the open source Compilers which are using replaceable backend for their code generation. Gcc, and CLang, might be a good starting point.
Yes, Virginia, there are "tools to convert C to assembly" on Windows. GCC comes to mind; likewise MS Visual Studio.
I'm sure this isn't what you want, since the off-the-shelf versions for Windows tend to generate x86 object code. It sounds like you want a compiler for a special not-x86 instruction set.
Given that you have not provided any details, there's no way for anybody to respond if such a compiler already exists.
In the absence of such detail, all one can do is offer you generic advice. It is possible to configure GCC to generate code for relatively arbitrary instruction sets. It isn't a walk in the park to do this, but it has been done for many different instruction sets.

arm or mips core to implement in fpga [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am trying to implement a risc processor core in fpga. Is it a good idea to do such a project. I am confused whether to implement an arm core or mips core. Please tell me which would be a better option consider that i am a starter in this field.
Yes such a project would be pretty cool and you would learn a lot. That being said I believe you should build smaller things first. As for ARM vs. MIPS, the complexity is equivalent, but I would pick ARM cause it's actually the most popular processor architecture in the world right now, so the knowledge you would gain would be highly practical.
I recommend starting with a book called "CODE". It will teach you all the basics in a very clear way. Once you read that you should be able to build logic gates, full adders and even a simple generic purpose computer, all using nothing but relays and wires.
Once you've done those smaller projects then try something larger with transistors, protoboards or FGPA. One very interesting computer you could build is the IAS, also called the Von Neumann machine, which is the base for all modern computers (yet is very simple and elegant).

Crenshaw's "Let's Build a Compiler": Transcription to C and x86 Assembler? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to work through Jack Crenshaw's excellent compiler programming tutorial "Let's Build a Compiler" and have bumped into two hurdles. First the code is written in Pascal, a great language for which I have both respect and fondness from a brief exposure to it in the mid 1980s, but which I have not touched since. I currently program mostly in C.
The other hurdle is that the generated assembler is for the Motorola 68000 line of processors. While I may be able to find a translator for it, it would be preferable if I could generate Intel x86 assembler (either Intel or AT&T style).
I can work through the code on Linux, Mac OsX or Windows 7, if it makes anything easier. I have access to all of the named operating systems.
I do not feel fully qualified to do the transcription myself. Has anybody worked this out already, or do you have other suggestions?
Any ideas, feedback or suggestions welcome.
You could run the generated code on a 68K emulator—several of the entries on that page are open-source.
It might be easier to target the JVM instead of a native processor. as for translating Pascal to C... it'shouldn't be that much of a hurdle really.

Would an ARM Processor be the way to go? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was making a little device that would have three buttons (like the ones at radioshack) and each preform its own action. These buttons and their actions would be controlled by a very small real time operating system that I would put on this device.
Would I need an ARM Processor in any way?
How would I put the real time operating system on the device?
What OS would I have to compile this on (ex. Ubuntu? Mac OS X? Windows 7?)?
Are there any examples of anyone doing this?
P.S. No prebuilt boards (ex. arduino). I would build the board myself.
Any feedback would be greatly appreciated!
Even if you don't want to use a prebuilt board in the finished product, I'd recommend getting a prebuilt board (like the Arduino), build your product, program it, test it, etc. while on the breadboard, and then simply rebuild it however you want, using the same hardware as you've been using.
That helps you out especially the next time you're building something, because you already have the prototype board and the toolchain ready to go.
Compiling your files can be done on any OS.
Enumerated version:
No, and I wouldn't even recommend using an ARM processor; but rather an Atmega328 or similar.
Using a programmer.
Any.
Probably millions, or at least hundreds of thousands of examples, yes.

Resources