Hacker Newsnew | past | comments | ask | show | jobs | submit | jblazevic's commentslogin

  --------- ---- -- ---- ----- --- ---- -----
  COPYRIGHT 1975 BY BILL GATES AND PAUL ALLEN
  --------- ---- -- ---- ----- --- ---- -----
  
  ORIGINALLY WRITTEN ON THE PDP-10 FROM
  FEBRUARY 9 TO  APRIL 9 1975
  
  BILL GATES WROTE A LOT OF STUFF.
  PAUL ALLEN WROTE A LOT OF OTHER STUFF AND FAST CODE.


According to Paul Allen's book [1] about his time at Microsoft (admittedly a biased source), his particularly critical contribution was an 8088 emulator/simulator for the PDP-10. That allowed them to write and even interactively debug (if I remember right) BASIC for the 8088 on the PDP. It would've been hopeless to develop directly on a microcomputer, so they would've had to have written on the minicomputer, transferred the binary across and see if it worked, and iterate like that.

That contribution wouldn't show up directly in the BASIC source code, since the emulator wasn't part of BASIC itself.

[1] https://www.amazon.co.uk/Idea-Man-Memoir-Co-founder-Microsof...


Yes.

There's an even more extraordinary story about them travelling to demonstrate their implementation of BASIC to the MITS team.

They realise they have not written a bootloader for the Altair, and Allen writes out a bootloader on the plane, which works when they get to MITS.

https://en.wikipedia.org/wiki/Altair_BASIC#Origin_and_develo...

My first encounter with a real Microsoft BASIC wasn't for another 15 years; the interpreter-only QBASIC that came with Halvorson & Rygmyr's Learn BASIC Now, which was a great book I gave away and now feel the urge to repurchase for nostalgia's sake. I used it for my GCSE Computer Science project.


Writing an 8080 emulator on the -10 is not extraordinary, after all, it's a trivial instruction set.

What was extraordinary is Allen realizing he could do this as a shortcut.


An 8080 has what, 40 opcodes? All doing simple things like "add" and "mov".

https://altairclone.com/downloads/manuals/8080%20Programmers...


I learned on an 8080 system (Interact) that also had MS basic. Almost every one of 256 op-codes is used on the 8080. That's not to say there were that many instructions. For example register-to-register move might be considered one instruction but the source and destination register are encoded into that one byte so there are many reg-reg moves. Same with add sub, etc... My father wrote a disassembler in basic to read out the ROM and he made his own mnemonics which amounted to probably 20-40 actual instructions (I still have it and could look it up), but there were maybe 8 entries in the opcode table that did nothing.


https://pastraiser.com/cpu/i8080/i8080_opcodes.html

As a pragmatic manner, I don't regard having the register and/or addressing mode encoded into the opcode as a separate opcode.

Emulating a modern 64 bit processor would be a major chunk of work, but the old 8 bit ones are simple.


If we exclude addressing mode then I think there are less than 26 instructions. Our mnemonic format was one letter (verb/op), one for source (a,b,c,d,e,h,l,w,x,y) and one for destination. I dont recall the letter for immediate, probably i but MIA for move immediate to a doesnt ring a bell for me. :-)


Yes, around 8 spare opcodes, and they were the ones Zilog used to escape into a large set of extensions for the (backwardly compatible to 8080) Z80.


Can a Z80 be dropped into an 8080A socket? I'm thinking there were hardware differences.


No absolutely not. 8080 was a 3 chip solution from memory. The 8085 was, like a Z80, a 40 pin DIP, but even here the compatibility was strictly software not hardware. And in fact the software compatibility was a little less than 100% because Zilog decided to add an overflow flag by changing the 8080/8085 parity flag to actually reflect overflow instead of parity on arithmetic instructions.


Interesting! Could you explain in a bit more detail how you used it for your CS project?


Oh I just mean, QBasic was the language I used for that project.

I can't actually remember it in detail now, but this was when I was 15 or 16. It was a database application; I guess mine would have been music lending.

I wonder if I still have the code. I definitely still wish I had the book.

I really enjoyed QBASIC because of the gentle way you were exposed to better programming practices; I've always admired that.

Five or six years later, my uni project was a BASIC-to-C transpiler for a simple dialect of BASIC as a teaching language with some specific language extensions for message-passing parallel programming. It had a simple IDE, too.

In some ways it is a shame BASIC itself is really gone; modern implementations only have a whisper of its original simplicity.


Python seems to have taken its place, specially with all school calculators having some variant of MicroPython.

It isn't the same thing though.


