BBC BASIC for Windows source code follows.
REM binary counter-upper
REM T Street
REM 2015-02-23
MODE 12
*font courier new, 20b
OFF
REM main loop
FOR n% = 0 TO 256^4
PRINTTAB(0,4)CHR$(17)CHR$(7)STR$(n%)" : " ,FN_hiliteBits(FN_toBinary(n%))
WAIT 20
NEXT
END
DEF FN_hiliteBits( s$ )
REM colours the string of bits
REM with 1 and 0 having different colours
LOCAL zeroCol% : zeroCol% = 3
LOCAL digitCol% : digitCol% = 6
_CHAR_FOR_COLOUR% = 17
LOCAL i%
LOCAL a$, b$, col$
FOR i% = 1 TO LEN(s$)
b$ = MID$(s$,i%,1)
CASE b$ OF
WHEN "1"
col$ = CHR$(_CHAR_FOR_COLOUR%)+CHR$(digitCol%)
WHEN "0"
col$ = CHR$(_CHAR_FOR_COLOUR%)+CHR$(zeroCol%)
WHEN " "
col$ =""
ENDCASE
a$ = a$ + col$+b$
NEXT
= a$
DEF FN_toBinary( n% )
REM converts a number to binary string
LOCAL a$ : REM answer
LOCAL b$ : REM copy of the answer
LOCAL b% : REM copy of parameter
LOCAL i% :
b% = n% : REM defensive copying
a$ = FN_binary(b%)
WHILE LEN(a$) MOD 8 <> 0
a$ = "0"+a$
ENDWHILE
b$ = a$
IF LEN(b$) > 8 THEN
b$ = ""
FOR i% = 1 TO LEN(a$)
IF i%-1 MOD 8 <> 0 THEN
b$ = b$ + MID$(a$,i%,1)
ELSE
b$ = b$ + " " + MID$(a$,i%,1)
ENDIF
NEXT
ENDIF
= b$
REM Convert to binary string:
DEF FN_binary(N%) = FN_tobase(N%,2,-32*(N%<0))
:
REM Convert N% to string in base B% with minimum M% digits:
DEF FN_tobase(N%,B%,M%)
LOCAL D%,A$
REPEAT
D% = N%MODB%
N% DIV= B%
IF D%<0 D% += B%:N% -= 1
A$ = CHR$(48 + D% - 7*(D%>9)) + A$
M% -= 1
UNTIL (N%=FALSE OR N%=TRUE) AND M%<=0
=A$