From d9b281039291862b0168e1255644edee6d8e13da Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 8 Dec 2023 10:20:44 -0800 Subject: [PATCH] Add 2015/endoh3/try.sh + format/typo checks A new make rule (or alias for mullender and back_to) called 'future' was added for the theme. The try.sh script uses make future ('back_to' just doesn't look that good in my eyes even when I added it). The try.sh tries to stay in character with the award theme a bit too though that will only be noticeable if you pay attention. I found the films very boring (though maybe years later I would find it more enjoyable) so I'm sure that something more fun could have been added if I knew them more but I do not. Well I tried anyway. --- 2015/endoh3/Makefile | 2 +- 2015/endoh3/README.md | 16 +++++++++------- 2015/endoh3/try.sh | 36 ++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 6 ++++-- 4 files changed, 50 insertions(+), 10 deletions(-) create mode 100755 2015/endoh3/try.sh diff --git a/2015/endoh3/Makefile b/2015/endoh3/Makefile index 26609e3a6..bd1b8a519 100644 --- a/2015/endoh3/Makefile +++ b/2015/endoh3/Makefile @@ -135,7 +135,7 @@ all: data ${TARGET} ${PROG}: ${PROG}.c ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} -mullender back_to: ${PROG}.c mullender.c +future mullender back_to: ${PROG}.c mullender.c ${CC} ${CFLAGS} $< -o ${PROG} ${LDFLAGS} ${BACK_TO} diff --git a/2015/endoh3/README.md b/2015/endoh3/README.md index a837ebb61..fad826025 100644 --- a/2015/endoh3/README.md +++ b/2015/endoh3/README.md @@ -17,14 +17,12 @@ make To see the original [mullender](mullender.c) in action: ```sh -cc -o prog prog.c mullender.c # or make mullender or make back_to -./prog -q -^C # where ^C is ctrl-C, interrupt. +./try.sh ``` -Observe what happens when you hit enter or another character! Send INTR to end -the program. +Observe what happens when you hit enter or another character! You might even try +typing out, one character at a time, `1984/mullender`, and then see what it looks +like at the end. Send INTR to end the program. More generally use: @@ -34,7 +32,7 @@ cc -o prog prog.c foo.c ^C # if necessary, where ^C is ctrl-C, interrrupt ``` -to run `prog` as whatever foo.c is in the joke PDP-11 emulator. +to compile and run `prog` as whatever foo.c is in the joke PDP-11 emulator. ## Judges' remarks: @@ -55,6 +53,7 @@ clue, see the end of the author's remarks.) If in doubt, use ## Author's remarks: + ### Hint / Compatibility * A little-endian system is required due to an external factor. @@ -65,6 +64,7 @@ the same reason. But I believe it is reasonably portable. the source code from all angles.. * Find `main()` function. + ### Spoiler This program is a joke PDP-11 emulator. ("ll-dpd" is embedded in the code. @@ -80,6 +80,7 @@ clang -o prog prog.c mullender.c You can enjoy the legendary winner of the first IOCCC, again. + ### Internal This program uses `__attribute__((constructor))`, which is a GCC extension, to @@ -104,6 +105,7 @@ needed for [mullender.c](mullender.c) to work: * 4: Auto-decrement deferred * 6: Index (incomplete) + ### Limitations Non-trivial combination of instruction and addressing mode may cause undefined diff --git a/2015/endoh3/try.sh b/2015/endoh3/try.sh new file mode 100755 index 000000000..43dceebe0 --- /dev/null +++ b/2015/endoh3/try.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2015/endoh3 +# + +# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it +# this way allows us to have the user specify a different compiler in an easy +# way. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +# clear screen so that only the entry is shown +clear + +read -r -n 1 -p "Press any key to run: less -EXF prog.c (space = next page, q = quit): " +echo 1>&2 +less -EXF prog.c +echo 1>&2 + +echo "$ make future" 1>&2 +make future || exit 1 + +echo 1>&2 +echo 1>&2 + +echo "Will go back to the future and run 1984/mullender through prog. To quit" 1>&2 +echo "the program hit ctrl-c/intr." 1>&2 +echo 1>&2 +echo "You might want to try hitting enter or another key when the output reaches" 1>&2 +echo "the end of the line." 1>&2 +echo 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +echo "$ ./prog" 1>&2 +./prog diff --git a/thanks-for-help.md b/thanks-for-help.md index 1133900d0..4b84dca2a 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3818,9 +3818,11 @@ they avoided. symbols of `main()`. The fix is through the compiler option `-fcommon` which will let it compile like it does with macOS. -Cody also made it easier to enjoy the theme of [Back to the +Cody also added the [try.sh](2015/endoh3/try.sh) script which makes use of the +make rule he added (to enjoy the theme of the entry, [Back to the Future](https://en.wikipedia.org/wiki/Back_to_the_Future) using this entry by -simply typing `make back_to` or `make mullender`. +simply typing `make back_to` or `make mullender`) and then runs the famous +[1984/mullender.c](/1984/mullender/mullender.c). ## [2015/hou](2015/hou/prog.c) ([README.md](2015/hou/README.md))