Yes -- I think sort of the most basic BASIC programming is done with Scratch, and then they graduate to Python.

In the UK I gather kids are taught Scratch and Python in an overlapping fashion, so they see the structure on the Scratch view and then have a better chance of understanding how the code works without being thrown off by the symbols.

This is probably better in a pedagogical sense, and I am sure Scratch programmers have a better early understanding of flow control and things like loop termination conditions than BASIC programmers did; Scratch makes it more physical.

But it does lose that absolute immediacy of being able to type simple words onto an empty screen and see it do things.


Scratch and especially Python are a lot more complex than BASIC. OTOH, Scratch having a structural rather than solely text-based interface might also make a more complex language immediately usable, by removing the difficulty associated with keywords and surface syntax. This is the kind of thing that would really benefit from a well-designed usability experiment.


Using a minicomputer as a dev environment for micros was particularly popular in the late 1970s and early 1980s. See Infocom

https://www.filfre.net/2013/03/the-top-of-its-game/

which used virtual machine technology to deliver games developed on a Decsystem 20 to many different kinds of Micro.

When Microsoft BASIC came out in 1976 it was rare for a micro to fill out the 16-bit address space with a full 64k. I had a TRS-80 Color Computer which ran a multitasking operating system

https://en.wikipedia.org/wiki/OS-9

With 64k of RAM I wrote a FORTH interpreter that ran under OS-9 with a good standard library in about 3000 lines of assembly. OS-9 looked a lot like UNIX or VMS. Dev tools in 1984 were good enough that writing a BASIC interpreter on a micro in assembly would have been straightforward, I'm sure you could on a C-64.

No way you could do that on the base configuration Altair that Microsoft BASIC originally targeted.

The first time I used emulation was circa 1987 when I developed a BASIC program for a high school teacher who had a Z-80 based CP/M system on my generic 286 machine... Even then there was a CP/M emulator for the 286 which could destroy any Z-80 machine on the market -- even though the protected mode of the 286 was as "brain damaged" as Bill Gates said it was, the raw performance of the 286 was the beginning of the end for the 6502, 68--, 68---, Z80 and all the other architectures.


I had an obscure machine ("Interact") in the early 80's that had an 8080, 16 kb of memory, and a cassette drive. There was an assembler for it. If I remember right, you read the editor from tape, edit and save your file, then read the assembler from tape, it reads the tape with your code and then writes the output to tape.

I have no idea what the people ("Micro Video") producing software for this thing did, but I can't imagine they used this on-machine assembler.

(The tape loading mechanism was basically blocks of address + data. They put loading screens on the tapes by populating video memory first.)


... an 8080 emulator, not 8088 :)


So I might be able to use a PiDP-11 microcomputer, presuming it is compatible with thd PDP-10, to run an 8088 emulator, on which I could run early DOS programs?


PDP-11 and PDP-10 are completely different. The 11 was in the DEC 16-bit series and the 10 was in the DEC 36-bit series.


While this is completely true, the PiDP-11 mentioned by the parent is based on SimH, which does simulate PDP-10 (as well as dozens of other early systems).

[1] https://obsolescence.wixsite.com/obsolescence/pidp-11 [2] https://github.com/simh/simh


They wrote this in two months? In assembly? Impressive! I wonder if they used code generators or wrote plain assembly?


Assembly language isn't that hard. I wrote a FORTH interpreter with a pretty good standard library in 3000 lines of 6809 assembly that pretty much worked right the first time.

Today you could spend as much time getting the build to work with npm or maven for something very simple.

