Jump to content
Gibson Brands Forums

C128 out of memory in 0 error in c64 mode and garbage characters in 128 mode


FenderGuy1

Recommended Posts

Come on Pippy, I use modern PC's for internet and modern gaming only, and skyping, but for everything else i use a Commodore 64 <3

I know, Nate, I was just being silly.

 

I'm a photographer who, obviously, uses modern kit for work but I have an enormous amount of love for cameras and lenses from the 1850s onwards.

Even peripheral items (i.e. 'Junk') to do with the Art have a certain fascination for me.

I'm a passionate fan (and part-time, amateur, collector) of high quality photographic prints produced by the Collodio-Albumen process. This was pretty much extinct by the 1890's when that new-fangled 'Silver-Chloride' parvenu arrived on the scene.

 

If you want to keep some of the old computer technology alive then go for it.

 

[thumbup]

 

P.

Link to comment
Share on other sites

I know, Nate, I was just being silly.

 

I'm a photographer who, obviously, uses modern kit for work but I have an enormous amount of love for cameras and lenses from the 1850s onwards.

Even peripheral items (i.e. 'Junk') to do with the Art have a certain fascination for me.

I'm a passionate fan (and part-time, amateur, collector) of high quality photographic prints produced by the Collodio-Albumen process. This was pretty much extinct by the 1890's when that new-fangled 'Silver-Chloride' parvenu arrived on the scene.

 

If you want to keep some of the old computer technology alive then go for it.

 

[thumbup]

 

P.

Thanks Pip, I am luckily the proud owner of a working C64 :) and proud of it! My dad had one when he was a kid, so I am taking that tradition on, its a tradition my dad started, and I will carry it on untill I die

Link to comment
Share on other sites

Nathan, little bro. I'm sure you are aware that I'm the biggest champion you have here, but the computer posts is driving folks crazy. If you want to chat computers, send me a PM and we can chat away. I work in the field, have a degree and several certifications. I will be happy to point you in the right direction. PM me if your want to chat computers. [thumbup]

Link to comment
Share on other sites

Nathan, little bro. I'm sure you are aware that I'm the biggest champion you have here, but the computer posts is driving folks crazy. If you want to chat computers, send me a PM and we can chat away. I work in the field, have a degree and several certifications. I will be happy to point you in the right direction. PM me if your want to chat computers. [thumbup]

OK, I'll send you one

Link to comment
Share on other sites

Pretty easy it is just:

The Commodore 128, as its name implies has 128k of primary RAM in two 64K blocks. The computer's elaborate memory management system can mix RAM from one or both blocks together with ROM or I/O chip registers to create the configurations known as banks. In general the 128 sees RAM from block 0 in even-numbered banks (0,4,8,14) and RAM from block 1 in odd-numbered banks (1,5,9). A notable exception is bank 15, where RAM from block 0 is seen. Another significant exception is that in every bank the system normally sees RAM from block 0 in locations 2-1023/$0002-$03FF. (Locations 0-1/$00-$01 are used for the processor's on-chip I/O port and are never seen as RAM.) This means that the lowest 1K of RAM in block 1 normally remains invisibile and unused. The common 1K block and locations 1024-7167/$0400-$1BFF in block 0 have special uses. MMU registers, rather than RAM or ROM, are seen at addresses 65280-65284/$FF00-$FF04 in every bank configuration.

 

Two pointers in page 10/$0A indicate the range of locations in block 0 considered free RAM. Locations 2565-2566/$0A05-$0A06 point to the lowest free address, and locations 2567-2568/$0A06-$0A07 point to one byte beyond the highest free address. These pointers are initialized during the reset sequence to 7168/$1C00 and 65280/$FF00, respectively. The pointer values can also be changed with the Kernal MEMTOP and MEMBOT routines. However-unlike earlier Commodore computers - the values in these pointers have no effect on the range of addresses used by BASIC.

 

BASIC RAM Usage

For BASIC programming, the areas of RAM normally available for storage of programs and variables are locations 7168-65279/$1C00-$FEFF in block 0 and 1024-65279/$0400-$FEFF in block 1. This is a total of 122,368 bytes of available RAM space (illustrated in Figure 1). This explains why part of the message you see when you turn on or reset the computer says 122365 BYTES FREE. (The three missing bytes are to account for the zero byte required by BASIC before the first program line and the two zero bytes used to mark the end of the program.)

 

Actually, its a bit misleading to claim that many free bytes, since you can write a BASIC program 120,000 bytes long. The free RAM is divided into two distinct segments: 58,112 bytes in block 0 for BASIC program text and 64,256 bytes in block 1 for variables and strings. (For comparison, the Commodore offers 38,911 bytes for program text and variables combined.)

 

As noted in Figure 1, there is one additional factor which affects the amount of memory available for program text. When you use a GRAPHIC statement to set up a high-resolution screen, an additional 9K is reserved in block 0; 1K at 7168-8191/$1C00-$1FFF for color information and 8K at 8192-16383/$2000-$3FFF for the screen bitmap. In this case, the amount of RAM available for BASIC program text is reduced to 48,896 bytes (locations 16384-65279/$4000-$FEFF in block 0). If a program is already in memory when the GRAPHIC statement is executed, program text will be moved upward in memory - the starting address will be changed from 7169/$1C01 to 16385/$4001 - and the program will be relinked to work at the new addresses. Once a high-resolution memory area is established, it remains allocated until a GRAPHIC CLR statement is executed, at which time the program text is moved down to start at 7169/$1C01 again.

 

Pointers in zero page and page 18/$12 indicate the amount of RAM currently used for program text and variables. BASIC program text is assumed to begin at the address in block 0 specified in location 45-46/$2D-$2E. That pointer is always initialized to 7169/$1C01 during the BASIC cold start routine. Unlike the Commodore 64, which sets its start-of-free-memory pointer, the 128 sets the address value without regard for the value in locations 2565-2566/$0A05-$0A06. Locations 4626-4627/$1212-$1213 point to one byte beyond the highest address in blcok 0 available for program text. That pointer is initialized during BASIC cold start to 65280/$FF00, again without regard to the value in the Kernal memory pointer at locations 2567-2568/$0A07-$0A08.

 

The actual ending address of the program text currently in memory is specified by the value in locations 4626-4625/$1210-$1211. That pointer is initialized during the BASIC CLR routine with an address valye that is two bytes beyond the starting address in locations 45-46/$2D-$2E. The pointer value is updated each time a BASIC program line is added or deleted. An OUT OF MEMORY error occurs if the address in locations 4624-4625/$1210-$1211 reaches the value in locations 4626-4627/$1212-$1213. The ending address pointer is set after a LOAD to the address of the last byte loaded, and the SAVE routine uses the values in the starting and ending address for the block of memory to be saved.

 

The address in the pointer at locations 47-48/$2F-$30 marks the start of scalar (nonarray) variables in bank 1. The pointer is initialized to 1024/$0400 during the BASIC cold start routine. A pointer at locations 49-50/$31-$32 marks the end of scalar variables and the beginning of arrays; another pointer at locations 51-52/$33-$34 marks the end of arrays and beginning of free memory in block 1. The latter two pointers are reset to the value in locations 47-48/$2F-$30 during the BASIC CLR routine.

 

The free memory in block 1 is used to hold strings of all types - constants, variables, and arrays. A pointer at locations 57-58/$39-$3A holds an addres which is one byte beyond the highest address of strings in block block 1. It is initialized during BASIC cold start to point to 65280/$FF00. The string pool is filled from this address downward toward the bottom of free memory indicated in locations 51-52/$33-$34. A pointer at locations 53-54/$35-$36 marks the current address of the bottom of the string pool. That pointer is reset to the value in locations 57-58/$39-$3A during the BASIC CLR routine. An OUT OF MEMORY error occurs if the value in locations 53-54/$35-$36 reaches the value in locations 51-52/$33-$34.

 

Reserving RAM

There are occasions when you will want to divert an area of RAM from its normal usage. For example, you may need to set asie space for a machine language routine, an alternate screen display, or a data buffer. For machine language programming, you can use any area of RAM in you are willing to learn the intricacies of the 128's banking scheme. Otherwise, its best to restrict your programming to certain known areas. For a machine language routine to be used in conjunction with a BASIC program, you'll need to select an area which BASIC doesn't normally use, or to take away some memory that otherwise would be used for program text or variable storage.

 

Locations 4864-7167/$1300-$1BFF in block 0 are currently unused (even though they are called "reserved" in some Commodore literature). This 2304-byte area is the largest segment of unused, protected RAM in the 128, and it is becoming extremely popular with 128 ML programmers - much like the $C000 block in the Commodore 64. You can expect to see many ML programs using this area.

 

