I am aware of this question, and I think I know why it has been closed. I hope that my question manages to be more specific.My skill level: I have a Computer Science degree. I have programmed in many languages. Back in the day I programmed in C on an embedded microcontroller (TI MSP430), and in Python and Prolog. I have absolutely no experience in programming in assembly language, although I think I understand the concept. I had to embed assembly for my microcontroller work, but this was on the level of initializing some of the attached hardware; nothing that even involved implementing an algorithm.I am aware of the fact that Knuth's The Art of Computer Programming shows all algorithms in assembly. Going through this book is a huge investment and I'd do it if someone recommends it.I realize this question is very general, but since I have absolutely no prior experience, I find it really difficult to put it into any context.My problem:I have to implement a simulator for a project that is part of my thesis work. I tried doing it in two different high-level languages: Python and Prolog. I could not model the things I am simulating (autonomous, very simple units without any complex logic, but too many of them) without incurring too much overhead. I even considered using Erlang and Erlang processes, but the messaging between them is definitely a bad way to model how the things interact with each other.I did consider using C or C++. The simulation involves changing the behaviour of the things I am modeling, and doing this in C or C++ would mean actually implementing a virtual machine (the simulator) that allows me to do this. It seems that assembler will make it slightly easier. I have to admit that the architecture I have written (very limited) assembly on had a flat address space, which is why I thought that would be an option.It feels as if Assembly language might be the way forward. However, I am at a loss at:which assembly language to pickhow to chose an architectureThings I considered:GNU AssemblerKnuth's MMIXThe questions:Can I actually use any of the two for a (more or less) efficient implementation on an already existing architecture?Does this sound like a completely misguided attempt?
Implementing a VM for simulation
assembly;simulation
MMIX isn't the solution you're looking for. It's primary purposes is to enable standardised implementations of algorithms and data structures so that they can be compared with each other in terms of efficiency. It is not intended to run on real hardware, and run-time efficiency was never its goal.I also don't recommend using the GNU assembler, at least not if you are targeting an 80x86 processor. It uses a syntax that is somewhat different to the syntax Intel use to describe their processors, and it is the latter syntax that most educational resources for assembly programming are aimed at. NASM is I believe the most commonly used assembler for hand-coded intel assembly, and I would recommend it because of this (even if I hadn't been involved in writing it!).That said, however, I'm not sure assembly language is the best approach to your problem. (update after question edited: I originally suggested C/C++ here)It may be that Java is actually your best bet - it has a handful of libraries available (asm.jar, BCEL, javassist) that are intended to make dynamic generation of java code at run time easy. You would program the dynamic parts of your system in Java bytecode, which is conceptually similar to assembly language, but much simpler, and this would then be converted to native machine code by the JVM. I think this is probably the best balance between simplicity and efficiency available. If it isn't efficient enough, LLVM can be used to achieve similar results in C++, but is harder to use.