Hi,
I don't confuse compilation with linking. In fact, I just wish it was done differently.
I probably wasn't clear enough about "X with Y" and "Y with X". In the former case, X is the caller and Y is the callee. In the latter case, Y is the caller and X is the callee. I'll try to explain that more thoroughly in the paragraphs below.
For calling high-level code from assembly code, as I said (but not explained well) a special construct could be used. Something like:
Code: Select all
(eax) = my_high_level_function(ebx, edx)
could be inserted by the programmer in the caller assembly function, which tells the compiler to compile the callee high-level function as if the first input value was in ebx, the second input value in edx, and the first return value in eax.
There is however an issue here, as someone could write multiple assembly stubs that call the high-level function in different ways and the compiler would need to generate multiple, similar yet, high-level functions where the only difference is their calling conventions. In this case, it's up to the assembly programmer to ensure a high-level function is called always the same way.
Also, you said that abstracting calls in assembly code would essentially involve a calling convention. That's true, I agree, but it's a calling convention that definitely fits the caller assembly code, and to which the callee high-level code can adapt without issues (unless it's called in different ways each time, as explained in the previous paragraph).
For calling assembly code from high-level code, as I said (but not explained well) a special construct similar to function prototypes in high-level code could be used. Something like:
Code: Select all
(eax) my_assembly_function(ebx, edx) { /* Assembly code goes here */ }
could be inserted by the programmer in the callee assembly function, which tells the compiler to compile the caller high-level function as to put the first input value in ebx, the second input value in ebx, and to expect the first return value in eax.
This also essentially involves a calling convention, although it's a calling convention that definitely fits the callee assembly code, and to which the caller high-level code can adapt without issues.
For calling assembly code from assembly code, assuming someone knows the constructs described above, it should be easy to imagine how would it work.
For calling high-level code from high-level code, provided the compiler can see the whole code in the form of an Intermediate Representation, it should be easy to imagine how would it work.
As for bugs caused by unmaintainable code, I don't really see how code that adheres to these principles would be unmaintainable.
Regards,
glauxosdever