As a fun puzzle I looked at different ways to reverse the binary representation of a byte completely with basic code. There are several examples of this to do this by using assembler but how to do this in basic?, well this is what I came up with.

1286432168421
10110001

If you calculate the byte value that would be 128+32+16+1= 177

Reversing or flipping this will give

1286432168421
10001101

Calculated byte value 128+8+4+1= 141

It is also a nice exercise to work with the different string editing instructions from Commodore Basic.
Nice puzzling with bits and bytes, I have made a number of different versions from straightforward solution to a shortened version with a FOR NEXT loop.

Below is the final version that also shows the original and result in bit form by building it in a string. On my blog you can find the other versions.

Before I was able to create this version I experimented with the following;

Categories:

Tags:

No responses yet

Geef een antwoord

Het e-mailadres wordt niet gepubliceerd.