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.


100H: /* PRINT INTEGERS IN OCTAL */
   BDOS: PROCEDURE( FN, ARG ); /* CP/M BDOS SYSTEM CALL */
      DECLARE FN BYTE, ARG ADDRESS;
      GOTO 5;
   END BDOS;
   PR$CHAR:  PROCEDURE( C ); DECLARE C BYTE; CALL BDOS( 2, C ); END;
   PR$NL:    PROCEDURE; CALL PR$CHAR( 0DH ); CALL PR$CHAR( 0AH ); END;
   PR$OCTAL: PROCEDURE( N );
      DECLARE N ADDRESS;
      DECLARE V ADDRESS, O$STR( 7 ) BYTE, W BYTE;
      V = N;
      O$STR( W := 0 ) = '0' + ( V AND 7 );
      DO WHILE( ( V := SHR( V, 3 ) ) > 0 );
         O$STR( W := W + 1 ) = '0' + ( V AND 7 );
      END;
      W = W + 1;
      DO WHILE( W <> 0 );
         CALL PR$CHAR( O$STR( W := W - 1 ) );
      END;
   END PR$OCTAL;
 
   DECLARE N ADDRESS;
   N = 0;
   CALL PR$OCTAL( N );
   CALL PR$NL;
   DO WHILE( ( N := N + 1 ) > 0 ); /* AFTER 65535 N WILL WRAP 'ROUND TO 0 */
      CALL PR$OCTAL( N );
      CALL PR$NL;
   END;
EOF