protoverse

A metaverse protocol
git clone git://jb55.com/protoverse
Log | Files | Refs | README | LICENSE

ifelse.wat (1003B)


      1 (module
      2   (memory $mem 0)
      3 	(func $add (param $lhs i32) (param $rhs i32) (result i32)
      4 	      local.get $lhs
      5 	      local.get $rhs
      6 	      i32.add)
      7 	(func $sub (param $lhs i32) (param $rhs i32) (result i32)
      8 	      local.get $lhs
      9 	      local.get $rhs
     10 	      i32.sub
     11 	      )
     12 	(func $start (result i32)
     13 	      (local i32 i32)
     14 	      i32.const 0
     15 	      local.set 0
     16 	      block
     17 	          local.get 0
     18 		  i32.const 1
     19 		  i32.add
     20 		  local.set 0
     21 	          i32.const 4
     22 		  local.get 0
     23 	          i32.gt_u
     24 	          if
     25 		    nop
     26 		    br 0
     27 		    if
     28 		      nop
     29 		    else
     30 		      nop
     31 		    end
     32 		  else
     33 		    unreachable
     34 		    block
     35 		      nop
     36 		    end
     37 		  end
     38 	      end
     39 	      i32.const 0
     40 	      )
     41 
     42 	(func $enter (result i32)
     43 	      (local i32)
     44 	      (call $start)
     45 	      local.set 0
     46 	      (call $start)
     47 	      local.get 0
     48 	      i32.ne
     49 	      )
     50 
     51 	(export "start" (func $start))
     52 	(export "_start" (func $enter))
     53 
     54 	(export "add" (func $add))
     55 	(export "memory" (memory $mem))
     56 	(export "sub" (func $sub)))