As stated, in theory yes, but in practice it is difficult to achieve this portability.
Since you are using a large-scale embedded operating system, this makes it easier
things, but this becomes different when using less widespread systems between architectures, or even no operating system.
Being Assembly one of the lowest level languages, you have great control over the generated code, so it is not uncommon to use Assembly in-line along with C for example.
See this quote taken from http://www.nongnu.org/avr-libc/user-manual/pgmspace.html
The problem is exacerbated by the Fact that the C Language was not
Signed for Harvard Architectures, it was Designed for Von Neumann
Architectures Where code and data exist in the same address space.
This Means that any Compiler for a Harvard Architecture Processor,
like the AVR, has to use other Means to Operate with Separate address
Spaces.
Free translation:
The problem becomes evident by the fact that the C language was not
designed for Harvard architecture, it is designed for architectures
von Neumann in which code and data exist in the same address space.
This means that any compiler for Harvard architectures, such as the
AVR, need to use other means to operate with address spaces
separated.
In this case, extensions to the C standard are used to store literals in program memory, which in theory is not common in Harvard architectures.
From what I’ve read, it seems the processor architecture only matters if I
is programming in Assembly. I am wrong?
Even in Assembly it is possible to have an abstraction layer. Ex: Calling software interrupts implemented by the operating system, so that it does the abstraction.
Note: this answer does not consider the use of Linux as OS, but rather portability in a more comprehensive way.
In theory, you program into a C-defined abstract machine and it is the compiler’s job to adapt your code to run on the target architecture as if She was this abstract machine. At first you should only have to worry about this if you are using some feature not available in C, but that exists for your processor (e.g., accessing the input/output pins).
– Guilherme Bernal
If your project for Open Source would be extremely interested in participating :)
– Paulo Roberto Rosa