Task

Produce a sequential count in octal,   starting at zero,   and using an increment of a one for each consecutive number.

Each number should appear on a single line,   and the program should count until terminated,   or until the maximum value of the numeric type in use is reached.



Related task

   Integer sequence   is a similar task without the use of octal numbers.


*        Octal                     04/07/2016
OCTAL    CSECT
         USING  OCTAL,R13          base register
         B      72(R15)            skip savearea
         DC     17F'0'             savearea
         STM    R14,R12,12(R13)    prolog
         ST     R13,4(R15)         "
         ST     R15,8(R13)         " 
         LR     R13,R15            "
         LA     R6,0               i=0
LOOPI    LR     R2,R6              x=i
         LA     R9,10              j=10
         LA     R4,PG+23           @pg
LOOP     LR     R3,R2              save x
         SLL    R2,29              shift left  32-3
         SRL    R2,29              shift right 32-3
         CVD    R2,DW              convert octal(j) to pack decimal 
         OI     DW+7,X'0F'         prepare unpack
         UNPK   0(1,R4),DW         packed decimal to zoned printable
         LR     R2,R3              restore x
         SRL    R2,3               shift right 3
         BCTR   R4,0               @pg=@pg-1
         BCT    R9,LOOP            j=j-1
         CVD    R2,DW              binary to pack decimal 
         OI     DW+7,X'0F'         prepare unpack
         UNPK   0(1,R4),DW         packed decimal to zoned printable
         CVD    R6,DW              convert i to pack decimal 
         MVC    ZN12,EM12          load mask
         ED     ZN12,DW+2          packed decimal (PL6) to char (CL12)
         MVC    PG(12),ZN12        output i
         XPRNT  PG,80              print buffer
         C      R6,=F'2147483647'  if i>2**31-1 (integer max)
         BE     ELOOPI             then exit loop on i
         LA     R6,1(R6)           i=i+1
         B      LOOPI              loop on i
ELOOPI   L      R13,4(0,R13)       epilog 
         LM     R14,R12,12(R13)    "
         XR     R15,R15            "
         BR     R14                exit
         LTORG  
PG       DC     CL80' '            buffer
DW       DS     0D,PL8             15num
ZN12     DS     CL12
EM12     DC     X'40',9X'20',X'2120'  mask CL12 11num
         YREGS
         END    OCTAL