sheerun
sheerun

Reputation: 1794

Unified assembly language

I wonder if there exists some kind of universal and easy-to-code opcode (or assembly) language which provides basic set of instructions available in most of today's CPUs (not some fancy CISC, register-only computer, just common one). With possibility to "compile", micro-optimize and "interpret" on any mentioned CPUs?

I'm thinking about something like MARS MIPS simulator (rather simple and easy to read code), with possibility to make real programs. No libraries necessary (but nice thing if that possible), just to make things (libraries or UNIX-like tools) faster in uniform way.

Sorry if that's silly question, I'm new to assembler. I just don't find NASM or UNIX assembly language neither extremely cross-platform nor easy to read and code.

Upvotes: 3

Views: 888

Answers (4)

Grzegorz Wierzowiecki
Grzegorz Wierzowiecki

Reputation: 10843

LLVM IR provides quite portable assembly, backed with powerful compiler, backing many projects including Clang

Upvotes: 0

Robin Green
Robin Green

Reputation: 33033

The JVM bytecode is sort of like assembly language, but without pointer arithmetic. However, it's quite object-oriented. On the positive side, it's totally cross-platform.

You might want to look at LLVM bytecode - but bear in mind this warning: http://llvm.org/docs/FAQ.html#can-i-compile-c-or-c-code-to-platform-independent-llvm-bitcode

Upvotes: 4

Grzegorz Wierzowiecki
Grzegorz Wierzowiecki

Reputation: 10843

Related stuff, so I hope might be useful :

There is

with an approach of a kind of portable assembler.

Interesting project of operating system with graphical user interface written in assembler, and great assembly API :

Upvotes: 2

Andre Artus
Andre Artus

Reputation: 1890

First thing: writing in Assembly does not guarantee a speed increase. Using the correct algorithm for the job at hand has the greatest impact on speed. By the time you need to go down to Assembly to squeeze the last few drops out you can only really do that by adapting the algorithm to the specific architecture of the hardware in question. A generic HLA (High Level Assembler) pretty much defeats the purpose of writing your code in Assembly. Note that I am not knocking Randall Hyde’s HLA, which is a great product, I’m just saying that you don’t gain anything from writing Assembly the way a compiler generates machine code. Most C and C++ compilers have very good optimizers, and can produce machine code superior to almost any naïve implementation in ASM.

See if you can find these books (2nd hand, they are out of print) by Michael Abrash: "Zen of Assembly Language", and "Zen of Code Optimization". Or look if you can find his articles on DDJ. They will give you an insight into optimization second to none,

Upvotes: 4

Related Questions