Task

Produce a formatted   12×12   multiplication table of the kind memorized by rote when in primary (or elementary) school.



Only print the top half triangle of products.




*        12*12 multiplication table    14/08/2015
MULTTABL CSECT
         USING  MULTTABL,R12
         LR     R12,R15
         LA     R10,0              buffer pointer
         LA     R3,BUFFER
         MVC    0(4,R3),=C'  | '
         LA     R10,4(R10)
         LA     R5,12
         LA     R4,1               i=1
LOOPN    LA     R3,BUFFER          do i=1 to 12
         AR     R3,R10
         XDECO  R4,XDEC            i
         MVC    0(4,R3),XDEC+8     output i
         LA     R10,4(R10)
         LA     R4,1(R4)
         BCT    R5,LOOPN           end i
         XPRNT  BUFFER,52
         XPRNT  PORT,52            border
         LA     R5,12
         LA     R4,1               i=1 (R4)
LOOPI    LA     R10,0              do i=1 to 12
         MVC    BUFFER,=CL52' '
         LA     R3,BUFFER
         AR     R3,R10
         XDECO  R4,XDEC
         MVC    0(2,R3),XDEC+10
         LA     R10,2(R10)
         LA     R3,BUFFER
         AR     R3,R10
         MVC    0(2,R3),=C'| '
         LA     R10,2(R10)
         LA     R7,12
         LA     R6,1               j=1 (R6)
LOOPJ    CR     R6,R4              do j=1 to 12
         BNL    MULT
         LA     R3,BUFFER
         AR     R3,R10
         MVC    0(4,R3),=C'    '
         LA     R10,4(R10)
         B      NEXTJ
MULT     LR     R9,R4              i
         MR     R8,R6              i*j in R8R9
         LA     R3,BUFFER
         AR     R3,R10
         XDECO  R9,XDEC
         MVC    0(4,R3),XDEC+8
         LA     R10,4(R10)
NEXTJ    LA     R6,1(R6)
         BCT    R7,LOOPJ           end j
ELOOPJ   XPRNT  BUFFER,52
         LA     R4,1(R4)
         BCT    R5,LOOPI           end i
ELOOPI   XR     R15,R15
         BR     R14
BUFFER   DC     CL52' '
XDEC     DS     CL12
PORT     DC     C'--+-------------------------------------------------'
         YREGS
         END    MULTTABL