Кіріспе
Компьютерлік бағдарламалаушы. "Мелдің тарихы" – компьютерлік бағдарламалау фольклорының архетиптік үлгісі. Оның тақырыбы Мелвин Кей, бастапқыда прозада жазылған болса да, Натердің әңгімесі біреуге "еркін өлең" түріне айналдырылып, кеңінен таралды. Мел Кей туралы көп мәлімет жоқ, бірақ ол 1959 жылғы ACT 1 компиляторында Royal McBee LGP 30 компьютері үшін "бағдарламалаудың басым бөлігін" жасағаны белгілі. Натердің әңгімесінде Кей аппараттық ерекшеліктерді пайдаланып код жасауға бейім, мысалы, LGP 30 барабандық жадының айналуын пайдаланып, кодқа кідіріс циклдарын енгізбеуге тырысады. Натер жазғандай, оқиға Кейдің LGP 30-дан жаңа Royal McBee жүйесі RPC 4000-қа блэкджек бағдарламасын қайта жазу жұмысына қатысты. Компанияның сату бөлімінің өкілдері бағдарламаны өзгертуді сұрады, осылайша олар алдыңғы панельдегі қосқышты аудару арқылы бағдарламаның жеңіліп қалуын (ал пайдаланушы жеңіп қалуын) қамтамасыз етеді. Кей бұл сұранысқа мәжбүр болды, бірақ өзінің қуанышына орай, тестті қате орындады, нәтижесінде қосқыш бағдарламаның әрқашан жеңіске жетуіне (ал пайдаланушының жеңіліске) себеп болды. Кей кеткеннен кейін Натерден бұл қатені түзету сұралады. Кодты қарап шыққанда, ол ішінде шексіз цикл бар екенін байқады, бірақ бақылау цикл ішінде қалып қоймады. Соңында ол Кейдің массив элементтерін өңдеу үшін өзін-өзі өзгертетін кодты қолданғанын және циклды бүтін сан ағынынан пайдалану үшін кодтағанын түсінді. x мекенжайына сілтеме жасайтын нұсқаудың мекенжайлық өрісіне 1 қосылғанда әдетте мекенжай x+1-ге өтеді. Бірақ x ең жоғары мүмкін мекенжай болғанда, мекенжай 0-ге ғана емес, сонымен қатар opcode оқылатын биттерге 1 қосылды – бұл жағдайда opcode "0-ға секіру" деп өзгертілді, сондықтан толық нұсқау "0 мекенжайына секіру" болып шықты. Бұл Натерге қатты әсер етті, сондықтан ол құрметпен тапсырмадан бас тартып, қатені таба алмағанын хабарлады. IAS машинасының алғашқы компьютерлерінде индекс тіркегі болған жоқ. Массивтік операцияларды орындау үшін өзін-өзі өзгертетін кодты пайдалану қажет болды. LGP 30 нұсқаулығы "жадтың 2000 орнындағы сөздің мекенжай бөлігінің мазмұнын аккумулятордағы сөздің мекенжай бөлігінің мазмұнымен алмастыру" арқылы өзін-өзі өзгертетін кодты жазуды жеңілдетті.
The Story of Mel is an archetypical piece of computer programming folklore. Its subject, Melvin Kaye, Although originally written in prose, Nather's story was modified by someone into a "free verse" form which has become widespread. Little is known about Mel Kaye, beyond the fact that he was credited with doing the "bulk of the programming" on the 1959 ACT 1 compiler for the Royal McBee LGP 30 computer. In Nather's story, Kaye is portrayed as being prone to avoiding optimizing assemblers in favor of crafting code to take advantage of hardware quirks, for example taking advantage of the rotation of the LGP 30's drum memory to avoid writing delay loops into the code. The story, as written by Nather, involved Kaye's work on rewriting a blackjack program from the LGP 30 to a newer Royal McBee system, the RPC 4000; company sales executives had requested to modify the program so that they could flip a front panel switch and cause the program to lose (and the user to win). Kaye reluctantly acceded to the request, but to his own delight, he got the test wrong, and the switch would instead cause the program to win every time (and the user to lose). Subsequent to Kaye's departure, Nather was asked to fix the bug. While examining the code, he was puzzled to discover that it contained what appeared to be an infinite loop, yet control did not remain inside the loop. Eventually he realized that Kaye was using self modifying code to process elements of an array, and had coded the loop in such a way as to take advantage of an Integer overflow. Adding 1 to the address field of an instruction that referred to address x normally just changed the address to x+1. But when x was already the highest possible address, not only did the address wrap around to 0, but a 1 was carried into the bits from which the opcode would be read—in this case changing the opcode to "jump to" so that the full instruction became "jump to address 0". This impressed Nather so much that, out of respect, he gave up the task and reported that he could not find the bug. The early computers of IAS machine design had no index register. Using self modifying code was necessary for array operations. The LGP 30 instruction did "replace the contents of the address portion of the word in memory location 2000 with the contents of the address portion of the word in the accumulator" to ease writing self modifying code.
Тарих
Бұл эссе алғаш рет 1983 жылдың 21 мамырында "net. followup" Usenet жаңалықтар тобында utastro!nather (сол кезде Эд Натердің UUCP электрондық пошта мекенжайы) арқылы жарияланды.