• Description:
    Libraries are on Amiga used very often, they contains many useful functions. It is ofcourse possible to use them in PowerD.

  • Syntax:
    
      LIBRARY <libbase>
    
        <name>( [ <args> ] ) [ (<result>) ] [ =<offset> ] [,...]
    
    
  • Function arguments:
    Each argument starts with register (eg.: d0,d1,a0,a1,fp0,fp1,...), then should follow a type. It is also possible to use 'LIST OF' keyword, that is used for inline lists. This must be last argument, since it may contain variable number of arguments. (eg.: PrintF('\d*\d=\d\n',a,b,a*b) where a, b, a*b are arguments of list)

  • Default argument values:
    If you want to use default arguments in library functions like in procedures, just insert after register '=value', where value is a number or a constant.

  • Return values:
    All functions in Amiga libraries currently returns maximally one value in D0 register. This way you can create your own libraries that wont be so limited. If you wont define return register/type, register (D0:VOID) will be used.

  • Library offsets:
    Initial library offset is -30 (default Amiga library first function offset). After each function is this offset decreased by 6.

  • Examples:
    
      LIBRARY DrawBase
    
        DrawPixel(a0:PTR TO RastPort,d0:WORD,d1:WORD),
    
        DrawLine(a0:PTR TO RastPort,d0:WORD,d1:WORD,d2:WORD,d3:WORD),
    
        ReadPixel(a0:PTR TO RastPort,d0:WORD,d1:WORD)(d0:WORD)=-48,
    
        VTextF(a0:PTR TO RastPort,d0:WORD,d1:WORD,a1:PTR TO UBYTE,a2=NIL:PTR TO LONG),
    
        TextF(a0:PTR TO RastPort,d0:WORD,d1:WORD,a1:PTR TO UBYTE,a2:LIST OF LONG)=-54