Remix.run Logo
PaulHoule 9 days ago

The earliest home computers had tiny amounts of memory: my TRS-80 Color Computer started out with 4K of RAM and BASIC in ROM although within a few years I had it filled out with 64K of RAM. There weren't a lot of languages that would fit in 4K, but they included BASIC, FORTH and assembler (like the actual assembler.) [1]

My FORTH experience with that was writing a subroutine-threaded FORTH for the 6809 under the OS-9 operating system in about 3000 lines of assembler. I wrote to the Forth Interest Group and they sent me a card which had a list of standard words in FIG FORTH, mine complied with that except that I used the Unix-like system calls from OS-9 for file I/O instead of the block scheme most FORTHs used.

[1] The popular 6502 (Apple ][, Atari 400/800, C-64, ...) was particularly weak in support for compiled languages because it had few registers and fewer addressing modes but it was easy to write a FORTH for too.

satiated_grue 9 days ago | parent [-]

The 6502's lack of registers is one point of view.

Another point of view is that the zero page provides 256 registers:

https://spectrum.ieee.org/q-a-with-co-creator-of-the-6502-pr...

"[Bill Mensch]:Rod Orgill and I had completed the designs of a few microprocessors before the 6501/6502. In other words, Rod and I already knew what was successful in an instruction set. And lower cost was key. So we looked at what instructions we really needed. And we figured out how to have addressable registers by using zero page [the first 256 bytes in RAM]. So you can have one byte for the op code and one byte for the address, and [the code is compact and fast]. There are limitations, but compared to other processors, zero page was a big deal."

https://news.ycombinator.com/item?id=38627821

http://forum.6502.org/viewtopic.php?f=2&t=7304

renewedrebecca 9 days ago | parent [-]

I see this idea a lot, but I don't really buy it. I've coded in 6502 assembly for years, and the zero page is not register-like at all.

Best thing you can say about zero page is that it only requires one read cycle to fetch a value from. (Or one write cycle to store a value to it.)

Why ZP isn't like registers: You can't do register operations with it. For example, you can do this with the accumulator:

LDA #03 ; load immediate value of 3. STA $c000 ; store it at $c000.

or

LDA $1004 ; load a value from $1004. ADC $4000 ; add the value stored at $4000. STA $4001 ; store to $4001.

You can't do this at all with a zero page address. You have to go through an actual register first.