Hacker News new | past | comments | ask | show | jobs | submit login
The original source code of Microsoft GW-BASIC from 1983 (microsoft.com)
546 points by AlexeyBrin 11 months ago | hide | past | favorite | 266 comments

The funny thing about this announcement is that a week ago I just found my old QBASIC textbook that I learned how to program with back in 1998. QBASIC was my very first programming language; I was a nine year old kid who loved computers and would read anything computer-related that was available, including my mom's textbooks (she was returning to college at the time and took some courses on computing and applications such as WordPerfect and Lotus 1-2-3) and software manuals. When we finally got Internet access in 1998 via AOL, I used the message boards to get resources on how to program. I was recommended to learn QBASIC, and I was told that QBASIC could be found on the Windows 95 install CD. I remember initially learning QBASIC through some web tutorials. My mom happened to have a friend who recently took a QBASIC programming course; her friend gave my mom her QBASIC textbook, which my mom then gave to me.

I'm now a researcher at an AI lab in Silicon Valley, and I just finished a five-week stint as a section leader for Stanford's CS106A "Code in Place" introductory Python course (https://www.stanforddaily.com/2020/05/07/students-instructor...). There's nothing like the joy of programming for the very first time, the realization that you can create something that works with code. Teaching those sections as well as finding my QBASIC book has reminded me of the feelings that I have from when I started learning how to program roughly 22 years ago. This release of GW-BASIC was quite timely for me.

I also started with QBasic (with no internet connection). Built a small choose your own adventure. Then I wanted to build a "password program" that would ask for a password before you could get "into the computer". I heard somewhere (schooljard) that you can put so called exe files into a file called autoexec.bat and they would start first. Alas QBasic could not build these magical files. I wnt to a store that had computer books and software in their music CD section and saw a huge Turbo Pascal book. It came with a floppy disk that had Turbo Pascal on it and 12 year old me was sitting on the floor of this store in front of the pop music CDs of the day and leafing through the book to see if you could build exe files :P

Lots of begging parents later I owned the book, struggled through it and build some small things. The interesting thing is I never programmed that much but was always fascinated by what amazing things existed. I guess I mostly liked reading about technology and using it a bit. I then mostly went through a phase of playing games on the family computer, completely destroying it when I tried to install Suse-Linux from a CD from some magazine (I was still very young and didn't fully understand what an operating system even is but the article made it sound very cool). My next phase of interest was when I discovered the Llama book and O'Reilly books in general. Programmed some Perl, picked up some other languages but never really build anything worth noting. And then the last experimental phase was when I stumbled upon "Smashing the stack for fun and profit" and into the huge field of computer security. Went through a lot of "crack mes" etc. and just had a fun time. After that I started to understand how things worked a little more and went about it in a more structured way that eventually lead to a CS-ish degree. But I still have the fondest memories of the time when I basically knew nothing and was just fiddling around and then pooof sometimes cool stuff happened, sometimes stuff broke :P

So yeah tl;dr...if it wasn't for stumbling onto Basic some day I might have never gotten interested in anything related to computers.

4.5 definitely had a compiler in it, as did later versions (after the first time I found 7.1, I stopped using the others). I should note that I'm not up to speed on the difference between QBasic and QuickBasic, though--so far as I know they're the same product, but there might be differences.

My favorite program for autoexec just had an infinite loop until you hit Ctrl+C.

I asked my dad, who programmed in C for work, to teach me how to program, but he was a bit too tired after work, and compilers weren't free back then. Instead he pointed me to QBasic, thinking I'd goof around with it for a little while and probably move on to the next thing. One day I pulled him in to show him a wireframe 3d graphics program I'd written, you could rotate simple models around, and he went "oh no, I'm so sorry, you've learned too much QBasic. I'll teach you C". I remember using GWBasic as well, but I don't think I made anything more than little Choose Your Own Adventure-type stories, i.e. a few if statements.

My first attempt at coding was with a Java Programming For Dummies book around the Java 1.1 era, using applets. That was a terrible choice for 12 year old non-native english speaking me, and I never got too far.

Somehow I ended up trying QBASIC a couple of years later and programming suddenly became a lot easier and fun. I especially loved that you could easily switch to graphics mode and just start drawing pixels and lines to the screen, it was like the perfect blank canvas to try out different ideas for a curious young mind.

Alas, that easy graphics programming environment - so critical to my early engagement with programming as well -is nowhere to be found. Even in the Python ecosystem, nothing approaches the simplicity of "SCREEN 12" and immediately being able to use POINT, LINE, CIRCLE etc.

Python ecosystem is precisely the one that does approach this level of simplicity, because it has turtle graphics out of the box. Here's one complete example from the docs:

   from turtle import *
   color('red', 'yellow')
   while True:
       if abs(pos()) < 1:

This does "approach the simplicity of "SCREEN 12" and immediately being able to use POINT, LINE, CIRCLE etc.":

    from pygame import *
    pantalla = display.set_mode((0, 0), FULLSCREEN)
    draw.rect(pantalla, 128, (50, 100, 200, 400))
That's from https://github.com/kragen/pyconar-talk/blob/master/helloneg1.... There are some more examples in that directory. They use PyGame, though, which isn't installed by default like POINT.

By default Python comes with Tkinter, though, which lets you do this:

    from tkinter import *  # or Tkinter in Python 2
    w = Tk()
    button(w, text="Not OK", command=w.destroy).pack()
That's a fuckload more than you can do graphically in GW-BASIC.

For graphics, though, you're better off in JS and DHTML. In http://canonical.org/~kragen/sw/dev3/tweetfract.html I have an HTML canvas which renders a fractal if you click on it, in 140 bytes:

    <canvas onclick="c=this.getContext('2d');
    function d(x,y,k){c.fillRect(x,y,1,1);
Moreover, if you put that on the web, you can link anyone in the world to it, and they can run it just by clicking the link. And you don't have to start that complicated; this works too:

    <b onclick='this.style.color="red"'>DO NOT CLICK ME</b>
You don't even need a server; you can put that into the address bar of your browser as data:text/html,<b onclick='this.style.color="red"'>DO NOT CLICK ME</b>.

LÖVE2D comes with a bunch of simple examples, like https://github.com/love2d-community/LOVE-Example-Browser/blo...:

    -- Example: Loading an Image and displaying it
    Load an image using love.graphics.newImage(image_path)
    Draw it using love.graphics.draw

    function love.load()
        image = love.graphics.newImage("assets/love-ball.png")

    function love.draw()
        love.graphics.draw(image, 400, 300)
LÖVE is programmable in Lua, like Minetest and WoW, and it gives you rotatable, alpha-composited 2-D sprites with collision detection and particle systems.

But Proce55ing is the paragon of this stuff. http://sketchpad.cc/, which uses processing.js, starts you off with this:

    // Pressing Control-R will render this sketch.
    int i = 0; 
    void setup() {  // this is run once.   
        // set the background color
        // canvas size (Integers only, please.)
        size(300, 300); 
        // smooth edges
        // limit the number of frames per second
        // set the width of the line. 

    void draw() {  // this is run repeatedly.  
        // set the color
        stroke(random(50), random(255), random(255), 100);
        // draw the line
        line(i, 0, random(0, width), height);
        // move over a pixel
        if (i < width) {
        } else {
            i = 0; 
That just fucking blows away anything I ever created in years of messing with GW-BASIC. And sketchpad.cc lets you edit your code in real time with someone else, and also save a link to the sketch you've made so that anyone else can see it. Still, I translated it to Python for my talk about this stuff at PyCon Ar (https://github.com/kragen/pyconar-talk/blob/master/hello1.py):

    from pygame import *
    from random import randrange

    pantalla = display.set_mode((0, 0), FULLSCREEN)
    ww, hh = pantalla.get_size()

    color = Color(64, 64, 192)

    for xx in range(0, ww, 5):
        h, s, v, a = color.hsva
        color.hsva = xx * 270 / ww, s, v, a # cambiar hue

        draw.line(pantalla,                 # surface
                  (xx, 20),                 # punto de inicio
                  (randrange(ww), hh - 20), # punto de terminar
                  10)                       # ancho de rayo
        display.flip()                      # para mostrar
Maybe the biggest environment for this kind of thing nowadays is Roblox, which has a couple of million people writing games in Lua in a 3-D world. It's not free software, but neither was GW-BASIC at the time.

Eat me, GW-BASIC.

I think I had the same book!

I wrote my first line of code on a game console without persistent storage. Coding is everything that makes computer a computer.

Now, some kids in college have an impression that coding is less relevant for a CS career.

When I was a kid my brother and a friend and I would spend hours punching games into a C64 out of the back of byte or compute magazine. We would work in shifts, one typing, one reading, and one proofreading to make sure what was said is what showed up on the screen. Usually by the time we were done it would be 4 a.m., so we would play the game for a little bit and then carefully tuck the C 64 in the corner so nobody would trip on the power cord. We didn’t have the floppy or tape drive, so the game only would live for as long as the power was on.

Good times. The best was when there was a typo or a bug or it just didn’t work. Esp. the machine code that was just pages of hex.

"Computer science is no more about computers than astronomy is about telescopes." - Edsger Dijkstra

Yes, then I had a computer science student who lost three years of work because he never made a backup of the files on his mac computer.

Learning nothing but theory can come back to bite you some times.

LOL. I had three graduate students (PHd CompSci candidates) working for me back at UMass. I come around the corner to see them all clustered around one of the PCs. Apparently one of the graduate students had slid a CD-ROM between two of the blanking panels instead of opening the CD-ROM tray. They were trying to figure out where the CD had gone.

After a chuckle, I showed them how to open the case and retrieve the CD.

That quote is misattributed and I also think it is not something Dijkstra would have said. Quite the opposite actually. However, I think this quote from him is much more beautiful:

In their capacity as a tool, computers will be but a ripple on the surface of our culture. In their capacity as intellectual challenge, they are without precedent in the cultural history of mankind.

(Turing award lecture, 1972)

He did say it because I heard him say it. The sentence just before was: "Our field should be called 'Computing Science' rather than 'Computer Science.'"

In my language most university courses/majors are actually named like that. Common names: "Ciências da Computação": Computing Science "Engenharia Informática": (Informática is usually translated as computer or computing science, or just computing) CS Engineering Less common: "Ciencias dos Computadores": Computer Science "Engenharia Informática e Ciências dos Computadores": I bet you can translate this one

Dijkstra probably assumed that you would have the programming chops and language knowledge.

As our second best DBA did when I worked at BT - he had worked at NPL and Dijkstra was his boss

As a child, I grew up with BASIC and Turbo Pascal. Your comment made me wonder, which version of BASIC that was.

It turns out, I was using N88-BASIC(86), developed by a Japanese team. Reverse-engineered from N88-BASIC to run on 8086 processor, and produced bytecodes compatible with Microsoft's GW-BASIC, which was released around the same time.

> There's nothing like the joy of programming for the very first time, the realization that you can create something that works with code.

That's so true. I'm thankful that I had use of a computer as a toy, essentially, and the joy I found in creative programming carried me far into the present. I'm not in the education field (at the moment) but would love to, as I get older, to do my part in passing down the torch, to inspire younger people to feel the magic. In my current role at a company, as part of the leadership, I also try to find, share, and encourage that joy.

QBASIC was also my first programming language. Learned it my Senior year in high school computer programming class back in 1995.

I still have the Qbasic for dummies book my good friend lent me probably 20+ years ago, back then I was playing with Qbasic even though it was old

I remember changes the variables in the gorilla banana toss game that came with qbasic ~ first time seeing changes in programming changing the game and it was magical.

My friend ended up being a great programmer and I'm doing e-commerce front end / project management work. Great times and I'm thankful for the experience

Mine was TI-99/4A BASIC. I wish I had a printer back then because I probably would have printed out some of my programs and I'd love to see what they look like today.

> There's nothing like the joy of programming for the very first time

The first time I had an idea of what programming was, was when I saw my brother trying to explain to me that the window had code that ran it. Of course, I ignored him...

We later did Delphi at school, which was maybe a crazy pedagogical decision. The only thing I would say pedagogically useful was that you wrote PUBLIC and PRIVATE for variables, but C or Java has that for functions.

One way in which I would say my fascination differed is this:

> the realization that you can create something that works with code

A lot of programmers mention the ability to write concrete instructions as their first realisation. OP is closer to my experience, but to me the a-ha moment was more surreal: It is strange to me, even today, how a computer can even exist at all. I often refer to that when I think the world is unstructured.

So, things like NAND gates (and fully homomorphic encryption) are almost mystical; more generally, I feel like computers are something of a vindication for mathematics that started in the Renaissance. Things can be mystical and mundane at the same time. There is a joke about this along the lines of a specific type of medical doctor, but I don't think I can post it here...

C doesn't have "public" and "private" at all. Java has them for both functions and variables (so long as they are members), as does Delphi. The only difference between the two in that regard is that Java requires visibility on every declaration, while in Delphi using the keyword sets it for all following declarations, until another keyword changes it.

On the whole, I don't see a problem with doing Delphi (or Free Pascal + Lazarus) in school, especially if students have studied Pascal earlier - it teaches them many of the same concepts they'll later see in the likes of Java and C++, and it gives them powerful tools to create "real" GUI apps. There are better options these days, but it's not the worst one.

You're right about C; I forgot that Java added it.

I think that Delphi could be a good language to teach in, but in practice it doesn't seem to be. You lose a lot of students along the way that feel it's irrelevant. In classes where you have a really good teacher they would add in "modules" of their own, irrespective of whether the syllabus makes sense or not. Often, however, a class barely gets through the standard workload to start off with.

Borrowed mine from the library at age 13 (`98) when i got a hand-me-down Apricot from a friend.


Just realised we have Apple computers, Apricot computers, Blackberry phones, Raspberry (Pi) computers – is there some kind of fruit obsession in IT I've missed out on?

There was Apricot too, https://en.m.wikipedia.org/wiki/Apricot_Computers.

And Cherry made peripherals/components, https://en.m.wikipedia.org/wiki/Cherry_(keyboards).

I guess such names make for simple logos.

I mentioned Apricot :)

Cherry, yes – good catch!

Tangerine computers too, back in the day, Acorn (technically a fruit)...

Apple from Beatles and for years Apple cannot release any music from Beatles to avoid confusion of the brand name (of Beatles).

I ran accounts on an Apricot for a year or so. It was actually an improvement over the PC, using software fonts etc, and the spanking new 3.5" diskettes. I don't think it was 100% compatible and sadly didn't do particularly well.

I'd forgotten about the cool little LCD display until I looked up your link to it.

I recently found my copy of the Precomputer 1000 manual that I learned BASIC with around 1993. It's now mounted in a shadow box!

That's awesome! I enjoyed my Precomputer 1000 so much when I started digging into the BASIC module, that I experienced my first bout of insomnia when I was in second grade (around age seven). Earlier that day I had discovered the trigonometric functions, and they fascinated me so much that I obsessively spent hours running different numbers through them, individually and in combination. I didn't understand trig at that age, so I didn't know that significance of the calculations, but I knew I wanted to develop an intuition for them.

That night as I tried falling asleep, the numbers and functions were all I could think about, preventing me from sleeping. It scared me, but I knew that excitement would lead to something interesting someday. It did: I can trace my academic work and career directly back to that experience with the Precomputer 1000.

To this day, I try to limit my bedtime reading to fiction, because when I read technical non-fiction, I get too hopped up on knowledge to want to fall asleep.

I started with QBASIC too.

Except I'd learned Speccy Basic from an Usborne book (Prior to getting access to a real computer) and as a result some parts of my programs failed to work correctly (usually stuff around PEEK and POKE)

It was a while before I worked out that the issue was :-)

I have a copy of the GW-Basic 3.2 user manual, and the MS-Dos 4.0 manual under my desk at the moment. I think they are still pretty common books, I mainly hold on to them for sentimental reasons.

If you love QBASIC you might be interested in the qb64 project.

My first foray into BASIC was BBC BASIC. I was an 11 year old in the eighties and attending comprehensive secondary school in the UK.

We had a school 'computer room' which hosted ten BBC Micros. The mathematics teacher at the time ran an after school computer club and it was alleged that the last 30 minutes were unstructured and some students had managed to get a cassette tape copy of Elite (now Elite Dangerous) loaded onto some Micros. This absolutely blew my mind and I had to get in there somehow. The problem was I knew nothing about computers and I had no computer at home to practise on (this was also not likely to change as I was part of a financially stretched single parent family).

What I did manage to do however, was get a copy of Computer Weekly from WH Smiths. This particular edition was running a monthly section on 'Programming in Basic'. Now as said I had no computer, but I was not deterred into letting that stop me, so I wrote my first program on some A4 paper. As with many first time programmers, It was a text based adventure game with a multiple choice engine:

You find yourself facing the dragon. Do you?

A, Fight the dragon B, Run away C, Use the magic potion the elf gave you. D, Do nothing.

The program itself consisted of nothing more than print statements, capturing user input and then conditionals leading to "goto line X" statements. Quite soon this got hugely un-manageable and I realised this programming stuff was not as easy as I thought. Somehow though, I summoned the confidence to take it to the math teacher for his feedback and thought perhaps he might see some promise in me sufficient to get me into the club. He leafed through a few pages and said I could join. He later told me that he was more impressed that someone would attempt such an effort, more than myself showing any sort of genius.

Years later now, that snotty nosed inquisitive 11 year old is now a Principal Engineer with a long career spent building many, many systems with many engineers. I have always remained a software engineer , while colleagues have drifted off into management. I will be honest, I am still as excited about tech as I was when I was young upstart. I am also still all to willing to take risks, fail and bite off more that I can chew. In reflection that sense of false bravado is what has led to my career being as successful as it has been. It's never been about how beautiful my code is or how well I understand the deep idiomatic nature of whatever the new language is. It’s been my naive over confident nature to always take on more than I can handle.

Is it really a good idea to be just as enthusiastic about tech now as you were then? Few things are what they say they are any more. Everyone's clawing at your personal data. With a few large exceptions, all the innovation goes to things make both us and tech cost less to management, or manipulate our attention, or track us because business types think theres gold in them thar hills. Half-assed attempts at things like "agile" abound so that we can please nosy managers. "Code as art" falls by the wayside as many of us are reduced to stringing together various services for a living

Tech isn't fun anymore...

Sure it is!

Go small. Embedded / retro / various micro controllers are a ton of fun, and they have most of the feel we all experienced back then too. A decade ago, I had a bunker. Unix, Linux, Windows, BSD, OS X, all piled into a basement running pretty much everything. It was serious fun building it up, and then when I got there?

These dark times took a lot of the fun out of it. So, I literally gave the best away to a younger guy I could see drooling over the whole works and ordered some micros. Back to my roots.

Assembly language was fun in the 80's. It's fun now. Hooking shit up to do things? Yup. Even more fun now because there is so damn much just laying around, and we can get almost anything delivered for a song too.

Back in the day, I actually got good at vacuum tubes. That is what was laying around, and I was in poverty at the time. (Which actually was good for me personally, no worries, no regrets, no harm done)

My point being:

Seeing and channeling that excitement will pay off for most who experience it.

Yeah, big brother networked computing is in a dark time. Oh well. It's a big world of tech out there.

And, these days?

Hell, we are super good at electro mechanical. So, a young person can get a look at that, learn to program, control things.

Then, head over to bio tech, which will soon be electro-bio-mechanical, among other things, and likely experience a boom and sense of wonder at it all same as we did.

I pretty much am against snuffing out those little sparks. Sometimes there is only one. Sometimes they don't come back.

I would have hated to see my own snuffed out. At that time, I probably would not realize the impact. But today I would, and do not want anyone with inclination to self-learn, grow, do, build, experiment, teach, go into business, to lose any of that inclination just because we see some bad times right now.

All of the things you listed are why I work in embedded systems / IoT rather than web stuff.

"Tech" isn't fun anymore but actual technology is still fun.

Good to meet another BBC BASIC aficionado. I did scrape enough money together to buy a BBC model B (was an engineering freshman at the time) and I used the Beeb as my primary computer probably longer than I should have. Wrote a word processor in BBC BASIC, which I used for my final thesis and also a complete Monopoly game. Loaded off tape. Fit in 32K memory....

I'm glad that BBC BASIC offered a more structured version of the language, with named subroutines and all, since it allowed me to move fairly painlessly to my next language, Turbo Pascal on a PC, followed by Turbo C.

Another BASIC adventure game writer checking in. Thanks for sharing your story. It brought a smile to my face.

Ones of my early long lasting memories from 7th grade computer lab, my first exposure to programming, was helping another student kick off a deeply nested tangle of IF statements to build his own adventure program.

Years later learning about the Z-machine was a revelation.

I can relate! My first BASIC programs were on paper too. For similar reasons.

In my case, it resulted in a trip to a neighbors house where I could input and run some programs. Mine didn't work, but it did not take too long to fix that.

My own story is not dissimilar :-)

Wow, what a blast from the past. I learned to program with BASICA.EXE and GW-BASIC as a kid in the late 80's.

I just noticed that microsoft has also released the source to MS-DOS 2.0: https://github.com/microsoft/MS-DOS

I don't think I ever imagined that I'd be able to "look behind the curtain" like this, let alone that Microsoft would come to embrace open source.

From there I moved on to Turbo Pascal 3.0, and then Borland Pascal 7.0 (which I loved - super fast compiler and superb IDE - many examples and comprehensive documentation - which were a must in the pre-Internet era), then Borland C. And then Linux and gcc for the following two decades.

Thirty years later, I still miss the Turbo Pascal / Borland Pascal, Borland C(++) experience. Few, if any, 'modern' IDEs have yet reached the simplicity and ease of that development environment.

I've been toying with Turbo Pascal 5.5 running on FreeDOS on an old laptop. There's something really relaxing about it, compared to modern programming.

Turbo Pascal 5.5 with objects was the pinnacle of my programming enjoyment. Python 3 is catching up.

Because the development itself has changed immensely. The closest experience today is probably the one of developing for Arduinos.

Homebrew scene for consoles and graphing calculators too, I'd say. I think the overarching reason is that you know the platform you're developing for all the way down to the hardware.

I loved Turbo Pascal back in the 90s, that was the first IDE I ever used.

I think Visual Studio 6 is equivalent in ease of use and user experience -- that's what I learned C++ on back in the early 2000s, before the influx of Java and Python into academia.

Free Pascal is still around, and still includes a text mode IDE written in their own fork of Turbo Vision.

Am actually totally digging JS DOS, the emscripten build of the DOSBox emulator. The performance is phenomenal in the browser, including vsync. Here is an example (CPU intensive) of multiple 64k demos running simultaneously on a single web page ;)


8 FPS on MacBook2019 and Chrome...

27 to 31 fps on a 2.6 GHz MacBook Pro (Late 2013) in Safari. Try Safari, maybe?

I’m getting 6fps on my iPad Air 2 in safari...

Similar story, learned to program using GWBASIC and loved figuring out how to recreate Conway's Game of Life, fern fractals, etc on my own. Though 25 years later can't pass FAANG whiteboard interviews with just an EE degree!

> Though 25 years later can't pass FAANG whiteboard interviews with just an EE degree!

Nor could I. But I think that's ok.

I remember trying to make a game using a BASIC interpreter on Sinclair ZX80 Soviet clone and failing. Yet, here we are on HN taking about tech and leading lives in tech, whatever that means for us.

I don't know where I'm going with this, but I'm glad for that experience and where it got me. And, I guess, I'm glad that you're here as well, stranger.

Haha likewise mate, cheers

You and I both - first time I ever touched an IBM PC XT (in my Dad's office), I immediately fired up BASIC and went to town (had already been programming BASIC for 18 months by that time).

It was the first time I ever saw him just stare in awe at me like I was an alien's child! :)

And me! (and a few hundred/thousand people in this great forum)!! Oh I still remember that Amstrad PC1512!!! What a carefree age that was...

I learned Locomotive Basic on a CPC464, then moved up to a PCW8256 before transitioning to a PC1512. Those were the days :)

I learned to core in C on a PC1512, using Walter Bright's rather nice Zortech C compiler. TP3 was indeed the dog's bollocks back then, too.

I recall GW-Basic as well. I ended up with a bunch of random software from my dad at the time. One of the included items was a basic compiler. Showed me how much faster compiled code could be.

I then went on to use the various Borland products.


Has anyone got it compiling yet?

I've tried in DOSBOX, using this MASM from this (possibly sketchy?) site: http://www.mediafire.com/file/x13v7gqqmw1pom7/8086_Assembler... . The output is as follows:

    Microsoft (R) Macro Assembler Version 5.00
    Copyright (C) Microsoft Corp 1981-1985, 1987.  All rights reserved.
    Object filename [GWMAIN.OBJ]: Source listing  [NUL.LST]: Cross-reference [NUL.CRF]: End of file encountered on input file
    GWMAIN.ASM(3568): warning A4085: End of file, no END directive
    Open segments: CSEG
    OEM.H(55): warning A4016: Reserved word used as symbol: SHORT
    OEM.H(102): warning A4016: Reserved word used as symbol: LENGTH
    OEM.H(165): warning A4016: Reserved word used as symbol: LENGTH
    End of file encountered on input file
    GWMAIN.ASM(3568): warning A4085: End of file, no END directive
      51620 + 169980 Bytes symbol space free
          4 Warning Errors
          1 Severe  Errors
TASM (version 2.5) gives a similar error.

Mentioned it in another reply, you'd probably want to start with the MASM and LINK from the MS-DOS 2.0 release.


Probably you want to try out PCem when dosbox doesn't do the trick. Was a lot of fun for me! I made a small page about PCem here: https://juangacovas.info/doku.php/windows/howtos/pcemu-page

Unfortunately, I can't get MS-DOS 2.0 to run in DOSBOX ("Invalid COMMAND.COM") and running MASM.EXE directly gives me some really interesting errors (looks like it's reading uninitialized memory).

I think you're on to something here, though!

Good job! I'm going to throw some cycles at this, this holiday weekend.


DOSBOX can't run older DOS programs, try my emulator: https://github.com/dmsc/emu2 , ASM86 runs in it.

Also, as written in the blog post, the .ASM files are not the original sources, more a temporary expansion of these for the given target. Looking at their binary form, all .ASM files end with zero characters instead of, for example, 0x1a with which .H files end. It can be that some tools (different than those originally used) have problems with the zeroes at the end?

That's a good observation. I tried stripping zeroes, but unfortunately it's the same error message.

I'm no assembly genius, but the GWBASIC source is for the 8088 CPU and not the 8086 (the chips are slightly different) - maybe that is why? Also, DOSBox is not 100% compatible with original hardware - Try it again in a VM under VirtualBox maybe?

The 8086 and 8088 are architecturally identical and run the exact same code. The only difference is that the 8088 runs an 8-bit external bus.

  --------- ---- -- ---- ----- --- ---- -----
  --------- ---- -- ---- ----- --- ---- -----
I love comments like these. They also say that the GW refers to Bill Gates, as in Gates William but I don't know the details on that.


Edit: Forgot to say, I was 3 years old when they wrote this code, wow! and I learned programming with GW-BASIC in the late 80's.

The meaning of "GW" is controversial according to the Wikipedia entry for GW-BASIC [1]:

> There are several theories on what the initials "GW" stand for. Greg Whitten, an early Microsoft employee who developed the standards in the company's BASIC compiler line, says Bill Gates picked the name GW-BASIC. Whitten refers to it as Gee-Whiz BASIC and is unsure if Gates named the program after him. The Microsoft User Manual from Microsoft Press also refers to it by this name.[citation needed] It may have also been nicknamed Gee-Whiz because of its numerous graphics commands. Other common theories as to the initials' origins include "Graphics and Windows", "Gates, William" (Microsoft's president at the time), or "Gates-Whitten" (the two main designers of the program).

[1] https://en.wikipedia.org/wiki/GW-BASIC

Those are all too clean for 1983 Microsoft. I'm more likely to think it's some cutting inside joke, maybe an IBM insult.

If they said it was say, something like George Wallace Basic, because they segregated it from IBM basic and only put it on the clones as a "separate but equal basic" I wouldn't think twice.

I can even imagine the meeting

"We can't say this is George Wallace basic, no".

"Fine, it's GW basic. Say it means gee wiz or some shit, just make something up"

The PDP-10 comment hints at a key innovation by Paul Allen: BASIC was originally ported to multiple 8-bit CPU architectures by first writing an emulator for each CPU that ran on DEC systems.

There is file OEM.h that gives a hint how porting worked.

Another interesting project:


  ;The following block of externals was added on Dec 19, 1982 when BINTRP was
  ; Split up after the freeze of GW-BASIC Version 1.0
  ; This Split-up was not reflected in the PS1:<BASIC>BINTRP.MAC source.
  ; See Tom Corbett if you have any questions.

It's really enjoyable to look at the source. These days one I feel it's quite rare to see assembly code not as an output from a tool like IDA Pro.

If I remember correctly, the size of a compiled GWBASIC.EXE file was about 80 kB.

What feels weird though is seeing all the files on GitHub last modified "38 years ago," which by the way, also includes the file CODE_OF_CONDUCT.md.

Another temporal anomaly is the license file. It's using the MIT license, but the timestamp is about 4 years before the MIT license existed.

Its not anomaly, just Orwell's "1984" as is.

I'm not familiar with modula but this doesn't appear to be a valid program ;)

I think it wasn't until Vim 8 that the default for .md files became markdown.

.md is mentioned as an extension in the text/markdown RFC from March 2016: https://tools.ietf.org/html/rfc7763

(Vim 8 was released in September of the same year.)

You think there weren't codes of conduct back in 1983? ;)

All those years, people thought MS was hostile to open source, but their commitment was right there all along, in the GW-Basic code of conduct, with a link to their website too!

Markdown itself is from 2004 but the .md extension/suffix wasn't used for it until sometime later (not really sure where it appeared first).

MDCD[0], an open source DOS archiver, used the .MD extension in 1988.

[0] https://www.sac.sk/download/pack/mdcd10.zip

I wasn't particularly aware of it, but it looks like the TRS-80 BASIC that introduced me to programming was also probably developed by Microsoft, and I'm pretty sure that AmigaBASIC was as well. I think I also used QuickBASIC on the Mac a little, but what I particularly remember was a demo for it that visually showed different sorting algorithms, that inspired me to do something similar in Pascal.

Microsoft BASIC was all over the place in the late 70's and early 80's. Before MS-DOS, Microsoft was basically a programming languages company (and they still are today). They licensed their BASIC to many other companies, even Apple.


And I think most if not all MSBASIC ports for early PC's had a memory leak if you did not break out a FOR loop in the right way.

I am a bit rusty but this sows the problem:

10 L = 4720 FOR I =1 TO 1000 STEP 2


35 IF I = l GOTO 6999


6999 STOP

What you needed to do was set I to the end condition as part of the break out of the loop.

There was also a lot of aggressive compression done to reduce program size PET in particular munged every thing up putting as many statements on one line as possible

There was a bug in the TRS-80 basic (which was indeed Microsoft). It had an "on x goto" command that allowed the program to move to different lines depending on the value of a variable:

ON X GOTO 200,300,400,500 depending if x=1, x=2,x=3...

They'd obviously used the same parser for the standard "If a=1 then goto 200" construct, which allowed an undocumented shortcut of "If a=1, 200" which a few people noticed and started using. However, a later model fixed this, which broke a number of programs.

This was legal in BASIC from the very first versions of the language:

   IF a=1 THEN 200
and when they added ON..GOTO, they basically made these two mirrored syntactically. So you could do:

   IF a=1 GOTO 200

   ON a THEN 100,200,300
(I suspect it was simply treated as identical token?)

ooh I never worked on TRS80's - so they had a version of the Arithmetic IF :-)

I could have Told BillG that was bad idea back when I was 19

  x = x + (x < 5)

No If needed.

Atari Basic would allow crazy things like:

  10 Goto ((x < 5)*100) + 50
Goes to either line 50 or 150, depending on the comparison result being 1, or 0)


  Goto (100*x)
Faster On goto with no checking, lol.

Bill Gates was not involved with the original Atari Basic. That could be purchased on a cartridge for running MS Basic programs.

Did Atari BASIC use 1 for TRUE? Most BASICs used -1 (i.e. all bits 1), because this allowed the same operators to work for both bitwise and Boolean logic, in the absence of a dedicated Boolean data type.


Yes, it used 0 and 1. And it did not contain bitwise ops. Those were quite the surprise!

My first efforts were in Applesoft. Computers at school. Got an Atari machine and programmed the crap out of it. Wrote my own assembler, a few games, etc...

Then I got an Apple and finding them in Applesoft was a nice surprise! Prior to that, I thought they were an assembly only thing.

The trade off in the Atari basic was doing things mathematically was pretty easy and it generally, but not always, was faster.

A few of us wrote fairly complex programs with basically no if statements. Kind of a fun way to think about things back then.

I much prefer -1 and 0 and the bit ops, frankly. Internally, I remembered this kind of thing as "really fucking true" as in every bit better signal, or it's false!

The problem with using bit ops as logical is that they don't short circuit. Although it was unfortunately common even in languages that had proper Booleans at the time - e.g. standard Pascal didn't have it, and Turbo Pascal required a compiler directive/switch to enable it, which few even knew of. So it feels worse in retrospect than it actually was back then.

On the other hand, one thing that BASIC still has to this day (in VBA) that no other language I can think of does, is bitwise equivalence (EQV) and implication (IMP) operators. Furthermore, since VBA has a Boolean data type, these operators are also available for Booleans; implication comes in handy sometimes.

Not sure what you mean by short circuit.

I had no idea about those VBA features. Will read about them.

Having the bit ops themselves is a very strong feature.

My simple assembler would definitely been faster and simpler with them. Graphics, some math, all benefit. People would make little language extensions or callable machine language routines to make the bit ops available.

In basics with bit ops, and the -1 as true:

X = 100 & (y = 5)


X = 100 * (y = 5)

Not doing the multiply seems like a net gain in a limited CPU too. That basic did not really have types, like MS basic did. Pretty much floating point only.

Interestingly, basics that have the bit ops do not always allow the expressions in a goto. Or, could just be my own memory, or lack of trying. Not really needed.

In fact, outside of trying to optimize, or just explore the language, the only case that made real sense was a sort of jump table making good use of line numbers like one would do with memory addresses in assembly.

Say, branching directly on a checked or masked character value.

And the spiffy thing was making pseudo labels. Put line numbers into variables and use them like labels.

Foo = 1000

Goto Foo

Overall though, it was a weird little basic. It nicely supported the machine, and the device independent I/O system in the OS ROM, but was slow otherwise.

This guy has actually made an N: driver meaning Atari Basic programs written long ago can operate across the Internet today.

Lol, cool old stuff.


Short circuiting means not evaluating the right side if the left side is sufficient - so e.g. in (Foo() OR Bar()), if Foo() returns true, it won't even evaluate Bar().

Most modern languages are like that, but BASIC is an exception to this day - even VB.NET still doesn't do short circuiting by default. You need to use special operators, AndAlso/OrElse, to get it.

Computing the line number in a GOTO is definitely an extension - the original Dartmouth BASIC never had anything like that. For jump tables and such, you were supposed to use ON..GOTO.

Makes perfect sense. Maybe nobody cares enough about Basic, or figures there are a zillion better performing options? Seems like an optimization like that would have been done at some point

Yeah, the computed goto is odd.

Back in the day, I used it and some conditional math to greatly shorten and improve performance in some programs. My first machine was only 16k. Using the graphics system in any meaningful way cost a lot in terms of program space. So, every dirty trick, including poking new addresses into string variable address pointers to overlap the graphics screen got done.

Absolutely terrible code though. I am sure if I saw some of that code today, I would have a bugger of a time sorting it out.

There were no bitwise operators in the Atari BASIC, and numbers in the tokenized program were always stored as floating-point numbers in BCD (Binary Coded Decimal) format.

10 CLS

10 is always CLS

In my opinion this was not good. Basic was considered harmful and was possibly the first computer thing to be considered harmful. Line numbers, REM statements, the GOTO statement and much else had to be unlearned by anyone moving on to a professional set of programming tools.

At the time we felt enabled rather than held back. But many Microsoft products were like that. The OS on a BBC micro was far ahead of DOS. Then the whole concept of the personal computer took hold even though we had already seen networking. Then the browser wars.

Now we learn that Linux is to be in Windows good and proper. So we are getting there in the end.

At the time when BASIC only had line numbers and GOTO, it was comparable to many other popular languages out there.

By 80s, when structured programming became the norm, BASIC became more structured as well, with loops and subprograms.

My introduction to computers was standing in front of a TRS-80 at a Tandy store (Australia's outlets for Radio Shack). I would visit sometimes after school and spend 15 minutes or so typing things in from the manual and adjusting them to see the effect. A few times when I went with my Dad I was hoping he would buy me one. Eventually I got the VZ200 from Dick Smith Electronics.

I ended up studying electrical engineering, really liking the notion of using digital systems to control the real world, and am a network and security consultant for my day job.

Oh wow, I never imagine seeing VZ200 ever mentioned in HN. One of the high school mates also had a VZ200. Unfortunately, the computer snobs at school treated him quite badly for having one. High school kids can be a*seholes! Hope you had fun with yours!

Apple II and Commodore 64 as well. They were all over the place.

Not sure whether it was exactly this version, but on an early job in the mid 80s, used a Microsoft BASIC compiler on a PC in a shared office. At least by default, when compiling, it would ring the "bell" on every syntax error. And by "ring", I mean loudly. BEEP BEEP BEEP BEEP BEEP BEEP BEEP. Which I discovered sitting at the PC, surrounded by secretaries, who commenced withering stares.

That's the first day I remember not liking Microsoft.

Supposedly IBM's fault that the original PC speaker failed to think of niceties like a mute button.

As late as the 486 era I remember how often it was reminded to people to just disconnect the PC Speaker. I also recall there were also crazy case mods where people would add a switch to their cases to add an on/off button.

Yeah, once I bought my first PC, I rapidly realized that just disconnecting the speaker was the way to go.

That said, I totally blame Microsoft for thinking that ringing the bell was in any way acceptable. Even if the PCs of the day had a soothing, quiet 'ding' sound, emitting that for every compiler diagnostic was the height of stupidity. As it was, I recall the original PC bell sound as more like gear grinding, if your head was one of the gears.

Once per compiler diagnostic isn't quite so bad as POSIX and macOS apps I know that will ring the bell for every wrong key stroke. ;)

(Even if more POSIX terminals these days make the bell actually sound like a bell or use a simple visual "nudge" instead and not the poor buzzsaw of an early DAC wired to a cheap speaker because it was free parts just laying around during the invention of the IBM PC, it's still amazing that terminals ever had a bell signal, as annoying as it can be, much less that apps intentionally used it or that it will forever be ambered into Unicode even. Learning to type a bell was a rite of passage for DOS kids, maybe with pseudo-terminals coming back into fashion it will be a thing kids learn again.)

I could not find the original macrotized version. As history tells it there was a version of this code that was written in a bunch of macros that were parsable by humans and they emitted assembly code for a wide variety of machines and architectures (from the 8080 to the 80286).

When I wrote the BASIC interpreter that runs in your web browser (using Java) I modelled it after GW-BASIC as this was the BASIC that had the most number of test cases I could find.

Given that we've got DOSBox for running DOS in your browser this should be portable to that sort of environment right? I know playing HAMMURABI and TREK isn't very engaging to the cool kids these days but they were a big component of the early microcomputer "revolution."

The article seems to confirm your recollection of a macrotized "master":

> Each of the assembly source files contains a header stating This translation created 10-Feb-83 by Version 4.3

> Since the Instruction Set Architecture (ISA) of the early processors used in home and personal computers weren’t spectacularly different from one another, Microsoft was able to generate a substantial amount of the code for a port from the sources of a master implementation. (Alas, sorry, we’re unable to open-source the ISA translator.)

For more information on why this happened check out Richard's blog post: https://devblogs.microsoft.com/commandline/microsoft-open-so...

> (Alas, sorry, we’re unable to open-source the ISA translator.)

> Alas, we’re unable to provide sources for these ports and/or customizations.

I wonder why. (I guess it might involve code licensed from third parties, co-developed and jointly owned with OEM vendors, or unclear provenance of IP.)

I wonder if it will ever change. I hope one day it does.

One of these days (probably long after I'm dead) the copyright will expire. I hope the source code hasn't been lost by then. (Sadly, there's a decent chance it will have been.)

Much of the source code from those days is simply lost.

OK, we've changed to that from https://github.com/microsoft/GW-BASIC. Thanks!

In 1988 or so, my dad bought us an 8088 IBM-PC for christmas. He used the gw-basic manuals to code in this christmas scene on boot with a santa, a tree, fireworks and even some christmas carol in chiptune in the background.

My dad was an autoworker. I've built foundational services and products now in the homes of 100s of millions & to this day I'm still astounded by what my old man pulled off.

Like others here, I see, I learned to program with GW-BASIC. Well, actually it was with the clunky BASIC from my beloved C64, but I wrote my first actual programs that did something with GW-BASIC, running on a trusty PC XT clone.

I also remember it had a graphics mode -- Hercules card, ambar monochrome monitor -- which sort of resembled Logo's turtle. You gave directions to a sort of pencil tip. I don't remember what the statement was called, but I remember I used it to program games.

I owe a lot to GW-BASIC :)

From a comment in the source


Wow! I did not realize that it was written so quickly. Two months that literally changed the PC landscape forever.

Paul Allen flew down to New Mexico where MITS was without ever having tested Basic on a real Altair 8800.

It was on essentially ticker-tape, which was the medium at the time (wikipedia's photo: https://en.wikipedia.org/wiki/Altair_BASIC#/media/File:Altai...)

Paul Allen was still "writing" it on the plane which in this case meant taking careful notes, cross-checking it very carefully and then manually punching holes into the paper. This is 1975, laptops are many years away.

It'd take about 30 minutes to load into the machine. Paul Allen claims they were the longest 30 minutes of his life. The MITS people were just smiling and waiting patiently, eager to see the cool software while Allen, on the other hand, had absolutely no idea whether it would work or not (they wrote it on an emulator after all).

After the 30 minutes it was ready to go and bam, everything worked. Bill and Paul had a company. Microcomputer software was now a thing.

Maybe I should do a computer history podcast ... I just checked and I don't really like most of them ... The video game crash of 1983 for example, I'd do at least 10 30 minute episodes on. The NES came out of it. I mean yeah, at least 10 episodes. I'll pick something super small (for example the HP 9100a) and see how it goes

Well...remember it is 'just' a BASIC interpreter.

Woz wrote Apple integer BASIC in the evenings while working at HP in just a few months. Guys were writing crazy stuff at the time. The original version of DOS that Microsoft bought to license to IBM for the PC was written in 6 weeks.

Expectations of complexity were much less in those days. Like, a programming language that is limited to 40 character variable names would be considered amateur hour, but back in the day it was prolly considered luxuriant. Also given the memory constraints, it also limited the amount of complexity you could put in your code.

More than luxuriant. Commodore BASIC (effectively 6502 Microsoft BASIC under license with tweaks) on the C64 only looked at the first two characters of variable names. It allowed them to be longer (don't remember how long), but would ignore subsequent letters.

This is getting off-track, but while the pitfalls of two relevant characters out of potentially many are obvious and only excusable due to technical limitation of the platform, insisting on more than 40 relevant characters is likewise contraproductive. Who (which human) will readily distinguish two character strings more than 40 characters in length sharing the first 40?

I feel often the need to remind programmers, that they don't write code for the computer. The computer will make it obvious, whether it understands you or not. You write for the poor sod tasked to maintain your code three years from now, when you're at your next gig.

Does namespacing count? com.mycompany.class.classfactory.factory.initializer.StaticGlobal

Sure you can usually use import/aliasing to narrow it, but sometimes you just need to grab some random global from somewhere.

>The original version of DOS that Microsoft bought to license to IBM for the PC was written in 6 weeks.

Is this actually true? From https://en.wikipedia.org/wiki/Tim_Paterson

When a book appeared in 2004 claiming that 86-DOS was an unoriginal "rip-off" of CP/M,[6] Paterson sued the authors and publishers for defamation.[7][8] The judge found that Paterson failed to provide any evidence regarding "serious doubts" about the accuracy of the Gary Kildall chapter.

Even a "rip-off" takes time to write. I'm not sure what you're questioning.

It wasn't a direct copying of the code, but the API was largely similar to CP/M.

I try to gauge the complexity of a task like this with a period view. On the one hand, BASIC was quite simple, and the 8-bit CPU had an instruction set that could be easily memorized (days before protected mode and 64 bytes worth of potential extended instruction decode prefixes!). On the other hand, debugging, code entry and documentation was sparse. (And there was no Stack Overflow.) So when I think to myself: How hard was this task compared to my for-fun projects? I really don't know what to think in today's inflationary terms. Thoughts?

Also, Spinellis' obfuscated C contest winner (the dds entry with LANDER.BAS):


Well this was way before the IBM PC.. Microsoft clearly had a plan in those days. They implemented all of the popular languages for microprocessors: Fortran-80, Cobol-80, Basic, PASCAL- but not C. They bought C from Lattice.

(I started with 6800 / 6809 assembly language, and then Microsoft C 4.0).

Also: PDP-10 (TENEX) was awesome to use, was a very nice development platform.

The PC in the comment was referring to “personal computer” in the generic sense.

It is interesting now to see Microsoft going back to its roots as a provider of developer tools for multiple platforms.

It's funny how stuff that got put together quickly like GW-BASIC and JavaScript got so much success because of luck and popular appeal. It's like music. The best music has never been in the top of the charts. The best movies have never won Oscars.

This is pop computing.

It wasn’t luck or popular appeal, it was like they say in real estate: “location, location, location.” JavaScript came bundled with every Web browser, and GW-BASIC came bundled with every IBM PC clone. A language that everybody in the world already has a copy of is going to get a lot of use, whether it’s good or not.

Not just IBM PC, but also hobbyist microcomputers. Few people could afford to have the real thing at home... but they could afford Spectrum or Commodore. And then those BASIC skills would readily translate to PC.

I think they were riding a wave as it was beginning to form; the microprocessor wave. It was very much part of a place in time but they made some exceptional choices given that context. I don’t think that their success was due to luck or popular appeal, it was due to vision and the ability to execute on that vision.

Well, some of us think that acts like Kanye, Jay-Z, Amy Weinstein, the Beatles, and Led Zeppelin were pretty great even though they had the crassness and audacity to make it to the top of the charts

Please don't mix Kanye and Jay-Z with Beatles and Led Zeppelin, they are in different leagues.

Sounds like you don't know music.

Think what you could do with a little time off and your own agenda to write something meaningful.

GW-BASIC was more of a reinterpretation of DEC's PDP-10 BASIC source code than a clean room reconstruction - ironic considering what happened next.

Gates and Allen had already been working on PDP-8 and Data General versions for a while.

For one person working 8 hours a day, that's roughly one line of assembly language per minute. If you know assembly language, and you know the algorithms you're implementing, that doesn't seem especially fast.

You find me someone who can code assembly for 8 hours a day continuously for two months and I'll hire them on the spot.

There are plenty that do, especially in embedded. I did assembly at Siemens half the day (the other half was C) when I worked for Siemens VDO in 2005-2006. It's not that hard, especially if you do simple stuff, opposed to high algorithms I usually implement these days in higher programming languages.

Is that a serious offer? It's been a couple years but I'm sure with a little practice I could get up to speed again, and (like half the country) I do happen to find myself out of a job right now.

No, I was trying to make a point. Namely, that no one produces that kind of output consistently over time.

I apologize for not taking current economic conditions into consideration with what was clearly a poorly-worded post.

I've had jobs where that level of productivity would have gotten me fired for goldbricking. Gotta love the game industry...

how long would it take you to write a fast circle routine in assembler?

(with stack overflow blocked)

In general I'd rely on symmetry per 1/8th I think, because within each quadrant you can mirror half by swapping x and of offsets. Then basically use the same approach as Bresenhams line algorithm adapted to integer, but instead of calculating a fixed slope, look it up in a table and adjust based on radius.

There is Bresenham's circle algorithm - I don't know it, but I'd guess it's not that far off the above, because the above is a pretty obvious solution when you know even the idea behind Bresenham's line algorithm and you know basic trigonometry.

Basically "everyone" that has done anything graphics related pre-fast floating point and pre-fast general multiplication/division in CPUs are used to the fact that you can boil anything involving trig down into tiny tables of number of steps in one direction before the next step in the other direction to avoid multiplication. You can often forego the tables for a few shifts, but it's often not worth it. You then look for mirroring as a means to avoid replicating computations wherever possible.

It'd certainly take a bit of time to get it just right, but at a few dozen instructions at least, you have a reasonable amount of time to figure it out. But more importantly: Most of the code will include a lot of pieces that takes far less than a minute per instruction.

I wouldn't be able to do it fast enough now given that it's 30+ years since I last wrote much assembler by hand and it'd take me a few days to get back up to speed, but this isn't a difficult challenge. Of course it'd also depend on CPU.

One thing you need to keep in mind is that the code density of assembler is very low. Once you know you need to add two 16 bit numbers together on an 8 bit CPU for example, you know what to write for several instructions. E.g. you might end up with something like this (roughly 6502, though I don't remember all the details of the assembler syntax; I'm assuming the use of <var to address the low byte of a 16 bit pair, and >var to address the high byte as at least some assemblers used that as shorthand to indicate address offsets), assuming two 16 bit values in var1 and var2, with result stored in var1

    CLC           ; Clear carry flag; can be ommitted if you know carry will be clear
    LDA <var1   ; Low byte of var1
    ADC <var2  ; Add with carry of low byte
    STA <var1
    LDA >var2   ; High byte
    ADC >var2
    STA >var2
That's 7 instructions that you'll do "automatically" when you're programming these CPUs daily and know you need an addition.

But even on much higher level CPU's like the x86 or M68k the density of high level concepts to assembly instructions is pretty low.

Wow, pretty good. I mentioned that because the first source file I pulled up was a circle drawing routine written in assembler.

I wrote a routine to do it once for fun -- in python -- and it took me some time to get it right. I also had access to wikipedia and stack overflow, so I was able to get the integer method going with guidance.

for example, the middle of the main loop was:

  x += 1
  if d > 0:
      y -= 1
      d = d + 4 * (x - y) + 10
      d = d + 4 * x + 6
(btw I was doing this not to draw a circle as much as draw a moon)

But when I read the source code I thought... writing geewhiz basic would take a long time now, let alone 1975 when there was no instantaneous communication of acm papers and computers were rare and graphical computers rarer.

It's one of those things where you relatively quickly get used to a specific way of thinking, and while we didn't have instantaneous communications of papers, we did have endless numbers of computer magazines with actual listings in them that often also discussed fairly in depth algorithms.

Mostly it boils down to learning patterns for common things, and things like basic trig replacement was a staple of the demo scene.

Poked around a fair bit. Didn't find any hint what the GW is/was supposed to stand for.

Micro-soft BASIC on Apple ][, as on other 8-bit targets, infamously did a linear search from the beginning of the program to locate the target of a GOTO or GOSUB statement, so that programs ran faster if frequently called subroutines (what we now call functions) were close to the front. I wonder if or when that behavior was ever corrected in GWBASIC. Also, did the NEXT statement do it too?

> Didn't find any hint what the GW is/was supposed to stand for.

Hah! This is the real mystery, isn't it? I noticed Wikipedia has a section on the topic (without resolution): https://en.wikipedia.org/wiki/GW-BASIC#Name

Looking at this source code I'm astonished by how many lines of code it is. I've never written more than the most basic (ha) of assembly language programs in my lifetime.

How does all this assemble into a 60k binary?!

Also, wasn't it true that Steve Wozniak was able to bootstrap the entire Apple I BASIC in hexadecimal from his own memory? How can that be? I'm reeling.

Each line gets translated down to a few bytes, maybe two to ten depending on the opcode. The downside being that each line doesn't do a whole lot.

And I can imagine that this is an absolute ear pull to try to debug with the tools they had. It's more akin to debugging embedded systems to the PCs we have today.

I wrote an implementation of BASIC for work a year or two ago, and there's a massive nest of case statements to figure out the resulting data types of operations. Grey(er) beard in the next office pointed out I was probably replacing one page of code in the thing I was emulating.

GWMAIN.ASM ( https://github.com/microsoft/GW-BASIC/blob/09ad7bc671c90f0ee... )


That's awesome. I actually have GW Basic from my first computer available. Copied from the old 5.25 inch floppy to a 3.5 inch floppy via a 486 and then to a USB hard drive about 20 years ago into a folder i called "Diskette Collection".

I lost a lot of valuable stuff, including my own first programs I wrote as a kid, to aging diskettes and bit rot. And then threw the diskettes away. I wish I had had your foresight...

Hmm: " (Alas, sorry, we’re unable to open-source the ISA translator.)"

For...legal reasons? Or because they lost it?

GWBasic was good resource to get into programming world during my teenage. Now I want to teach coding to my 10 years old son. Will you still recommend GWBASIC/Quick basic or Python or other languages for kids?

I learned BASIC as a kid (first on a mainframe terminal with line numbers), and use Python today. I think the language is not as important as other issues:

1. Computers are so much more advanced now, that the obvious gap between beginner and commercial software is vast. This can be discouraging. When I learned BASIC, I could write programs that didn't look any more crappy than typical commercial software, even if there was a performance gap.

2. There's more magic involved today, meaning that when you run into an obstacle, you wave a wand and a library or stackoverflow post magically appears. To do something in the old BASIC, you had to figure out a way to compose it out of the 13 keywords that you had already learned. So you were forced to think about algorithms, right off the bat.

3. You were closer to the hardware, which was more exciting if you were interested in things. I could kinda explain what the computer was actually doing. I loved math as a kid, but I also loved electronics. The day that I programmed a thing to do something (maybe just a blinking LED) was like the rapture for me.

What's closest to the old experience for me is not a language, but a thing: A microcontroller board. Out of the box, it has no GUI, so no expectations for what "cool" software looks like. And you can make it do things that have an immediate sensory effect. You can now put CircuitPython on a Teensy 4.0 board, and sidestep having to learn C, at least for a while. And your son can really own the thing that he's programming.

As a minor suggestion, you can also get closer to the computer and to programming by making more use of the command terminal when showing your son how to do things.

A final word, don't be heartbroken if it doesn't click. It might not. This is also something parents are told when their kids start music lessons.

thanks for the interesting & thoughtful view. I learned BASIC as a kid in the mid-eighties and already then felt a big obvious gap between what I could write in BASIC and commercial software like Nintendo NES games or even Commodore 64 games, that were written in assembly language.

Assembly language was easier too. ;-) I found a book, I think it was published by Howard Sams but sold at Radio Shack, on the Z80 microprocessor. Now I had no particular reason to favor the Z80, but it was available so I bought it. There was another book on TTL logic. The Z80 book was so well written that I gained a grasp of how a microprocessor works, back when there weren't things like pipelines and microcode to blow your mind. But I learned about how pointers work, buses, etc.

The closest thing I'm aware of today, that are actually useful, are the 8 bit PIC chips.

JavaScript since they can make web pages that do things in browsers they are familiar with, which is a huge motivation. Lua so they can mess with Roblox scripting. Then C# mostly for the dev environment And strong types, and Python for the expressiveness. In my humble opinion and experience at least. It's almost always most important to start with something that will augment what they are already interested in.

I personally don't like JS, how can I teach him? Plus working on JS involves many things for a beginner, you know HTML, you know a bit CSS too.

I don't know Python, but I saw online (amazon and the likes) that there are plenty of books on Python for kids (search for that and many similar titles will come up). I was thinking of Python because it's a language that is useful to learn and make it more fun by learnyht it together.

A large part of why I (and I assume others) started with BASIC was because it was accessible. I really wanted to do "real" programming, but C compilers were expensive and there was no internet connection when I was in grade school. Now you can just download Linux and practically infinite languages.

Also, I can't help thinking of how it can be counterproductive to try to push someone in a certain direction.

A lot of times showing what you value and want for yourself tends to have more influence than what you try to get others to value.

Try Python with Thonny.

Python itself is great because it has all the right batteries included. It's easy to get started - you don't need to explain "import" or functions to write a basic hello world type app with console input and output. Then you can gradually build it up from there, introducing turtle graphics, databases (SQLite), and finally GUI (Tk) - all of which are present in the standard library.

And Thonny, well - it's self-explanatory once you see it: https://www.youtube.com/watch?v=nwIgxrXP-X4

Python is probably a better intro language than GW-BASIC ever was. I say this with all the reverence and fondness I still have for the latter.

Check out Scratch, from MIT.


Scratch is great. If you want something like that but less open ended and more directed (with exercices and training videos) try https://code.org/

It also helps they use known franchises like minecraft or angry birds =)

I know about Scratch. The only issue I have that real-world programming environment is different than Scratch one.

These days you might use Roblox Studio.

BTW, Paul Graham (pg) using online Repl to teach GWBasic to his son.

IBM had their own Basic, 4 of them really (collectively called IBM Basic) that was a barrier for the clones[1] (eg, Compaq, Dell, etc) because they wouldn't license it. (You probably used one of them, basica if you used the classic PC)

Microsoft made GW basic and smited IBM by putting it on the clones Except for the IBM machines. They also intentionally made it slightly incompatible with IBM's basic. Then they held the GW basic source hostage so IBM couldn't resolve the inconsistencies, couldn't backwards engineer it because of the licensing, and thus put them at a losing negotiating position since Microsoft now called the shots because they controlled the software. (I wonder if this slight is in the comments, let me go look, that'd be great[2])

Microsoft also held the DOS source code hostage and it was a huge stickling point in the OS/2 and Windows work and was a significant reason Microsoft was able to steal the show from IBM. IBM even sent over a bunch of engineers to get DOS 2 to work because DOS 1.1 was a complete mess. But they didn't have the rights to walk out the building with the source they wrote due to a contract oversight.

Bill Gates was a true software Napoleon, it's really quite something.

Now they're releasing all of it. It's a strange coincidence to pick the three they burned IBM with 35 years ago...

Maybe they're trying to shake off the old days, maybe they're putting a final stick in IBMs eye, maybe it's genuinely unrelated, who knows.

Smacking around IBM is my preferred reading because the idea of doing one final power play, against IBM for God sakes, 25 years after it became unarguably 100% meaningless with the release of Windows 95, I personally find hilarious.


[1] The only source code left in the timeline we don't have is Phoenix, who cleanroom cloned IBM's BIOS in 1983 (using a Chinese Wall) which allowed the clones to really take off. But they've been pieced off and sold as a fleamarket to HPE, Absolute, and Marlin, so who knows when we'll see that source.

[2] I'm going to make the bold claim (after 10 minutes of poking) and say either they removed the incriminating things or the claimed intentionality of the incompatibility is now provably just a rumor (as in they lucked into it through implementing an imperfect clone)

There's evidence for both I guess. For instance, GIOCOM.ASM has a reference:

COMPAQ=0 ;Include IBM 1.0/1.1 Bugs for compatibility

But this isn't cited anywhere else. It's just hanging. They have a bunch of other vendor specific things like ZENITH, TSHIBA, they all have logic, this one is absent any logic, it's just an orphan. Shrug...

I just tweeted @ BillG and asked him --- snowballs' chance he'll respond but who knows.

I'm not sure that the ROM BASIC was a huge commercial factor much after 1983 or so.

It might have given IBM more leverage to say "not fully compatible" or instigate IP lawsuits, but most clones seemed to be okay with a boot error of "NO ROM BASIC - SYSTEM HALTED" instead of the IBM BASIC ROM.

They stopped updating the ROM version virtually immediately, and it never supported discs. No PCs after the PCjr supported cassette tape natively. So all it could be was a penalty box when the boot failed.

BASICA and GWBASIC seemed to be treated equivalently from the perspective of mid-late 80s magazines with type-in listings of near commerical-grade for the time software.

> Include IBM 1.0/1.1 Bugs for compatibility

I am, to put it mildly, not the greatest fan of Microsoft, or of most of their products. But that just sounds like a flag to avoid breaking backwards compatibility by fixing bugs that people have come to rely on.

And a strong focus on backwards compatibility most certainly is a principle by which Microsoft operated for years.


Great news, and hopefully this will be pulled into the FreeDOS devtools distribution ASAP.

So this is the initial version that might still contain some bugs?

I forgot the details, but I remember that my XT clone had does MSDOS 2.11 and whatever version of gwbasic came with that, and MUSIC.BAS would always play the notes slightly out of sync with the visuals, and the prompt would return before the last note played.

Some day I saw it running on a friends machine, and there everything looked fine. I copied his gwbasic.exe and lo and behold, now it worked on my machine too. The version numbers were also different, but I couldn't tell you either one now.

That's interesting:

    ; There is a problem with running the ASM86 sources for BASIC as they
    ; stand.  MSDOS puts a 100 hex byte control block at the beginning of the
    ; EXE file and sets up the ES register to point to it.  BASIC, however,
    ; expects this block to be at 0 in the code segment.


PC Basic emulates GWBasic on many platforms.

The Altair BASIC from early Microsoft was an insane achievement. They created it without having access to the Altair, and it worked at the first attempt... using punched tape.

"Sometimes I just look in mirror and spook myself". In 1983 I wrote modern high-level language interpreter and compiler with backtracking and throw-catches (clojures sortof) in MSDOS assembler and it is much shorter than this GW-Basic. Admittedly I used macros like a madman on steroids. https://github.com/timonoko/nokolisp

My biggest take away here is that old MS-DOS has been made free software. I had a Compaq Portable that I’m restoring, and I gave half a though to combining my love of retro hardware with free software and running FreeDOS even if it is a bit of a resource hog. But I think this machine(its the original version of the Compaq Portable) came with DOS 2.something, so the now open source DOS 2.0 might work without the performance hit of FreeDOS. Neat.

This is great! But it makes me think that Microsoft need to add a BASIC compiler as standard in all Windows distributions. They did that Small Basic thing a while back, but it was too encumbered in .NET-isms, a kind of Visual Basic .NET lite. It would be great if there was just a easy to understand BASIC that you could hack away with that could produce interesting programs without the .NET cruft or the barrier that is dealing with Windows APIs.

It's too bad Microsoft QuickBASIC isn't a thing anymore. Who didn't love GORILLAS.BAS?

Old-timer geeky note: ah I think you meant QBasic? The Basic that was included in MS-DOS 5.0?

"QuickBasic" was the commercial compiler (like QuickC and QuickPascal), whereas "QBasic" was the stripped down IDE with interpreter that a Gorilla throwing bananas based on physics.


It was no DONKEY.BAS, that's for sure. :)

Yes! QuickBasic 4.5 was my jam! I used to churn out apps with that left and right.

I loved QuickBasic 4.5! It could compile programs to .EXE files ;)

And from there, once you hit QuickBasic's limitations, it was a small step to Turbo Pascal or Borland C!

It’s about time MS open sourced QuickBasic or at the very least released it as abandonware.

Who did write GORILLAS.BAS?

It's a shame it disappeared before educators became serious about teaching kids to code as well. All my math text books from the late 80's and 90's came with code samples written in basic that teachers ignored and now kids have dedicated coding classes where the snap together if statements in a useless visual programming thing on their iPads. We missed the opportunity to teach programming in a way that was both immediately useful (took away the repetitive work) and integrated way with other classes. I wish I could go back in time and show my younger self what to do with those basic code samples while I was wasting time plotting some function on a piece of graph paper.

C# and .net core don't have as much cruft, and the simple dev environment in code or visual studio are invaluable - especially the debuggers which are imo one of the most important learning tools.

Argueably MS already provide a complete language pre-installed in PowerShell. However would be nice if they more of a beginners IDE for simple programming.

The command-line C# compiler csc.exe is also pre-installed as part of the .NET Framework. There's also all the WSH languages (VBScript and JScript).

Powershell ISE is pre-installed.

In 1985, I was developing a simple serial network for barcode readers, to run on the original IBM PC. It needed to run as a TSR (Terminate and Stay Resident) assembler routine and use the 8250 UART chip, and the 8259 Programmable Interupt Controller.

At that point the only documentation we had access to was the IBM Technical Reference Manual, which gave the schematics and BIOS listing, but little else.

I was very familiar with GW-BASIC and had written some BASIC code to use the RS232 serial interface from it, so decided to reverse engineer GW-BASIC itself, to work out how it was addressing those chips.

A month or two later, we came across Peter Norton's "Programmers Guide to the IBM PC", which could have saved us weeks.

Exciting times.

First of all, I'd like to thank Microsoft for open-sourcing this, as well as early versions of MS-DOS; they are important pieces of computer history.

Now, a few software engineering observations (these are to my future self, not to Microsoft):

1) This is extremely minor, but it would have been nice if the main file (which I'm guessing is GWMAIN.ASM?) had been pointed to in the documentation. Reason: We're not in a language that has a default main file by custom, i.e., C's 'main.c'. But again, extremely minor...

2) This code is great, I mean, absolutely great for someone to learn x86 programming IF they have the prerequisite understanding about how memory is segmented in those early computers (including segment registers, etc.)... Reason: Very few basic x86 instructions are used, relative to the entire x86 instruction set...

3) It seems that the assembler which was being used at the time had a limitation of 6 characters per symbol. This kind of sucks a little bit for the readability of those symbols (but note that the code makes up for this with liberal commenting, which is great!), and of course, with a little bit of effort, you can mentally parse what most of these mean.

4) I would have liked to see some kind of document (although, since it's 38 years "after-the-fact", after this program was being written, I certainly don't expect one! <g>) which, at a high level, would describe the main data structure being used to hold the lines of basic code (I'm guessing this would be a linked list of sorts), in what source file that data structure lives, and how it is evaluated when a BASIC program is run...

Basically, give me the high-level view of the system.

The code itself represents the low-level implementation details of that high-level "as simple as possible but not simpler", view...

But again, those things are minor, relatively speaking, and they only amount to "notes to self" in my future software engineering efforts...

Anyway, thanks again to Microsoft for this great important contribution to computer history!!!

Perhaps stupid questions but how do they get the commit history to be from 38 years ago at https://github.com/microsoft/GW-BASIC

Probably a script with some version of:

git commit --amend --no-edit --date="Fri Nov 6 20:00:00 2015 -0600"

Visual Basic 6 next please! :)

I did VB 3 when I was like 13. I think it makes more sense to me after doing JS for so damned long now.


I'd love QBasic from a few years later.

I'd also love a nice, easy-to-run Ubuntu .deb for either.

Not a .deb, but still pretty damn easy to install:


QB64 is pretty cool, they got the IDE experience right: https://www.qb64.org/portal/#about

In their implementation, BASIC code is transpiled to C++ first, then compiled and executed.

Oh, interesting. I wonder what implications this will have for the MS Basic disassembly project:


While it might initially feel like a downer, it would still be quite educational on its own to go through the code comparing what they came up with in the disassembly in light of the real deal being now published.

There would probably be a few "Ah Hah!" moments for code that stumped them, and lessons to be learned on any particular errors they made.

They are different. That project is disassembling Microsoft BASIC for 6502. What Microsoft has just open sourced is their BASIC for 8086. Two separate codebases, although they have some commonalities. (As the MS blog post mentions, they kept master source in some kind of abstract assembly which could then be automatically translated into specific machine's assembly language, but then I believe there were manual additions to the assembly code after translation.)

I wonder if the master source was that abstract, the original Microsoft BASIC was for the 8080, and there were several 8080 -> 8086 source translators. TRANS.COM shipped with 86-DOS before it became Microsoft MS-DOS. https://tech-insider.org/personal-computers/research/acrobat...

That does explain the top line comment in each source file. Thanks. I was wondering what they meant.

Huh. There's a very well-commented disassembly of Applesoft BASIC in existence already that shipped with the MERLIN assembler. I assume those guys already have that one.

Roughly none, I would guess. I can't imagine there are any patents expressed in the actual MS code, and the MIT and 2 clause BSD licenses are virtually identical.

Oh, I didn't mean from a legal perspective! I meant in terms of what historical insights the newly available GW-BASIC source can provide.

Very nice, that was my first language on a PC-compatible (Epson Equity I if anyone remembers those, later upgraded it with a 20MB Seagate ST225!). Man, those were the days... and get off my lawn! lol

GW-BASIC was the first Basic I wrote substantial code in! I got a kids' book with drawings and text explaing variables and such from my dad. I think I was 7 or 8. It was not long that I reached for the extensive and English-language manual for GW-BASIC which came with the computer. Being a Dutch kid, this allowed me to both learn some English AND some Basic.

Prior to that my dad had a Tandy TRS-80 model III but at that point I was 6 or 7 and my typing skills were holding me back from writing more than 3 or 4 lines of code.

My mom's IBM 8088 had GW-BASIC built into its BIOS. You could turn on the computer and go straight into it without having any storage medium present.

Have an original IBM PC sitting here. It has a 5 pin DIN plug on the back to connect a casette tape drive. I also recall BASICA.COM on diskette leveraged the BASIC routines in the original ROM, so it was about 1/3 the size of GWBASIC.EXE.

Interesting. Was that the original IBM PC? I thought it needed DOS for some reason.

I've always thought that using BASIC as the default command line was really weird... Like on an Apple II or TRS-80. You could type in a command to load something from a disk or run a program, or type a line number to start programming. How did that make sense to anyone?? To my 11yo self, it was confusing and I've never changed my mind.

Yes. The original PC and PC XT had BASIC in ROM just like all the other home computers of the day. In its most bare bones configuration, you booted into BASIC and used a cassette tape drive for your storage.

I don't know how common that setup was - probably not very. The most typical stripped-down PCs were dual floppy (the hard drive was a premium), and booted either MS-DOS or CP/M.

If you already have a PL, why not re-use it as a shell? Those environments were very memory and storage limited, so it made a lot of sense.

That was actually “Cassette BASIC” written by IBM.

It was scary to see it when you didn’t expect to, because that meant something was wrong with your disk drives!

Some real cool things - this is computing history being preserved, like in one of the files I saw this:

--------- ---- -- ---- ----- --- ---- ----- COPYRIGHT 1975 BY BILL GATES AND PAUL ALLEN --------- ---- -- ---- ----- --- ---- -----



I really appreciate the nearly per-line commenting.

Sure, but opening a random file yields the comment:

.RADIX 8 ; To be safe

To be safe of what exactly?

Probably because the PDP & Intel 8080 were typically octal systems rather than hex, the 8080 instruction set decoded nicely in octal (or at least the MOV A,H instructions). By the time the 8086 arrived the micro-computer world had moved to hex as it nice decode mapping was broken by the Z80 and the 6502/68xx families didn't have that nice split.

So my guess this is to allow 12 octal to be 10 decimal as that would have been the default in the inital code base.

I thought the whole octal business stemmed from the time mainframes and minis used 36b, 18b words respectively as 6bit (early mainframe character width) can be conveniently represented as two digit octal. This changed when computers went 16/32bit and started to use 8bit bytes (and ASCII encoding of characters).

I noticed an odd thing here. The repo is full of assembly code and nothing else but the colored bars in github shows C++ and C !!

Missing github feature: activity chart on the forks page to see easily who is working on the code - not just collecting

I remember when Bill Gates released his terrible BASIC for homebrew computers. It was implemented in ROM (because nobody had enough RAM to hold something like an interpreter). It was terrible, bug-ridden and unambitious. I recall thinking at the time "I could do better than that!".

If only I had :)

Please also open-source MS DOS 7.1 and QuickBasic 4.5. These are equally nostalgic and slightly less useless.

Very nice commented code, it really looks like the best practices of some Assembly books back then.

Also love the remark about high level languages and the choice to go with Assembly, no kids, C wasn't always as fast as you have been sold on, specially on home computers.

Wow, Microsoft are really going full-in on open source. I think this means Open Source has won?

No. Open Source lost to Oracle instead of Microsoft: https://en.wikipedia.org/wiki/Google_v._Oracle_America#Impac...

Wait until the Current Branch of Windows 10 becomes open source.

I'd be content (happy, even!) with Windows 2000.

"Contains no build scripts, makefiles, or tools required to generate executable binaries, nor does it contain any pre-built binaries / executables"

Considering the repository is 80's assembly code, I have no idea how to rebuilt it.

Is the original Turbo Pascal open sourced? I would have lots of interest in reading it.

When developing on/for mainframes and minicomputers of the day, developers were sometimes able to use higher-level languages

ISTR hearing that MS had a VAX that they developed on then cross-compiled for 8086

My first programming language was AppleSoft Basic. My Aunt gave me a book, they have Apple II at work, and I read it and learned it even though I dont have an Apple II at that time or even a computer.

very cool.

> When writing software for early PCs, every single byte and every single instruction mattered, so developers often wrote code entirely in assembly language simply to be able to physically fit their software into the available memory, and to be able to access the computer’s resources and internal workings.

This made me a bit sad. Imagine how fast things could be today if developers still had this mindset. Of course I wouldn't advocate writing everything in ASM, but the adage that computers are fast, write inefficient code...is disappointing to say the least.

I don't care about Microsoft's BASIC, in fact I don't care much about BASIC at all. It was a poor choice 35 years ago, it's irrelevant today. Or nearly so.

However, I do find GPIB programming examples in what seems to be Rocky Mountain BASIC (HP BASIC / HT BASIC) in the manuals of measurement devices from the seventies to the early nineties. Analog electronics didn't evolve nearly as quickly over the last forty years as digital, so some of those instruments are still significant today (chiefly to hobbyists, but at least the HP 3458A, introduced 1989, is still produced virtually unchanged and is even today the top-end long scale-scale DMM).

I like to see a OSS implementation of that dialect (for Linux).

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact