Showing posts with label compiler. Show all posts
Showing posts with label compiler. 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 

 

Thursday, June 27, 2013

Fortune Cookie in Hex Code

Twenty years ago, a friend of mine with two satellite dishes to the Chicago Board of Trade and the Chicago Mercantile Exchange had a problem. His IBM-PC/ATs, running the “Windows” interface for MS-DOS, and programmed in Basic, could not properly translate data.  The trading floors identified futures contracts by codes representing commodity and date.  Most troublesome was “26” because ASCII code 26, control-Z, looked like “End of file” to his computers. 

I had him lock me in his office on Friday and let me out on Sunday morning.  We actually worked together, ate breakfast and lunch, but overnight, I was alone with the computers and Peter Norton’s books on IBM-PC Assembler.  Working in Debug, after re-keying versions of the same code over and over, I said to myself, “I wish I had an editor” and I heard the voice of Obi-Wan Kenobi: ”Beware the dark side of the Force.” 

The project was successful. 

Afterward, I wrote a “Fortune Cookie” program for myself.  It is an old hack. On boot-up, the computer displays a random good-luck saying. I chose 60 of them and called the seconds counter of the system clock to point to one.  I wrote it in hex in Debug. 

B4 2C
CD 21
B0 46
F6 EE
05 20 01
89 C2
B4 09
CD 21
BA 18 01
CD 21
CD 20

Debug has an Assemble command to display a more English-like translation of the hex codes. Each of the sayings was limited to 80 characters with 40 more spaces for some margin and to create a buffer offset.

B4 2C        MOV AH,2C       Get the clock
CD 21        INT 21          execute
B0 46        MOV AL,46       Get the seconds
F6 EE        IMUL DH         multiply the DH by the seconds   
05 20 01     ADD AX, 0120    add 120 to that
89 C2        MOV DX,AX       put that number in the DX register
B4 09        MOV AH,09       display to screen
CD 21        INT 21          execute
BA 18 01     MOV DX, 0118    end of line
CD 21        INT 21          execute
CD 20        INT 20          quit

Negotiate to the Command Prompt. Enter DEBUG.
The command "d" is for Display memory.
The ? Question Mark brings up all available commands.
These are some of the 60 sayings:

Beam me up, Scotty: there's no intelligent life down here $
8 + 8 = 10 $
4 + 4 = 10 $
5 + 5 = 0Ah $
5 + 5 = &12 $
Daisy, Daisy, gove  m   y  r   ans er  ru  $
Hello, Dave, it's good to be working with you again! $
TRON to user: Send me a disk. $  
In the beginning was the Word $    
If A is A, how can X = X + 1? $ 
A program is a selective recreation of reality...$   
... according to the psycho-epistemology of the programmer$ 
I am alive and I have rights!$