4

On home / personal computers (such as before 1984), a machine might be described as having 24k RAM, but only 18k of that available to BASIC. If the machine had BASIC and the OS (or BIOS) stored in ROM, what would have been in this 6k of RAM that wasn't available to BASIC?

I assume this space would have been used to store variables or strings (or assembly-code which could use all of the memory), so I'm looking to see if anything else was stored there.

Would this computer need to load the entire OS/BIOS into RAM, or only some variable components .

  • 1
    You can probably learn a lot by reading about the memory layout for machines such as the Apple 2: apple2history.org/history/ah03 – Greg Hewgill Nov 21 '19 at 1:16
  • 2
    Your phrase "If a machine had 24k RAM, and only 18k of that available to BASIC" refers to the fact that was only 18k of memory available for the code of a program written in BASIC. The remaining 6k would be used for other purposes, such as storing the contents of the screen (display memory), and for the operating system itself. A BASIC program would have access to all this memory: but changing its contents would affect the image on screen or the operation of the operating system. This could be a good or a bad thing, depending on what the code does. – Kaz Nov 21 '19 at 9:44
  • 1
    @Raffzahn Maybe I'm having a very altruistic morning. :) Either way, if you don't feel the edited question is good enough to reopen, so be it. – Kaz Nov 21 '19 at 10:07
  • 1
    @Kaz +5 for having an 'altruistic morning' :) May your day be as promising. – Raffzahn Nov 21 '19 at 10:09
  • 1
    Why is this such a bad question? – dashnick Nov 21 '19 at 14:01
5

Let's take for example an MSX computer with 64K RAM. That's what you get on boot:

enter image description here

Where does this 28815 come from?

To start with, a MSX is a Z80 based machine. The Z80 has an addressing space of 64K. The MSX standard divides these 64K in four 16K pages that can be independently switched to any internal or external memory slot.

When booting in BASIC mode (the default unless there's a disk system present or a game cartridge inserted) the first page is switched to the BIOS ROM and the second page is switched to the BASIC interpreter ROM. This leaves two more pages that are switched to RAM, so 32K RAM are available.

Now, the MSX system reserves some RAM for BIOS work area. This area starts at F380h, so this turns those 32K into 29568 bytes. Add (or better, substract) one extra K or so for BASIC-specific work area and the stack itself, and that's it, 28K free.

(Side note: when a disk system is present additional work area is required for MSX-DOS, so the free space in BASIC turns into 23K)

And what happens with those "invisible" 32K RAM in the lower two pages?

Nothing. That is, BASIC does nothing with them. The MSX2 standard introduced a limited RAM disk mechanism that made use of that memory area, but other than that, that RAM was "wasted" as far as MSX-BASIC was concerned.

Of course you were free to use that extra RAM from BASIC using the BIOS inter-slot read/write routines (you'd need custom assembly code for that, though) but from the point of view of the BASIC interpreter itself that RAM didn't exist.

|improve this answer|||||
  • If you are writing a custom 32k (simple) cartridge ROM for MSX-1 in pure machine code, then can't you use the whole 64k RAM in an MSX-1 machine from the custom cartridge program? When I mean simple cartridge -I mean it just contains a single EPROM chip (and no other chips such as mapper chips) . – Rosemary Nov 25 '19 at 3:30
  • If you write your own program in machine code, then you are free to use the entire machine hardware (including RAM) however you want, but the question asked especifically about the RAM reported as available in interpreted BASIC environments. – Konamiman Nov 25 '19 at 7:20
5

If by "unavailable to store BASIC program text," the general answer would be "all sorts of stuff." A typical memory map for an early Apple system would be along the lines of the following:

$0000 - $00FF (0 - 255): Zero Page (system variables)
$0100 - $01FF (256 - 511): 6502 Processor Stack
$0200 - $02FF (512 - 767): GETLN Line Input Buffer
$0300 - $03CF (768 - 975): Free Space for Machine Language, Shape Table, etc.
$03D0 - $03FF (976 - 1023): DOS, ProDOS, and Interrupt Vectors
$0400 - $07FF (1024 - 2047): Text Video Page and Peripheral Screenholes
$0800 - $0BFF (2048 - 3071): Text Video Page 2 or Applesoft Program and Variables
$0C00 - $1FFF (3072 - 8191): Free Space for Machine Language, Shapes, etc.
(might be overwritten if you use a lot of variables or BASIC program is long)
$2000 - $3FFF (8192 - 16383): High Resolution Graphics Page 1
$4000 - $5FFF (16384 - 24575): High Resolution Graphics Page 2
$6000 - $95FF (24576 - 38399): Applesoft String Data
(may have a little space free)
(some BASIC programs move the variables all the way up to $4000 or even $6000)

There's a lot of machine code and corresponding data needed to do the basic operations of a machine such as reading from the keyboard, keeping track of what program is loaded, and so on. As you can probably guess, you've asked a really broad question.

The best thing to do is to read through, or at least skim, the (non-BASIC) reference manuals for some typical computers, such as the Apple II Reference Manual and the Commodore 64 Programmer's Reference Guide. These go into detail about how the memory is used.

To understand them, you may need some basic knowledge of assembly language programming. If you don't have that at all, you should probably start with a beginner's machine-language tutorial first. There are tons of books and other resources out there for this, varying vastly in quality, but one I came across recently that looks good is Roger Wagner's Assembly Lines: The Complete Book.

|improve this answer|||||
1

In general: there were some system variables, system stack, display memory, buffers, etc. On some systems, there was a RAM area "under" the ROM (it means on the same address, but not accessible in a straight way) - for example, the Atari XL.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.