JAL manual - language - subprograms

previous up next


procedure

A procedure declaration declares a name for an argument list and a sequence of statements. The mechanism for passing arguments is described under the procedure call.

examples
   procedure zero( byte out x ) is begin
      x = 0
   end procedure


function

A function declaration declares a name for an argument list, a sequence of statements and a return type.

When the execution of a function reaches the end of the statements the returned value is undefined.

examples
   
   function reverse( byte in x ) return byte is
      byte y
      for 8 loop
         asm rrf x, f
         asm rlf y, f
      end loop
      return y
   end function


pseudo-variable

A pseudo-variable can be used like any other variable, but is implemented by a get and/or put routine. One of the two routines can be omitted, which makes the variable read-only or write-only. Alternatively a variable and a put or get routine can be declared, in which case the plain variable will be used for the missing routine.

A put procedure must have one byte in parameter, a get function must have no parameters.

examples
   procedure hd44780'put( byte in x ) is ...

   hd44780 = "H"
   hd44780 = "e"
   hd44780 = "l"
   hd44780 = "l"
   hd44780 = "o"


   procedure async'put( byte in x ) is ...
   function async'get return byte is ..

   forever loop
      byte c = async
      if ( c >= "a" ) & ( c <= "z" ) then
         c = c + "A" - "a"
      end if
      async = c
   end loop

previous up next