; ; CPYMEM.Z80 - Fast Memory Copy for Z80 or 8080. ; By Carson Wilson 27 Jul 90 ; ; 8080-compatible Z80 source code generated with ZCASM 1.5. ; ; This is like the BDS MOVMEM function, except that it ALWAYS ; copies "head first", REGARDLESS of overlap (i.e., when ; length to copy > distance). This was required by the ; "sliding dictionary" functions of the "explode" file ; decompression algorithm used by my UNZIP. ; ; Derived from Leor Zolman's DEFF2A.CSM. ; TPALOC EQU 0100H CCCORG ASET 0100H RAMOFF: EQU 024BH FALSE: EQU 0 TRUE: EQU NOT FALSE CPM: EQU TRUE MPM2: EQU FALSE if not cpm CCCORG: SET WHATEVER RAM: EQU WHATEVER2 BASE: EQU WHATEVER3 endif if cpm base: equ 0000h fcb: equ base+5ch tbuff: equ base+80h bdos: equ base+5 tpa: equ base+100h nfcbs: equ 9 errorv: equ 255 ram: equ cccorg + ramoff endif cr: equ 0dh lf: equ 0ah bell: equ 7 newlin: equ lf tab: equ 9 bs: equ 08h cntrlc: equ 3 fexitv: equ cccorg+12h error: equ cccorg+1dh exit: equ error+3 if cpm close: equ error+6 fgfd: equ error+12 fgfcb: equ error+15 setusr: equ error+21 rstusr: equ error+24 khack: equ error+33 clrex: equ error+36 endif eqwel: equ cccorg+0e5h smod: equ cccorg+10fh usmod: equ cccorg+129h smul: equ cccorg+13fh usmul: equ cccorg+16bh usdiv: equ cccorg+189h sdiv: equ cccorg+1cbh cmphd: equ cccorg+1ddh cmh: equ cccorg+1fah cmd: equ cccorg+202h ma1toh: equ cccorg+20ah ma2toh: equ cccorg+213h ma3toh: equ ma2toh+6 ma4toh: equ ma2toh+12 ma5toh: equ ma2toh+18 ma6toh: equ ma2toh+24 ma7toh: equ ma2toh+30 arghak: equ ma2toh+36 savorg: equ $ org ram errnum: ds 1 rseed: ds 8 args: ds 14 iohack: ds 6 allocp: ds 2 alocmx: ds 2 tmp ds 1 tmp1 ds 1 tmp2 ds 2 tmp2a ds 2 pwdrow ds 1 pwdcol ds 1 curusr ds 1 usrnum ds 1 chmode ds 1 nleft ds 1 ungetl ds 1 iobrf ds 1 spsav ds 2 zenvad ds 2 topofm ds 2 wheel ds 1 z3ndir ds 2 maxdrv ds 1 maxusr ds 1 duok ds 1 cusr ds 1 cdrv ds 1 envtyp ds 1 drvec ds 2 secvio ds 1 pwdchk ds 1 custpw ds 1 custfn ds 2 errbyt: ds 2 ds 8 org savorg extrns: equ cccorg+15h cccsiz: equ cccorg+17h codend: equ cccorg+19h freram: equ cccorg+1bh arg1: equ args arg2: equ args+2 arg3: equ args+4 arg4: equ args+6 arg5: equ args+8 arg6: equ args+10 arg7: equ args+12 if cpm conin: equ 1 conout: equ 2 lstout: equ 5 dconio: equ 6 pstrng: equ 9 getlin: equ 10 cstat: equ 11 select: equ 14 openc: equ 15 closec: equ 16 delc: equ 19 reads: equ 20 creatc: equ 22 renc: equ 23 sdma: equ 26 gsuser: equ 32 readr: equ 33 writr: equ 34 cfsizc: equ 35 srrecc: equ 36 endif ORG TPALOC ; Directory: DEFB 'CPYME','M'+80H DEFW BEG$00 DEFB 80H DEFW END$CRL ORG TPALOC+200H DEFB 0,0,0,0,0 BEG$00 EQU $-TPALOC DEFB 0 DEFW END$00-$-2 STR$00 EQU $ F00$00 EQU STR$00 STC$00 EQU $ CALL ARGHAK LD HL,(ARG3) ; Get block length LD A,H OR L RET Z ; Do nothing if zero length PUSH BC LD B,H LD C,L ; Set BC to length LD HL,(ARG2) ; Get dest addr EX DE,HL ; Put in DE LD HL,(ARG1) ; Get source addr in HL LD A,2 ; Test for Z-80 INC A JP PE,M8080H ; Z80? DEFB 0EDH,0B0H ; Yes. do block move. POP BC RET ; And done. M8080H: LD A,(HL) LD (DE),A INC HL INC DE DEC BC LD A,B OR C JP NZ,M8080H POP BC RET END$00 EQU $ DEFW 0 END$CRL EQU $-TPALOC END