Showing posts with label Basic computer language. Show all posts
Showing posts with label Basic computer language. Show all posts

Saturday, April 19, 2025

Bill Gates’s Source Code

Source Code is the title of Bill Gates’s autobiography. It also the eponym for the work that he, Paul Allen, and Ric Weiland did for Ed Roberts’s Altair 8800. Written on a teletype connected to a Digital Equipment PDP-10, their first task was to create a simulator of the Altair 8800 on the PDP-10. Then they wrote the source code for Altair BASIC. The BASIC interpreter was the product that Gates and Allen promised Roberts. In legendary hacker style, they did the work in under a week in bursts of long overnight sessions. 


For myself, reading through it, I enjoyed contemplating the roots of modern computer programming but really understanding it at that level would have required more effort than they put into it. So, I left it like a trip to an art museum: spend time understanding the work, but I will never create anything like it.

 


Note that the nested line numbers along the wide left side show that the publication is an archive:. a file saved later as a new file.

 

https://images.gatesnotes.com/
12514eb8-7b51-008e-41a9-512542cf683b/34d561c8-cf5c-
4e69-af47-3782ea11482e/
Original-Microsoft-Source-Code.pdf
 

The source code is commented at the right. 

https://images.gatesnotes.com/
12514eb8-7b51-008e-41a9-512542cf683b/34d561c8-cf5c-
4e69-af47-3782ea11482e/
Original-Microsoft-Source-Code.pdf

Also, in the story from Bill Gates, they had some discussion about whether to create an interpreter or a compiler. BASIC was intended as an interpreter so that each line could be debugged while written and run instead of writing, compiling the whole program, and then debugging the inevitable errors, as with Fortran or Cobol. 

 

The power in the interpreter for learners is that feedback is immediate. It is also true that at some level of complexity and volume, having the entire program in a body is convenient and we spent hours reading and debugging long programs on accordions of greenbar paper and carrying around decks of punched cards. 


While it was possible to Save a program under a filename, the fact is that such resources were not often available for those high school and college learners of 1969 to 1989 because disk drive space was expensive. Today, I am going to the Apple store to pick up a new iMac with a terabyte of onboard memory. When I took Fortran in 1976 at Lansing Community College, the whole town - Michigan State University, General Motors, and the State of Michigan - did not have a billion billion bytes of storage. 

 

PREVIOUSLY ON NECESSARY FACTS

Fortune Cookie in Hex Code 

John Kemeny Knew: We Shall Have Computed 

BASIC: Turing’s Truth 

Claude M. Watson 

 

Monday, December 18, 2017

Merry Newtonmas 2017

Celebrating Newtonmas off and on since 1984, this year I honored Sir Isaac by buying myself one of the commemorative 50p coins from the British Royal Mint. 

"Near the end of  his life, Newton described  himself to  his nephew and biographer,  John Conduitt, in these pleasant words: 'I do  not know what I may appear to the  world, but to myself I seem  to have been  only  boy, playing on  the seashore, and  diverting myself in  now and then finding a smoother pebble or a prettier shell  than ordinary, whilst the great ocean of truth lay all undiscovered before me.'

"Two hundred years later, biographer Milo Keynes wrote: 'This  life of apparent serenity was, however, far  from the  truth, for Newton is known to have  had most complex and difficult  personality.' His colleagues described  him variously as  fearful, cautious, suspicious, insidious, ambitious, excessively covetous of  praise and impatient of  contradiction. Even his closest relatives and true friends were modest  in their praise." -- "Sir Isaac Newton: Warden and Master of the Mint," by Michael E. Marotta, The Numismatist, November 2001. (George Heath Literary Award, 2nd Place, 2002.)


10 REM MIKE MAROTTA. FEB 5, 1987. NEWTON'S ALGORITHM FOR SQUARE ROOTS
19 LIMIT= .0001
20 PRINT "ENTER A NUMBER"
21 INPUT X
56 XN = X/2
60 R1 = (XN + X/XN)/2
70 IF ABS(XN-R1) < LIMIT THEN GOTO 80
75 XN = R1
76 GOTO 60
80 PRINT "THE SQUARE ROOT OF ";X;" = ";R1

PREVIOUSLY ON NECESSARY FACTS
Newton versus the Counterfeiter
Fig Newtons and Leibniz Biscuits
The Structure of Scientific Revolutions
Feynman's Rainbow

Saturday, December 21, 2013

The Code Book

In the University of Texas library stacks, looking for the early history of word processors, I was in the Zs and discovered that my book on codes and ciphers was actually checked out.  It took three editions to get it right.  The first 3000 years were easy enough to understand. I wrote programs in Basic that transposed and substituted right up through the Playfair and Vigenere ciphers.  RSA was a tough nut to crack; and I finally just cut-and-pasted one of their own graphics and quoted their own abstract. 
 As the IBM-PC finally overtook the TRS-80, other amateur cryptographers published more complete books of programs for personal computers.  By 1993 or so, with Phil Zimmermann's PGP becoming common in sig lines and footers, applied personal cryptography sped light years past high school algebra in Basic. PGP is now part of the Symantec suite. 

This week, news about more of Edward Snowden's leaks revealed that RSA (now an EMC label) took $10 million from the NSA and installed weaknesses to allow backdoors to its encryption.

Codes and ciphers are about more than sending secret messages, though there is that.  When the first public key cryptosystems were being publicized in the 1970s, authentication was a suggested application.  How do you validate a digital signature?  If you have the answer to the public key question, then you must hold the authenticating string. Although the first Diffie-Hellman knapsack system was later exposed for weaknesses, the problem itself and the algorithms for instantiating it remain as possible platforms. Others have been invented since.

