1

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 pick
  • how to chose an architecture

Things I considered:

  • GNU Assembler
  • Knuth's MMIX

The 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?

closed as off-topic by gnat, user40980, Thomas Owens Jan 20 '15 at 12:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – Thomas Owens
If this question can be reworded to fit the rules in the help center, please edit the question.

2

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.

  • I see. I still think assembly will turn out to be a vert difficult way to implement this, but I'm starting to see why you're tempted in this direction. 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. – Jules Jan 20 '15 at 9:36
  • 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. – Jules Jan 20 '15 at 9:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.