
Here are listings of the three programs included in my 1989
article.  Everything is in ANSI.  I also have the two BASIC
programs as PRG files, but haven't decided how to post those,
if that's needed.

I seem to remember that Program 1 is mathematically very cool
and efficient (I think "elegant" is the word math majors use),
but I don't remember exactly why, and of course it's completely
un-commented.  :-)



Program 1: Split record identifier routine.

1100  ; "split.src"
1110  ;  set up rnum and size. jsr split.
1120  ;  returns with carry clear if split.
1130          ;fill in the locations you want:
1140  rnum    =$xxxx       ;record num. lo/hi
1150  size    =$xxxx       ;record length
1160  temp    =$xxxx       ;work memory lo/hi
1170  *       =$xxxx       ;(relocatable)
1180  ;
1190  split   lda rnum
1200          sta temp
1210          lda rnum+1
1220          sta temp+1
1230          ldx #17
1240          lda #0
1250          beq shift2
1260  mloop   bcc shift
1270          clc
1280          adc size
1290  shift   ror
1300  shift2  ror temp+1
1310          ror temp
1320          dex
1330          bne mloop
1340          inx
1350  sloop   asl
1360          bcc addnxt
1370  bump    adc #1
1380          bcs bump
1390  addnxt  adc temp,x
1400          bcc chkx
1410  bump2   adc #1
1420          bcs bump2
1430  chkx    dex
1440          bpl sloop
1450          cmp #254
1460          bcc test
1470          sbc #254
1480  test    cmp size
1490          rts





Program 2:  Major Bug Demo

100 rem ** major bug demo - c64/128  **
110 rem ** 1541 & 1571 series drives **
120 print: s=127: n=8: rem 0<n<256
130 f$="0:test"+str$(s)+",l,"+chr$(s)
140 open15,8,15: open2,8,2,f$
150 r=n: gosub300: print#2,chr$(255);
160 r=1: gosub300: forr=1ton
170 a$(r)=str$(r): print#2,a$(r);
180 next: gosub270: print
190 readc$: ifc$<>"999"then210
200 print: gosub270: close2: close15: end
210 ac$=left$(c$,1): r=val(mid$(c$,2))
220 printc$,: gosub300: ifac$="w"then240
230 printa$(r),: gosub320: printb$: goto250
240 a$(r)=a$(r)+"*": print#2,a$(r);: printa$(r)
250 rem ifr*s-int(r*s/254)*254<sthengosub310
260 goto190
270 print"rec#","nominal","actual"
280 r=1: gosub300: forr=1ton: gosub320
290 printr,a$(r),b$: next: return
300 p$="p"+chr$(2)+chr$(r)+chr$(0)+chr$(1)
310 print#15,p$;: return
320 b$=""
330 get#2,d$: ifd$=""ord$=chr$(0)thend$="@"
340 b$=b$+d$: ifst=0then330
350 return
360 data w1,r2,r5,w4,w7
999 data 999




Program 3: Minor Bug Demo

100 rem ** minor bug demo - c64/128 **
110 rem ** 1541/71/81 series drives **
120 print: s=126: n=8: rem 0<n<256
130 f$="0:test"+str$(s)+",l,"+chr$(s)
140 open15,8,15: open2,8,2,f$
150 r=n: gosub250: print#2,chr$(255);
160 a$="123456789": r=1: gosub250
170 forr=1ton: print#2,a$;: next
180 z$="12"
190 r=1: gosub250: print#2,z$;
200 forr=2ton
210 rem gosub250: gosub250
220 gosub280: printr,b$
230 rem ifr*s-int(r*s/254)*254<sthengosub270
240 next: close2: close15: end
250 p$="p"+chr$(2)+chr$(r)+chr$(0)+chr$(1)
260 print#15,p$;: return
270 gosub250
280 b$=""
290 get#2,d$: ifd$=""ord$=chr$(0)thend$="@"
300 b$=b$+d$: ifst=0then290
310 return

