Hello World Tutorial
This is the Catnip equivalent of the Assembly hello world tutorial.
It uses the Catnip std library print() helper.
#include "std"
main();
fun main() { let msg:4 = "Hello, World!\n\0"; print(msg:4);
while (1) { }}or you can simplify this all down to:
#include "std"
main();
fun main() { // strings can be passed inline print("Hello, World!\n\0");
while (1) { }}How it works
Section titled “How it works”#include "std"imports std helpers, includingprint.let msg:4 = "Hello, World!\n\0";stores a pointer to null-terminated string data.print(msg:4);calls std library printing (which uses interrupt0x80internally).while (1) { }keeps execution from running into unrelated memory.
Build and run (Catnip + CatLauncher)
Section titled “Build and run (Catnip + CatLauncher)”nipcompile hello-world.nip -o hello-world.bincatlaunch run --rom hello-world.binExpected output:
Hello, World!