Macro to Generate Quotient/Remainder Table for Hi-Res Work
                       ....................Bob Sander-Cederlof

A few months back an article in Byte magazine presented some fast hi-resolution plotting routines.  One of the secrets to fast plotting is table lookup rather than computation of base addresses and offsets.  The article included a 560 byte table for all the possible quotients and remainers you can get when dividing X by 7, where X is the horizontal coordinate (0 to 279).

The table of quotients and remainders makes it easy to get the byte position on a line (quotient) and the bit position in the byte (remainder) for a given dot X-coordinate.

Typing a 560 byte table into the computer is no fun, no matter how you do it.  You might go into the monitor and type directly in hex, then later BSAVE the table.  Or you might use an Applesoft program to build the table.  I think the easiest way is to write a few short macros, and let the assembler do the work.

If you have Version 1.1 of the S-C Macro Assembler, the following code will do the trick.  Version 1.0 cannot handle it, because the nesting level goes too deep.  The listing it prints out gets quite long, due to all the macro expansion.  Therefore I am just printing the source code here.  The table it produces is also long, so I am just showing the beginning and end of it.


!LM+5
1000 *--------------------------------
1010 *   GENERATE QUOTIENT-REMAINDER
1020 *   TABLE FOR ALL POSSIBLE VALUES
1030 *   OF X/7, WHERE X=0...279
1040 *--------------------------------
1050        .MA DO.QS
1060 R      .SE 0
1070        >DO.RS
1080 Q      .SE Q+1
1090        .DO Q<40
1100        >DO.QS
1110        .FIN
1120        .EM
1130 *--------------------------------
1140        .MA DO.RS
1150        .DA #Q,#R
1160 R      .SE R+1
1170        .DO R<7
1180        >DO.RS
1190        .FIN
1200        .EM
1210 *--------------------------------
1220 Q      .SE 0
1230 QR     >DO.QS
1240 *--------------------------------
!LM-5


<<<show the beginning and end few lines of the hex dump of the table here>>>
