#Commodore VIC-20/VC-20/C64 - 95 69 68 67 tokenized BASIC bytes used (obfuscated and minimized)
Commodore VIC-20/VC-20/C64 - 95 69 68 67 tokenized BASIC bytes used (obfuscated and minimized)
0dEfnb(x)=sgn(xandb):fOi=0to10:b=8:fOj=0to3:?rI(stR(fnb(i)),1);:b=b/2:nE:?:nE
Copy and paste the above text into WinVice, for instance. Just about fits onto 80 characters on a Commodore 64.
Here's the non-obfuscated symbolic listing for illustrative purposes:
0 DEF FN B(X)=SGN(X AND B)
1 FOR I=0 TO 10
2 LET B=8
3 FOR J=0 TO 3
4 PRINT RIGHT$(STR$(FN B(I)),1);
5 LET B=B/2
6 NEXT J
7 PRINT
8 NEXT I
Of course this may be minimised and further obfuscated. Explanation:
The DEF FN
command in line zero is a simple function which accepts one numeric parameter. This will give the algebraic sign the number passed to it as a parameter, in this case is AND
ed with the value B
(declared elsewhere, but becomes global once declared).
Line 1 starts the loop counter I
Line 2 sets the value of the 3rd BIT.
Line 3 starts loop counter J
(we want bits 0 - 3 essentially).
Line 4 gets the STR$
value (string value) of the function FN B(I)
, this is then passed to the RIGHT$
command as CBM BASIC auto-pads outputted numbers with a white space, so we get the last character in the string created by STR$
.
Line 5 moves the BIT counter down one (like x >> 1
in C I suppose).
Line 6 moves the J
loop up one.
Line 7 prints a new line (line echo PHP_EOL;
in PHP).
Line 8 moves the I
loop up one.
I've 'nested' the listing in the example to better show the loop and loop order.