User`s guide

; source and destination fcbs ready
;
0117 1l5c00 lxi d,sfcb ; source file
0lla cd690l call 0pen ; error if 255
0lid 118701 lxi d,nofile; ready message
0120 3c inr a ; 255 becomes 0
0121 cc6l0l cz finis ; done if no file
;
; source file open, prep destination
0l24 llda0l lxi d ,dfcb ; destination
0127 cd7301 call delete ; remove if present
0lZa llda0l lxi d,dfcb ; destination
0lZd cdB20l call make ; create the file
0130 119601 lxi d,nodir; ready message
0133 3c inr a ; 255 becomes 0
0134 cc6l0l cz finis ; done if no dir space
;
; source file open, dest file open
; copy until end of file on source
0137 115c00copy: lxi d,sfcb ; source
013a cd780l call read ; read next record
013d b7 ora a ; end of file?
013e c25101 Jnz eofile ; skip write if s0
; not end of file, write the record
0141 llda0l lxi d,dfcb ; destination
0144 cd7d0l call write ; write record
0147 11a901 lxi d,space; ready message
014a b7 ora a ; 00 if write ok
014b c46101 cnz finis ; end if so
014e c33701 Jmp copy ; loop until eof
;
eofile: ; end of file, close destination
0151 llda0l lxi d,dfcb ; destination
0154 cd6e0l call close ; 255 if error
0157 2lbb0l lxi h,wrprot; ready message
015a 3c inr a ; 255 becomes 00
015b cc6l0l cz finis ; should not happen
;
; copy operation complete, end
0lSe llcc0l lxi d,normal ; ready message
;
finis: ; write message given by de, reboot
0161 0e09 mvi c,printf
0163 cd0500 call bdos ; write message
0166 c30000 Jmp boot ; reboot system4-3
4.1 A Sample Copy Program CP/M 3 Programmer's Guide