boot2

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

double.P1pp (525B)


      1 # tests/p1/double.P1 — call a helper that doubles argc, return that.
      2 #
      3 # `:double` is a leaf function that shifts its one-word argument left by
      4 # one and returns. `:p1_main` is not a leaf (it calls `double`), so it
      5 # establishes a standard frame with %enter/%eret to preserve the hidden
      6 # return-address state across the call. argc arrives in a0, is handed to
      7 # double unchanged, and the doubled result comes back in a0.
      8 
      9 :double
     10     %shli(a0, a0, 1)
     11     %ret
     12 
     13 :p1_main
     14     %enter(0)
     15     %call(&double)
     16     %eret
     17 
     18 :ELF_end