!pr0
!lm12
!rm75
Procedure for Converting S-C Source Files to Text Files
Without Owning an S-C Assembler
                               ............Bob Sander-Cederlof

Strangely enough, there are some of you who still do not own an S-C Assembler.  And some of you buy or would like to buy our Quarterly Disks or the Applesoft Docu-Mentor disks.

These disks contain source files which are only usable by the S-C Macro Assembler.  However, it is possible (even without an S-C Assembler) to convert them to regular text files so as to be readable by another brand assembler/editor.

The files appear in the catalog as type "I", which is supposed to mean Integer BASIC.  Of course the contents has nothing to do with Integer BASIC, but making them "I-files" has several advantages:

       *  they LOAD/SAVE faster than text files
       *  standard DOS commands can be used for load/save
       *  when the S-C Assembler is in the RAM card,
          DOS can automatically switch between
          Applesoft and Assembler as it normally
          would between Applesoft and Integer BASIC.

There are also some dis-advantages:

       *  some users have trouble believing they
          are not really Integer BASIC programs,
          and try to RUN them.
       *  the files are harder for people without
          an S-C Assembler to convert to another
          brand.

Which brings us back to the point of this article.

To make the procedure simple, you need at least a 64K Apple.  If you have an Apple //e, you are all set.  An older Apple needs a "language card", or "RAM card".

The first step in the conversion process is to load the file into memory and find out where it is.  Start by booting with your DOS 3.3 System Master disk, which loads Integer BASIC into the RAM card.  Then LOAD the S-C source file which you want to convert.  Integer BASIC will be switched on, but don't try to LIST or RUN!

Enter the Monitor by typing "CALL -151".  At this point you will get an asterisk prompt.  Look at locations $4C, $4D, $CA, and $CB.  You can do it like this:

       *4C.4D CA.CB
       004C- 00 96
       00CA- 58 73

Interpret the above as meaning that the source code begins in memory at $7358 and ends one byte before $9600.

If you use the monitor commands to look at the first 30 or 40 bytes (or more), you will discover how the source lines are stored.  Each line begins with a byte count, which if added to the address will give the address of the first byte of the next line.  Each line ends with a 00 byte.  The byte count includes both of these bytes, and all in between.  Here is a sample line:

       0F E8 03 41 42 43 84 4C 44 41 81 23 24 35 00

The second and third bytes are the binary form of the line number.  As usual in 6502 domain, the number is stored low-byte first. $3E8 means the line above is line 1000.

The fourth byte and beyond are ASCII codes for the text of the line, with two exceptions.  If the bytes are less than $80, they are plain ASCII.  If they are in the range from $81 through $BF, they represent a series of blanks.  $81 means one blank, $84 means four blanks, and so on.  The line above now decodes to:

       1000 ABC    LDA #$5

The other exception is not illustrated above, but here is one:

       08 F2 03 2A C0 20 2D 00

The token $C0 means "repeated character".  The next byte after $C0 gives the number of repetitions, and the byte after that tells what character to repeat.  Above the C0 20 2D means 32 "-" characters, so the whole line looks like this:

       1010 *--------------------------------

Armed with all that information, you can probably see how to write a simple Applesoft program to convert the memory image of the S-C source file to plain text and then write it on a text file.

In fact, here is just such a program:



       <<<<<listing of CONVERT S-C TO TEXT here>>>>>


!np
Here is a blow-by-blow description of how to use the program.

!lm+9
!pp-4
1.  Boot your DOS System Master to load INTBASIC into the RAM card.
2.  Load the S-C source file.
3.  Type CALL-151 to get into the monitor.
4.  Type CA.CB to get the starting address of the S-C source program (xx yy).
5.  Type 300:xx yy to store the starting address in a place Applesoft will not clobber.
6.  Type 3D0G to return to Integer BASIC.
7.  Type RUN CONVERT S-C TO TEXT to execute the Applesoft program listed above.
8.  Stand back and wait while the program chugs through the bytes.  When you see the Applesoft prompt again, it is all done!

!pp0
!lm-9
If you add a line at 315 to turn on MONCIO, you can see the text as it is produced.
