INTERCAL, 270 258 247 bytes
DO,1<-#1PLEASECOMEFROM(2)DOWRITEIN,1DO.1<-,1SUB#1DO.5<-#1$.1~#256DO.2<-.3DO(1)NEXTPLEASE.2<-'"!3~#1'$.3~#16"$!3~#4'$.3~#64'$"!3~#2'$.3~#32"$!3~#8'$.3~#128DO(1010)NEXTPLEASE,1SUB#1<-.3DOREADOUT,1(1)DO(1002)NEXTDO(1009)NEXTDO.3<-.3~#255(2)DOFORGET#1
Try it online!
-8 thanks to 鳴神裁四点一号 removing DOGIVEUP
to terminate by NEXT stack explosion, opening up another -4 changing a PLEASE
to DO
.
-11 removing some grouping from the bit-reversing expression from hell. It seems that binary operators generally act right-associative in C-INTERCAL, though having no precedence among themselves.
Writing this was... interesting. I was thinking I might want to use INTERCAL to INTERCALate, but I'm a bit less sure now.
Ungolfed and commented:
DO ,1<-#1 PLEASE NOTE We want the input array to only have space for one element, so it will only take one at a time
DO COME FROM (2)
DO WRITE IN ,1 PLEASE NOTE If this is the first byte of the input, it'll write its value... but if not, it'll write the
previous value minus its value mod 256.
DO .1<-,1SUB#1
DO .5<-#1$!1~#256' PLEASE NOTE .5 is 3 if the input is 256, 2 otherwise
DO .2<-.3
DO (1) NEXT
PLEASE NOTE If we're here, we've found the end of the input. Now, we need to print it back out... C-INTERCAL's
array I/O, in order to determine what it will actually print, subtracts the value it's going to print from the
previous one (still mod 256, and with the previous value defaulting to 0), and then reads the bits of the byte
backwards. So in order to go from the value we want to display to the value we need to feed into READ OUT, we
reverse the bits and then subtract from 256. The nightmarish expression on the following line reverses the
bits the best way I could think to: individually select each one out and then mingle them all back
together. It may be possible to emulate the method used in cesspool.c, by using mingle and unary AND as a
substitute for binary AND where we can't afford for select to rearrange it, but it might end up longer...
DO .2 <- '"'.3~#1'$'.3~#16'"$"'.3~#4'$'.3~#64'"'$'"'.3~#2'$'.3~#32'"$"'.3~#8'$'.3~#128'"'
DO (1010) NEXT PLEASE NOTE .1 already has 256 in it, which is very convenient for when you need to subtract .2 from 256.
DO ,1SUB#1 <- .3 PLEASE NOTE If we just read .3 out, we'd get a Roman numeral instead of the correct output.
DO READ OUT ,1
DON'T GIVE UP PLEASE NOTE Logical end of program. However, if we don't gracefully terminate here, nothing more is output,
and the FORGET can't keep up with the NEXTs.
(1) DO (1002) NEXT PLEASE NOTE that that line in syslib does 1001 next, which pops .5 entries off the next-stack and returns
control flow to the last one, such that if .5 is 2 flow will come back here, but if it's 3 then it'll go back
to the line that nexted to this one.
Here we add .1 and .2 into .3, then truncate it to a byte before looping back (while managing the next-stack
responsibly so the program doesn't disappear into the black lagoon for any input over 79 (?) bytes)
DO (1009) NEXT
DO .3<-.3~#255
(2) DO FORGET #1