A C89 compiler that produces executables that are also valid ASCII text files [pdf]
cs.cmu.edu
cs.cmu.edu
Update: I have my data well sorted enough that I found it :-) It even comes with code and is under a vague free license: https://github.com/hannob/com2txt
Kind of uncanny to see a perfectly readable Makefile written around the year I was born...
First two paragraphs of the README:
Com2txt is a tool on MS-DOS which converts a com file to a text file. It's DOS generic. Unlike tools such as uuencode, the text file generated by com2txt works as a com file, exactly like the original com file does. Using com2txt, you can create a com file which can be sent through networks such as internet, and runs without any decoding.
Moreover, the text file got by com2txt consists only of ECHOable characters; it doesn't contain characters such as `<' or `|'. So, using ECHO command, you can easily generate the textized com file and use it in a batch file. For detail see section 4.
Crazy fun stuff though.
* com2txt.exe is 7110 bytes long, xcom.com is only 401 bytes long.
* xcom.com can also convert back from text to binary.
* xcom.com can also convert to data text (without the self-decoder header).
I think what parent is remembering were characters that effectively created a jump instruction at the beginning of the file.
[1] https://en.wikipedia.org/wiki/DOS_MZ_executable
edit: [2] Section 6 of the paper talks about that, just noticed.
The characters you were typing are (probably) the code for a jump to an entry point somewhere else in the file.
https://gist.github.com/jdarpinian/1952a58b823222627cc1a8b83...
Neat though, and I haven't seen it before.
https://docs.google.com/document/d/1sBzur57FeLqzgcoGMz8jwOgM...
Challenge accepted. :-) Might be just a matter of a shebang at the beginning and an 'exec' before the final $p.
I now remember why I used the complicated expr command and make; it's to ensure it works with C and C++.
And any language that happens to accept // as a comment and is supported by "make". (note that no actual Makefile is required)
#!/usr/bin/tcc -run #include <stdio.h> int main() { puts("Hello, World!"); }
$ cat >test.c
//usr/bin/gcc "$0" -o /tmp/out.exe || exit; exec /tmp/out.exe "$@"
#include <stdio.h>
void main(int argc, char **argv) {
printf("Hello, world!");
}
^D
$ chmod a+x test.c
$ ./test.c
Hello, world! //usr/bin/make -s "${0%.*}"&&exec "${0%.*}" "$@";exitHowever, Intel has used their advantage in process technology to throw massive amounts of transistors to make up for the problems caused by all this complexity, and has done well. RISC has done well in the mobile space because those transistors tend to be power-hungry, but everywhere else x86 is today almost the only game in town.
One reason it's especially funny is that "HLT" is one of those legacy instructions that has pretty much no use in a modern system, yet takes up a whole slot in the byte encoding, while common operations like MOV or ADD often require extra prefix bytes to specify the size of the operands.
Hope that helps!
Is HLT no longer used in OS idle loops? Are there now other instructions which are better to use instead?
So everything adds up. CYA!
I'm still curious as to how Intel thought a mobile x86 chip could ever work.
I guess it depends when and where one studied.
Having grown with Z80 and x86, it surely looked kind of alright to me.
I only missed the flat addressing from 68000, but given that I only had access to it on Amigas available at some dev meetings, it wasn't something I bothered much with.
Also I don't remember anyone jumping of joy during the MIPS assignments (using SPIM).
> Dennis Ritchie invents a powerful gun that shoots both forward and backward simultaneously. Not satisfied with the number of deaths and permanent maimings from that invention he invents C and Unix.
His video on learnfun/playfun is both hilarious and amazing.
I laughed very hard indeed when I first read this and got to the last 30 seconds of the video.
From what I can tell, the .exe file generated by the compiler must be really big anyway (since the relevant sizes in the header can't be small because they have to be printable). So there must be some text, it might as well be the paper.
[1] https://sourceforge.net/p/tom7misc/svn/HEAD/tree/trunk/abc/e...