Macro assemblers are nowhere near as much fun on the x86 (and other 80's era micros) as they are on something like the IBM 360 or AVR8 with a big register file... If you've got 32 registers you can write macros where the register names are parameters and avoid a lot of the meaningless activity involved in "calling conventions" in programming languages like C.


Was the FORTH interpreter for your own use or did you sell it? I ask because it's always fun to see someone on HN that wrote products I saw in the pages of Rainbow long ago.


It was for my own use.

It was unusual in quite a few ways. For one thing it was subroutine threaded which made it a little faster than most FORTHs, also it used self-modifying code in an inner loop to save a cycle in an important place.

Most FORTHs at the time used block-based disk I/O because you could do that without a real operating system and have some nice benefits such being able to copy a block of source code to the screen buffer to edit in place, easy memory allocation, etc.

OS-9 had a handle-based API for filesystem access basically the same as UNIX and MS-DOS 2.0 so my FORTH used that. OS-9 had a choice of text editors, including a vi clone so I didn't feel the need to embed an editor in the interpreter.


Everyone wrote plain assembly in those days. If you were lucky your assembler did nice things like symbolic constants.

It was a skill pretty much everyone knew.


It's fair to assume this is handcrafted and hand-optimized code, as machines back then were typically too small to use for many tasks. Any code generated would have added bloat making the whole project untenable.


Unless you set them correctly to actual CPU frequencies, in which case they correlated perfectly.


What I find very interesting here is the QuickJS engine used in this. Developed by none other than Fabrice Bellard!


C-smile (OP) ported Fabrice Bellard's gcc code to standard C (without gcc extensions).

The Sciter engine currently uses TIScript - a language c-smile orginally developed and the kickstarter proposal is to open source Sciter as is, then replace TIScript with the QuickJS engine. (TIScript is a very nice scripting language in itself that is easily picked up by JS devs)

The standard C version of QuickJS can be compiled using visual studio on windows as can be seen in this repo: https://github.com/c-smile/quickjspp

(Edit to update to latest repo)


Very much in the same vein as Duktape[0]. It looks like Duktape is smaller and has a more useful standard library, but is slower and doesn't support ES2020 features.

https://duktape.org/index.html

https://bellard.org/quickjs/bench.html


Not just es2020, Duktape doesn't even support arrow functions and classes.

QuickJS seems interesting, but I couldn't manage to compile it on Windows (without MSYS2).


You can use this fork for msvc support: https://github.com/c-smile/quickjspp


Duktape supports ES5, with only partial support for anything ES6+ (and not much partial support, at that).

That said - having used Duktape in production, it's a very handy little library. Small, easy to drop into projects, great way to add support for custom user scripts or to run js code somewhere outside of a browser context.

Also - insanely easy to target still, despite the lack of ES6+, as long as you already have babel somewhere in your build pipeline.


c-smile (author of Sciter) maintains a MSVC compatible fork https://github.com/c-smile/quickjspp/


It is mathematically the most "economical" integer base in terms of space, when considering complexity of digit representation along with word length [1].

[1] Hayes, B. (2001). Third base. American Scientist 89: 490-494 (http://lrss.fri.uni-lj.si/sl/teaching/ont/lectures/third_bas...)


Of course the "optimal one" would be base "e" but nobody is going to be able to do anything remotely reasonable with it... (pg. 491 of that manuscript).


Well, you could... if you want to give up discrete integer representation...

Anyway, if ternary is actually optional in practice depends as much on how efficient the ternary logic can be implemented on a silicon process. If you increase integer storage efficiency by 10%, but circuit density decreases, maybe you're not getting enough value.


base 7 is very nearly e^2, and 20 is almost exactly e^3. Base 20 would fix many problems with floating point math, wouldn't it?

By the time someone built a base 20 computer it would probably be an anachronism anyway.


Okay but what's the significance of (non-unity) powers of e? e is the optimum of a specific function[1], and you lose the benefits for higher values.

It's true that you can conveniently represent the numbers by using integer powers of the base (like representing binary with hexadecimal), but the whole reason e is a "good" base in the first place is because you're (partially) minimizing the number of distinct symbols needed to represent a number, and you lose that once you go to a higher base.

Plus, using a slightly-off integer like 7 breaks the integer-power-mapping anyway.

[1] x ^ (N/x) for any N.


A team I was a part of at the uni made a fuzzy logic-based robot for a soft computing course, almost 20 years ago it seems. I rember that we were able to accomplish seemingly complex behavior (light tracking with obstacle avoidance) with only a few very simple fuzzy logic rules. Seems the project page is still up, along with the source code, schematics and documentation (in Croatian): http://www.zemris.fer.hr/predmeti/nenr/


Or the girl killed by her “mother” this week [1].

Humans mostly follow their instinct, and it is absurd/dangerous not to zoomorphise their behavior.

[1] https://abcnews.go.com/US/mother-accused-killing-14-year-dau...


They went for a short visit to Room 101, Ministry of love


I’m just reading it now and I must say it’s a rarely honest book and has actionable models and tactics for the sales non-“naturals”. It has opened my eyes.


How is this practice of inflating prices while exploiting urgency and lack of choice not clearly fradulent and illegal?


There are emerging alternatives on the market:

https://reason.com/reasontv/2017/10/16/doctors-direct-primar...

Note that the current system is actively fighting off the development of such alternatives...


I was there just 5 days ago on an aircraft tour which flew directly above the fissures. We landed in Kona normally. The lava fountains are awe-inspiring. Here's what I was able to record: https://www.youtube.com/watch?v=9Pn1MiYB5KQ


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

Search: