boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

hello.P1pp (802B)


      1 # tests/p1/hello.P1 — P1-language hello world using the portable entry model.
      2 #
      3 # The backend-owned `:_start` stub is emitted automatically by P1.M1pp. It
      4 # captures argc/argv from the native entry state, calls `p1_main` under the
      5 # one-word direct-result convention (a0=argc, a1=argv), then sys_exits
      6 # p1_main's return value as the process exit status.
      7 #
      8 # p1_main is an ordinary P1 function written to the portable ISA. It's a
      9 # leaf — no P1 `%call` — so no %enter/%leave frame is needed. It ignores
     10 # argc/argv, writes "Hello, World!\n" to stdout via sys_write, and returns
     11 # 0 in a0 so the backend stub exits with status 0.
     12 
     13 :p1_main
     14     %li(a0) %sys_write()
     15     %li(a1) %1 %0
     16     %la(a2, &msg)
     17     %li(a3) %14 %0
     18     %syscall()
     19     %li(a0) %0 %0
     20     %ret()
     21 
     22 :msg
     23 "Hello, World!
     24 "
     25 
     26 :ELF_end