diff --git a/1991/dds/README.md b/1991/dds/README.md index 80f0858f2..11691d1b9 100644 --- a/1991/dds/README.md +++ b/1991/dds/README.md @@ -8,7 +8,7 @@ make all ## To use: ```sh -./dds basic_program 2>/dev/null +./dds basic_program ./a.out 2>/dev/null ``` @@ -18,14 +18,17 @@ make all The author suggests trying: ```sh -./dds LANDER.BAS 2>/dev/null -./a.out 2>/dev/null +./dds LANDER.BAS +./a.out ``` +Notice that a file `a.c` has been generated. Can you tell how `a.c` was +produced? How does `a.c` relate to [LANDER.BAS](LANDER.BAS)? + What happens if you give the program a C program like itself? Try: ```sh -./dds dds.c 2>/dev/null +./dds dds.c ``` You'll get errors yes but what does the generated file look like? What about @@ -34,9 +37,6 @@ other types of files? ## Judges' remarks: -Notice that a file `a.c` has been generated. Can you tell how `a.c` was -produced? How does `a.c` relate to [LANDER.BAS](LANDER.BAS)? - This obfuscated program translates BASIC programs into obfuscated C programs by way of an obfuscated algorithm. @@ -45,15 +45,16 @@ C programs by way of an obfuscated algorithm. This program is a companion to the [DDS-BASIC interpreter program](/1990/dds/README.md) that was submitted to [the contest in -1990](/years.html#1990). This compiles BASIC programs into executable commands. -The input format is almost identical to the input format of the DDS-BASIC -interpreter. The program needs an executable C compiler called `cc` in your -path in order to work. +1990](/years.html#1990). This compiles BASIC programs into compilable C code +and then compiles it. The input format is almost identical to the input format +of the DDS-BASIC interpreter. The program needs an executable C compiler called +`cc` in your path in order to work. + ### Program commands: -- variable names A to Z +- variable names `A` to `Z` - FOR var = exp TO exp - GOSUB exp - GOTO exp @@ -75,7 +76,7 @@ Many system calls and C library calls can be used. - Free format positioning of tokens on the line. - No space is allowed before the line number. -- Exactly one space is needed after the FOR and NEXT tokens +- Exactly one space is needed after the `FOR` and `NEXT` tokens. - ALL INPUT MUST BE UPPERCASE. ### Error checking / error reports: @@ -85,19 +86,19 @@ Other errors may produce errors in later phases of the compilation. ### Can you figure out how the compiler works? -Hint: +#### Hint: The compiler is NOT written in C, so this is really a meta-obfuscated program. The C code is an interpreter for the four register, seven -instruction COGNIMP$ machine that is contained in the `s` string. -(COGNIMP$ is named after the symbolic names of the seven instructions it -defines (Print Output Goto Match If, iNcrement and Copy). The `$` sign -is used for labels.) The actual compiler is written in COGNIMP$. -Browsing through the COGNIMP$ code we encourage you to examine the -loops for scanning the expression in the IF statement and the way a -decision tree is implemented in order to match the statements. (Of -course the `s` string is encoded by adding one to every character of it just -to confuse you). +instruction `COGNIMP$` machine that is contained in the `s` string. +(`COGNIMP$` is named after the symbolic names of the seven instructions it +defines (`Copy`, `Output`, `Goto`, `iNcrement`, `If`, `Match` and `Print`). + +The `$` sign is used for labels. The actual compiler is written in `COGNIMP$`. +Browsing through the `COGNIMP$` code we encourage you to examine the loops for +scanning the expression in the `IF` statement and the way a decision tree is +implemented in order to match the statements. (Of course the `s` string is +encoded by adding one to every character of it just to confuse you). ## Copyright and CC BY-SA 4.0 License: