brendan@gryphon.COM (Brendan Kehoe) (07/16/89)
Following is the ymodem source I mentioned earlier. It's in Lads format, but all you have to do is strip off the leading line #'s and change the .opt stuff here and there, and you can form it to most of the assemblers out there.. I hold no guarantee with this...I just found it on a bbs one day and grabbed it.. --- cut here --- 1000 ; ymodem protocol source 1010 ; by the voyager finally done on 1/17/88 1020 ; i was too lazy to include more comments. 1030 ; it was impossible to add a buffer 1040 ; window to this - the blocks are 1050 ; 1024 bytes long, bigger than the 1060 ; screen! this should be a seq file 1070 ; for commodore macro assembler, and a 1080 ; prg file for lads or symass. 1090 ; 1100 .opt nolist 1110 ; 1120 * = $c000 ;you can change this.. 1130 ; 1140 mem = $c400 ;..and this to whatever you want 1150 header = mem+$0400 1160 crc = $61 1170 memory = $63 1180 sizcount = $65 1190 calcrc = $69 1200 crclen = $6b 1210 endfile = $6d 1220 st = $90 1230 blknum = $b0 1240 badblk = $b2 1250 setup = $ef7e 1260 chrout = $ffd2 1270 settim = $ffdb 1280 chrin = $ffcf 1290 getin = $ffe4 1300 chkin = $ffc6 1310 chkout = $ffc9 1320 restor = $ffcc 1330 close = $ffc3 1350 ; 1360 jmp xmit 1370 jmp recv 1380 data .byt 0,0,0,1,0,1,0,0,10,0 1390 ; 1400 ; data+0 : timer1 1410 ; 1 : timer2 1420 ; 2 : last block good or bad 1430 filend = data+3 1440 ; 4 : abort code return 1450 ; 5 : first blockprint 1460 ; 6 : signal being sent 1470 sigtry = data+7 1480 blktry = data+8 1490 ; 9 : # of 128-byte blocks 1500 ; 1510 ; abort code returns: 1520 ; 1530 ; 0 : eot received/acknowledged 1540 ; 1 : ^x received 1550 ; 2 : c= pressed 1560 ; 3 : timeout 1570 ; 4 : more than 10 tries a block 1580 ; 5 : lost synchronization 1590 ; 1600 blkset inc blknum 1610 bne noinc 1620 inc blknum+1 1630 noinc lda blknum 1640 sta header+1 1650 eor #255 1660 sta header+2 1670 ldx data+9 1680 bne shorter 1690 ldx #02 1700 jsr chkin 1710 lda #00 1720 sta sizcount 1730 sta sizcount+1 1740 lda #<mem 1750 sta memory 1760 lda #>mem 1770 sta memory+1 1780 ldy #00 1790 getblk ldx filend 1800 beq padblk 1810 getonce jsr chrin 1820 .byt $2c 1830 padblk lda #00 1840 sta (memory),y 1850 ldx filend 1860 beq notend 1870 lda st 1880 beq notend 1890 lda sizcount 1900 sta endfile 1910 lda sizcount+1 1920 sta endfile+1 1930 ended ldx #00 1940 stx filend 1950 notend iny 1960 bne incr 1970 inc memory+1 1980 incr inc sizcount 1990 bne getblk 2000 inc sizcount+1 2010 incr2 lda sizcount+1 2020 cmp #04 2030 bne getblk 2040 ldx filend 2050 bne noshort 2060 lda endfile+1 2070 asl a 2080 sta data+9 2090 lda endfile 2100 and #$80 2110 rol a 2120 adc data+9 2130 tay 2140 iny 2150 iny 2160 sty data+9 2170 cpy #08 2180 bcc carry 2190 noshort lda #<mem 2200 sta memory 2210 lda #>mem 2220 sta memory+1 2230 lda #00 2240 sta data+9 2250 lda #02 2260 sta header 2270 jmp short2 2280 shorter clc 2290 lda memory 2300 adc #$80 2310 sta memory 2320 bcc carry 2330 inc memory+1 2340 clc 2350 jmp carry2 2360 carry lda #>mem 2370 sta memory+1 2380 carry2 lda #128 2390 sta sizcount 2400 lda #00 2410 sta sizcount+1 2420 lda #01 2430 sta header 2440 dec data+9 2450 short2 ldx #01 2460 jsr savstk 2470 sty header+3 2480 stx header+4 2490 jmp setup 2500 signal ldx #06 2510 signal2 stx sigtry 2520 sta data+6 2530 codsen jsr timer 2540 ldx #05 2550 jsr chkout 2560 lda data+6 2570 beq wait 2580 jsr chrout 2590 wait ldx 653 2600 cpx #02 2610 bne table 2620 cpx #00 2630 rts 2640 table jsr getchr 2650 cpx #00 2660 beq return 2670 inc data 2680 bne wait 2690 inc data+1 2700 bne wait 2710 dec sigtry 2720 bne codsen 2730 ldx #03 2740 return rts 2750 getchr sty $57 2760 lda 667 2770 cmp 668 2780 beq get1 2790 ldy 668 2800 lda ($f7),y 2810 inc 668 2820 ldx #00 2830 jmp get2 2840 get1 ldx #02 2850 lda #00 2860 get2 ldy $57 2870 rts 2880 init ldy #00 2890 sty blknum 2900 sty blknum+1 2910 sty badblk 2920 sty badblk+1 2930 sty data+2 2940 rts 2950 xmit jsr init 2960 sty data+9 2970 iny 2980 sty filend 2990 sty data+5 3000 jsr setup 3010 jmp code 3020 ack lda #10 3030 sta blktry 3040 lda filend 3050 bne next 3060 lda data+9 3070 bne next 3080 jmp eot 3090 next jsr blkset 3100 nak ldx #05 3110 jsr chkout 3120 send0 ldy #00 3130 send4 lda header,y 3140 jsr chrout 3150 iny 3160 cpy #03 3170 bne send4 3180 ldx #00 3190 jsr savstk 3200 lda header+3 3210 jsr chrout 3220 lda header+4 3230 jsr chrout 3240 ldx 667 3250 stx 668 3260 code lda #00 3270 ldx #10 3280 jsr signal2 3290 beq nope0 3300 cpx #03 3310 beq send0 3320 txa 3330 jmp exit 3340 nope0 cmp #$06 3350 bne nope1 3360 jsr restor 3370 lda #'-' 3380 jsr chrout 3390 jmp ack 3400 nope1 cmp #$15 3410 bne nope2 3420 nak0 jsr restor 3430 lda #':' 3440 jsr chrout 3450 dec blktry 3460 bne nak 3470 lda #04 3480 jmp exit 3490 nope2 cmp #'c' 3500 bne nope3 3510 lda data+5 3520 beq code 3530 jmp ack 3540 nope3 cmp #$18 3550 bne code 3560 can lda #01 3570 .byt $2c 3580 timout lda #03 3590 .byt $2c 3600 end lda #00 3610 exit sta data+4 3620 beq exit2 3630 ldx #05 3640 jsr chkout 3650 lda #$18 3660 jsr chrout 3670 jsr chrout 3680 jsr chrout 3690 exit2 lda #02 3700 jsr close 3710 jmp restor 3720 timer lda #00 3730 sta data 3740 sta data+1 3750 rts 3760 eot lda #04 3770 jsr signal 3780 bne timout 3790 cmp #06 3800 bne timout 3810 jmp end 3820 recv jsr setup 3830 jsr init 3840 lda 667 3850 sta 668 3860 lda #'c' 3870 .byt $2c 3880 nak1 lda #$15 3890 .byt $2c 3900 ack1 lda #$06 3910 over4 sta data+6 3920 over3 lda data+6 3930 over1 jsr signal 3940 beq over2 3950 txa 3960 jmp exit 3970 over2 cmp #$02 3980 beq start 3990 cmp #$01 4000 beq lessblk 4010 cmp #$18 4020 beq can 4030 cmp #$04 4040 bne over3 4050 chr4 lda #06 4060 jsr chrout 4070 jsr chrout 4080 jsr chrout 4090 jmp end 4100 start ldx #00 4110 stx sizcount 4120 ldx #04 4130 jmp chr3 4140 lessblk ldx #128 4150 stx sizcount 4160 ldx #00 4170 chr3 stx sizcount+1 4180 sta header 4190 lda #<mem 4200 sta memory 4210 lda #>mem 4220 sta memory+1 4230 ldx #02 4240 jsr savstk 4250 ldy #01 4260 waits lda #00 4270 ldx #02 4280 jsr signal2 4290 beq wait3 4300 cpx #03 4310 beq nak1 4320 txa 4330 jmp exit 4340 wait3 cpy #03 4350 beq block 4360 bcs recsum 4370 sta header,y 4380 iny 4390 jmp waits 4400 block dec sizcount 4410 ldx sizcount 4420 cpx #$ff 4430 bne block0 4440 dec sizcount+1 4450 bmi block1 4460 block0 ldy #00 4470 sta (memory),y 4480 ldy #03 4490 inc memory 4500 bne waits 4510 inc memory+1 4520 jmp waits 4530 block1 iny 4540 recsum sta header-1,y 4550 iny 4560 cpy #06 4570 bne waits 4580 ldy #03 4590 restk lda calcrc,y 4600 sta memory,y 4610 dey 4620 bpl restk 4630 jsr bufclr 4640 lda header+1 4650 cmp blknum 4660 bne test2 4670 ldx data+2 4680 bmi sync 4690 jmp ack1 4700 test2 inc blknum 4710 bne noinc1 4720 inc blknum+1 4730 noinc1 cmp blknum 4740 beq sync 4750 lda #05 4760 jmp exit 4770 sync eor #$ff 4780 cmp header+2 4790 bne nak2 4800 ldx #01 4810 jsr savstk 4820 cpy header+3 4830 bne nak2 4840 cpx header+4 4850 beq good 4860 nak2 jsr restor 4870 lda #':' 4880 jsr chrout 4890 lda #$ff 4900 sta data+2 4910 jmp nak1 4920 good jsr restor 4930 lda #'-' 4940 jsr chrout 4950 lda #00 4960 sta data+2 4970 ldx #02 4980 jsr chkout 4990 disk ldx #00 5000 jsr savstk 5010 jsr setup 5020 jmp ack1 5030 bufclr jsr setup 5040 lda $02a1 5050 and #02 5060 cmp #02 5070 beq bufclr 5080 ldx 667 5090 stx 668 5100 rts 5110 savstk ldy #03 5120 savstk1 lda memory,y 5130 sta calcrc,y 5140 dey 5150 bpl savstk1 5160 cpx #02 5170 beq savstk2 5180 cpx #00 5190 beq sav2 5200 jsr cksum 5210 ldx crc 5220 ldy crc+1 5230 savstk2 rts 5240 sav2 jmp send 5250 ;crc.m65 - written for mac/65 5260 ; by ralph walden 5270 ;this takes a variable size block 5280 ;and calculates the crc and 5290 ;returns with the value in 5300 ;crc. 5310 ; 5320 cksum lda #00 ;zero crc 5330 sta crc 5340 sta crc+1 5350 tay 5360 mainlp dec crclen 5370 lda crclen 5380 cmp #$ff 5390 bne loop3 5400 dec crclen+1 5410 bmi end2 5420 loop3 lda crc+1 5430 eor (calcrc),y 5440 sta crc+1 5450 iny 5460 bne loop4 5470 inc calcrc+1 5480 loop4 ldx #08 5490 loop2 lda crc+1 5500 bpl shft 5510 lda crc 5520 asl a 5530 eor #<$1021 5540 sta crc 5550 lda crc+1 5560 rol a 5570 eor #>$1021 5580 sta crc+1 5590 check2 dex 5600 bne loop2 5610 beq mainlp 5620 shft asl crc 5630 rol crc+1 5640 jmp check2 5650 end2 rts 5660 send ldy #00 5670 send1 dec crclen 5680 lda crclen 5690 cmp #$ff 5700 bne send2 5710 dec crclen+1 5720 bmi send3 5730 send2 lda (calcrc),y 5740 jsr chrout 5750 inc calcrc 5760 bne send1 5770 inc calcrc+1 5780 jmp send1 5790 send3 rts 5800 .opt list 5810 .end --- cut here --- -- Brendan Kehoe brendan@gryphon.com | "Oh No! I forgot to say goodbye to my mind!" Just for the summer | - Abby Normal