Skip to content

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) { }
}
  1. #include "std" imports std helpers, including print.
  2. let msg:4 = "Hello, World!\n\0"; stores a pointer to null-terminated string data.
  3. print(msg:4); calls std library printing (which uses interrupt 0x80 internally).
  4. while (1) { } keeps execution from running into unrelated memory.
Terminal window
nipcompile hello-world.nip -o hello-world.bin
catlaunch run --rom hello-world.bin

Expected output:

Hello, World!