Hello,

This is my first post so apologies in advance if I make a fool out of myself

I've recently bought a CPC 6128 and started playing with assembler. I created a small program that calculates the number of primes up to 1000. Its beginning looks following:

`WRITE "primes.bin"`

org &1200

call Main ; call the main part of the program

ld e,0

ld (res),de ; load result to memory for later use

ret

res equ &3000 ; address to store the result in

...

some more code to do the actual calculation

After assembling that code in Maxam I can run following basic commands:

`MEMORY &11FF`

LOAD "primes.bin", &1200

CALL &1200

RES=PEEK(&3001)

PRINT RES

with the result being 168, as expected.

I would like to have a little basic program though which would execute the above commands, as well as measure time required to calculate the prime numbers. In order to achieve that I wrote the following:

`10 MEMORY &11FF`

20 LOAD "primes.bin", &1200

30 t1=TIME

40 CALL &1200

50 t2=TIME

60 result=PEEK(&3001)

70 td=INT((t2-t1)/3)

80 PRINT result;"primes found in";td;"* 1/100 s."

SAVE "primes.bas

However now whenever I try running that basic program, it throws a "Memory full in 20" error every time.

I checked the

BASIC programming tips manual for creating the simple loader and looked for an answer to this problem on this forum and the web, but nowhere could find anything that would help. Is there (there must be) something that I'm missing?

Thanks in advance!

**[EDIT] Solved**

In case anyone has the same problem in the future, after some experimentation in WinApe it turned out that there needs to be exactly 4100 bytes of free space in memory after the end of the loaded basic program in order to avoid the Memory full problem. The basic program always starts at &170.In other words, code of the basic loader should look like this:

` 10 MEMORY <368(&170) + size of the basic program in memory + 4100>`

20 LOAD <filename>, <number above + 1>

...

Or just use any reasonably high number (like &8000) instead of what I did in the beginning...