In the late 70’s, early 80’s there were many magazines and books devoted to the personal computers of the time that contained programs that you could type into your computer, save and use. Though tedious it was often the only way many people could get new software for their orphaned systems.Also there was a process of Boot Strapping, where you would type in a small program that would in turn let you load or create a bigger program. In the tradition of this I am offering the following Type In:
Let’s Make a CP/M Tape!
First off, if you don’t know what CP/M is, it is an operating system designed for 8080 and Z80 computers that was the basis for MS-DOS and just about every other operating system. There are literally 10’s of thousands of programs available for it, everything from games to productivity software. It was made available for the Adam on tape or disk and was the starting point for TDOS, an improved version of CP/M used on the Adam. You can still buy it online in my store (or even get it for free). But we are going to make one!
Squashing a Bug
To begin with you will need a blank tape, a tape initialized for Smart Basic using the INIT command and a copy of Smart Basic. The reason for three tapes is it is preferable to store these programs on a blank tape then on your Smart Basic tape. If you happen to run any of the programs with the Smart Basic tape in drive 1 IT WILL ERASE you Smart Basic tape. If you have an original Colecovision Smart Basic version 1.0 you will want to do something before you get started. You will want to squash a bug!
There is a bug in Smart Basic in that every time you load a program with a REM or DATA statement it will add an extra space after the REM or DATA, eventually pushing your code off the line and ruining the code. To fix this is easy:
- Start Smart Basic
- Type the following code:10 PRINT “Data bump bug fix”
20 POKE 15830,8
30 POKE 15831,55
40 POKE 15832,19
50 POKE 15824,216
- Save the code as HELLO on the tape using save HELLO (it is case sensitive)
- Reboot your tape and it should tell you the data bug is fixed, if not then you saved it with the wrong name
If you already have a HELLO program on your tape, load it and add the code above to it in the beginning. You can eliminate line 10 and line 60 if you want and combine all the POKEs onto one line.
Preparing the Tape
Now that we are ready to start boot your basic tape and when ready put in the initialized Smart Basic (SB) tape you will be saving the type in’s to. We will now type in the first program called PREPARE. It does what its name suggests, it prepares a tape to have CP/M on it.
1 HIMEM :39000: R = 40004: B = 40128 2 DATA 1,0,0,17,0,0,62,8,33,192,156,205,246,252,201 3 FOR K = 40000 TO 40014: READ D: POKE K,D: NEXT K 4 PRINT "PLACE BLANK TAPE IN DRIVE #1": PRINT "AND PRESS RETURN": INPUT Z$ 5 FOR K = 0 TO 1023: POKE B + K,229: NEXT K 6 FOR A = 0 TO 255 7 POKE R,A: PRINT "WRITING RECORD ";A; 8 CALL 40000: PRINT " DONE" 9 NEXT A
How it works:
1 > Tell SB to not touch memory above 39000 and set up the variables R and B. R holds where we will poke tape records and B is where our tape record buffer is.
2 > This is a small machine language (ML) code that we use to access the EOS routines to write a block to tape. The variable R which we defined in line 1 points to the block low byte. Here is the code:
LD BC,0 ;Block High Byte
LD DE,0 ;Block Low Byte
LD A,8 ;Tape drive 1
LD HL,40128 ;Buffer
CALL 0FCF6h ;Write one block
3 > This line reads in the ML in lien 2 and pokes it into memory starting at address 40128 which we defined on line 1
4 > This line pauses and prompts you to put in the blank tape we will be turning into a CP/M tape – PLEASE follow this instruction.
5 > This lines pokes into our buffer starting at the value for B the byte 229 which is CP/M’s code for unused byte on the tape. It fills the 1024 bytes with this code as each block is 1024 bytes long.
6 – 9 > These lines poke into the memory address R (inside the ML code) the block we are doing held in A, tells you it is writing the record, then calls the ML code to use EOS to write the buffer at 40128 to the tape. It will do this 256 times then tell you it is done.
So type this in, save it, put your blank tape in that you are turning into CP/M and then run the above. When it is done you will still have a blank tape, but now it is blank and ready for CP/M!
Typing in CP/M
Now we are ready to start typing in earnest! To create the CP/M tape we need to type in 13 programs, each program contains a loader and a bunch of data statements which hold 1024 bytes of CP/M code. The loader for each program is the same so you can save typing by only doing it once, saving it and then loading it and adding to it. I will show you how to do the first part and you will know how to do the other 12 after that. First I will explain the loader:
1 HIMEM :39000: R = 40004: B = 40128 2 DATA 1,0,0,17,0,0,62,8,33,192,156,205,246,252,201 3 FOR K = 40000 TO 40014: READ D: POKE K,D: NEXT K 4 PRINT "PLACE BLANK TAPE IN DRIVE #1": PRINT "AND PRESS RETURN": INPUT Z$ 5 READ A 6 IF A = -3 THEN CALL 40000: PRINT " DONE":END 7 IF A = -2 THEN READ A: POKE R,A: PRINT "WRITING RECORD ";A;: GOTO 5 8 IF A = -1 THEN READ A: FOR K = 0 TO 15: POKE B,A: B = B + 1: NEXT K: GOTO 5 9 POKE B,A: B = B + 1: GOTO 5
How it works:
1 – 4 > These are the same as the PREPARE program so I will not explain them
5 > This reads in a byte from the CP/M data statements. The byte can have one of 4 values:
0 – 255 = This is a byte that will be poked into memory
-1 = This tells the loader that the next byte to be read gets poked into memory 16 times – This saves on typing
-2 = This tells the loader that the next byte contains the record number this block of data gets saved to
-3 = This tells the loader we are done, write the block to tape and end
6 – 8 > These lines process the data that is read as described above
9 > Pokes the data into memory at B, increments B and then loops back to line 5 to do more
Once you have typed in the LOADER program save it. Now we will type in our first block:
30 DATA -2,0 31 DATA 24,1,229,62,201,50,102,0,49,255,199,175,203,88,32,9 32 DATA 62,2,203,64,40,7,60,24,4,203,96,32,249,50,79,0 33 DATA 62,255,50,77,0,120,50,78,0,38,6,1,1,0,17,0 34 DATA 218,229,245,197,213,205,85,201,48,96,209,33,0,4,25,235 35 DATA 193,3,241,225,37,32,234,62,2,211,127,33,132,0,17,0 36 DATA 4,6,5,126,79,238,85,119,190,32,50,238,85,113,190,32 37 DATA 44,25,16,239,1,233,20,42,130,0,237,66,40,13,33,0 38 DATA 8,54,229,84,93,19,1,255,7,237,176,33,161,200,17,0 39 DATA 1,1,63,0,237,176,33,140,200,195,21,1,33,14,255,62 40 DATA 1,211,127,121,50,77,0,195,0,218,209,193,241,225,195,49 41 DATA 200,62,10,211,127,237,67,128,0,1,0,4,237,176,62,2 42 DATA 211,127,42,128,0,233,34,128,0,42,130,0,17,233,20,183 43 DATA 237,82,40,238,62,14,211,127,42,0,128,17,83,202,183,237 44 DATA 82,32,219,33,2,128,17,0,8,1,0,120,237,176,24,206 45 DATA -1, 32 46 DATA 32,32,32,32,32,32,73,110,116,101,114,110,97,108,32,82 47 DATA 101,118,46,32,49,46,53,48,32,32,74,117,108,121,32,53 48 DATA 44,32,49,57,56,52,32,32,32,32,40,99,41,32,49,57 49 DATA 56,51,44,49,57,56,52,44,32,67,111,108,101,99,111,32 50 DATA 73,110,100,117,115,116,114,105,101,115,32,73,110,99,46,32 51 DATA 0,0,0,0,0,0,229,126,185,32,8,35,126,187,32,3 52 DATA 35,126,186,225,201,213,197,245,193,209,58,64,201,184,32,8 53 DATA 42,65,201,183,237,82,40,38,72,120,50,64,201,237,83,65 54 DATA 201,33,67,201,205,70,201,6,2,197,40,7,193,197,205,200 55 DATA 201,48,66,58,64,201,205,236,201,48,58,193,16,239,209,33 56 DATA 59,238,1,0,4,237,176,42,65,201,35,34,68,201,58,64 57 DATA 201,50,67,201,205,79,202,48,16,126,183,242,185,201,54,1 58 DATA 126,23,48,252,183,40,7,54,1,175,50,67,201,201,33,67 59 DATA 201,195,207,201,193,193,193,201,33,64,201,175,50,67,201,62 60 DATA 4,50,230,201,31,126,35,94,35,86,33,59,238,1,0,0 61 DATA 245,213,229,205,34,202,0,225,209,193,120,201,245,205,79,202 62 DATA 193,62,68,208,126,7,48,252,54,1,126,183,242,250,201,254 63 DATA 155,40,245,238,128,62,102,192,14,240,120,161,121,32,1,47 64 DATA 1,20,0,229,9,166,225,192,55,201,193,193,193,193,193,225 65 DATA 35,233,245,197,213,17,0,4,213,229,205,236,201,48,235,229 66 DATA 235,19,33,2,0,57,1,8,0,237,176,35,126,35,15,15 67 DATA 15,15,230,15,18,209,249,235,209,26,19,213,119,55,201,33 68 DATA 195,254,70,4,5,40,20,33,212,254,17,21,0,230,15,190 69 DATA 40,3,25,16,250,17,240,255,25,55,200,62,155,183,201,80 70 DATA 65,77,39,115,32,102,97,99,101,39,58,105,120,106,99,106 71 DATA 106,43,63,99,76,88,67,101,97,97,113,79,97,52,98,71 72 DATA 71,103,65,82,82,36,56,36,51,124,107,65,44,123,120,120 73 DATA 108,120,114,114,114,106,63,76,115,42,70,104,70,75,75,97 74 DATA 75,75,100,112,75,111,111,122,70,103,65,82,41,114,103,33 75 DATA 40,58,33,39,46,46,46,46,46,39,60,106,76,111,42,75 76 DATA 52,51,51,80,51,37,33,46,32,46,58,58,96,120,111,46 77 DATA 41,88,32,32,46,32,32,32,46,116,123,46,32,46,39,60 78 DATA 121,73,97,51,82,56,65,123,46,46,32,39,52,56,85,119 79 DATA 113,97,46,45,117,46,32,46,124,46,39,123,93,108,92,46 80 DATA 92,44,95,105,99,97,90,82,35,82,70,105,126,58,41,114 81 DATA 99,98,36,36,82,61,46,41,47,40,58,58,58,92,47,92 82 DATA 58,58,58,58,41,123,114,43,86,75,69,35,35,36,65,85 83 DATA 97,52,103,65,56,36,36,35,55,32,46,60,105,123,114,114 84 DATA 105,59,105,125,108,116,43,63,99,121,116,99,93,79,36,35 85 DATA 35,35,35,82,65,68,87,65,82,56,36,108,32,46,118,123 86 DATA 59,123,125,108,108,120,121,120,116,116,99,116,120,108,99,99 87 DATA 67,80,35,35,56,82,82,65,65,57,54,65,82,68,46,46 88 DATA 58,41,41,62,105,59,62,61,59,41,41,58,92,40,118,108 89 DATA 116,93,49,122,97,69,56,65,90,81,69,87,77,65,82,82 90 DATA 41,32,44,99,45,95,58,58,58,58,60,40,60,58,58,95 91 DATA 58,60,62,58,125,116,67,50,65,82,69,53,53,68,65,82 92 DATA 36,36,70,46,124,120,90,124,126,47,126,95,58,40,41,62 93 DATA 40,61,125,59,105,105,108,49,88,52,56,35,35,35,56,36 94 DATA 36,36,56,35,65,70,75,38,80,65,0,0,0,0,0,0 95 DATA -3
This is the first 1K of the CP/M tape. Once you have typed in it save it as CPM-0. DO NOT RUN IT – If you do it will ruin the tape you have in the drive.
After saving CPM-0, reload LOADER and do the same thing for CPM-1 through CPM-12. This will probably take a few days but it in the end it will be worth it. Place your new tape in and reset the system, within a few moments you will be at the CP/M A> prompt. At this point there is nothing on the disk so if you type DIR it will just say NO FILE. In an upcoming article I will show you how to get programs onto this tape.
If you decide to do this let me know. I will be posting another article soon on a CP/M program that will be of use to get more software onto the tape.