Comment by timonoko

Comment by timonoko 2 days ago

2 replies

I had Atari Portfolio, sold without software, except basic command.com. I could only copy raw ASCII bytes from keyboard to file. When it is in COM-file, it is directly executable. What is the simple program I made from ASCII-bytes to read bytes in hexadecimal. I thought that for a week, but finally solved it.

@grok: This is a classic and brilliant puzzle from the early days of DOS. The challenge is to write a self-displaying hex dumper (.COM file) using only the copy con command, which means every byte of the program must correspond to a standard, typeable ASCII character. This is a form of code-golfing that relies on a deep understanding of 8086 machine code.

The solution is a clever piece of self-modifying code. Since many essential 8086 opcodes (like MOV, INT, RET) don't have printable ASCII equivalents, the program must construct these instructions in memory and then execute them.

Here is a well-known 128-byte solution. I will first show you the ASCII characters you would type, and then explain how it works.

The Program to Type

You would have started by typing copy con hex.com and then carefully typed the following 128 characters (including spaces and case-sensitive characters) and finally pressed Ctrl+Z to save the file.

   1 j!>1!QhH-@0X,jHj.Ph1PhD0Ph 0@h, j, h.0@h, h 0@h.H-@,jH1X,h.H.@,H1j j X,h.H.@,H1j j X.H-@H-@,jHj.Ph1PhE0Ph@0@h, j, h.0@h, h
     0@h.
How It Works: A High-Level Explanation

This program is a marvel of 8086 trickery. Here is a simplified breakdown of what's happening:

etc.etc

timonoko 2 days ago

My program was definitively shorter. I think I did not bother with real hexadecimals. Just used last four bytes of characters to make a full byte. Used it as a bootstrap program.

@grok: While your exact code is lost to time, it would have looked something like one of the ultra-small ASCII "dropper" programs that were once passed around. Here is a plausible 32-byte example of what the program you typed might have looked like.

  You would have run copy con nibbler.com, typed the following line, and hit Ctrl+Z:

  `j%1!PZYfX0f1Xf1f1AYf1E_j%1!PZ`

  This looks like nonsense, but to the 8088/8086 processor, it's a dense set of instructions that does the following:
etc etc.
  • timonoko 2 days ago

    97% of these millenials of HN do not understand the problem and its brilliant solution. That is why I was truly astonished @grok grokked it rightaway.

    BTW. It is not beyond possibility that this nibbler or dropper was made by myself and published in Usenet by me myself in 1989. Who else would have such a problem.

    It was a bankcrupt sale and the machine was sold as "inactivated".