The file I assembled and downloaded as a .PRG file, using the Virtual 6502 Assembler, I smart attached in the V.I.C.E. C128 emulator. I then attached an empty .D64 disk file, and used Basic 7.0 to save memory location $C000 to $C12F to a binary file, called “usrfunc04.c000”. I detached the .D64 file, and closed V.I.C.E. C128. In the C64 emulator I rewrote the previous C64 Basic program so it loads this binary file from disk. It then proceeds to checking of primality of numbers between 0 and 65535. I saved this Basic program to the same disk as the binary file, and copied it as text in the listing below.

[ part 1 | part 2 | part 3 | part 4 | part 5 ]

It was a bit of a hassle, but it all works, and that’s what counts here.


0 rem testusrf-0-4.bas
1 rem version 6 - test completed usr function
10 on s goto 20,40
20 print "loading binary file...":print
30 s=2:load"usrfunc04.c000",8,1
40 poke 785,0: poke 786,192:rem usr function at $c000
50 print "... (tests between 0 and 65535)":print
60 for n=0 to 65535
70 m = usr(n)
80 print n;"is ";: if not m then print "not ";
90 print "prime"
100 print "any key to continue"
110 poke 198,0:wait198,1:poke198,0
120 next n