Update 1992/buzzard.1
Format fixes in README.md. Note that it'll crash without two args both in bugs.md and README.md.
This commit is contained in:
1 parent
460443fa48
commit
48559c1f16
2 files changed
+100
-71
No files matched your search
+92
-71
@@ -1,36 +1,51 @@
|
||||
Most Obfuscated Algorithm:
|
||||
# Most Obfuscated Algorithm:
|
||||
|
||||
Sean Barrett
|
||||
Software Construction Company
|
||||
430 Southwest Parkway, #1906
|
||||
College Station, TX 77840
|
||||
USA
|
||||
Sean Barrett
|
||||
Software Construction Company
|
||||
430 Southwest Parkway, #1906
|
||||
College Station, TX 77840
|
||||
USA
|
||||
|
||||
|
||||
## To build:
|
||||
|
||||
make all
|
||||
```sh
|
||||
make all
|
||||
```
|
||||
|
||||
## To run
|
||||
|
||||
./buzzard.1 0 10
|
||||
./buzzard.1 56 720
|
||||
./buzzard.1 1 521
|
||||
```sh
|
||||
./buzzard.1 num num
|
||||
|
||||
## Judges' comments
|
||||
```
|
||||
|
||||
NOTE: this program will crash without two args.
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./buzzard.1 0 10
|
||||
./buzzard.1 56 720
|
||||
./buzzard.1 1 521
|
||||
```
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
To see good C Preprocessor buzzard.1, try:
|
||||
|
||||
make babble.cppcb
|
||||
cat babble.cppcb
|
||||
|
||||
```sh
|
||||
make babble.cppcb
|
||||
cat babble.cppcb
|
||||
```
|
||||
|
||||
Notice how many statements it takes to do anything useful?
|
||||
|
||||
## Author's comments;
|
||||
## Author's comments:
|
||||
|
||||
What you shouldn't think about buzzard.1:
|
||||
What you shouldn't think about `buzzard.1`:
|
||||
|
||||
`buzzard.1` doesn't just do a mass of #defines as its obfuscation.
|
||||
`buzzard.1` doesn't just do a mass of `#define`s as its obfuscation.
|
||||
|
||||
|
||||
### What you should be glad about:
|
||||
@@ -75,8 +90,8 @@ error message.
|
||||
|
||||
`buzzard.1` is a translator from a pseudo-assembly language into a subset of C
|
||||
suitable for execution on Charles Babbage's Analytical Engine. Or rather, the
|
||||
`#define`s in `buzzard.1` are that translator. The rest of buzzard.1 is a
|
||||
buzzard.1 program. If you run the whole mess through CPP and a beautifier, you
|
||||
`#define`s in `buzzard.1` are that translator. The rest of `buzzard.1` is a
|
||||
`buzzard.1` program. If you run the whole mess through CPP and a beautifier, you
|
||||
will see that all you have is a loop that runs until a variable is not 0, and a
|
||||
sequence of assignment statements. The assignment statements are all of the
|
||||
form `a op= b` or `a = b`. The Engine actually allowed 'a = b op c'. Only `+`,
|
||||
@@ -102,58 +117,56 @@ themselves to it.
|
||||
|
||||
### Theoretical observations:
|
||||
|
||||
The simulated comparison operations only work with a certain
|
||||
range of numbers; numbers that are too large will cause the
|
||||
output code to fail to simulate the input code. This means
|
||||
that this implementation of buzzard.1 would not be Turing-complete,
|
||||
even if the AE could process indefinitely-sized numbers.
|
||||
However, this is actually a constraint that no actual computer
|
||||
can meet, either, so we can conclude that if an AE, with
|
||||
card bins connected as suggested above, were hooked up to
|
||||
a memory unit of sufficient size, it would be as Turing
|
||||
complete as any existing machine (or, for those who
|
||||
interpret that excessively critically, i.e. "not at all" for
|
||||
both, we can simply say that the AE could simulate any
|
||||
existing machine--although not quickly). This would be a
|
||||
good place to site some references on the AE, but I don't
|
||||
have any.
|
||||
The simulated comparison operations only work with a certain range of numbers;
|
||||
numbers that are too large will cause the output code to fail to simulate the
|
||||
input code. This means that this implementation of `buzzard.1` would not be
|
||||
Turing-complete, even if the AE could process indefinitely-sized numbers.
|
||||
However, this is actually a constraint that no actual computer can meet, either,
|
||||
so we can conclude that if an AE, with card bins connected as suggested above,
|
||||
were hooked up to a memory unit of sufficient size, it would be as Turing
|
||||
complete as any existing machine (or, for those who interpret that excessively
|
||||
critically, i.e. "not at all" for both, we can simply say that the AE could
|
||||
simulate any existing machine--although not quickly). This would be a good
|
||||
place to site some references on the AE, but I don't have any.
|
||||
|
||||
|
||||
### Definition of the input language to buzzard.1 (OR What Exactly Do All The Macros Do?):
|
||||
|
||||
[Don't read this unless you're stumped!]
|
||||
|
||||
|
||||
MACRO FUNCTION MNEMONIC
|
||||
```
|
||||
|
||||
V begin variable declarations Variable
|
||||
C begin program Code
|
||||
MACRO FUNCTION MNEMONIC
|
||||
|
||||
Q(b,a) let b = a eQuals
|
||||
A(c,a,b) let c = a + b Add
|
||||
S(c,a,b) let c = a - b Subtract
|
||||
D(c,a,b) let c = a / b, where b is a *constant* Divide
|
||||
U(c,a,b) let c = a / b, where b is anything Unknown
|
||||
M(c,a,b) let c = a * b Multiply
|
||||
V begin variable declarations Variable
|
||||
C begin program Code
|
||||
|
||||
O(c,a,b) let c = a boolean-or b (a,b are 0 or 1) Or
|
||||
B(b, a) let b = boolean value of a Boolean
|
||||
P(b, a) let b = 1 if a>0, else 0. Positive
|
||||
Q(b,a) let b = a eQuals
|
||||
A(c,a,b) let c = a + b Add
|
||||
S(c,a,b) let c = a - b Subtract
|
||||
D(c,a,b) let c = a / b, where b is a *constant* Divide
|
||||
U(c,a,b) let c = a / b, where b is anything Unknown
|
||||
M(c,a,b) let c = a * b Multiply
|
||||
|
||||
l emit next sequential label Label
|
||||
J(x) goto label #x Jump
|
||||
O(c,a,b) let c = a boolean-or b (a,b are 0 or 1) Or
|
||||
B(b, a) let b = boolean value of a Boolean
|
||||
P(b, a) let b = 1 if a>0, else 0. Positive
|
||||
|
||||
Z(a,d) if a is 0 goto d (a is 0 or 1) Zero
|
||||
E(a,d) if a is 1 goto d (a is 0 or 1) Else
|
||||
l emit next sequential label Label
|
||||
J(x) goto label #x Jump
|
||||
|
||||
H halt Haly
|
||||
Z(a,d) if a is 0 goto d (a is 0 or 1) Zero
|
||||
E(a,d) if a is 1 goto d (a is 0 or 1) Else
|
||||
|
||||
K(x) let x = number of cmd line arguments Kount
|
||||
G(x,y) let x = the value if the yth argument Get argument
|
||||
H halt Haly
|
||||
|
||||
T end of code; begin output section Terminate
|
||||
X(y) print out hexadecimal value of y heXadecimal
|
||||
T end of output section and program Terminate
|
||||
K(x) let x = number of cmd line arguments Kount
|
||||
G(x,y) let x = the value if the yth argument Get argument
|
||||
|
||||
T end of code; begin output section Terminate
|
||||
X(y) print out hexadecimal value of y heXadecimal
|
||||
T end of output section and program Terminate
|
||||
```
|
||||
|
||||
You can figure out the other macros yourself. In the sample program, I've
|
||||
actually implemented subroutines by saving a return address in a variable and
|
||||
@@ -168,32 +181,40 @@ programs is the conditional (given that we have loops).
|
||||
Since all you can do in the given operation output set is
|
||||
assignment, we implement "conditional assignment":
|
||||
|
||||
if (x) y = z;
|
||||
```
|
||||
if (x) y = z;
|
||||
```
|
||||
|
||||
To implement this, we constrain x to be either 0 or 1, and
|
||||
simply compute:
|
||||
|
||||
y = (z * x) + (y * (1-x));
|
||||
```
|
||||
y = (z * x) + (y * (1-x));
|
||||
```
|
||||
|
||||
This is more obscured by factoring out common terms and restricting
|
||||
ourselves to two operand operations:
|
||||
|
||||
temp = z; (temp == z)
|
||||
temp -= y; (temp == z-y)
|
||||
temp *= x; (temp == (z-y)*x)
|
||||
y += temp; (y == (z-y)*x + y)
|
||||
( == z*x - y*x + y)
|
||||
( == z*x + y*(1-x))
|
||||
```
|
||||
temp = z; (temp == z)
|
||||
temp -= y; (temp == z-y)
|
||||
temp *= x; (temp == (z-y)*x)
|
||||
y += temp; (y == (z-y)*x + y)
|
||||
( == z*x - y*x + y)
|
||||
( == z*x + y*(1-x))
|
||||
```
|
||||
|
||||
Next we imagine we have a pc. "I'm supposed to execute statement
|
||||
pc next", says our emulator. But suppose we're not currently
|
||||
coming up on statement pc. To handle this, we simply make every
|
||||
operation conditional on the pc having the correct value:
|
||||
Next we imagine we have a [pc](https://en.wikipedia.org/wiki/Program_counter).
|
||||
"I'm supposed to execute statement pc next", says our emulator. But suppose
|
||||
we're not currently coming up on statement pc. To handle this, we simply make
|
||||
every operation conditional on the pc having the correct value:
|
||||
|
||||
if (pc == some_constant) y = z;
|
||||
```
|
||||
if (pc == some_constant) y = z;
|
||||
```
|
||||
|
||||
To combine this with other operations, we simply multiply by our
|
||||
(`pc == some_constant`) flag right after the above 'temp `*= x'`.
|
||||
(`pc == some_constant`) flag right after the above `temp *= x`.
|
||||
|
||||
To evaluate `pc == some_constant` requires one more trick. We assume that
|
||||
numbers can only be in some limited range. Then we use successive additions and
|
||||
|
||||
@@ -498,6 +498,14 @@ This program crashes. This will be worked on in the near future.
|
||||
|
||||
# 1992
|
||||
|
||||
## [1992/buzzard.1](1992/buzzard.1/buzzard.1.c) ([README.md](1992/buzzard.1/README.md))
|
||||
## STATUS: INABIAF - please **DO NOT** fix
|
||||
|
||||
This entry will crash without enough args (2). At this time this is not
|
||||
considered a bug to fix so it should not be fixed.
|
||||
|
||||
|
||||
|
||||
## [1992/lush](1992/lush/lush.c) ([README.md](1992/lush/README.md))
|
||||
## STATUS: doesn't work with some compilers - please provide alternative code
|
||||
|
||||
|
||||
Reference in new issue
Block a user