All compiler has assembler? - assemblies

Are all programming languages compiled into assembly language? And then assembly translate them to machine code? And all of structured language has a compiler involved assembler?
This is computer programming problem

Related

How to link an application written in Ada language?

I have a running a board with FreeRTOS. What do I need to do if I want to link an application written in Ada language?
Does the SDK source code of FreeRTOS need to be recompiled with GNAT?
How to realize static link and dynamic link an Ada application?
Your question reads as though you already have an application written in Ada and you want to run it on a board already running FreeRTOS; in that case, Trashgod’s link directly applies.
Ada code relies on a runtime system (RTS), which is (usually) almost entirely written in Ada. Your application will very likely have been written in full (unrestricted) Ada, using exceptions and, possibly, tasking. The GNAT folk (AdaCore) have produced one bare-board RTS that supports exceptions, but only the Ravenscar (and now Jorvik) tasking subset.
FreeRTOS itself shouldn’t need recompiling. If your other code is written in C++, it should be OK if your compiler is GCC.
FreeRTOS doesn’t support dynamic linking.

Language with extensive support for self-modifying code?

Which programming languages provide the best support for self-modifying code?
In particular, since the program will need to make extensive use of self-modifying code, I am looking forward at the ability to remove from memory some parts of code, after they are no longer needed, thus freeing that memory. Also, it would be a plus if there was the ability to identify and index the routines (procedures, functions, etc) with some sort of serial number, so that they could be easily managed in the memory (deleted, cloned etc) at runtime.
Operating systems need to have some more-or-less "self-modifying code" in order to load programs and dynamic link libraries from storage into RAM and later free up that RAM for other things, do relocation fix-ups, etc.
My understanding is that currently the C programming language is by far the most popular language for writing an operating systems.
The OSDev.org wiki has many tips of writing a new custom operating system, including a brief discussion of languages suitable for writing an operating system -- C, Assembly language, Lisp, Forth, C++, C#, PL/1, etc.
Just-in-time (JIT) compilers also need to have some more-or-less "self-modifying code" to compile source text into native instructions and run them, then later free up that memory for the next hot-spot.
Perhaps you could find some OS project or JIT project and use their code with relatively little modification.
A few people, when they say they want "self-modifying code", really want a language that supports homoiconicity such Scheme or some other dialect of Lisp, Prolog, TCL, Curl, etc.

Can C/C++ software be compiled into bytecode for later execution? (Architecture independent unix software.)

I would want to compile existing software into presentation that can later be run on different architectures (and OS).
For that I need a (byte)code that can be easily run/emulated on another arch/OS (LLVM IR? Some RISC assemby?)
Some random ideas:
Compiling into JVM bytecode and running with java. Too restricting? C-compilers available?
MS CIL. C-Compilers available?
LLVM? Can Intermediate representation be run later?
Compiling into RISC arch such as MMIX. What about system calls?
Then there is the system call mapping thing, but e.g. BSD have system call translation layers.
Are there any already working systems that compile C/C++ into something that can later be run with an interpreter on another architecture?
Edit
Could I compile existing unix software into not-so-lowlevel binary, which could be "emulated" more easily than running full x86 emulator? Something more like JVM than XEN HVM.
There are several C to JVM compilers listed on Wikipedia's JVM page. I've never tried any of them, but they sound like an interesting exercise to build.
Because of its close association with the Java language, the JVM performs the strict runtime checks mandated by the Java specification. That requires C to bytecode compilers to provide their own "lax machine abstraction", for instance producing compiled code that uses a Java array to represent main memory (so pointers can be compiled to integers), and linking the C library to a centralized Java class that emulates system calls. Most or all of the compilers listed below use a similar approach.
C compiled to LLVM bit code is not platform independent. Have a look at Google portable native client, they are trying to address that.
Adobe has alchemy which will let you compile C to flash.
There are C to Java or even JavaScript compilers. However, due to differences in memory management, they aren't very usable.
Web Assembly is trying to address that now by creating a standard bytecode format for the web, but unlike the JVM bytecode, Web Assembly is more low level, working at the abstraction level of C/C++, and not Java, so it's more like what's typically called an "assembly language", which is what C/C++ code is normally compiled to.
LLVM is not a good solution for this problem. As beautiful as LLVM IR is, it is by no means machine independent, nor was it intended to be. It is very easy, and indeed necessary in some languages, to generate target dependent LLVM IR: sizeof(void*), for example, will be 4 or 8 or whatever when compiled into IR.
LLVM also does nothing to provide OS independence.
One interesting possibility might be QEMU. You could compile a program for a particular architecture and then use QEMU user space emulation to run it on different architectures. Unfortunately, this might solve the target machine problem, but doesn't solve the OS problem: QEMU Linux user mode emulation only works on Linux systems.
JVM is probably your best bet for both target and OS independence if you want to distribute binaries.
As Ankur mentions, C++/CLI may be a solution. You can use Mono to run it on Linux, as long as it has no native bits. But unless you already have a code base you are trying to port at minimal cost, maybe using it would be counter productive. If it makes sense in your situation, you should go with Java or C#.
Most people who go with C++ do it for performance reasons, but unless you play with very low level stuff, you'll be done coding earlier in a higher level language. This in turn gives you the time to optimize so that by the time you would have been done in C++, you'll have an even faster version in whatever higher level language you choose to use.
The real problem is that C and C++ are not architecture independent languages. You can write things that are reasonably portable in them, but the compiler also hardcodes aspects of the machine via your code. Think about, for example, sizeof(long). Also, as Richard mentions, there's no OS independence. So unless the libraries you use happen to have the same conventions and exist on multiple platforms then it you wouldn't be able to run the application.
Your best bet would be to write your code in a more portable language, or provide binaries for the platforms you care about.

Mix ada with assembly

How I can mix Ada code with assembly (assembled using GAS)?
I know how to link Ada with C, but how I can link with assembly? I know that gcc generates assembly code from Ada code, and because of this, I think is possible to do this cross-linking.
Presumably you would compile the assembly into a .o object file and give this as a parameter to your Ada compiler.
how can I work with the two codes?
If you are using GNAT on Intel x86, the Inline Assembler includes related examples.
Addendum: The -S option allows one "to examine the generated assembly code." This applies to Ada, C, C++, etc.
If you want to perform any kind of mixed-language programming with Ada, including Ada/Assember, you should probably look at your compiler's documentation on Interfacing pragmas, in particular its allowed calling conventions.
For example, Gnat provides an Assembler convention for pragma import/export.
Generally you will have to craft your assembler to act as a subprogram which uses a calling convention compatible with the "convention" used in your interfacing pragma.
Most compilers also support some kind of inline assembly, via the System.Machine_Code package. This allows you to mix small amounts of assembly language right in the same source files with your Ada.

Can system programming be done in JAVA?

Unix System programming to be precise.
Consider using C language, which was originally defined as a language for system software on Unix platforms.

Resources