BigDumbDinosaur wrote:
cjs wrote:
As soon as you start using 24-bit pointers into your heap, you slow everything down drastically compared to using 16-bit pointers, regardless of whether it's a 6502 or 65816.
A 24-bit addressing mode of any kind with the '816 will incur a one-cycle penalty per memory access compared to use of 16-bit addressing with the same type of instruction....In the overall scheme of things, the performance penalty won't be all that severe, especially if the code is running on a system that can support a high Ø2 rate. Meanwhile, 24-bit indirect addressing combined with a 16-bit index register width will allow you to reach anywhere into address space with succinct code. Most importantly, you will be able to readily index across bank boundaries with no performance penalty.[/color]
I'm not sure that a "high φ2 rate" is relevant here; don't modern 8-bit 6502s also support the same clock speeds?
Certainly indexing across bank boundaries is a good advantage. But I'm not sure really covers everything you'd want for fast 24-bit pointer manipulation. Consider the following fragment of program text in a format like the "crunched" one used by early '80s MS BASIC interpreters. (8F and 89 are the tokens used for the REM and GOTO keywords, respectively, and the target of GOTO is stored as a pointer to the target line's data structure. That's converted to a line number in a saved image, and converted back to a pointer after loading, IIRC.)
Code:
address next linenum line data (hex) listing
──────────────────────────────────────────────────────────────────
10FFF7: FE FF 10 00 20 8F 68 65 6C 6C 6F 00 32 REM hello
10FFFE: 08 00 11 00 40 89 FE FF 10 00 64 GOTO 64
110008: 00 00 00
Here if you add a new line,
48 GOTO 64, the new line will be inserted at location $10FFFE, moving the
64 GOTO 64 line and end-of-program marker up in memory. I'm not too familiar with 65816 assembler, but looking through the instruction set this seems to me near as complex as doing it on a 6502, and probably not too much faster, since you still have no easily way to load, store and copy 24-bit pointers as a single unit, and you still usually need to keep your pointers in direct page memory "pseudo-registers" instead of just in a register. (That said, at least
some 24-bit pointer handling should still be faster on a 65816 than on a bank-switched 6502.)
On the other hand, as you point out, the 65816 offers considerable advantage in speed and ease of handling 16-bit arithmetic, so perhaps one should tout the advantage as being that you're getting the memory space of a bank-switched 6502 (many hundreds of kilobytes rather than many tens) with much more speed.
I guess that makes the 65816 more of a PDP-11-style "16 bit" processor than a 68000-style "16-bit" processor? Maybe I should be thinking of the 68000 as really a "16/32-bit" processor, and not expecting the PDP-11, 8086 and 65816 to compare to it in ease of use of >64K address space?
BigEd wrote:
Curt, I quite agree: a language such as Basic could surely do well with several 64k arenas for different types of information. I very much like the idea of a pair of 64k heaps to make for easier garbage collection.
It feels like the least-effort route to a large-memory BBC Basic might be to start with Acorn's BAS128, which already handles a separate space for interpreter purposes, yielding 64k space for program and data. Whether it would be easy or not to separate further, I don't know.
Sure, there's lots of room for easy improvement here in a Microsoft-style BASIC if you're willing to limit the size of any particular area to 64K. These use separate areas for program text, DIM'd arrays, scalar variables and string heap for non-constant strings; all these can be separated into their own 64K address spaces, along with moving disk buffers and the like to their own space as well.
A bit more difficult would be to separate string constants (normally part of program text) to their own area, or even multiple areas by using 24-bit pointers just for those. How much of a win that would be depends on the amount of constant string text in the particular program, but for something like a text adventure game this would probably be a big win.
This isn't anything you couldn't do on a 6502 without huge amounts of difficulty, but as BDD points out, it should all run significantly faster on a 65816 due to easy 16-bit arithmetic and being able to use 24-bit pointers in the direct page rather than having to bank switch.