A function is a body of code that returns a value.

The value returned may depend on arguments provided to the function.



Task

Write a definition of a function called "multiply" that takes two arguments and returns their product.

(Argument types should be chosen so as not to distract from showing how functions are created and values returned).



Related task

   Function prototype


DEFFUN   CSECT
         USING  DEFFUN,R13
SAVEAREA B      PROLOG-SAVEAREA(R15)
         DC     17F'0'
PROLOG   STM    R14,R12,12(R13)
         ST     R13,4(R15)
         ST     R15,8(R13)
         LR     R13,R15            set base register
BEGIN    L      R2,=F'13'
         ST     R2,X               X=13
         L      R2,=F'17'
         ST     R2,Y               Y=17
         LA     R1,PARMLIST        R1->PARMLIST
         B      SKIPPARM
PARMLIST DS     0F
         DC     A(X)
         DC     A(Y)
SKIPPARM BAL    R14,MULTPLIC       call MULTPLIC
         ST     R0,Z               Z=MULTPLIC(X,Y)
RETURN   L      R13,4(0,R13)       epilog
         LM     R14,R12,12(R13)
         XR     R15,R15            set return code
         BR     R14                return to caller
*        
MULTPLIC EQU    *                  function MULTPLIC(X,Y)
         L      R2,0(R1)           R2=(A(X),A(Y))
         XR     R4,R4              R4=0     
         L      R5,0(R2)           R5=X    
         L      R6,4(R2)           R6=Y    
         MR     R4,R6              R4R5=R4R5*R6
         LR     R0,R5              R0=X*Y   (R0 return value)
         BR     R14                end function MULTPLIC
*
X        DS     F
Y        DS     F
Z        DS     F
         YREGS  
         END    DEFFUN