!@@))T]))$D)%Lb.!--->." Naturally, there are lots of complicated ways to do this. You could write a program to TYPE a file, muck around inside CP/M to shorten or eliminate the need for the TYPE command, etc. But most of these solutions are more trouble than they're worth. What if we just rename a text file README.COM? CP/M can't tell the difference between text and program files: it just blindly loads anything called ".COM" into memory, and executes it. "Execute" is right. If you try this with a text file, the system will almost certainly die. That's because CP/M tries to use the text characters as 8080 opcodes. Sensible-looking text becomes a nonsense program. But what if I choose ASCII characters that just happen to form a valid program? Now the text looks like nonsense, but the CPU can run it as a program! The gibberish at the top of this listing is the result. It's really a program that types all of the following text, until it finds a "dollar" sign. Just use your word processor to put it at the beginning of any text file, rename the file "anything.COM" and you have an executable program! Writing it was rather restrictive. I wanted the "program" to use only printable ASCII characters: no control codes or characters with the 8th bit set. Examine the 8080 instruction set, and you'll see you've got SHLD, LHLD, DAA, CMA, CMC, STC, HLT, all the MOV opcodes, and some of the MVI, INR, DCR, INX, DCX, LXI and DAD instructions. But it leaves out all JMP, CALL, RET, PUSH, POP, math and logical instructions. Here it is in assembly language: addr hex byte ASCII instruction comments ---- -------- ----- ----------- --------------------------- ; ascii.asm ; Lee Hart 11/26/90 cr equ 0dh lf equ 0ah 0100 org 100h ; load this program at 0100h 0100 21 40 40 !@@ lxi h,'@@' 0103 29 ) dad h 0104 29 ) dad h ; "0" and "1" w/o control codes 0105 54 T mov d,h ; D=1 0106 5D ] mov e,l ; E=0 0107 29 ) dad h 0108 29 ) dad h 0109 24 inr h ; create 5 010A 44 D mov b,h ; B=5 010B 29 ) dad h 010C 25 % dcr h ; create 9 010D 4C L mov c,h ; C=9 (BDOS "type string") 010E 62 b mov h,d 010F 2E 21 .! mvi l,'!' 0111 2D - dcr l 0112 2D - dcr l 0113 2D - dcr l ; HL=011Eh (addr of JMP opcode) 0114 3E 3C >< mvi a,'<' 0116 2F / cma ; A="JMP" opcode 0117 77 w mov m,a ; write "JMP xxxx" 0118 23 # inx h 0119 70 p mov m,b ; write "JMP xx05" 011A 23 # inx h 011B 73 s mov m,e ; write "JMP 0005" 011C 23 # inx h 011D 5D ] mov e,l ; DE=0121h (points to 1st char) 011E 2E 0D 0A . db '.',cr,lf ; end of line, gets changed to (C3 05 00) (jmp 0005) ; jump to BDOS "type string" 0121 db 'Normal ASCII text goes here, ends in' db '' end That's it! Working out programs like this is a little like putting together a jigsaw puzzle. I wonder if there are any other uses for this method. Can we eliminate the "dollar sign" restriction? Is it possible to write a line that is both executable, and readable (self- documenting) when printed? Can it be done on an MSDOS system? How about other CPUs? Let's see what you can do! copyright 11/26/90 by: Lee Hart 323 West 19th Street Holland, MI 49423 phone 616-396-5085 $