Whether or not you rely on cryptography, and independent of which (if any) system(s) you choose, codes and ciphers are in and of your daily world. They make credit card transactions and cellphone handshaking possible.  They allow the efficient compression of messages. In fact, the common zip command on your computer is one way to encipher any message. It is easy to break, but the message is no longer in plaintext. Many other simple systems are available.  No better or worse than the Yale or Schlage lock on your front door, they do stop all honest people and many who are not.

Of all the secret messages from World War II, many remain unbroken because the need is gone. Those ciphers have kept their secrets. 

Of all the "unbreakable" codes, the one-time pad and the dictionary code remain easy and effective.

ALSO ON NECESSARY FACTS
Basic: Turing's Truth
Patterns in Pi
Open Secrets
BSides Austin 2013
Visualizing Complex Data

Wednesday, June 26, 2013

BASIC: Turing's Truth

Alan Turing showed that any finite-state machine can model any other.  That is how the team at Bletchley Park built the Bombe to imitate the German Enigma machine.  Today, we have “virtual machines” that let us put Unix and Windows on a Macintosh or Linux and Windows on a PC and so on.  The C language is actually an extension of itself, a realization by Kerninghan and Ritchie that inherent extensibility would allow programmers to create a language that would never become archaic.  And today we have C+, C++, and C#.  In fact, Ruby is just a set of macros written in C.  Once you have that, you can create your own Ruby objects, classes, and methods.  
 
Book cover shows silouette of man behind computer's punched card

The “Venture Rocket” blog presented a cute history of computer languages.  While one graphic did acknowledge Visual Basic as the seventh most popular development language, their history below that ignored Basic entirely. (They did cite Fortran and Cobol.) 

Earlier this month, I answered a challenge from the Praetorian computer security company to decipher this block of text.

Mpyza johsslunl ZWXY, Zluhabz Wvwbsbzxbl Yvthubz (Aol Zluhal huk Wlvwsl vm Yvtl), aolzl hyl aol budhclypun hsslnphujlz vm Aol Wyhlavyphu Nbhyk, luaybzalk if Jhlzhy av wyvcpkl aolpy lspal zljbypaf zlycpjlz huk luzbyl aol zhmlaf vm aol nsvihs Yvthu Ltwpyl. Hz aol zhfpun nvlz, "Hss Yvhkz Slhk av Yvtl", ovdlcly aol whao vm h Wyhlavyphu pz ulpaoly zayhpnoa uvy klalytpuhal. Aolyl hyl zlclyhs whaoz av qvpupun aol Wyhlavyphu Nbhyk, iba aol whao dlss-mvbuklk pu tlypa pz aol tvza ovuvyhisl. Pa pz mvy aopz ylhzvu aoha Jhlzhy ohz klcpzlk aopz zlyplz vm johsslunlz av qbknl aol tlypa vm wvaluaphs Wyhlavyphu yljybpaz. Fvb ohcl wyvclu fvbyzlsm ylzvbyjlmbs, iba kvu'a sla fvby nbhyk kvdu hz mhy tvyl kpmmpjbsa johsslunlz spl holhk. Av hjjlwa fvby ulea johsslunl, fvb dpss ullk av zluk tl h tlzzhnl vu Zrfwl. Av hkk tl hz h jvuahja, zluk h jvuahja ylxblza jvuahpupun aol alea "Zluhabz Wvwbsbzxbl Yvthubz" av "wyhlmljabz.jhzayvybt", aolu zluk tl h joha tlzzhnl av sla tl ruvd fvb'yl aolyl. Zll fvb vu aol ihaaslmplsk.

To do that, I wrote this program in BASIC.

10 REM Mike Marotta. June 21, 2013. Praetorian challenge.
11 REM: Claudic.bas compares cipher with known transposed key
12 REM: prints deciphered text
15 ON ERROR GOTO 199
20 P1$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
22 C1$ = "TUVWXYZABCDEFGHIJKLMNOPQRStuvwxyzabcdefghijklmnopqrs"
40 OPEN "i",1,"praeto.txt"
42 OPEN "o",2,"plain.txt"
50 LINE INPUT #1, X$
53 E = LEN(X$)
60 FOR I = 1 TO E
62 Q$ = MID$(X$,I,1)
63 REM Accept punctuation as is
64 IF ASC(Q$)<65 THEN PRINT#2,Q$;:
70 FOR J = 1 TO 52:
73 IF Q$=MID$(P1$,J,1) THEN PRINT#2, MID$(C1$,J,1);
80 NEXT J
85 NEXT I
90 GOTO 50
199 CLOSE 1: CLOSE 2
200 END

The program returned this decipherment.

First challenge SPQR, Senatus Populusque Romanus (The Senate and People of Rome), these are the unwavering allegiances of The Praetorian Guard, entrusted by Caesar to provide their elite security services and ensure the safety of the global Roman Empire. As the saying goes, "All Roads Lead to Rome", however the path of a Praetorian is neither straight nor determinate. There are several paths to joining the Praetorian Guard, but the path well-founded in merit is the most honorable. It is for this reason that Caesar has devised this series of challenges to judge the merit of potential Praetorian recruits. You have proven yourself resourceful, but don't let your guard down as far more difficult challenges lie ahead. To accept your next challenge, you will need to send me a message on Skype. To add me as a contact, send a contact request containing the text "Senatus Populusque Romanus" to "praefectus.castrorum", then send me a chat message to let me know you're there. See you on the battlefield.

Of course, this is merely a transliteration.  I already broke the cipher.  I found the common three-letter words, and guessed “the.”  I also guessed that the longest word would be “Praetorian” which then validated two of my letters in “the.”  All I wanted to do next was avoid the grunt work of writing out the answer. Computers are good for that.

Previously on Necessary Facts