Other, shorter blocks are also available if certain BASIC features are not used. If tape is not used, the 256 bytes at 2816-3071/$0B00-$0BFF are available. However, unlike other free blocks, this page may be overwritten during a reset because disk boot sectors are read into this area. Thus, the time-honored Commodore tradition of using the cassette buffer for short ML routines is less suitable in the 128. (It's annoying to have to reload your routine after each reset.)

 

If your program doesn't use RS-232 communications, the two RS-232 buffers at 3072-3583/$0C00-$0DFF provide a 512-byte workspace. This is probably the best area for short ML routines that you wish to use in conjunction with BASIC. (Unlike the cassette buffer, this area always survives reset intact.) If your program doesn't use sprites, the 512-byte sprite definition area at 3584-4095/$0E00-$0FFF is also available. Of course, if your program uses neither tape nor RS-232 nor sprites, you can use the full 1280 bytes at 2816-4095/$0B00-$0FFF, or any subsection thereof.

 

To use a large ML program in conjunction with BASIC, there is an easy way to reserve over 11K of protected RAM. However, this technique works only if neither the BASIC nor ML program requires high-resolution graphics. The trick is to use the BASIC GRAPHIC statement to set aside a high-resolution screen area at 7168-16383/$1C00-$3FFF. As mentioned above, this area remains allocated until a GRAPHIC CLR statement is executed. Simply begin your BASIC program with a line like GRAPHIC 1:GRAPHIC 0 (or GRAPHIC1:GRAPHIC5 if you want to use the 80 column display). The BLOAD or POKE the machine language program into the reserved area. In addition to the 9K screen area, you can also use the contiguous unused area just below, at 4864-7167/$1300-$1BFF. If you want to use a machine language program in conjunction with BASIC and high-resolution graphics, you'll have to resort to bank-switching techniques if the program is too large to fit in the unused area at 4864/$1300.

 

It's possible to reserve space above or below either the BASIC or variable/string areas. To reserve space below BASIC program text, increase the value in the start-of-BASIC pointer at locations 45-45/$2D-$2E by the number of bytes you want to reserve. (To reserve an even number of 256-byte pages, you need only change the value in location 46/$2E.) Two other steps are also necessary; BASIC requires a zero byte below the first location in its program text space, and a NEW operation is required to reset other important memory pointers. For example, to reserve three pages (768 bytes) below the normal start of BASIC, you would use a statement like this:

 

poke46,31:poke31*256,0:new

 

After this statement is executed, the area at 7168-7935/$1C00-$1EFF is protected from BASIC until the next time the BASIC cold start routine is performed (normally during the next reset sequence). The pointer value is unaffected by RUN/STOP-RESTORE. This technique is less useful when a high-resolution screen area is allocated. In that case, the start of BASIC is moved to 16384/$4000. The technique for reserving space at the start of BASIC still works, but the reserved memory will lie above 16383/$3FFF, which is the highest address seen as RAM in bank 15 - the bank in which Kernal ROM is visible and to which BASIC defaults. Thus, and ML routine above that boundary will be invisible unless you tinker with the MMU configuration register.

 

Space can be reserved at the top of the BASIC program area by reducing the value in the pointer at locations 4626-4627/$1212-$1213 by the desired number of bytes. (Again, if you wish to reserve an even number of 256-byte pages, you can simply reduce the value in location 4627/$1213.) No additional steps are required other than changing the pointer value. This technique was often used in the Commodore 64 to reserve space for machine language routines; its usefulness is more limited in the 128 because of the 16384/$4000 boundary of RAM visible in bank 15, which was mentioned above. To easily use the reserved area for an ML routine in conjunction with BASIC, the top of memory must be lowered sufficiently to make at least a portion of the reserved area appear below the boundary of RAM visible in bank 15; this dramatically reduces the amount of memory available for program text. It's not even possible when a high-resolution screen area is allocated. The technique can, however, be useful for setting aside an area in block 0 for a buffer, a reserved area of memory for data storage.

 

Clear enough?

Link to comment
Share on other sites

 

The trick is to use the BASIC GRAPHIC statement to set aside a high-resolution screen area at 7168-16383/$1C00-$3FFF. As mentioned above, this area remains allocated until a GRAPHIC CLR statement is executed. Simply begin your BASIC program with a line like GRAPHIC 1:GRAPHIC 0 (or GRAPHIC1:GRAPHIC5 if you want to use the 80 column display). The BLOAD or POKE the machine language program into the reserved area. In addition to the 9K screen area, you can also use the contiguous unused area just below, at 4864-7167/$1300-$1BFF. If you want to use a machine language program in conjunction with BASIC and high-resolution graphics, you'll have to resort to bank-switching techniques if the program is too large to fit in the unused area at 4864/$1300.

 

 

 

That's usually what I do.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...