genodelabs / goa

Tool for streamlining the development of Genode applications
GNU Affero General Public License v3.0
19 stars 18 forks source link

examples: add hello world NASM example #88

Open mewmew opened 2 months ago

jschlatow commented 2 months ago

@mewmew Can you provide a bit of context? I'm wondering what your use case is which requires writing assembly components with Goa.

mewmew commented 2 months ago

@mewmew Can you provide a bit of context? I'm wondering what your use case is which requires writing assembly components with Goa.

Hi Johannes!

Absolutely.

I use the examples of Goa to explore and investigate the interactions between user-land components in Genode and the session interfaces, compatibility layers (e.g. POSIX), and other aspects of the Genode framework.

The hello_make example in C++ is great for showcasing how a Genode component should look like and interact with it's environment.

The hello_posix example in C illustrates how to make use of POSIX compatibility layers and also illustrates how one can execute code on Genode where the entry point cannot be written as a C++ Component class.

The hello_rust example in Rust provides insight into how other languages than C/C++ can be integrated into the Genode userland, what linking is required to have those executables be able to run on Genode (e.g. the libutil Rust compatibility library for Genode).

Personally, I understand concepts and interactions the best when I can go down to the low-level constructs, removing as much magic as possible. So, for exploring concepts of linkage requirements, session interface interactions, POSIX compatibility layers and many future investigations that I have yet to imagine, I wish to have a Goa example implemented in Assembly language. Of course, NASM would only be suited for x86 architectures. But given this example, other Goa users on the aarch64 architecture may easily adapt it to their use cases.

I hope that provides some background for why playing around with Goa using assembly, as a way of learning more about the underlying magic of how Genode works.

I spoke with @nfeske about adding the NASM example to Goa, and was thoroughly thrilled to realize that no modification was required to Goa to make the linking step work. It is a thing of beauty how decoupled the Goa linking step is from the target language, and a very powerful mechanism for introducing new language targets to Goa in the future.

Cheerful regards, Robin

jschlatow commented 1 month ago

Thanks, Robin! It's fascinating to read about your motivation and explorative approach.

Would you mind capturing the rationale behind the NASM example in a separate README file?

mewmew commented 1 month ago

Thanks, Robin! It's fascinating to read about your motivation and explorative approach.

Would you mind capturing the rationale behind the NASM example in a separate README file?

Of course! I added a top-level README with the rationale behind the NASM example. Let me know what you think.

I considered using Gosh or Markdown for the top-level README, and decided upon using Markdown so the top-level README would be rendered on GitHub. See https://github.com/mewpull/goa/tree/hello-nasm/examples/hello_nasm#readme for an example.

If decided to use Gosh format instead, the changes would be minimal.

Cheers, Robin

jschlatow commented 1 month ago

Thanks, Robin. I changed the formatting to gosh and merged the commit as a1a6dfd with a shortened commit message that fits into 50 characters.

mewmew commented 1 month ago

Thanks, Robin. I changed the formatting to gosh and merged the commit as a1a6dfd with a shortened commit message that fits into 50 characters.

Perfect! Thanks Johannes!