News for hackers. Stuff that matters.
Re:Cloning a 6502 Apple-1 in just 930 logic gates by ncmncm on Sunday May 10, 2020 @03:49PM (#23135527)
I still recall the shock discovering that Micro-soft BASIC in the Apple ][ did a linear search for the line number from, the beginning of the program, on each GOTO or GOSUB. It would have been super-easy to memoize the search result at the branch site, but Bill couldn't be bothered.
Re:Cloning a 6502 Apple-1 in just 930 logic gates by PhantomGremlin on Sunday May 10, 2020 @08:34PM (#23137680)
Sneer all you want, Microsoft Basic was a reasonable achievement considering that:

1) it ran in under 4K bytes of memory on an Altair 8800. That means less than 4,096 bytes of memory. Not 4,096 Kilobytes or Megabytes. 4,096 bytes.

2) An enhanced version ran in under 8K bytes of memory. Less than 8,192 bytes. Let me repeat: less than 8,192 bytes.

When you're fitting an entire BASIC interpreter in 8,192 bytes, you're not spending a lot of effort to memoize a search result.

Bill had a lot on his plate at the time. The software started out on the Altair, but all sorts of manufacturers were soon beating the door down begging for versions for the Commodore PET, the Atari, and countless other computers.

https://en.wikipedia.org/wiki/Microsoft_BASIC

Re:Cloning a 6502 Apple-1 in just 930 logic gates by perl4ever on Sunday May 10, 2020 @09:11PM (#23137914)
From what I've read, Microsoft BASIC was considered too bloated for a 4K machine, plus Bill Gates wrote an open letter to hobbyists and suggested they were all pirates, so a smaller BASIC was developed called "Tiny BASIC":

"Tiny BASIC was published openly and later invented the term "copyleft" to describe this. This made it popular in the burgeoning early microcomputer market."

https://en.wikipedia.org/wiki/Tiny_BASIC

Re:Cloning a 6502 Apple-1 in just 930 logic gates by ncmncm on Monday May 11, 2020 @02:45AM (#23139481)
It did not fit in 4K on the Apple ][. PET and Atari were also 6502, like Apple, so mostly the same code. Altair and the others were 8080. So, only two interpreters. It was the same design on two instruction sets, with some simple customization per vendor. Some had a Z-80, with extra instructions available: using those made your program smaller, but slower. It is doubtful he did.

That it was so short also meant there just wasn't much to it. Bill doesn't need your unpaid defense. He didn't make his $billions from BASIC. That just gave him a customer list.

Re:Cloning a 6502 Apple-1 in just 930 logic gates by quicklyfrozen on Sunday May 10, 2020 @08:06PM (#23137507)
Doesn't sound that easy to me. You'd need an efficient way to forget all those memoized values on each program edit, and every byte of program storage counted when memory size was a whopping 4K.
Re:Cloning a 6502 Apple-1 in just 930 logic gates by ncmncm on Monday May 11, 2020 @02:30AM (#23139414)
Trust me, it would be easy. They could all be erased on the first edit, in time not noticeable.

Essentially the same code would have been in each interpreter, so written just twice. The space for the code to do it would be in ROM, so would not take up any of your precious 4k.

Re:Cloning a 6502 Apple-1 in just 930 logic gates by fortran77 on Sunday May 10, 2020 @05:26PM (#23136357)
In fact you could poke around and get the line numbers in a different order and the program would still run properly.

That's why subroutines were put at the beginning of "efficient" code.

Re:Cloning a 6502 Apple-1 in just 930 logic gates by sitkack on Sunday May 10, 2020 @06:32PM (#23136932)
This is cool. I feel like this has implications in metaprogramming, code generation, state machines, interposition, and stuff I haven't thought of.

This changes my understanding of the semantics of basic immensely.

Re:Cloning a 6502 Apple-1 in just 930 logic gates by ncmncm on Monday May 11, 2020 @03:36PM (#23146057)
Sorry, it is not cool at all.

A system that runs subroutines faster according to how far they are from the start of the program is just badly designed. Robustness against poking in different line numbers is not worth trading off performance.

He should be ashamed.