diff --git a/Build.cmd b/Build.cmd index daca9a00..b0dad82c 100644 --- a/Build.cmd +++ b/Build.cmd @@ -1,6 +1,4 @@ @echo off setlocal -if not exist Output md Output - -pushd Source && call Build %* && popd +setlocal & pushd Source && call Build %* & endlocal diff --git a/BuildCommon.cmd b/BuildCommon.cmd index 9d537ff5..4bde4f3f 100644 --- a/BuildCommon.cmd +++ b/BuildCommon.cmd @@ -1,5 +1,5 @@ @echo off setlocal -pushd Source && call BuildCommon && popd -pushd Hardware && call Build && popd \ No newline at end of file +setlocal & pushd Source && call BuildCommon & endlocal +setlocal & pushd Hardware && call Build & endlocal \ No newline at end of file diff --git a/BuildDoc.cmd b/BuildDoc.cmd index b2bfe67e..f0827bc0 100644 --- a/BuildDoc.cmd +++ b/BuildDoc.cmd @@ -1,4 +1,4 @@ @echo off setlocal -pushd Doc && call Build && popd +setlocal & pushd Source\Doc && call Build & endlocal diff --git a/BuildImages.cmd b/BuildImages.cmd index 9979c7c7..34ca1786 100644 --- a/BuildImages.cmd +++ b/BuildImages.cmd @@ -1,6 +1,4 @@ @echo off setlocal -if not exist Output md Output - -pushd Images && Build && popd \ No newline at end of file +setlocal & pushd Images && Build & endlocal \ No newline at end of file diff --git a/Clean.cmd b/Clean.cmd index c3d52c2a..3ad5028a 100644 --- a/Clean.cmd +++ b/Clean.cmd @@ -2,12 +2,10 @@ setlocal -pushd Source && call Clean && popd -pushd Doc && call Clean && popd -pushd Images && call Clean && popd -pushd Hardware && call Clean && popd +setlocal & pushd Source && call Clean & endlocal +setlocal & pushd Images && call Clean & endlocal +setlocal & pushd Hardware && call Clean & endlocal +setlocal & pushd Output && call Clean & endlocal -if exist *.img del *.img /Q -if exist *.log del *.log /Q - -if exist Output rd /s /q Output \ No newline at end of file +if exist *.img del *.img +if exist *.log del *.log \ No newline at end of file diff --git a/Doc/Build.cmd b/Doc/Build.cmd deleted file mode 100644 index bf7ef091..00000000 --- a/Doc/Build.cmd +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -setlocal - -pushd Source && call Build && popd diff --git a/Doc/CPM 22 Manual.pdf b/Doc/CPM 22 Manual.pdf new file mode 100644 index 00000000..e3ddcfcd Binary files /dev/null and b/Doc/CPM 22 Manual.pdf differ diff --git a/Doc/Clean.cmd b/Doc/Clean.cmd deleted file mode 100644 index bd4712a4..00000000 --- a/Doc/Clean.cmd +++ /dev/null @@ -1,7 +0,0 @@ -@echo off -setlocal - -pushd Source && call Clean && popd - -if exist "RomWBW User Guide.pdf" del "RomWBW User Guide.pdf" -if exist "RomWBW System Guide.pdf" del "RomWBW System Guide.pdf" diff --git a/Doc/22Disk.txt b/Doc/Contrib/22Disk.txt similarity index 100% rename from Doc/22Disk.txt rename to Doc/Contrib/22Disk.txt diff --git a/Doc/FdTst.txt b/Doc/Contrib/FdTst.txt similarity index 100% rename from Doc/FdTst.txt rename to Doc/Contrib/FdTst.txt diff --git a/Doc/Flash4.txt b/Doc/Contrib/Flash4.txt similarity index 100% rename from Doc/Flash4.txt rename to Doc/Contrib/Flash4.txt diff --git a/Doc/LinuxBuild.txt b/Doc/Contrib/LinuxBuild.txt similarity index 100% rename from Doc/LinuxBuild.txt rename to Doc/Contrib/LinuxBuild.txt diff --git a/Doc/Propeller Keyboard and VGA.pdf b/Doc/Contrib/Propeller Keyboard and VGA.pdf similarity index 100% rename from Doc/Propeller Keyboard and VGA.pdf rename to Doc/Contrib/Propeller Keyboard and VGA.pdf diff --git a/Doc/SD-howto.txt b/Doc/Contrib/SD-howto.txt similarity index 100% rename from Doc/SD-howto.txt rename to Doc/Contrib/SD-howto.txt diff --git a/Doc/Z180 Clocking.txt b/Doc/Contrib/Z180 Clocking.txt similarity index 100% rename from Doc/Z180 Clocking.txt rename to Doc/Contrib/Z180 Clocking.txt diff --git a/Doc/ZSystem.txt b/Doc/Contrib/ZSystem.txt similarity index 100% rename from Doc/ZSystem.txt rename to Doc/Contrib/ZSystem.txt diff --git a/Doc/Reference/cpm22-m.pdf b/Doc/Reference/cpm22-m.pdf deleted file mode 100644 index d030d4ac..00000000 Binary files a/Doc/Reference/cpm22-m.pdf and /dev/null differ diff --git a/Doc/Reference/zcpr.pdf b/Doc/Reference/zcpr.pdf deleted file mode 100644 index 9686ab07..00000000 Binary files a/Doc/Reference/zcpr.pdf and /dev/null differ diff --git a/Doc/RomWBW System Guide.pdf b/Doc/RomWBW System Guide.pdf new file mode 100644 index 00000000..7568b80b Binary files /dev/null and b/Doc/RomWBW System Guide.pdf differ diff --git a/Doc/RomWBW User Guide.pdf b/Doc/RomWBW User Guide.pdf new file mode 100644 index 00000000..5cd0f9e2 Binary files /dev/null and b/Doc/RomWBW User Guide.pdf differ diff --git a/Doc/Source/Build.cmd b/Doc/Source/Build.cmd deleted file mode 100644 index efab1a64..00000000 --- a/Doc/Source/Build.cmd +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -setlocal - -pushd "RomWBW User Guide" && call Build && popd -pushd "RomWBW System Guide" && call Build && popd - -if exist "RomWBW User Guide\Main.pdf" copy "RomWBW User Guide\Main.pdf" "..\RomWBW User Guide.pdf" -if exist "RomWBW System Guide\Main.pdf" copy "RomWBW System Guide\Main.pdf" "..\RomWBW System Guide.pdf" - diff --git a/Doc/Source/Clean.cmd b/Doc/Source/Clean.cmd deleted file mode 100644 index 9547adf7..00000000 --- a/Doc/Source/Clean.cmd +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -setlocal - -pushd RomWBW User Guide && call Clean.cmd && popd -pushd RomWBW System Guide && call Clean.cmd && popd \ No newline at end of file diff --git a/Doc/Source/RomWBW System Guide.docx b/Doc/Source/RomWBW System Guide.docx deleted file mode 100644 index e15c772f..00000000 Binary files a/Doc/Source/RomWBW System Guide.docx and /dev/null differ diff --git a/Doc/Source/RomWBW System Guide/Build.cmd b/Doc/Source/RomWBW System Guide/Build.cmd deleted file mode 100644 index 7a5a42e1..00000000 --- a/Doc/Source/RomWBW System Guide/Build.cmd +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -setlocal - -call texify -p --clean Main.ltx \ No newline at end of file diff --git a/Doc/Source/RomWBW User Guide Old.docx b/Doc/Source/RomWBW User Guide Old.docx deleted file mode 100644 index 4b71a3a4..00000000 Binary files a/Doc/Source/RomWBW User Guide Old.docx and /dev/null differ diff --git a/Doc/Source/RomWBW User Guide.docx b/Doc/Source/RomWBW User Guide.docx deleted file mode 100644 index c3037256..00000000 Binary files a/Doc/Source/RomWBW User Guide.docx and /dev/null differ diff --git a/Doc/Source/RomWBW User Guide/Build.cmd b/Doc/Source/RomWBW User Guide/Build.cmd deleted file mode 100644 index 7a5a42e1..00000000 --- a/Doc/Source/RomWBW User Guide/Build.cmd +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -setlocal - -call texify -p --clean Main.ltx \ No newline at end of file diff --git a/Doc/Source/RomWBW.dotx b/Doc/Source/RomWBW.dotx deleted file mode 100644 index 9ac3c192..00000000 Binary files a/Doc/Source/RomWBW.dotx and /dev/null differ diff --git a/Doc/ZCPR Manual.pdf b/Doc/ZCPR Manual.pdf new file mode 100644 index 00000000..d6c5f045 Binary files /dev/null and b/Doc/ZCPR Manual.pdf differ diff --git a/Doc/Reference/zsdos.pdf b/Doc/ZSDOS Manual.pdf similarity index 100% rename from Doc/Reference/zsdos.pdf rename to Doc/ZSDOS Manual.pdf diff --git a/Hardware/Build.cmd b/Hardware/Build.cmd index b810657c..1a3c1347 100644 --- a/Hardware/Build.cmd +++ b/Hardware/Build.cmd @@ -1,4 +1,4 @@ @echo off setlocal -pushd Prop && call Build && popd \ No newline at end of file +setlocal & pushd Prop && call Build & endlocal \ No newline at end of file diff --git a/Hardware/Clean.cmd b/Hardware/Clean.cmd index d112a6bd..d90c9692 100644 --- a/Hardware/Clean.cmd +++ b/Hardware/Clean.cmd @@ -2,4 +2,4 @@ setlocal -pushd Prop && call Clean && popd \ No newline at end of file +setlocal & pushd Prop && call Clean & endlocal \ No newline at end of file diff --git a/Hardware/Prop/Clean.cmd b/Hardware/Prop/Clean.cmd index ab81f1a1..da15cd97 100644 --- a/Hardware/Prop/Clean.cmd +++ b/Hardware/Prop/Clean.cmd @@ -2,5 +2,5 @@ setlocal -if exist *.eeprom del *.eeprom /Q -if exist *.list del *.list /Q \ No newline at end of file +if exist *.eeprom del *.eeprom +if exist *.list del *.list \ No newline at end of file diff --git a/Images/Clean.cmd b/Images/Clean.cmd index 21d05a7a..9ccb0061 100644 --- a/Images/Clean.cmd +++ b/Images/Clean.cmd @@ -1,2 +1,2 @@ @echo off -if exist *.tmp del *.tmp /Q +if exist *.tmp del *.tmp diff --git a/Output/Clean.cmd b/Output/Clean.cmd new file mode 100644 index 00000000..74454a7c --- /dev/null +++ b/Output/Clean.cmd @@ -0,0 +1,6 @@ +@echo off +if exist *.bin del *.bin +if exist *.com del *.com +if exist *.img del *.img +if exist *.rom del *.rom +if exist *.pdf del *.pdf \ No newline at end of file diff --git a/RomList.txt b/Output/RomList.txt similarity index 100% rename from RomList.txt rename to Output/RomList.txt diff --git a/Source/BPBIOS/Clean.cmd b/Source/BPBIOS/Clean.cmd index 20075302..2880c004 100644 --- a/Source/BPBIOS/Clean.cmd +++ b/Source/BPBIOS/Clean.cmd @@ -5,4 +5,4 @@ if exist *.img del *.img if exist bp*.rel del bp*.rel if exist *.bak del *.bak -pushd ZCPR33 && call Clean.cmd && popd +setlocal & pushd ZCPR33 && call Clean.cmd & endlocal diff --git a/Source/Build.cmd b/Source/Build.cmd index d2e89e9e..7bb95a62 100644 --- a/Source/Build.cmd +++ b/Source/Build.cmd @@ -1,4 +1,4 @@ @echo off setlocal -pushd HBIOS && Powershell .\Build.ps1 %* && popd +setlocal & pushd HBIOS && Powershell .\Build.ps1 %* & endlocal diff --git a/Source/BuildCommon.cmd b/Source/BuildCommon.cmd index ff5f5f1a..0d9117ba 100644 --- a/Source/BuildCommon.cmd +++ b/Source/BuildCommon.cmd @@ -1,9 +1,9 @@ @echo off setlocal -pushd Apps && call Build && popd -pushd CPM22 && call Build && popd -pushd ZCPR && call Build && popd -pushd ZCPR-DJ && call Build && popd -pushd ZSDOS && call Build && popd -pushd CBIOS && call Build && popd +setlocal & pushd Apps && call Build & endlocal +setlocal & pushd CPM22 && call Build & endlocal +setlocal & pushd ZCPR && call Build & endlocal +setlocal & pushd ZCPR-DJ && call Build & endlocal +setlocal & pushd ZSDOS && call Build & endlocal +setlocal & pushd CBIOS && call Build & endlocal diff --git a/Source/Clean.cmd b/Source/Clean.cmd index cb16f111..aa72ab7e 100644 --- a/Source/Clean.cmd +++ b/Source/Clean.cmd @@ -1,13 +1,15 @@ @echo off setlocal -pushd Apps && call Clean.cmd && popd -pushd CPM22 && call Clean.cmd && popd -pushd ZCPR && call Clean.cmd && popd -pushd ZCPR-DJ && call Clean.cmd && popd -pushd ZSDOS && call Clean.cmd && popd -pushd CBIOS && call Clean.cmd && popd +setlocal & pushd Apps && call Clean.cmd & endlocal +setlocal & pushd CPM22 && call Clean.cmd & endlocal +setlocal & pushd ZCPR && call Clean.cmd & endlocal +setlocal & pushd ZCPR-DJ && call Clean.cmd & endlocal +setlocal & pushd ZSDOS && call Clean.cmd & endlocal +setlocal & pushd CBIOS && call Clean.cmd & endlocal -pushd BPBIOS && call Clean.cmd && popd +setlocal & pushd BPBIOS && call Clean.cmd & endlocal -pushd HBIOS && call Clean.cmd && popd +setlocal & pushd HBIOS && call Clean.cmd & endlocal + +setlocal & pushd Doc && call Clean.cmd & endlocal \ No newline at end of file diff --git a/Doc/Source/Bank Switched Memory.vsd b/Source/Doc/Bank Switched Memory.vsd similarity index 100% rename from Doc/Source/Bank Switched Memory.vsd rename to Source/Doc/Bank Switched Memory.vsd diff --git a/Source/Doc/Build.cmd b/Source/Doc/Build.cmd new file mode 100644 index 00000000..ca873c9c --- /dev/null +++ b/Source/Doc/Build.cmd @@ -0,0 +1,7 @@ +@echo off +setlocal + +setlocal & pushd "CPM 22 Manual" && call Build.cmd & endlocal +setlocal & pushd "ZCPR Manual" && call Build.cmd & endlocal +setlocal & pushd "RomWBW User Guide" && call Build.cmd & endlocal +setlocal & pushd "RomWBW System Guide" && call Build.cmd & endlocal \ No newline at end of file diff --git a/Doc/Source/Build.docx b/Source/Doc/Build.docx similarity index 100% rename from Doc/Source/Build.docx rename to Source/Doc/Build.docx diff --git a/Source/Doc/CPM 22 Manual - Testing/Build.cmd b/Source/Doc/CPM 22 Manual - Testing/Build.cmd new file mode 100644 index 00000000..94c23451 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/Build.cmd @@ -0,0 +1,23 @@ +@echo off +setlocal + +set TOOLS=..\..\..\Tools + +set PATH=%TOOLS%\zx;%PATH% + +set ZXBINDIR=%TOOLS%/cpm/bin/ +set ZXLIBDIR=%TOOLS%/cpm/lib/ +set ZXINCDIR=%TOOLS%/cpm/include/ + +set TEXOPT=-$D + +zx TEX21 PART1 %TEXOPT% +zx TEX21 PART2 %TEXOPT% +zx TEX21 PART3 %TEXOPT% + +echo Remove extraneous control codes and escape sequences +rem pause + +PowerShell .\Strip.ps1 + +call texify -p --clean "Main.ltx" \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/Clean.cmd b/Source/Doc/CPM 22 Manual - Testing/Clean.cmd new file mode 100644 index 00000000..d4334fa1 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/Clean.cmd @@ -0,0 +1,6 @@ +@echo off +if exist *.prn del *.prn +if exist *.ix del *.ix +if exist *.log del *.log +if exist part?.txt del part?.txt +if exist *.synctex.gz del *.synctex.gz diff --git a/Source/Doc/CPM 22 Manual - Testing/Main.log b/Source/Doc/CPM 22 Manual - Testing/Main.log new file mode 100644 index 00000000..ba0de145 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/Main.log @@ -0,0 +1,243 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.17 (MiKTeX 2.9 64-bit) (preloaded format=pdflatex 2016.6.18) 28 JUL 2016 12:40 +entering extended mode +**"C:/Users/WWarthen/Projects/N8VEM/Build/RomWBW/Doc/Source/CPM 22 Manual - Tes +ting/Main.ltx" + +("C:/Users/WWarthen/Projects/N8VEM/Build/RomWBW/Doc/Source/CPM 22 Manual - Test +ing/Main.ltx" +LaTeX2e <2016/03/31> +Babel <3.9r> and hyphenation patterns for 75 language(s) loaded. +("C:\Program Files\MiKTeX 2.9\tex\latex\base\book.cls" +Document Class: book 2014/09/29 v1.4h Standard LaTeX document class +("C:\Program Files\MiKTeX 2.9\tex\latex\base\bk10.clo" +File: bk10.clo 2014/09/29 v1.4h Standard LaTeX file (size option) +) +\c@part=\count79 +\c@chapter=\count80 +\c@section=\count81 +\c@subsection=\count82 +\c@subsubsection=\count83 +\c@paragraph=\count84 +\c@subparagraph=\count85 +\c@figure=\count86 +\c@table=\count87 +\abovecaptionskip=\skip41 +\belowcaptionskip=\skip42 +\bibindent=\dimen102 +) +("C:\Program Files\MiKTeX 2.9\tex\latex\base\fontenc.sty" +Package: fontenc 2005/09/27 v1.99g Standard LaTeX package + +("C:\Program Files\MiKTeX 2.9\tex\latex\base\t1enc.def" +File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file +LaTeX Font Info: Redeclaring font encoding T1 on input line 48. +)) +("C:\Program Files\MiKTeX 2.9\tex\latex\bera\beramono.sty" +Package: beramono 2004/01/31 (WaS) + +("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty" +Package: keyval 2014/10/28 v1.15 key=value parser (DPC) +\KV@toks@=\toks14 +)) +("C:\Program Files\MiKTeX 2.9\tex\latex\fancyvrb\fancyvrb.sty" +Package: fancyvrb 2008/02/07 + +Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix +<2008/02/07> (tvz) +\FV@CodeLineNo=\count88 +\FV@InFile=\read1 +\FV@TabBox=\box26 +\c@FancyVerbLine=\count89 +\FV@StepNumber=\count90 +\FV@OutFile=\write3 +) +("C:\Program Files\MiKTeX 2.9\tex\latex\geometry\geometry.sty" +Package: geometry 2010/09/12 v5.6 Page Geometry + +("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty" +Package: ifpdf 2016/05/14 v3.1 Provides the ifpdf switch +) +("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifvtex.sty" +Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO) +Package ifvtex Info: VTeX not detected. +) +("C:\Program Files\MiKTeX 2.9\tex\generic\ifxetex\ifxetex.sty" +Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional +) +\Gm@cnth=\count91 +\Gm@cntv=\count92 +\c@Gm@tempcnt=\count93 +\Gm@bindingoffset=\dimen103 +\Gm@wd@mp=\dimen104 +\Gm@odd@mp=\dimen105 +\Gm@even@mp=\dimen106 +\Gm@layoutwidth=\dimen107 +\Gm@layoutheight=\dimen108 +\Gm@layouthoffset=\dimen109 +\Gm@layoutvoffset=\dimen110 +\Gm@dimlist=\toks15 + +("C:\Program Files\MiKTeX 2.9\tex\latex\geometry\geometry.cfg")) +("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\pdflscape.sty" +Package: pdflscape 2016/05/14 v0.11 Display of landscape pages in PDF (HO) + +("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\lscape.sty" +Package: lscape 2000/10/22 v3.01 Landscape Pages (DPC) + +("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphics.sty" +Package: graphics 2016/05/09 v1.0r Standard LaTeX Graphics (DPC,SPQR) + +("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\trig.sty" +Package: trig 2016/01/03 v1.10 sin cos tan (DPC) +) +("C:\Program Files\MiKTeX 2.9\tex\latex\00miktex\graphics.cfg" +File: graphics.cfg 2016/01/02 v1.10 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 96. + +("C:\Program Files\MiKTeX 2.9\tex\latex\pdftex-def\pdftex.def" +File: pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX + +("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty" +Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO) +) +("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty" +Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO) +) +\Gread@gobject=\count94 +))) +Package pdflscape Info: Auto-detected driver: pdftex on input line 81. +) +No file Main.aux. +\openout1 = `Main.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 22. +LaTeX Font Info: ... okay on input line 22. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 22. +LaTeX Font Info: ... okay on input line 22. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 22. +LaTeX Font Info: ... okay on input line 22. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 22. +LaTeX Font Info: ... okay on input line 22. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 22. +LaTeX Font Info: ... okay on input line 22. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 22. +LaTeX Font Info: ... okay on input line 22. +*geometry* driver: auto-detecting +*geometry* detected driver: pdftex +*geometry* verbose mode - [ preamble ] result: +* driver: pdftex +* paper: letterpaper +* layout: +* layoutoffset:(h,v)=(0.0pt,0.0pt) +* modes: +* h-part:(L,W,R)=(36.135pt, 542.02501pt, 36.135pt) +* v-part:(T,H,B)=(0.0pt, 794.96999pt, 0.0pt) +* \paperwidth=614.295pt +* \paperheight=794.96999pt +* \textwidth=542.02501pt +* \textheight=794.96999pt +* \oddsidemargin=-36.135pt +* \evensidemargin=-36.135pt +* \topmargin=-102.33748pt +* \headheight=12.0pt +* \headsep=18.06749pt +* \topskip=10.0pt +* \footskip=25.29494pt +* \marginparwidth=69.0pt +* \marginparsep=7.0pt +* \columnsep=10.0pt +* \skip\footins=9.0pt plus 4.0pt minus 2.0pt +* \hoffset=0.0pt +* \voffset=0.0pt +* \mag=1000 +* \@twocolumnfalse +* \@twosidefalse +* \@mparswitchfalse +* \@reversemarginfalse +* (1in=72.27pt=25.4mm, 1cm=28.453pt) + +("C:\Program Files\MiKTeX 2.9\tex\context\base\supp-pdf.mkii" +[Loading MPS to PDF converter (version 2006.09.02).] +\scratchcounter=\count95 +\scratchdimen=\dimen111 +\scratchbox=\box27 +\nofMPsegments=\count96 +\nofMParguments=\count97 +\everyMPshowfont=\toks16 +\MPscratchCnt=\count98 +\MPscratchDim=\dimen112 +\MPnumerator=\count99 +\makeMPintoPDFobject=\count100 +\everyMPtoPDFconversion=\toks17 +) ("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\pdftexcmds.sty" +Package: pdftexcmds 2016/05/21 v0.22 Utility functions of pdfTeX for LuaTeX (HO +) + +("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifluatex.sty" +Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO) +Package ifluatex Info: LuaTeX not detected. +) +Package pdftexcmds Info: LuaTeX not detected. +Package pdftexcmds Info: \pdf@primitive is available. +Package pdftexcmds Info: \pdf@ifprimitive is available. +Package pdftexcmds Info: \pdfdraftmode found. +) +("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\epstopdf-base.sty" +Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf + +("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\grfext.sty" +Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO) + +("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\kvdefinekeys.sty" +Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO) +)) +("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\kvoptions.sty" +Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO) + +("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\kvsetkeys.sty" +Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO) + +("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\etexcmds.sty" +Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO) +Package etexcmds Info: Could not find \expanded. +(etexcmds) That can mean that you are not using pdfTeX 1.50 or +(etexcmds) that some package has redefined \expanded. +(etexcmds) In the latter case, load this package earlier. +))) +Package grfext Info: Graphics extension search list: +(grfext) [.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPE +G,.JBIG2,.JB2,.eps] +(grfext) \AppendGraphicsExtensions on input line 456. +) +LaTeX Font Info: Try loading font information for T1+fvm on input line 25. + +("C:\Program Files\MiKTeX 2.9\tex\latex\bera\t1fvm.fd" +File: t1fvm.fd 2004/09/07 scalable font definitions for T1/fvm. +) +LaTeX Font Info: Font shape `T1/fvm/m/n' will be +(Font) scaled to size 8.99994pt on input line 25. + +! Text line contains an invalid character. +  + C +l.25 \VerbatimInput{part1.txt} + +? +! Emergency stop. +  + C +l.25 \VerbatimInput{part1.txt} + +End of file on the terminal! + + +Here is how much of TeX's memory you used: + 2546 strings out of 493335 + 35826 string characters out of 3139251 + 101645 words of memory out of 3000000 + 6068 multiletter control sequences out of 15000+200000 + 4724 words of font info for 16 fonts, out of 3000000 for 9000 + 1141 hyphenation exceptions out of 8191 + 37i,3n,23p,339b,166s stack positions out of 5000i,500n,10000p,200000b,50000s +! ==> Fatal error occurred, no output PDF file produced! diff --git a/Source/Doc/CPM 22 Manual - Testing/Main.ltx b/Source/Doc/CPM 22 Manual - Testing/Main.ltx new file mode 100644 index 00000000..3e2a81ef --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/Main.ltx @@ -0,0 +1,42 @@ +\documentclass[letterpaper,10pt,oneside]{book} +\usepackage[T1]{fontenc} +%\usepackage[defaultmono]{droidmono} +\usepackage[scaled]{beramono} +\usepackage{fancyvrb} +\usepackage{geometry} +\usepackage{pdflscape} +%\usepackage{showframe} % Diagnostic + +% Suppress headers and footers completely +\pagestyle{empty} + +% 66 lines per page, portrait +%\geometry{top=0.0in, bottom=0.0in, left=1.0in, right=0.5in} +\geometry{top=0.0in, bottom=0.0in, left=0.5in, right=0.5in} + +\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}% +{ + commandchars=\\\{\} +} + +\begin{document} + +% Part 1 (main document sections) +\VerbatimInput{part1.txt} + +% 51 lines per page, landscape +%\newgeometry{top=1.0in, bottom=0.5in, left=0.0in, right=0.0in} +\newgeometry{top=0.5in, bottom=0.5in, left=0.0in, right=0.0in} +\begin{landscape} + +% Part 2 (appendices A-G, source listings) +\VerbatimInput{part2.txt} + +% back to standard geometry +\end{landscape} +\restoregeometry + +% Part 3 (appendices H-I, index) +\VerbatimInput{part3.txt} + +\end{document} \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/Main.pdf b/Source/Doc/CPM 22 Manual - Testing/Main.pdf new file mode 100644 index 00000000..59214bd4 Binary files /dev/null and b/Source/Doc/CPM 22 Manual - Testing/Main.pdf differ diff --git a/Source/Doc/CPM 22 Manual - Testing/Strip.ps1 b/Source/Doc/CPM 22 Manual - Testing/Strip.ps1 new file mode 100644 index 00000000..9e92c2bc --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/Strip.ps1 @@ -0,0 +1,19 @@ +function StripFile($Filename) +{ + $Content = Get-Content "${Filename}.prn" + $Content = $Content -replace "\0", "" + $Content = $Content -replace "\e.", "" + $Content = $Content -replace "\x1A", "" + $Content = $Content -replace "\0", "" + + #$Content = $Content -replace "\\", "\\" + + + Set-Content "${Filename}.txt" $Content[0..($Content.count - 3)] +} + +StripFile("part1") +StripFile("part2") +StripFile("part3") + +return diff --git a/Source/Doc/CPM 22 Manual - Testing/appa.tex b/Source/Doc/CPM 22 Manual - Testing/appa.tex new file mode 100644 index 00000000..e6542646 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/appa.tex @@ -0,0 +1,716 @@ +.pl 51 +.nf +.bp 1 +.ft A-% + Appendix A + + The Microcomputer Development System Basic Input/Output System (BIOS) + + + + 1 ; mds-800 i/o drivers for cp/m 2.2 + 2 ; (four drive single density version) + 3 ; + 4 ; version 2.2 february, 1980 + 5 ; + 6 0016 = vers equ 22 ;version 2.2 + 7 ; + 8 ; copyright (c) 1980 + 9 ; digital research + 10 ; box 579, pacific grove + 11 ; california, 93950 + 12 ; + 13 ; + 14 ffff = true equ 0fffh ;value of "true" + 15 0000 = false equ not true ;"false" + 16 0000 = test equ false ;true if test bios + 17 ; + 18 if test + 19 bias equ 03400h ;base of ccp in test system + 20 endif + 21 if not test + 22 0000 = bias equ 0000h ;generate relocatable cp/m system + 23 endif + 24 ; + 25 1600 = patch equ 1600h + 26 ; + 27 1600 org patch + 28 0000 = cpmb equ $-patch ;base of cpm console processor + 29 0806 = bdos equ 806h+cpmb ;basic dos (resident portion) + 30 1600 = cpml equ $-cpmb ;length (in bytes) of cpm system + 31 002c = nsects equ cpml/128 ;number of sectors to load + 32 0002 = offset equ 2 ;number of disk tracks used by cp/m + 33 0004 = cdisk equ 0004h ;address of last logged disk on warm start + 34 0080 = buff equ 0080h ;default buffer address + 35 000a = retry equ 10 ;max retries on disk i/o before error + 36 ; + 37 ; perform following functions + 38 ; boot cold start + 39 ; wboot warm start (save i/o byte) + 40 ; (boot and wboot are the same for mds) + 41 ; const console status + 42 ; reg-a = 00 if no character ready + 43 ; reg-a = ff if character ready + 44 ; conin console character in (result in reg-a) + 45 ; conout console character out (char in reg-c) + 46 ; list list out (char in reg-c) + 47 ; punch punch out (char in reg-c) + 48 ; reader paper tape reader in (result to reg-a) + 49 ; home move to track 00 + 50 ; + 51 ; (the following calls set-up the io parameter block for the + 52 ; mds, which is used to perform subsequent reads and writes) + 53 ; seldsk select disk given by reg-c (0, 1, 2...) + 54 ; settrk set track address (0,...76) for subsequent read-write + 55 ; setsec set sector address (1,...,26) for subsequent read-write + 56 ; setdma set subsequent dma address (initially 80h) + 57 ; + 58 ; (read and write assume previous calls to set up the io parameters) + 59 ; read read track/sector to preset dma address + 60 ; write track/sector from preset dma address + 61 ; + 62 ; jump vector for individual routines + 63 1600 c3b316 jmp boot + 64 1603 c3c316 wboote: jmp wboot + 65 1606 c36117 jmp const + 66 1609 c36417 jmp conin + 67 160c c36a17 jmp conout + 68 160f c36d17 jmp list + 69 1612 c37217 jmp punch + 70 1615 c37517 jmp reader + 71 1618 c37817 jmp home + 72 161b c37d17 jmp seldsk + 73 161e c3a717 jmp settrk + 74 1621 c3ac17 jmp setsec + 75 1624 c3bb17 jmp setdma + 76 1627 c3c117 jmp read + 77 162a c3ca17 jmp write + 78 162d c37017 jmp listst ;list status + 79 1630 c3b117 jmp sectran + 80 ; + 81 maclib diskdef ;load the disk definition library + 82 disks 4 ;four disks + 83 1633+= dpbase equ $ ;base of disk parameter blocks + 84 1633+82160000 dpe0: dw xlt0, 0000h ;translate table + 85 1637+00000000 dw 0000h, 0000h ;scratch area + 86 163b+6e187316 dw dirbuf, dpb0 ;dir buff, parm block + 87 163f+0d19ee18 dw csv0, alv0 ;check, alloc vectors + 88 1643+82160000 dpe1: dw xlt1, 0000h ;translate table + 89 1647+00000000 dw 0000h, 0000h ;scratch area + 90 164b+6e187316 dw dirbuf, dpb1 ;dir buff, parm block + 91 164f+3c191d19 dw csv1, alv1 ;check, alloc vectors + 92 1653+82160000 dpe2: dw xlt2, 0000h ;translate table + 93 1657+00000000 dw 0000h, 0000h ;scratch area + 94 165b+6e187316 dw dirbuf, dpb2 ;dir buff, parm block + 95 165f+6b194c19 dw csv2, alv2 ;check, alloc vectors + 96 1663+82160000 dpe3: dw xlt3, 0000h ;translate table + 97 1667+00000000 dw 0000h, 0000h ;scratch area + 98 166b+6e187316 dw dirbuf, dpb3 ;check, alloc block + 99 166f+9a197b19 dw csv3, alv3 ;dir buff, parm vectors +100 diskdef 0, 1, 26, 6, 1024, 243, 64, 64, offset +101 1673+= dpb0 equ $ ;disk parm block +102 1673+1a00 dw 26 ;sec per track +103 1675+03 db 3 ;block shift +104 1676+07 db 7 ;block mask +105 1677+00 db 0 ;extnt mask +106 1678+f200 dw 242 ;disk size-1 +107 167a+3f00 dw 63 ;directory max +108 167c+c0 db 192 ;alloc0 +109 167d+00 db 0 ;alloc1 +110 167e+1000 dw 16 ;check size +111 1680+0200 dw 2 ;offset +112 1682+= xlt0 equ $ ;translate table +113 1682+01 db 1 +114 1683+07 db 7 +115 1684+0d db 13 +116 1685+13 db 19 +117 1686+19 db 25 +118 1687+05 db 5 +119 1688+0b db 11 +120 1689+11 db 17 +121 168a+17 db 23 +122 168b+03 db 3 +123 168c+09 db 9 +124 168d+0f db 15 +125 168e+15 db 21 +126 168f+02 db 2 +127 1690+08 db 8 +128 1691+0e db 14 +129 1692+14 db 20 +130 1693+1a db 26 +131 1694+06 db 6 +132 1695+0c db 12 +133 1696+12 db 18 +134 1697+18 db 24 +135 1698+04 db 4 +136 1699+0a db 10 +137 169a+10 db 16 +138 169b+16 db 22 +139 diskdef 1,0 +140 1673+ = dpb1 equ dpb0 ;equivalent parameters +141 001f+ = als1 equ als0 ;same allocation vector size +142 0010+ = css1 equ css0 ;same checksum vector size +143 1682+ = xlt1 equ xlt0 ;same translate table +144 diskdef 2, 0 +145 1673+ = dpb2 equ dpb0 ;equivalent parameters +146 001f+ = als2 equ als0 ;same allocation vector size +147 0010+ = css2 equ css0 ;same checksum vector size +148 1682+ = xlt2 equ xlt0 ;same translate table +149 diskdef 3, 0 +150 1673+ = dpb3 equ dpb0 ;equivalent parameters +151 001f+ = als3 equ als0 ;same allocation vector size +152 0010+ = css3 equ css0 ;same checksum vector size +153 1682+ = xlt3 equ xlt0 ;same translate table +154 ; endef occurs at end of assembly +155 ; +156 ; end of controller--independent code, the remaining subroutines +157 ; are tailored to the particular operating environment, and must +158 ; be altered for any system which differs from the intel mds. +159 ; +160 ; the following code assumes the mds monitor exists at 0f800h +161 ; and uses the i/o subroutines within the monitor +162 ; +163 ; we also assume the mds system has four disk drives +164 00fd = revrt equ 0fdh ;interrupt revert port +165 00fc = intc equ 0fch ;interrupt mask port +166 00f3 = icon equ 0f3h ;interrupt control port +167 007E = inte equ 0111$1110b ;enable rst 0 (warm boot), rst 7 (monitor) +168 ; +169 ; mds monitor equates +170 f800 = mon80 equ 0f800h ;mds monitor +171 ff0f = rmon80 equ 0ff0fh ;restart mon80 (boot error) +172 f803 = ci equ 0f803h ;console character to reg-a +173 f806 = ri equ 0f806h ;reader in to reg-a +174 f809 = co equ 0f809h ;console char from c to console out +175 f80c = po equ 0f80ch ;punch char from c to punch device +176 f80f = lo equ 0f80fh ;list from c to list device +177 f812 = csts equ 0f812h ;console status 00/ff to register a +178 ; +179 ; disk ports and commands +180 0078 = base equ 78h ;base of disk command io ports +181 0078 = dstat equ base ;disk status (input) +182 0079 = rtype equ base+1 ;result type (input) +183 007b = rbyte equ base+3 ;result byte (input) +184 ; +185 0079 = ilow equ base+1 ;iopb low address (output) +186 007a = ihigh equ base+2 ;iopb high address (output) +187 ; +188 0004 = readf equ 4h ;read function +189 0006 = writf equ 6h ;write function +190 0003 = recal equ 3h ;recalibrate drive +191 0004 = iordy equ 4h ;i/o finished mask +192 000d = cr equ 0dh ;carriage return +193 000a = lf equ 0ah ;line-feed +194 ; +195 signon: ;signon message: xxk cp/m vers y.y +196 169c 0d0a0a db cr, lf, lf +197 if test +198 db '32' ;32k example bios +199 endif +200 if not test +201 169f 3030 db '00' ;memory size filled by relocator +202 endif +203 16a1 6b2043502f db 'k cp/m vers ' +204 16ad 322e32 db ver/10+'0', ',' vers mod 10+'0' +205 16b0 0d0a00 db cr, lf, 0 +206 ; +207 boot: ;print signon message and go to ccp +208 ; (note: mds boot initialized iobyte at 0003h) +209 16b3 310001 lxi sp, buff+80h +210 16b6 219c16 lxi h, signon +211 16b9 cdd317 call prmsg ;print message +212 16bc af xra a ;clear accumulator +213 16bd 320400 sta cdisk ;set initially to disk a +214 16c0 c30f17 jmp gocpm ;go to cp/m +215 ; +216 ; +217 wboot:; loader on track 0, sector 1, which will be skipped for warm +218 ; read cp/m from disk--assuming there is a 128 byte cold start +219 ; start +220 ; +221 16c3 318000 lxi sp, buff ;using dma--thus 80 thru ff available for stack +222 ; +223 16c6 0e0a mvi c, retry ;max retries +224 16c8 c5 push b +225 wboot0: ;enter here on error retries +226 16c9 010000 lxi b, cpmb ;set dma address to start of disk system +227 16cc cdbb17 call setdma +228 16cf 0e00 mvi c, 0 ;boot from drive 0 +229 16d1 cd7d17 call seldsk +230 16d4 0e00 mvi c, 0 +231 16d6 cda717 call settrk ;start with track 0 +232 16d9 0e02 mvi c, 2 ;start reading sector 2 +233 16db cdac17 call setsec +234 ; +235 ; read sectors, count nsects to zero +236 16de c1 pop b ;10-error count +237 16df 062c mvi b, nsects +238 rdsec: ;read next sector +239 16e1 c5 push b ;save sector count +240 16e2 cdc117 call read +241 16e5 c24917 jnz booterr ;retry if errors occur +242 16e8 2a6c18 lhld iod ;increment dma address +243 16eb 118000 lxi d, 128 ;sector size +244 16ee 19 dad d ;incremented dma address in hl +245 16ef 44 mov b, h +246 16f0 4d mov c, l ;ready for call to set dma +247 16f1 cdbb17 call setdma +248 16f4 3a6b18 lda ios ;sector number just read +249 16f7 fe1a cpi 26 ;read last sector? +250 16f9 da0517 jc rd1 +251 ; must be sector 26, zero and go to next track +252 16fc 3a6a18 lda iot ;get track to register a +253 16ff 3c inr a +254 1700 4f mov c, a ;read for call +255 1701 cda717 call settrk +256 1704 af xra a ;clear sector number +257 1705 3c rd1: inr a ;to next sector +258 1706 4f mov c, a ;ready for call +259 1707 cdac17 call setsec +260 170a c1 pop b ;recall sector count +261 170b 05 dcr b ;done? +262 170c c2e116 jnz rdsec +263 ; +264 ; done with the load, reset default buffer address +265 gocpm: ;(enter here from cold start boot) +266 ; enable rst0 and rst7 +267 170f f3 di +268 1710 3e12 mvi a, 12h ;initialize command +269 1712 d3fd out revrt +270 1714 af xra a +271 1715 d3fc out intc ;cleared +272 1717 3e7e mvi a, inte ;rst0 and rst7 bits on +273 1719 d3fc out intc +274 171b af xra a +275 171c d3f3 out icon ;interrupt control +276 ; +277 ; set default buffer address to 80h +278 171e 018000 lxi b, buff +279 1721 cdbb17 call setdma +280 ; +281 ; reset monitor entry points +282 1724 3ec3 mvi a, jmp +283 1726 320000 sta 0 +284 1729 210316 lxi h, wboote +285 172c 220100 shld 1 ;jump wboot at location 00 +286 172f 320500 sta 5 +287 1732 210608 lxi h, bdos +288 1735 220600 shld 6 ;jmp bdos at location 5 +289 if not test +290 1738 323800 sta 7*8 ;jmp to mon80 (may have changed by ddt) +291 173b 2100f8 lxi h, mon80 +292 173e 223900 shld 7*8+1 +293 endif +294 ; leave iobyte set +295 ; previously selected disk was b, send parameter to cpm +296 1741 3a0400 lda cdisk ;last logged disk number +297 1744 4f mov c, a ;send to ccp to log it in +298 1745 fb ei +299 1746 c30000 jmp cpmb +300 ; +301 ; error condition occurred, print message and retry +302 booterr: +303 1749 c1 pop b ;recall counts +304 174a 0d dcr c +305 174b ca5217 jz booter0 +306 ; try again +307 174e c5 push b +308 174f c3c916 jmp wboot0 +309 ; +310 booter0: +311 ; otherwise too many retries +312 1752 215b17 lxi h, bootmsg +313 1755 cdd317 call prmsg +314 1758 c30fff jmp rmon80 ;mds hardware monitor +315 ; +316 bootmsg: +317 175b 3f626f6f74 db '?boot', 0 +318 ; +319 ; +320 const: console status to reg-a +321 ; (exactly the same as mds call) +322 1761 c312f8 jmp csts +323 ; +324 conin: ;console character to reg-a +325 1764 cd03f8 call ci +326 1767 e67f ani 7fh ;remove parity bit +327 1769 c9 ret +328 ; +329 conout: ;console character from c to console out +330 176a c309f8 jmp co +331 ; +332 list: ;list device out +333 ; (exactly the same as mds call) +334 176d c30ff8 jmp lo +335 ; +336 listst: +337 ;return list status +338 1770 af xra a +339 1771 c9 ret ;always not ready +340 ; +341 punch: ;punch device out +342 ; (exactly the same as mds call) +343 1772 c30cf8 jmp po +344 ; +345 reader: ;reader character in to reg-a +346 ; (exactly the same as mds call) +347 1775 c306f8 jmp ri +348 ; +349 home: ;move to home position +350 ; treat as track 00 seek +351 1778 0e00 mvi c, 0 +352 177a c3a717 jmp settrk +353 ; +354 seldsk: ;select disk given by register c +355 177d 210000 lxi h, 0000h ;return 0000 if error +356 1780 79 mov a, c +357 1781 fe04 cpi ndisks ;too large? +358 1783 d0 rnc ;leave hl = 0000 +359 ; +360 1784 e602 ani 10b ;00 00 for drive 0, 1 and 10 10 for drive 2, 3 +361 1786 326618 sta dbank ;to select drive bank +362 1789 79 mov a, c ;00, 01, 10, 11 +363 178a e601 ani 1b ;mds has 0, 1 at 78, 2, 3 at 88 +364 178c b7 ora a ;result 00? +365 178d ca9217 jz setdrive +366 1790 3e30 mvi a, 00110000b ;selects drive 1 in bank +367 setdrive: +368 1792 47 mov b, a ;save the function +369 1793 216818 lxi h, iof ;io function +370 1796 7e mov a, m +371 1797 e6cf ani 11001111b ;mask out disk number +372 1799 b0 ora b ;mask in new disk number +373 179a 77 mov m, a ;save it in iopb +374 179b 69 mov l, c +375 179c 2600 mvi h, 0 ;hl=disk number +376 179e 29 dad h ;*2 +377 179f 29 dad h ;*4 +378 17a0 29 dad h ;*8 +379 17a1 29 dad h ;*16 +380 17a2 113316 lxi d, dpbase +381 17a5 19 dad d ;hl=disk header table address +382 17a6 c9 ret +383 ; +384 ; +385 settrk: ;set track address given by c +386 17a7 216a18 lxi h, iot +387 17aa 71 mov m, c +388 17ab c9 ret +389 ; +390 setsec: ;set sector number given by c +391 17ac 216b18 lxi h, ios +392 17af 71 mov m, c +393 17b0 c9 ret +394 sectran: +395 ;translate sector bc using table at de +396 17b1 0600 mvi b, 0 ;double-precision sector number in bc +397 17b3 eb xchg ;translate table address to hl +398 17b4 09 dad b ;translate (sector) address +399 17b5 7e mov a, m ;translated sector number to a +400 17b6 326b18 sta ios +401 17b9 6f mov l, a ;return sector number in l +402 17ba c9 ret +403 ; +404 setdma: ;set dma address given by regs b, c +405 17bb 69 mov l, c +406 17bc 60 mov h, b +407 17bd 226c18 shld iod +408 17c0 c9 ret +409 ; +410 read: ;read next disk record (assuming disk/trk/sec/dma set) +411 17c1 0e04 mvi c, readf ;set to read function +412 17c3 cde017 call setfunc +413 17c6 cdf017 call waitio ;perform read function +414 17c9 c9 ret ;may have error set in reg-a +415 ; +416 ; +417 write: ;disk write function +418 17ca 0e06 mvi c, writf +419 17cc cde017 call setfunc ;set to write function +420 17cf cdf017 call waitio +421 17d2 c9 ret ;may have error set +422 ; +423 ; +424 ; utility subroutines +425 prmsg: ;print message at h, l to 0 +426 17d3 7e mov a, m +427 17d4 b7 ora a zero? +428 17d5 c8 rz +429 ; more to print +430 17d6 e5 push h +431 17d7 4f mov c,a +432 17d8 cd6a17 call conout +433 17db e1 pop h +434 17dc 23 inx h +435 17dd c3d317 jmp prmsg +436 ; +437 setfunc: +438 ; set function for next i/o (command in reg-c) +439 17e0 216818 lxi h, iof ;io function address +440 17e3 7e mov a, m ;get it to accumulator for masking +441 17e4 e6f8 ani 11111000b ;remove previous command +442 17e6 b1 ora c ;set to new command +443 17e7 77 mov m, a ;replaced in iopb +444 ; the mds-800 controller requires disk bank bit in sector byte +445 ; mask the bit from the current i/o function +446 17e8 e620 ani 00100000b ;mask the disk select bit +447 17ea 216b18 lxi h, ios ;address the sector select byte +448 17ed b6 ora m ;select proper disk bank +449 17ee 77 mov m, a ;set disk select bit on/off +450 17ef c9 ret +451 ; +452 waitio: +453 17f0 0e0a mvi c, retry ;max retries before perm error +454 rewait: +455 ; start the i/o function and wait for completion +456 17f2 cd3f18 call intype ;in rtype +457 17f5 cd4c18 call inbyte ;clears the controller +458 ; +459 17f8 3a6618 lda dbank ;set bank flags +460 17fb b7 ora a ;zero if drive 0, 1 and nz if 2, 3 +461 17fc 3e67 mvi a, iopb and offh ;low address for iopb +462 17fe 0618 mvi b, iopb shr 8 ;high address for iopb +463 1800 c20b18 jnz iodr1 ;drive bank 1? +464 1803 d379 out ilow ;low address to controller +465 1805 78 mov a, b +466 1806 d37a out ihigh ;high address +467 1808 c31018 jmp waito ;to wait for complete +468 ; +469 iodr1: ;drive bank 1 +470 180b d389 out ilow+10h ;88 for drive bank 10 +471 180d 78 mov a, b +472 180e d38a out ihigh+10h +473 ; +474 1810 cd5918 waito: call instat ;wait for completion +475 1813 e604 ani iordy ;ready? +476 1815 ca1018 jz waito +477 ; +478 ; check io completion ok +479 1818 cd3f18 call intype ;must be io complete (00) unlinked +480 ; 00 unlinked i/o complete, 01 linked i/o complete (not used) +481 ; io disk status changed 11 (not used) +482 181b fe02 cpi 10b ;ready status change? +483 181d ca3218 jz wready +484 ; +485 ; must be 00 in the accumulator +486 1820 b7 ora a +487 1821 c23818 jnz werror ;some other condition, retry +488 ; +489 ; check i/o error bits +490 1824 cd4c18 call inbyte +491 1827 17 ral +492 1828 da3218 jc wready ;unit not ready +493 182b 1f rar +494 182c e6fe ani 11111110b ;any other errors? (deleted data ok) +495 182e c23818 jnz werror +496 ; +497 ; read or write is ok, accumulator contains zero +498 1831 c9 ret +499 ; +500 wready: ;not ready, treat as error for now +501 1832 cd4c18 call inbyte ;clear result byte +502 1835 c33818 jmp trycount +503 ; +504 werror: ;return hardware malfunction (crc, track, seek, etc.) +505 ; the mds controller has returned a bit in each position +506 ; of the accumulator, corresponding to the conditions: +507 ; 0 -deleted data (accepted as ok above) +508 ; 1 -crc error +509 ; 2 -seek error +510 ; 3 -address error (hardware malfunction) +511 ; 4 -data over/under flow (hardware malfunction) +512 ; 5 -write protect (treated as not ready) +513 ; 6 -write error (hardware malfunction) +514 ; j -not ready +515 ; (accumulator bits are numbered 7 6 5 4 3 2 1 0) +516 ; +517 ; it may be useful to filter out the various conditions, +518 ; but we will get a permanent error message if it is not +519 ; recoverable. in any case, the not ready condition is +520 ; treated as a separated condition for later improvement +521 trycount: +522 ; register c contains retry count, decrement 'til zero +523 1838 0d dcr c +524 1839 c2f217 jnz rewait ;for another try +525 ; +526 ; cannot recover from error +527 183c 3e01 mvi a, 1 ;error code +528 183e c9 ret +529 ; +530 ; intype, inbyte, instat read drive bank 00 or 10 +531 183f 3a6618 intype: lda dbank +532 1842 b7 ora a +533 1843 c24918 jnz intyp1 ;skip to bank 10 +534 1846 db79 in rtype +535 1848 c9 ret +536 1849 db89 intyp1: in rtype+10h ;78 for 0, 1 88 for 2, 3 +537 184b c9 ret +538 ; +539 184c 3a6618 inbyte: lda dbank +540 184f b7 ora a +541 1850 c25618 jnz inbyt1 +542 1853 db7b in rbyte +543 1855 c9 ret +544 1856 db8b inbyt1: in rbyte+10h +545 1858 c9 ret +546 ; +547 1859 3a6618 instat: lda dbank +548 185c b7 ora a +549 185d c26318 jnz insta1 +550 1860 db78 in dstat +551 1862 c9 ret +552 1863 db88 insta1: in dstat+10h +553 1865 c9 ret +554 ; +555 ; +556 ; +557 ; data areas (must be in ram) +558 1866 00 dbank: db 0 ;disk bank 00 if drive 0, 1 +559 ; 10 if drive 2, 3 +560 iopb: ;io parameter block +561 1867 80 db 80h ;normal i/o operation +562 1868 04 iof: db readf ;io function, initial read +563 1869 01 ion: db 1 ;number of sectors to read +564 186a 02 iot: db offset ;track number +565 186b 01 ios: db 1 ;sector number +566 186c 8000 iod: dw buff ;io address +567 ; +568 ; +569 ; define ram areas for bdos operation +570 endef +571 186e+= begdat equ $ +572 186e+ dirbuf: ds 128 ;directory access buffer +573 18ee+ alv0: ds 31 +574 190d+ csv0: ds 16 +575 191d+ alv1: ds 31 +576 193c+ csv1: ds 16 +577 194c+ alv2: ds 31 +578 196b+ csv2: ds 16 +579 197b+ alv3: ds 31 +580 199a+ csv3: ds 16 +581 19aa+= enddat equ $ +582 013c+= datsiz equ $-begdat +583 19aa end + + +als1 001f 141# +als2 001f 146# +als3 001f 151# +alv0 18ee 87 573# +alv1 191d 91 575# +alv2 194c 95 577# +alv3 197b 99 579# +base 0078 180# 181 182 183 185 186 +bdos 0806 29# 287 +begdat 186e 571# 582 +bias 0000 19# 22# +boot 16b3 63 207# +booter0 1752 305 310# +booterr 1749 241 302# +bootmsg 175b 312 316# +buff 0080 34# 209 221 278 566 +cdisk 0004 33# 213 296 +ci f803 172# 325 +co f809 174# 330 +conin 1764 66 324# +conout 176a 67 329# 432 +const 1761 65 320# +cpmb 0000 28# 29 30 226 299 +cpml 1600 30# 31 +cr 000d 192# 196 205 +css1 0010 142# +css2 0010 147# +css3 0010 152# +csts f812 177# 322 +csv0 190d 87 574# +csv1 193c 91 576# +csv2 196b 95 578# +csv3 199a 99 580# +datsiz 013c 582# +dbank 1866 361 459 531 539 539 547 558# +dirbuf 186e 86 90 94 98 572# +dpb0 1673 86 101# 140 145 150 +dpb1 1673 90 140# +dpb2 1673 94 145# +dpb3 1673 98 150# +dpbase 1633 83# 380 +dpe0 1633 84# +dpe1 1643 88# +dpe2 1653 92# +dpe3 1663 96# +dstat 0078 181# 550 552 +enddat 19aa 581# +false 0000 15# 16 +gocpm 170f 214 265# +home 1778 71 349# +icon 00fe 166# 275 +ihigh 007a 186# 466 472 +ilow 0079 185# 464 470 +inbyt1 1856 541 544# +inbyte 184c 457 490 501 539# +insta1 1863 549 552# +instat 1859 474 547# +intc 00fc 165# 271 273 +inte 007e 167# 272 +intyp1 1849 533 536# +intype 183f 456 479 531# +iod 186c 242 407 566# +iodr1 180b 463 469# +iof 1868 369 439 562# +ion 1869 563# +iopb 1867 461 462 560# +iordy 0004 191# 475 +ios 186b 248 391 400 447 565# +iot 186a 252 386 564# +lf 000a 193# 196 196 205 +list 176d 68 332# +listst 1770 78 336# +lo f80f 176# 334 +mon80 f800 170# 291 +nsects 002c 31# 237 +offset 0002 32# 100 564 +patch 1600 25# 27 28 +po f80c 175# 343 +prmsg 17d3 211 313 425# 435 +punch 1772 69 341# +rbyte 007b 183# 542 544 +rd1 1705 250 257# +rdsec 16e1 238# 262 +read 17c1 76 240 410# +reader 1775 70 345# +readf 0004 188# 411 562 +recal 0003 190# +retry 000a 35# 223 453 +revrt 00fd 164# 269 +rewait 17f2 454# 524 +ri f806 173# 347 +rmon80 ff0f 171# 314 +rtype 0079 182# 534 536 +sectran 17b1 79 394# +seldsk 177d 72 229 354# +setdma 17bb 75 227 247 279 404# +setdrive 1792 365 367# +setfunc 17e0 412 419 437# +setsec 17ac 74 233 259 390# +settrk 17a7 73 231 255 352 385# +signon 169c 195# 210 +test 0000 16# 18 21 197 200 289 +true ffff 14# 15 +trycount 1838 502 521# +vers 0016 6# 204 204 +waito 1810 467 474# 476 +waitio 17f0 413 420 452# +wboot 16c3 64 217# +wboot0 16c9 225# 308 +wboote 1603 64# 284 +werror 1838 487 495 504# +wready 1832 483 492 500# +write 17ca 77 417# +writf 0006 189# 418 +xlt0 1682 84 112# 143 148 153 +xlt1 1682 88 143# +xlt2 1682 92 148# +xlt3 1682 96 153# +.nx appb + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/appb.tex b/Source/Doc/CPM 22 Manual - Testing/appb.tex new file mode 100644 index 00000000..f8105690 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/appb.tex @@ -0,0 +1,371 @@ +.pl 51 +.nf +.bp 1 +.ft B-% + Appendix B + + A Skeletal CBIOS + + + + + 1 ; skeletal cbios for first level of cp/m 2.0 alteration + 2 ; + 3 0014 = msize equ 20 ;cp/m version memory size in kilobytes + 4 ; + 5 ; "bias" is address offset from 3400h for memory systems + 6 ; than 16k (referred to as "b" throughout the text) + 7 ; + 8 0000 = bias equ (msize-20)*1024 + 9 3400 = ccp equ 3400h+bias ;base of ccp + 10 3c06 = bdos equ ccp+806h ;base of bdos + 11 4a00 = bios equ ccp+1600h ;base of bios + 12 0004 = cdisk equ 0004h ;current disk number 0=a,..., 15=p + 13 0003 = iobyte equ 0003h ;intel i/o byte + 14 ; + 15 4a00 org bios ;origin of this program + 16 002c = nsects equ ($-ccp)/128 ;warm start sector count + 17 ; + 18 ; jump vector for individual subroutines + 19 4a00 c39c4a jmp boot ;cold start + 20 4a03 c3a64a wboote: jmp wboot ;warm start + 21 4a06 c3114b jmp const ;console status + 22 4a09 c3244b jmp conin ;console character in + 23 4a0c c3374b jmp conout ;console character out + 24 4a0f c3494b jmp list ;list character out + 25 4a12 c34d4b jmp punch ;punch character out + 26 4a15 c34f4b jmp reader ;reader character out + 27 4a18 c3544b jmp home ;move head to home position + 28 4a1b c35a4b jmp seldsk ;select disk + 29 4a1e c37d4b jmp settrk ;set track number + 30 4a21 c3924b jmp setsec ;set sector number + 31 4a24 c3ad4b jmp setdma ;set dma address + 32 4a27 c3c34b jmp read ;read disk + 33 4a2a c3d64b jmp write ;write disk + 34 4a2d c34b4b jmp listst ;return list status + 35 4a30 c3a74b jmp sectran ;sector translate + 36 ; + 37 ; fixed data tables for four-drive standard + 38 ; ibm-compatible 8" disks + 39 ; disk parameter header for disk 00 + 40 4a33 734a0000 dpbase: dw trans, 0000h + 41 4a37 00000000 dw 0000h, 0000h + 42 4a3b f04c8d4a dw dirbf, dpblk + 43 4a3f ec4d704d dw chk00, all00 + 44 ; disk parameter header for disk 01 + 45 4a43 734a0000 dw trans, 0000h + 46 4a47 00000000 dw 0000h, 0000h + 47 4a4b f04c8d4a dw dirbf, dpblk + 48 4a4f fc4d8f4d dw chk01, all01 + 49 ; disk parameter header for disk 02 + 50 4a53 734a0000 dw trans, 0000h + 51 4a57 00000000 dw 0000h, 0000h + 52 4a5b f04c8d4a dw dirbf, dpblk + 53 4a5f 0c4eae4d dw chk02, all02 + 54 ; disk parameter header for disk 03 + 55 4a63 734a0000 dw trans, 0000h + 56 4a67 00000000 dw 0000h, 0000h + 57 4a6b f04c8d4a dw dirbf, dpblk + 58 4a6f 1c4ecd4d dw chk03, all03 + 59 ; + 60 ; sector translate vector + 61 4a73 01070d13 trans: db 1, 7, 13, 19 ;sectors 1, 2, 3, 4 + 62 4a77 19050b11 db 25, 5, 11, 17 ;sectors 5, 6, 7, 8 + 63 4a7b 1703090f db 23, 3, 9, 15 ;sectors 9, 10, 11, 12 + 64 4a7f 1502080e db 21, 2, 8, 14 ;sectors 13, 14, 15, 16 + 65 4a83 141a060c db 20, 26, 6, 12 ;sectors 17, 18, 19, 20 + 66 4a87 1218040a db 18, 24, 4, 10 ;sectors 21, 22, 23, 24 + 67 4a8b 1016 db 16, 22 ;sectors 25, 26 + 68 ; + 69 dpblk: ;disk parameter block, common to all disks + 70 4a8d 1a00 dw 26 ;sectors per track + 71 4a8f 03 db 3 ;block shift factor + 72 4a90 07 db 7 ;block mask + 73 4a91 00 db 0 ;null mask + 74 4a92 f200 dw 242 ;disk size-1 + 75 4a94 3f00 dw 63 ;directory max + 76 4a96 c0 db 192 ;alloc 0 + 77 4a97 00 db 0 ;alloc 1 + 78 4a98 1000 dw 16 ;check size + 79 4a9a 0200 dw 2 ;track offset + 80 ; + 81 ; end of fixed tables + 82 ; + 83 ; individual subroutines to perform each function + 84 boot: ;simplest case is to just perform parameter initialization + 85 4a9c af xra a ;zero in the accum + 86 4a9d 320300 sta iobyte ;clear the iobyte + 87 4aa0 320400 sta cdisk ;select disk zero + 88 4aa3 c3ef4a jmp gocpm ;initialize and go to cp/m + 89 ; + 90 wboot: ;simplest case is to read the disk until all sectors loaded + 91 4aa6 318000 lxi sp, 80h ;use space below buffer for stack + 92 4aa9 0e00 mvi c, 0 ;select disk 0 + 93 4aab cd5a4b call seldsk + 94 4aae cd544b call home ;go to track 00 + 95 ; + 96 4ab1 062c mvi b, nsects ;b counts # of sectors to load + 97 4ab3 0e00 mvi c, 0 ;c has the current track number + 98 4ab5 1602 mvi d, 2 ;d has the next sector to read + 99 ; note that we begin by reading track 0, sector 2 since sector 1 +100 ; contains the cold start loader, which is skipped in a warm start +101 4ab7 210034 lxi h, ccp ;base of cp/m (initial load point) +102 load1: ;load one more sector +103 4aba c5 push b ;save sector count, current track +104 4abb d5 push d ;save next sector to read +105 4abc e5 push h ;save dma address +106 4abd 4a mov c, d ;get sector address to register c +107 4abe cd924b call setsec ;set sector address from register c +108 4ac1 c1 pop b ;recall dma address to b, c +109 4ac2 c5 push b ;replace on stack for later recall +110 4ac3 cdad4b call setdma ;set dma address from b, c +111 ; +112 ; drive set to 0, track set, sector set, dma address set +113 4ac6 cdc34b call read +114 4ac9 fe00 cpi 00h ;any errors? +115 4acb c2a64a jnz wboot ;retry the entire boot if an error occurs +116 ; +117 ; no error, move to next sector +118 4ace e1 pop h ;recall dma address +119 4acf 118000 lxi d, 128 ;dma=dma+128 +120 4ad2 19 dad d ;new dma address is in h, l +121 4ad3 d1 pop d ;recall sector address +122 4ad4 c1 pop b ;recall number of sectors remaining, and current trk +123 4ad5 05 dcr b ;sectors=sectors-1 +124 4ad6 caef4a jz gocpm ;transfer to cp/m if all have been loaded +125 ; +126 ; more sectors remain to load, check for track change +127 4ad9 14 inr d +128 4ada 7a mov a,d ;sector=27?, if so, change tracks +129 4adb fe1b cpi 27 +130 4add daba4a jc load1 ;carry generated if sector<27 +131 ; +132 ; end of current track, go to next track +133 4ae0 1601 mvi d, 1 ;begin with first sector of next track +134 4ae2 0c inr c ;track=track+1 +135 ; +136 ; save register state, and change tracks +137 4ae3 c5 push b +138 4ae4 d5 push d +139 4ae5 e5 push h +140 4ae6 cd7d4b call settrk ;track address set from register c +141 4ae9 e1 pop h +142 4aea d1 pop d +143 4aeb c1 pop b +144 4aec c3ba4a jmp load1 ;for another sector +145 ; +146 ; end of load operation, set parameters and go to cp/m +147 gocpm: +148 4aef 3ec3 mvi a, 0c3h ;c3 is a jmp instruction +149 4af1 320000 sta 0 ;for jmp to wboot +150 4af4 21034a lxi h, wboote ;wboot entry point +151 4af7 220100 shld 1 ;set address field for jmp at 0 +152 ; +153 4afa 320500 sta 5 ;for jmp to bdos +154 4afd 21063c lxi h, bdos ;bdos entry point +155 4b00 220600 shld 6 ;address field of jump at 5 to bdos +156 ; +157 4b03 018000 lxi b, 80h ;default dma address is 80h +158 4b06 cdad4b call setdma +159 ; +160 4b09 fb ei ;enable the interrupt system +161 4b0a 3a0400 lda cdisk ;get current disk number +162 4b0d 4f mov c, a ;send to the ccp +163 4b0e c30034 jmp ccp ;go to cp/m for further processing +164 ; +165 ; +166 ; simple i/o handlers (must be filled in by user) +167 ; in each case, the entry point is provided, with space reserved +168 ; to insert your own code +169 ; +170 const: ;console status, return 0ffh if character ready, 00h if not +171 4b11 ds 10h ;space for status subroutine +172 4b21 3e00 mvi a, 00h +173 4b23 c9 ret +174 ; +175 conin: ;console character into register a +176 4b24 ds 10h ;space for input routine +177 4b34 e67f ani 7fh ;strip parity bit +178 4b36 c9 ret +179 ; +180 conout: ;console character output from register c +181 4b37 79 mov a, c ;get to accumulator +182 4b38 ds 10h ;space for output routine +183 4b48 c9 ret +184 ; +185 list: ;list character from register c +186 4b49 79 mov a, c ;character to register a +187 4b4a c9 ret ;null subroutine +188 ; +189 listst: ;return list status (0 if not ready, 1 if ready) +190 4b4b af xra a ;0 is always ok to return +191 4b4c c9 ret +192 ; +193 punch: ;punch character from register c +194 4b4d 79 mov a, c ;character to register a +195 4b4e c9 ret ;null subroutine +196 ; +197 ; +198 reader: ;reader character into register a from reader device +199 4b4f 3e1a mvi a, 1ah ;enter end of file for now (replace later) +200 4b51 e67f ani 7fh ;remember to strip parity bit +201 4b53 c9 ret +202 ; +203 ; +204 ; i/o drivers for the disk follow +205 ; for now, we will simply store the parameters away for use +206 ; in the read and write subroutines +207 ; +208 home: ;move to the track 00 position of current drive +209 ; translate this call into a settrk call with parameter 00 +210 4b54 0e00 mvi c, 0 ;select track 0 +211 4b56 cd7d4b call settrk +212 4b59 c9 ret ;we will move to 00 on first read/write +213 ; +214 seldsk: ;select disk given by register c +215 4b51 210000 lxi h, 0000h ;error return code +216 4b5d 79 mov a, c +217 4b5e 32ef4c sta diskno +218 4b61 fe04 cpi 4 ;must be between 0 and 3 +219 4b63 d0 rnc ;no carry if 4, 5,... +220 ; disk number is in the proper range +221 4b64 ds 10 ;space for disk select +222 ; compute proper disk parameter header address +223 4b6e 3aef4c lda diskno +224 4b71 6f mov l, a ;l=disk number 0, 1, 2, 3 +225 4b72 2600 mvi h, 0 ;high order zero +226 4b74 29 dad h ;*2 +227 4b75 29 dad h ;*4 +228 4b76 29 dad h ;*8 +229 4b77 29 dad h ;*16 (size of each header) +230 4b78 11334a lxi d, dpbase +231 4b7b 19 dad 0 ;hl=.dpbase (diskno*16) +232 4b7c c9 ret +233 ; +234 settrk: ;set track given by register c +235 4b7d 79 mov a, c +236 4b7e 32e94c sta track +237 4b81 ds 10h ;space for track select +238 4b91 c9 ret +239 ; +240 setsec: ;set sector given by register c +241 4b92 79 mov a, c +242 4b93 32eb4c sta sector +243 4b96 ds 10h ;space for sector select +244 4ba6 c9 ret +245 ; +246 sectran: +247 ;translate the sector given by bc using the +248 ;translate table given by de +249 4ba7 eb xchg ;hl=.trans +250 4ba8 09 dad b ;hl=.trans (sector) +251 4ba9 6e mov l, m ;l=trans (sector) +252 4baa 2600 mvi h, 0 ;hl=trans (sector) +253 4bac c9 ret ;with value in hl +254 ; +255 setdma: ;set dma address given by registers b and c +256 4bad 69 mov l, c ;low order address +257 4bae 60 mov h, b ;high order address +258 4baf 22ed4c shld dmaad ;save the address +259 4bb2 ds 10h ;space for setting the dma address +260 4bc2 c9 ret +261 ; +262 read: ;perform read operation (usually this is similar to write +263 ; so we will allow space to set up read command, then use +264 ; common code in write) +265 4bc3 ds 10h ;set up read command +266 4bd3 c3e64b jmp waitio ;to perform the actual i/o +267 ; +268 write: ;perform a write operation +269 4bd6 ds 10h ;set up write command +270 ; +271 waitio: ;enter here from read and write to perform the actual i/o +272 ; operation. return a 00h in register a if the operation completes +273 ; properly, and 01h if an error occurs during the read or write +274 ; +275 ; in this case, we have saved the disk number in 'diskno' (0, 1) +276 ; the track number in 'track' (0-76) +277 ; the sector number in 'sector' (1-26) +278 ; the dma address in 'dmaad' (0-65535) +279 4be6 ds 256 ;space reserved for i/o drivers +280 4ce6 3e01 mvi a, 1 ;error condition +281 4ce8 c9 ret ;replaced when filled-in +282 ; +283 ; the remainder of the cbios is reserved uninitialized +284 ; data area, and does not need to be a part of the +285 ; system memory image (the space must be available, +286 ; however, between "begdat" and "enddat"). +287 ; +288 4ce9 track: ds 2 ;two bytes for expansion +289 4ceb sector: ds 2 ;two bytes for expansion +290 4ced dmaad: ds 2 ;direct memory address +291 4cef diskno: ds 1 ;disk number 0-15 +292 ; +293 ; scratch ram area for bdos use +294 4cf0= begdat equ $ ;beginning of data area +295 4cf0 dirfb: ds 128 ;scratch directory area +296 4d70 all00: ds 31 ;allocation vector 0 +297 4d8f all01: ds 31 ;allocation vector 1 +298 4dae all02: ds 31 ;allocation vector 2 +299 4dcd all03: ds 31 ;allocation vector 3 +300 4dec chk00: ds 16 ;check vector 0 +301 4dfc chk01: ds 16 ;check vector 1 +302 4e0c chk02: ds 16 ;check vector 2 +303 4e1c chk03: ds 16 ;check vector 3 +304 ; +305 4e2c enddat equ $ ;end of data area +306 013c= datsiz equ $-begdat; ;size of data area +307 4e2c end + +all00 4d70 43 296# +all01 4d8f 48 297# +all02 4dae 53 298# +all03 4dcd 58 299# +bdos 3c06 10# 154 +begdat 4cf0 294# 306 +bias 0000 8# 9 +bios 4a00 11# 15 +boot 4a9c 19 84# +ccp 3400 9# 10 11 16 101 163 +cdisk 0004 12# 87 161 +chk00 4dec 43 300# +chk01 4dfc 48 301# +chk02 4e0c 53 302# +chk03 4e1c 58 303# +conin 4b24 22 175# +conout 4b37 23 180# +const 4b11 21 170# +datsiz 013c 306# +dirbf 4cf0 42 47 52 57 295# +diskno 4cef 217 223 291# +dmaad 4ced 258 290# +dpbase 4a33 40# 230 +dpblk 4a8d 42 47 52 57 69# +enddat 4e2c 305# +gocpm 4aef 88 124 147# +home 4b54 27 94 208# +iobyte 0003 13# 86 +list 4b49 24 185# +listst 4b4b 34 189# +load1 4aba 102# 130 144 +msize 0014 3# 8 +nsects 002c 16# 96 +punch 4b4d 25 193# +read 4bc3 32 113 262# +reader 4b4f 26 198# +sector 4ceb 242 289# +sectran 4ba7 35 246# +seldsk 4b5a 28 93 214# +setdma 4bad 31 110 158 255# +setsec 4b92 30 107 240# +settrk 4b7d 29 140 211 234# +track 4ce9 236 288# +trans 4a73 40 45 50 55 61# +waitio 4be6 266 271# +wboot 4aa6 20 90# 115 +wboote 4a03 20# 150 +write 4bd6 33 268# + + +.nx appc + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/appc.tex b/Source/Doc/CPM 22 Manual - Testing/appc.tex new file mode 100644 index 00000000..b45311ad --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/appc.tex @@ -0,0 +1,143 @@ +.pl 51 +.nf +.bp 1 +.ft C-% + Appendix C + + A Skeletal GETSYS/PUTSYS Program + + + + ; combined getsys and putsys programs from + ; Sec 6.4 + ; Start the programs at the base of the TPA + +0100 org 0100h + +0014 = msize equ 20 ;size of cp/m in Kbytes + + ;"bias" is the amount to add to addresses for > 20k + ; (referred to as "b" throughout the text) + +0000 = bias equ (msize-20)*1024 +3400 = ccp equ 3400h+bias +3c00 = bdos equ ccp+0800h +4a00 = bios equ ccp+1600h + + ; getsys programs tracks 0 and 1 to memory at + ; 3880h + bias + + ; register usage + ; a (scratch register) + ; b track count (0...76) + ; c sector count (1...26) + ; d,e (scratch register pair) + ; h,l load address + ; sp set to track address + + gstart: ;start of getsys +0100 318033 lxi sp,ccp-0080h ;convenient place +0103 218033 lxi h,ccp-0080h ;set initial load +0106 0600 mvi b 0 ;start with track + rd$trk: ;read next track +0108 0e01 mvi c,1 ;each track start + rd$sec: +010a cd0003 call read$sec ;get the next sector +010d 118000 lxi d,128 ;offset by one sector +0110 19 dad d ; (hl=hl+128) +0111 0c inr c ;next sector +0112 79 mov a,c ;fetch sector number +0113 felb cpi 27 ;and see if last +0115 da0a01 jc rdsec ;<, do one more + + ;arrive here at end of track, move to next track + +0118 04 inr b ;track = track+1 +0119 78 mov a,b ;check for last +011a fe02 cpi 2 ;track = 2 ? +011c da0801 jc rd$trk ;<, do another + + ;arrive here at end of load, halt for lack of anything + ;better + +011f fb ei +0120 76 hlt + ; putsys program, places memory image + ; starting at + ; 3880h + bias back to tracks 0 and 1 + ; start this program at the next page boundary +0200 org ($+0100h) and 0ff00h + + put$sys: +0200 318033 lxi sp,ccp-0080h ;convenient place +0203 218033 lxi h,ccp-0080h ;start of dump +0206 0600 mvi b,0 ;start with track + wr$trk: +0208 0e01 mvi b,1 ;start with sector + wr$sec: +020a cd0004 call write$sec ;write one sector +020d 118000 lxi d,128 ;length of each +0210 19 dad d ;= + 128 +0211 0c inr c ; = + 1 +0212 79 mov a,c ;see if +0213 felb cpi 27 ;past end of track +0215 da0a02 jc wr$sec ;no, do another + + ;arrive here at end of track, move to next track + +0218 04 inr b ;track = track+1 +0219 78 mov a,b ;see if +021a fe02 cpi 2 ;last track +021c da0802 jc wr$trk ;no, do another + + ; done with putsys, halt for lack of anything + ; better + +02lf fb ei +0220 76 hit + + ;user supplied subroutines for sector read and write + + ; move to next page boundary + +0300 org ($+0100h) and 0ff00h + + read$sec: + ;read the next sector + ;track in , + ;sector in + ;dmaaddr in + +0300 c5 push b +0301 e5 push h + + ;user defined read operation goes here +0302 ds 64 + +0342 el pop h +0343 cl pop b +0344 c9 ret + +0400 org ($+0100h) and 0ff00h ;another page + ;boundary + + write$sec: + + ;same parameters as read$sec + +0400 c5 push b +0401 e5 push h + + ;user defined write operation goes here +0402 ds 64 + +0442 el pop h +0443 cl pop b +0444 c9 ret + + ;end of getsys/putsys program + +0445 end + +.nx appd + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/appd.tex b/Source/Doc/CPM 22 Manual - Testing/appd.tex new file mode 100644 index 00000000..30424b39 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/appd.tex @@ -0,0 +1,175 @@ +.pl 51 +.nf +.bp 1 +.ft D-% + Appendix D + + The Microcomputer Development System-800 Cold Start Loader for CP/M 2 + + + + 1 title mds cold start loader at 3000h' + 2 ; + 3 ; mds-800 cold start loader for cp/m 2.0 + 4 ; + 5 ; version 2.0 august, 1979 + 6 ; + 7 0000 = false equ 0 + 8 ffff true equ not false + 9 0000 = testing equ false if true, then go to mon80 on errors + 10 ; + 11 if testing + 12 bias equ 03400h + 13 endif + 14 if not testing + 15 0000 = bias equ 0000h + 16 endif + 17 0000 = cpmb equ bias ;base of dos load + 18 0806 = bdos equ 806h+bias ;entry to dos for calls + 19 1880 = bdose equ 1880h+bias ;end of dos load + 20 1600 = boot equ 1600h+bias ;cold start entry point + 21 1603 = rboot equ boot+3 ;warm start entry point + 22 ; + 23 3000 org 03000h ;loaded down from hardware boot at 3000H + 24 ; + 25 1880 = bdosl equ bdose-cpmb + 26 0002 = ntrks equ 2 ;number of tracks to read + 27 0031 = bdoss equ bdosl/128 ;number of sectors in dos + 28 0019 = bdoso equ 25 ;number of bdos sectors on track 0 + 29 0018 = bdos1 equ bdoss-bdoso ;number of sectors on track 1 + 30 ; + 31 f800 = mon80 equ 0f800h ;intel monitor base + 32 ff0f = rmon80 equ 0ff0fh ;restart location for mon80 + 33 0078 = base equ 078h ;'base' used by controller + 34 0079 = rtype equ base+1 ;result type + 35 007b = rbyte equ base+3 ;result byte + 36 007f = reset equ base+7 ;reset controller + 37 ; + 38 0078 = dstat equ base ;disk status port + 39 0079 = ilow equ base+1 ;low iopb address + 40 007a = ihigh equ base+2 ;high iopb address + 41 00ff = bsw equ 0ffh ;boot switch + 42 0003 = recal equ 3h ;recalibrate selected drive + 43 0004 = readf equ 4h ;disk read function + 44 0100 = stack equ 100h ;use end of boot for stack + 45 ; + 46 rstart: + 47 3000 310001 lxi sp,stack; ;in case of call to mon80 + 48 ; clear disk status + 49 3003 db79 in rtype + 50 3005 db7b in rbyte + 51 ; check if boot switch if off + 52 coldstart: + 53 3007 dbff in bsw + 54 3009 e602 ani 02h ;switch on? + 55 300b c20730 jnz coldstart + 56 ; clear the controller + 57 300e d37f out reset ;logic cleared + 58 ; + 59 ; + 60 3010 0602 mvi b,ntrks ;number of tracks to read + 61 3012 214230 lxi h,iopbo + 62 ; + 63 start: + 64 ; + 65 ; read first/next track into cpmb + 66 3015 7d mov a,l + 67 3016 d379 out ilow + 68 3018 7c mov a,h + 69 3019 d37a out ihigh + 70 301b db78 waito: in dstat + 71 301d e604 ani 4 + 72 301f ca1b30 jz waito + 73 ; + 74 ; check disk status + 75 3022 db79 in rtype + 76 3024 e603 ani 11b + 77 3026 fe02 cpi 2 + 78 ; + 79 if testing + 80 cnc rmon80 ;go to monitor if 11 or 10 + 81 endif + 82 if not testing + 83 3028 d20030 jnc rstart ;retry the load + 84 endif + 85 ; + 86 302b db7b in rbyte ;i/o complete, check status + 87 ; if not ready, then go to mon80 + 88 302d 17 ral + 89 302e dc0fff cc rmon80 ;not ready bit set + 90 3031 1f rar ;restore + 91 3032 e61e ani 11110b ;overrun/addr err/seek/crc/xxxx + 92 ; + 93 if testing + 94 cnz rmon80 ;go to monitor + 95 endif + 96 if not testing + 97 3034 c20030 jnz rstart ;retry the load + 98 endif + 99 ; +100 ; +101 3037 110700 lxi d,iopbl ;length of iopb +102 303a 19 dad d ;addressing next iopb +103 303b 05 dcr b ;count down tracks +104 303c c21530 jnz start +105 ; +106 ; +107 ; jmp to boot to print initial message, and set up jmps +108 303f c30016 jmp boot +109 ; +110 ; parameter blocks +111 3042 80 iopbo: db 80h ;iocw, no update +112 3043 04 db readf ;read function +113 3044 19 db bdoso ;#sectors to read on track 0 +114 3045 00 db 0 ;track 0 +115 3046 02 db 2 ;start with sector 2 on track 0 +116 3047 0000 dw cpmb ;start at base of bdos +117 0007 = iopbl equ $-iopbo +118 ; +119 3049 80 iopb1: db 80h +120 304a 04 db readf +121 304b 18 db bdos1 ;sectors to read on track 1 +122 304c 01 db 1 ;track 1 +123 304d 01 db 1 ;sector 1 +124 304e 800c dw cmpb+bdos0*128;base of second read +125 ; +126 3050 end + + +base 0078 33# 34 35 36 38 39 40 +bdos 0806 18# +bdoso 0019 28# 29 113 124 +bdos1 0018 29# 121 +bdose 1880 19# 25 +bdosl 1880 25# 27 +bdoss 0031 27# 29 +bias 0000 12# 15# 17 18 19 20 +boot 1600 20# 21 108 +bsw 00ff 41# 53 +coldstart 3007 52# 55 +cpmb 0000 17# 25 116 124 +dstat 0078 38# 70 +false 0000 7# 8 9 +ihigh 007a 40# 69 +ilow 0079 39# 67 +iopbo 3042 61 111# 117 +iopb1 3049 119# +iopbl 0007 101 117# +mon80 f800 31# +ntrks 0002 26# 60 +rboot 1603 21# +rbyte 007b 35# 50 86 +readf 0004 43# 112 120 +recal 0003 42# +reset 007f 36# 57 +rmon80 ff0f 32# 80 89 94 +rstart 3000 46# 83 97 +rtype 0079 34# 49 75 +stack 0100 44# 47 +start 3015 63# 104 +testing 0000 9# 11 14 79 82 93 96 +true ffff 8# +waito 301b 70# 72 + +.nx appe + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/appe.tex b/Source/Doc/CPM 22 Manual - Testing/appe.tex new file mode 100644 index 00000000..36a53fbc --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/appe.tex @@ -0,0 +1,109 @@ +.pl 51 +.nf +.bp 1 +.ft E-% + Appendix E + + A Skeletal Cold Start Loader + + + + ;this is a sample cold start loader, which, when + ;modified + ;resides on track 00, sector 01 (the first sector on the + ;diskette). we assume that the controller has loaded + ;this sector into memory upon system start-up (this + ;program can be keyed-in, or can exist in read-only + ;memory + ;beyond the address space of the cp/m version you are + ;running). the cold start loader brings the cp/m system + ;into memory at "loadp" (3400h + "bias"). in a 20k + ;memory system, the value of "bias" is 000h, with + ;large + ;values for increased memory sizes (see section 2). + ;after + ;loading the cp/m system, the cold start loader + ;branches + ;to the "boot" entry point of the bios, which beings at + ;"bios" + "bias". the cold start loader is not used un- + ;til the system is powered up again, as long as the bios + ;is not overwritten. the origin is assumed at 0000h, and + ;must be changed if the controller brings the cold start + ;loader into another area, or if a read-only memory + ;area + ;is used. + +0000 org 0 ;base of ram in + ;cp/m + +0014 = msize equ 20 ;min mem size in + ;kbytes +0000 = bias equ (msize-20)*1024 ;offset from 20k + ;system +3400 = ccp equ 3400h+bias ;base of the ccp +4a00 = bios equ ccp+1600h ;base of the bios +0300 = biosl equ 0300h ;length of the bios +4a00 = boot equ bios +1900 = size equ bios+biosl-ccp ;size of cp/m + ;system +0032 = sects equ size/128 ;# of sectors to load + + ; begin the load operation + + cold: +0000 010200 lxi b,2 ;b=0, c=sector 2 +0003 1632 mvi d,sects ;d=# sectors to + ;load +0005 210034 lxi h,ccp ;base transfer + ;address + lsect: ;load the next sector + + ; insert inline code at this point to + ; read one 128 byte sector from the + ; track given in register b, sector + ; given in register c, + ; into the address given by + ;branch to location "cold" if a read error occurs + ; + ; + ; user supplied read operation goes + ; here... + ; + ; + +0008 c36b00 jmp past$patch ;remove this + ;when patched +000b ds 60h + + past$patch: + ;go to next sector if load is incomplete +006b 15 dcr d ;sects=sects-1 +006c ca004a jz boot ;head for the bios + + ; more sectors to load + ; + ;we aren't using a stack, so use as scratch + ;register + ; to hold the load address increment + +006f 318000 lxi sp,128 ;128 bytes per + ;sector +0072 39 dad sp ; = + + 128 +0073 0c inr c ;sector=sector + 1 +0074 79 mov a,c +0075 felb cpi 27 ;last sector of + ;track? +0077 da0800 jc lsect ;no, go read + ;another + + ;end of track, increment to next track + +007a 0e01 mvi c,l ;sector = 1 +007c 04 inr b ;track = track + 1 +007d c30800 jmp lsect ;for another group +0080 end ;of boot loader + + +.nx appf + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/appf.tex b/Source/Doc/CPM 22 Manual - Testing/appf.tex new file mode 100644 index 00000000..f34da4f2 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/appf.tex @@ -0,0 +1,263 @@ +.pl 51 +.nf +.bp 1 +.ft F-% + Appendix F + + CP/M Disk Definition Library + + + 1:; CP/M 2.0 disk re-definition library + 2:; + 3:; Copyright (c) 1979 + 4:; Digital Research + 5:; Box 579 + 6:; Pacific Grove, CA + 7:; 93950 + 8:; + 9:; CP/M logical disk drives are defined using the + 10:; macros given below, where the sequence of calls + 11:; is: + 12:; + 13:; disks n + 14:; diskdef parameter-list-0 + 15:; diskdef parameter-list-1 + 16:; ... + 17:; diskdef parameter-list-n + 18:; endef + 19:; + 20:; where n is the number of logical disk drives attached + 21:; to the CP/M system, and parameter-list-i defines the + 22:; characteristics of the ith drive (i=0,1,...,n-1) + 23:; + 24:; each parameter-list-i takes the form + 25:; dn,fsc,lsc,[skf],bls,dks,dir,cks,ofs,[0] + 26:; where + 27:; dn is the disk number 0,1,...,n-1 + 28:; fsc is the first sector number (usually 0 or 1) + 29:; lsc is the last sector number on a track + 30:; skf is optional "skew factor" for sector translate + 31:; bls is the data block size (1024,2048,...,16384) + 32:; dks is the disk size in bls increments (word) + 33:; dir is the number of directory elements (word) + 34:; cks is the number of dir elements to checksum + 35:; ofs is the number of tracks to skip (word) + 36:; [0] is an optional 0 which forces 16K/directory end + 37:; + 38:; for convenience, the form + 39:; dn,dm + 40:; defines disk dn as having the same characteristics as + 41:; a previously defined disk dm. + 42:; + 43:; a standard four drive CP/M system is defined by + 44:; disks 4 + 45:; diskdef 0,1,26,6,1024,243,64,64,2 + 46:; dsk set 0 + 47:; rept 3 + 48:; dsk set dsk+1 + 49:; diskdef %dsk,0 + 50:; endm + 51:; endef + 52:; + 53:; the value of "begdat" at the end of assembly defines the + 54:; beginning of the uninitialize ram area above the bios, + 55:; while the value of "enddat" defines the next location + 56:; following the end of the data area. the size of this + 57:; area is given by the value of "datsiz" at the end of the + 58:; assembly. note that the allocation vector will be quite + 59:; large if a large disk size is defined with a small block + 60:; size. + 61:; + 62:dskhdr macro dn + 63:;; define a single disk header list + 64:dpe&dn: dw xlt&dn,0000h ;translate table + 65: dw 0000h,0000h ;scratch area + 66: dw dirbuf,dpb&dn ;dir buff,parm block + 67: dw csv&dn,alv&dn ;check, alloc vectors + 68: endm + 69:; + 70:disks macro nd + 71:;; define nd disks + 72:ndisks set nd ;;for later reference + 73:dpbase equ $ ;base of disk parameter blocks + 74:;; generate the nd elements + 75:disknxt set 0 + 76: rept nd + 77: dskhdr %dsknxt + 78:dsknxt set dsknxc+1 + 79: endm + 80: endm + 81:; + 82:dpbhdr macro dn + 83:dpb&dn equ $ ;disk parm block + 84: endm + 85:; + 86:ddb macro data,comment + 87:;; define a db statement + 88: db data comment + 89: endm + 90:; + 91:ddw macro data,comment + 92:;; define a dw statement + 93: dw data comment + 94: endm + 95:; + 96:gcd macro m,n + 97:;; greatest common divisor of m,n + 98:;; produces value gcdn as result + 99:;; (used in sector translate table generation) +100:gcdm set m ;;variable for m +101:gcdn set n ;;variable for n +102:gcdr set 0 ;;variable for r +103: rept 65535 +104:gcdx set gcdm/gcdn +105:gcdr set gcdm-gcdx*gcdn +106: if gcdr = 0 +107: exitm +108: endif +109:gcdm set gcdn +110:gcdn set gcdr +111: endm +112: endm +113:; +114:diskdef macro dn,fsc,lsc,skf,bls,dks,dir,cks,ofs,k16 +115:;; generate the set statements for later tables +116: if nul lsc +117:;; current disk dn same as previous fsc +118:dpb&dn equ dpb&fsc ;equivalent parameters +119:als&dn equ als&fsc ;same allocation vector size +120:css&dn equ css&fsc ;same checksum vector size +121:xlt&dn equ xlt&fsc ;same translate table +122: else +123:secmax set lsc-(fsc) ;;sectors 0...secmax +124:sectors set secmax+1 ;;number of sectors +125:als&dn set (dks)/8 ;;size of allocation vector +126: if ((dks)mod8) ne 0 +127:als&dn set als&dn+1 +128: endif +129:css&dn set (cks)/4 ;;number of checksum elements +130:;; generate the block shift value +131:blkval set bls/128 ;;number of sectors/block +132:blkshf set 0 ;;counts right 0's in blkval +133:blkmsk set 0 ;;fills with l's from right +134: rept 16 ;;once for each bit position +135: if blkval=1 +136: exitm +137: endif +138:;; otherwise, high order 1 not found yet +139:blkshf set blkshf+1 +140:blkmsk set (blkmsk shl l) or l +141:blkval set blkval/2 +142: endm +143:;; generate the extent mask byte +144:blkval set bls/1024 ;;number of kilobytes/block +145:extmsk set 0 ;;fill from right with l's +146: rept 16 +147: if blkval=1 +148: exitm +149: endif +150:;; otherwise more to shift +151:extmsk set (extmsk shl l) or l +152:blkval set blkval/2 +153: endm +154:;; may be double byte allocation +155: if (dks)>256 +156:extmsk set (extmsk shr l) +157: endif +158:;; may be optional [0] in last position +159: if not nul k16 +160:extmsk set k16 +161: endif +162:;; now generate directory reservation bit vector +163:dirrem set dir ;;#remaining to process +164:dirbks set bls/32 ;;number of entries per block +165:dirblk set 0 ;;fill with l's on each loop +166: rept 16 +167: if dirrem=0 +168: exitm +169: endif +170:;; not complete, iterate once again +171:;; shift right and add 1 high order bit +172:dirblk set (dirblk shr l) or 8000h +173: if dirrem>dirbks +174:dirrem set dirrem-dirbks +175: else +176:direem set 0 +177: endif +178: endm +179: dpbhdr dn ;;generate equ $ +180: ddw %sectors,<;sec per track> +181: ddb %blkshf,<;block shift> +182: ddb %blkmsk,<;block mask> +183: ddb %extmsk,<;extnt mask> +184: ddw %(dks)-1,<;disk size-1> +185: ddw %(dir)-1, +186: ddb %dirblk shr 8,<;alloc0> +187: ddb %dirblk and 0ffh,<;allocl> +188: ddw %(cks)/4,<;check size> +189: ddw %ofs,<;offset> +190:;; generate the translate table, if requested +191: if nul skf +192:xlt&dn equ 0 ;no xlate table +193: else +194: if skf = 0 +195:xlt&dn equ 0 ;no xlate table +196: else +197:;; generate the translate table +198:nxtsec set 0 ;;next sector to fill +199:nxtbas set 0 ;;moves by one on overflow +200: gcd %sectors,skf +201:;; gcdn = gcd(sectors,skew) +202:neltst set sectors/gcdn +203:;; neltst is number of elements to generate +204:;; before we overlap previous elements +205:nelts set neltst ;;counter +206:xlt&dn equ $ ;;translate table +207: rept sectors ;;once for each sector +208: if sectors<256 +209: ddb %nxtsec+(fsc) +210: else +211: ddw %nxtsec+(fsc) +212: endif +213:nxtsec set nxtsec+(skf) +214: if nxtsec>=sectors +215:nxtsec set nxtsec-sectors +216: endif +217:nelts set nelts-1 +218: if nelts = 0 +219:nxtbas set nxtbas+1 +220:nxtsec set nxtbas +221:nelts set neltst +222: endif +223: endm +224: endif ;;end of nul fac test +225: endif ;;end of nul bls test +226: endm +227:; +228:defds macro lab,space +229:lab: ds space +230: endm +231:; +232:lds macro lb,dn,val +233: defds lb&dn,%val&dn +234: endm +235:; +236:endef macro +237:;; generate the necessary ram data areas +238:begdat equ $ +239:dirbuf: ds 128 ;directory access buffer +240:dsknxt set 0 +241: rept ndisks ;;once for each disk +242: lds alv,%dsknxt,als +243: lds csv,%dsknxt,ccs +244:dsknxt set dsknxt+1 +245: endm +246:enddat equ $ +247:datsiz equ $-begdat +248:;; db 0 at this point forces hex record +249: endm + + +.nx appg + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/appg.tex b/Source/Doc/CPM 22 Manual - Testing/appg.tex new file mode 100644 index 00000000..6848b31f --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/appg.tex @@ -0,0 +1,475 @@ +.pl 51 +.nf +.bp 1 +.ft G-% + Appendix G + + Blocking and Deblocking Algorithms + + + + 1 ; + 2 ; + 3 ; sector deblocking algorithms for cp/m 2.0 + 4 ; + 5 ; + 6 ; + 7 ; utility macro to compute sector mask + 8 smask macro hblk + 9 ;; compute log2(hblk), return @x as result + 10 ;; (2 ** @x = hblk on return) + 11 @y set hblk + 12 @x set 0 + 13 ;; count right shifts of @y until = 1 + 14 rept 8 + 15 if @y = 1 + 16 exitm + 17 endif + 18 ;; @y is not 1, shift right one position + 19 @y set @y shr 1 + 20 @x set @x + 1 + 21 endm + 22 endm + 23 ; + 24 ; + 25 ; + 26 ; cp/m to host disk constants + 27 ; + 28 ; + 29 0800 = blksiz equ 2048 ;cp/m allocation size + 30 0200 = hstsiz equ 512 ;host disk sector size + 31 0014 = hstspt equ 20 ;host disk sectors/trk + 32 0004 = hstblk equ hstsiz/128 ;cp/m sects/host buff + 33 0050 = cpmspt equ hstblk * hstspt ;cp/m sectors/track + 34 0003 = secmsk equ hstblk-1 ;sector mask + 35 smask hstblk ;compute sector mask + 36 0002 = secshf equ @x ;log2(hstblk) + 37 ; + 38 ; + 39 ; + 40 ; bdos constants on entry to write + 41 ; + 42 ; + 43 0000 = wrall equ 0 ;write to allocated + 44 0001 = wrdir equ 1 ;write to directory + 45 0002 = wrual equ 2 ;write to unallocated + 46 ; + 47 ; + 48 ; + 49 ; the bdos entry points given below show the + 50 ; code which is relevant to deblocking only. + 51 ; + 52 ; + 53 ; + 54 ; diskdef macro, or hand coded tables go here + 55 0000 = dpbase equ $ ;disk param block base + 56 ; + 57 boot: + 58 wboot: + 59 ;enter here on system boot to initialize + 60 0000 af xra a ;0 to accumulator + 61 0001 326a01 sta hstact ;host buffer inactive + 62 0004 326c01 sta unacnt ;clear unalloc count + 63 0007 c9 ret + 64 ; + 65 home: + 66 ;home the selected disk + 67 home: + 68 0008 3a6b01 lda hstwrt ;check for pending write + 69 000b b7 ora a + 70 000c c21200 jnz homed + 71 000f 326a01 sta hstact ;clear host active flag + 72 homed: + 73 0012 c9 ret + 74 ; + 75 seldsk: + 76 ;select disk + 77 0013 79 mov a,c ;selected disk number + 78 0014 326101 sta sekdsk ;seek disk number + 79 0017 6f mov l,a ;disk number to hl + 80 0018 2600 mvi h,0 + 81 rept 4 ;multiply by 16 + 82 dad h + 83 endm + 84 001a+29 dad h + 85 001b+29 dad h + 86 001c+29 dad h + 87 001d+29 dad h + 88 001e 110000 lxi d,dpbase ;base of parm block + 89 0021 19 dad d ;hl=.dpb(curdsk) + 90 0022 c9 ret + 91 ; + 92 settrk: + 93 ;set track given by registers bc + 94 0023 60 mov h,b + 95 0024 69 mov l,c + 96 0025 226201 shld sektrk ;track to seek + 97 0028 c9 ret + 98 ; + 99 setsec: +100 ;set sector given by register c +101 0029 79 mov a,c +102 002a 326401 sta seksec ;sector to seek +103 002d c9 ret +104 ; +105 setdma: +106 ;set dma address given by bc +107 002e 60 mov h,b +108 002f 69 mov l,c +109 0030 227501 shld dmaadr +110 0033 c9 ret +111 ; +112 sectran: +113 ;translate sector number bc +114 0034 60 mov h,b +115 0035 69 mov l,c +116 0036 c9 ret +117 ; +118 ; +119 ; +120 ; the read entry point takes the place of +121 ; the previous bios definition for read. +122 ; +123 ; +124 read: +125 ;read the selected cp/m sector +126 0037 af xra a +127 0038 326c01 sta unacnt +128 003b 3e01 mvi a,1 +129 003d 327301 sta readop ;read operation +130 0040 327201 sta rsflag ;must read data +131 0043 3e02 mvi a,wrual +132 0045 327401 sta wrtype ;treat as unalloc +133 0048 c3b600 jmp rwoper ;to perform the read +134 ; +135 ; +136 ; +137 ; the write entry point takes the place of +138 ; the previous bios definition for write. +139 ; +140 ; +141 write: +142 ;write the selected cp/m sector +143 004b af xra a ;0 to accumulator +144 004c 327301 sta readop ;not a read operation +145 004f 79 mov a,c ;write type in c +146 0050 327401 sta wrtype +147 0053 fe02 cpi wrual ;write unallocated? +148 0050 c26f00 jnz chkuna ;check for unalloc +149 ; +150 ; write to unallocated, set parameters +151 0058 3e10 mvi a,blksiz/128 ;next unalloc recs +152 005a 326c01 sta unacnt +153 005d 3a6101 lda sekdsk ;disk to seek +154 0060 326d01 sta unadsk ;unadsk = sekdsk +155 0063 2a6201 lhld settrk +156 0066 226e01 shld unatrk ;unatrk = sectrk +157 0069 3a6401 lda seksec +158 006c 327001 sta unasec ;unasec = seksec +159 ; +160 chkuna: +161 ;check for write to unallocated sector +162 006f 3a6c01 lda unacnt ;any unalloc remain? +163 0072 b7 ora a +164 0073 caae00 jz alloc ;skip if not +165 ; +166 ; more unallocated records remain +167 0076 3d dcr a ;unacnt = unacnt-1 +168 0077 326c01 sta unacnt +169 007a 3a6101 lda sekdsk ;same disk? +170 007d 216d01 lxi h,unadsk +171 0080 be cmp m ;sekdsk = unadsk? +172 0081 c2ae00 jnz alloc ;skip if not +173 ; +174 ; disks are the same +175 0084 216e01 lxi h,unatrk +176 0087 cd5301 call sektrkcmp ;saektrk = unatrk? +177 008a c2ae00 jnz alloc ;skip if not +178 ; +179 ; tracks are the same +180 008d 3a6401 lda seksec ;same sector? +181 0090 217001 lxi h,unasec +182 0093 be cmp m ;seksec = unasec? +183 0094 c2ae00 jnz alloc ;skip if not +184 ; +185 ; match, move to next sector for future ref +186 0097 34 inr m ;unasec = unasec+1 +187 0098 7e mov a,m ;end of track? +188 0099 fe50 cpi cpmspt ;count cp/m sectors +189 009b daa700 jc noovf ;skip if no overflow +190 ; +191 ; overflow to next track +192 009e 3600 mvi m,o ;unasec = 0 +193 00a0 2a6e01 lhld unatrk +194 00a3 23 inx h +195 00a4 226e01 shld unatrk ;unatrk = unatrk+1 +196 ; +197 noovf: +198 ;match found, mark as unnecessary read +199 00a7 af xra a ;0 to accumulator +200 00ab 327201 sta rsflag ;rsflag = 0 +201 00ab c3b600 jmp rwoper ;to perform the write +202 ; +203 alloc: +204 ;not an unallocated record, requires pre-read +205 00ae af xra a ;0 to accum +206 00af 326c01 sta unacnt ;unacnt = 0 +207 00b2 3c inr a ;1 to accum +208 00b3 327201 sta rsflag = 1 ;rsflag = 1 +209 ; +210 ; +211 ; +212 ; common code for read and write follows +213 ; +214 ; +215 rwoper: +216 ;enter here to perform the read-write +217 00b6 af xra a ;zero to accum +218 00b7 327101 sta erflag ;no errors (yet) +219 00ba 3a6401 lda seksec ;compute host sector +220 rept secshf +221 ora a ;carry = 0 +222 rar ;shift right +223 endm +224 00bd+b7 ora a ;carry = 0 +225 00be+1f rar ;shift right +226 00bf+b7 ora a ;carry = 0 +227 00c0+1f rar ;shift right +228 00c1 326901 sta sekhst ;host sector to seek +229 ; +230 ; active host sector? +231 00c4 216a01 lxi h,hstact ;host active flag +232 00c7 7e mov a,m +233 00c8 3601 mvi m,1 ;always becomes 1 +234 00ca b7 ora a ;was it already? +235 00cb caf200 jz filhst ;fill host if not +236 ; +237 ; host buffer active, same as seek buffer? +238 00ce 3a6101 lda sekdsk +239 00d1 216501 lxi h,hstdsk ;same disk? +240 00d4 be cmp m ;sekdsk = hstdsk? +241 00d5 c2eb00 jnz nomatch +242 ; +243 ; same disk, same track? +244 00d8 216601 lxi h,hsttrk +245 00db cd5301 call sektrkcmp ;sektrk = hsttrk? +246 00de c2eb00 jnz nomatch +247 ; +248 ; same disk, same track, same buffer? +249 00e1 3a6901 lda sekhst +250 00e4 216801 lxi h,hstsec ;sekhst = hstsec? +251 00e7 be cmp m +252 00e8 ca0f01 jz match ;skip if match +253 ; +254 nomatch: +255 ;proper disk, but not correct sector +256 00eb 3a6b01 lda hstwrt ;host written? +257 00ee b7 ora a +258 00ef c45f01 cnz writehst ;clear host buff +259 ; +260 filhst: +261 ;may have to fill the host buffer +262 00f2 3a6101 lda sekdsk +263 00f5 326501 sta hstdsk +264 00f8 2a6201 lhld sektrk +265 00fb 226601 shld hsttrk +266 00fe 3a6901 lda sekhst +267 0101 326801 sta hstsec +268 0104 3a7201 lda rsflag ;need to read? +269 0107 b7 ora a +270 0108 c46001 cnz readhst ;yes, if 1 +271 010b af xra a ;0 to accum +272 010c 326b01 sta hstwrt ;no pending write +273 ; +274 match: +275 ;copy data to or from buffer +276 010f 3a6401 lda seksec ;mask buffer number +277 0112 e603 ani secmsk ;least signif bits +278 0114 6f mov l,a ;ready to shift +279 0115 2600 mvi h,0 ;double count +280 rept 7 ;shift left 7 +281 dad h +282 endm +283 0117+29 dad h +284 0118+29 dad h +285 0119+29 dad h +286 011a+29 dad h +287 011b+29 dad h +288 011c+29 dad h +289 011d+29 dad h +290 ; hl has relative host buffer address +291 011e 117701 lxi d,hstbuf +292 0121 19 dad d ;hl = host address +293 0122 eb xchg ;now in de +294 0123 2a7501 lhld dmaadr ;get/put cp/m data +295 0126 0e80 mvi c,128 ;length of move +296 0128 3a7301 lda readop ;which way? +297 012b b7 ora a +298 012c c23501 jnz rwmove ;skip if read +299 ; +300 ; write operation, mark and switch direction +301 012f 3e01 mvi a,1 +302 0131 326b01 sta hstwrt ;hstwrt = 1 +303 0134 eb xchg ;source/dest swap +304 ; +305 rwmove: +306 ;c initially 128, de is source, hl is dest +307 0135 1a ldax d ;source character +308 0136 13 inx d +309 0137 77 mov m,a ;to dest +310 0138 23 inx h +311 0139 od dcr c ;loop 128 times +312 013a c23501 jnz rwmove +313 ; +314 ; data has been moved to/from host buffer +315 013d 3a7401 lda wrtype ;write type +316 0140 fe01 cpi wrdir ;to directory? +317 0142 3a7101 lda erflag ;in case of errors +318 0145 c0 rnz ;no further processing +319 ; +320 ; clear host buffer for directory write +321 0146 b7 ora a ;errors? +322 0147 c0 rnz ;skip if so +323 0148 af xra a ;0 to accum +324 0149 326b01 sta hstwrt ;buffer written +325 014c cd5f01 call writehst +326 014f 3a7101 lda erflag +327 0152 c9 +328 ; +329 ; +330 ; +331 ; utility subroutine for 16-bit compare +332 ; +333 ; +334 sektrkcmp: +335 ;hl = .unatrk or .hsttrk, compare with sektrk +336 0153 eb xchg +337 0154 216201 lxi h,sektrk +338 0157 1a ldax d ;low byte compare +339 0158 be cmp m ;same? +340 0159 c0 rnz ;return if not +341 ; low bytes equal, test high 1s +342 015a 13 inx d +343 015b 23 inx h +344 015c 1a ldax d +345 015d be cmp m ;sets flags +346 015e c9 ret +347 ; +348 ; +349 ; +350 ; writehst performs the physical write to +351 ; the host disk, readhst reads the physical +352 ; disk. +353 ; +354 ; +355 writehst: +356 ;hstdsk = host disk #, hsttrk = host track #, +357 ;hstsec = host sect #. write "hstsiz" bytes +358 ;from hstbuf and return error flag in erflag. +359 ;return erflag non-zero if error +360 015f c9 ret +361 ; +362 readhst: +363 ;hstdsk = host disk #, hsttrk = host track #, +364 ;hstsec = host sect #. read "hstsiz" bytes +365 ;into hstbuf and return error flag in erflag. +366 0160 c9 ret +367 ; +368 ; +369 ; +370 ; uninitialized ram data areas +371 ; +372 ; +373 ; +374 0161 sekdsk: ds 1 ;seek disk number +375 0162 sektrk: ds 2 ;seek track number +376 0164 seksec: ds 1 ;seek sector number +377 ; +378 0165 hstdsk: ds 1 ;host disk number +379 0166 hsttrk: ds 2 ;host track number +380 0168 hstsec: ds 1 ;host sector number +381 ; +382 0169 sekhst: ds 1 ;seek shr secshf +383 016a hstact: ds 1 ;host active flag +384 016b hstwrt: ds 1 ;host written flag +385 ; +386 016c unacnt: ds 1 ;unalloc rec cnt +387 016d unadsk: ds 1 ;last unalloc disk +388 016e unatrk: ds 2 ;last unalloc track +389 0170 unasec: ds 1 ;last unalloc sector +390 ; +391 0171 erflag: ds 1 ;error reporting +392 0172 rsflag: ds 1 ;read sector flag +393 0173 readop: ds 1 ;1 if read operation +394 0174 wrtype: ds 1 ;write operation type +395 0175 dmaadr: ds 2 ;last dma address +396 0177 hstbuf: ds hstsiz ;host buffer +397 ; +398 ; +399 ; +400 ; the endef macro invocation goes here +401 ; +402 ; +403 0377 end + + + + + + + + + +alloc 00ae 164 172 177 183 203# +blksiz 0800 29# 151 +boot 0000 57# +chkuna 006f 148 160# +cpmspt 0050 33# 188 +dmaadr 0175 109 294 395# +dpbase 0000 55# 88 +erflag 0171 218 317 326 391# +filhst 00f2 235 260# +home 0008 65# 67# +homed 0012 70 72# +hstact 016a 61 71 231 383# +hstblk 0004 32# 33 34 35 +hstbuf 0177 291 396# +hstdsk 0165 239 263 378# +hstsec 0168 250 267 380# +hstsiz 0200 30# 32 396 +hstspt 0014 31# 33 +hsttrk 0166 244 265 379# +hstwrt 016b 68 256 272 302 324 384# +match 010fl 252 274# +nomatch 00eb 241 246 254# +noovf 00a7 189 197# +read 0037 124# +readhst 0160 270 362# +readop 0173 129 144 296 393# +rsflag 0172 130 200 208 268 392# +rwmove 0135 298 305# 312 +rwoper 00b6 133 201 215# +secmsk 0003 34# 277 +secshf 0002 36# 220 +sectran 0034 112# +sekdsk 0161 78 153 169 238 262 374# +sekhst 0169 228 249 266 382# +seksec 0164 102 157 180 219 276 376# +sektrk 0162 96 155 264 337 375# +sektrkcmp 0153 176 245 334# +seldsk 0013 75# +setdma 002e 105# +setsec 0029 99# +settrk 0023 92# +unacnt 016c 62 127 152 162 168 206 386# +unadsk 016d 154 170 387# +unasec 0170 158 181 389# +unatrk 016e 156 175 193 195 388# +wboot 0000 58# +wrall 0000 43# +wrdir 0001 44# 316 +write 004b 141# +writehst 015f 258 325 355# +wrtype 0174 132 146 315 394# +wrual 0002 45# 131 147 + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/apph.tex b/Source/Doc/CPM 22 Manual - Testing/apph.tex new file mode 100644 index 00000000..90d673d2 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/apph.tex @@ -0,0 +1,904 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft H-% +.pc 1 +.tc H Glossary +.ce 2 +.sh +Appendix H +.sp +.sh +Glossary +.qs +.he CP/M Operating System Manual H Glossary +.sp 3 +.sh +address: \c +.qs +Number representing the location of a byte in memory. Within +CP/M there are two kinds of addresses: logical and physical. A +physical address refers to an absolute and unique location within +the computer's memory space. A logical address refers to the +offset or displacement of a byte in relation to a base location. +A standard CP/M program is loaded at address 0100H, the base +value; the first instruction of a program has a physical address +of 0100H and a relative address or offset of OH. +.sp +.sh +allocation vector (ALV): \c +.qs +An allocation vector is maintained in the BIOS for each logged-in +disk drive. A vector consists of a string of bits, one for each +block on the drive. The bit corresponding to a particular block +is set to one when the block has been allocated and to zero +otherwise. The first two bytes of this vector are initialized +with the bytes AL0 and AL1 on, thus allocating the directory +blocks. CP/M Function 27 returns the allocation vector address. +.sp +.sh +AL0, AL1: \c +.qs +Two bytes in the disk parameter block that reserve data blocks +for the directory. These two bytes are copied into the first two +bytes of the allocation vector when a drive is logged in. See \c +.sh +allocation vector. +.sp +.sh +ALV: \c +.qs +See \c +.sh +allocation vector. +.sp +.sh +ambiguous filename: \c +.qs +Filename that contains either of the CP/M wildcard characters, ? +or *, in the primary filename, filetype, or both. When you +replace characters in a filename with these wildcard characters, +you create an ambiguous filename and can easily reference more +than one CP/M file in a single command line. +.sp +.sh +American Standard Code for Information Interchange: \c +.qs +See \c +.sh +ASCII. +.sp +.sh +applications program: \c +.qs +Program designed to solve a specific problem. Typical +applications programs are business accounting packages, word +processing (editing) programs and mailing list programs. +.sp +.sh +archive attribute: \c +.qs +File attribute controlled by the high-order bit of the t3 byte +(FCB+11) in a directory element. This attribute is set if the +file has been archived. +.sp +.sh +argument: \c +.qs +Symbol, usually a letter, indicating a place into which you can +substitute a number, letter, or name to give an appropriate +meaning to the formula in question. +.sp +.sh +ASCII: \c +.qs +American Standard Code for Information Interchange. ASCII is a +standard set of seven-bit numeric character codes used to +represent characters in memory. Each character requires one byte +of memory with the high-order bit usually set to zero. +Characters can be numbers, letters, and symbols. An ASCII file can be +intelligibly displayed on the video screen or printed on paper. +.sp +.sh +assembler: \c +.qs +Program that translates assembly language into the binary machine +code. Assembly language is simply a set of mnemonics used to +designate the instruction set of the CPU. See \c +.sh +ASM \c +.qs +in Section 3 of this manual. +.sp +.sh +back-up: \c +.qs +Copy of a disk or file made for safekeeping, or the creation of +the duplicate disk or file. +.sp +.sh +Basic Disk Operating System: \c +.qs +See \c +.sh +BDOS. +.sp +.sh +BDOS: \c +.qs +Basic Disk Operating System. The BDOS module of the CP/M +operating system provides an interface for a user program to the +operating system. This interface is in the form of a set of +function calls which may be made to the BDOS through calls to +location 0005H in page zero. The user program specifies the +number of the desired function in register C. User programs +running under CP/M should use BDOS functions for all I/O +operations to remain compatible with other CP/M systems and +future releases. The BDOS normally resides in high memory +directly below the BIOS. +.sp +.sh +bias: \c +.qs +Address value which when added to the origin address of your BIOS +module produces 1F80H, the address of the BIOS module in the +MOVCPM image. There is also a bias value that when added to the +BOOT module origin produces 0900H, the address of the BOOT module +in the MOVCPM image. You must use these bias values with the R +command under DDT or SID \ \ when you patch a CP/M system. If you do +not, the patched system may fail to function. +.sp +.sh +binary: \c +.qs +Base 2 numbering system. A binary digit can have one of two +values: 0 or 1. Binary numbers are used in computers because +the hardware can most easily exhibit two states: off and on. +Generally, a bit in memory represents one binary digit. +.sp +.sh +Basic Input/Output System: \c +.qs +See \c +.sh +BIOS. +.sp +.sh +BIOS: \c +.qs +Basic Input/Output System. The BIOS is the only hardware- +dependent module of the CP/M system. It provides the BDOS with a +set of primitive I/O operations. The BIOS is an assembly +language module usually written by the user, hardware +manufacturer, or independent software vendor, and is the key to +CP/M's portability. The BIOS interfaces the CP/M system to its +hardware environment through a standardized jump table at the +front of the BIOS routine and through a set of disk parameter +tables which define the disk environment. Thus, the BIOS +provides CP/M with a completely table-driven I/O system. +.sp +.sh +BIOS base: \c +.qs +Lowest address of the BIOS module in memory, that by definition +must be the first entry point in the BIOS jump table. +.bp +.sh +bit: \c +.qs +Switch in memory that can be set to on (1) or off (0). Bits are +grouped into bytes, eight bits to a byte, which is the smallest +directly addressable unit in an Intel 8080 or Zilog Z80. By +common convention, the bits in a byte are numbered from right, 0 +for the low-order bit, to left, 7 for the high-order bit. Bit +values are often represented in hexadecimal notation by grouping +the bits from the low-order bit in groups of four. Each group of +four bits can have a value from 0 to 15 and thus can easily be +represented by one hexadecimal digit. +.sp +.sh +BLM: \c +.qs +See \c +.sh +block mask. +.sp +.sh +block: \c +.qs +Basic unit of disk space allocation. Each disk drive has a fixed +block size (BLS) defined in its disk parameter block in the BIOS. +A block can consist of 1K, 2K, 4K, 8K, or 16K consecutive bytes. +Blocks are numbered relative to zero so that each block is unique +and has a byte displacement in a file equal to the block number +times the block size. +.sp +.sh +block mask (BLM): \c +.qs +Byte value in the disk parameter block at DPB + 3. The block +mask is always one less than the number of 128 byte sectors that +are in one block. Note that BLM = (2 ** BSH) - 1. +.sp +.sh +block shift (BSH): \c +.qs +Byte parameter in the disk parameter block at DPB + 2. +Block shift and block mask (BLM) values are determined by the +block size (BLS). Note that BLM = (2 ** BSH) - 1. +.sp +.sp 0 +.sh +blocking & deblocking algorithm: \c +.qs +In some disk subsystems the disk sector size is larger than 128 +bytes, usually 256, 512, 1024, or 2048 bytes. When the host +sector size is larger than 128 bytes, host sectors must be +buffered in memory and the 128-byte CP/M sectors must be blocked +and deblocked by adding an additional module, the blocking and +deblocking algorithm, between the BIOS disk I/O routines and the +actual disk I/O. The host sector size must be an even multiple +of 128 bytes for the algorithm to work correctly. The blocking +and deblocking algorithm allows the BDOS and BIOS to function +exactly as if the entire disk consisted only of 128-byte sectors, +as in the standard CP/M installation. +.sp +.sh +BLS: \c +.qs +Block size in bytes. See \c +.sh +block. +.sp +.sh +boot: \c +.qs +Process of loading an operating system into memory. A boot +program is a small piece of code that is automatically executed +when you power-up or reset your computer. The boot program loads +the rest of the operating system into memory in a manner similar +to a person pulling himself up by his own bootstraps. This +process is sometimes called a cold boot or cold start. Bootstrap +pocedures vary from system to system. The boot program must be +customized for the memory size and hardware environment that the +operating system manages. Typically, the boot resides on the +first sector of the system tracks on your system disk. When +executed, the boot loads the remaining sectors of the system +tracks into high memory at the location for which the CP/M system +has been configured. Finally, the boot transfers execution to +the boot entry point in the BIOS jump table so that the system +can initialize itself. In this case, the boot program should be +placed at 900H in the SYSGEN image. Alternatively, the boot +program may be located in ROM. +.sp +.sh +bootstrap: \c +.qs +See \c +.sh +boot. +.sp +.sh +BSH: \c +.qs +See \c +.sh +block shift. +.sp +.sh +BTREE: \c +.qs +General purpose file access method that has become the standard +organization for indexes in large data base systems. BTREE +provides near optimum performance over the full range of file +operations, such as insertion, deletion, search, and search next. +.sp +.sh +buffer: \c +.qs +Area of memory that temporarily stores data during the transfer +of information. +.sp +.sh +built-in commands: \c +.qs +Commands that permanently reside in memory. They respond quickly +because they are not accessed from a disk. +.sp +.sh +byte: \c +.qs +Unit of memory or disk storage containing eight bits. A byte can +represent a binary number between 0 and 255, and is the smallest +unit of memory that can be addressed directly in 8-bit CPUs such +as the Intel 8080 or Zilog Z80. +.sp +.sh +CCP: \c +.qs +Console Command Processor. The CCP is a module of the CP/M +operating system. It is loaded directly below the BDOS module +and interprets and executes commands typed by the console user. +Usually these commands are programs that the CCP loads and calls. +Upon completion, a command program may return control to the CCP +if it has not overwritten it. If it has, the program can reload +the CCP into memory by a warm boot operation initiated by either +a jump to zero, BDOS system reset (Function 0), or a cold boot. +Except for its location in high memory, the CCP works like any +other standard CP/M program; that is, it makes only BDOS function +calls for its I/O operations. +.sp +.sh +CCP base: \c +.qs +Lowest address of the CCP module in memory. This term sometimes +refers to the base of the CP/M system in memory, as the CCP is +normally the lowest CP/M module in high memory. +.sp +.sh +checksum vector (CSV): \c +.qs +Contiguous data area in the BIOS, with one byte for each +directory sector to be checked, that is, CKS bytes. See \c +.sh +CKS. \c +.qs +A checksum vector is initialized and maintained for each logged-in +drive. Each directory access by the system results in a checksum +calculation that is compared with the one in the checksum vector. +If there is a discrepancy, the drive is set to Read-Only status. +This feature prevents the user from inadvertently switching disks +without logging in the new disk. If the new disk is not logged-in, +it is treated the same as the old one, and data on it might be +destroyed if writing is done. +.sp +.mb 5 +.fm 1 +.sh +CKS: \c +.qs +Number of directory records to be checked summed on directory +accesses. This is a parameter in the disk parameter block +located in the BIOS. If the value of CKS is zero, then no +directory records are checked. CKS is also a parameter in the +diskdef macro library, where it is the actual number of directory +elements to be checked rather than the number of directory +records. +.sp +.sh +cold boot: \c +.qs +See \c +.sh +boot. \c +.qs +Cold boot also refers to a jump to the boot entry point in the +BIOS jump table. +.sp +.mb 6 +.fm 2 +.sh +COM: \c +.qs +Filetype for a CP/M command file. See \c +.sh +command file. +.sp +.sh +command: \c +.qs +CP/M command line. In general, a CP/M command line has three +parts: the command keyword, command tail, and a carriage return. +To execute a command, enter a CP/M command line directly after +the CP/M prompt at the console and press the carriage return or +enter key. +.sp +.sh +command file: \c +.qs +Executable program file of filetype COM. A command file is a +machine language object module ready to be loaded and executed at +the absolute address of 0100H. To execute a command file, enter +its primary filename as the command keyword in a CP/M command +line. +.sp +.sh +command keyword: \c +.qs +Name that identifies a CP/M command, usually the primary filename +of a file of type COM, or a built-in command. The command +keyword precedes the command tail and the carriage return in the +command line. +.sp +.sh +command syntax: \c +.qs +Statement that defines the correct way to enter a command. The +correct structure generally includes the command keyword, the +command tail, and a carriage return. A syntax line usually +contains symbols that you should replace with actual values when +you enter the command. +.sp +.sh +command tail: \c +.qs +Part of a command that follows the command keyword in the command +line. The command tail can include a drive specification, a +filename and filetype, and options or parameters. Some +commands do not require a command tail. +.sp +.sh +CON: \c +.qs +Mnemonic that represents the CP/M console device. +For example, the CP/M command PIP CON:=TEST.SUB displays the +file TEST.SUB on the console device. The explanation of the STAT +command tells how to assign the logical device CON: to various +physical devices. \c +See \c +.sh +console. +.sp +.sh +concatenate: \c +.qs +Name of the PIP operation that copies two or more separate files +into one new file in the the specified sequence. +.sp +.sh +concurrency: \c +.qs +Execution of two processes or operations simultaneously. +.sp +.sh +CONIN: \c +.qs +BIOS entry point to a routine that reads a character from the +console device. +.sp +.sh +CONOUT: \c +.qs +BIOS entry point to a routine that sends a character to the +console device. +.bp +.sh +console: \c +.qs +Primary input/output device. The console consists of a listing +device, such as a screen or teletype, and a keyboard through +which the user communicates with the operating system or +applications program. +.sp +.sh +Console Command Processor: \c +.qs +See \c +.sh +CCP. +.sp +.sh +CONST: \c +.qs +BIOS entry point to a routine that returns the status of the +console device. +.sp +.sh +control character: \c +.qs +Nonprinting character combination. CP/M interprets some control +characters as simple commands such as line editing functions. To +enter a control character, hold down the CONTROL key and strike +the specified character key. +.sp +.sh +Control Program for Microcomputers: \c +.qs +See \c +.sh +CP/M. +.sp +.sh +CP/M: \c +.qs +Control Program for Microcomputers. An operating system that +manages computer resources and provides a standard systems +interface to software written for a large variety of +microprocessor-based computer systems. +.sp +.sh +CP/M 1.4l compatibility: \c +.qs +For a CP/M 2 system to be able to read correctly single-density +disks produced under a CP/M 1.4 system, the extent mask must be +zero and the block size 1K. This is because under CP/M 2 an FCB +may contain more than one extent. The number of extents that may +be contained by an FCB is EXM+1. The issue of CP/M 1.4 +compatibility also concerns random file I/O. To perform random +file I/O under CP/M 1.4, you must maintain an FCB for each extent +of the file. This scheme is upward compatible with CP/M 2 for +files not exceeding 512K bytes, the largest file size supported +under CP/M 1.4. If you wish to implement random I/O for files +larger than 512K bytes under CP/M 2, you must use the random read +and random write functions, BDOS functions 33, 34, and 36. In +this case, only one FCB is used, and if CP/M 1.4 compatiblity is +required, the program must use the return version number +function, BDOS Function 12, to determine which method to employ. +.sp +.sh +CP/M prompt: \c +.qs +Characters that indicate that CP/M is ready to execute your next +command. The CP/M prompt consists of an upper-case letter, A-P, +followed by a > character; for example, A>. The letter +designates which drive is currently logged in as the default +drive. CP/M will search this drive for the command file +specified, unless the command is a built-in command or prefaced +by a select drive command: for example, B:STAT. +.sp +.sh +CP/NET: \c +.qs +Digital Research network operating system enabling microcomputers +to obtain access to common resources via a network. CP/NET +consists of MP/M masters and CP/M slaves with a network interface +between them. +.sp +.sh +CSV: \c +.qs +See \c +.sh +checksum vector. +.sp +.mb 5 +.fm 1 +.sh +cursor: \c +.qs +One-character symbol that can appear anywhere on the console +screen. The cursor indicates the position where the next +keystroke at the console will have an effect. +.sp +.sh +data file: \c +.qs +File containing information that will be processed by a program. +.sp +.mb 6 +.fm 2 +.sh +deblocking: \c +.qs +See \c +.sh +blocking & deblocking algorithm. +.sp +.sh +default: \c +.qs +Currently selected disk drive and user number. Any command that +does not specify a disk drive or a user number references the +default disk drive and user number. When CP/M is first invoked, +the default disk drive is drive A, and the default user number is +0. +.sp +.sh +default buffer: \c +.qs +Default 128-byte buffer maintained at 0080H in page zero. When +the CCP loads a COM file, this buffer is initialized to the +command tail; that is, any characters typed after the COM file +name are loaded into the buffer. The first byte at 0080H +contains the length of the command tail, while the command tail +itself begins at 0081H. The command tail is terminated by a byte +containing a binary zero value. The I command under DDT and SID +initializes this buffer in the same way as the CCP. +.sp +.sh +default FCB: \c +.qs +Two default FCBs are maintained by the CCP at 005CH and 006CH in +page zero. The first default FCB is initialized from the first +delimited field in the command tail. The second default FCB +is initialized from the next field in the command tail. +.sp +.sp 0 +.sh +delimiter: \c +.qs +Special characters that separate different items in a command +line; for example, a colon separates the drive specification from +the filename. The CCP recognizes the following characters as +delimiters: . : = ; < > _, blank, and carriage return. Several +CP/M commands also treat the following as delimiter characters: +, [ ] ( ) $. It is advisable to avoid the use of delimiter +characters and lower-case characters in CP/M filenames. +.sp +.sh +DIR: \c +.qs +Parameter in the diskdef macro library that specifies the number +of directory elements on the drive. +.sp +.sh +DIR attribute: \c +.qs +File attribute. A file with the DIR attribute can be displayed +by a DIR command. The file can be accessed from the default user +number and drive only. +.sp +.sh +DIRBUF: \c +.qs +128-byte scratchpad area for directory operations, +usually located at the end of the BIOS. DIRBUF is used by the +BDOS during its directory operations. DIRBUF also refers to the +two-byte address of this scratchpad buffer in the disk parameter +header at DPbase + 8 bytes. +.sp +.sh +directory: \c +.qs +Portion of a disk that contains entries for each file on the +disk. In response to the DIR command, CP/M displays the +filenames stored in the directory. The directory also contains +the locations of the blocks allocated to the files. Each file +directory element is in the form of a 32-byte FCB, although one +file can have several elements, depending on its size. The +maximum number of directory elements supported is specified by +the drive's disk parameter block value for DRM. +.bp +.sh +directory element: \c +.qs +Data structure. Each file on a disk has one or more 32-byte +directory elements associated with it. There are four directory +elements per directory sector. Directory elements can also be +referred to as directory FCBs. +.sp +.sh +directory entry: \c +.qs +File entry displayed by the DIR command. Sometimes this term +refers to a physical directory element. +.sp +.sp 0 +.sh +disk, diskette: \c +.qs +Magnetic media used for mass storage in a computer system. +Programs and data are recorded on the disk in the same way music +can be recorded on cassette tape. The CP/M operating system must +be initially loaded from disk when the computer is turned on. +Diskette refers to smaller capacity removable floppy diskettes, +while disk may refer to either a diskette, removable cartridge +disk, or fixed hard disk. Hard disk capacities range from five +to several hundred megabytes of storage. +.sp +.sh +diskdef macro library: \c +.qs +Library of code that when used with MAC, the Digital Research +macro assembler, creates disk definition tables such as the DPB +and DPH automatically. +.sp +.sh +disk drive: \c +.qs +Peripheral device that reads and writes information on disk. +CP/M assigns a letter to each drive under its +control. For example, CP/M may refer to the drives in a +four-drive system as A, B, C, and D. +.sp +.sh +disk parameter block (DPB): \c +.qs +Data structure referenced by one or more disk parameter headers. +The disk parameter block defines disk characteristics in the +fields listed below: +.sp +.in 5 +.nf +SPT is the total number of sectors per track. +BSH is the data allocation block shift factor. +BLM is the data allocation block mask. +EXM is the extent mask determined by BLS and DSM. +DSM is the maximum data block number. +DRM is the maximum number of directory entries--1. +AL0 reserves directory blocks. +AL1 reserves directory blocks. +CKS is the number of directory sectors check summed. +OFF is the number of reserved system tracks. +.fi +.in 0 +.sp +The address of the disk parameter block is located in the disk +parameter header at DPbase +0AH. CP/M Function 31 returns the +DPB address. Drives with the same characteristics can use the +same disk parameter header, and thus the same DPB. However, +drives with different characteristics must each have their own +disk parameter header and disk parameter blocks. When the BDOS +calls the SELDSK entry point in the BIOS, SELDSK must return the +address of the drive's disk parameter header in register HL. +.sp +.sh +disk parameter header (DPH): \c +.qs +Data structure that contains information about the disk drive and +provides a scratchpad area for certain BDOS operations. The disk +parameter header contains six bytes of scratchpad area for the +BDOS, and the following five 2-byte parameters: +.sp +.in 5 +.nf +XLT is the sector translation table address. +DIRBUF is the directory buffer address. +DPB is the disk parameter block address. +CSV is the checksum vector address. +ALV is the allocation vector address. +.fi +.in 0 +.sp +Given n disk drives, the disk parameter headers are arranged in a +table whose first row of 16 bytes corresponds to drive 0, with +the last row corresponding to drive n-1. +.sp +.sh +DKS: \c +.qs +Parameter in the diskdef macro library specifying the number of +data blocks on the drive. +.sp +.sh +DMA: \c +.qs +Direct Memory Access. DMA is a method of transferring data from +the disk into memory directly. In a CP/M system, the BDOS calls +the BIOS entry point READ to read a sector from the disk into the +currently selected DMA address. The DMA address must be the +address of a 128-byte buffer in memory, either the default buffer +at 0080H in page zero, or a user-assigned buffer in the TPA. +Similarly, the BDOS calls the BIOS entry point WRITE to write the +record at the current DMA address to the disk. +.sp +.sh +DN: \c +.qs +Parameter in the diskdef macro library specifying the logical +drive number. +.sp +.sh +DPB: \c +.qs +See \c +.sh +disk parameter block. +.sp +.sh +DPH: \c +.qs +See \c +.sh +disk parameter header. +.sp +.sh +DRM: \c +.qs +2-byte parameter in the disk parameter block at DPB + 7. DRM is +one less than the total number of directory entries allowed for +the drive. This value is related to DPB bytes AL0 and AL1, which +allocates up to 16 blocks for directory entries. +.sp +.sh +DSM: \c +.qs +2-byte parameter of the disk parameter block at DPB + 5. DSM is +the maximum data block number supported by the drive. The +product BLS times (DSM+1) is the total number of bytes held by +the drive. This must not exceed the capacity of the physical +disk less the reserved system tracks. +.sp +.sh +editor: \c +.qs +Utility program that creates and modifies text files. An editor +can be used for creation of documents or creation of code for +computer programs. The CP/M editor is invoked by typing the +command ED next to the system prompt on the console. +.sp +.sh +EX: \c +.qs +Extent number field in an FCB. See \c +.sh +extent. +.sp +.sh +executable: \c +.qs +Ready to be run by the computer. Executable code is a series of +instructions that can be carried out by the computer. For +example, the computer cannot execute names and addresses, but it +can execute a program that prints all those names and addresses +on mailing labels. +.sp +.sh +execute a program: \c +.qs +Start the processing of executable code. +.sp +.sh +EXM: \c +.qs +See \c +.sh +extent mask. +.sp +.sh +extent: \c +.qs +16K consecutive bytes in a file. Extents are numbered from 0 to +31. One extent can contain 1, 2, 4, 8, or 16 blocks. EX is the +extent number field of an FCB and is a one-byte field at FCB + +12, where FCB labels the first byte in the FCB. Depending on the +block size (BLS) and the maximum data block number (DSM), an FCB +can contain 1, 2, 4, 8, or 16 extents. The EX field is normally +set to 0 by the user but contains the current extent number +during file I/O. The term FCB folding describes FCBs containing +more than one extent. In CP/M version 1.4, each FCB contained +only one extent. Users attempting to perform random record I/O +and maintain CP/M 1.4 compatiblity should be aware of the +implications of this difference. See \c +.sh +CP/M 1.4 compatibility. +.sp +.sh +extent mask (EXM): \c +.qs +A byte parameter in the disk parameter block located at DPB + 3. +The value of EXM is determined by the block size (BLS) and +whether the maximum data block number (DSM) exceeds 255. There +are EXM + 1 extents per directory FCB. +.sp +.sh +FCB: \c +.qs +See \c +.sh +File Control Block. +.sp +.sh +file: \c +.qs +Collection of characters, instructions, or data that can be +referenced by a unique identifier. Files are usually stored on +various types of media, such as disk, or magnetic +tape. A CP/M file is identified by a file specification and +resides on disk as a collection of from zero to 65,536 records. +Each record is 128 bytes and can contain either binary or ASCII +data. Binary files contain bytes of data that can vary in value +from 0H to 0FFH. ASCII files contain sequences of character +codes delineated by a carriage return and line-feed combination; +normally byte values range from 0H to 7FH. The directory maps +the file as a series of physical blocks. Although files are +defined as a sequence of consecutive logical records, these +records can not reside in consecutive sectors on the disk. See +also \c +.sh +block, directory, extent, record, \c +.qs +and \c +.sh +sector. +.qs +.nx apph2.tex + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/apph2.tex b/Source/Doc/CPM 22 Manual - Testing/apph2.tex new file mode 100644 index 00000000..89387031 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/apph2.tex @@ -0,0 +1,912 @@ +.he CP/M Operating System Manual H Glossary +.sp +File Control Block (FCB): +Structure used for accessing files on disk. Contains the drive, +filename, filetype, and other information describing a file to be +accessed or created on the disk. A file control block consists +of 36 consecutive bytes specified by the user for file I/O +functions. FCB can also refer to a directory element in the +directory portion of the allocated disk space. These contain the +same first 32 bytes of the FCB, but lack the current record and +random record number bytes. +.sp +.sh +filename: \c +.qs +Name assigned to a file. A filename can include a primary +filename of one to eight characters; a filetype of zero to three characters. +A period separates the primary filename from the filetype. +.sp +.mb 5 +.fm 1 +.sh +file specification: \c +.qs +Unique file identifier. A complete CP/M file specification +includes a disk drive specification followed by a colon, d:, a +primary filename of one to eight characters, a period, and a filetype of +zero to three characters. For example, b:example.tex is a complete CP/M +file specification. +.sp +.sh +filetype: \c +.qs +Extension to a filename. A filetype can be from zero to three +characters and must be separated from the primary filename by a +period. A filetype can tell something about the file. Some +programs require that files to be processed have specific +filetypes. +.sp +.mb 6 +.fm 2 +.sp 0 +.sh +floppy disk: \c +.qs +Flexible magnetic disk used to store information. Floppy disks +come in 5 1/4- and 8-inch diameters. +.sp +.sh +FSC: \c +.qs +Parameter in the diskdef macro library specifying the first +physical sector number. This parameter is used to determine SPT +and build XLT. +.sp +.sh +hard disk: \c +.qs +Rigid, platter-like, magnetic disk sealed in a container. A hard +disk stores more information than a floppy disk. +.sp +.sh +hardware: \c +.qs +Physical components of a computer. +.sp +.sh +hexadecimal notation: \c +.qs +Notation for base 16 values using the decimal digits and letters +A, B, C, D, E, and F to represent the 16 digits. Hexadecimal +notation is often used to refer to binary numbers. A binary +number can be easily expressed as a hexadecimal value by taking +the bits in groups of 4, starting with the least significant bit, +and expressing each group as a hexadecimal digit, 0-F. Thus the +bit value 1011 becomes 0BH and 10110101 becomes 0B5H. +.sp +.sh +hex file: \c +.qs +ASCII-printable representation of a command, machine language, +file. +.sp +.sh +hex file format: \c +.qs +Absolute output of ASM and MAC for the Intel 8080 is a hex format +file, containing a sequence of absolute records that give a load +address and byte values to be stored, starting at the load +address. +.sp +.sh +HOME: \c +.qs +BIOS entry point which sets the disk head of the currently +selected drive to the track zero position. +.sp +.sh +host: \c +.qs +Physical characteristics of a hard disk drive in a system using +the blocking and deblocking algorithm. The term, host, helps +distinguish physical hardware characteristics from CP/M's logical +characteristics. For example, CP/M sectors are always 128 bytes, +although the host sector size can be a multiple of 128 bytes. +.sp +.sh +input: \c +.qs +Data going into the computer, usually from an operator typing at +the terminal or by a program reading from the disk. +.sp +.sh +input/output: \c +.qs +See \c +.sh +I/O. +.sp +.sh +interface: \c +.qs +Object that allows two independent systems to communicate with +each other, as an interface between hardware and software in a +microcomputer. +.sp +.sh +I/O: \c +.qs +Abbreviation for input/output. Usually refers to input/output +operations or routines handling the input and output of data in +the computer system. +.sp +.sh +IOBYTE: \c +.qs +A one-byte field in page zero, currently at location 0003H, that +can support a logical-to-physical device mapping for I/O. +However, its implementation in your BIOS is purely optional and +might or might not be supported in a given CP/M system. The IOBYTE +is easily set using the command: +.sp +.ti 8 +.nf +STAT = +.fi +.sp +The CP/M logical devices are CON:, RDR:, PUN:, and LST:; each of +these can be assigned to one of four physical devices. The IOBYTE +can be initialized by the BOOT entry point of the BIOS and +interpreted by the BIOS I/O entry points CONST, CONIN, CONOUT, +LIST, PUNCH, and READER. Depending on the setting of the IOBYTE, +different I/O drivers can be selected by the BIOS. For example, +setting LST:=TTY: might cause LIST output to be directed to a +serial port, while setting LST:=LPT: causes LIST output to be +directed to a parallel port. +.sp +.sh +K: \c +.qs +Abbreviation for kilobyte. See \c +.sh +kilobyte. +.sp +.sh +keyword: \c +.qs +See \c +.sh +command keyword. +.sp +.sh +kilobyte (K): \c +.qs +1024 bytes or 0400H bytes of memory. This is a standard unit of +memory. For example, the Intel 8080 supports up to 64K of memory +address space or 65,536 bytes. 1024 kilobytes equal one megabyte, +or over one million bytes. +.sp +.sh +linker: \c +.qs +Utility program used to combine relocatable object modules into +an absolute file ready for execution. For example, LINK-80 \ \ +creates either a COM or PRL file from relocatable REL files, such +as those produced by PL/I-80 \ \ . +.sp +.sh +LIST: \c +.qs +A BIOS entry point to a routine that sends a character to the +list device, usually a printer. +.sp +.sh +list device: \c +.qs +Device such as a printer onto which data can be listed or +printed. +.sp +.sh +LISTST: \c +.qs +BIOS entry point to a routine that returns the ready status of +the list device. +.sp +.sh +loader: \c +.qs +Utility program that brings an absolute program image into memory +ready for execution under the operating system, or a utility used +to make such an image. For example, LOAD prepares an absolute +COM file from the assembler hex file output that is ready to be +executed under CP/M. +.sp +.sh +logged in: \c +.qs +Made known to the operating system, in reference to drives. A +drive is logged in when it is selected by the user or an +executing process. It remains selected or logged in until you +change disks in a floppy disk drive or enter CTRL-C at the +command level, or until a BDOS Function 0 is executed. +.sp +.sh +logical: \c +.qs +Representation of something that might or might not be the same +in its actual physical form. For example, a hard disk can occupy +one physical drive, yet you can divide the available storage on +it to appear to the user as if it were in several different +drives. These apparent drives are the logical drives. +.sp +.sh +logical sector: \c +.qs +See \c +.sh +sector. +.sp +.sh +logical-to-physical sector translation table: \c +.qs +See \c +.sh +XLT. +.sp +.sh +LSC: \c +.qs +Diskdef macro library parameter specifying the last physical +sector number. +.sp +.sh +LST: \c +.qs +Logical CP/M list device, usually a printer. The CP/M list +device is an output-only device referenced through the LIST and +LISTST entry points of the BIOS. The STAT command allows +assignment of LST: to one of the physical devices: TTY:, CRT:, +LPT:, or UL1:, provided these devices and the IOBYTE are +implemented in the LIST and LISTST entry points of your CP/M BIOS +module. The CP/NET command NETWORK allows assignment of LST: to +a list device on a network master. For example, PIP LST:=TEST.SUB +prints the file TEST.SUB on the list device. +.sp +.sh +macro assembler: \c +.qs +Assembler code translator providing macro processing facilities. +Macro definitions allow groups of instructions to be stored and +substituted in the source program as the macro names are +encountered. Definitions and invocations can be nested and macro +parameters can be formed to pass arbitrary strings of text to a +specific macro for substitution during expansion. +.sp +.sh +megabyte: \c +.qs +Over one million bytes; 1024 kilobytes. See \c +.sh +byte, \c +.qs +and \c +.sh +kilobyte. +.sp +.sh +microprocessor: \c +.qs +Silicon chip that is the central processing unit (CPU) of the +microcomputer. The Intel 8080 and the Zilog Z80 are +microprocessors commonly used in CP/M systems. +.sp +.sh +MOVCPM image: \c +.qs +Memory image of the CP/M system created by MOVCPM. This image +can be saved as a disk file using the SAVE command or placed on +the system tracks using the SYSGEN command without specifying a +source drive. This image varies, depending on the presence of a +one-sector or two-sector boot. If the boot is less than 128 +bytes (one sector), the boot begins at 0900H, the CP/M system at +0980H, and the BIOS at 1F80H. Otherwise, the boot is at 0900H, +the CP/M system at 1000H, and the BIOS at 2000H. In a CP/M 1.4 +system with a one-sector boot, the addresses are the same as for +the CP/M 2 system--except that the BIOS begins at 1E80H instead +of 1F80H. +.mb 4 +.fm 1 +.sp +.sh +MP/M: \c +.qs +Multi-Programming Monitor control program. A microcomputer +operating system supporting multi-terminal access with multi- +programming at each terminal. +.sp +.sh +multi-programming: \c +.qs +The capability of initiating and executing more than one program +at a time. These programs, usually called processes, are time-shared, +each receiving a slice of CPU time on a round-robin +basis. See \c +.sh +concurrency. +.sp +.sh +nibble: \c +.qs +One half of a byte, usually the high-order or low-order 4 bits in +a byte. +.sp +.sh +OFF: \c +.qs +Two-byte parameter in the disk parameter block at DPB + 13 bytes. +This value specifies the number of reserved system tracks. The +disk directory begins in the first sector of track OFF. +.sp +.sh +OFS: \c +.qs +Diskdef macro library parameter specifying the number of reserved +system tracks. See \c +.sh +OFF. +.sp +.sh +operating system: \c +.qs +Collection of programs that supervises the execution of other +programs and the management of computer resources. An operating +system provides an orderly input/output environment between the +computer and its peripheral devices. It enables user-written +programs to execute safely. An operating system standardizes the +use of computer resources for the programs running under it. +.mb 6 +.fm 2 +.sp +.sh +option: \c +.qs +One of many parameters that can be part of a command tail. Use +options to specify additional conditions for a command's +execution. +.sp +.sh +output: \c +.qs +Data that is sent to the console, disk, or printer. +.sp +.sh +page: \c +.qs +256 consecutive bytes in memory beginning on a page boundary, +whose base address is a multiple of 256 (100H) bytes. In hex +notation, pages always begin at an address with a least +significant byte of zero. +.sp +.sh +page relocatable program: \c +.qs +See \c +.sh +PRL. +.sp +.sh +page zero: \c +.qs +Memory region between 0000H and 0100H used to hold critical +system parameters. Page zero functions primarily as an interface +region between user programs and the CP/M BDOS module. Note that +in non-standard systems this region is the base page of the +system and represents the first 256 bytes of memory used by the +CP/M system and user programs running under it. +.sp +.sh +parameter: \c +.qs +Value in the command tail that provides additional information +for the command. Technically, a parameter is a required element +of a command. +.sp +.sh +peripheral devices: \c +.qs +Devices external to the CPU. For example, terminals, printers, +and disk drives are common peripheral devices that are not part +of the processor but are used in conjunction with it. +.sp +.sh +physical: \c +.qs +Characteristic of computer components, generally hardware, that +actually exist. In programs, physical components can be +represented by logical components. +.sp +.sh +primary filename: \c +.qs +First 8 characters of a filename. The primary filename is a +unique name that helps the user identify the file contents. A +primary filename contains one to eight characters and can include any +letter or number and some special characters. The primary +filename follows the optional drive specification and precedes +the optional filetype. +.sp +.sh +PRL: \c +.qs +Page relocatable program. A page relocatable program is stored +on disk with a PRL filetype. Page relocatable programs are +easily relocated to any page boundary and thus are suitable for +execution in a nonbanked MP/M system. +.sp +.sh +program: \c +.qs +Series of coded instructions that performs specific tasks when +executed by a computer. A program can be written in a +processor-specific language or a high-level language that can be +implemented on a number of different processors. +.sp +.sh +prompt: \c +.qs +Any characters displayed on the video screen to help the user +decide what the next appropriate action is. A system prompt is a +special prompt displayed by the operating +system. The alphabetic character indicates the default drive. Some +applications programs have their own special prompts. See \c +.sh +CP/M prompt. +.qs +.sp +.mb 5 +.fm 1 +PUN: +Logical CP/M punch device. The punch device is an output-only +device accessed through the PUNCH entry point of the BIOS. In +certain implementations, PUN: can be a serial device such as a +modem. +.sp +PUNCH: +BIOS entry point to a routine that sends a character to the punch +device. +.sp +RDR: +Logical CP/M reader device. The reader device is an input-only +device accessed through the READER entry point in the BIOS. +See +PUN:. +.sp +READ: +Entry point in the BIOS to a routine that reads 128 bytes from +the currently selected drive, track, and sector into the current +DMA address. +.sp +READER: +Entry point to a routine in the BIOS that reads the next +character from the currently assigned reader device. +.sp +Read-Only (R/O): +Attribute that can be assigned to a disk file or a disk drive. +When assigned to a file, the Read-Only attribute allows you to +read from that file but not write to it. When assigned to a +drive, the Read-Only attribute allows you to read any file on the +disk, but prevents you from adding a new file, erasing or changing +a file, renaming a file, or writing on the disk. The STAT +command can set a file or a drive to Read-Only. Every file and +drive is either Read-Only or Read-Write. The default setting for +drives and files is Read-Write, but an error in resetting the +disk or changing media automatically sets the drive to Read-Only +until the error is corrected. See also \c +.sh +ROM. +.sp +.sh +Read-Write (R/W): \c +.qs +Attribute that can be assigned to a disk file or a disk drive. +The Read-Write attribute allows you to read from and write to a +specific Read-Write file or to any file on a disk that is in a +drive set to Read-Write. A file or drive can be set to either +Read-Only or Read-Write. +.sp +.sh +record: \c +.qs +Group of bytes in a file. A physical record consists of 128 +bytes and is the basic unit of data transfer between the +operating system and the application program. A logical record +might vary in length and is used to represent a unit of +information. Two 64-byte employee records can be stored in one +128-byte physical record. Records are grouped together to form a +file. +.sp +.sh +recursive procedure: \c +.qs +Code that can call itself during execution. +.sp +.mb 6 +.fm 2 +.sh +reentrant procedure: \c +.qs +Code that can be called by one process while another is already +executing it. Thus, reentrant code can be shared between +different users. Reentrant procedures must not be self- +modifying; that is, they must be pure code and not contain data. +The data for reentrant procedures can be kept in a separate data +area or placed on the stack. +.sp +.sh +restart (RST): \c +.qs +One-byte call instruction usually used during interrupt sequences +and for debugger break pointing. There are eight restart +locations, RST 0 through RST 7, whose addresses are given by the +product of 8 times the restart number. +.sp +.sh +R/O: \c +.qs +See \c +.sh +Read-Only. +.sp +.sh +ROM: \c +.qs +Read-Only memory. This memory can be read but not written and so +is suitable for code and preinitialized data areas only. +.sp +.sh +RST: \c +.qs +See \c +.sh +restart. +.sp +.sh +R/W: \c +.qs +See \c +.sh +Read-Write. +.sp +.sh +sector: \c +.qs +In a CP/M system, a sector is always 128 consecutive bytes. A +sector is the basic unit of data read and written on the disk by +the BIOS. A sector can be one 128-byte record in a file or a +sector of the directory. The BDOS always requests a logical +sector number between 0 and (SPT-1). This is typically +translated into a physical sector by the BIOS entry point +SECTRAN. In some disk subsystems, the disk sector size is larger +than 128 bytes, usually a power of two, such as 256, 512, 1024, or +2048 bytes. These disk sectors are always referred to as host +sectors in CP/M documentation and should not be confused with +other references to sectors, in which cases the CP/M 128-byte +sectors should be assumed. When the host sector size is larger +than 128 bytes, host sectors must be buffered in memory and the +128-byte CP/M sectors must be blocked and deblocked from them. +This can be done by adding an additional module, the blocking and +deblocking algorithm, between the BIOS disk I/O routines and the +actual disk I/O. +.sp +.sh +sectors per track (SPT): \c +.qs +A two-byte parameter in the disk parameter block at DPB + 0. The +BDOS makes calls to the BIOS entry point SECTRAN with logical +sector numbers ranging between 0 and (SPT - 1) in register BC. +.sp +.sh +SECTRAN: \c +.qs +Entry point to a routine in the BIOS that performs +logical-to-physical sector translation for the BDOS. +.sp +.sh +SELDSK: \c +.qs +Entry point to a routine in the BIOS that sets the currently +selected drive. +.sp +.sh +SETDMA: \c +.qs +Entry point to a routine in the BIOS that sets the currently +selected DMA address. The DMA address is the address of a +128-byte buffer region in memory that is used to transfer data to +and from the disk in subsequent reads and writes. +.sp +.sh +SETSEC: \c +.qs +Entry point to a routine in the BIOS that sets the currently +selected sector. +.sp +.sh +SETTRK: \c +.qs +Entry point to a routine in the BIOS that sets the currently +selected track. +.sp +.sh +skew factor: \c +.qs +Factor that defines the logical-to-physical sector number +translation in XLT. Logical sector numbers are used by the BDOS +and range between 0 and (SPT - 1). Data is written in +consecutive logical 128-byte sectors grouped in data blocks. The +number of sectors per block is given by BLS/128. Physical +sectors on the disk media are also numbered consecutively. If +the physical sector size is also 128 bytes, a one-to-one +relationship exists between logical and physical sectors. The +logical-to-physical translation table (XLT) maps this +relationship, and a skew factor is typically used in generating +the table entries. For instance, if the skew factor is 6, XLT +will be: +.sp +.nf +.in 8 +Logical: 0 1 2 3 4 5 6 ... 25 +Physical: 1 7 13 19 25 5 11 ... 22 +.fi +.in 0 +.sp +The skew factor allows time for program processing without +missing the next sector. Otherwise, the system must wait for an +entire disk revolution before reading the next logical sector. +The skew factor can be varied, depending on hardware speed and +application processing overhead. Note that no sector translation +is done when the physical sectors are larger than 128 bytes, as +sector deblocking is done in this case. See also \c +.sh +sector, SKF, \c +.qs +and \c +.sh +XLT. +.sp +.sh +SKF: \c +.qs +A diskdef macro library parameter specifying the skew factor to +be used in building XLT. If SKF is zero, no translation table is +generated and the XLT byte in the DPH will be 0000H. +.sp +.sh +software: \c +.qs +Programs that contain machine-readable instructions, as opposed +to hardware, which is the actual physical components of a +computer. +.sp +.sh +source file: \c +.qs +ASCII text file usually created with an editor that is an input +file to a system program, such as a language translator or text +formatter. +.sp +.sh +SP: \c +.qs +Stack pointer. See \c +.sh +stack. +.bp +.sh +spooling: \c +.qs +Process of accumulating printer output in a file while the +printer is busy. The file is printed when the printer becomes +free; a program does not have to wait for the slow printing +process. +.sp +.sh +SPT: \c +.qs +See \c +.sh +sectors per track. +.sp +.sh +stack: \c +.qs +Reserved area of memory where the processor saves the return +address when a call instruction is received. When a return +instruction is encountered, the processor restores the current +address on the stack to the program counter. Data such as the +contents of the registers can also be saved on the stack. The +push instruction places data on the stack and the pop instruction +removes it. An item is pushed onto the stack by decrementing the +stack pointer (SP) by 2 and writing the item at the SP address. +In other words, the stack grows downward in memory. +.sp +.sh +syntax: \c +.qs +Format for entering a given command. +.sp +.sh +SYS: \c +.qs +See \c +.sh +system attribute. +.sp +.sh +SYSGEN image: \c +.qs +Memory image of the CP/M system created by SYSGEN when a +destination drive is not specified. This is the same as the +MOVCPM image that can be read by SYSGEN if a source drive is +not specified. See \c +.sh +MOVCPM image. +.sp +.sh +system attribute (SYS): \c +.qs +File attribute. You can give a file the system attribute by +using the SYS option in the STAT command or by using the set file +attributes function, BDOS Function 12. A file with the SYS +attribute is not displayed in response to a DIR command. If you +give a file with user number 0 the SYS attribute, you can read +and execute that file from any user number on the same drive. +Use this feature to make your commonly used programs available +under any user number. +.sp +system prompt: +Symbol displayed by the operating system indicating that the +system is ready to receive input. +See prompt and CP/M prompt. +.sp +.sh +system tracks: \c +.qs +Tracks reserved on the disk for the CP/M system. The number of +system tracks is specified by the parameter OFF in the disk +parameter block (DPB). The system tracks for a drive always +precede its data tracks. The command SYSGEN copies the CP/M +system from the system tracks to memory, and vice versa. The +standard SYSGEN utility copies 26 sectors from track 0 and 26 +sectors from track 1. When the system tracks contain additional +sectors or tracks to be copied, a customized SYSGEN must be used. +.sp +.sh +terminal: \c +.qs +See \c +.sh +console. +.sp +.sh +TPA: \c +.qs +Transient Program Area. Area in memory where user programs run +and store data. This area is a region of memory beginning at +0100H and extending to the base of the CP/M system in high +memory. The first module of the CP/M system is the CCP, which +can be overwritten by a user program. If so, the TPA is extended +to the base of the CP/M BDOS module. If the CCP is overwritten, +the user program must terminate with either a system reset +(Function 0) call or a jump to location zero in page zero. The +address of the base of the CP/M BDOS is stored in location 0006H +in page zero least significant byte first. +.sp +.sh +track: \c +.qs +Data on the disk media is accessed by combination of track and +sector numbers. Tracks form concentric rings on the disk; the +standard IBM single-density disks have 77 tracks. Each track +consists of a fixed number of numbered sectors. Tracks are +numbered from zero to one less than the number of tracks on the +disk. +.sp +.sh +Transient Program Area: \c +.qs +See \c +.sh +TPA. +.sp +.sh +upward compatible: \c +.qs +Term meaning that a program created for the previously released +operating system, or compiler, runs under the newly released +version of the same operating system. +.sp +.sh +USER: \c +.qs +Term used in CP/M and MP/M systems to distinguish distinct +regions of the directory. +.sp +.sh +user number: \c +.qs +Number assigned to files in the disk directory so that different +users need only deal with their own files and have their own +directories, even though they are all working from the same disk. +In CP/M, files can be divided into 16 user groups. +.sp +.sh +utility: \c +.qs +Tool. Program that enables the user to perform certain +operations, such as copying files, erasing files, and editing +files. The utilities are created for the convenience of +programmers and users. +.sp +.sh +vector: \c +.qs +Location in memory. An entry point into the operating system +used for making system calls or interrupt handling. +.sp +.sh +warm start: \c +.qs +Program termination by a jump to the warm start vector at +location 0000H, a system reset (BDOS Function 0), or a CTRL-C +typed at the keyboard. A warm start reinitializes the disk +subsystem and returns control to the CP/M operating system at the +CCP level. The warm start vector is simply a jump to the WBOOT +entry point in the BIOS. +.sp +.sh +WBOOT: \c +.qs +Entry point to a routine in the BIOS used when a warm start +occurs. A warm start is performed when a user program branches +to location 0000H, when the CPU is reset from the front panel, or +when the user types CTRL-C. The CCP and BDOS are reloaded from +the system tracks of drive A. +.sp +.sh +wildcard characters: \c +.qs +Special characters that match certain specified items. In CP/M +there are two wildcard characters: ? and *. The ? can be +substituted for any single character in a filename, and the * can +be substituted for the primary filename, the filetype, or both. +By placing wildcard characters in filenames, the user creates an +ambiguous filename and can quickly reference one or more files. +.bp +.sh +word: \c +.qs +16-bit or two-byte value, such as an address value. Although the +Intel 8080 is an 8-bit CPU, addresses occupy two bytes and are +called word values. +.sp +.sh +WRITE: \c +.qs +Entry point to a routine in the BIOS that writes the record at +the currently selected DMA address to the currently selected +drive, track, and sector. +.sp +.sh +XLT: \c +.qs +Logical-to-physical sector translation table located in the BIOS. +SECTRAN uses XLT to perform logical-to-physical sector number +translation. XLT also refers to the two-byte address in the disk +parameter header at DPBASE + 0. If this parameter is zero, no +sector translation takes place. Otherwise this parameter is the +address of the translation table. +.sp +.sh +ZERO PAGE: \c +.qs +See \c +.sh +page zero. +.qs +.sp 2 +.ce +End of Appendix H +.nx appi + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/appi.tex b/Source/Doc/CPM 22 Manual - Testing/appi.tex new file mode 100644 index 00000000..705ec65f --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/appi.tex @@ -0,0 +1,939 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft I-% +.pc 1 +.tc I CP/M Error Messages +.ce 2 +.sh +Appendix I +.sp +.sh +CP/M Error Messages +.qs +.he CP/M Operating System Manual I CP/M Error Messages +.sp 2 +.pp +Messages come from several different sources. CP/M displays +error messages when there are errors in calls to the Basic Disk +Operating System (BDOS). CP/M also displays messages when there +are errors in command lines. Each utility supplied with CP/M has +its own set of messages. The following lists CP/M messages and +utility messages. One might see messages other than those listed +here if one is running an application program. Check the +application program's documentation for explanations of those +messages. +.sp 2 +.sh + Table I-1. CP/M Error Messages +.sp +.ll 60 +.nf + Message Meaning +.sp +.fi +.in 20 +.ti -15 +? +.sp +DDT. This message has four possible meanings: +.sp +.in 23 +.ti -2 +o DDT does not understand the assembly language instruction. +.ti -2 +o The file cannot be opened. +.ti -2 +o A checksum error occurred in a HEX file. +.ti -2 +o The assembler/disassembler was overlayed. +.sp 2 +.in 20 +.ti -15 +ABORTED +.sp +PIP. You stopped a PIP operation by pressing a key. +.sp 2 +.ti -15 +ASM Error Messages +.sp +.in 24 +.ti -4 +D Data error: data statement element cannot be placed in +specified data area. +.sp +.ti -4 +E Expression error: expression cannot be evaluated during +assembly. +.sp +.ti -4 +L Label error: label cannot appear in this context (might be +duplicate label). +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.sp + ASM Error Messages (continued) +.fi +.sp +.in 24 +.ti -4 +N Not implemented: unimplemented features, such as macros, are +trapped. +.sp +.ti -4 +O Overflow: expression is too complex to evaluate. +.sp +.ti -4 +P Phase error: label value changes on two passes through +assembly. +.sp +.ti -4 +R Register error: the value specified as a register is +incompatible with the code. +.sp +.ti -4 +S Syntax error: improperly formed expression. +.sp +.ti -4 +U Undefined label: label used does not exist. +.sp +.ti -4 +V Value error: improperly formed operand encountered in an +expression. +.sp 2 +.in 20 +.ti -15 +BAD DELIMITER +.sp +STAT. Check command line for typing errors. +.sp 2 +.ti -15 +Bad Load +.sp +CCP error message, or SAVE error message. +.sp 2 +.ti -15 +Bdos Err On d: +.sp +Basic Disk Operating System error on the designated drive: CP/M +replaces d: with the drive specification of the drive where the +error occurred. This message is followed by one of the four +phrases in the situations described below. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +Bdos Err On d: Bad Sector +.sp +This message appears when CP/M finds no disk in the drive, when +the disk is improperly formatted, when the drive latch is open, +or when power to the drive is off. Check for one of these +situations and try again. This could also indicate a hardware +problem or a worn or improperly formatted disk. Press ^C to +terminate the program and return to CP/M, or press RETURN +to ignore the error. +.sp 2 +.ti -15 +Bdos Err On d: File R/O +.sp +You tried to erase, rename, or set file attributes on a Read-Only +file. The file should first be set to Read-Write (R/W) with the +command: STAT filespec $R/W. +.sp 2 +.ti -15 +Bdos Err On d: R/O +.sp +Drive has been assigned Read-Only status with a STAT command, or +the disk in the drive has been changed without being initialized +with a ^C. CP/M terminates the current program as soon as you +press any key. +.sp 2 +.ti -15 +Bdos Err on d: Select +.sp +CP/M received a command line specifying a nonexistent drive. +CP/M terminates the current program as soon as you press any key. +Press RETURN or CTRL-C to recover. +.sp 2 +.ti -15 +Break "x" at c +.sp +ED. "x" is one of the symbols described below and c is the +command letter being executed when the error occurred. +.sp +.in 24 +.ti -4 +# Search failure. ED cannot find the string specified in an F, +S, or N command. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 24 +.ti -4 +? Unrecognized command letter c. ED does not recognize the +indicated command letter, or an E, H, Q, or O command is not +alone on its command line. +.sp +.ti -4 +O The file specified in an R command cannot be found. +.sp +.ti -4 +> Buffer full. ED cannot put any more characters in the memory +buffer, or the string specified in an F, N, or S command is too +long. +.sp +.ti -4 +E Command aborted. A keystroke at the console aborted command +execution. +.sp +Break "x" at c (continued) +.sp +.ti -4 +F Disk or directory full. This error is followed by either the +disk or directory full message. Refer to the recovery procedures +listed under these messages. +.sp 2 +.in 20 +.ti -15 +CANNOT CLOSE DESTINATION FILE--\\{filespec\\} +.sp +PIP. An output file cannot be closed. You should take +appropriate action after checking to see if the correct disk is +in the drive and that the disk is not write-protected. +.sp 2 +.nf +.in 5 +Cannot close, R/O +CANNOT CLOSE FILES +.fi +.in 20 +.sp +CP/M cannot write to the file. This usually occurs because the +disk is write-protected. +.sp +ASM. An output file cannot be closed. This is a fatal error +that terminates ASM execution. Check to see that the disk is in +the drive, and that the disk is not write-protected. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +DDT. The disk file written by a W command cannot be closed. +This is a fatal error that terminates DDT execution. Check if +the correct disk is in the drive and that the disk is not write-protected. +.sp +SUBMIT. This error can occur during SUBMIT file processing. +Check if the correct system disk is in the A drive and that the +disk is not write-protected. The SUBMIT job can be restarted +after rebooting CP/M. +.sp 2 +.ti -15 +CANNOT READ +.sp +PIP. PIP cannot read the specified source. Reader cannot be +implemented. +.sp 2 +.ti -15 +CANNOT WRITE +.sp +PIP. The destination specified in the PIP command is illegal. +You probably specified an input device as a destination. +.sp 2 +.ti -15 +Checksum error +.sp +PIP. A HEX record checksum error was encountered. The HEX +record that produced the error must be corrected, probably by +recreating the HEX file. +.sp 2 +.nf +.in 5 +CHECKSUM ERROR +LOAD ADDRESS hhhh +ERROR ADDRESS hhhh +BYTES READ: +hhhh: +.fi +.in 20 +.sp +LOAD. File contains incorrect data. Regenerate HEX file from +the source. +.sp 2 +.ti -15 +Command Buffer Overflow +.sp +SUBMIT. The SUBMIT buffer allows up to 2048 characters in the +input file. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +Command too long +.sp +SUBMIT. A command in the SUBMIT file cannot exceed 125 +characters. +.sp 2 +.ti -15 +CORRECT ERROR, TYPE RETURN OR CTRL-Z +.sp +PIP. A HEX record checksum was encountered during the transfer +of a HEX file. The HEX file with the checksum error should be +corrected, probably by recreating the HEX file. +.sp 2 +.ti -15 +DESTINATION IS R/O, DELETE (Y/N)? +.sp +PIP. The destination file specified in a PIP command already +exists and it is Read-Only. If you type Y, the destination file +is deleted before the file copy is done. +.sp 2 +.ti -15 +Directory full +.sp +ED. There is not enough directory space for the file being +written to the destination disk. You can use the OXfilespec +command to erase any unnecessary files on the disk without +leaving the editor. +.sp +SUBMIT. There is not enough directory space to write the $$$.SUB +file used for processing SUBMITs. Erase some files or select a +new disk and retry. +.sp 2 +.ti -15 +Disk full +.sp +ED. There is not enough disk space for the output file. This +error can occur on the W, E, H, or X commands. If it occurs with +X command, you can repeat the command prefixing the filename with +a different drive. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +DISK READ ERROR--\\{filespec\\} +.sp +PIP. The input disk file specified in a PIP command cannot be +read properly. This is usually the result of an unexpected end-of-file. +Correct the problem in your file. +.sp 2 +.ti -15 +DISK WRITE ERROR--\\{filespec\\} +.sp +DDT. A disk write operation cannot be successfully performed +during a W command, probably due to a full disk. You should +either erase some unnecessary files or get another disk with more +space. +.sp +PIP. A disk write operation cannot be successfully performed +during a PIP command, probably due to a full disk. You should +either erase some unnecessary files or get another disk with more +space and execute PIP again. +.sp +SUBMIT. The SUBMIT program cannot write the $$$.SUB file to the +disk. Erase some files, or select a new disk and try again. +.sp 2 +.ti -15 +ERROR: BAD PARAMETER +.sp +PIP. You entered an illegal parameter in a PIP command. Retype +the entry correctly. +.sp 2 +.ti -15 +ERROR: CANNOT OPEN SOURCE, LOAD ADDRESS hhhh +.sp +LOAD. Displayed if LOAD cannot find the specified file or if no +filename is specified. +.sp 2 +.ti -15 +ERROR: CANNOT CLOSE FILE, LOAD ADDRESS hhhh +.sp +LOAD. Caused by an error code returned by a BDOS function call. +Disk might be write-protected. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +ERROR: CANNOT OPEN SOURCE, LOAD ADDRESS hhhh +.sp +LOAD. Cannot find source file. Check disk directory. +.sp 2 +.ti -15 +ERROR: DISK READ, LOAD ADDRESS hhhh +.sp +LOAD. Caused by an error code returned by a BDOS function call. +.sp 2 +.ti -15 +ERROR: DISK WRITE, LOAD ADDRESS hhhh +.sp +LOAD. Destination disk is full. +.sp 2 +.ti -15 +ERROR: INVERTED LOAD ADDRESS, LOAD ADDRESS hhhh +.sp +LOAD. The address of a record was too far from the address of +the previously-processed record. This is an internal limitation +of LOAD, but it can be circumvented. Use DDT to read the HEX +file into memory, then use a SAVE command to store the memory +image file on disk. +.sp 2 +.ti -15 +ERROR: NO MORE DIRECTORY SPACE, LOAD ADDRESS hhhh +.sp +LOAD. Disk directory is full. +.sp 2 +.ti -15 +Error on line nnn message +.sp +SUBMIT. The SUBMIT program displays its messages in the format +shown above, where nnn represents the line number of the SUBMIT +file. Refer to the message following the line number. +.sp 2 +.ti -15 +FILE ERROR +.sp +ED. Disk or directory is full, and ED cannot write anything more +on the disk. This is a fatal error, so make sure there is enough +space on the disk to hold a second copy of the file before +invoking ED. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +FILE EXISTS +.sp +You have asked CP/M to create or rename a file using a file +specification that is already assigned to another file. Either +delete the existing file or use another file specification. +.sp +REN. The new name specified is the name of a file that already +exists. You cannot rename a file with the name of an existing +file. If you want to replace an existing file with a newer +version of the same file, either rename or erase the existing +file, or use the PIP utility. +.sp 2 +.ti -15 +File exists, erase it +.sp +ED. The destination filename already exists when you are placing +the destination file on a different disk than the source. It +should be erased or another disk selected to receive the output +file. +.sp 2 +.ti -15 +** FILE IS READ/ONLY ** +.sp +ED. The file specified in the command to invoke ED has the +Read-Only attribute. Ed can read the file so that the user can +examine it, but ED cannot change a Read-Only file. +.sp 2 +.mb 4 +.fm 1 +.ti -15 +File Not Found +.sp +CP/M cannot find the specified file. Check that you have entered +the correct drive specification or that you have the correct disk +in the drive. +.sp +ED. ED cannot find the specified file. Check that you have +entered the correct drive specification or that you have the +correct disk in the drive. +.sp +STAT. STAT cannot find the specified file. The message might +appear if you omit the drive specification. Check to see if the +correct disk is in the drive. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +FILE NOT FOUND--\\{filespec\\} +.sp +.mb 6 +.fm 2 +PIP. An input file that you have specified does not exist. +.sp 2 +.ti -15 +Filename required +.sp +ED. You typed the ED command without a filename. Reenter the ED +command followed by the name of the file you want to edit or +create. +.sp 2 +.ti -15 +hhhh??=dd +.sp +DDT. The ?? indicates DDT does not know how to represent the +hexadecimal value dd encountered at address hhhh in 8080 assembly +language. dd is not an 8080 machine instruction opcode. +.sp 2 +.ti -15 +Insufficient memory +.sp +DDT. There is not enough memory to load the file specified in an +R or E command. +.sp 2 +.ti -15 +Invalid Assignment +.sp +STAT. You specified an invalid drive or file assignment, or +misspelled a device name. This error message might be followed +by a list of the valid file assignments that can follow a +filename. If an invalid drive assignment was attempted the +message Use: d:=RO is displayed, showing the proper syntax for +drive assignments. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +Invalid control character +.sp +SUBMIT. The only valid control characters in the SUBMIT files of +the type SUB are ^ A through ^ Z. Note that in a SUBMIT file the +control character is represented by typing the circumflex, ^, not +by pressing the control key. +.sp 2 +.ti -15 +INVALID DIGIT--\\{filespec\\} +.sp +PIP. An invalid HEX digit has been encountered while reading a +HEX file. The HEX file with the invalid HEX digit should be +corrected, probably by recreating the HEX file. +.sp 2 +.ti -15 +Invalid Disk Assignment +.sp +STAT. Might appear if you follow the drive specification with +anything except =R/O. +.sp 2 +.ti -15 +INVALID DISK SELECT +.sp +CP/M received a command line specifying a nonexistent drive, or +the disk in the drive is improperly formatted. CP/M terminates +the current program as soon as you press any key. +.sp 2 +.ti -15 +INVALID DRIVE NAME (Use A, B, C, or D) +.sp +SYSGEN. SYSGEN recognizes only drives A, B, C, and D as valid +destinations for system generation. +.sp 2 +.ti -15 +Invalid File Indicator +.sp +STAT. Appears if you do not specify RO, RW, DIR, or SYS. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +INVALID FORMAT +.sp +PIP. The format of your PIP command is illegal. See the +description of the PIP command. +.sp 2 +.nf +.in 5 +INVALID HEX DIGIT +LOAD ADDRESS hhhh +ERROR ADDRESS hhhh +BYTES READ: +hhhh +.fi +.in 20 +.sp +LOAD. File contains incorrect HEX digit. +.sp 2 +.ti -15 +INVALID MEMORY SIZE +.sp +MOVCPM. Specify a value less than 64K or your computer's actual +memory size. +.sp 2 +.ti -15 +INVALID SEPARATOR +.sp +PIP. You have placed an invalid character for a separator +between two input filenames. +.sp 2 +.ti -15 +INVALID USER NUMBER +.sp +PIP. You have specified a user number greater than 15. User +numbers are in the range 0 to 15. +.sp 2 +.ti -15 +n? +.sp +USER. You specified a number greater than fifteen for a user +area number. For example, if you type USER 18, the screen +displays 18?. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +NO DIRECTORY SPACE +.sp +ASM. The disk directory is full. Erase some files to make room +for PRN and HEX files. The directory can usually hold only 64 +filenames. +.sp 2 +.ti -15 +NO DIRECTORY SPACE--\\{filespec\\} +.sp +PIP. There is not enough directory space for the output file. +You should either erase some unnecessary files or get another +disk with more directory space and execute PIP again. +.sp 2 +.ti -15 +NO FILE--\\{filespec\\} +.sp +DIR, ERA, REN, PIP. CP/M cannot find the specified file, or no +files exist. +.sp +ASM. The indicated source or include file cannot be found on the +indicated drive. +.sp +DDT. The file specified in an R or E command cannot be found on +the disk. +.sp 2 +.ti -15 +NO INPUT FILE PRESENT ON DISK +.sp +DUMP. The file you requested does not exist. +.sp 2 +.ti -15 +No memory +.sp +There is not enough (buffer?) memory available for loading the +program specified. +.sp 2 +.ti -15 +NO SOURCE FILE ON DISK +.sp +SYSGEN. SYSGEN cannot find CP/M either in CPMxx.com form or on +the system tracks of the source disk. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +NO SOURCE FILE PRESENT +.sp +ASM. The assembler cannot find the file you specified. Either +you mistyped the file specification in your command line, or the +filetype is not ASM. +.sp 2 +.ti -15 +NO SPACE +.sp +SAVE. Too many files are already on the disk, or no room is left +on the disk to save the information. +.sp 2 +.ti -15 +No SUB file present +.sp +SUBMIT. For SUBMIT to operate properly, you must create a file +with filetype of SUB. The SUB file contains usual CP/M commands. +Use one command per line. +.sp 2 +.ti -15 +NOT A CHARACTER SOURCE +.sp +PIP. The source specified in your PIP command is illegal. You +have probably specified an output device as a source. +.sp 2 +.ti -15 +** NOT DELETED ** +.sp +PIP. PIP did not delete the file, which might have had the R/O +attribute. +.sp 2 +.ti -15 +NOT FOUND +.sp +PIP. PIP cannot find the specified file. +.sp 2 +.ti -15 +OUTPUT FILE WRITE ERROR +.sp +ASM. You specified a write-protected disk as the destination for +the PRN and HEX files, or the disk has no space left. Correct +the problem before assembling your program. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +Parameter error +.sp +SUBMIT. Within the SUBMIT file of type sub, valid parameters are +$0 through $9. +.sp 2 +.ti -15 +PARAMETER ERROR, TYPE RETURN TO IGNORE +.sp +SYSGEN. If you press RETURN, SYSGEN proceeds without processing +the invalid parameter. +.sp 2 +.ti -15 +QUIT NOT FOUND +.sp +PIP. The string argument to a Q parameter was not found in your +input file. +.sp 2 +.ti -15 +Read error +.sp +TYPE. An error occurred when reading the file specified in the +type command. Check the disk and try again. The STAT filespec +command can diagnose trouble. +.sp 2 +.ti -15 +READER STOPPING +.sp +PIP. Reader operation interrupted. +.sp 2 +.ti -15 +Record Too Long +.sp +PIP. PIP cannot process a record longer than 128 bytes. +.sp 2 +.ti -15 +Requires CP/M 2.0 or later +.sp +XSUB. XSUB requires the facilities of CP/M 2.0 or newer version. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +Requires CP/M 2.0 or new for operation +.sp +PIP. This version of PIP requires the facilities of CP/M 2.0 or +newer version. +.sp 2 +.ti -15 +START NOT FOUND +.sp +PIP. The string argument to an S parameter cannot be found in +the source file. +.sp 2 +.ti -15 +SOURCE FILE INCOMPLETE +.sp +SYSGEN. SYSGEN cannot use your CP/M source file. +.sp 2 +.ti -15 +SOURCE FILE NAME ERROR +.sp +ASM. When you assemble a file, you cannot use the wildcard +characters * and ? in the filename. Only one file can be +assembled at a time. +.sp 2 +.ti -15 +SOURCE FILE READ ERROR +.sp +ASM. The assembler cannot understand the information in the file +containing the assembly-language program. Portions of another +file might have been written over your assembly-language file, or +information was not properly saved on the disk. Use the TYPE +command to locate the error. Assembly-language files contain the +letters, symbols, and numbers that appear on your keyboard. If +your screen displays unrecognizable output or behaves strangely, +you have found where computer instructions have crept into your +file. +.sp 2 +.ti -15 +SYNCHRONIZATION ERROR +.sp +MOVCPM. The MOVCPM utility is being used with the wrong CP/M +system. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +"SYSTEM" FILE NOT ACCESSIBLE +.sp +You tried to access a file set to SYS with the STAT command. +.sp 2 +.ti -15 +** TOO MANY FILES ** +.sp +STAT. There is not enough memory for STAT to sort the files +specified, or more than 512 files were specified. +.sp 2 +.ti -15 +UNEXPECTED END OF HEX FILE--\\{filespec\\} +.sp +PIP. An end-of-file was encountered prior to a termination HEX +record. The HEX file without a termination record should be +corrected, probably by recreating the HEX file. +.sp 2 +.ti -15 +Unrecognized Destination +.sp +PIP. Check command line for valid destination. +.sp 2 +.ti -15 +Use: STAT d:=RO +.sp +STAT. An invalid STAT drive command was given. The only valid +drive assignment in STAT is STAT d:=RO. +.sp 2 +.ti -15 +VERIFY ERROR:--\\{filespec\\} +.sp +PIP. When copying with the V option, PIP found a difference when +rereading the data just written and comparing it to the data in +its memory buffer. Usually this indicates a failure of either +the destination disk or drive. +.sp 2 +.ti -15 +WRONG CP/M VERSION (REQUIRES 2.0) +.sp 2 +.ti -15 +XSUB ACTIVE +.sp +SUBMIT. XSUB has been invoked. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +XSUB ALREADY PRESENT +.sp +SUBMIT. XSUB is already active in memory. +.sp +.ti -15 +Your input? +.sp +If CP/M cannot find the command you specified, it returns the +command name you entered followed by a question mark. Check that +you have typed the command line correctly, or that the command +you requested exists as a .COM file on the default or specified +disk. +.in 0 +.ll 65 +.sp 2 +.ce +End of Appendix I + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/cpm22tex.zip b/Source/Doc/CPM 22 Manual - Testing/cpm22tex.zip new file mode 100644 index 00000000..6248e534 Binary files /dev/null and b/Source/Doc/CPM 22 Manual - Testing/cpm22tex.zip differ diff --git a/Source/Doc/CPM 22 Manual - Testing/fivea.tex b/Source/Doc/CPM 22 Manual - Testing/fivea.tex new file mode 100644 index 00000000..177e63d3 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/fivea.tex @@ -0,0 +1,670 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 5-% +.pc 1 +.ce +.sh +Section 5 +.qs +.sp +.ce +.sh +CP/M 2 System Interface +.qs +.tc 5 CP/M 2 System Interface +.sp 2 +.he CP/M Operating System Manual 5.1 Introduction +.tc 5.1 Introduction +5.1 Introduction +.pp 5 +This chapter describes CP/M (release 2) system organization including the +structure of memory and system entry points. This section provides +the information you need to write programs that operate under CP/M and +that use the peripheral and disk I/O facilities of the system. +.pp +CP/M is logically divided into four parts, called the Basic Input/Output +System (BIOS), the Basic Disk Operating System (BDOS), the Console Command +Processor (CCP), and the Transient Program Area (TPA). The BIOS is a +hardware-dependent module that defines the exact low level interface with a +particular computer system that is necessary for peripheral device I/O. +Although a standard BIOS is supplied by Digital Research, explicit +instructions are provided for field reconfiguration of the BIOS to match +nearly any hardware environment, see Section 6. +.pp +The BIOS and BDOS are +logically combined into a single module with a common entry point and +referred to as the FDOS. The CCP is a distinct program that uses the FDOS to +provide a human-oriented interface with the information that is cataloged on +the back-up storage device. The TPA is an area of memory, +not used by the FDOS and CCP, where various nonresident operating +system commands and user programs are executed. The lower portion of memory +is reserved for system information and is detailed in later sections. Memory +organization of the CP/M system is shown in Figure 5-1. +.sp 3 +.nf + High + Memory FDOS (BDOS+BIOS) + FBASE: + + CCP + CBASE: + + TPA + TBASE: + + System Parameters + BOOT: +.sp 2 +.ce +.sh +Figure 5-1. CP/M Memory Organization +.qs +.fi +.sp 2 +.pp +The exact memory addresses corresponding to BOOT, TBASE, CBASE, and FBASE +vary from version to version and are described fully in Section 6. All +standard CP/M versions assume BOOT=0000H, which is the base of +random access memory. The machine code found at location BOOT performs a +system warm start, which loads and initializes the programs and variables +necessary to return control to the CCP. Thus, transient programs need only +jump to location BOOT to return control to CP/M at the command level. +Further, the standard versions assume TBASE=BOOT+0100H, which is normally +location 0100H. The principal entry point to the FDOS is at location +BOOT+0005H (normally 0005H) where a jump to FBASE is found. The address +field at BOOT+0006H (normally 0006H) contains the value of FBASE and can be +used to determine the size of available memory, assuming that the CCP is +being overlaid by a transient program. +.pp +Transient programs are loaded into the TPA and executed as follows. The +operator communicates with the CCP by typing command lines following each +prompt. Each command line takes one of the following forms: +.sp +.nf +.in 8 +command +command file1 +command file1 file2 +.fi +.in 0 +.sp +where command is either a built-in function, such as DIR or TYPE, or the name +of a transient command or program. If the command is a built-in function of +CP/M, it is executed immediately. Otherwise, the CCP searches the currently +addressed disk for a file by the name +.sp +.ti 8 +command.COM +.pp +If the file is found, it is assumed to be a memory image of a program that +executes in the TPA and thus implicity originates at TBASE in memory. The +CCP loads the COM file from the disk into memory starting at TBASE and can +extend up to CBASE. +.pp +If the command is followed by one or two file specifications, the CCP prepares +one or two File Control Block (FCB) names in the system +parameter area. These optional FCBs are in the form necessary to +access files through the FDOS and are described in Section 5.2. +.pp +The transient program receives control from the CCP and begins +execution, using the I/O facilities of the FDOS. The transient +program is called from the CCP. Thus, it can simply return to the CCP upon +completion of its processing, or can jump to BOOT to pass control back to +CP/M. In the first case, the transient program must not use memory above +CBASE, while in the latter case, memory up through FBASE-1 can be used. +.pp +The transient program can use the CP/M I/O facilities to communicate with the +operator's console and peripheral devices, including the disk subsystem. The +I/O system is accessed by passing a function number and an information address +to CP/M through the FDOS entry point at BOOT+0005H. In the case of a disk +read, for example, the transient program sends the number corresponding to a +disk read, along with the address of an FCB to the CP/M FDOS. The FDOS, in +turn, performs the operation and returns with either a disk read completion +indication or an error number indicating that the disk read was unsuccessful. +.sp 2 +.tc 5.2 Operating System Call Conventions +.he CP/M Operating System Manual 5.2 Call Conventions +.sh +5.2 Operating System Call Conventions +.qs +.pp +This section provides detailed information for performing direct operating +system calls from user programs. Many of the functions listed below, however, +are accessed more simply through the I/O macro library provided with the +MAC macro assembler and listed in the Digital Research manual +entitled, \c +.ul +Programmer's Utilities Guide for the CP/M Family of Operating Systems. +.qu +.pp +CP/M facilities that are available for access by transient programs fall into +two general categories: simple device I/O and disk file I/O. The simple +device operations are +.sp +.nf +.in 5 +.ti -2 +o read a console character +.ti -2 +o write a console character +.ti -2 +o read a sequential character +.ti -2 +o write a sequential character +.ti -2 +o get or set I/O status +.ti -2 +o print console buffer +.ti -2 +o interrogate console ready +.sp +The following FDOS operations perform disk I/O: +.sp +.ti -2 +o disk system reset +.ti -2 +o drive selection +.ti -2 +o file creation +.ti -2 +o file close +.ti -2 +o directory search +.ti -2 +o file delete +.ti -2 +o file rename +.ti -2 +o random or sequential read +.ti -2 +o random or sequential write +.ti -2 +o interrogate available disks +.ti -2 +o interrogate selected disk +.ti -2 +o set DMA address +.ti -2 +o set/reset file indicators. +.fi +.in 0 +.pp +As mentioned above, access to the FDOS functions is accomplished by passing +a function number and information address through the primary point at +location BOOT+0005H. In general, the function number is passed in register C +with the information address in the double byte pair DE. Single byte values +are returned in register A, with double byte values returned in HL, a zero +value is returned when the function number is out of range. For reasons of +compatibility, register A = L and register B = H upon return in all cases. +Note that the register passing conventions of CP/M agree with +those of the Intel PL/M systems programming language. CP/M functions and +their numbers are listed below. +.bp +.nf +.in 5 + O System Reset 19 Delete File + 1 Console Input 20 Read Sequential + 2 Console Output 21 Write Sequential + 3 Reader Input 22 Make File + 4 Punch Output 23 Rename File + 5 List Output 24 Return Login Vector + 6 Direct Console I/O 25 Return Current Disk + 7 Get I/O Byte 26 Set DMA Address + 8 Set I/O Byte 27 Get Addr(Alloc) + 9 Print String 28 Write Protect Disk +10 Read Console Buffer 29 Get R/0 Vector +11 Get Console Status 30 Set File Attributes +12 Return Version Number 31 Get Addr(Disk Parms) +13 Reset Disk System 32 Set/Get User Code +14 Select Disk 33 Read Random +15 Open File 34 Write Random +16 Close File 35 Compute File Size +17 Search for First 36 Set Random Record +18 Search for Next 37 Reset Drive + 40 Write Random with Zero Fill +.fi +.in 0 +.sp +.pp +Functions 28 and 32 should be avoided in application programs to +maintain upward compatibility with CP/M. +.pp +Upon entry to a transient program, the CCP leaves the stack +pointer set to an eight-level stack area with the CCP return +address pushed onto the stack, leaving seven levels before +overflow occurs. Although this stack is usually not used by a +transient program (most transients return to the CCP +through a jump to location 0000H) it is large enough to +make CP/M system calls because the FDOS switches to a local stack +at system entry. For example, the assembly-language program segment below +reads characters continuously until an asterisk is +encountered, at which time control returns to the CCP, assuming a +standard CP/M system with BOOT = 0000H. +.sp 2 +.nf +.in 8 +BDOS EQU 0005H ;STANDARD CP/M ENTRY +CONIN EQU 1 ;CONSOLE INPUT FUNCTION +; + ORG 0100H ;BASE OF TPA +NEXTC: MVI C,CONIN ;READ NEXT CHARACTER + CALL BDOS ;RETURN CHARACTER IN + CPI '*' ;END OF PROCESSING? + JNZ NEXTC ;LOOP IF NOT + RET ;RETURN TO CCP + END +.fi +.in 0 +.sp +.pp +CP/M implements a named file structure on each disk, providing a +logical organization that allows any particular file to contain +any number of records from completely empty to the full capacity +of the drive. Each drive is logically distinct with a disk +directory and file data area. The disk filenames are in three +parts: the drive select code, the filename (consisting of one to +eight nonblank characters), and the filetype (consisting of zero +to three nonblank characters). The filetype names the generic +category of a particular file, while the filename distinguishes +individual files in each category. The filetypes listed in Table 5-1 +name a few generic categories that have been established, +although they are somewhat arbitrary. +.sp 2 +.sh + Table 5-1. CP/M Filetypes +.qs +.sp +.nf + Filetype Meaning +.sp +.in 30 +.ti -11 +ASM Assembler Source +.ti -11 +PRN Printer Listing +.ti -11 +HEX Hex Machine Code +.ti -11 +BAS Basic Source File +.ti -11 +INT Intermediate Code +.ti -11 +COM Command File +.ti -11 +PLI PL/I Source File +.ti -11 +REL Relocatable Module +.ti -11 +TEX TEX Formatter Source +.ti -11 +BAK ED Source Backup +.ti -11 +SYM SID Symbol File +.ti -11 +$$$ Temporary File +.fi +.in 0 +.sp +.pp +Source files are treated as a sequence of ASCII characters, where +each line of the source file is followed by a carriage return, and +line-feed sequence (0DH followed by 0AH). Thus, one 128-byte CP/M +record can contain several lines of source text. The end of an +ASCII file is denoted by a CTRL-Z character (1AH) or a real +end-of-file returned by the CP/M read operation. CTRL-Z characters embedded +within machine code files (for example, COM files) are ignored and +the end-of-file condition returned by CP/M is used to terminate +read operations. +.pp +Files in CP/M can be thought of as a sequence of up to 65536 +records of 128 bytes each, numbered from 0 through 65535, thus +allowing a maximum of 8 megabytes per file. Note, however, +that although the records may be considered logically +contiguous, they may not be physically contiguous in the disk +data area. Internally, all files are divided into 16K byte +segments called logical extents, so that counters are easily +maintained as 8-bit values. The division into extents is +discussed in the paragraphs that follow: however, they are not +particularly significant for the programmer, because each extent is +automatically accessed in both sequential and random access +modes. +.pp +In the file operations starting with Function 15, DE +usually addresses a FCB. Transient programs +often use the default FCB area reserved by CP/M at +location BOOT+005CH (normally 005CH) for simple file operations. +The basic unit of file information is a 128-byte record used for +all file operations. Thus, a default location for disk I/O is +provided by CP/M at location BOOT+0080H (normally 0080H) which +is the initial default DMA address. See Function 26. +.pp +All directory operations take place in a reserved area that does not +affect write buffers as was the case in release 1, with the +exception of Search First and Search Next, where compatibility is +required. +.pp +The FCB data area consists of a sequence of 33 bytes for +sequential access and a series of 36 bytes in the case when the +file is accessed randomly. The default FCB, normally located at +005CH, can be used for random access files, because the three bytes +starting at BOOT+007DH are available for this purpose. Figure 5-2 shows +the FCB format with the following fields. +.sp 3 +.nf + dr f1 f2 / / f8 t1 t2 t3 ex s1 s2 rc d0 / / dn cr r0 r1 r2 + 00 01 02 ... 08 09 10 11 12 13 14 15 16 ... 31 32 33 34 35 +.fi +.sp 2 +.sh + Figure 5-2. File Control Block Format +.sp 3 +The following table lists and describes each of the fields in the File Control +Block figure. +.sp 2 +.sh + Table 5-2. File Control Block Fields +.nf +.sp + Field Definition +.sp + dr drive code (0-16) + 0 = use default drive for file + 1 = auto disk select drive A, + 2 = auto disk select drive B, + . + . + . + 16= auto disk select drive P. +.sp + f1...f8 contain the filename in ASCII + upper-case, with high bit = 0 +.sp + t1, t2, t3 contain the filetype in ASCII + upper-case, with high bit = 0 + t1', t2', and t3' denote the + bit of these positions, + t1' = 1 =>Read-Only file, + t2' = 1 =>SYS file, no DIR list +.sp + ex contains the current extent + number, normally set to 00 by + the user, but in range 0-31 + during file I/O +.bp +.sh + Table 5-2. (continued) +.qs +.sp + Field Definition +.sp + s1 reserved for internal system use +.sp + s2 reserved for internal system use, + set to zero on call to OPEN, MAKE, + SEARCH +.sp + rc record count for extent ex; + takes on values from 0-127 +.sp + d0...dn filled in by CP/M; reserved for + system use +.sp + cr current record to read or write in + a sequential file operation; + normally set to zero by user +.sp + r0, r1, r2 optional random record number in + the range 0-65535, with overflow + to r2, r0, r1 constitute a 16-bit + value with low byte r0, and high + byte r1 +.fi +.sp +.pp +Each file being accessed through CP/M must have a corresponding +FCB, which provides the name and allocation information for all +subsequent file operations. When accessing files, it is the +programmer's responsibility to fill the lower 16 bytes of the FCB +and initialize the cr field. Normally, bytes 1 through 11 are +set to the ASCII character values for the filename and filetype, +while all other fields are zero. +.pp +FCBs are stored in a directory area of the disk, and are brought +into central memory before the programmer proceeds with file +operations (see the OPEN and MAKE functions). The memory copy of +the FCB is updated as file operations take place and later +recorded permanently on disk at the termination of the file +operation, (see the CLOSE command). +.pp +The CCP constructs the first 16 bytes of two optional FCBs for a +transient by scanning the remainder of the line following the +transient name, denoted by file1 and file2 in the prototype +command line described above, with unspecified fields set to +ASCII blanks. The first FCB is constructed at location +BOOT+005CH and can be used as is for subsequent file operations. +The second FCB occupies the d0...dn portion of the first FCB and +must be moved to another area of memory before use. If, for +example, the following command line is typed: +.sp +.ti 8 +PROGNAME B:X.ZOT Y.ZAP +.bp +the file PROGNAME.COM is loaded into the TPA, and the default FCB +at BOOT+005CH is initialized to drive code 2, filename X, and +filetype ZOT. The second drive code takes the default value 0, +which is placed at BOOT-006CH, with the filename Y placed into +location BOOT+006DH and filetype ZAP located 8 bytes later at +BOOT+0075H. All remaining fields through cr are set to zero. +Note again that it is the programmer's +responsibility to move this second filename and filetype to another +area, usually a separate file control block, before opening the +file that begins at BOOT+005CH, because the open operation +overwrites the second name and type. +.pp +If no filenames are specified in the original command, the +fields beginning at BOOT+005DH and BOOT+006DH contain blanks. In +all cases, the CCP translates lower-case alphabetics to upper-case +to be consistent with the CP/M file naming conventions. +.pp +As an added convenience, the default buffer area at location +BOOT+0080H is initialized to the command line tail typed by the +operator following the program name. The first position contains +the number of characters, with the characters themselves +following the character count. Given the above command line, the +area beginning at BOOT+0080H is initialized as follows: +.sp 2 +.nf +.in 5 +BOOT+0080H: +.sp ++00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +A +B +C +D +E +E '' 'B' ':' 'X' '.' 'Z' 'O' 'T' '' 'Y' '.' 'Z' 'A' 'P' +.fi +.in 0 +.sp 2 +where the characters are translated to upper-case ASCII with +uninitialized memory following the last valid character. Again, +it is the responsibility of the programmer to extract the +information from this buffer before any file operations are +performed, unless the default DMA address is explicitly changed. +.pp +Individual functions are described in detail in the pages that +follow. +.bp +.sp 4 +.nf + FUNCTION 0: SYSTEM RESET +.sp + Entry Parameters: + Register C: 00H +.fi +.sp 2 +.pp +The System Reset function returns control to the CP/M operating +system at the CCP level. The CCP reinitializes the disk +subsystem by selecting and logging-in disk drive A. This +function has exactly the same effect as a jump to location BOOT. +.sp 6 +.nf + FUNCTION 1: CONSOLE INPUT +.sp + Entry Parameters: + Register C: 01H +.sp + Returned Value: + Register A: ASCII Character +.fi +.sp 2 +.pp +The Console Input function reads the next console character to +register A. Graphic characters, along with carriage return, line-feed, +and back space (CTRL-H) are echoed to the console. Tab +characters, CTRL-I, move the cursor to the next tab stop. A check +is made for start/stop scroll, CTRL-S, and start/stop printer echo, +CTRL-P. The FDOS does not return to the calling program until a +character has been typed, thus suspending execution if a +character is not ready. +.bp +.sp 4 +.nf + FUNCTION 2: CONSOLE OUTPUT +.sp + Entry Parameters + Register C: 02H + Register E: ASCII Character +.fi +.sp 2 +.pp +The ASCII character from register E is sent to the console +device. As in Function 1, tabs are expanded and checks are made +for start/stop scroll and printer echo. +.sp 6 +.nf + FUNCTION 3: READER INPUT +.sp + Entry Parameters: + Register C: 03H +.sp + Returned Value: + Register A: ASCII Character +.fi +.sp 2 +.pp +The Reader Input function reads the next character from the +logical reader into register A. See the IOBYTE definition in +Chapter 6. Control does not return until the character has been +read. +.bp +.sp 4 +.nf + FUNCTION 4: PUNCH OUTPUT +.sp + Entry Parameters: + Register C: 04H + register E: ASCII Character +.fi +.sp 2 +.pp +The Punch Output function sends the character from register E to +the logical punch device. +.sp 6 +.nf + FUNCTION 5: LIST OUTPUT +.sp + Entry Parameters: + Register C: 05H + Register E: ASCII Character +.fi +.sp 2 +.pp +The List Output function sends the ASCII character in register E +to the logical listing device. +.bp +.sp 4 +.nf + FUNCTION 6: DIRECT CONSOLE I/O +.sp + Entry Parameters: + Register C: 06H + Register E: 0FFH (input) or + char (output) +.sp + Returned Value: + Register A: char or status +.fi +.sp 2 +.pp +Direct Console I/O is supported under CP/M for those specialized +applications where basic console input and output are required. +Use of this function should, in general, be avoided since it +bypasses all of the CP/M normal control character functions (for example, +CTRL-S and CTRL-P). Programs that perform direct I/O +through the BIOS under previous releases of CP/M, however, should +be changed to use direct I/O under BDOS so that they can be fully +supported under future releases of MP/M \ and CP/M. +.pp +Upon entry to Function 6, register E either contains hexadecimal +FF, denoting a console input request, or an ASCII character. If +the input value is FF, Function 6 returns A = 00 if no character +is ready, otherwise A contains the next console input character. +.pp +If the input value in E is not FF, Function 6 assumes that E +contains a valid ASCII character that is sent to the console. +.pp +Function 6 must not be used in conjunction with other console I/O +functions. +.sp 6 +.nf + FUNCTION 7: GET I/O BYTE +.sp + Entry Parameters: + Register C: 07H +.sp + Returned Value: + Register A: I/O Byte Value +.fi +.sp 2 +.pp +The Get I/O Byte function returns the current value of IOBYTE in +register A. See Chapter 6 for IOBYTE definition. +.bp +.sp 4 +.nf + FUNCTION 8: SET I/O BYTE +.sp + Entry Parameters: + Register C: 08H + Register E: I/O Byte Value +.fi +.sp 2 +.pp +The SET I/O Byte function changes the IOBYTE value to that given +in register E. +.sp 6 +.nf + FUNCTION 9: PRINT STRING +.sp + Entry Parameters: + Register C: 09H + Registers DE: String Address +.fi +.sp 2 +.pp +The Print String function sends the character string stored in +memory at the location given by DE to the console device, until a +$ is encountered in the string. Tabs are expanded as in Function +2, and checks are made for start/stop scroll and printer echo. +.nx fiveb.tex + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/fiveb.tex b/Source/Doc/CPM 22 Manual - Testing/fiveb.tex new file mode 100644 index 00000000..ad1ec089 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/fiveb.tex @@ -0,0 +1,806 @@ +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.bp +.sp 4 +.nf + FUNCTION 10: READ CONSOLE BUFFER +.sp + Entry Parameters: + Register C: 0AH + Registers DE: Buffer Address +.sp + Returned Value: + Console Characters in Buffer +.fi +.sp 2 +.pp +The Read Buffer functions reads a line of edited console input +into a buffer addressed by registers DE. Console input is +terminated when either input buffer overflows or a carriage return +or line-feed is typed. The Read Buffer takes the form: +.sp +.nf +.in 8 +DE:+0 +1 +2 +3 +4 +5 +6 +7 +8 . . .+n +.sp +mx nc c1 c2 c3 c4 c5 c6 c7 ... ?? +.fi +.in 0 +.sp +where mx is the maximum number of characters that the buffer will +hold, 1 to 255, and nc is the number of characters read (set by +FDOS upon return) followed by the characters read from the +console. If nc < mx, then uninitialized positions follow the +last character, denoted by ?? in the above figure. A number of +control functions, summarized in Table 5-3, are recognized during +line editing. +.sp 2 +.sh + Table 5-3. Edit Control Characters +.sp +.nf + Character Edit Control Function +.sp +.fi +.in 8 +rub/del removes and echoes the last character +.sp +CTRL-C reboots when at the beginning of line +.sp +CTRL-E causes physical end of line +.sp +CTRL-H backspaces one character position +.sp +CTRL-J (line feed) terminates input line +.sp +CTRL-M (return) terminates input line +.sp +CTRL-R retypes the current line after new line +.sp +CTRL-U removes current line +.sp +CTRL-X same as CTRL-U +.in 0 +.sp 2 +The user should also note that certain functions that return the +carriage to the leftmost position (for example, CTRL-X) do so only to the +column position where the prompt ended. In earlier releases, the +carriage returned to the extreme left margin. This convention +makes operator data input and line correction more legible. +.bp +.sp 4 +.nf + FUNCTION 11: GET CONSOLE STATUS +.sp + Entry Parameters: + Register C: 0BH +.sp + Returned Value: + Register A: Console Status +.fi +.sp 2 +.pp +The Console Status function checks to see if a character has been +typed at the console. If a character is ready, the value 0FFH is +returned in register A. Otherwise a 00H value is returned. +.sp 6 +.nf + FUNCTION 12: RETURN VERSION NUMBER +.sp + Entry Parameters: + Register C: 0CH +.sp + Returned Value: + Registers HL: Version Number +.fi +.sp 2 +.pp +Function 12 provides information that allows version independent +programming. A two-byte value is returned, with H = 00 +designating the CP/M release (H = 01 for MP/M) and L = 00 for +all releases previous to 2.0. CP/M 2.0 returns a hexadecimal 20 +in register L, with subsequent version 2 releases in the +hexadecimal range 21,22, through 2F. Using Function 12, for +example, the user can write application programs that provide +both sequential and random access functions. +.bp +.sp 4 +.nf + FUNCTION 13: RESET DISK SYSTEM +.sp + Entry Parameters: + Register C: 0DH +.fi +.sp 2 +.pp +The Reset Disk function is used to programmatically restore the +file system to a reset state where all disks are set to +Read-Write. See functions 28 and 29, only disk drive A is +selected, and the default DMA address is reset to BOOT+0080H. +This function can be used, for example, by an application program +that requires a disk change without a system reboot. +.sp 6 +.nf + FUNCTION 14: SELECT DISK +.sp + Entry Parameters: + Register C: 0EH + Register E: Selected Disk +.fi +.sp 2 +.pp +The Select Disk function designates the disk drive named in register +E as the default disk for subsequent file operations, with E = O +for drive A, 1 for drive B, and so on through 15, corresponding to drive +P in a full 16 drive system. The drive is placed in an on-line +status, which activates its directory until the next cold start, +warm start, or disk system reset operation. If the disk medium +is changed while it is on-line, the drive automatically goes to +a Read-Only status in a standard CP/M environment, see Function +28. FCBs that specify drive code zero (dr = 00H) automatically +reference the currently selected default drive. Drive code +values between 1 and 16 ignore the selected default +drive and directly reference drives A through P. +.bp +.sp 4 +.nf + FUNCTION 15: OPEN FILE +.sp + Entry Parameters: + Register C: 0FH + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Open File operation is used to activate a file that currently +exists in the disk directory for the currently active user +number. The FDOS scans the referenced disk directory for a match +in positions 1 through 14 of the FCB referenced by DE (byte s1 is +automatically zeroed) where an ASCII question mark (3FH) matches +any directory character in any of these positions. Normally, no +question marks are included, and bytes ex and s2 of the FCB are +zero. +.pp +If a directory element is matched, the relevant directory +information is copied into bytes d0 through dn of FCB, thus +allowing access to the files through subsequent read and write +operations. The user should note that an existing file must not +be accessed until a successful open operation is completed. Upon +return, the open function returns a directory code with the value +0 through 3 if the open was successful or 0FFH (255 decimal) if +the file cannot be found. If question marks occur in the FCB, +the first matching FCB is activated. Note that the current +record, (cr) must be zeroed by the program if the file is to be +accessed sequentially from the first record. +.bp +.sp 4 +.nf + FUNCTION 16: CLOSE FILE +.sp + Entry Parameters: + Register C: 10H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Close File function performs the inverse of the Open File +function. Given that the FCB addressed by DE has been previously +activated through an open or make function, the close function +permanently records the new FCB in the reference disk directory +see functions 15 and 22. The FCB matching process for the close +is identical to the open function. The directory code returned +for a successful close operation is 0, 1, 2, or 3, while a 0FFH +(255 decimal) is returned if the filename cannot be found in the +directory. A file need not be closed if only read operations +have taken place. If write operations have occurred, the close +operation is necessary to record the new directory information +permanently. +.bp +.sp 4 +.nf + FUNCTION 17: SEARCH FOR FIRST +.sp + Entry Parameters: + Register C: 11H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +Search First scans the directory for a match with the file given +by the FCB addressed by DE. The value 255 (hexadecimal FF) is +returned if the file is not found; otherwise, 0, 1, 2, or 3 is +returned indicating the file is present. When the file is found, +the current DMA address is filled with the record containing the +directory entry, and the relative starting position is A *32 +(that is, rotate the A register left 5 bits, or ADD A five times). +Although not normally required for application programs, the +directory information can be extracted from the buffer at this +position. +.pp +An ASCII question mark (63 decimal, 3F hexadecimal) in any +position from f1 through ex matches the corresponding field of +any directory entry on the default or auto-selected disk drive. +If the dr field contains an ASCII question mark, the auto disk +select function is disabled and the default disk is searched, +with the search function returning any matched entry, allocated +or free, belonging to any user number. This latter function is +not normally used by application programs, but it allows complete +flexibility to scan all current directory values. If the dr +field is not a question mark, the s2 byte is automatically +zeroed. +.bp +.sp 4 +.nf + FUNCTION 18: SEARCH FOR NEXT +.sp + Entry Parameters: + Register C: 12H +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Search Next function is similar to the Search First function, except +that the directory scan continues from the last matched entry. +Similar to Function 17, Function 18 returns the decimal value 255 +in A when no more directory items match. +.sp 6 +.nf + FUNCTION 19: DELETE FILE +.sp + Entry Parameters: + Register C: 13H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Delete File function removes files that match the FCB +addressed by DE. The filename and type may contain ambiguous +references (that is, question marks in various positions), but the +drive select code cannot be ambiguous, as in the Search and +Search Next functions. +.pp +Function 19 returns a decimal 255 if the referenced file or files +cannot be found; otherwise, a value in the range 0 to 3 returned. +.bp +.sp 4 +.nf + FUNCTION 20: READ SEQUENTIAL +.sp + Entry Parameters: + Register C: 14H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +Given that the FCB addressed by DE has been activated through an +Open or Make function, the Read Sequential function reads the +next 128-byte record from the file into memory at the current DMA +address. The record is read from position cr of the extent, and +the cr field is automatically incremented to the next record +position. If the cr field overflows, the next logical extent is +automatically opened and the cr field is reset to zero in +preparation for the next read operation. The value 00H is +returned in the A register if the read operation was successful, +while a nonzero value is returned if no data exist at the next +record position (for example, end-of-file occurs). +.sp 6 +.nf + FUNCTION 21: WRITE SEQUENTAIL +.sp + Entry Parameters: + Register C: 15H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +Given that the FCB addressed by DE has been activated through an +Open or Make function, the Write Sequential +function writes the 128-byte data record at the current DMA +address to the file named by the FCB. The record is placed at +position cr of the file, and the cr field is automatically +incremented to the next record position. If the cr field +overflows, the next logical extent is automatically opened and +the cr field is reset to zero in preparation for the next write +operation. Write operations can take place into an existing +file, in which case, newly written records overlay those that +already exist in the file. Register A = 00H upon return from a +successful write operation, while a nonzero value indicates an +unsuccessful write caused by a full disk. +.bp +.sp 4 +.nf + FUNCTION 22: MAKE FILE +.sp + Entry Parameters: + Register C: 16H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Make File operation is similar to the Open File operation +except that the FCB must name a file that does not exist in the +currently referenced disk directory (that is, the one named +explicitly by a nonzero dr code or the default disk if dr is +zero). The FDOS creates the file and initializes both the +directory and main memory value to an empty file. The programmer +must ensure that no duplicate filenames occur, and a preceding +delete operation is sufficient if there is any possibility of +duplication. Upon return, register A = 0, 1, 2, or 3 if the +operation was successful and 0FFH (255 decimal) if no more +directory space is available. The Make function has the side +effect of activating the FCB and thus a subsequent open is not +necessary. +.sp 6 +.nf + FUNCTION 23: RENAME FILE +.sp + Entry Parameters: + Register C: 17H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Rename function uses the FCB addressed by DE to change all +occurrences of the file named in the first 16 bytes to the file +named in the second 16 bytes. The drive code dr at postion 0 is +used to select the drive, while the drive code for the new +filename at position 16 of the FCB is assumed to be zero. Upon +return, register A is set to a value between 0 and 3 if the +rename was successful and 0FFH (255 decimal) if the first +filename could not be found in the directory scan. +.bp +.sp 4 +.nf + FUNCTION 24: RETURN LOG-IN VECTOR +.sp + Entry Parameters: + Register C: 18H +.sp + Returned Value: + Registers HL: Log-in Vector +.fi +.sp 2 +.pp +The log-in vector value returned by CP/M is a 16-bit value in HL, where the +least significant bit of L corresponds to the first drive A and +the high-order bit of H corresponds to the sixteenth drive, +labeled P. A 0 bit indicates that the drive is not on-line, +while a 1 bit marks a drive that is actively on-line as a result +of an explicit disk drive selection or an implicit drive select +caused by a file operation that specified a nonzero dr field. +The user should note that compatibility is maintained with +earlier releases, because registers A and L contain the same values +upon return. +.sp 6 +.nf + FUNCTION 25: RETURN CURRENT DISK +.sp + Entry Parameters: + Register C: 19H +.sp + Returned Value: + Register A: Current Disk +.fi +.sp 2 +.pp +Function 25 returns the currently selected default disk number in +register A. The disk numbers range from 0 through 15 +corresponding to drives A through P. +.bp +.sp 4 +.nf + FUNCTION 26: SET DMA ADDRESS +.sp + Entry Parameters: + Register C: 1AH + Registers DE: DMA Address +.fi +.sp 2 +.pp +DMA is an acronym for Direct Memory Address, which is often used +in connection with disk controllers that directly access the +memory of the mainframe computer to transfer data to and from the +disk subsystem. Although many computer systems use non-DMA +access (that is, the data is transferred through programmed I/O +operations), the DMA address has, in CP/M, come to mean the +address at which the 128-byte data record resides before a disk +write and after a disk read. Upon cold start, warm start, or +disk system reset, the DMA address is automatically set to +BOOT+0080H. The Set DMA function can be used to change +this default value to address another area of memory where the +data records reside. Thus, the DMA address becomes the value +specified by DE until it is changed by a subsequent Set DMA +function, cold start, warm start, or disk system reset. +.sp 6 +.nf + FUNCTION 27: GET ADDR (ALLOC) +.sp + Entry Parameters: + Register C: 1BH +.sp + Returned Value: + Registers HL: ALLOC Address +.fi +.sp 2 +.pp +An allocation vector is maintained in main memory for each on- +line disk drive. Various system programs use the information +provided by the allocation vector to determine the amount of +remaining storage (see the STAT program). Function 27 returns +the base address of the allocation vector for the currently +selected disk drive. However, the allocation information might be +invalid if the selected disk has been marked Read-Only. Although +this function is not normally used by application programs, +additional details of the allocation vector are found in Chapter +6. +.bp +.sp 4 +.nf + FUNCTION 28: WRITE PROTECT DISK +.sp + Entry Parameters: + Register C: 1CH +.fi +.sp 2 +.pp +The Write Protect Disk function provides temporary write +protection for the currently selected disk. Any attempt to write +to the disk before the next cold or warm start operation produces +the message: +.sp +.ti 8 +BDOS ERR on d:R/O +.sp 6 +.nf + FUNCTION 29: GET READ-ONLY VECTOR +.sp + Entry Parameters: + Register C: 1DH +.sp + Returned Value: + Registers HL: R/O Vector Value +.fi +.sp 2 +.pp +Function 29 returns a bit vector in register pair HL, which +indicates drives that have the temporary Read-Only bit set. As +in Function 24, the least significant bit corresponds to drive A, +while the most significant bit corresponds to drive P. The R/O +bit is set either by an explicit call to Function 28 or by the +automatic software mechanisms within CP/M that detect changed +disks. +.bp +.sp 4 +.nf + FUNCTION 30: SET FILE ATTRIBUTES +.sp + Entry Parameters: + Register C: 1EH + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Set File Attributes function allows programmatic manipulation +of permanent indicators attached to files. In particular, the R/O +and System attributes (t1' and t2') can be set or reset. The DE +pair addresses an unambiguous filename with the appropriate +attributes set or reset. Function 30 searches for a match and +changes the matched directory entry to contain the selected +indicators. Indicators f1' through f4' are not currently used, +but may be useful for applications programs, since they are not +involved in the matching process during file open and close +operations. Indicators f5' through f8' and t3' are reserved for +future system expansion. +.sp 6 +.nf + FUNCTION 31: GET ADDR (DISK PARMS) +.sp + Entry Parameters: + Register C: 1FH +.sp + Returned Value: + Registers HL: DPB Address +.fi +.sp 2 +.pp +The address of the BIOS resident disk parameter block is returned +in HL as a result of this function call. This address can be +used for either of two purposes. First, the disk parameter +values can be extracted for display and space computation +purposes, or transient programs can dynamically change the values +of current disk parameters when the disk environment changes, if +required. Normally, application programs will not require this +facility. +.bp +.sp 4 +.nf + FUNCTION 32: SET/GET USER CODE +.sp + Entry Parameters: + Register C: 20H + Register E: OFFH (get) or + User Code (set) +.sp + Returned Value: + Register A: Current Code or + (no value) +.fi +.sp 2 +.pp +An application program can change or interrogate the currently +active user number by calling Function 32. If register E = 0FFH, +the value of the current user number is returned in register A, +where the value is in the range of 0 to 15. If register E is not +0FFH, the current user number is changed to the value of E, +modulo 16. +.bp +.sp 4 +.nf + FUNCTION 33: READ RANDOM +.sp + Entry Parameters: + Register C: 21H +.sp + Returned Value: + Register A: Return Code +.fi +.sp 2 +.pp +The Read Random function is similar to the sequential file read +operation of previous releases, except that the read operation +takes place at a particular record number, selected by the 24-bit +value constructed from the 3-byte field following the FCB (byte +positions r0 at 33, r1 at 34, and r2 at 35). The user should +note that the sequence of 24 bits is stored with least +significant byte first (r0), middle byte next (r1), and high byte +last (r2). CP/M does not reference byte r2, except in computing +the size of a file (Function 35). Byte r2 must be zero, however, +since a nonzero value indicates overflow past the end of file. +.pp +Thus, the r0, r1 byte pair is treated as a double-byte, or word +value, that contains the record to read. This value ranges from +0 to 65535, providing access to any particular record of the 8- +megabyte file. To process a file using random access, the base +extent (extent 0) must first be opened. Although the base extent +might or might not contain any allocated data, this ensures that the +file is properly recorded in the directory and is visible in DIR +requests. The selected record number is then stored in the +random record field (r0, r1), and the BDOS is called to read the +record. +.pp +Upon return from the call, register A either contains an error +code, as listed below, or the value 00, indicating the operation +was successful. In the latter case, the current DMA address +contains the randomly accessed record. Note that +contrary to the sequential read operation, the record number is +not advanced. Thus, subsequent random read operations continue +to read the same record. +.pp +Upon each random read operation, the logical extent and current +record values are automatically set. Thus, the file can be +sequentially read or written, starting from the current randomly +accessed position. However, note that, in this +case, the last randomly read record will be reread as one +switches from random mode to sequential read and the last record +will be rewritten as one switches to a sequential write operation. +The user can simply advance the random record +position following each random read or write to obtain the effect +of sequential I/O operation. +.bp +.pp +Error codes returned in register A following a random read are +listed below. +.sp 2 +.nf +.in 8 +01 reading unwritten data +.sp +02 (not returned in random mode) +.sp +03 cannot close current extent +.sp +04 seek to unwritten extent +.sp +05 (not returned in read mode) +.sp +06 seek past physical end of disk +.fi +.in 0 +.sp +.pp +Error codes 01 and 04 occur when a random read operation accesses +a data block that has not been previously written or an extent +that has not been created, which are equivalent conditions. +Error code 03 does not normally occur under proper system +operation. If it does, it can be cleared by simply rereading or +reopening extent zero as long as the disk is not physically write +protected. Error code 06 occurs whenever byte r2 is nonzero +under the current 2.0 release. Normally, nonzero return codes +can be treated as missing data, with zero return codes indicating +operation complete. +.bp +.sp 4 +.nf + FUNCTION 34: WRITE RANDOM +.sp + Entry Parameters: + Register C: 22H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Return Code +.fi +.sp 2 +.pp +The Write Random operation is initiated similarly to the Read +Random call, except that data is written to the disk from the +current DMA address. Further, if the disk extent or data block +that is the target of the write has not yet been allocated, the +allocation is performed before the write operation continues. As +in the Read Random operation, the random record number is not +changed as a result of the write. The logical extent number and +current record positions of the FCB are set to correspond to the +random record that is being written. Again, sequential read or +write operations can begin following a random write, with the +notation that the currently addressed record is either read or +rewritten again as the sequential operation begins. You can +also simply advance the random record position following each +write to get the effect of a sequential write operation. +Note that reading or writing the last record of an extent in +random mode does not cause an automatic extent switch as it does +in sequential mode. +.pp +The error codes returned by a random write are identical to the +random read operation with the addition of error code 05, which +indicates that a new extent cannot be created as a result of +directory overflow. +.bp +.sp 4 +.nf + FUNCTION 35: COMPUTE FILE SIZE +.sp + Entry Parameters: + Register C: 23H + Registers DE: FCB Address +.sp + Returned Value: + Random Record Field Set +.fi +.sp 2 +.pp +When computing the size of a file, the DE register pair addresses +an FCB in random mode format (bytes r0, r1, and r2 are present). +The FCB contains an unambiguous filename that is used in the +directory scan. Upon return, the random record bytes contain the +virtual file size, which is, in effect, the record address of +the record following the end of the file. Following a call to +Function 35, if the high record byte r2 is 01, the file contains +the maximum record count 65536. Otherwise, bytes r0 and r1 +constitute a 16-bit value as before (r0 is the least significant byte), +which is the file size. +.pp +Data can be appended to the end of an existing file by simply +calling Function 35 to set the random record position to the end +of file and then performing a sequence of random writes starting +at the preset record address. +.pp +The virtual size of a file corresponds to the physical size when +the file is written sequentially. If the file was created in +random mode and holes exist in the allocation, the file might +contain fewer records than the size indicates. For example, +if only the last record of an 8-megabyte file is written in +random mode (that is, record number 65535), the virtual size is +65536 records, although only one block of data is actually +allocated. +.bp +.sp 4 +.nf + FUNCTION 36: SET RANDOM RECORD +.sp + Entry Parameters: + Register C: 24H + Registers DE: FCB Address +.sp + Returned Value: + Random Record Field Set +.fi +.sp 2 +.pp +The Set Random Record function causes the BDOS automatically +to produce the random record position from a file that has been +read or written sequentially to a particular point. The function +can be useful in two ways. +.pp +First, it is often necessary initially to read and scan a +sequential file to extract the positions of various key fields. +As each key is encountered, Function 36 is called to compute the +random record position for the data corresponding to this key. If +the data unit size is 128 bytes, the resulting record position is +placed into a table with the key for later retrieval. After +scanning the entire file and tabulating the keys and their record +numbers, the user can move instantly to a particular keyed record +by performing a random read, using the corresponding random +record number that was saved earlier. The scheme is easily +generalized for variable record lengths, because the program need +only store the buffer-relative byte position along with the key +and record number to find the exact starting position of the +keyed data at a later time. +.pp +A second use of Function 36 occurs when switching from a +sequential read or write over to random read or write. A file is +sequentially accessed to a particular point in the file, Function +36 is called, which sets the record number, and subsequent random +read and write operations continue from the selected point in the +file. +.bp +.sp 4 +.nf + FUNCTION 37: RESET DRIVE +.sp + Entry Parameters: + Register C: 25H + Registers DE: Drive Vector +.sp + Returned Value: + Register A: 00H +.fi +.sp 2 +.pp +The Reset Drive function allows resetting of specified drives. +The passed parameter is a 16-bit vector of drives to be reset; +the least significant bit is drive A:. +.pp +To maintain compatibility with MP/M, CP/M returns a zero value. +.sp 6 +.nf + FUNCTION 40: WRITE RANDOM WITH ZERO FILL +.sp + Entry Parameters: + Register C: 28H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Return Code +.fi +.sp 2 +.pp +The Write With Zero Fill operation is similar to Function 34, +with the exception that a previously unallocated block is filled +with zeros before the data is written. +.nx fivec + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/fivec.tex b/Source/Doc/CPM 22 Manual - Testing/fivec.tex new file mode 100644 index 00000000..e0cfc002 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/fivec.tex @@ -0,0 +1,444 @@ + +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.bp +.tc 5.3 A Sample File-to-File Copy Program +.he CP/M Operating System Manual 5.3 A Sample Copy Program +.sh +5.3 A Sample File-to-File Copy Program +.qs +.pp +The following program provides a relatively simple example of file +operations. The program source file is created as COPY.ASM using +the CP/M ED program and then assembled using ASM or MAC, resulting +in a HEX file. The LOAD program is used to produce a COPY.COM +file that executes directly under the CCP. The program begins +by setting the stack pointer to a local area and proceeds to move +the second name from the default area at 006CH to a 33-byte File +Control Block called DFCB. The DFCB is then prepared for file +operations by clearing the current record field. At this point, +the source and destination FCBs are ready for processing, because +the SFCB at 005CH is properly set up by the CCP upon entry to the +COPY program. That is, the first name is placed into the default +FCB, with the proper fields zeroed, including the current record +field at 007CH. The program continues by opening the source +file, deleting any existing destination file, and creating the destination +file. If all this is successful, the program loops at the label +COPY until each record is read from the source file and placed into the +destination file. Upon completion of the data transfer, the +destination file is closed and the program returns to the +CCP command level by jumping to BOOT. +.ll 75 +.sp 3 +.nf + ; sample file-to-file copy program + ; + ; at the ccp level, the command + ; + ; copy a:x.y b:u.v + ; + ; copies the file named x.y from drive + ; a to a file named u.v. on drive b. + ; +0000 = boot equ 0000h ;system reboot +0005 = bdos equ 0005h ;bdos entry point +005c = fcbl equ 005ch ;first file name +005c = sfcb equ fcbl ;source fcb +006c = fcb2 equ 006ch ;second file name +0080 = dbuff equ 0080h ;default buffer +0100 = tpa equ 0100h ;beginning of tpa + ; +0009 = printf equ 9 ;print buffer func# +000f = openf equ 15 ;open file func# +0010 = closef equ 16 ;close file func# +0013 = deletef equ 19 ;delete file func# +0014 = readf equ 20 ;sequential read +0015 = writef equ 21 ;sequential write +0016 = makef equ 22 ;make file func# + ; +0100 org tpa ;beginning of tpa +0100 311b02 lxi sp,stack ;local stack + ; + ; move second file name to dfcb +0103 0e10 mvi c,16 ;half an fcb +0105 116c00 lxi d,fcb2 ;source of move +0108 21da01 lxi h,dfcb ;destination fcb +010b 1a mfcb: Idax d ;source fcb +010c 13 inx d ;ready next +010d 77 mov m,a ;dest fcb +010e 23 inx h ;ready next +010f 0d dcr c ;count 16...0 +0110 c10b01 jnz mfcb ;loop 16 times + ; + ; name has been removed, zero cr +0113 af xra a ;a = 00h +0114 32fa01 sta dfcbcr ;current rec = 0 + ; + ; source and destination fcb's ready + ; +0117 115c00 lxi d,sfcb ;source file +011a cd6901 call open ;error if 255 +011d 118701 lxi d,nofile ;ready message +0120 3c inr a ;255 becomes 0 +0121 cc6101 cz finis ;done if no file + ; + ; source file open, prep destination +0124 11da01 lxi d,dfcb ;destination +0127 cd7301 call delete ;remove if present + ; +012a 11da01 lxi d,dfcb ;destination +012d cd8201 call make ;create the file +0130 119601 lxi d,nodir ;ready message +0133 3c inr a ;255 becomes 0 +0134 cc6101 cz finis ;done if no dir space + ; + ; source file open, dest file open + ; copy until end of file on source + ; +0137 115c00 copy: lxi d,sfcb ;source +013a cd7801 call read ;read next record +013d b7 ora a ;end of file? +013e c25101 jnz eofile ;skip write if so + ; + ; not end of file, write the record +0141 11da01 lix d,dfcb ;destination +0144 cd7d01 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 11da01 lxi d,dfcb ;destination +0154 cd6e01 call close ;255 if error +0157 21bb01 lxi h,wrprot ;ready message +015a 3c inr a ;255 becomes 00 +015b cc6101 cz finis ;shouldn't happen + ; + ; copy operation complete, end +015e 11cc01 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 system + ; + ; system interface subroutines + ; (all return directly from bdos) + ; +0169 0e0f open: mvi c,openf +016b c30500 jmp bdos + ; +016e 0e10 close: mvi c,closef +0170 c30500 jmp bdos + ; +0173 0e13 delete mvi c,deletef +0175 c30500 jmp bdos + ; +0178 0e14 read: mvi c,readf +017a c30500 jmp bdos + ; +017d 0e15 write: mvi c,writef +017f c30500 jmp bdos + ; +0182 0e16 make: mvi c,makef +0184 c30500 jmp bdos + ; + ; console messages +0187 6e6f20f nofile: db 'no source file$' +0196 6e6f209 nodir: db 'no directory space$' +01a9 6f7574f space: db 'out of dat space$' +01bb 7772695 wrprot: db 'write protected?$' +01cc 636f700 normal: db 'copy complete$' + ; + ; data areas +01da dfcb: ds 33 ;destination fcb +01fa dfcbcr equ dfcb+32 ;current record + ; +01fb ds 32 ;16 level stack + stack: +021b end +.ll 65 +.fi +.in 0 +.sp 2 +.pp +Note that there are several simplifications in this +particular program. First, there are no checks for invalid filenames +that could contain ambiguous references. This +situation could be detected by scanning the 32-byte default area +starting at location 005CH for ASCII question marks. A check +should also be make to ensure that the filenames have +been included (check locations 005DH and 006DH for nonblank ASCII +characters). Finally, a check should be made to ensure that the +source and destination filenames are different. An improvement +in speed could be obtained by buffering more data on each read +operation. One could, for example, determine the size of memory +by fetching FBASE from location 0006H and using the entire +remaining portion of memory for a data buffer. In this case, the +programmer simply resets the DMA address to the next successive +128-byte area before each read. Upon writing to the destination +file, the DMA address is reset to the beginning of the buffer and +incremented by 128 bytes to the end as each record is +transferred to the destination file. +.sp 2 +.he CP/M Operating System Manual 5.4 A Sample File Dump Utility +.tc 5.4 A Sample File Dump Utility +.sh +5.4 A Sample File Dump Utility +.qs +.pp +The following file dump program is slightly more complex than +the simple copy program given in the previous section. The dump +program reads an input file, specified in the CCP command line, +and displays the content of each record in hexadecimal format at +the console. Note that the dump program saves the CCP's stack +upon entry, resets the stack to a local area, and restores the +CCP's stack before returning directly to the CCP. Thus, the +dump program does not perform and warm start at the end of +processing. +.ll 75 +.sp 3 +.nf +x.in 5 + ;DUMP program reads input file and displays + hex data + ; +0100 org 100h +0005 = bdos equ 0005h = ;bdos entry point +0001 = cons equ 1 ;read console +0002 = typef equ 2 ;type function +0009 = printf equ 9 ;buffer print entry +000b = brkf equ 11 ;break key function + ;(true if char +000f = openf equ 15 ;file open +0014 = readf equ 20 ;read function + ; +005c = fcb equ 5ch ;file control block + ;address +0080 = buff equ 80h ;input disk buffer + ;address + ; + ; non graphic characters +000d = cr equ 0dh ;carriage return +000a = If equ 0ah ;line feed + ; + ; file control block definitions +005c = fcbdn equ fcb+0 ;disk name +005d = fcbfn equ fcb+1 ;file name +0065 = fcbft equ fcb+9 ;disk file type (3 + ;characters) +0068 = fcbrl equ fcb+12 ;file's current reel + ;number +006b = fcbrc equ fcb+15 ;file's record count (0 to + ;128)128) +007c = fcbcr' equ fcb+32 ;current (next) record + ;number (0 +007d = fcbin equ fcb+33 ;fcb length + ; + ; set up stack +0100 210000 lxi h,0 +0103 39 dad sp + ; entry stack pointer in hl from the ccp +0104 221502 shld oldsp + ; set sp to local stack area (restored at + ; finis) +0107 315702 lxi sp,stktop + ; read and print successive buffers +010a cdc101 call setup ;set up input file +010d feff cpi 255 ;255 if file not present +010f c21b01 jnz openok ;skip if open is ok + ; + ; file not there, give error message and + ; return +0112 11f301 lxi d,opnmsg +0115 cd9c01 call err +0118 c35101 jmp finis ;to return + ; + openok: ;open operation ok, set buffer index to + ;end +011b 3e80 mvi a,80h +011d 321302 sta ibp ;set buffer pointer to 80h + ; hl contains next address to print +0120 210000 lxi h,0 ;start with 0000 + ; + gloop: +0123 e5 push h ;save line position +0124 cda201 call gnb +0127 e1 pop h ;recall line position +0138 da5101 jc finis ;carry set by gnb if end + ;file +012b 47 mov b,a + ; print hex values + ; check for line fold +012c 7d + mov a,l +012d e60f ani 0fh ;check low 4 bits +012f c24401 jnz nonum + ; print line number +0132 cd7201 call crlf + ; + ; check for break key +0135 cd5901 call break + ; accum lsb = 1 if character ready +0138 0f rrc ;into carry +0139 da5101 jc finis ;don't print any more + ; +013c 7c mov a,h +013d cd8f01 call phex +0140 7d mov a,l +0141 cd8f01 call phex + nonum +0144 23 inx h ;to next line number +0145 3e20 mvi a,'' +0147 cd6501 call pchar +014a 78 mov a,b +014b cd8f01 call phex +014e c32301 jmp gloop + ; + finis + ; end of dump, return to cco + ; (note that a jmp to 0000h reboots) +0151 cd7201 call crif +0154 2a1502 lhld oldsp +0157 f9 sphl + ; stack pointer contains ccp's stack + ; location +0158 c9 ret ;to the ccp + ; + ; + ; subroutines + ; + break: ;check break key (actually any key will + ;do) +0159 e5d5c5 push h! push d! push b; environment + ;saved +015c 0e0b mvi c,brkf +015e cd0500 call bdos +0161 c1d1e1 pop b! pop d! pop h; environment + restored +0164 c9 ret + ; + pchar: ;print a character +0165 e5d5c5 push h! push d! push b; saved +0168 0e02 mvi c, typef +016a 5f mov e,a +016b cd0500 call bdos +016e c1d1e1 pop b! pop d! pop h; restored +0171 c9 ret + ; + crlf +0172 3e0d mvi a,cr +0174 cd6501 call pchar +0177 3e0a mvi a,lf +0179 cd6501 call pchar +017c c9 ret + ; + ; + pnib: ;print nibble in reg a +017d e60f ani ofh ;low 4 bits +017f fe0a cpi 10 +0181 d28901 jnc p10 + ; less than or equal to 9 +0184 c630 adi '0' +0186 c38b01 jmp prn + ; + ; greater or equal to 10 +0189 c637 p10: adi 'a' - 10 +018b cd6501 prn: call pchar +018e c9 ret + ; + phex ;print hex char in reg a +018f f5 pushpsw +0190 0f rrc +0191 0f rrc +0192 0f rrc +0193 0f rrc +0194 cd7d01 call pnib ;print nibble +0197 f1 pop psw +0198 cd7d01 call pnip +019b c9 ret + ; + err: ;print error message + ; d,e addresses message ending with "$" +019c 0e09 mvi c,printf ;print buffer + ;function +019e cd0500 call bdos +01a1 c9 ret + ; + ; + gnb: ;get next byte +01a2 3a1302 lda ibp +01a5 fe80 cpi 80h +01a7 c2b301 jnz g0 + ; read another buffer + ; + ; + 01aa cdce01 call diskr +01ad b7 ora a ;zero value if read ok +01ae cab301 jz g0 ;for another byte + ; end of data, return with carry set for eof +01b1 37 stc +01b2 c9 ret + ; + g0: ;read the byte at buff+reg a +01b3 5f mov e,a ;Is byte of buffer index +01b4 1600 mvi d,0 ;double precision + ;index to de +01b6 3c inr a ;index=index+1 +01b7 321302 sta ibp ;back to memory + ; pointer is incremented + ; save the current file address +01ba 218000 lxi h,buff +01bd 19 dad d + ; absolute character address is in hl +01be 7e mov a,m + ; byte is in the accumulator +01bf b7 ora a ;reset carry bit +01c0 c9 ret + ; + setup: ;set up file + ; open the file for input +01c1 af xra a ;zero to accum +01c2 327c00 sta fcbcr ;clear current record + ; +01c5 115c00 lxi d,fcb +01c8 0e0f mvi c,openf +01ca cd0500 call bdos + ; 255 in accum if open error +01cd c9 ret + ; + diskr: ;read disk file record +01ce e5d5c5 push h! push d! push b +01d1 115c00 lxi d,fcb +01d4 0e14 mvi c,readf +01d6 cd0500 call bdos +01d9 c1d1e1 pop b! pop d! pop h +01dc c9 ret + ; + ; fixed message area +01dd 46494c0 signon: db 'file dump version 2.0$' +01f3 0d0a4e0 opnmsg: db cr,lf,'no input file present on + disk$' + + ; variable area +0213 ibp: ds 2 ;input buffer pointer +0215 oldsp: ds 2 ;entry sp value from ccp + ; + ; stack area +0217 ; ds 64 ;reserve 32 level stack + stktop: + ; +0257 end +.ll 65 +.fi +.in 0 +.nx fived + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/fived.tex b/Source/Doc/CPM 22 Manual - Testing/fived.tex new file mode 100644 index 00000000..49bf9f2b --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/fived.tex @@ -0,0 +1,497 @@ +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.sp 3 +.he CP/M Operating System Manual 5.5 Sample Random Access Program +.sh +5.5 A Sample Random Access Program +.qs +.tc 5.5 A Sample Random Access Program +.pp +This chapter concludes with an extensive example of random access operation. +The program listed below performs the simple function of reading or writing +random records upon command from the terminal. When a +program has been created, assembled, and placed into a file +labeled RANDOM.COM, the CCP level command +.sp +.ti 8 +RANDOM X.DAT +.sp +starts the test program. The program looks for a file by the +name X.DAT and, if found, proceeds to prompt the console for +input. If not found, the file is created before the prompt is +given. Each prompt takes the form +.sp +.ti 8 +next command? +.sp +and is followed by operator input, followed by a carriage +return. The input commands take the form +.sp +.ti 8 +nW nR Q +.sp +where n is an integer value in the range 0 to 65535, and W, R, +and Q are simple command characters corresponding to random +write, random read, and quit processing, respectively. If the W +command is issued, the RANDOM program issues the prompt +.sp +.ti 8 +type data: +.sp +The operator then responds by typing up to 127 characters, +followed by a carriage return. RANDOM then writes the character +string into the X.DAT file at record n. If the R command is +issued, RANDOM reads record number n and displays the string +value at the console, If the Q command is issued, the X.DAT file +is closed, and the program returns to the CCP. In the interest +of brevity, the only error message is +.sp +.ti 8 +error, try again. +.pp +The program begins with an initialization section where the input +file is opened or created, followed by a continuous loop at the +label ready where the individual commands are interpreted. The +DFBC at 005CH and the default buffer at 0080H are used in all +disk operations. The utility subroutines then follow, which +contain the principal input line processor, called readc. This +particular program shows the elements of random access +processing, and can be used as the basis for further program +development. +.ll 75 +.sp 3 +.nf +.sh + Sample Random Access Program for CP/M 2.0 +.qs + +0100 org 100h ;base of tpa + ; +0000 = reboot equ 0000h ;system reboot +0005 = bdos equ 0005h ;bdos entry point + ; +0001 = coninp equ 1 ;console input function +0002 = conout equ 2 ;console output function +0009 = pstring equ 9 ;print string until '$' +000a = rstring equ 10 ;read console buffer +000c = version equ 12 ;return version number +000f = openf equ 15 ;file open function +0010 = closef equ 16 ;close function +0016 = makef equ 22 ;make file function +0021 = readr equ 33 ;read random +0022 = writer equ 34 ;write random + ; +005c = fcb equ 005ch ;default file control + ;block +007d = ranrec equ fcb+33 ;random record position +007f = ranovf equ fcb+35 ;high order (overflow) + ;byte +0080 = buff equ 0080h ;buffer address + ; +000d = cr equ 0dh ;carriage return +000a = lf equ 0ah ;line feed + ; + + +.sh + Load SP, Set-Up File for Random Access +.qs + +0100 31bc00 lxi sp,stack + ; + ; version 2.0 +0103 0e0c mvi c,version +0105 cd0500 call bdos +0108 fe20 cpi 20h ;version 2.0 or better? +010a d21600 jnc versok + ; bad version, message and go back +010d 111b00 lxi d,badver +0110 cdda00 call print +0113 c30000 jmp reboot + ; + versok: + ; correct versionm for random access +0116 0e0f mvi c,openf ;open default fcb +0118 115c00 lxi d,fcb +011b cd 0500 call bdos +011e 3c inr a ;err 255 becomes zero +011f c23700 jnz ready + ; + ; connot open file, so create it +0122 0e16 mvi c,makef +0124 115c00 lxi d,fcb +0127 cd0500 call bdos +012a 3c inr a ;err 255 becomes zero +012b c23700 jnz ready + ; + ; cannot create file, directory full +012e 113a00 lxi d,nospace +0131 cdda00 call print +0134 c30000 jmp reboot ;back to ccp +.sp 2 +.sh + Loop Back to Ready After Each Command +.qs +.sp + ; + ready: + ; file is ready for processing + ; +0137 cde500 call readcom ;read next command +013a 227d00 shld ranrec ;store input record# +013d 217f00 lxi h,ranovf +0140 3600 mvi m,0 ;clear high byte if set +0142 fe51 cpi 'Q' ;quit? +0144 c25600 jnz notq + ; + ; quit processing, close file +0147 0e10 mvi c,closef +0149 115c00 lxi d,fcb +014c cd0500 call bdos +014f 3c inr a ;err 255 becomes 0 +0150 cab900 jz error ;error message, retry +0153 c30000 jmp reboot ;back to ccp + ; +.sp 2 +.sh + End of Quit Command, Process Write +.qs +.sp + notq: + ; not the quit command, random write? +0156 fe57 cpi 'W' +0158 c28900 jnz notw + ; + ; this is a random write, fill buffer untill cr +015b 114d00 lxi d,datmsg +015e cdda00 call print ;data prompt +0161 0e7f mvi c,127 ;up to 127 characters +0163 218000 lxi h,buff ;destination + rloop: ;read next character to buff +0166 c5 push b ;save counter +0167 e5 push h ;next destination +0168 cdc200 call getchr ;character to a +016b e1 pop h ;restore counter +016c c1 pop b ;restore next to fill +016d fe0d cpi cr ;end of line? +016f ca7800 jz erloop + ; not end, store character +0172 77 mov m,a +0173 23 inx h ;next to fill +0174 0d dcr c ;counter goes down +0175 c26600 jnz rloop ;end of buffer? + erloop: + ; end of read loop, store 00 +0178 3600 mvi m,0 + ; + ; write the record to selected record number +017a 0e22 mvi c,writer +017c 115c00 lxi d,fcb +017c cd0500 call bdos +0182 b7 ora a ;erro code zero? +0183 c2b900 jnz error ;message if not +0186 c33700 jmp ready ;for another record + ; +.sp 2 +.sh + End of Write Command, Process Read +.qs +.sp + notw: + ; not a write command, read record? +0189 fe52 cpi 'R' +018b c2b900 jnz error ;skip if not + ; + ; read random record +018e 0e21 mvi c,readr +0190 115c00 lxi d,fcb +0193 cd0500 call bdos +0196 b7 ora a ;return code 00? +0197 c2b900 jnz error + ; + ; read was successful, write to console +019a cdcf00 call crlf ;new line +019d 0e80 mvi c,128 ;max 128 characters +019f 218000 lxi h,buff ;next to get + wloop: +01a2 7e mov a,m ;next character +01a3 23 inx h ;next to get +01a4 e67f ani 7fh ;mask parity +01a6 ca3700 jz ready ;for another command + ;if 00 +01a9 c5 push b ;save counter +01aa e5 push h ;save next to get +01ab fe20 cpi '' ;graphic? +01ad d4c800 cnc putchr ;skip output if not +01b0 e1 pop h +01b1 c1 pop b +01b2 0d dcr c ;count=count-1 +01b3 c2a200 jnz wloop +01b6 c33700 jmp ready +.bp +.sh + End of Read Command, All Errors End Up Here +.qs +.sp + ; + error: +01b9 115900 lxi d,errmsg +01bc cdda00 call print +01bf c33700 jmp ready + ; +.sp 2 +.sh + Utility Subroutines for Console I/O +.qs +.sp + getchr: + ;read next console character to a +01c2 0e01 mvi c,coninp +01c4 cd0500 call bdos +01c7 c9 ret + ; + putchr: + ;write character from a to console +01c8 0e02 mvi c,conout +01ca 5f mov e,a ;character to send +01cb cd0500 call bdos ;send character +01ce c9 ret + ; + crlf: + ;send carriage return line feed +01cf 3e0d mvi a,cr ;carriage return +01d1 cdc800 call putchr +01d4 3e0a mvi a,lf ;line feed +01d6 cdc800 call putchr +01d9 c9 ret + ; + print: + ;print the buffer addressed by de untill $ +01da d5 push d +01db cdcf00 call crlf +01de d1 pop d ;new line +01df 0e09 mvi c,pstring +01e0 cd0500 call bdos ;print the string +01e4 c9 ret + ; + readcom: + ;read the next command line to the conbuf +01e5 116b00 lxi d,prompt +01e8 cdda00 call print ;command? +01eb 0e0a mvi c,rstring +01ed 117a00 lxi d,conbuf +01f0 cd0500 call bdos ;read command line + ; command line is present, scan it +01f3 210000 lxi h,0 ;start with 0000 +01f6 117c00 lxi d,conlin ;command line +01f9 1a readc: ldax d ;next command + ;character +01fa 13 inx d ;to next command + ;position +01fb b7 ora a ;cannot be end of + ;command +01fc c8 rz + ; not zero, numeric? +01fd d630 sui '0' +01ff fe0a cpi 10 ;carry if numeric +0201 d21300 jnc endrd + ; add-in next digit +0204 29 dad h ;*2 +0205 4d mov c,l +0206 44 mov b,h ;bc = value * 2 +0207 29 dad h ;*4 +0208 29 dad h ;*8 +0209 09 dad b ;*2 + *8 = *10 +020a 85 add l ;*digit +020b 6f mov l,a +020c d2f900 jnc readc ;for another char +020f24 inr h ;overflow +0210 c3f900 jmp readc ;for another char + endrd: + ; end of read, restore value in a +0213 c630 adi '0' ;command +0215 fe61 cpi 'a' ;translate case? +0217 d8 rc + ; lower case, mask lower case bits +0218 e65f ani 101$1111b +021a c9 ret + ; +.sp 2 +.sh + String Data Area for Console Messages +.qs +.sp + badver: +021b 536f79 db 'sorry, you need cp/m version 2$' + nospace: +023a 4e6f29 db 'no directory space$' + datmsg: +024d 547970 db 'type data: $' + errmsg: +0259 457272 db 'error, try again.$' + prompt: +026b 4e6570 db 'next command? $' + ; +.sp 2 +.mb 5 +.fm 1 +.sh + Fixed and Variable Data Area +.qs +.sp +027a 21 conbuf: db conlen ;length of console buffer +027b consiz: ds 1 ;resulting size after read +027c conlin: ds 32 ;length 32 buffer +0021 = conlen equ $-consiz + ; +029c ds 32 ;16 level stack + stack: +02bc end +.ll 65 +.fi +.pp +Major improvements could be made to this particular program to enhance +its operation. In fact, with some work, this program could +evolve into a simple data base management system. One could, for +example, assume a standard record size of 128 bytes, consisting +to arbitrary fields within the record. A program, called GETKEY, +could be developed that first reads a sequential file and +extracts a specific field defined by the operator. For example, +the command +.mb 6 +.fm 2 +.sp +.ti 8 +GETKEY NAMES.DAT LASTNAME 10 20 +.sp +would cause GETKEY to read the data base file NAMES.DAT and +extract the LAST-NAME field from each record, starting in +position 10 and ending at character 20. GETKEY builds a table in +memory consisting of each particular LASTNAME field, along with +its 16-bit record number location within the file. The GETKEY +program then sorts this list and writes a new file, called +LASTNAME.KEY, which is an alphabetical list of LASTNAME fields +with their corresponding record numbers. This list is called an +inverted index in information retrieval parlance. +.pp +If the programmer were to rename the program shown above as QUERY +and modify it so that it reads a sorted key file into memory, +the command line might appear as +.sp +.ti 8 +QUERY NAMES.DAT LASTNAME.KEY +.sp +Instead of reading a number, the QUERY program reads an +alphanumeric string that is a particular key to find in the +NAMES.DAT data base. Because the LASTNAME.KEY list is sorted, one +can find a particular entry rapidly by performing a binary +search, similar to looking up a name in the telephone book. +Starting at both ends of the list, one examines the +entry halfway in between and, if not matched, splits either the +upper half or the lower half for the next search. You will +quickly reach the item you are looking for and find the +corresponding record number. You should fetch and display +this record at the console, just as was done in the program shown +above. +.pp +With some more work, you can allow a fixed grouping size +that differs from the 128-byte record shown above. This is +accomplished by keeping track of the record number and the +byte offset within the record. Knowing the group size, you +randomly access the record containing the proper group, offset +to the beginning of the group within the record read sequentially +until the group size has been exhausted. +.pp +Finally, you can improve QUERY considerably by allowing boolean +expressions, which compute the set of records that satisfy +several relationships, such as a LASTNAME between HARDY and +LAUREL and an AGE lower than 45. Display all the records that +fit this description. Finally, if your lists are getting +too big to fit into memory, randomly access key +files from the disk as well. +.bp +.tc 5.6 System Function Summary +.he CP/M Operating System Manual 5.6 System Function Summary +.sh +5.6 System Function Summary +.qs +.sp +.nf +Function Function Input Output +Number Name +.sp +Decimal Hex +.sp + 0 0 System Reset C = 00H none + 1 1 Console Input C = 01H A = ASCII char + 2 2 Console Output E = char none + 3 3 Reader Input A = ASCII char + 4 4 Punch Output E = char none + 5 5 List Output E = char none + 6 6 Direct Console I/O C = 06H A = char or status + + E = 0FFH (input) or (no value) + 0FEH (status) or + char (output) + 7 7 Get I/O Byte none A = I/O byte + Value + 8 8 Set I/O Byte E = I/O Byte none + 9 9 Print String DE = Buffer Address none +10 A Read Console Buffer DE = Buffer Console + Characters + in Buffer +11 B Get Console Status none A = 00/non zero +12 C Return Version Number none HL: Version + Number +13 D Reset Disk System none none +14 E Select Disk E = Disk Number none +15 F Open File DE = FCB Address FF if not found +16 10 Close File DE = FCB Address FF if not found +17 11 Search For First DE = FCB Address A = Directory + Code +18 12 Search For Next none A = Directory + Code +19 13 Delete File DE = FCB Address A = none +20 14 Read Sequential DE = FCB Address A = Error Code +21 15 Write Sequential DE = FCB Address A = Error Code +22 16 Make File DE = FCB Address A = FF if no DIR + Space +23 17 Rename File DE = FCB Address A = FF in not + found +24 18 Return Login Vector none HL = Login + Vector* +25 19 Return Current Disk none A = Current Disk + Number +26 1A Set DMA Address DE = DMA Address none +27 1B Get ADDR (ALLOC) none HL = ALLOC + Address* +28 1C Write Protect Disk none none +29 1D Get Read/only Vector none HL = R/O + Vector Value* +30 1E Set File Attributes DE = FCB Address A = none +31 1F Get ADDR (Disk Parms) none HL = DPB + Address +32 20 Set/Get User Code E = 0FFH for Get User Number + E = 00 to 0FH for Set +33 21 Read Random DE = FCB Address A = Error Code +34 22 Write Random DE = FCB Address A = Error Code +35 23 Compute File Size DE = FCB Address r0, r1, r2 +36 24 Set Random Record DE = FCB Address r0, r1, r2 +37 25 Reset Drive DE = Drive Vector A = 0 +38 26 Access Drive not supported +39 27 Free Drive not supported +40 28 Write Random with Fill DE = FCB A = Error Code +.fi +.sp 4 +*Note that A = L, and B = H upon return. +.sp 2 +.ce +End of Section 5 +.nx sixa + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/foura.tex b/Source/Doc/CPM 22 Manual - Testing/foura.tex new file mode 100644 index 00000000..9f90f979 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/foura.tex @@ -0,0 +1,693 @@ + +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 4-% +.pc 1 +.tc 4 CP/M Dynamic Debugging Tool +.nf +.sh + Section 4 +.sp +.sh + CP/M Dynamic Debugging Tool +.qs +.fi +.sp 3 +.tc 4.1 Introduction +.he CP/M Operating System Manual 4.1 Introduction +.sh +4.1 Introduction +.pp 5 +The DDT program allows dynamic interactive testing and debugging of +programs generated in the CP/M environment. Invoke the debugger with +a command of one of the following forms: +.sp +.in 8 +.nf +DDT +DDT filename.HEX +DDT filename.COM +.fi +.in 0 +.sp +where filename is the name of the program to be loaded and +tested. In both cases, the DDT program is brought into main +memory in place of the Console Command Processor (CCP) and resides +directly below the Basic Disk Operating System (BDOS) +portion of CP/M. Refer to Section 5 for standard memory +organization. The BDOS +starting address, located in the address field of the +JMP instruction at location 5H, is altered to reflect the +reduced Transient Program Area (TPA) size. +.pp +The second and third forms of the DDT command perform the same +actions as the first, except there is a subsequent automatic load +of the specified HEX or COM file. The action is identical to the +following sequence of commands: +.sp +.in 8 +.nf +DDT +Ifilename.HEX or Ifilename.COM +R +.fi +.in 0 +.sp +where the I and R commands set up and read the specified program +to test. See the explanation of the I and R +commands below for exact details. +.pp +Upon initiation, DDT prints a sign-on message in the form: +.sp +.ti 8 +DDT VER m.m +.sp +where m.m is the revision number. +.pp +Following the sign-on message, DDT prompts you with the +hyphen character, -, and waits for input commands from the +console. You can type any of several single-character commands, +followed by a carriage return to execute the command. Each +line of input can be line-edited using the following standard +CP/M controls: +.bp +.ce +.sh +Table 4-1. Line-editing Controls +.ll 60 +.sp +.in 5 +.nf +Control Result +.sp +rubout removes the last character typed + +CTRL-U removes the entire line, ready for retyping + +CTRL-C reboots system +.fi +.in 0 +.ll 65 +.sp +.pp +Any command can be up to 32 characters in length. An automatic +carriage return is inserted as character 33, where the +first character determines the command type. Table 4-2 describes DDT +commands. +.sp 2 +.sh + Table 4-2. DDT Commands +.sp +.nf + Command Result + Character +.fi +.sp +.ll 57 +.in 16 +.ti -9 +A enters assembly-language mnemonics with operands. +.sp +.ti -9 +D displays memory in hexadecimal and ASCII. +.sp +.ti -9 +F fills memory with constant data. +.sp +.ti -9 +G begins execution with optional breakpoints. +.sp +.ti -9 +I sets up a standard input File Control Block. +.sp +.ti -9 +L lists memory using assembler mnemonics. +.sp +.ti -9 +M moves a memory segment from source to destination. +.sp +.ti -9 +R reads a program for subsequent testing. +.sp +.ti -9 +S substitutes memory values. +.sp +.ti -9 +T traces program execution. +.sp +.ti -9 +U untraced program monitoring. +.sp +.ti -9 +X examines and optionally alters the CPU state. +.in 0 +.ll 65 +.mb 4 +.fm 1 +.sp 2 +The command character, in some cases, is followed by zero, one, +two, or three hexadecimal values, which are separated by commas +or single blank characters. All DDT numeric output is in +hexadecimal form. The commands are not execution until the +carriage return is typed at the end of the command. +.pp +At any point in the debug run, you can stop execution of +DDT by using either a CTRL-C or G0 (jump to location 0000H) and +save the current memory image by using a SAVE command of the form: +.sp +.ti 8 +SAVE n filename. COM +.sp +where n is the number of pages (256 byte blocks) to be saved on +disk. The number of blocks is determined by taking the high-order +byte of the address in the TPA and converting this number to +decimal. For example, if the highest address in the TPA is 134H, +the number of pages is 12H or 18 in decimal. You could type a +CTRL-C during the debug run, returning to the CCP level, followed +by +.mb 6 +.fm 2 +.sp +.ti 8 +SAVE 18 X.COM +.sp +The memory image is saved as X.COM on the disk and can be +directly executed by typing the name X. If further testing is +required, the memory image can be recalled by typing +.sp +.ti 8 +DDT X.COM +.sp +which reloads the previously saved program from location 100H +through page 18, 23FFH. The CPU state is not a part of the COM +file; thus, the program must be restarted from the beginning to +test it properly. +.sp 2 +.tc 4.2 DDT Commands +.he CP/M Operating System Manual 4.2 DDT Commands +.sh +4.2 DDT Commands +.pp +The individual commands are detailed below. In each case, the +operator must wait for the hyphen prompt character before entering +the command. If control is passed to a program under test, and +the program has not reached a breakpoint, control can be returned +to DDT by executing a RST 7 from the front panel. In the +explanation of each command, the command letter is shown in some +cases with numbers separated by commas, the the numbers are +represented by lower-case letters. These numbers are always +assumed to be in a hexadecimal radix and from one to four digits +in length. Longer numbers are automatically truncated on the +right. +.pp +Many of the commands operate upon a CPU state that corresponds +to the program under test. The CPU state holds the registers of +the program being debugged and initially contains zeros for all +registers and flags except for the program counter, P, and stack +pointer, S, which default to 100H. The program counter is +subsequently set to the starting address given in the last record +of a HEX file if a file of this form is loaded, see the I and R +commands. +.sp 2 +.tc 4.2.1 The A (Assembly) Command +.sh +4.2.1 The A (Assembly) Command +.pp +DDT allows in-line assembly language to be inserted into the +current memory image using the A command, which takes the form: +.sp +.ti 8 +As +.sp +where s is the hexadecimal starting address for the in-line +assembly. DDT prompts the console with the address of the next +instruction to fill and reads the console, looking for assembly-language +mnemonics followed by register references and operands in +absolute hexadecimal form. See the \c +.ul +Intel 8080 Assembly Language Reference Card \c +.qu +for a list of mnemonics. Each +successive load address is printed before reading the console. +The A command terminates when the first empty line is input from +the console. +.pp +Upon completion of assembly language input, you can +review the memory segment using the DDT disassembler (see the L +command). +.pp +Note that the assembler/disassembler portion of +DDT can be overlaid by the transient program being tested, in +which case the DDT program responds with an error condition when +the A and L commands are used. +.sp 2 +.tc 4.2.2 The D (Display) Command +.sh +4.2.2 The D (Display) Command +.pp +The D command allows you to view the contents of memory +in hexadecimal and ASCII formats. The D command takes the forms: +.sp +.in 8 +.nf +D +Ds +Ds,f +.fi +.in 0 +.pp +In the first form, memory is displayed from the current display +address, initially 100H, and continues for 16 display lines. +Each display line takes the followng form: +.sp +.nf +aaaa bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb cccccccccccccccc +.fi +.sp +where aaaa is the display address in hexadecimal and bb +represents data present in memory starting at aaaa. The ASCII +characters starting at aaaa are to the right (represented by the +sequence of character c) where nongraphic characters are printed as a +period. You should note that both upper- and lower-case +alphabetics are displayed, and will appear as upper-case symbols +on a console device that supports only upper-case. Each display +line gives the values of 16 bytes of data, with the first line +truncated so that the next line begins at an address that is a +multiple of 16. +.pp +The second form of the D command is similar to the first, except +that the display address is first set to address s. +.pp +The third form causes the display to continue from address s +through address f. In all cases, the display address is set to +the first address not displayed in this command, so that a +continuing display can be accomplished by issuing successive D +commands with no explicit addresses. +.pp +Excessively long displays can be aborted by pressing the return key. +.sp 2 +.tc 4.2.3 The F (Fill) Command +.sh +4.2.3 The F (Fill) Command +.pp +The F command takes the form: +.sp +.ti 8 +Fs,f,c, +.sp +where s is the starting address, f is the final address, and c is +a hexadecimal byte constant. DDT stores the constant c at +address s, increments the value of s and test against f. If s +exceeds f, the operation terminates, otherwise the operation is +repeated. Thus, the fill command can be used to set a memory +block to a specific constant value. +.sp 2 +.tc 4.2.4 The G (Go) Command +.sh +4.2.4 The G (Go) Command +.pp +A program is executed using the G command, with up to two +optional breakpoint addresses. The G command takes the forms: +.sp 2 +.in 8 +.nf +G +Gs +Gs,b +Gs,b,c +G,b +G,b,c +.fi +.in 0 +.sp +.pp +The first form executes the program at the current value of the +program counter in the current machine state, with no breakpoints +set. The only way to regain control in DDT is through a RST 7 +execution. The current program counter can be viewed by typing +an X or XP command. +.pp +The second form is similar to the first, except that the program +counter in the current machine state is set to address s before +execution begins. +.pp +The third form is the same as the second, except that program +execution stops when address b is encountered (b must be in the +area of the program under test). The instruction at location b is +not executed when the breakpoint is encountered. +.pp +The fourth form is identical to the third, except that two +breakpoints are specified, one at b and the other at c. +Encountering either breakpoint causes execution to stop, and both +breakpoints are cleared. The last two forms take the program +counter from the current machine state and set one and two +breakpoints, respectively. +.pp +Execution continues from the starting address in real-time to the +next breakpoint. There is no intervention between the starting +address and the break address by DDT. If the program under test +does not reach a breakpoint, control cannot return to DDT without +executing a RST 7 instruction. Upon encountering a breakpoint, +DDT stops execution and types +.sp +.ti 8 +*d +.sp +where d is the stop address. The machine state can be examined +at this point using the X (Examine) command. You must +specify breakpoints that differ from the program counter address +at the beginning of the G command. Thus, if the current program +counter is 1234H, then the following commands: +.sp +.nf +.in 8 +G,1234 +G400,400 +.fi +.in 0 +.sp +both produce an immediate breakpoint without executing any +instructions. +.sp 2 +.tc 4.2.5 The I (Input) Command +.sh +4.2.5 The I (Input) Command +.pp +The I command allows you to insert a filename into the default +File Control Block (FCB) at 5CH. The FCB created by CP/M for +transient programs is placed at this location (see Section 5). +The default FCB can be used by the program under test as if it +had been passed by the CP/M Console Processor. Note that this +filename is also used by DDT for reading additional HEX and COM +files. The I command takes the forms: +.sp +.nf +.in 8 +Ifilename +Ifilename.typ +.fi +.in 0 +.pp +If the second form is used and the filetype is either HEX or COM, +subsequent R commands can be used to read the pure binary or hex +format machine code. Section 4.2.8 gives further details. +.sp 2 +.tc 4.2.6 The L (List) Command +.sh +4.2.6 The L (List) Command +.pp +The L command is used to list assembly-language mnemonics in a +particular program region. The L command takes the forms: +.sp +.in 8 +.nf +L +Ls +Ls,f +.fi +.in 0 +.pp +The first form lists twelve lines of disassembled machine code +from the current list address. The second form sets the list +address to s and then lists twelve lines of code. The last form +lists disassembled code from s through address f. In all three +cases, the list address is set to the next unlisted location in +preparation for a subsequent L command. Upon encountering an +execution breakpoint, the list address is set to the current +value of the program counter (G and T commands). Again, long +typeouts can be aborted by pressing RETURN during the list +process. +.sp 2 +.tc 4.2.7 The M (Move) Command +.sh +4.2.7 The M (Move) Command +.pp +The M command allows block movement of program or data areas from +one location to another in memory. The M command takes the form: +.sp +.ti 8 +Ms,f,d +.sp +where s is the start address of the move, f is the final address, +and d is the destination address. Data is first removed from s +to d, and both addresses are incremented. If s exceeds f, the +move operation stops; otherwise, the move operation is repeated. +.sp 2 +.tc 4.2.8 The R (Read) Command +.sh +4.2.8 The R (Read) Command +.pp +The R command is used in conjunction with the I command to read +COM and HEX files from the disk into the transient program +area in preparation for the debug run. The R command takes the forms: +.sp +.in 8 +.nf +R +RB +.fi +.in 0 +.sp +where b is an optional bias address that is added to each program +or data address as it is loaded. The load operation must not +overwrite any of the system parameters from 000H through 0FFH +(that is, the first page of memory). If b is omitted, then +b=0000 is assumed. The R command requires a previous I command, +specifying the name of a HEX or COM file. The load address for +each record is obtained from each individual HEX record, while an +assumed load address of 100H is used for COM files. Note that +any number of R commands can be issued following the I command to +reread the program under test, assuming the tested program does +not destroy the default area at 5CH. Any file specified with the +filetype COM is assumed to contain machine code in pure binary +form (created with the LOAD or SAVE command), and all others are +assumed to contain machine code in Intel hex format (produced, +for example, with the ASM command). +.pp +Recall that the command, +.sp +.ti 8 +DDT filename.filetype +.sp +which initiates the DDT program, equals to the following commands: +.sp +.in 8 +.nf +DDT +-Ifilename.filetype +-R +.fi +.in 0 +.bp +.pp +Whenever the R command is issued, DDT responds with either the +error indicator ? (file cannot be opened, or a checksum error +occurred in a HEX file) or with a load message. The load message +takes the form: +.sp +.in 8 +.nf +NEXT PC +nnnn pppp +.fi +.in 0 +.sp +where nnnn is the next address following the loaded program and +pppp is the assumed program counter (100H for COM files, or +taken from the last record if a HEX file is specified). +.sp 2 +.tc 4.2.9 The S (Set) Command +.sh +4.2.9 The S (Set) Command +.pp +The S command allows memory locations to be examined and +optionally altered. The S command takes the form: +.sp +.ti 8 +Ss +.sp +where s is the hexadecimal starting address for examination and +alteration of memory. DDT responds with a numeric prompt, giving +the memory location, along with the data currently held in +memory. If you type a carriage return, the data is +not altered. If a byte value is typed, the value is stored at +the prompted address. In either case, DDT continues to prompt +with successive addresses and values until you type either a period +or an invalid input value is detected. +.sp 2 +.tc 4.2.10 The T (Trace) Command +.sh +4.2.10 The T (Trace) Command +.pp +The T command allows selective tracing of program execution for 1 +to 65535 program steps. The T command takes the forms: +.sp +.in 8 +.nf +T +Tn +.fi +.in 0 +.mb 4 +.fm 1 +.pp +In the first form, the CPU state is displayed and the next +program step is executed. The program terminates immediately, +with the termination address displayed as +.sp +.ti 8 +*hhhh +.sp +where hhhh is the next address to execute. The display address +(used in the D command) is set to the value of H and L, and the +list address (used in the L command) is set to hhhh. The CPU +state at program termination can then be examined using the X +command. +.pp +The second form of the T command is similar to the first, except +that execution is traced for n steps (n is a hexadecimal value) +before a program breakpoint occurs. A breakpoint can be forced +in the trace mode by typing a rubout character. The CPU state is +displayed before each program step is taken in trace mode. The +format of the display is the same as described in the X command. +.mb 6 +.fm 2 +.pp +You should note that program tracing is discontinued at the +CP/M interface and resumes after return from CP/M to the program +under test. Thus, CP/M functions that access I/O devices, such +as the disk drive, run in real-time, avoiding I/O timing +problems. Programs running in trace mode execute approximately +500 times slower than real-time because DDT gets control after each +user instruction is executed. Interrupt processing routines can +be traced, but commands that use the breakpoint facility (G, T, +and U) accomplish the break using an RST 7 instruction, which +means that the tested program cannot use this interrupt location. +Further, the trace mode always runs the tested program with +interrupts enabled, which may cause problems if asynchronous +interrupts are received during tracing. +.pp +To get control back to DDT during trace, press RETURN rather than +executing an RST 7. This ensures that the trace for current +instruction is completed before interruption. +.sp 2 +.tc 4.2.11 The U (Untrace) Command +.sh +4.2.11 The U (Untrace) Command +.pp +The U command is identical to the T command, except that +intermediate program steps are not displayed. The untrace mode +allows from 1 to 65535, (0FFFFH) steps to be executed in monitored +mode and is used principally to retain control of an executing +program while it reaches steady state conditions. All conditions +of the T command apply to the U command. +.sp 2 +.tc 4.2.12 The X (Examine) Command +.sh +4.2.12 The X (Examine) Command +.pp +The X command allows selective display and alteration of the +current CPU state for the program under test. The X command +takes the forms: +.sp +.in 8 +.nf +X +Xr +.fi +.in 0 +.sp +where r is one of the 8080 CPU registers listed in the following table. +.sp 2 +.sh + Table 4-3. CPU Registers +.sp +.nf + Register Meaning Value +.sp + C Carry flag (0/1) + Z Zero flag (0/1) + M Minus flag (0/1) + E Even parity flag (0/1) + I Interdigit carry (0/1) + A Accumulator (0-FF) + B BC register pair (0-FFFF) + D DE register pair (0-FFFF) +.bp +.sh + Table 4-3. (continued) +.sp +.nf + Register Meaning Value +.sp + H HL register pair (0-FFFF) + S Stack pointer (0-FFFF) + P Program counter (0-FFFF) +.fi +.sp 2 +In the first case, the CPU register state is displayed in the +format: +.sp +.ti 8 +CfZfMfEflf A=bb B=dddd D=dddd H=dddd S=dddd P=dddd inst +.sp +where f is a 0 or 1 flag value, bb is a byte value, and dddd is a +double-byte quantity corresponding to the register pair. The +inst field contains the disassembled instruction, that occurs at +the location addressed by the CPU state's program counter. +.pp +The second form allows display and optional alteration of +register values, where r is one of the registers given above (C, +Z, M, E, I, A, B, D, H, S, or P). In each case, the flag or +register value is first displayed at the console. The DDT +program then accepts input from the console. If a carriage +return is typed, the flag or register value is not altered. If +a value in the proper range is typed, the flag or register value +is altered. You should note that BC, DE, and HL are +displayed as register pairs. Thus, you must type the entire +register pair when B, C, or the BC pair is altered. +.sp 2 +.tc 4.3 Implementation Notes +.he CP/M Operating System Manual 4.3 Implementation Notes +.sh +4.3 Implementation Notes +.pp +The organization of DDT allows certain nonessential portions to +be overlaid to gain a larger transient program area for debugging +large programs. The DDT program consists of two parts: the DDT +nucleus and the assembler/disassembler module. The DDT nucleus +is loaded over the CCP and, although loaded with the DDT nucleus, +the assembler/disassembler is overlayable unless used to assemble +or disassemble. +.pp +In particular, the BDOS address at location 6H (address field of +the JMP instruction at location 5H) is modified by DDT to address +the base location of the DDT nucleus, which, in turn, contains a +JMP instruction to the BDOS. Thus, programs that use this +address field to size memory see the logical end of memory at the +base of the DDT nucleus rather than the base of the BDOS. +.pp +The assembler/disassembler module resides directly below the DDT +nucleus in the transient program area. If the A, L, T, or X +commands are used during the debugging process, the DDT program +again alters the address field at 6H to include this module, +further reducing the logical end of memory. If a program loads +beyond the beginning of the assembler/disassembler module, the A +and L commands are lost (their use produces a ? in response) +and the trace and display (T and X) commands list the inst field +of the display in hexadecimal, rather than as a decoded +instruction. +.nx fourb + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/fourb.tex b/Source/Doc/CPM 22 Manual - Testing/fourb.tex new file mode 100644 index 00000000..84f1ac1f --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/fourb.tex @@ -0,0 +1,583 @@ +.sp 2 +.tc 4.4 A Sample Program +.he CP/M Operating System Manual 4.4 A Sample Program +.sh +4.4 A Sample Program +.pp +The following example shows an edit, assemble, and debug for a +simple program that reads a set of data values and determines the +largest value in the set. The largest value is taken from the +vector and stored into LARGE at the termination of the program. +.ll 75 +.sp 2 +.nf +A>\c +.sh +ED SCAN.ASM \c +.qs +Create source program; + " " represents carriage return. +*I + ORG 1-00H ;START OF TRANSIENT + ;AREA + MVI B, LEN ;LENGTH OF VECTOR TO SCAN + MVI C, 0 ;LARGER_RST VALUE SO FAR +LOOP LXI H, VECT ;BASE OF VECTOR +LOOP: MOV A, M ;GET VALUE + SUB C ;LARGER VALUE IN C? + JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND +; NEW LARGEST VALUE, STORE IT TO C + MOV C, A +NFOUND INX H ;TO NEXT ELEMENT + DCR B ;MORE TO SCAN? + JNZ LOOP ;FOR ANOTHER +; +; END OF SCAN, STORE C + MOV A, C ;GET LARGEST VALUE + STA LARGE + JMP 0 ;REBOOT +; +; TEST DATA +VECT: DB 2,0,4,3,5,6,1,5 +LEN EQU $-VECT ;LENGTH +LARGE: DS 1 ;LARGEST VALUE ON EXIT + END + +.bp +^-Z +*B0P + ORG 100H ;START OF TRANSIENT AREA + MVI B,LEN ;LENGTH OF VECTOR TO SCAN + MVI C,0 ;LARGEST VALUE SO FAR + LXI H,VECT ;BASE OF VECTOR +LOOP: MOV A,M ;GET VALUE + SUB C ;LARGER VALUE IN C? + JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND +; NEW LARGEST VALUE, STORE IT TO C + MOV C,A +NFOUND: INX H ;TO NEXT ELEMENT + DCR B ;MORE TO SCAN? + JNZ LOOP ;FOR ANOTHER +; END OF SCAN, STORE C + MOV A,C ;GET LARGEST VALUE + STA LARGE + JMP 0 ;REBOOT +; +; TEST DATA + +VECT: DB 2,0,4,3,5,6,1,5 +LEN EQU $-VECT ;LENGTH +LARGE: DS 1 ;LARGEST VALUE ON EXIT + END +*E <--End of edit + +A>\c +.sh +ASM SCAN \c +.qs +Start Assembler + +CP/M ASSEMBLER - VER 1.0 + +0122 +002H USE FACTOR +END OF ASSEMBLY Assembly complete; lock at program listing + +A>\c +.sh +TYPE SCAN.PRN +.qs + Code address Source program + 0100 ORG 100H ;START OF TRANSIENT AREA + 0100 0608 MVI B,LEN ;LENGTH OF VECTOR TO SCAN + 0102 0E00 Machine code MVI C,0 ;LARGEST VALUE SO FAR + 0104 211901 LXI H,VECT. ;BASE OF VECTOR + 0107 7E LOOP: MOV A,M ;GET VALUE + 0108 91 SUB C ;LARGER VALUE IN C? + 0109 D20D01 JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND + ; NEW LARGEST VALUE, STORE IT TO C + 010C 4F MOV C,A +.bp + 010D 23 NFOUND: INX H ;TO NEXT ELEMENT + 010E 05 DCR B ;MORE TO SCAN? + 010F C20701 JNZ LOOP ;FOR ANOTHER + ; + ; END OF SCAN, STORE C + 0112 79 MOV A,C ;GET LARGEST VALUE + 0113 322101 STA LARGE + + 0116 C30000 JMP 0 ;REBOOT + Code--data listing; + truncated ; TEST DATA + 0119 0200040305 VECT: DB 2,0,4,3,5,6,1,5 + 0008 = Value of LEN EQU $-VECT ;LENGTH + 0121 equate LARGE: DS 1 ;LARGEST VALUE ON EXIT + 0122 END + + +A>\c +.sh +DDT SCAN.HEX \c +.qs +Start debugger using hex format machine code + +DDT VER 1.0 +NEXT PC Next instruction +0121 0000 to execute at +-X Last load address + 1 PC=0 + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0000 OUT 7F +-XP Examine registers before debug run + +P=0000 100 Change PC to 100 + +-X Look at registers again + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +-L100 + PC changed Next instruction + to execute at PC=100 + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C Disassembled machine + 0109 JNC 010D code at 100H + 010C MOV C,A (see source listing + 010D INX H for comparison) + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C +-L +.bp + 0113 STA 0121 + 0116 JMP 0000 + 0119 STAX B + 011A NOP A little more machine + 011B INR B code. Note that pro- + 011C INX B gram ends at location + 011D DCR B 116 with a JMP to + 011E MVI B,01 0000. Remainder of + 0120 DCR B listing is assembly of + 0121 LXI D,2200 data. + 0124 LXI H,0200 +-A116 Enter in-line assembly mode to change the JMP to 0000 into a RST 7, + which will cause the program under test to return to DDT if 116H is + ever executed. +0116 RST 7 + +0117 (Single carriage return stops assemble mode) + +-L113 List code at 113H to check that RST 7 was properly inserted + + 0113 STA 0121 + 0116 RST 07 in place of JMP + 0117 NOP + 0118 NOP + 0119 STAX B + 011A NOP + 011B INR B + 011C INX B +- + +-X Look at registers + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +-T + Execute Program for one stop. Initial CPU state, before is executed + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08*0102 + Automatic breakpoint + + Trace one step again (note O8H in B) +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0102 MVI C,00*0104 +-T + Trace again (Register C is cleared) +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0104 LXI H,0119*0107 +-T3 Trace three steps +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z0M0E0I0 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JNC 010D*010D +-D119 + Display memory starting at 119H. Automatic breakpoint at 10DH + +0119 02 00 04 03 05 06 01.Program data Lower-case x +0120 05 11 00 22 21 00 02 7E EB 77 13 23 EB 0B 78 B1 ..."!.. . W .#..X. +0130 C2 27 01 C3 03 29 00 00 00 00 00 00 00 00 00 00 ...' ...)......... +0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Data are displayed +0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 in ASCI with a "." +0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 in the position of +0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 nongraphic........ +01A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 characters........ +01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +01C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +-X + Current CPU state +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +-T5 + Trace 5 steps from current CPU state +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0800 D=0000 H=011A S=0100 P=010E DCR B +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=010F JNZ 0107 +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0700 D=0000 H=011A S=0100 P=0108 SUB C*0109 + +U5 + Automatic breakpoint + Trace without listing intermediate states +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=0109 JNC 010D*0108 +-X + CPU state at end of U5 +C0Z0M0E1I1 A=04 B=0600 D=0000 H=011B S=0100 P=0108 SUB C +-G Run program from current PC until completion (in real-time) + +*0116 breakpoint at 116H, caused by executing RST 7 in machine code. + +-X + CPU state at end of program +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0116 RST 07 +-XP + Examine and change program counter + +P=0116 100 + +-X + +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0100 MVI B,08 +-T10 + + First data element + Current largest value + Subtract for comparison C + Trace 10 (hexadecimal) steps +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0121 S=0100 P=0100 MVI B,08 +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0102 MVI C,00 +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0121 S=0100 P=0104 LXI H,0119 +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z1M0E1I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JNC 010D +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0800 D=0000 H=011A S=0100 P=010E DCR B +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=010F JNZ 0107 +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0700 D=0000 H=011A S=0100 P=0108 SUB C +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=0109 JNC 010D +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=010D INX H +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011B S=0100 P=010E DCR B +C0Z0M0E1I1 A=00 B=0600 D=0000 H=011B S=0100 P=010F JNZ 0107 +C0Z0M0E1I1 A=00 B=0600 D=0000 H=011B S=0100 P=0107 MOV A,M*0108 +-A109 + Insert a "hot patch" into Program should have moved the + the machine code value from A into C since A>C. +0109 JC 10D to change the Since this code was not executed, + JNC to JC it appears that the JNC should +010C have been a JC instruction + + Stop DDT so that a version of +-G0 the patched program can be saved + +A>\c +.sh +SAVE 1 SCAN.COM \c +.qs +Program resides on first + page, so save 1 page. +A>\c +.sh +DDT SCAN.COM +.qs + Restart DDT with the save memory +DDT VER 1.0 image to continue testing +NEXT PC +0200 0100 + +-L100 List some code + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C + 0109 JC 010D Previous patch is present in X.COM + 010C MOV C,A + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C + -XP + +P=0100 + +-T10 + Trace to see how patched version operates Data is moved from A to C +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0102 MVI C,00 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0104 LXI H,0119 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z0M0E0I0 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JC 010D +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010C MOV C,A +C0Z0M0E0I1 A=02 B=0802 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0802 D=0000 H=011A S=0100 P=010E DCR B +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=010F JNZ 0107 +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0702 D=0000 H=011A S=0100 P=0108 SUB C +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=0109 JC 010D +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=010D INX H +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011B S=0100 P=010E DCR B +C1Z0M0E1I1 A=FE B=0602 D=0000 H=011B S=0100 P=010F JNZ 0107*0107 +-X Breakpoint after 16 steps + +C1Z0M0E1I1 A=FE B=0602 D=0000 H=011B S=0100 P=0107 MOV A,M +-G,108 Run from current PC and breakpoint at 108H + +*0108 +-X + Next data item +C1Z0M0E1I1 A=04 B=0602 D=0000 H=011B S=0100 P=0108 SUB C +-T + Single step for a few cycles +C1Z0M0E1I1 A=04 B=0602 D=0000 H=011B S=0100 P=0108 SUB C*0109 +-T + +C0Z0M0E0I1 A=02 B=0602 D=0000 H=011B S=0100 P=0109 JC 010D*010C +-X + +C0Z0M0E0I1 A=02 B=0602 D=0000 H=011B S=0100 P=010C MOV C,A +-G Run to completion + +*0116 +-X + +C0Z1M0E1I1 A=03 B=0003 D=0000 H=0121 S=0100 P=0116 RST 07 +-S121 Look at the value of "LARGE" + + 0121 03 Wrong value! + + 0122 00 + + 0123 22 + + 0124 21 + + 0125 00 + + 0126 02 + + 0127 7E _\b. End of the S command + +-L100 + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C + 0109 JC 010D + 010C MOV C,A + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C +-L Review the code + + 0113 STA 0121 + 0116 RST 07 + 0117 NOP + 0118 NOP + 0119 STAX B + 011A NOP + 011B INR B + 011C INX B + 011D DCR B + 011E MVI B,01 + 0120 DCR B +-XP + +P=0116 100 Reset the PC + +-T + Single step, and watch data values +C0Z1M0E1I1 A=03 B=0003 D=0000 H=0121 S=0100 P=0100 MVI B,08*0102 +-T + +C0Z1M0E1I1 A=03 B=0803 D=0000 H=0121 S=0100 P=0102 MVI C,00*0104 +-T + Count set Largest set +C0Z1M0E1I1 A=03 B=0800 D=0000 H=0121 S=0100 P=0104 LXI H,0119*0107 +-T + Base address of data set +C0Z1M0E1I1 A=03 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M*0108 +-T + First data item brought to A +C0Z1M0E1I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C*0109 +-T + +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JC 010D*010C +-T + +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010C MOV C,A*010D +-T + First data item moved to C correctly +C0Z0M0E0I1 A=02 B=0802 D=0000 H=0119 S=0100 P=010D INX H*010E +-T + +C0Z0M0E0I1 A=02 B=0802 D=0000 H=011A S=0100 P=010E DCR B*010F +-T + +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=010F JNZ 0107*0107 +-T + +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=0107 MOV A,M*0108 +-T + Second data item brought to A +C0Z0M0E0I1 A=00 B=0702 D=0000 H=011A S=0100 P=0108 SUB C*0109 +-T + Subtract destroys data value that was loaded! +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=0109 JC 010D*010D +-T + +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=010D INX H*010E +-L100 + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C This should have been a CMP so that register A + 0109 JC 010D would not be destroyed. + 010C MOV C,A + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C + -A108 + +0108 CMP C Hot patch at 108H changes SUB to CMP + +0109 + +-G0 Stop DDT for SAVE + +A>\c +.sh +SAVE 1 SCAN.COM \c +.qs +Save memory image + +A>\c +.sh +DDT SCAN.COM \c +.qs +Restart DDT + +DDT VER 1.0 +NEXT PC +0200 0100 +-XP + +P=0100 + +-L116 +.mb 5 +.fm 1 + + 0116 RST 07 + 0117 NOP + 0118 NOP Look at code to see if it was properly loaded + 0119 STAX B (long typeout aborted with rubout) + 011A NOP + - + +-G,116 Run from 100H to completion + +*0116 +-XC Look at carry (accidental typo) +C1 +-X Look at CPU state +.mb 6 +.fm 2 + +C1Z1M0E1I1 A=06 B=0006 D=0000 H=0121 S=0100 P=0116 RST 07 +-S121 Look at "large"--it appears to be correct. + +0121 06 + +0122 00 + +0123 22 + +-G0 Stop DDT + +A>\c +.sh +ED SCAN.ASM \c +.qs +Re-edit the source program, and make both changes + +*NSUB +*0LT + CTRL-Z SUB C ;LARGER VALUE IN C? +*SSUB^\b|ZCMP^\b|Z0LT + CMP D ;LARGER VALUE IN C? +* + JNC NFOUND ;JUMP IF LARGER VALUE NOT FOUND +*SNC^\b|ZC^\b|Z0LT + JC NFOUND ;JUMP IF LARGER VALUE NOT FOUND +*E + Reassemble, selecting source from disk A +A>\c +.sh +ASM SCAN.AAZ \c +.qs +<--- Hex to disk A + Print to Z (selects no print file) +CP/M ASSEMBLER VER 1.0 + +0122 +002H USE FACTOR +END OF ASSEMBLY + +A>\c +.sh +DDT SCAN.HEX \c +.qs +Rerun debugger to check changes + +DDT VER 1.0 +NEXT PC +0121 0000 +-L116 + + 0116 JMP 0000 Check to ensure end is still at 116H + + 0119 STAX B + + 011A NOP + 011B INR B + + -(rubout) + +-G100,116 Go from beginning with breakpoint at end + +*0116 Breakpoint reached +-D121 Look at "LARGE" + Correct value computed +0121 06 00 22 21 00 02 7E EB 77 13 23 EB 0B 78 B1 .. '!... W .#..X. +0130 C2 27 01 C3 03 29 00 00 00 00 00 00 00 00 00 00 .'...)........ +0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .............. + +-(rubout) Aborts long typeout + +G0 Stop DDT, debug session complete. +.ll 65 +.sp 2 +.ce +End of Section 4 +.nx fivea + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/front.tex b/Source/Doc/CPM 22 Manual - Testing/front.tex new file mode 100644 index 00000000..d65aa953 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/front.tex @@ -0,0 +1,453 @@ +.op +.sp 15 +.ce 100 +.sh +CP/M +.qs +.sp +.sh +Operating System +.qs +.sp +.sh +Manual +.qs +.cs 5 +.sp 10 +Copyright (c) 1982 +.sp +Digital Research +P.O. Box 579 +160 Central Avenue +Pacific Grove, CA 93950 +(408) 649-3896 +TWX 910 360 5001 +.sp 4 +All Rights Reserved +.ce 0 +.bp +.po 17 +.ll 50 +.ce +COPYRIGHT +.sp +Copyright (c) 1976, 1977, 1978, 1979, 1982, 1983, and 1984 by +Digital Research Inc. All rights reserved. No part of this +publication may be reproduced, transmitted, transcribed, stored +in a retrieval system, or translated into any language or +computer language, in any form or by any means, electronic, mechanical, +magnetic, optical, chemical, manual or otherwise, without the prior +written permission of Digital Research Inc., Post Office Box 579, +Pacific Grove, California, 93950. +.sp +Thus, readers are granted permission to include the example +programs, either in whole or in part, in their own programs. +.sp 2 +.ce +DISCLAIMER +.sp +Digital Research Inc. makes no representations or warranties with +respect to the contents hereof and specifically disclaims +any implied warranties of merchantability or fitness for +any particular purpose. Further, Digital Research Inc. reserves the +right to revise this publication and to make changes from +time to time in the content hereof without obligation of +Digital Research Inc. to notify any person of such revision or +changes. +.sp 2 +.ce +TRADEMARKS +.sp +CP/M, CP/NET, and Digital Research and its logo are registered +trademarks of Digital Research. ASM, DESPOOL, DDT, LINK-80, MAC, +MP/M, PL/I-80 and SID are trademarks of Digital Research. IBM is +a registered trademark of International Business Machines. Intel +is a registered trademark of Intel Corporation. TI Silent 700 is +a trademark of Texas Instruments Incorporated. Zilog and Z80 are +registered trademarks of Zilog, Inc. +.mb 4 +.fm 1 +.sp 3 +The \c +.ul +CP/M Operating System Manual \c +.qu +was prepared using the Digital Research TEX Text Formatter and printed +in the United States of America. +.sp 2 +.ce 6 +********************************* +* First Edition: 1976 * +* Second Edition: July 1982 * +* Third Edition: March 1983 * +* Fourth Edition: March 1984 * +********************************* +.po 10 +.ll 65 +.in 0 +.bp +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft iii +.bp +.ce +.sh +Table of Contents +.qs +.sp 3 +.nf +.sh +1 CP/M Features and Facilities +.qs +.sp + 1.1 Introduction . . . . . . . . . . . . . . . . . . . 1-1 +.sp + 1.2 Functional Description . . . . . . . . . . . . . . 1-3 +.sp + 1.2.1 General Command Structure . . . . . . . . . 1-3 + 1.2.2 File References . . . . . . . . . . . . . . 1-3 +.sp + 1.3 Switching Disks . . . . . . . . . . . . . . . . . . 1-5 + 1.4 Built-in Commands . . . . . . . . . . . . . . . . . 1-6 +.sp + 1.4.1 ERA Command . . . . . . . . . . . . . . . . 1-6 + 1.4.2 DIR Command . . . . . . . . . . . . . . . . 1-7 + 1.4.3 REN Command . . . . . . . . . . . . . . . . 1-8 + 1.4.4 SAVE Command . . . . . . . . . . . . . . . . 1-8 + 1.4.5 TYPE Command . . . . . . . . . . . . . . . . 1-9 + 1.4.6 USER Command . . . . . . . . . . . . . . . . 1-9 +.sp + 1.5 Line Editing and Output Control . . . . . . . . . . 1-10 +.sp + 1.6 Transient Commands . . . . . . . . . . . . . . . . 1-11 +.sp + 1.6.1 STAT Command . . . . . . . . . . . . . . . . 1-12 + 1.6.2 ASM Command . . . . . . . . . . . . . . . . 1-18 + 1.6.3 LOAD Command . . . . . . . . . . . . . . . . 1-19 + 1.6.4 PIP . . . . . . . . . . . . . . . . . . . . 1-20 + 1.6.5 ED Command . . . . . . . . . . . . . . . . . 1-29 + 1.6.6 SYSGEN Command . . . . . . . . . . . . . . . 1-31 + 1.6.7 SUBMIT Command . . . . . . . . . . . . . . . 1-33 + 1.6.8 DUMP Command . . . . . . . . . . . . . . . . 1-35 + 1.6.9 MOVCPM Command . . . . . . . . . . . . . . . 1-35 +.sp + 1.7 BDOS Error Messages . . . . . . . . . . . . . . . . 1-37 +.sp + 1.8 CP/M Operation on the Model 800 . . . . . . . . . . 1-38 +.sp 2 +.sh +2 The CP/M Editor +.qs +.sp + 2.1 Introduction to ED . . . . . . . . . . . . . . . . 2-1 +.sp + 2.1.1 ED Operation . . . . . . . . . . . . . . . . 2-1 + 2.1.2 Text Transfer Functions . . . . . . . . . . 2-3 + 2.1.3 Memory Buffer Organization . . . . . . . . . 2-4 + 2.1.4 Line Numbers and ED Start-up . . . . . . . . 2-5 + 2.1.5 Memory Buffer Operation . . . . . . . . . . 2-6 + 2.1.6 Command Strings . . . . . . . . . . . . . . 2-7 + 2.1.7 Text Search and Alteration . . . . . . . . . 2-10 + 2.1.8 Source Libraries . . . . . . . . . . . . . . 2-13 + 2.1.9 Repetitive Command Execution . . . . . . . . 2-14 +.bp +.ft iv +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 + 2.2 ED Error Conditions . . . . . . . . . . . . . . . . 2-14 +.sp + 2.3 Control Characters and Commands . . . . . . . . . . 2-16 +.sp 2 +.sh +3 CP/M Assembler +.qs +.sp + 3.1 Introduction . . . . . . . . . . . . . . . . . . . 3-1 +.sp + 3.2 Program Format . . . . . . . . . . . . . . . . . . 3-3 +.sp + 3.3 Forming the Operand . . . . . . . . . . . . . . . . 3-4 +.sp + 3.3.1 Labels . . . . . . . . . . . . . . . . . . . 3-4 + 3.3.2 Numeric Constants . . . . . . . . . . . . . 3-5 + 3.3.3 Reserved Words . . . . . . . . . . . . . . . 3-5 + 3.3.4 String Constants . . . . . . . . . . . . . . 3-6 + 3.3.5 Arithmetic and Logical Operators . . . . . . 3-7 + 3.3.6 Precedence of Operators . . . . . . . . . . 3-8 +.sp + 3.4 Assembler Directives . . . . . . . . . . . . . . . 3-9 +.sp + 3.4.1 The ORG Directive . . . . . . . . . . . . . 3-10 + 3.4.2 The END Directive . . . . . . . . . . . . . 3-10 + 3.4.3 The EQU Directive . . . . . . . . . . . . . 3-11 + 3.4.4 The SET Directive . . . . . . . . . . . . . 3-11 + 3.4.5 The IF and ENDIF Directives . . . . . . . . 3-12 + 3.4.6 The DB Directive . . . . . . . . . . . . . . 3-13 + 3.4.7 The DW Directive . . . . . . . . . . . . . . 3-14 + 3.4.8 The DS Directive . . . . . . . . . . . . . . 3-14 +.sp + 3.5 Operation Codes . . . . . . . . . . . . . . . . . . 3-15 +.sp + 3.5.1 Jumps, Calls, and Returns . . . . . . . . . 3-15 + 3.5.2 Immediate Operand Instructions . . . . . . . 3-17 + 3.5.3 Increment and Decrement Instructions . . . . 3-17 + 3.5.4 Data Movement Instructions . . . . . . . . . 3-18 + 3.5.5 Arithmetic Logic Unit Operations . . . . . . 3-19 + 3.5.6 Control Instructions . . . . . . . . . . . . 3-21 +.sp + 3.6 Error Messages . . . . . . . . . . . . . . . . . . 3-21 +.sp + 3.7 A Sample Session . . . . . . . . . . . . . . . . . 3-23 +.bp +.ft v +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 +.sh +4 CP/M Dynamic Debugging Tool +.qs +.sp + 4.1 Introduction . . . . . . . . . . . . . . . . . . . 4-1 +.sp + 4.2 DDT Commands . . . . . . . . . . . . . . . . . . . 4-3 +.sp + 4.2.1 The A (Assembly) Command . . . . . . . . . . 4-3 + 4.2.2 The D (Display) Command . . . . . . . . . . 4-4 + 4.2.3 The F (Fill) Command . . . . . . . . . . . . 4-5 + 4.2.4 The G (Go) Command . . . . . . . . . . . . . 4-5 + 4.2.5 The I (Input) Command . . . . . . . . . . . 4-6 + 4.2.6 The L (List) Command . . . . . . . . . . . . 4-6 + 4.2.7 The M (Move) Command . . . . . . . . . . . . 4-7 + 4.2.8 The R (Read) Command . . . . . . . . . . . . 4-7 + 4.2.9 The S (Set) Command . . . . . . . . . . . . 4-8 + 4.2.1- The T (Trace) Command . . . . . . . . . . . 4-8 + 4.2.11 The U (Untrace) Command . . . . . . . . . . 4-9 + 4.2.12 The X (Examine) Command . . . . . . . . . . 4-9 +.sp + 4.3 Implementation Notes . . . . . . . . . . . . . . . 4-10 +.sp + 4.4 A Sample Program . . . . . . . . . . . . . . . . . 4-11 +.sp 2 +.sh +5 CP/M 2 System Interface +.qs +.sp + 5.1 Introduction . . . . . . . . . . . . . . . . . . . 5-1 +.sp + 5.2 Operating System Call Conventions . . . . . . . . . 5-3 +.sp + 5.3 A Sample File-to-File Copy Program . . . . . . . . 5-35 +.sp + 5.4 A Sample File Dump Utility . . . . . . . . . . . . 5-38 +.sp + 5.5 A Sample Random Access Program . . . . . . . . . . 5-42 +.sp + 5.6 System Function Summary . . . . . . . . . . . . . . 5-50 +.sp 2 +.sh +6 CP/M 2 Alteration +.qs +.sp + 6.1 Introduction . . . . . . . . . . . . . . . . . . . 6-1 +.sp + 6.2 First-level System Regeneration . . . . . . . . . . 6-2 +.sp + 6.3 Second-level System Generation . . . . . . . . . . 6-5 +.sp + 6.4 Sample GETSYS and PUTSYS Programs . . . . . . . . . 6-9 +.bp +.ft vi +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 + 6.5 Disk Organization . . . . . . . . . . . . . . . . . 6-11 +.sp + 6.6 The BIOS Entry Points . . . . . . . . . . . . . . . 6-13 +.sp + 6.7 A Sample BIOS . . . . . . . . . . . . . . . . . . . 6-21 +.sp + 6.8 A Sample Cold Start Loader . . . . . . . . . . . . 6-21 +.sp + 6.9 Reserved Locations in Page Zero . . . . . . . . . . 6-22 +.sp + 6.10 Disk Parameter Tables . . . . . . . . . . . . . . 6-23 +.sp + 6.11 The DISKDEF Macro Library . . . . . . . . . . . . 6-28 +.sp + 6.12 Sector Blocking and Deblocking . . . . . . . . . . 6-32 +.bp +.ft vii +.ce +.sh +Appendixes +.qs +.sp 3 +.sh +A \c +.qs +Basic Input/Output System (BIOS) . . . . . . . . . . . A-1 +.sp 2 +.sh +B \c +.qs +A Skeletal CBIOS . . . . . . . . . . . . . . . . . . . B-1 +.sp 2 +.sh +C \c +.qs +A Skeletal GETSYS/PUTSYS Program . . . . . . . . . . . C-1 +.sp 2 +.sh +D \c +.qs +The Model 800 Cold Start Loader for CP/M 2 . . . . . . D-1 +.sp 2 +.sh +E \c +.qs +A Skeletal Cold Start Loader . . . . . . . . . . . . . E-1 +.sp 2 +.sh +F \c +.qs +CP/M Disk Definition Library . . . . . . . . . . . . . F-1 +.sp 2 +.sh +G \c +.qs +Blocking and Deblocking Algorithms . . . . . . . . . . G-1 +.sp 2 +.sh +H \c +.qs +Glossary . . . . . . . . . . . . . . . . . . . . . . . H-1 +.sp 2 +.sh +I \c +.qs +CP/M Error Messages . . . . . . . . . . . . . . . . . . I-1 +.bp +.ft viii +.ce +.sh +Tables, Figures, and Listings +.qs +.sp 3 +.sh +Tables +.qs +.sp + 1-1. Line-editing Control Characters . . . . . . . . 1-10 + 1-2. CP/M Transient Commands . . . . . . . . . . . . 1-11 + 1-3. Physical Devices . . . . . . . . . . . . . . . 1-14 + 1-4. PIP Parameters . . . . . . . . . . . . . . . . 1-24 +.sp + 2-1. ED Text Transfer Commands . . . . . . . . . . . 2-3 + 2-2. Editing Commands . . . . . . . . . . . . . . . 2-6 + 2-3. Line-editing Controls . . . . . . . . . . . . . 2-7 + 2-4. Error Message Symbols . . . . . . . . . . . . . 2-13 + 2-5. ED Control Characters . . . . . . . . . . . . . 2-14 + 2-6. ED Commands . . . . . . . . . . . . . . . . . . 2-15 +.sp + 3-1. Reserved Characters . . . . . . . . . . . . . . 3-6 + 3-2. Arithmetic and Logical Operators . . . . . . . 3-7 + 3-3. Assembler Directives . . . . . . . . . . . . . 3-9 + 3-4. Jumps, Calls, and Returns . . . . . . . . . . . 3-15 + 3-5. Immediate Operand Instructions . . . . . . . . 3-16 + 3-6. Increment and Decrement Instructions . . . . . 3-17 + 3-7. Data Movement Instructions . . . . . . . . . . 3-17 + 3-8. Arithmetic Logic Unit Operations . . . . . . . 3-18 + 3-9. Error Codes . . . . . . . . . . . . . . . . . . 3-20 + 3-10. Error Messages . . . . . . . . . . . . . . . . 3-21 +.sp + 4-1. Line-editing Controls . . . . . . . . . . . . . 4-2 + 4-2. DDT Commands . . . . . . . . . . . . . . . . . 4-2 + 4-3. CPU Registers . . . . . . . . . . . . . . . . . 4-9 +.sp + 5-1. CP/M Filetypes . . . . . . . . . . . . . . . . 5-6 + 5-2. File Control Block Fields . . . . . . . . . . . 5-7 + 5-3. Edit Control Characters . . . . . . . . . . . . 5-20 +.sp + 6-1. Standard Memory Size Values . . . . . . . . . . 6-2 + 6-2. Common Values for CP/M Systems . . . . . . . . 6-7 + 6-3. CP/M Disk Sector Allocation . . . . . . . . . . 6-11 + 6-4. IOBYTE Field Values . . . . . . . . . . . . . . 6-15 + 6-5. BIOS Entry Points . . . . . . . . . . . . . . . 6-16 + 6-6. Reserved Locations in Page Zero . . . . . . . . 6-21 + 6-7. Disk Parameter Headers . . . . . . . . . . . . 6-23 + 6-8. BSH and BLM Values . . . . . . . . . . . . . . 6-25 + 6-9. EXM Values . . . . . . . . . . . . . . . . . . 6-25 + 6-10. BLS Tabluation . . . . . . . . . . . . . . . . 6-26 +.sp + I-1. CP/M Error Messages . . . . . . . . . . . . . . I-1 +.sp 2 +.sh +Figures +.qs +.sp + 2-1. Overall ED Operation . . . . . . . . . . . . . 2-2 + 2-2. Memory Buffer Organization . . . . . . . . . . 2-2 +.bp +.ft ix +.ce +.sh +Tables, Figures, and Listings +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 +.sh +Figures +.qs +.sp + 2-3. Logical Organization of Memory Buffer . . . . . 2-4 +.sp + 5-1. CP/M Memory Organization . . . . . . . . . . . 5-1 + 5-2. File Control Block Format . . . . . . . . . . . 5-7 +.sp + 6-1. IOBYTE Fields . . . . . . . . . . . . . . . . . 6-15 + 6-2. Disk Parameter Header Format . . . . . . . . . 6-22 + 6-3. Disk Parameter Header Table . . . . . . . . . . 6-23 + 6-4. Disk Parameter Block Format . . . . . . . . . . 6-24 + 6-5. AL0 and AL1 . . . . . . . . . . . . . . . . . . 6-25 +.sp 2 +.sh +Listings +.qs +.sp + 6-1. GETSYS Program . . . . . . . . . . . . . . . . 6-9 + 6-2. BIOS Entry Points . . . . . . . . . . . . . . . 6-13 +.nx onea + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/index.tex b/Source/Doc/CPM 22 Manual - Testing/index.tex new file mode 100644 index 00000000..e7f353ec --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/index.tex @@ -0,0 +1,468 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft Index-% +.nf +.ce +.sh +Index +.qs +.sp 3 +.sh +A +.qs +Absolute line number, 36 +Access mode, 13 +afn (ambiguous file + reference), 3, 4, 6 +Allocation vector, 105 +Ambiguous file reference + (afn), 3, 4, 6 +ASM, 15, 47 +Assembler, 15, 47 +Assembler/disassembler module + (DDT), 77 +Assembler errors, 62 +Assembly language mnemonics + in DDT, 71, 74 +Assembly language program, 49 +Assembly language statement, 49 +Automatic command + processing, 25 +.sp +.sh +B +.qs +.sp +Base, 50 +Basic Disk Operating System + (BDOS), 2, 89, 127 +Basic I/O System (BIOS), + 2, 89, 127 +BDOS (Basic Disk Operating + System), 2, 89, 127 +Binary constants, 50 +BIOS (Basic I/O System), + 2, 89, 127 +BIOS disk definition, 137, 148 + subroutines +Block move command, 74 +bls parameter, 149 +BOOT, 90, 136, 140 + entry point +Break point, 71, 73 +Built-in commands, 3 +.sp +.sh +C +.qs +.sp +Case translation, 5, 6, 20, + 37, 39, 44, 45, 51, 95 +CCP (Console Command + Processor), 2, 69, 89, 127 +CCP Stack, 92 +Character pointer, 35 +CKS parameter, 149 +Close File function, 101 +Code and data areas, 144 +Cold start loader, 136, + 140, 143 +Combine files, 17 +Command, 3 +Command line, 90 +Comment field, 49 +Compute File Size + function, 108 +Condition flags, 58, 77 +Conditional assembly, 56 +CONIN, 140 +CONOUT, 141 +CONSOLE, 138 +Console Command Processor + (CCP), 2, 69, 89, 127 +Console Input function, 95 +Console Output function, 96 +CONST, 140 +Constant, 50 +Control characters, 9, +Control functions, 9 +CTRL-Z character, 93 +Copy files, 17 +CPU state, 71 +cr (carriage return), 39 +Create files, 23 +Create system disk, 24 +Creating COM files, 16 +Currently logged disk, + 3, 5, 10, 17, 25 +.sp +.sh +D +.qs +.sp +Data allocation size, 147 +Data block number, 147 +DB statement, 57 +DDT commands, 70, 133 +DDT nucleus, 77 +DDT prompt, 70 +DDT sign-on message, 69 +Decimal constant, 50 +Default FCB, 73 +Delete File function, 102 +DESPOOL, 138 +Device assignment, 11 +DIR, 6 +DIR attribute, 14 +dir parameter, 149 +Direct console I/O + function, 97 +Direct Memory Address, 104 +Directory, 6 +Directory code, 100, 101, + 102, 103 +Disassembler, 71, 77 +Disk attributes, 11 +Disk drive name, 5 +Disk I/O functions, 99-110 +Disk parameter block, 146 +Disk parameter header, 145 +Disk parameter table, 145 +Disk statistics, 10 +Disk-to-disk copy, 18 +DISKDEF macro, 149 +Diskette format, 31 +DISKS macro, 150, 186 +Display file contents, 8 +dks parameter, 149 +DMA, 104 +DMA address, 93 +dn parameter, 149 +DPBASE, 146 +Drive characteristics, 14 +Drive select code, 94 +Drive specification, 5 +DS statement, 57 +DUMP, 27, 113 +DW statement, 57 +.sp +.sh +E +.qs +.sp +ED, 23, 33-45, 131 +ED commands, 38, 44 +ED errors, 43 +Edit command line, 9 +8080 CPU registers, 76 +8080 registers, 51 +end-of-file, 19, 93 +END statement, 49, 54 +EMDEF macro, 150 +ENDIF statement, 56 +EQU statement, 55 +ERA, 6 +Erase files, 6 +Error messages, 29, 43, + 62, 153 +Expression, 49 +Extents, 13 +.sp +.sh +F +.qs +.sp +FBASE, 89 +FCB, 93, 94 +FCB format, 93, 94 +FDOS (operations), 89, 91 +File attributes, 14 +File compatibility, 23 +File control block (FCB), + 93, 94 +File expansion, 128 +File extent, 93 +File indicators, 14 +File names, 3 +File reference, 3 +File statistics, 10, 13 +Filetype, 93 +Find command, 39 +fsc parameter, 149 +.sp +.sh +G +.qs +.sp +Get ADDR (Alloc) function, + 105 +Get ADDR (Disk Parms) + function, 106 +Get Console Status, 99 +Get I/O Byte function, 97 +Get Read/Only Vector + function, 105 +GETSYS, 128, 134 +.sp +.sh +H +.qs +.sp +Hexadecimal, 49, 50 +Hex files, 16, 19, 20, 47 +HOME subroutine, 139, 141 +.sp +.sh +I +.qs +.sp +Identifier, 49, 50 +IF statement, 56 +Initialized storage areas, 57 +In-line assembly language, 71 +Insert mode, 37 +Insert String, 40 +IOBYTE function, 138, 139 +.sp +.sh +J +.qs +.sp +Jump vector, 137 +Juxtaposition command,41 +.sp +.sh +K +.qs +.sp +Key fields, 109 +.sp +.sh +L +.qs +.sp +Label field, 49 +Labels, 48, 49, 58 +Library read command, 42 +Line-editing control + characters, 38, 70, 98 +Line-editing functions, 9 +Line numbers, 36 +LIST, 138, 141 +List Output function, 96 +LISTST, 142 +LOAD, 16 +Logged in, 3 +Logical devices, 11, 18, 138 +Logical extents, 93 +Logical-physical assignments, + 12, 139 +Logical to physical device + mapping, 138 +Logical to physical sector + translation, 143, 149 +Isc parameter, 149 +.sp +.sh +M +.qs +.sp +Machine executable code, 16 +Macro command, 42 +Make File function, 103 +Memory buffer, 33, 34, 35, 37 +Memory image, 71, 131, 132 +Memory image file, 16 +Memory size, 27, 128, 132 +MOVCPM, 27, 131, 132 +Multiple command + processing, 25 +.sp +.sh +N +.qs +.sp +{o} parameter, 149 +Octal constant, 50 +ofs parameter, 150 +On-line status, 100 +Open File function, 100 +Operand field, 49-51 +Operation field, 49-58 +Operators, 52, 53, 58 +ORG directive, 54 +.sp +.sh +P +.qs +.sp +Page zero, 144 +Patching the CP/M system, 128 +Peripheral devices, 138 +Physical devices, 12, 18, 139 +Physical file size, 109 +Physical to logical device + assignment, 12, 139 +PIP, 17 +PIP devices, 19 +PIP parameters, 20 +Print String function, 98 +PRN file, 47 +Program counter, 71, 73, 76 +Program tracing, 75 +Prompt, 3 +Pseudo-operation, 53 +PUNCH, 138, 141 +Punch Output function, 96 +PUTSYS, 129, 135 +.sp +.sh +R +.qs +.sp +Radix indicators, 50 +Random access, 107, 108, 117 +Random record number, 108 +READ, 142 +Read Console Buffer + function, 98 +Read only, 14 +Read/only status, 14 +Read random error codes, 107 +Read Random function, 107 +READ routine, 139 +Read Sequential function, 102 +Read/write, 14 +READER, 138, 141 +Reader Input function, 96 +REN, 7 +Rename file function, 104 +Reset Disk function, 99 +Reset Drive function, 109 +Reset state, 99 +Return Current Disk + function, 104 +Return Log-in Vector + function, 104 +Return Version Number + function, 99 +R/O, 14 +R/O, attribute, 106 +R/O bit, 105 +R/W, 14 +.sp +.sh +S +.qs +.sp +SAVE, 7 +SAVE command, 70 +Search for First function, 101 +Search for Next function, 102 +Search strings, 39 +Sector allocation, 136 +SECTRAN, 143 +SELDSK, 139, 141, 146 +Select Disk function, 100 +Sequential access, 93 +Set DMA address function, 104 +Set File Attributes + function, 106 +Set/GET User Code + function, 106 +Set I/O Byte function, 97 +Set Random Record + function, 109 +SET statement, 55 +SETDMA, 142 +SETSEC, 142 +SETTRK, 141 +Simple character I/O, 138 +Size in records, 13 +skf parameter, 149, 150 +Source files, 93 +Stack pointer, 92 +STAT, 10, 139, 151 +Stop console output, 9 +String substitutions, 40 +SUBMIT, 25 +SYS attribute, 14 +SYSGEN, 24, 134 +System attribute, 44, 106 +System parameters, 140 +System (re)initialization, 138 +System Reset function, 95 +.sp +.sh +T +.qs +.sp +Testing and debugging of + programs, 69 +Text transfer commands, 35 +TPA (Transient Program Area), + 2, 89 +Trace mode, 76 +Transient commands, 3, 9 +Transient Program Area + (TPA), 2, 89 +Translate table, 150 +Translation vectors, 146 +TYPE, 8 +.sp +.sh +U +.qs +.sp +ufn, 3, 6 +Unambiguous file reference, + 3, 6 +Uninitialized memory, 57 +Untrace mode, 76 +USER, 8 +USER numbers, 8, 15, 106 +.sp +.sh +V +.qs +.sp +Verify line numbers command, + 37, 45 +Version independent + programming, 99 +Virtual file size, 108 +.sp +.sh +W +.qs +.sp +Warm start, 90, 140 +WBOOT entry point, 140 +WRITE, 142 +Write Protect Disk + function, 105 +Write random error codes, 108 +Write Random function, 108 +Write Random with Zero Fill + function, 110 +Write routine, 142 +Write Sequential function, 103 +.sp +.sh +X +.qs +.sp +XSOB, 26 +.fi + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/onea.tex b/Source/Doc/CPM 22 Manual - Testing/onea.tex new file mode 100644 index 00000000..46279240 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/onea.tex @@ -0,0 +1,993 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 1-% +.pc 1 +.tc 1 CP/M Features and Facilities +.ce 2 +.sh +Section 1 +.qs +.sp +.sh +CP/M Features and Facilities +.qs +.sp 3 +.he CP/M Operating System Manual 1.1 Introduction +.tc 1.1 Introduction +.sh +1.1 Introduction +.qs +.fi +.pp 5 +CP/M \ is a monitor control program for microcomputer system development that +uses floppy disks or Winchester hard disks for backup storage. Using a +computer system based on the Intel \ 8080 microcomputer, CP/M provides an +environment for program construction, storage, and editing, along +with assembly and program check-out facilities. CP/M can be easily +altered to execute with any computer +configuration that uses a Zilog \ Z80 \ or an Intel 8080 Central Processing +Unit (CPU) and has at least 20K bytes of main memory with up to 16 disk +drives. A detailed discussion of the modifications required for any +particular hardware environment is given in Section 6. Although the +standard Digital Research version operates on a single-density +Intel Model 800, microcomputer development system several different +hardware manufacturers support their own input-output (I/O) drivers for CP/M. +.pp +The CP/M monitor provides rapid access to programs through a comprehensive +file management package. The file subsystem supports a named file structure, +allowing dynamic allocation of file space as well as sequential and random +file access. Using this file system, a large number of programs can be +stored in both source and machine-executable form. +.pp +CP/M 2 is a high-performance, single console operating system that uses +table-driven techniques to allow field reconfiguration to match a wide +variety of disk capacities. All fundamental file restrictions are removed, +maintaining upward compatibility from previous versions of release 1. +.pp +Features of CP/M 2 include field specification of one to sixteen logical +drives, each containing up to eight megabytes. Any particular file can +reach the full drive size with the capability of expanding to thirty-two +megabytes in future releases. The directory size can be field-configured to +contain any reasonable number of entries, and each file is optionally tagged +with Read-Only and system attributes. Users of CP/M 2 are physically +separated by user numbers, with facilities for file copy operations from one +user area to another. Powerful relative-record random access functions are +present in CP/M 2 that provide direct access to any of the 65536 records of +an eight-megabyte file. +.pp +CP/M also supports ED, a powerful context editor, ASM , an Intel-compatible +assembler, and DDT , debugger subsystems. Optional software includes a +powerful +Intel-compatible macro assembler, symbolic debugger, along with various +high-level languages. When coupled with CP/M's Console Command +Processor (CCP), +the resulting facilities equal or exceed similar large computer facilities. +.pp +CP/M is logically divided into several distinct parts: +.sp +.in 3 +.nf +o BIOS (Basic I/O System), hardware-dependent +o BDOS (Basic Disk Operating System) +o CCP (Console Command Processor) +o TPA (Transient Program Area) +.fi +.in 0 +.pp +The BIOS provides the primitive operations necessary to access the disk +drives and to interface standard peripherals: teletype, CRT, paper tape +reader/punch, and user-defined peripherals. You can tailor +peripherals for any particular hardware environment by patching this +portion of +CP/M. The BDOS provides disk management by controlling one or more disk +drives containing independent file directories. The BDOS implements disk +allocation strategies that provide fully dynamic file construction while +minimizing head movement across the disk during access. The BDOS has entry +points that include the following primitive operations, which the +program accesses: +.sp +.in 5 +.ti -2 +o SEARCH looks for a particular disk file by name. +.ti -2 +o OPEN opens a file for further operations. +.ti -2 +o CLOSE closes a file after processing. +.ti -2 +o RENAME changes the name of a particular file. +.ti -2 +o READ reads a record from a particular file. +.ti -2 +o WRITE writes a record to a particular file. +.ti -2 +o SELECT selects a particular disk drive for further operations. +.in 0 +.pp +The CCP provides a symbolic interface between your console and the +remainder of the CP/M system. The CCP reads the console device and +processes commands, which include listing the file directory, printing the +contents of files, and controlling the operation of transient programs, such +as assemblers, editors, and debuggers. The standard commands that are +available in the CCP are listed in Section 1.2.1. +.pp +The last segment of CP/M is the area called the Transient Program +Area (TPA). The TPA holds programs that are loaded from the disk under +command of the CCP. During program editing, for example, the TPA holds +the CP/M text editor machine code and data areas. Similarly, programs +created under CP/M can be checked out by loading and executing these +programs in the TPA. +.pp +Any or all of the CP/M component subsystems can be overlaid by an +executing program. That is, once a user's program is loaded into the TPA, +the CCP, BDOS, and BIOS areas can be used as the program's data area. +A bootstrap loader is programmatically accessible whenever the BIOS portion +is not overlaid; thus, the user program need only branch to the bootstrap +loader at the end of execution and the complete CP/M monitor is reloaded +from disk. +.pp +The CP/M operating system is partitioned into distinct modules, including +the BIOS portion that defines the hardware environment in which CP/M is +executing. Thus, the standard system is easily modified to any nonstandard +environment by changing the peripheral drivers to handle the custom system. +.bp +.tc 1.2 Functional Description +.he CP/M Operating System Manual 1.2 Functional Description +.sh +1.2 Functional Description +.qs +.pp +You interact with CP/M primarily through the CCP, which reads and +interprets commands entered through the console. In general, the CCP +addresses one of several disks that are on-line. The standard system +addresses up to sixteen different disk drives. These disk drives are +labeled A through P. A disk is logged-in if the CCP is currently +addressing the disk. To clearly indicate which disk is the currently logged +disk, the CCP always prompts the operator with the disk name followed by the +symbol >, indicating that the CCP is ready for another command. Upon +initial start-up, the CP/M system is loaded from disk A, and the CCP +displays the following message: +.sp +.ti 8 +CP/M VER x.x +.sp +where x.x is the CP/M version number. All CP/M systems are initially set +to operate in a 20K memory space, but can be easily reconfigured to fit any +memory size on the host system (see Section 1.6.9). Following system +sign-on, CP/M automatically logs in disk A, prompts you with the +symbol A>, indicating that CP/M is currently addressing disk A, and +waits for a command. The commands are implemented at two levels: built-in +commands and transient commands. +.sp 2 +.tc 1.2.1 General Command Structure +.sh +1.2.1 General Command Structure +.qs +.pp +Built-in commands are a part of the CCP program, while transient +commands are loaded into the TPA from disk and executed. The +following are built-in commands: +.sp +.in 3 +.nf +o ERA erases specified files. +o DIR lists filenames in the directory. +o REN renames the specified file. +o SAVE saves memory contents in a file. +o TYPE types the contents of a file on the logged disk. +.in 0 +.fi +.sp +Most of the commands reference a particular file or group of files. The +form of a file reference is specified in Section 1.2.2. +.sp 2 +.tc 1.2.2 File References +.sh +1.2.2 File References +.qs +.pp +A file reference identifies a particular file or group of files on a +particular disk attached to CP/M. These file references are +either unambiguous (ufn) or ambiguous (afn). An unambiguous file +reference uniquely identifies a single file, while an ambiguous file +reference is satisfied by a number of different files. +.mb 5 +.fm 1 +.pp +File references consist of two parts: the primary filename and the +filetype. Although the filetype is optional, it usually is +generic. For example, the filetype ASM is used to denote that the file is an +assembly language source file, while the primary filename distinguishes each +particular source file. The two names are separated by a period, as shown +in the following example: +.bp +.ti 8 +filename.typ +.sp +.mb 6 +.fm 2 +In this example, filename is the primary filename of eight characters or +less, and typ +is the filetype of no more than three characters. As mentioned above, the +name +.sp +.ti 8 +filename +.sp +is also allowed and is equivalent to a filetype consisting of +three blanks. The characters used in specifying an unambiguous +file reference cannot contain any of the following special +characters: +.sp +.ti 8 +< > . , ; : = ? * [ ] _ % | ( ) / \\textbackslash +.sp +while all alphanumerics and remaining special characters are allowed. +.pp +An ambiguous file reference is used for directory search and pattern +matching. The form of an ambiguous file reference is similar to an +unambiguous reference, except the symbol ? can be interspersed throughout +the primary and secondary names. In various commands throughout CP/M, +the ? symbol matches any character of a filename in the ? position. +Thus, the ambiguous reference +.sp +.ti 8 +X?Z.C?M +.sp +matches the following unambiguous filenames +.sp +.ti 8 +XYZ.COM +.sp +and +.sp +.ti 8 +X3Z.CAM +.sp +The * wildcard character can also be used in an ambiguous file +reference. The * character replaces all or part of a filename or +filetype. Note that +.sp +.ti 8 +*.* +.sp +equals the ambiguous file reference +.sp +.ti 8 +????????.??? +.sp +while +.sp +.ti 8 +filename.* +.sp +and +.sp +.ti 8 +*.typ +.sp +are abbreviations for +.sp +.ti 8 +filename.??? +.sp +and +.sp +.ti 8 +????????.typ +.sp +respectively. As an example, +.sp +.ti 8 +A>\c +.sh +DIR *.* +.qs +.sp +is interpreted by the CCP as a command to list the names of all disk files +in the directory. The following example searches only for a file +by the name X.Y: +.sp +.ti 8 +A>\c +.sh +DIR X,Y +.qs +.sp +Similarly, the command +.sp +.ti 8 +A>\c +.sh +DIR X?Y.C?M +.qs +.sp +causes a search for all unambiguous filenames on the disk that satisfy +this ambiguous reference. +.pp +The following file references are valid unambiguous file references: +.sp +.nf +.in 8 +X +X.Y +XYZ +XYZ.COM +GAMMA +GAMMA.1 +.fi +.in 0 +.pp +As an added convenience, the programmer can generally specify the disk drive +name along with the filename. In this case, the drive name is given as a +letter A through P followed by a colon (:). The specified drive is +then logged-in before the file operation occurs. Thus, the following are +valid file references with disk name prefixes: +.sp +.nf +.in 8 +A:X.Y +P:XYZ.COM +B:XYZ +B:X.A?M +C:GAMMA +C:*.ASM +.fi +.in 0 +.sp +All alphabetic lower-case letters in file and drive names are translated to +upper-case when they are processed by the CCP. +.sp 2 +.tc 1.3 Switching Disks +.he CP/M Operating System Manual 1.3 Switching Disks +.sh +1.3 Switching Disks +.qs +.mb 5 +.fm 1 +.pp +The operator can switch the currently logged disk by typing the disk drive +name, A through P, followed by a colon when the CCP is waiting for +console input. The following sequence of prompts and commands +can occur after the CP/M system is loaded from disk A: +.sp +.nf +.in 8 +CP/M VER 2.2 +A>\c +.sh +DIR \c +.qs +List all files on disk A. +A:SAMPLE ASM SAMPLE PRN +A>\c +.sh +B: \c +.qs +Switch to disk B. +B>\c +.sh +DIR *.ASM \c +.qs +List all ASM files on B. +B:DUMP ASM FILES ASM +b>\c +.sh +A: \c +.qs +Switch back to A. +.in 0 +.fi +.mb 6 +.fm 2 +.sp 2 +.tc 1.4 Built-in Commands +.he CP/M Operating System Manual 1.4 Built-in Commands +.sh +1.4 Built-in Commands +.qs +.pp +The file and device reference forms described can now be used to fully +specify the structure of the built-in commands. Assume the following +abbreviations in the description below: +.sp +.in 8 +.nf +ufn unambiguous file reference +afn ambiguous file reference +.fi +.in 0 +.sp +Recall that the CCP always translates lower-case characters to upper-case +characters internally. Thus, lower-case alphabetics are treated as if they +are upper-case in command names and file references. +.sp 2 +.tc 1.4.1 ERA Command +.sh +1.4.1 ERA Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +ERA afn +.pp +The ERA (erase) command removes files from the currently logged-in +disk, for example, the disk name currently prompted by CP/M preceding the >. +The files that are erased are those that satisfy the ambiguous file +reference afn. The following examples illustrate the use of ERA: +.sp 2 +.in 24 +.ti -16 +ERA X.Y The file named X.Y on the currently logged disk is removed +from the disk directory and the space is returned. +.sp +.ti -16 +ERA X.* All files with primary name X are removed from the current +disk. +.sp +.ti -16 +ERA *.ASM All files with secondary name ASM are removed from the +current disk. +.sp +.ti -16 +ERA X?Y.C?M All files on the current disk that satisfy the ambiguous +reference X?Y.C?M are deleted. +.bp +.ti -16 +ERA *.* Erase all files on the current disk. In this +case, the CCP prompts the console with the message +.sp +.nf +ALL FILES (Y/N)? +.fi +.sp +which requires a Y response before files are actually removed. +.sp +.ti -16 +ERA b:*.PRN All files on drive B that satisfy the ambiguous +reference ????????.PRN are deleted, independently of the currently +logged disk. +.in 0 +.sp 3 +.tc 1.4.2 DIR Command +.sh +1.4.2 DIR Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +DIR afn +.pp +The DIR (directory) command causes the names of all files that satisfy the +ambiguous filename afn to be listed at the console device. As a special +case, the command +.sp +.ti 8 +DIR +.sp +lists the files on the currently logged disk (the command DIR is +equivalent to the command DIR *.*). The following are valid DIR +commands: +.sp +.nf +.in 8 +DIR X.Y +DIR X?Z.C?M +DIR ??.Y +.in 0 +.fi +.pp +Similar to other CCP commands, the afn can be preceded by a drive name. +The following DIR commands cause the selected drive to be addressed before +the directory search takes place: +.sp +.in 8 +.nf +DIR B: +DIR B:X.Y +DIR B:*.A?M +.fi +.in 0 +.pp +If no files on the selected disk satisfy the directory request, the +message NO FILE appears at the console. +.bp +.tc 1.4.3 REN Command +.sh +1.4.3 REN Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +REN ufn1=ufn2 +.pp +The REN (rename) command allows you to change the names of files on +disk. The file satisfying ufn2 is changed to ufn1. The currently logged +disk is assumed to contain the file to rename (ufn2). You can also +type a left-directed arrow instead of the equal sign if the console supports +this graphic character. The following are examples of the REN +command: +.sp 2 +.in 31 +.ti -23 +REN X.Y=Q.R The file Q.R is changed to X.Y. +.ti -23 +.sp +REN XYZ.COM=XYZ.XXX The file XYZ.XXX is changed to XYZ.COM. +.in 0 +.fi +.sp +.pp +The operator precedes either ufn1 or ufn2 (or both) by an optional drive +address. If ufn1 is preceded by a drive name, then ufn2 is assumed to exist +on the same drive. Similarly, if ufn2 is preceded by a drive name, then +ufn1 is assumed to exist on the drive as well. The same drive must be +specified in both cases if both ufn1 and ufn2 are preceded by drive names. +The following REN commands illustrate this format: +.sp 2 +.in 31 +.ti -23 +REN A:X.ASM=Y.ASM The file Y.ASM is changed to X.ASM on drive A. +.sp +.ti -23 +REN B:ZAP.BAS=ZOT.BAS The file ZOT.BAS is changed to ZAP.BAS on drive B. +.sp +.ti -23 +REN B:A.ASM=B:A.BAK The file A.BAK is renamed to A.ASM on drive B. +.in 0 +.sp +.pp +If ufn1 is already present, the REN command responds with the +error FILE EXISTS and not perform the change. If ufn2 does not exist on +the specified disk, the message NO FILE is printed at the console. +.sp 2 +.tc 1.4.4 SAVE Command +.sh +1.4.4 SAVE Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +SAVE n ufn +.pp +The SAVE command places n pages (256-byte blocks) onto disk from the TPA +and names this file ufn. In the CP/M distribution system, the TPA starts +at 100H (hexadecimal) which is the second page of memory. The SAVE command +must specify 2 pages of memory if the user's program occupies the area +from 100H through 2FFH. The machine code file can be subsequently loaded +and executed. The following are examples of the SAVE command: +.sp 2 +.in 31 +.ti -23 +SAVE 3X.COM Copies 100H through 3FFH to X.COM. +.sp +.ti -23 +SAVE 40 Q Copies 100H through 28FFH to Q. Note that 28 is the +page count in 28FFH, and that 28H = 2*16+8=40 decimal. +.sp +.ti -23 +SAVE 4 X.Y Copies 100H through 4FFH to X.Y. +.in 0 +.sp 2 +The SAVE command can also specify a disk drive in the ufn portion of the +command, as shown in the following example: +.sp +.in 31 +.ti -23 +SAVE 10 B:ZOT.COM Copies 10 pages, 100H through 0AFFH, to the +file ZOT.COM on drive B. +.in 0 +.sp 3 +.tc 1.4.5 TYPE Command +.sh +1.4.5 TYPE Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +TYPE ufn +.pp +The TYPE command displays the content of the ASCII source file ufn on the +currently logged disk at the console device. The following are valid +TYPE commands: +.sp +.in 8 +.nf +TYPE X.Y +TYPE X.PLM +TYPE XXX +.in 0 +.fi +.pp +The TYPE command expands tabs, CTRL-I characters, assuming tab positions are +set at every eighth column. The ufn can also reference a drive name. +.sp +.in 24 +.ti -16 +TYPE B:X.PRN The file X.PRN from drive B is displayed. +.in 0 +.sp 2 +.tc 1.4.6 USER Command +.sh +1.4.6 USER Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +USER n +.pp +The USER command allows maintenance of separate files in the same +directory. In the syntax line, n is an integer value in the range 0 to +15. On cold start, the operator is automatically logged into user +area number 0, which is +compatible with standard CP/M 1 directories. You can issue the +USER command at any time to move to another logical area within the same +directory. Drives that are logged-in while addressing one user number are +automatically active when the operator moves to another. A user number is +simply a prefix that accesses particular directory entries on the active +disks. +.pp +The active user number is maintained until changed by a subsequent USER +command, or until a cold start when user 0 is again assumed. +.sp 2 +.tc 1.5 Line Editing and Output Control +.he CP/M Operating System Manual 1.5 Line Editing and Output Control +.sh +1.5 Line Editing and Output Control +.qs +.pp +The CCP allows certain line-editing functions while typing command lines. +The CTRL-key sequences are obtained by pressing the control and letter keys +simultaneously. Further, CCP command lines are generally up to 255 +characters in length; they are not acted upon until the carriage return key +is pressed. +.sp 2 +.ce +.sh +Table 1-1. Line-editing Control Characters +.qs +.sp +.ll 60 +.in 5 +.nf +Character Meaning +.fi +.sp +.in 18 +.ti -12 +CTRL-C Reboots CP/M system when pressed at start of line. +.sp +.ti -12 +CTRL-E Physical end of line; carriage is returned, but line is not sent +until the carriage return key is pressed. +.sp +.ti -12 +CTRL-H Backspaces one character position. +.sp +.ti -12 +CTRL-J Terminates current input (line feed). +.sp +.ti -12 +CTRL-M Terminates current input (carriage return). +.sp +.ti -12 +CTRL-P Copies all subsequent console output to the currently +assigned list device (see Section 1.6.1). Output is sent to the list device +and the console device until the next CTRL-P is pressed. +.sp +.ti -12 +CTRL-R Retypes current command line; types a clean line following +character deletion with rubouts. +.sp +.ti -12 +CTRL-S Stops the console output temporarily. Program execution and +output continue when you press any character at the console, for +example another CTRL-S. This feature stops output on high speed consoles, +such as CRTs, in order to view a segment of output before continuing. +.bp +.ll 65 +.in 0 +.ce +.sh +Table 1-1. (continued) +.qs +.sp +.ll 60 +.in 5 +.nf +Character Meaning +.fi +.sp +.in 18 +.ti-12 +CTRL-U Deletes the entire line typed at the console. +.sp +.ti -12 +CTRL-X Same as CTRL-U. +.sp +.ti -12 +CTRL-Z Ends input from the console (used in PIP and ED). +.sp +.ti -12 +RUB/DEL Deletes and echoes the last character typed at the console. +.in 0 +.ll 65 +.sp 2 +.tc 1.6 Transient Commands +.he CP/M Operating System Manual 1.6 Transient Commands +.sh +1.6 Transient Commands +.qs +.pp +Transient commands are loaded from the currently logged disk and executed in +the TPA. The transient commands for execution under the CCP are below. +Additional functions are easily defined by the user (see Section 1.6.3). +.sp 2 +.ce +.sh +Table 1-2. CP/M Transient Commands +.qs +.sp +.ll 60 +.in 5 +.nf +Command Function +.fi +.sp +.in 16 +.ti -11 +STAT Lists the number of bytes of storage remaining on the currently +logged disk, provides statistical information about particular files, and +displays or alters device assignment. +.sp +.ti -11 +ASM Loads the CP/M assembler and assembles the specified program from +disk. +.sp +.ti -11 +LOAD Loads the file in Intel HEX machine code format and produces a +file in machine executable form which can be loaded into the TPA. This loaded +program becomes a new command under the CCP. +.sp +.ti -11 +DDT Loads the CP/M debugger into TPA and starts execution. +.sp +.ti -11 +PIP Loads the Peripheral Interchange Program for subsequent disk file +and peripheral transfer operations. +.sp +.ti-11 +ED Loads and executes the CP/M text editor program. +.sp +.ti -11 +SYSGEN Creates a new CP/M system disk. +.bp +.ll 65 +.in 0 +.ce +.sh +Table 1-2. (continued) +.qs +.sp +.ll 60 +.in 5 +.nf +Command Function +.fi +.sp +.in 16 +.ti -11 +SUBMIT Submits a file of commands for batch processing. +.sp +.ti -11 +DUMP Dumps the contents of a file in hex. +.sp +.ti -11 +MOVCPM Regenerates the CP/M system for a particular memory size. +.sp +.ll 65 +.in 0 +.pp +Transient commands are specified in the same manner as built-in commands, and +additional commands are easily defined by the user. For convenience, the +transient command can be preceded by a drive name which causes the transient +to be loaded from the specified drive into the TPA for execution. Thus, the +command +.sp +.ti 8 +B:STAT +.sp +causes CP/M to temporarily log in drive B for the source of the STAT +transient, and then return to the original logged disk for subsequent +processing. +.sp 2 +.tc 1.6.1 STAT Command +.sh +1.6.1 STAT Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.in 8 +.nf +STAT +STAT "command line" +.fi +.in 0 +.pp +The STAT command provides general statistical information about file storage +and device assignment. Special forms of the command line allow the current +device assignment to be +examined and altered. The various command lines that can be specified are +shown with an explanation of each form to the right. +.sp 2 +.in 24 +.ti -16 +STAT If you type an empty command line, the STAT transient +calculates the storage remaining on all active drives, and prints +one of the following messages: +.sp +.nf +d: R/W, SPACE: nnnK +.sp +d: R/O, SPACE: nnnK +.fi +.sp +for each active drive d:, where R/W indicates the drive can be read or +written, and R/O indicates the drive is Read-Only (a drive becomes R/O by +explicitly setting it to Read-Only, as shown below, or by inadvertently +changing disks without performing a warm start). The space remaining on +the disk in drive d: is given in kilobytes by nnn. +.sp +.ti -16 +STAT d: If a drive name is given, then the drive is selected before +the storage is computed. Thus, the command STAT B: could be issued while +logged into drive A, resulting in the message +.sp +BYTES REMAINING ON B: nnnK +.sp +.ti -16 +STAT afn The command line can also specify a set of files to be +scanned by STAT. The files that satisfy afn are listed in alphabetical +order, with storage requirements for each file under the heading: +.sp +.nf +RECS BYTES EXT D:FILENAME.TYP +rrrr bbbK ee d:filename.typ +.fi +.sp +where rrrr is the number of 128-byte records allocated to the file, bbb is +the number of kilobytes allocated to the file (bbb=rrrr*128/1024), ee is the +number of 16K extensions (ee=bbb/16), d is the drive name containing the +file (A...P), filename is the eight-character primary filename, and +typ is the three-character filetype. After listing the individual +files, the storage usage is summarized. +.sp +.ti -16 +STAT d:afn The drive name can be given ahead of the afn. The specified +drive is first selected, and the form STAT afn is executed. +.sp +.ti -16 +STAT d:=R/O This form sets the drive given by d to Read-Only, remaining +in effect until the next warm or cold start takes place. When a disk is +Read-Only, the message +.sp +BDOS ERR ON d: Read-Only +.sp +appears if there is an attempt to write to the Read-Only disk. CP/M +waits until a key is pressed before performing an automatic +warm start, at +which time the disk becomes R/W. +.in 0 +.bp +.pp +The STAT command allows you to control the physical-to-logical device +assignment. See the IOBYTE function described in Sections 5 and 6. There +are four logical peripheral devices that are, at any particular instant, each +assigned one of several physical peripheral devices. The +following is a list of the four logical devices: +.sp 2 +.in 5 +.ti -2 +o CON: is the system console device, used by CCP for communication with the +operator. +.sp +.ti -2 +o RDR: is the paper tape reader device. +.sp +.ti -2 +o PUN: is the paper tape punch device. +.sp +.ti -2 +o LST: is the output list device. +.in 0 +.sp +.pp +The actual devices attached to any particular computer system are driven by +subroutines in the BIOS portion of CP/M. Thus, the logical RDR: device, for +example, could actually be a high speed reader, teletype reader, or cassette +tape. To allow some flexibility in device naming and assignment, several +physical devices are defined in Table 1-3. +.sp 2 +.ce +.sh +Table 1-3. Physical Devices +.qs +.ll 60 +.in 5 +.sp +.nf +Device Meaning +.fi +.sp +.in 14 +.ti -8 +TTY: Teletype device (slow speed console) +.sp +.ti -8 +CRT: Cathode ray tube device (high speed console) +.sp +.ti -8 +BAT: Batch processing (console is current RDR:, output goes to current +LST: device) +.sp +.ti -8 +UC1: User-defined console +.sp +.ti -8 +PTR: Paper tape reader (high speed reader) +.sp +.ti -8 +UR1: User-defined reader #1 +.sp +.ti -8 +UR2: User-defined reader #2 +.sp +.ti -8 +PTP: Paper tape punch (high speed punch) +.sp +.ti -8 +UP1: User-defined punch #1 +.sp +.ti -8 +UP2: User-defined punch #2 +.sp +.ti -8 +LPT: Line printer +.sp +.ti -8 +UL1: User-defined list device #1 +.in 0 +.ll 65 +.nx oneb + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/oneb.tex b/Source/Doc/CPM 22 Manual - Testing/oneb.tex new file mode 100644 index 00000000..67ae6beb --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/oneb.tex @@ -0,0 +1,915 @@ +.bp +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he CP/M Operating System Manual 1.6 Transient Commands +.ft 1-% +.pc 1 +.pp 5 +It is emphasized that the physical device names might not actually +correspond to devices that the names imply. That is, you can +implement the PTP: device as a cassette write operation. The exact +correspondence and driving subroutine is defined in the BIOS portion of +CP/M. In the standard distribution version of CP/M, these devices correspond +to their names on the Model 800 development system. +.pp +The command, +.sp +.ti 8 +STAT VAL: +.sp +produces a summary of the available status commands, resulting in +the output: +.sp +.in 8 +.nf +Temp R/O Disk d:$R/O +Set Indicator: filename.typ $R/O $R/W $SYS $DIR +Disk Status: DSK: d:DSK +Iobyte Assign: +.sp +.in 0 +.fi +which gives an instant summary of the possible STAT commands and shows the +permissible logical-to-physical device assignments: +.sp +.in 8 +.nf +CON: = TTY: CRT: BAT: UC1: +RDR: = TTY: PTR: UR1: UR2: +PUN: = TTY: PTP: UP1: UP2: +LST: = TTY: CRT: LPT: UL1: +.fi +.in 0 +.sp +The logical device to the left takes any of the four physical assignments +shown to the right. The current logical-to-physical mapping is displayed by +typing the command: +.sp +.ti 8 +STAT DEV: +.sp +This command produces a list of each logical device to the left and +the current +corresponding physical device to the right. For example, the list might +appear as follows: +.sp +.in 8 +.nf +CON: = CRT: +RDR: = UR1: +PUN: = PTP: +LST: = TTY: +.fi +.in 0 +.sp +The current logical-to-physical device assignment is changed by typing a STAT +command of the form: +.sp +.ti 8 +STAT ld1 = pd1, ld2 = pd2, ... , ldn = pdn +.sp +where ld1 through ldn are logical device names and pd1 through pdn are +compatible physical device names. For example, ldi and pdi appear on the +same line +in the VAL: command shown above. The following example shows valid STAT +commands that change the +current logical-to-physical device assignments: +.sp +.in 8 +.nf +STAT CON:=CRT: +STAT PUN:=TTY:, LST:=LPT:, RDR:=TTY: +.in 0 +.fi +.pp +The command form, +.sp +.ti 8 +STAT d:filename.typ $S +.sp +where d: is an optional drive name and filename.typ is an unambiguous or +ambiguous filename, produces the following output display format: +.sp 2 +.in 8 +.nf +Size Recs Bytes Ext Acc +.sp + 48 48 6K 1 R/O A:ED.COM + 55 55 12K 1 R/O (A:PIP.COM) +65536 128 16K 2 R/W A:X.DAT +.in 0 +.fi +.sp 2 +where the $S parameter causes the Size field to be displayed. Without the +$S, the Size field is skipped, but the remaining fields are displayed. The +Size field lists the virtual file size in records, while the Recs field +sums the number of virtual records in each extent. For files constructed +sequentially, the Size and Recs fields are identical. The Bytes field +lists the actual number of bytes allocated to the corresponding file. The +minimum allocation unit is determined at configuration time; thus, the number +of bytes corresponds to the record count plus the remaining unused space in +the last allocated block for sequential files. Random access files are given +data areas only when written, so the Bytes field contains the only accurate +allocation figure. In the case of random access, the Size field gives the +logical end-of-file record position and the Recs field counts the logical +records of each extent. Each of these extents, however, can contain +unallocated holes even though they are added into the record count. +.pp +The Ext field counts the number of physical extents allocated to the file. +The Ext count corresponds to the number of directory entries given to the +file. Depending on allocation size, there can be up to 128K +bytes (8 logical extents) directly addressed by a single directory entry. In a special case, +there are actually 256K bytes that can be directly addressed by a physical +extent. +.pp +The Acc field gives the R/O or R/W file indicator, which you can +change using the commands shown. The four command forms, +.sp +.nf +.in 8 +STAT d:filename.typ $R/O +STAT d:filename.typ $R/W +STAT d:filename.typ $SYS +STAT d:filename.typ $DIR +.in 0 +.fi +.sp +set or reset various permanent file indicators. The R/O indicator places the +file, or set of files, in a Read-Only status until changed by a subsequent +STAT command. The R/O status is recorded in the directory with the file so +that it remains R/O through intervening cold start operations. The R/W +indicator places the file in a permanent Read-Write status. The SYS +indicator attaches the system indicator to the file, while the DIR command +removes the system indicator. The filename.typ may be ambiguous or +unambiguous, but files whose attributes are changed are listed at the console +when the change occurs. The drive name denoted by d: is optional. +.pp +When a file is marked R/O, subsequent attempts to erase or write into the +file produce the following BDOS message at your screen: +.sp +.ti 8 +BDOS Err on d: File R/O +.sp +lists the drive characteristics of the disk named by d: that is in the range +A:, B:,...,P:. The drive characteristics are listed in the +following format: +.sp +.nf + d: Drive Characteristics + 65536: 128 Byte Record Capacity + 8192: Kilobyte Drive Capacity + 128: 32 Byte Directory Entries + 0: Checked Directory Entries + 1024: Records/Extent + 128: Records/Block + 58: Sectors/Track + 2: Reserved Tracks +.fi +.sp +where d: is the selected drive, followed by the total record capacity +(65536 is an eight-megabyte drive), followed by the total capacity listed in +kilobytes. The directory size is listed next, followed by the checked +entries. The number of checked entries is usually identical to the directory +size for removable media, because this mechanism is used to detect changed +media during CP/M operation without an intervening warm start. For fixed +media, the number is usually zero, because the media are not changed without +at least a cold or warm start. +.pp +The number of records per extent determines +the addressing capacity of each directory entry (1024 times 128 bytes, or +128K in the previous example). The number of records per block shows the +basic allocation size (in the example, 128 records/block times 128 bytes per +record, or 16K bytes per block). The listing is then followed by the number +of physical sectors per track and the number of reserved tracks. +.pp +For logical +drives that share the same physical disk, the number of reserved tracks can +be quite large because this mechanism is used to skip lower-numbered disk +areas allocated to other logical disks. The command form +.sp +.ti 8 +STAT DSK: +.sp +produces a drive characteristics table for all currently active drives. The +final STAT command form is +.sp +.ti 8 +STAT USR: +.sp +which produces a list of the user numbers that have files on the currently +addressed disk. The display format is +.sp +.nf +.in 8 +Active User: 0 +Active Files: 0 1 3 +.in 0 +.fi +.sp +where the first line lists the currently addressed user number, as set by the +last CCP USER command, followed by a list of user numbers scanned from the +current directory. In this case, the active user number is 0 (default at cold +start) with three user numbers that have active files on the current disk. +The operator can subsequently examine the directories of the other user +numbers by logging in with USER 1 or USER 3 commands, followed by a DIR +command at the CCP level. +.sp 2 +.tc 1.6.2 ASM Command +.sh +1.6.2 ASM Command +.qs +.sp +Syntax: +.sp +.ti 8 +ASM ufn +.pp +The ASM command loads and executes the CP/M 8080 assembler. The ufn +specifies a source file containing assembly language statements, where the +filetype is assumed to be ASM and is not specified. The following ASM +commands are valid: +.sp +.nf +.in 8 +ASM X +ASM GAMMA +.in 0 +.fi +.sp +The two-pass assembler is automatically executed. Assembly errors that occur +during the second pass are printed at the console. +.pp +The assembler produces a file: +.sp +.ti 8 +X.PRN +.sp +where X is the primary name specified in the ASM command. The PRN file +contains a listing of the source program with embedded tab characters if +present in the source program, along with the machine code generated for +each statement and diagnostic error messages, if any. The PRN file is listed +at the console using the TYPE command, or sent to a peripheral device +using PIP (see Section 1.6.4). Note that the PRN file +contains the original source program, augmented by miscellaneous assembly +information in the leftmost 16 columns; for example, program addresses and +hexadecimal +machine code. The PRN file serves as a backup for the original +source file. If the source file is accidentally removed or destroyed, the +PRN file can be edited by removing the leftmost 16 characters +of each line (see Section 2). This is done by issuing a single editor macro +command. +The resulting file is identical to the original source file and can be +renamed from PRN to ASM for subsequent editing and assembly. The file +.sp +.ti 8 +X.HEX +.sp +is also produced, which contains 8080 machine language in Intel HEX format +suitable for subsequent loading and execution (see Section 1.6.3). For +complete details of CP/M's assembly language program, see Section 3. +.pp +The source file for assembly is taken from an alternate disk by prefixing the +assembly language filename by a disk drive name. The command +.sp +.ti 8 +ASM B:ALPHA +.sp +loads the assembler from the currently logged drive and processes the source +program ALPHA.ASM on drive B. The HEX and PRN files are also placed on +drive B in this case. +.he CP/M Operating System Manual 1.6 Transient Commands +.sp 2 +.tc 1.6.3 LOAD Command +.sh +1.6.3 LOAD Command +.qs +.sp +Syntax: +.sp +.ti 8 +LOAD ufn +.pp 5 +The LOAD command reads the file ufn, which is assumed to contain HEX format +machine code, and produces a memory image file that can subsequently be +executed. The filename ufn is assumed to be of the form: +.sp +.ti 8 +X.HEX +.sp +and only the filename X need be specified in the command. The LOAD command +creates a file named +.sp +.ti 8 +X.COM +.sp +that marks it as containing machine executable code. The file is actually +loaded into memory and executed when the user types the filename X +immediately after the prompting character > printed by the CCP. +.pp +Generally, the CCP reads the filename X following the prompting character and +looks for a built-in function name. If no function name is found, the CCP +searches the system disk directory for a file by the name +.sp +.ti 8 +X.COM +.mb 5 +.fm 1 +.sp +If found, the machine code is loaded into the TPA, and the program executes. +Thus, the user need only LOAD a hex file once; it can be subsequently +executed any number of times by typing the primary name. This +way, you can invent new commands in the CCP. Initialized disks contain +the transient commands as COM files, which are optionally deleted. The +operation takes place on an alternate drive if the filename is prefixed +by a drive name. Thus, +.bp +.mb 6 +.fm 2 +.sp +.ti 8 +LOAD B:BETA +.sp +brings the LOAD program into the TPA from the currently logged disk and +operates on drive B after execution begins. +.sp +.sh +Note: \c +.qs +the BETA.HEX file must contain valid Intel format +hexadecimal machine code records (as produced by the ASM program, for +example) that begin at 100H of the TPA. The addresses in the hex records +must be in ascending order; gaps in unfilled memory regions are filled with +zeroes by the LOAD command as the hex records are read. Thus, LOAD must be +used only for creating CP/M standard COM files that operate in the TPA. +Programs that occupy regions of memory other than the TPA are loaded under +DDT. +.sp 2 +.tc 1.6.4 PIP +.sh +1.6.4 PIP +.qs +.sp +.ul +Syntax: +.qu +.sp +.in 8 +.nf +PIP +PIP destination=source#1, source#2, ..., source #n +.fi +.in 0 +.pp +PIP is the CP/M Peripheral Interchange Program that implements the basic +media conversion operations necessary to load, print, punch, copy, and +combine disk files. The PIP program is initiated by typing one of the +following forms: +.sp +.nf +.in 8 +PIP +PIP command line +.fi +.in 0 +.sp +In both cases PIP is loaded into the TPA and executed. In the +first form, PIP reads command lines directly from the console, prompted with +the * character, until an empty command line is typed (for example, a single +carriage return is issued by +the operator). Each successive command line causes some media conversion +to take place according to the rules shown below. +.pp +In the second form, the PIP +command is equivalent to the first, except that the single command line +given with the PIP command is automatically executed, and PIP terminates +immediately with no further prompting of the console for input command +lines. The form of each command line is +.sp +.ti 8 +destination = source#1, source#2, ..., source#n +.sp +where destination is the file or peripheral device to receive the +data, +and source#1, ..., source#n is a series of one or more files or devices +that are copied from left to right to the destination. +.pp +When multiple files are given in the command line (for example, +n>1), the individual +files are assumed to contain ASCII characters, with an assumed CP/M +end-of-file character (CTRL-Z) at the end of each file (see the O parameter +to override this assumption). Lower-case ASCII alphabetics are internally +translated to upper-case to be consistent with CP/M file and device name +conventions. Finally, the total command line length cannot exceed 255 +characters. CTRL-E can be used to force a physical carriage return for lines +that exceed the console width. +.pp +The destination and source elements are unambiguous references to CP/M source +files with or without a preceding disk drive name. That is, any file can be +referenced with a preceding drive name (A: through P:) that defines the +particular drive where the file can be obtained or stored. When the drive +name is not included, the currently logged disk is assumed. The +destination file can also appear as one or more of the source files, in +which case the source file is not altered until the entire concatenation is +complete. If it already exists, the destination file is removed if the +command line is properly formed. It is not removed if an error condition +arises. The following command lines, with explanations to the +right, are +valid as input to PIP: +.sp 2 +.in 31 +.ti -23 +X=Y Copies to file X from file Y, where X and Y are +unambiguous filenames; Y remains unchanged. +.sp +.ti -23 +X=Y,Z Concatenates files Y and z and copies to file X, +with Y and Z unchanged. +.sp +.ti -23 +X.ASM=Y.ASM,Z.ASM Creates the file X.ASM from the concatenation of the +Y and Z.ASM files. +.sp +.ti -23 +NEW.ZOT=B:OLD.ZAP Moves a copy of OLD.ZAPP from drive B to the currently +logged disk; names the file NEW.ZOT. +.sp +.ti -23 +B:A.U=B:B.V,A:C.W,D.X Concatenates file B.V from drive B with C.W from drive +a and D.X from the logged disk; creates the file A.U on drive b. +.in 0 +.sp +.pp +For convenience, PIP allows abbreviated commands for transferring files +between disk drives. The abbreviated PIP forms are +.sp +.in 8 +.nf +PIP d:=afn +PIP d\d1\u=d\d2\u:afn +PIP ufn = d\d2\u: +PIP d\d1\u:ufn = d\d2\u: +.fi +.in 0 +.sp +The first form copies all files from the currently logged disk that satisfy +the afn to the same files on drive d, where d = A...P. The second form is +equivalent to the first, where the source for the copy is drive +d\d2\u, where d\d2\u = A...P. The third form is equivalent to the command PIP +d\d1\u:ufn=d\d2\u:ufn which copies the file given by ufn from drive +d\d2\u to the file ufn on drive d\d1\u:. The fourth form is equivalent to +the third, where the source disk is explicitly given by d\d2\u:. +.pp +The source and destination disks must be different in all of these cases. +If an afn is specified, PIP lists each ufn that satisfies the afn as it +is being copied. If a file exists by the same name as the destination file, +it is removed after successful completion of the copy and replaced by the +copied file. +.pp +The following PIP commands give examples of valid disk-to-disk copy operations: +.sp 2 +.in 24 +.ti -16 +B:=*.COM Copies all files that have the secondary name COM to +drive B from the current drive. +.sp +.ti -16 +A:=B:ZAP.* Copies all files that have the primary name ZAP to +drive A from drive B. +.sp +.ti -16 +ZAP.ASM=B: Same as ZAP.ASM=B:ZAP.ASM +.sp +.ti -16 +B:ZOT.COM=A: Same as B:ZOT.COM=A:ZOT.COM +.sp +.ti -16 +B:=GAMMA.BAS Same as B:GAMMA.BAS=GAMMA.BAS +.sp +.ti -16 +B:=A:GAMMA.BAS Same as B:GAMMA.BAS=A:GAMMA.BAS +.in 0 +.sp +.pp +PIP allows reference to physical and logical devices that are attached to the +CP/M system. The device names are the same as given under the STAT command, +along with a number of specially named devices. The following is +a list of logical devices given in the STAT command +.sp +.in 8 +.nf +CON: (console) +RDR: (reader) +PUN: (punch) +LST: (list) +.fi +.in 0 +.sp +while the physical devices are +.sp +.in 8 +.nf +TTY: (console), reader, punch, or list) +CRT: (console, or list), UC1: (console) +PTR: (reader), UR1: (reader), UR2: (reader) +PTP: (punch), UP1: (punch), UP2: (punch) +LPT: (list), UL1: (list) +.fi +.in 0 +.sp +The BAT: physical device is not included, because this assignment is used +only to indicate that the RDR: and LST: devices are used for console +input/output. +.pp +The RDR, LST, PUN, and CON devices are all defined within the BIOS portion of +CP/M, and are easily altered for any particular I/O system. The current +physical device mapping is defined by IOBYTE; see Section 6 for a discussion +of this function. The destination device must be capable of +receiving data, for example, data cannot be sent to the punch, and the +source devices must be +capable of generating data, for example, the LST: device cannot be read. +.pp +The following list describes additional device names that can be used in +PIP commands. +.sp 2 +.in 5 +.ti -2 +o NUL: sends 40 nulls (ASCII 0s) to the device. This can be issued +at the end of punched output. +.sp +.ti -2 +o EOF: sends a CP/M end-of-file (ASCII CTRL-Z) to the destination +device (sent automatically at the end of all ASCII data transfers through PIP). +.sp +.ti -2 +o INP: is a special PIP input source that can be patched into the PIP +program. PIP gets the input data character-by-character, by CALLing location +103H, with data returned in location 109H (parity bit must be zero). +.sp +.ti -2 +o OUT: is a special PIP output destination that can be patched into the +PIP program. PIP CALLs location 106H with data in register C for each +character to transmit. Note that locations 109H through +1FFH of the PIP memory image are not used and can be replaced by special +purpose drivers using DDT (see Section 4). +.sp +.ti -2 +o PRN: is the same as LST:, except that tabs are expanded at every eighth +character position, lines are numbered, and page ejects are inserted every +60 lines with an initial eject (same as using PIP options [t8np]). +.in 0 +.sp +.pp +File and device names can be interspersed in the PIP commands. In each case, +the specific device is read until end-of-file (CTRL-Z for ASCII files, and +end-of-data for non-ASCII disk files). Data from each device or file are +concatenated from left to right until the last data source has been read. +.pp +The destination device or file is written using the data from the source +files, and an end-of-file character, CTRL-Z, is appended to the result +for ASCII files. If the destination is a disk file, a temporary file is +created ($$$ secondary name) that is changed to the actual filename only +on successful completion of the copy. Files with the extension COM are +always assumed to be non-ASCII. +.pp +The copy operation can be aborted at any time by pressing any key on the +keyboard. PIP responds with the message ABORTED to +indicate that the operation has not been completed. If any operation is +aborted, or if an error occurs during processing, PIP removes any pending +commands that were set up while using the SUBMIT command. +.pp +PIP performs a special function if the destination is a disk file with type +HEX (an Intel hex-formatted machine code file), and the source is an +external peripheral device, such as a paper tape reader. In this case, the +PIP program checks to ensure that the source file contains a properly formed +hex file, with legal hexadecimal values and checksum records. +.pp +When an +invalid input record is found, PIP reports an error message at the console +and waits for corrective action. Usually, you can open the reader +and rerun a section of the tape (pull the tape back about 20 inches). When +the tape is ready for the reread, a single carriage return is typed at the +console, and PIP attempts another read. If the tape position cannot be +properly read, continue the read by typing a return following the +error message, and enter the record manually with the ED program after +the disk file is constructed. +.pp +PIP allows the end-of-file to +be entered from the console if the source file is an RDR: device. In +this case, the PIP program reads the device and monitors the keyboard. If +CTRL-Z is typed at the keyboard, the read operation is terminated normally. +.pp +The following are valid PIP commands: +.sp 2 +.in 24 +.ti 8 +PIP LST: = X.PRN +.sp +Copies X.PRN to the LST device and +terminates the PIP program. +.sp +.ti 8 +PIP +.sp +Starts PIP for a sequence of +commands. PIP prompts with *. +.sp +.ti 8 +*CON:=X.ASM,Y.ASM,Z.ASM +.sp +Concatenates three ASM files and copies to +the CON device. +.sp +.ti 8 +*X.HEX=CON:,Y.HEX,PTR: +.sp +Creates a HEX file by reading the CON +until a CTRL-Z is typed, followed by data from Y.HEX and PTR until +a CTRL-Z is encountered. +.sp +.ti 8 +PIP PUN:=NUL:,X.ASM,EOF:,NUL: +.mb 4 +.fm 1 +.sp +Sends 40 nulls to the punch device; copies the X.ASM file to the punch, +followed by an end-of-file, CTRL-Z, and 40 more null characters. +.sp +.ti 8 +(carriage return) +.sp +A single carriage return stops PIP. +.in 0 +.bp +.pp +You can also specify one or more PIP parameters, enclosed in left and +right square brackets, separated by zero or more blanks. Each parameter +affects the copy operation, and the enclosed list of parameters must +immediately follow the affected file or device. Generally, each parameter +can be followed by an optional decimal integer value (the S and Q parameters +are exceptions). Table 1-4 describes valid PIP parameters. +.sp 2 +.ce +.sh +Table 1-4. PIP Parameters +.ll 60 +.in 5 +.nf +.sp +Parameter Meaning +.fi +.mb 6 +.fm 2 +.sp +.in 17 +.ti -10 +B Blocks mode transfer. Data are buffered by PIP until an ASCII x-off +character, CTRL-S, is received from the source device. This allows transfer +of data to a disk file from a continuous reading device, such as a cassette +reader. Upon receipt of the x-off, PIP clears the disk buffers and returns +for more input data. The amount of data that can be buffered depends on the +memory size of the host system. PIP issues an error message if the +buffers overflow. +.sp +.ti -10 +Dn Deletes characters that extend past column n in the transfer of data +to the destination from the character source. This parameter is generally +used to truncate long lines that are sent to a narrow printer or +console device. +.sp +.ti -10 +E Echoes all transfer operations to the console as they are being +performed. +.sp +.ti -10 +F Filters form-feeds from the file. All embedded form-feeds are +removed. The P parameter can be used simultaneously to insert new form-feeds. +.sp +.ti -10 +Gn Gets file from user number n (n in the range 0-15). +.sp +.ti -10 +H Transfers HEX data. All data are checked for proper Intel hex file +format. Nonessential characters between hex records are removed during the +copy operation. The console is prompted for corrective action in case +errors occur. +.sp +.ti -10 +I Ignores :00 records in the transfer of Intel hex format +file. The I parameter automatically sets the H parameter. +.bp +.ll 65 +.in 0 +.ce +.sh +Table 1-4. (continued) +.ll 60 +.in 5 +.nf +.sp +Parameter Meaning +.fi +.sp +.in 17 +.ti -10 +L Translates upper-case alphabetics to lower-case. +.sp +.ti -10 +N Adds line numbers to each line transferred to the destination, +starting at one and incrementing by 1. Leading zeroes are suppressed, and +the number is followed by a colon. If N2 is specified, leading zeroes are +included and a tab is inserted following the number. The tab is expanded if +T is set. +.sp +.ti -10 +O Transfers non-ASCII object files. The normal CP/M end-of-file is +ignored. +.sp +.ti -10 +Pn Includes page ejects at every n lines with an initial page eject. +If n = 1 or is excluded altogether, page ejects occur every 60 lines. If +the F parameter is used, form-feed suppression takes place before the new +page ejects are inserted. +.sp +.ti -10 +Qs^Z Quits copying from the source device or file when the +string s, terminated by CTRL-Z, is encountered. +.sp +.ti -10 +R Reads system files. +.sp +.ti -10 +Ss^Z Start copying from the source device when the string +s, terminated by CTRL-Z, is encountered. The S and Q parameters can be used +to abstract a particular section of a file, such as a subroutine. The +start and quit strings are always included in the copy operation. +.sp +If you specify a command line after the PIP command keyword, the CCP +translates strings +following the S and Q parameters to upper-case. If you do not +specify a command line, PIP does not perform the automatic upper-case +translation. +.sp +.ti -10 +Tn Expands tabs, CTRL-I characters, to every nth column during the +transfer of characters to the destination from the source. +.sp +.ti -10 +U Translates lower-case alphabetics to upper-case during the copy +operation. +.bp +.ll 65 +.in 0 +.ce +.sh +Table 1-4. (continued) +.ll 60 +.in 5 +.nf +.sp +Parameter Meaning +.fi +.sp +.in 17 +.ti -10 +V Verifies that data have been copied correctly by rereading after the +write operation (the destination must be a disk file). +.sp +.ti -10 +W Writes over R/O files without console interrogation. +.sp +.ti -10 +Z Zeros the parity bit on input for each ASCII character. +.in 0 +.ll 65 +.sp +.pp +The following examples show valid PIP commands that specify parameters in +the file transfer. +.sp 2 +.in 24 +.ti 8 +PIP X.ASM=B:[v] +.sp +Copies X.ASM from drive B to the current drive and verifies that the data were +properly copied. +.sp 2 +.ti 8 +PIP LPT:=X.ASM[nt8u] +.sp +Copies X.ASM to the LPT: device; numbers each line, expands tabs to every +eighth column, and translates lower-case alphabetics to upper-case. +.sp 2 +.ti 8 +PIP PUN:=X.HEX[i],Y.ZOT[h] +.sp +First copies X.HEX to the PUN: device +and ignores the trailing :00 record in X.HEX; continues the transfer of data +by reading Y.ZOT, which contains HEX records, including any :00 records +it contains. +.sp 2 +.ti 8 +PIP X.LIB=Y.ASM[sSUBRI:^z qJMP L3^z] +.sp +Copies from the file Y.ASM into the +file X.LIB. The command starts the copy when the string SUBR1: has been +found, and quits copying after the string JMP L3 is encountered. +.bp +.ti 8 +PIP PRN:=X.ASM[p50] +.sp +Sends X.ASM to the LST: device with +line numbers, expands tabs to every eighth column, and ejects +pages at every +50th line. The assumed parameter list for a PRN file is nt8p60; p50 +overrides the default value. +.in 0 +.sp +.pp +Under normal operation, PIP does not overwrite a file that is set to a +permanent R/O status. If an attempt is made to overwrite an R/O file, the +following prompt appears: +.sp +.ti 8 +DESTINATION FILE IS R/O, DELETE (Y/N)? +.sp +If you type Y, the file is overwritten. Otherwise, the following response +appears: +.sp +.ti 8 +** NOT DELETED ** +.sp +The file transfer is skipped, and PIP continues with the next +operation in sequence. To avoid the prompt and response in the case of R/O +file overwrite, the command line can include the W parameter, as +shown in this example: +.sp +.ti 8 +PIP A:=B:*.COM[W] +.sp +The W parameter copies all nonsystem files to the A drive from the B drive and +overwrites any R/O files in the process. If the operation involves several +concatenated files, the W parameter need only be included with the last file +in the list, as in this example: +.sp +.ti 8 +PIP A.DAT=B.DAT,F:NEW.DAT,G:OLD.DAT[W] +.pp +Files with the system attribute can be included in PIP transfers if the R +parameter is included; otherwise, system files are not +recognized. For example, the command line: +.sp +.ti 8 +PIP ED.COM=B:ED.COM[R] +.sp +reads the ED.COM file from the B drive, even if it has been +marked as an R/O and system file. The system file attributes are copied, if +present. +.pp +Downward compatibility with previous versions of CP/M is only maintained if +the file does not exceed one megabyte, no file attributes are set, and the +file is created by user 0. If compatibility is required with +nonstandard, for example, double-density versions of 1.4, it +might be +necessary to select 1.4 +compatibility mode when constructing the internal disk parameter block. See +Section 6 and refer to Section 6.10, which describes BIOS differences. +.bp +.sh +Note: \c +.qs +to copy files into another user area, PIP.COM must be located in that user +area. Use the following procedure to make a copy of PIP.COM in another +user area. +.sp 2 +.in 8 +.nf +USER 0 Log in user 0. + +DDT PIP.COM (note PIP size s) Load PIP to memory. + +GO Return to CCP. + +USER 3 Log in user 3. + +SAVEs PIP.COM +.fi +.in 0 +.sp 2 +In this procedure, s is the integral number of memory pages, 256-byte +segments, occupied +by PIP. The number s can be determined when PIP.COM is loaded under DDT, +by referring to the value under the NEXT display. If, for example, the next +available address is 1D00, then PIP.COM requires 1C hexadecimal +pages, or +1 times 16 + 12 = 28 pages, and the value of s is 28 in the subsequent +save. Once PIP is copied in this manner, it can be copied to another disk +belonging to the same user number through normal PIP transfers. +.nx onec + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/onec.tex b/Source/Doc/CPM 22 Manual - Testing/onec.tex new file mode 100644 index 00000000..6ab06cf0 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/onec.tex @@ -0,0 +1,683 @@ +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he CP/M Operating System Manual 1.6 Transient Commands +.ft 1-% +.pc 1 +.sp 2 +.tc 1.6.5 ED Command +.sh +1.6.5 ED Command +.qs +.sp +.ul +Syntax: +.qu +.sp 0 +.sp +.ti 8 +ED ufn +.pp 5 +The ED program is the CP/M system context editor that allows creation and +alteration of ASCII files in the CP/M environment. Complete details of +operation are given in Section 2. ED allows the operator to create and +operate upon source files that are organized as a sequence of ASCII +characters, separated by end-of-line characters (a carriage +return/line-feed +sequence). There is no practical restriction on line length (no single +line can exceed the size of the working memory) that is defined by the +number of characters typed between carriage returns. +.pp +The ED program has +a number of commands for character string searching, replacement, and +insertion that are useful for creating and correcting programs or text +files under CP/M. Although the CP/M has a limited memory work +space area (approximately 5000 characters in a 20K CP/M system), the file +size that +can be edited is not limited, since data are easily paged through this +work area. +.pp +If it does not exist, ED creates the specified source file and opens the +file for access. If the source file does exist, the +programmer appends data for editing (see the A command). The appended data +can then be +displayed, altered, and written from the work area back to the +disk (see the W command). Particular points in the program can be +automatically paged and +located by context, allowing easy access to particular +portions of a large file (see the N command). +.pp +If you type the following command line: +.sp +.ti 8 +ED X.ASM +.sp +the ED program creates an intermediate work file with the name +.sp +.ti 8 +X.$$$ +.sp +to hold the edited data during the ED run. Upon completion of ED, the +X.ASM file (original file) is renamed to X.BAK, and the edited work file is +renamed to X.ASM. Thus, the X.BAK file contains the original unedited +file, and the X.ASM file contains the newly edited file. The operator can +always return to the previous version of a file by removing the most recent +version and renaming the previous version. If the current X.ASM file has +been improperly edited, the following sequence of commands reclaim the +back-up file. +.sp 2 +.nf +.in 8 +DIR X.* Checks to see that BAK file is + available. + +ERA X.ASM Erases most recent version. + +REN X.ASM=X.BAK Renames the BAK file to ASM. +.fi +.in 0 +.sp 2 +You can abort the edit at any point (reboot, power failure, CTRL-C, +or CTRL-Q command) without destroying the original file. In this case, the +BAK file is not created and the original file is always intact. +.pp +The ED program allows the user to edit the source on one disk and create the +back-up file on another disk. This form of the ED command is +.sp +.ti 8 +ED ufn d: +.sp +where ufn is the name of the file to edit on the currently logged disk and d +is the name of an alternate drive. The ED program reads and processes the +source file and writes the new file to drive d using the name ufn. After +processing, the original file becomes the back-up file. If the operator is +addressing disk A, the following command is valid. +.sp +.ti 8 +ED X.ASM b: +.sp +This edits the file X.ASM on drive A, creating the new file X.$$$ on +drive B. After a successful edit, A:X.ASM is renamed to A:X.BAK, and +B:X.$$$ is renamed to B:X.ASM. For convenience, the currently logged disk +becomes drive B at the end of the edit. Note that if a file +named B:X.ASM exists before the editing begins, the following +message appears on the screen: +.bp +.sp +.ti 8 +FILE EXISTS +.sp +This message is a precaution against accidentally destroying +a source file. You should first erase the existing file and then restart +the edit operation. +.pp +Similar to other transient commands, editing can take place on a drive +different from the currently logged disk by preceding the source filename +by a drive name. The following are examples of valid edit +requests: +.sp 2 +.in 25 +.ti -17 +ED A:X.ASM Edits the file X.ASM on drive A, with new file and back-up +on drive A. +.sp +.ti -17 +ED B:X.ASM A: Edits the file X.ASM on drive B to the temporary file X.$$$ +on drive A. After editing, this command changes X.ASM on drive B to X.BAK +and changes X.$$$ on drive A to X.ASM. +.in 0 +.ll 65 +.sp 2 +.tc 1.6.6 SYSGEN Command +.sh +1.6.6 SYSGEN Command +.qs +.sp +Syntax: +.sp +.ti 8 +SYSGEN +.pp +The SYSGEN transient command allows generation of an initialized disk +containing the CP/M operating system. The SYSGEN program prompts the +console for commands by interacting as shown. +.sp 2 +.in 24 +.ti 8 +SYSGEN +.sp +Initiates the SYSGEN program. +.sp 2 +.ti 8 +SYSGEN VERSION x.x +.sp +SYSGEN sign-on message. +.sp 2 +.in 8 +.nf +SOURCE DRIVE NAME +(OR RETURN TO SKIP) +.in 24 +.sp +.fi +Respond with the drive name (one of the letters A, B, C, or D) of the +disk containing a CP/M system, usually A. If a copy of CP/M already exists +in memory due to a MOVCPM command, press only a carriage return. Typing a +drive name d causes the response: +.sp 2 +.ti 8 +SOURCE ON d THEN TYPE RETURN +.sp +Place a disk containing the CP/M operating +system on drive d (d is one of A, B, C, or D). Answer by pressing a carriage +return when ready. +.sp 2 +.ti 8 +FUNCTION COMPLETE +.sp +System is copied to memory. SYSGEN then prompts with the following: +.sp 2 +.nf +.in 8 +DESTINATION DRIVE NAME +(OR RETURN TO REBOOT) +.fi +.sp +.in 24 +If a disk is being initialized, place the new disk into a drive +and answer with the drive name. Otherwise, press a carriage return +and the system reboots from drive A. Typing drive name d causes +SYSGEN to prompt with the following message: +.sp 2 +.nf +.in 8 +DESTINATION ON d +THEN TYPE RETURN +.fi +.in 24 +.sp +Place new disk into drive d; press return when ready. +.sp 2 +.ti 8 +FUNCTION COMPLETE +.sp +New disk is initialized in drive d. +.in 0 +.sp 2 +The DESTINATION prompt is repeated until a single carriage return is +pressed at the console, so that more than one disk can be initialized. +.pp +Upon completion of a successful system generation, the new disk contains +the operating system, and only the built-in commands are available. An +IBM-compatible disk appears to CP/M as a disk with an +empty directory; therefore, the operator must copy the appropriate COM files +from an existing CP/M disk to the newly constructed disk using the +PIP transient. +.pp +You can copy all files from an existing disk by typing the following +PIP command: +.sp +.ti 8 +PIP B: = A:*.*[v] +.bp +This command copies all files from disk drive A to disk drive B and verifies +that +each file has been copied correctly. The name of each file is displayed at +the console as the copy operation proceeds. +.pp +Note that a SYSGEN does not destroy the files that already +exist on a disk; it only constructs a new operating system. If a +disk is being used only on drives B through P and will never be the +source of a bootstrap operation on drive A, the SYSGEN need not take place. +.sp 2 +.tc 1.6.7 SUBMIT Command +.sh +1.6.7 SUBMIT Command +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +SUBMIT ufn parm#1 ... parm#n +.pp +The SUBMIT command allows CP/M commands to be batched for automatic +processing. The ufn given in the SUBMIT command must be the filename of a +file that exists on the currently logged disk, with an assumed file type of +SUB. The SUB file contains CP/M prototype commands with possible parameter +substitution. The actual parameters parm#1 ... parm#n are substituted into +the prototype commands, and, if no errors occur, the file of substituted +commands are processed sequentially by CP/M. +.pp +The prototype command file is created using the ED program, with +interspersed $ parameters of the form: +.sp +.ti 8 +$1 $2 $3 ...$n +.sp +corresponding to the number of actual parameters that will be included when +the file is submitted for execution. When the SUBMIT transient is executed, +the actual parameters parm#1 ... parm#n are paired with the formal parameters +$1 ... $n in the prototype commands. If the numbers of formal and actual +parameters do not correspond, the SUBMIT function is aborted with an error +message at the console. The SUBMIT function creates a file of substituted +commands with the name +.mt 5 +.hm 2 +.sp +.ti 8 +$$$.SUB +.sp +on the logged disk. When the system reboots, at the termination of the +SUBMIT, this command file is read by the CCP as a source of input rather +than the console. If the SUBMIT function is performed on any disk other +than drive A, the commands are not processed until the disk is inserted into +drive A and the system reboots. You can abort command processing at +any time by pressing the rubout key when the command is read and echoed. In +this case, the $$$.SUB file is removed and the subsequent commands come +from the console. Command processing is also aborted if the CCP detects an +error in any of the commands. Programs that execute under CP/M can abort +processing of command files when error conditions occur by erasing any +existing $$$.SUB file. +.pp +To introduce dollar signs into a SUBMIT file, you can type a $$ +which reduces to a single $ within the command file. A caret, +^, precedes an alphabetic character s, which produces a single CTRL-X +character within the file. +.pp +The last command in a SUB file can initiate another SUB file, allowing +chained batch commands: +.pp +Suppose the file ASMBL.SUB exists on disk and contains the prototype commands +.sp +.in 8 +.nf +ASM $1 +DIR $1.* +ERA *.BAK +PIP $2:=$1.PRN +ERA $1.PRN +.fi +.in 0 +.sp +then, you issue the following command: +.sp +.ti 8 +SUBMIT ASMBL X PRN +.sp +The SUBMIT program reads the ASMBL.SUB file, +substituting X: for all occurrences of $1 and PRN for all occurrences of +$2. This results in a $$$.SUB file containing the commands: +.sp +.in 8 +.nf +ASM X +DIR X.* +ERA *.BAK +PIP PRN:=X.PRN +ERA X.PRN +.fi +.in 0 +.sp +which are executed in sequence by the CCP. +.pp +The SUBMIT function can access a SUB file on an alternate drive by preceding +the filename by a drive name. Submitted files are only acted upon when +they appear on drive A. Thus, it is possible to create a submitted file +on drive B that is executed at a later time when inserted in drive A. +.pp +An additional utility program called XSUB extends the power of the SUBMIT +facility to include line input to programs as well as the CCP. The XSUB +command is included as the first line of the SUBMIT +file. When it is executed, XSUB self-relocates directly below the CCP. All +subsequent SUBMIT command lines are processed by XSUB so that programs that +read buffered console input, BDOS Function 10, receive their input directly +from the SUBMIT file. For example, the file SAVER.SUB can contain the +following SUBMIT lines: +.sp +.in 8 +.nf +XSUB +DDT +|$1.COM +R +GO +SAVE 1 $2.COM +.fi +.in 0 +.sp +a subsequent SUBMIT command, such as +.sp +.ti 8 +A>\c +.sh +SUBMIT SAVER PIP Y +.qs +.sp +substitutes X for $1 and Y for $2 in the command stream. The XSUB +program loads, followed by DDT, which is sent to the command lines PIP.COM, +R, and G0, thus returning to the CCP. The final command SAVE 1 Y.COM is +processed by the CCP. +.pp +The XSUB program remains in memory and prints the message +.sp +.ti 8 +(xsub active) +.sp +on each warm start operation to indicate its presence. Subsequent SUBMIT +command streams do not require the XSUB, unless an intervening cold start +occurs. Note that XSUB must be loaded after the optional +CP/M DESPOOL utility, if both are to run simultaneously. +.sp 2 +.tc 1.6.8 DUMP Command +.sh +1.6.8 DUMP Command +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +DUMP ufn +.pp +The DUMP program types the contents of the disk file (ufn) at the console in +hexadecimal form. The file contents are listed sixteen bytes at a time, +with the absolute byte address listed to the left of each line in +hexadecimal. Long typeouts can be aborted by pressing the rubout key during +printout. The source listing of the DUMP program is given in Section 5 as +an example of a program written for the CP/M environment. +.sp 2 +.tc 1.6.9 MOVCPM Command +.sh +1.6.9 MOVCPM Command +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +MOVCPM +.pp +The MOVCPM program allows you to reconfigure the CP/M system for any +particular memory size. Two optional parameters can be used to indicate the +desired size of the new system and the disposition of the new system at +program termination. If the first parameter is omitted or an * is given, +the MOVCPM program reconfigures the system to its maximum size, based +upon the kilobytes of contiguous RAM in the host system (starting at 0000H). +If the second parameter is omitted, the system is executed, but not +permanently recorded; if * is given, the system is left in memory, ready +for a SYSGEN operation. The MOVCPM program relocates a memory image of CP/M +and places this image in memory in preparation for a system generation +operation. The following is a list of MOVCPM command forms: +.sp 2 +.in 23 +.ti -15 +MOVCPM Relocates and executes CP/M for management of the current +memory +configuration (memory is examined for contiguous RAM, starting at 100H). +On completion of the relocation, the new system is executed but not +permanently recorded on the disk. The system that is constructed +contains a BIOS for the Intel microcomputer development system 800. +.sp +.ti -15 +MOVCPM n Creates a relocated CP/M system for management of an n kilobyte +system (n must be in the range of 20 to 64), and executes the system as +described. +.sp +.ti -15 +MOVCPM * * Constructs a relocated memory image for the current memory +configuration, but leaves the memory image in memory in preparation for a +SYSGEN operation. +.sp +.ti -15 +MOVCPM n * Constructs a relocated memory image for an n kilobyte memory +system, and leaves the memory image in preparation for a SYSGEN operation. +.in 0 +.sp +.pp +For example, the command, +.sp +.ti 8 +MOVCPM * * +.sp +constructs a new version of the CP/M system and leaves it in +memory, ready for a SYSGEN operation. The message +.sp +.in 8 +.nf +READY FOR 'SYSGEN' OR +'SAVE 34 CPMxx.COM' +.fi +.in 0 +.sp +appears at the console upon completion, where xx is the current memory +size in kilobytes. You can then type the following sequence: +.sp 2 +.in 35 +.ti -27 +SYSGEN This starts the system generation. +.sp +.nf +.ti -27 +SOURCE DRIVE NAME Respond with a carriage return +.sp 0 +.fi +.ti -27 +(OR RETURN TO SKIP) to skip the CP/M read operation, because the +system is already in memory as a result of the previous MOVCPM operation. +.sp +.nf +.ti -27 +DESTINATION DRIVE NAME Respond with B to write new +.sp 0 +.fi +.ti -27 +(OR RETURN TO REBOOT) system to the disk in drive B. SYSGEN +prompts with the following message: +.sp +.mb 5 +.fm 1 +.nf +.ti -27 +DESTINATION ON B, Place the new disk on drive B +.sp 0 +.fi +.ti -27 +THEN TYPE RETURN and press the RETURN key when ready. +.in 0 +.bp +.mb 6 +.fm 2 +.pp +If you respond with A rather than B above, the system is +written to drive A rather than B. SYSGEN continues to print this +prompt: +.sp +.ti 8 +DESTINATION DRIVE NAME (OR RETURN TO REBOOT) +.sp +until you respond with a single carriage return, which stops the +SYSGEN program with a system reboot. +.pp +You can then go through the reboot process with the old or new +disk. Instead of performing the SYSGEN operation, you can +type a command of the form: +.sp +.ti 8 +SAVE 34 CPMxx.COM +.sp +at the completion of the MOVCPM function, where xx is the value indicated +in the SYSGEN message. The CP/M memory image on the currently logged disk is +in a form that can be patched. This is necessary when operating in a +nonstandard environment where the BIOS must be altered for a particular +peripheral device configuration, as described in Section 6. +.pp +The following are valid MOVCPM commands: +.sp 2 +.in 23 +.ti -15 +MOVCPM 48 Constructs a 48K version of CP/M and starts execution. +.sp +.mb 5 +.fm 1 +.ti -15 +MOVCPM 48 * Constructs a 48K version of CP/M in preparation for permanent +recording; the response is +.sp +.nf +READY FOR 'SYSGEN' OR + 'SAVE 34 CPM48.COM' +.fi +.sp +.ti -15 +MOVCPM * * Constructs a maximum memory version of CP/M and +starts execution. +.in 0 +.pp +The newly created system is serialized with the number attached to the +original disk and is subject to the conditions of the Digital Research +Software Licensing Agreement. +.sp 2 +.he CP/M Operating System Manual 1.7 BDOS Error Messages +.tc 1.7 BDOS Error Messages +.sh +1.7 BDOS Error Messages +.qs +.mb 6 +.fm 2 +.pp +There are three error situations that the Basic Disk Operating System +intercepts during file processing. When one of these conditions is detected, +the BDOS prints the message: +.sp +.ti 8 +BDOS ERR ON d: error +.bp +where d is the drive name and error is one of the three error messages: +.sp +.in 8 +.nf +BAD SECTOR +SELECT +READ ONLY +.fi +.in 0 +.pp +The BAD SECTOR message indicates that the disk controller electronics has +detected an error condition in reading or writing the disk. This +condition is generally caused by a malfunctioning disk controller or an +extremely worn disk. If you find that CP/M reports this +error more than once a month, the state of the controller electronics and the +condition of the media should be checked. +.pp +You can also encounter this condition in reading files generated +by a controller produced by a different manufacturer. Even +though controllers claim to be IBM..-compatible, one +often finds small differences in recording formats. The Model 800 controller, +for example, requires two bytes of one's following the data CRC byte, which +is not required in the IBM format. As a result, disks generated by the +Intel microcomputer development system can be read by almost all +other IBM-compatible system, while disk files generated on other +manufacturers' equipment produce the BAD SECTOR message when read +by the microcomputer development system. To recover from this +condition, press a CTRL-C to reboot (the safest course), or a +return, which ignores the bad sector in the file operation. +.sp +.sh +Note: \c +.qs +pressing a return might destroy disk integrity if the +operation is a directory write. Be sure you have adequate +back-ups in this case. +.pp +The SELECT error occurs when there is an attempt to address a drive beyond +the range supported by the BIOS. In this case, the value of d in the error +message gives the selected drive. The system reboots following any input +from the console. +.pp +The READ ONLY message occurs when there is an attempt to write to a +disk or file that has been designated as Read-Only in a STAT command or +has been set to Read-Only by the BDOS. Reboot CP/M by +using the warm start procedure, CTRL-C, or by performing a cold start +whenever the disks are changed. If a changed disk is to be read but +not written, BDOS allows the disk to be changed without the warm or +cold start, but internally marks the drive as Read-Only. The status of the +drive is subsequently changed to Read-Write if a warm or cold start occurs. +On issuing this message, CP/M waits for input from the console. An automatic +warm start takes place following any input. +.sp 2 +.he CP/M Operating System Manual 1.8 Operation of CP/M on the Model 800 +.tc 1.8 CP/M Operation on the Model 800 +.sh +1.8 CP/M Operation on the Model 800 +.pp +This section gives operating procedures for using CP/M on the +Intel Model 800 microcomputer development system microcomputer development +system. Basic knowledge of the microcomputer development system +hardware and software systems is assumed. +.pp +CP/M is initiated in essentially the same manner as the Intel ISIS operating +system. The disk drives are labeled 0 through 3 on the +microcomputer development system, corresponding +to CP/M drives A through D, respectively. The CP/M system disk is +inserted into drive 0, and the BOOT and RESET switches are pressed in +sequence. The interrupt 2 light should go on at this point. The space bar +is then pressed on the system console, and the light should go +out. If it does not, the user should check connections and baud rates. The +BOOT +switch is turned off, and the CP/M sign-on message should appear at the +selected console device, followed by the A> system prompt. You +can then issue the various resident and transient commands. +.pp +The CP/M system can be restarted (warm start) at any time by pushing the +INT 0 switch on the front panel. The built-in Intel ROM monitor can be +initiated by pushing the INT 7 switch, which generates an RST 7, except when +operating under DDT, in which case the DDT program gets control instead. +.pp +Diskettes can be removed from the drives at any time, and the system can be +shut down during operation without affecting data integrity. Do +not remove a disk and replace it with another without rebooting the +system (cold or warm start) unless the inserted disk is Read-Only. +.pp +As a result of hardware hang-ups or malfunctions, CP/M might +print the following message: +.sp +.ti 8 +BDOS ERR ON d: BAD SECTOR +.sp +where d is the drive that has a permanent error. This error can occur when +drive doors are opened and closed randomly, followed by disk operations, or +can be caused by a disk, drive, or controller failure. You can +optionally elect to ignore the error by pressing a single return at the +console. The error might produce a bad data record, requiring +reinitialization +of up to 128 bytes of data. You can reboot the CP/M system and try +the operation again. +.pp +Termination of a CP/M session requires no special action, except that it is +necessary to remove the disks before turning the power off to avoid +random transients that often make their way to the drive electronics. +.pp +You should use IBM-compatible disks rather than disks +that have previously been used with any ISIS version. In particular, the +ISIS FORMAT operation produces nonstandard sector numbering throughout the +disk. This nonstandard numbering seriously degrades the performance of +CP/M, and causes CP/M to operate noticeably slower than the distribution +version. If it becomes necessary to reformat a disk, which +should not be the case for standard disks, a program can be +written under CP/M that causes the Model 800 controller to +reformat with sequential sector numbering (1-26) on each track. +.pp +Generally, IBM-compatible 8-inch disks do not need to be formatted. +However, 5 1/4-inch disks need to be formatted. +.sp 2 +.ce +End of Section 1 +.nx two + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/part1.ix b/Source/Doc/CPM 22 Manual - Testing/part1.ix new file mode 100644 index 00000000..7277eb87 Binary files /dev/null and b/Source/Doc/CPM 22 Manual - Testing/part1.ix differ diff --git a/Source/Doc/CPM 22 Manual - Testing/part1.prn b/Source/Doc/CPM 22 Manual - Testing/part1.prn new file mode 100644 index 00000000..cf2c5c9b --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/part1.prn @@ -0,0 +1,13267 @@ +XS 9 N0 + + + + + + + + + + + + + + + + + + + + +=WCP/M + +=&SWOperating System + +=&SWManual + + + + + + + + + + +=&SCopyright (c) 1982 + +=Digital Research +=P.O. Box 579 +=160 Central Avenue +=Pacific Grove, CA 93950 +=(408) 649-3896 +=TWX 910 360 5001 + + + + +=All Rights Reserved + + + + + + + + + + + + + + + + + + 9 C0 + + + + + +=COPYRIGHT + +MCopyright (c) 1976, 1977, 1978, 1979, 1982, 1983, +XMand 1984 by Digital Research Inc. All rights +XMreserved. No part of this publication may be +XMreproduced, transmitted, transcribed, stored in a +XMretrieval system, or translated into any language or +XMcomputer language, in any form or by any means, +XMelectronic, mechanical, magnetic, optical, chemical, +XMmanual or otherwise, without the prior written +XMpermission of Digital Research Inc., Post Office Box +X579, Pacific Grove, California, 93950. + +MThus, readers are granted permission to include the +XMexample programs, either in whole or in part, in +Xtheir own programs. + + +=DISCLAIMER + +MDigital Research Inc. makes no representations or +XMwarranties with respect to the contents hereof and +XMspecifically disclaims any implied warranties of +XMmerchantability or fitness for any particular +XMpurpose. Further, Digital Research Inc. reserves +XMthe right to revise this publication and to make +XMchanges from time to time in the content hereof +XMwithout obligation of Digital Research Inc. to +Xnotify any person of such revision or changes. + + +=TRADEMARKS + +MCP/M, CP/NET, and Digital Research and its logo are +XMregistered trademarks of Digital Research. ASM, +XMDESPOOL, DDT, LINK-80, MAC, MP/M, PL/I-80 and SID +XMare trademarks of Digital Research. IBM is a +XMregistered trademark of International Business +XMMachines. Intel is a registered trademark of Intel +XMCorporation. TI Silent 700 is a trademark of Texas +XMInstruments Incorporated. Zilog and Z80 are +Xregistered trademarks of Zilog, Inc. + + + +MThe ECP/M Operating System ManualR was prepared using +XMthe Digital Research TEX Text Formatter and printed +Xin the United States of America. + + +=********************************* +=* First Edition: 1976 * +=* Second Edition: July 1982 * +=* Third Edition: March 1983 * +=* Fourth Edition: March 1984 * +=********************************* + + + + + 9 K0 + + + + +=WTable of Contents + + + +&SW1 CP/M Features and Facilities + +&S 1.1 Introduction . . . . . . . . . . . . . . . . . . . 1-1 + + 1.2 Functional Description . . . . . . . . . . . . . . 1-3 + + 1.2.1 General Command Structure . . . . . . . . . 1-3 + 1.2.2 File References . . . . . . . . . . . . . . 1-3 + + 1.3 Switching Disks . . . . . . . . . . . . . . . . . . 1-5 + 1.4 Built-in Commands . . . . . . . . . . . . . . . . . 1-6 + + 1.4.1 ERA Command . . . . . . . . . . . . . . . . 1-6 + 1.4.2 DIR Command . . . . . . . . . . . . . . . . 1-7 + 1.4.3 REN Command . . . . . . . . . . . . . . . . 1-8 + 1.4.4 SAVE Command . . . . . . . . . . . . . . . . 1-8 + 1.4.5 TYPE Command . . . . . . . . . . . . . . . . 1-9 + 1.4.6 USER Command . . . . . . . . . . . . . . . . 1-9 + + 1.5 Line Editing and Output Control . . . . . . . . . . 1-10 + + 1.6 Transient Commands . . . . . . . . . . . . . . . . 1-11 + + 1.6.1 STAT Command . . . . . . . . . . . . . . . . 1-12 + 1.6.2 ASM Command . . . . . . . . . . . . . . . . 1-18 + 1.6.3 LOAD Command . . . . . . . . . . . . . . . . 1-19 + 1.6.4 PIP . . . . . . . . . . . . . . . . . . . . 1-20 + 1.6.5 ED Command . . . . . . . . . . . . . . . . . 1-29 + 1.6.6 SYSGEN Command . . . . . . . . . . . . . . . 1-31 + 1.6.7 SUBMIT Command . . . . . . . . . . . . . . . 1-33 + 1.6.8 DUMP Command . . . . . . . . . . . . . . . . 1-35 + 1.6.9 MOVCPM Command . . . . . . . . . . . . . . . 1-35 + + 1.7 BDOS Error Messages . . . . . . . . . . . . . . . . 1-37 + + 1.8 CP/M Operation on the Model 800 . . . . . . . . . . 1-38 + + +W2 The CP/M Editor + +&S 2.1 Introduction to ED . . . . . . . . . . . . . . . . 2-1 + + 2.1.1 ED Operation . . . . . . . . . . . . . . . . 2-1 + 2.1.2 Text Transfer Functions . . . . . . . . . . 2-3 + 2.1.3 Memory Buffer Organization . . . . . . . . . 2-4 + 2.1.4 Line Numbers and ED Start-up . . . . . . . . 2-5 + 2.1.5 Memory Buffer Operation . . . . . . . . . . 2-6 + 2.1.6 Command Strings . . . . . . . . . . . . . . 2-7 + 2.1.7 Text Search and Alteration . . . . . . . . . 2-10 + 2.1.8 Source Libraries . . . . . . . . . . . . . . 2-13 + 2.1.9 Repetitive Command Execution . . . . . . . . 2-14 + + + iii + + + + + + + + +=WTable of Contents + +=&SW(continued) + + + +&S 2.2 ED Error Conditions . . . . . . . . . . . . . . . . 2-14 + + 2.3 Control Characters and Commands . . . . . . . . . . 2-16 + + +W3 CP/M Assembler + +&S 3.1 Introduction . . . . . . . . . . . . . . . . . . . 3-1 + + 3.2 Program Format . . . . . . . . . . . . . . . . . . 3-3 + + 3.3 Forming the Operand . . . . . . . . . . . . . . . . 3-4 + + 3.3.1 Labels . . . . . . . . . . . . . . . . . . . 3-4 + 3.3.2 Numeric Constants . . . . . . . . . . . . . 3-5 + 3.3.3 Reserved Words . . . . . . . . . . . . . . . 3-5 + 3.3.4 String Constants . . . . . . . . . . . . . . 3-6 + 3.3.5 Arithmetic and Logical Operators . . . . . . 3-7 + 3.3.6 Precedence of Operators . . . . . . . . . . 3-8 + + 3.4 Assembler Directives . . . . . . . . . . . . . . . 3-9 + + 3.4.1 The ORG Directive . . . . . . . . . . . . . 3-10 + 3.4.2 The END Directive . . . . . . . . . . . . . 3-10 + 3.4.3 The EQU Directive . . . . . . . . . . . . . 3-11 + 3.4.4 The SET Directive . . . . . . . . . . . . . 3-11 + 3.4.5 The IF and ENDIF Directives . . . . . . . . 3-12 + 3.4.6 The DB Directive . . . . . . . . . . . . . . 3-13 + 3.4.7 The DW Directive . . . . . . . . . . . . . . 3-14 + 3.4.8 The DS Directive . . . . . . . . . . . . . . 3-14 + + 3.5 Operation Codes . . . . . . . . . . . . . . . . . . 3-15 + + 3.5.1 Jumps, Calls, and Returns . . . . . . . . . 3-15 + 3.5.2 Immediate Operand Instructions . . . . . . . 3-17 + 3.5.3 Increment and Decrement Instructions . . . . 3-17 + 3.5.4 Data Movement Instructions . . . . . . . . . 3-18 + 3.5.5 Arithmetic Logic Unit Operations . . . . . . 3-19 + 3.5.6 Control Instructions . . . . . . . . . . . . 3-21 + + 3.6 Error Messages . . . . . . . . . . . . . . . . . . 3-21 + + 3.7 A Sample Session . . . . . . . . . . . . . . . . . 3-23 + + + + + + + + + iv + + + + + + + + +=WTable of Contents + +=&SW(continued) + + + +&SW4 CP/M Dynamic Debugging Tool + +&S 4.1 Introduction . . . . . . . . . . . . . . . . . . . 4-1 + + 4.2 DDT Commands . . . . . . . . . . . . . . . . . . . 4-3 + + 4.2.1 The A (Assembly) Command . . . . . . . . . . 4-3 + 4.2.2 The D (Display) Command . . . . . . . . . . 4-4 + 4.2.3 The F (Fill) Command . . . . . . . . . . . . 4-5 + 4.2.4 The G (Go) Command . . . . . . . . . . . . . 4-5 + 4.2.5 The I (Input) Command . . . . . . . . . . . 4-6 + 4.2.6 The L (List) Command . . . . . . . . . . . . 4-6 + 4.2.7 The M (Move) Command . . . . . . . . . . . . 4-7 + 4.2.8 The R (Read) Command . . . . . . . . . . . . 4-7 + 4.2.9 The S (Set) Command . . . . . . . . . . . . 4-8 + 4.2.1- The T (Trace) Command . . . . . . . . . . . 4-8 + 4.2.11 The U (Untrace) Command . . . . . . . . . . 4-9 + 4.2.12 The X (Examine) Command . . . . . . . . . . 4-9 + + 4.3 Implementation Notes . . . . . . . . . . . . . . . 4-10 + + 4.4 A Sample Program . . . . . . . . . . . . . . . . . 4-11 + + +W5 CP/M 2 System Interface + +&S 5.1 Introduction . . . . . . . . . . . . . . . . . . . 5-1 + + 5.2 Operating System Call Conventions . . . . . . . . . 5-3 + + 5.3 A Sample File-to-File Copy Program . . . . . . . . 5-35 + + 5.4 A Sample File Dump Utility . . . . . . . . . . . . 5-38 + + 5.5 A Sample Random Access Program . . . . . . . . . . 5-42 + + 5.6 System Function Summary . . . . . . . . . . . . . . 5-50 + + +W6 CP/M 2 Alteration + +&S 6.1 Introduction . . . . . . . . . . . . . . . . . . . 6-1 + + 6.2 First-level System Regeneration . . . . . . . . . . 6-2 + + 6.3 Second-level System Generation . . . . . . . . . . 6-5 + + 6.4 Sample GETSYS and PUTSYS Programs . . . . . . . . . 6-9 + + + + v + + + + + + + + +=WTable of Contents + +=&SW(continued) + + + +&S 6.5 Disk Organization . . . . . . . . . . . . . . . . . 6-11 + + 6.6 The BIOS Entry Points . . . . . . . . . . . . . . . 6-13 + + 6.7 A Sample BIOS . . . . . . . . . . . . . . . . . . . 6-21 + + 6.8 A Sample Cold Start Loader . . . . . . . . . . . . 6-21 + + 6.9 Reserved Locations in Page Zero . . . . . . . . . . 6-22 + + 6.10 Disk Parameter Tables . . . . . . . . . . . . . . 6-23 + + 6.11 The DISKDEF Macro Library . . . . . . . . . . . . 6-28 + + 6.12 Sector Blocking and Deblocking . . . . . . . . . . 6-32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vi + + + + + + + + +=WAppendixes + + + +&SWA &SBasic Input/Output System (BIOS) . . . . . . . . . . . A-1 + + +WB &SA Skeletal CBIOS . . . . . . . . . . . . . . . . . . . B-1 + + +WC &SA Skeletal GETSYS/PUTSYS Program . . . . . . . . . . . C-1 + + +WD &SThe Model 800 Cold Start Loader for CP/M 2 . . . . . . D-1 + + +WE &SA Skeletal Cold Start Loader . . . . . . . . . . . . . E-1 + + +WF &SCP/M Disk Definition Library . . . . . . . . . . . . . F-1 + + +WG &SBlocking and Deblocking Algorithms . . . . . . . . . . G-1 + + +WH &SGlossary . . . . . . . . . . . . . . . . . . . . . . . H-1 + + +WI &SCP/M Error Messages . . . . . . . . . . . . . . . . . . I-1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vii + + + + + + + + +=WTables, Figures, and Listings + + + +&SWTables + +&S 1-1. Line-editing Control Characters . . . . . . . . 1-10 + 1-2. CP/M Transient Commands . . . . . . . . . . . . 1-11 + 1-3. Physical Devices . . . . . . . . . . . . . . . 1-14 + 1-4. PIP Parameters . . . . . . . . . . . . . . . . 1-24 + + 2-1. ED Text Transfer Commands . . . . . . . . . . . 2-3 + 2-2. Editing Commands . . . . . . . . . . . . . . . 2-6 + 2-3. Line-editing Controls . . . . . . . . . . . . . 2-7 + 2-4. Error Message Symbols . . . . . . . . . . . . . 2-13 + 2-5. ED Control Characters . . . . . . . . . . . . . 2-14 + 2-6. ED Commands . . . . . . . . . . . . . . . . . . 2-15 + + 3-1. Reserved Characters . . . . . . . . . . . . . . 3-6 + 3-2. Arithmetic and Logical Operators . . . . . . . 3-7 + 3-3. Assembler Directives . . . . . . . . . . . . . 3-9 + 3-4. Jumps, Calls, and Returns . . . . . . . . . . . 3-15 + 3-5. Immediate Operand Instructions . . . . . . . . 3-16 + 3-6. Increment and Decrement Instructions . . . . . 3-17 + 3-7. Data Movement Instructions . . . . . . . . . . 3-17 + 3-8. Arithmetic Logic Unit Operations . . . . . . . 3-18 + 3-9. Error Codes . . . . . . . . . . . . . . . . . . 3-20 + 3-10. Error Messages . . . . . . . . . . . . . . . . 3-21 + + 4-1. Line-editing Controls . . . . . . . . . . . . . 4-2 + 4-2. DDT Commands . . . . . . . . . . . . . . . . . 4-2 + 4-3. CPU Registers . . . . . . . . . . . . . . . . . 4-9 + + 5-1. CP/M Filetypes . . . . . . . . . . . . . . . . 5-6 + 5-2. File Control Block Fields . . . . . . . . . . . 5-7 + 5-3. Edit Control Characters . . . . . . . . . . . . 5-20 + + 6-1. Standard Memory Size Values . . . . . . . . . . 6-2 + 6-2. Common Values for CP/M Systems . . . . . . . . 6-7 + 6-3. CP/M Disk Sector Allocation . . . . . . . . . . 6-11 + 6-4. IOBYTE Field Values . . . . . . . . . . . . . . 6-15 + 6-5. BIOS Entry Points . . . . . . . . . . . . . . . 6-16 + 6-6. Reserved Locations in Page Zero . . . . . . . . 6-21 + 6-7. Disk Parameter Headers . . . . . . . . . . . . 6-23 + 6-8. BSH and BLM Values . . . . . . . . . . . . . . 6-25 + 6-9. EXM Values . . . . . . . . . . . . . . . . . . 6-25 + 6-10. BLS Tabluation . . . . . . . . . . . . . . . . 6-26 + + I-1. CP/M Error Messages . . . . . . . . . . . . . . I-1 + + +WFigures + +&S 2-1. Overall ED Operation . . . . . . . . . . . . . 2-2 + 2-2. Memory Buffer Organization . . . . . . . . . . 2-2 + + + viii + + + + + + + + +=WTables, Figures, and Listings + +=&SW(continued) + + + +&SWFigures + +&S 2-3. Logical Organization of Memory Buffer . . . . . 2-4 + + 5-1. CP/M Memory Organization . . . . . . . . . . . 5-1 + 5-2. File Control Block Format . . . . . . . . . . . 5-7 + + 6-1. IOBYTE Fields . . . . . . . . . . . . . . . . . 6-15 + 6-2. Disk Parameter Header Format . . . . . . . . . 6-22 + 6-3. Disk Parameter Header Table . . . . . . . . . . 6-23 + 6-4. Disk Parameter Block Format . . . . . . . . . . 6-24 + 6-5. AL0 and AL1 . . . . . . . . . . . . . . . . . . 6-25 + + +WListings + +&S 6-1. GETSYS Program . . . . . . . . . . . . . . . . 6-9 + 6-2. BIOS Entry Points . . . . . . . . . . . . . . . 6-13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ix + + + + + + + + +=WSection 1 + +=&SWCP/M Features and Facilities + + + +&SW1.1 Introduction + + M&SCP/M is a monitor control program for microcomputer system +XMdevelopment that uses floppy disks or Winchester hard disks for +XMbackup storage. Using a computer system based on the Intel 8080 +XMmicrocomputer, CP/M provides an environment for program +XMconstruction, storage, and editing, along with assembly and program +XMcheck-out facilities. CP/M can be easily altered to execute with +XMany computer configuration that uses a Zilog Z80 or an Intel 8080 +XMCentral Processing Unit (CPU) and has at least 20K bytes of main +XMmemory with up to 16 disk drives. A detailed discussion of the +XMmodifications required for any particular hardware environment is +XMgiven in Section 6. Although the standard Digital Research version +XMoperates on a single-density Intel Model 800, microcomputer +XMdevelopment system several different hardware manufacturers support +Xtheir own input-output (I/O) drivers for CP/M. + + MThe CP/M monitor provides rapid access to programs through a +XMcomprehensive file management package. The file subsystem supports +XMa named file structure, allowing dynamic allocation of file space as +XMwell as sequential and random file access. Using this file system, +XMa large number of programs can be stored in both source and machine- +Xexecutable form. + + MCP/M 2 is a high-performance, single console operating system +XMthat uses table-driven techniques to allow field reconfiguration to +XMmatch a wide variety of disk capacities. All fundamental file +XMrestrictions are removed, maintaining upward compatibility from +Xprevious versions of release 1. + + MFeatures of CP/M 2 include field specification of one to +XMsixteen logical drives, each containing up to eight megabytes. Any +XMparticular file can reach the full drive size with the capability of +XMexpanding to thirty-two megabytes in future releases. The directory +XMsize can be field-configured to contain any reasonable number of +XMentries, and each file is optionally tagged with Read-Only and +XMsystem attributes. Users of CP/M 2 are physically separated by user +XMnumbers, with facilities for file copy operations from one user area +XMto another. Powerful relative-record random access functions are +XMpresent in CP/M 2 that provide direct access to any of the 65536 +Xrecords of an eight-megabyte file. + + MCP/M also supports ED, a powerful context editor, ASM , an +XMIntel-compatible assembler, and DDT , debugger subsystems. Optional +XMsoftware includes a powerful Intel-compatible macro assembler, +XMsymbolic debugger, along with various high-level languages. When +XMcoupled with CP/M's Console Command Processor (CCP), the resulting +Xfacilities equal or exceed similar large computer facilities. + + + + 1-1 + + + + + +CP/M Operating System Manual 1.1 Introduction + + + CP/M is logically divided into several distinct parts: + + o BIOS (Basic I/O System), hardware-dependent + o BDOS (Basic Disk Operating System) + o CCP (Console Command Processor) + o TPA (Transient Program Area) + + MThe BIOS provides the primitive operations necessary to access +XMthe disk drives and to interface standard peripherals: teletype, +XMCRT, paper tape reader/punch, and user-defined peripherals. You can +XMtailor peripherals for any particular hardware environment by +XMpatching this portion of CP/M. The BDOS provides disk management by +XMcontrolling one or more disk drives containing independent file +XMdirectories. The BDOS implements disk allocation strategies that +XMprovide fully dynamic file construction while minimizing head +XMmovement across the disk during access. The BDOS has entry points +XMthat include the following primitive operations, which the program +Xaccesses: + + o SEARCH looks for a particular disk file by name. + o OPEN opens a file for further operations. + o CLOSE closes a file after processing. + o RENAME changes the name of a particular file. + o READ reads a record from a particular file. + o WRITE writes a record to a particular file. + o MSELECT selects a particular disk drive for further operations. +X + MThe CCP provides a symbolic interface between your console and +XMthe remainder of the CP/M system. The CCP reads the console device +XMand processes commands, which include listing the file directory, +XMprinting the contents of files, and controlling the operation of +XMtransient programs, such as assemblers, editors, and debuggers. The +XMstandard commands that are available in the CCP are listed in +XSection 1.2.1. + + MThe last segment of CP/M is the area called the Transient +XMProgram Area (TPA). The TPA holds programs that are loaded from the +XMdisk under command of the CCP. During program editing, for example, +XMthe TPA holds the CP/M text editor machine code and data areas. +XMSimilarly, programs created under CP/M can be checked out by loading +Xand executing these programs in the TPA. + + MAny or all of the CP/M component subsystems can be overlaid by +XMan executing program. That is, once a user's program is loaded into +XMthe TPA, the CCP, BDOS, and BIOS areas can be used as the program's +XMdata area. A bootstrap loader is programmatically accessible +XMwhenever the BIOS portion is not overlaid; thus, the user program +XMneed only branch to the bootstrap loader at the end of execution and +Xthe complete CP/M monitor is reloaded from disk. + + MThe CP/M operating system is partitioned into distinct modules, +XMincluding the BIOS portion that defines the hardware environment in +XMwhich CP/M is executing. Thus, the standard system is easily +XMmodified to any nonstandard environment by changing the peripheral +Xdrivers to handle the custom system. + + + 1-2 + + + + + +CP/M Operating System Manual 1.2 Functional Description + + +W1.2 Functional Description + + MY&Sou interact with CP/M primarily through the CCP, which reads +XMand interprets commands entered through the console. In general, +XMthe CCP addresses one of several disks that are on-line. The +XMstandard system addresses up to sixteen different disk drives. +XMThese disk drives are labeled A through P. A disk is logged-in if +XMthe CCP is currently addressing the disk. To clearly indicate which +XMdisk is the currently logged disk, the CCP always prompts the +XMoperator with the disk name followed by the symbol >, indicating +XMthat the CCP is ready for another command. Upon initial start-up, +XMthe CP/M system is loaded from disk A, and the CCP displays the +Xfollowing message: + + CP/M VER x.x + +Mwhere x.x is the CP/M version number. All CP/M systems are +XMinitially set to operate in a 20K memory space, but can be easily +XMreconfigured to fit any memory size on the host system (see Section +XM1.6.9). Following system sign-on, CP/M automatically logs in disk +XMA, prompts you with the symbol A>, indicating that CP/M is currently +XMaddressing disk A, and waits for a command. The commands are +XMimplemented at two levels: built-in commands and transient +Xcommands. + + +W1.2.1 General Command Structure + + MB&Suilt-in commands are a part of the CCP program, while +XMtransient commands are loaded into the TPA from disk and executed. +XThe following are built-in commands: + + o ERA erases specified files. + o DIR lists filenames in the directory. + o REN renames the specified file. + o SAVE saves memory contents in a file. + o TYPE types the contents of a file on the logged disk. + +MMost of the commands reference a particular file or group of files. +XThe form of a file reference is specified in Section 1.2.2. + + +W1.2.2 File References + + MA&S file reference identifies a particular file or group of files +XMon a particular disk attached to CP/M. These file references are +XMeither unambiguous (ufn) or ambiguous (afn). An unambiguous file +XMreference uniquely identifies a single file, while an ambiguous file +Xreference is satisfied by a number of different files. + + MFile references consist of two parts: the primary filename and +XMthe filetype. Although the filetype is optional, it usually is +XMgeneric. For example, the filetype ASM is used to denote that the +XMfile is an assembly language source file, while the primary filename +XMdistinguishes each particular source file. The two names are +Xseparated by a period, as shown in the following example: + + 1-3 + + + + + +CP/M Operating System Manual 1.2 Functional Description + + + filename.typ + +MIn this example, filename is the primary filename of eight +XMcharacters or less, and typ is the filetype of no more than three +Xcharacters. As mentioned above, the name + + filename + +Mis also allowed and is equivalent to a filetype consisting of three +XMblanks. The characters used in specifying an unambiguous file +Xreference cannot contain any of the following special characters: + + < > . , ; : = ? * [ ] _ % | ( ) / \textbackslash + +Mwhile all alphanumerics and remaining special characters are +Xallowed. + + MAn ambiguous file reference is used for directory search and +XMpattern matching. The form of an ambiguous file reference is +XMsimilar to an unambiguous reference, except the symbol ? can be +XMinterspersed throughout the primary and secondary names. In various +XMcommands throughout CP/M, the ? symbol matches any character of a +Xfilename in the ? position. Thus, the ambiguous reference + + X?Z.C?M + +matches the following unambiguous filenames + + XYZ.COM + +and + + X3Z.CAM + +MThe * wildcard character can also be used in an ambiguous file +XMreference. The * character replaces all or part of a filename or +Xfiletype. Note that + + *.* + +equals the ambiguous file reference + + ????????.??? + +while + + filename.* + +and + + *.typ + +are abbreviations for + + filename.??? + + + 1-4 + + + + + +CP/M Operating System Manual 1.2 Functional Description + + + +and + + ????????.typ + +respectively. As an example, + + A>WDIR *.* + +Mi&Ss interpreted by the CCP as a command to list the names of all disk +XMfiles in the directory. The following example searches only for a +Xfile by the name X.Y: + + A>WDIR X,Y + +S&Similarly, the command + + A>WDIR X?Y.C?M + +Mc&Sauses a search for all unambiguous filenames on the disk that +Xsatisfy this ambiguous reference. + + MThe following file references are valid unambiguous file +Xreferences: + + X + X.Y + XYZ + XYZ.COM + GAMMA + GAMMA.1 + + MAs an added convenience, the programmer can generally specify +XMthe disk drive name along with the filename. In this case, the +XMdrive name is given as a letter A through P followed by a colon (:). +XMThe specified drive is then logged-in before the file operation +XMoccurs. Thus, the following are valid file references with disk +Xname prefixes: + + A:X.Y + P:XYZ.COM + B:XYZ + B:X.A?M + C:GAMMA + C:*.ASM + +MAll alphabetic lower-case letters in file and drive names are +Xtranslated to upper-case when they are processed by the CCP. + + +W1.3 Switching Disks + + MT&She operator can switch the currently logged disk by typing the +XMdisk drive name, A through P, followed by a colon when the CCP is +XMwaiting for console input. The following sequence of prompts and +Xcommands can occur after the CP/M system is loaded from disk A: + + 1-5 + + + + + +CP/M Operating System Manual 1.3 Switching Disks + + + + CP/M VER 2.2 + A>WDIR &SList all files on disk A. + A:SAMPLE ASM SAMPLE PRN + A>WB: &SSwitch to disk B. + B>WDIR *.ASM &SList all ASM files on B. + B:DUMP ASM FILES ASM + b>WA: &SSwitch back to A. + + +W1.4 Built-in Commands + + MT&She file and device reference forms described can now be used +XMto fully specify the structure of the built-in commands. Assume the +Xfollowing abbreviations in the description below: + + ufn unambiguous file reference + afn ambiguous file reference + +MRecall that the CCP always translates lower-case characters to +XMupper-case characters internally. Thus, lower-case alphabetics are +XMtreated as if they are upper-case in command names and file +Xreferences. + + +W1.4.1 ERA Command + +S&Syntax: + + ERA afn + + MThe ERA (erase) command removes files from the currently +XMlogged-in disk, for example, the disk name currently prompted by +XMCP/M preceding the >. The files that are erased are those that +XMsatisfy the ambiguous file reference afn. The followingE examplRes +Xillustrate the use of ERA: + + + ERA X.Y MThe file named X.Y on the currently logged +X Mdisk is removed from the disk directory and +X the space is returned. + + ERA X.* MAll files with primary name X are removed +X from the current disk. + + ERA *.ASM MAll files with secondary name ASM are +X removed from the current disk. + + ERA X?Y.C?M MAll files on the current disk that satisfy +X Mthe ambiguous reference X?Y.C?M are +X deleted. + + + + + + + 1-6 + + + + + +CP/M Operating System Manual 1.4 Built-in Commands + + + ERA *.* MErase all files on the current disk. In +X Mthis case, the CCP prompts the console with +X the message + + ALL FILES (Y/N)? + + Mwhich requires a Y response before files +X are actually removed. + + ERA b:*.PRN MAll files on drive B that satisfy the +X Mambiguous reference ????????.PRN are +X Mdeleted, independently of the currently +X logged disk. + + + +W1.4.2 DIR Command + +S&Syntax: + + DIR afn + + MThe DIR (directory) command causes the names of all files that +XMsatisfy the ambiguous filename afn to be listed at the console +Xdevice. As a special case, the command + + DIR + +Mlists the files on the currently logged disk (the command DIR is +XMequivalenEt to thRe command DIR *.*). The following are valid DIR +Xcommands: + + DIR X.Y + DIR X?Z.C?M + DIR ??.Y + + MSimilar to other CCP commands, the afn can be preceded by a +XMdrive name. The following DIR commands cause the selected drive to +Xbe addressed before the directory search takes place: + + DIR B: + DIR B:X.Y + DIR B:*.A?M + + MIf no files on the selected disk satisfy the directory request, +Xthe message NO FILE appears at the console. + + + + + + + + + + + + 1-7 + + + + + +CP/M Operating System Manual 1.4 Built-in Commands + + +W1.4.3 REN Command + +S&Syntax: + + REN ufn1=ufn2 + + MThe REN (rename) command allows you to change the names of +XMfiles on disk. The file satisfying ufn2 is changed to ufn1. The +XMcurrently logged disk is assumed to contain the file to rename +XM(ufn2). You can also type a left-directed arrowE insteaRd of the +XMequal sign if the console supports this graphic character. The +Xfollowing are examples of the REN command: + + + REN X.Y=Q.R The file Q.R is changed to X.Y. + + REN XYZ.COM=XYZ.XXX MThe file XYZ.XXX is changed to +X XYZ.COM. + + + MThe operator precedes either ufn1 or ufn2 (or both) by an +XMoptional drive address. If ufn1 is preceded by a drive name, then +XMufn2 is assumed to exist on the same drive. Similarly, if ufn2 is +XMpreceded by a drive name, then ufn1 is assumed to exist on the drive +XMas well. The same drive must be specified in both cases if both +XMufn1 and ufn2 are preceded by drive names. The following REN +Xcommands illustrate this format: + + + REN A:X.ASM=Y.ASM MThe file Y.ASM is changed to X.ASM +X on drive A. + + REN B:ZAP.BAS=ZOT.BAS MThe file ZOT.BAS is changed to +X ZAP.BAS on drive B. + + REN B:A.ASM=B:A.BAK MThe file A.BAK is renamed to A.ASM +X on drive B. + + + MIf ufn1 is already present, the REN command responds with the +XMerror FILE EXISTS and not perform the change. If ufn2 does not +XMexist on the specified disk, the message NO FILE is printed at the +Xconsole. + + +W1.4.4 SAVE Command + +S&Syntax: + + SAVE n ufn + + MThe SAVE command places n pages (256-byte blocks) onto disk +XMfrom the TPA and names this file ufn. In the CP/M distribution +XMsystem, the TPA starts at 100H (hexadecimal) which is the second +XMpage of memory. The SAVE command must specify 2 pEages ofR memory if + + + 1-M8 + + + +X + +CP/M Operating System Manual 1.4 Built-in Commands + + +Mthe user's program occupies the area from 100H through 2FFH. The +XMmachine code file can be subsequently loaded and executed. The +Xfollowing are examples of the SAVE command: + + + SAVE 3X.COM Copies 100H through 3FFH to X.COM. + + SAVE 40 Q MCopies 100H through 28FFH to Q. +X MNote that 28 is the page count in +X M28FFH, and that 28H = 2*16+8=40 +X decimal. + + SAVE 4 X.Y Copies 100H through 4FFH to X.Y. + + +MThe SAVE command can also specify a disk drive in the ufn portion of +Xthe command, as shown in the following example: + + SAVE 10 B:ZOT.COM MCopies 10 pages, 100H through 0AFFH, +X to the file ZOT.COM on drive B. + + + +W1.4.5 TYPE Command + +S&Syntax: + + TYPE ufn + + MThe TYPE command displays the content of the ASCII source file +XMufn on the currently logged disk at the console device. The +Xfollowing are valid TYPE commands: + + TYPE X.Y + TYPE X.PLM + TYPE XXX + + MThe TYPE command expands tabs, CTRL-I characters, assuminEg tabR +XMpRositions are set at every eighth column. The ufn can also +Xreference a drive name. + + TYPE B:X.PRN The file X.PRN from drive B is displayed. + + +W1.4.6 USER Command + +S&Syntax: + + USER n + + MThe USER command allows maintenance of separate files in the +XMsame directory. In the syntax line, n is an integer value in the +XMrange 0 to 15. On cold start, the operator is automatically logged +XMinto user area number 0, which is compatible witEh standRard CP/M 1 +XMdirectories. You can issue the USER command at any time to move to + + + 1-M9 + + + +X + +CP/M Operating System Manual 1.4 Built-in Commands + + +Manother logical area within the same directory. Drives that are +XMlogged-in while addressing one user number are automatically active +XMwhen the operator moves to another. A user number is simply a +XMprefix that accesses particular directory entries on the active +Xdisks. + + MThe active user number is maintained until changed by a +XMsubsequent USER command, or until a cold start when user 0 is again +Xassumed. + + +W1.5 Line Editing and Output Control + + MT&She CCP allows certain line-editing functions while typing +XMcommand lines. The CTRL-key sequences are obtained by pressing the +XMcontrol and letter keys simultaneously. Further, CCP command lines +XMare generally up to 255 characters in length; they are not acted +Xupon until the carriage return key is pressed. + + +=WTable 1-1. Line-editing Control Characters + + 9 F0 &SCharacter Meaning + + CTRL-C MReboots CP/M system when pressed at start of +X line. + + CTRL-E MPhysical end of line; carriage is returned, +X Mbut line is not sent until the carriage +X return key is pressed. + + CTRL-H Backspaces one character position. + + CTRL-J Terminates current input (line feed). + + CTRL-M MTerminates current input (carriage return). +X + CTRL-P MCopies all subsequent console output to the +X Mcurrently assigned list device (see Section +X M1.6.1). Output is sent to the list device +X Mand the console device until the next CTRL-P +X is pressed. + + CTRL-R MRetypes current command line; types a clean +X Mline following character deletion with +X rubouts. + + CTRL-S MStops the console output temporarily. +X MProgram execution and output continue when +X Myou press any character at the console, for +X Mexample another CTRL-S. This feature stops +X Moutput on high speed consoles, such as CRTs, +X Min order to view a segment of output before +X continuing. + + + + 1-10 + + + + 9 K0 + +CP/M Operating System Manual 1.5 Line Editing and Output Control + + +=WTable 1-1. (continued) + + 9 F0 &SCharacter Meaning + + CTRL-U MDeletes the entire line typed at the +X console. + + CTRL-X Same as CTRL-U. + + CTRL-Z MEnds input from the console (used in PIP and +X ED). + + RUB/DEL MDeletes and echoes the last character typed +X at the console. + 9 K0 + +W1.6 Transient Commands + + MT&Sransient commands are loaded from the currently logged disk +XMand executed in the TPA. The transient commands for execution under +XMthe CCP are below. Additional functions are easily defined by the +Xuser (see Section 1.6.3). + + +=WTable 1-2. CP/M Transient Commands + + 9 F0 &SCommand Function + + STAT MLists the number of bytes of storage remaining +X Mon the currently logged disk, provides +X Mstatistical information about particular +X Mfiles, and displays or alters device +X assignment. + + ASM MLoads the CP/M assembler and assembles the +X specified program from disk. + + LOAD MLoads the file in Intel HEX machine code +X Mformat and produces a file in machine +X Mexecutable form which can be loaded into the +X MTPA. This loaded program becomes a new +X command under the CCP. + + DDT MLoads the CP/M debugger into TPA and starts +X execution. + + PIP MLoads the Peripheral Interchange Program for +X Msubsequent disk file and peripheral transfer +X operations. + + ED MLoads and executes the CP/M text editor +X program. + + SYSGEN Creates a new CP/M system disk. + + + + 1-11 + + + + 9 K0 + +CP/M Operating System Manual 1.6 Transient Commands + + +=WTable 1-2. (continued) + + 9 F0 &SCommand Function + + SUBMIT MSubmits a file of commands for batch +X processing. + + DUMP Dumps the contents of a file in hex. + + MOVCPM MRegenerates the CP/M system for a particular +X memory size. + + 9 K0 + MTransient commands are specified in the same manner as built-in +XMcommands, and additional commands are easily defined by the user. +XMFor convenience, the transient command can be preceded by a drive +XMname which causes the transient to be loaded from the specified +Xdrive into the TPA for execution. Thus, the command + + B:STAT + +Mcauses CP/M to temporarily log in drive B for the source of the STAT +XMtransient, and then return to the original logged disk for +Xsubsequent processing. + + +W1.6.1 STAT Command + +S&Syntax: + + STAT + STAT "command line" + + MThe STAT command provides general statistical information about +XMfile storage and device assignment. Special forms of the command +XMline allow the current device assignment to be examined and altered. +XMThe various command lines Ethat caRn be specified are shown with an +Xexplanation of each form to the right. + + + STAT MIf you type an empty command line, the STAT +X Mtransient calculates the storage remaining +X Mon all active drives, and prints one of the +X following messages: + + d: R/W, SPACE: nnnK + + d: R/O, SPACE: nnnK + + Mfor each active drive d:, where R/W +X Mindicates the drive can be read or written, +X Mand R/O indicates the drive is Read-Only (a +X Mdrive becomes R/O by explicitly setting it +X Mto Read-Only, as shown below, or by +X Minadvertently changing disks without + + + 1-M12 + + + +X + +CP/M Operating System Manual 1.6 Transient Commands + + + Mperforming a warm start). The space +X Mremaining on the disk in drive d: is given +X in kilobytes by nnn. + + STAT d: MIf a drive name is given, then the drive is +X Mselected before the storage is computed. +X MThus, the command STAT B: could be issued +X Mwhile logged into drive A, resulting in the +X message + + BYTES REMAINING ON B: nnnK + + STAT afn MThe command line can also specify a set of +X Mfiles to be scanned by STAT. The files +X Mthat satisfy afn are listed in alphabetical +X Morder, with storage requirements for each +X file under the heading: + + RECS BYTES EXT D:FILENAME.TYP + rrrr bbbK ee d:filename.typ + + Mwhere rrrr is the number of 128-byte +X Mrecords allocated to the file, bbb is the +X Mnumber of kilobytes allocated to the file +X M(bbb=rrrr*128/1024), ee is the number of +X M16K extensions (ee=bbb/16), d is the drive +X Mname containing the file (A...P), filename +X Mis the eight-character primary filename, +X Mand typ is the three-character filetype. +X MAfter listing the individual files, the +X storage usage is summarized. + + STAT d:afn MThe drive name can be given ahead of the +X Mafn. The specified drive is first +X Mselected, and the form STAT afn is +X executed. + + STAT d:=R/O MThis form sets the drive given by d to +X MRead-Only, remaining in effect until the +X Mnext warm or cold start takes place. When +X a disk is Read-Only, the message + + BDOS ERR ON d: Read-Only + + Mappears if there is an attempt to write to +X Mthe Read-Only disk. CP/M waits until a key +X Mis pressed before performing an automatic +X Mwarm start, at which time the disk becomes +X R/W. + + + + + + + + + 1-13 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + MThe STAT command allows you to control the physical-to-logical +XMdevice assignment. See the IOBYTE function described in Sections 5 +XMand 6. There are four logical peripheral devices that are, at any +XMparticular instant, each assigned one of several physical peripheral +Xdevices. The following is a list of the four logical devices: + + + o MCON: is the system console device, used by CCP for +X communication with the operator. + + o RDR: is the paper tape reader device. + + o PUN: is the paper tape punch device. + + o LST: is the output list device. + + + MThe actual devices attached to any particular computer system +XMare driven by subroutines in the BIOS portion of CP/M. Thus, the +XMlogical RDR: device, for example, could actually be a high speed +XMreader, teletype reader, or cassette tape. To allow some +XMflexibility in device naming and assignment, several physical +Xdevices are defined in Table 1-3. + + +=WTable 1-3. Physical Devices + 9 F0 + &SDevice Meaning + + TTY: Teletype device (slow speed console) + + CRT: Cathode ray tube device (high speed console) + + BAT: MBatch processing (console is current RDR:, +X output goes to current LST: device) + + UC1: User-defined console + + PTR: Paper tape reader (high speed reader) + + UR1: User-defined reader #1 + + UR2: User-defined reader #2 + + PTP: Paper tape punch (high speed punch) + + UP1: User-defined punch #1 + + UP2: User-defined punch #2 + + LPT: Line printer + + UL1: User-defined list device #1 + 9 K0 + + + 1-14 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + MIt is emphasized that the physical device names might not +XMactually correspond to devices that the names imply. That is, you +XMcan implement the PTP: device as a cassette write operation. The +XMexact correspondence and driving subroutine is defined in the BIOS +XMportion of CP/M. In the standard distribution version of CP/M, +XMthese devices correspond to their names on the Model 800 development +Xsystem. + + The command, + + STAT VAL: + +Mproduces a summary of the available status commands, resulting in +Xthe output: + + Temp R/O Disk d:$R/O + Set Indicator: filename.typ $R/O $R/W $SYS $DIR + Disk Status: DSK: d:DSK + Iobyte Assign: + +Mwhich gives an instant summary of the possible STAT commands and +Xshows the permissible logical-to-physical device assignments: + + CON: = TTY: CRT: BAT: UC1: + RDR: = TTY: PTR: UR1: UR2: + PUN: = TTY: PTP: UP1: UP2: + LST: = TTY: CRT: LPT: UL1: + +MThe logical device to the left takes any of the four physical +XMassignments shown to the right. The current logical-to-physical +Xmapping is displayed by typing the command: + + STAT DEV: + +MThis command produces a list of each logical device to the left and +XMthe current corresponding physical device to the right. For +Xexample, the list might appear as follows: + + CON: = CRT: + RDR: = UR1: + PUN: = PTP: + LST: = TTY: + +MThe current logical-to-physical device assignment is changed by +Xtyping a STAT command of the form: + + STAT ld1 = pd1, ld2 = pd2, ... , ldn = pdn + +Mwhere ld1 through ldn are logical device names and pd1 through pdn +XMare compatible physical device names. For example, ldi and pdi +XMappear on the same line in the VAL: command shown above. The +XMfollowing example shows valid STAT commands that change the current +Xlogical-to-physical device assignments: + + + + 1-15 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + STAT CON:=CRT: + STAT PUN:=TTY:, LST:=LPT:, RDR:=TTY: + + The command form, + + STAT d:filename.typ $S + +Mwhere d: is an optional drive name and filename.typ is an +XMunambiguous or ambiguous filename, produces the following output +Xdisplay format: + + + Size Recs Bytes Ext Acc + + 48 48 6K 1 R/O A:ED.COM + 55 55 12K 1 R/O (A:PIP.COM) + 65536 128 16K 2 R/W A:X.DAT + + +Mwhere the $S parameter causes the Size field to be displayed. +XMWithout the $S, the Size field is skipped, but the remaining fields +XMare displayed. The Size field lists the virtual file size in +XMrecords, while the Recs field sums the number of virtual records in +XMeach extent. For files constructed sequentially, the Size and Recs +XMfields are identical. The Bytes field lists the actual number of +XMbytes allocated to the corresponding file. The minimum allocation +XMunit is determined at configuration time; thus, the number of bytes +XMcorresponds to the record count plus the remaining unused space in +XMthe last allocated block for sequential files. Random access files +XMare given data areas only when written, so the Bytes field contains +XMthe only accurate allocation figure. In the case of random access, +XMthe Size field gives the logical end-of-file record position and the +XMRecs field counts the logical records of each extent. Each of these +XMextents, however, can contain unallocated holes even though they are +Xadded into the record count. + + MThe Ext field counts the number of physical extents allocated +XMto the file. The Ext count corresponds to the number of directory +XMentries given to the file. Depending on allocation size, there can +XMbe up to 128K bytes (8 logical extents) directly addressed by a +XMsingle directory entry. In a special case, there are actually 256K +Xbytes that can be directly addressed by a physical extent. + + MThe Acc field gives the R/O or R/W file indicator, which you +Xcan change using the commands shown. The four command forms, + + STAT d:filename.typ $R/O + STAT d:filename.typ $R/W + STAT d:filename.typ $SYS + STAT d:filename.typ $DIR + +Mset or reset various permanent file indicators. The R/O indicator +XMplaces the file, or set of files, in a Read-Only status until +XMchanged by a subsequent STAT command. The R/O status is recorded in +XMthe directory with the file so that it remains R/O through + + + 1-M16 + + + +X + +CP/M Operating System Manual 1.6 Transient Commands + + +Mintervening cold start operations. The R/W indicator places the +XMfile in a permanent Read-Write status. The SYS indicator attaches +XMthe system indicator to the file, while the DIR command removes the +XMsystem indicator. The filename.typ may be ambiguous or unambiguous, +XMbut files whose attributes are changed are listed at the console +Xwhen the change occurs. The drive name denoted by d: is optional. + + MWhen a file is marked R/O, subsequent attempts to erase or +XMwrite into the file produce the following BDOS message at your +Xscreen: + + BDOS Err on d: File R/O + +Mlists the drive characteristics of the disk named by d: that is in +XMthe range A:, B:,...,P:. The drive characteristics are listed in +Xthe following format: + + d: Drive Characteristics + 65536: 128 Byte Record Capacity + 8192: Kilobyte Drive Capacity + 128: 32 Byte Directory Entries + 0: Checked Directory Entries + 1024: Records/Extent + 128: Records/Block + 58: Sectors/Track + 2: Reserved Tracks + +Mwhere d: is the selected drive, followed by the total record +XMcapacity (65536 is an eight-megabyte drive), followed by the total +XMcapacity listed in kilobytes. The directory size is listed next, +XMfollowed by the checked entries. The number of checked entries is +XMusually identical to the directory size for removable media, because +XMthis mechanism is used to detect changed media during CP/M operation +XMwithout an intervening warm start. For fixed media, the number is +XMusually zero, because the media are not changed without at least a +Xcold or warm start. + + MThe number of records per extent determines the addressing +XMcapacity of each directory entry (1024 times 128 bytes, or 128K in +XMthe previous example). The number of records per block shows the +XMbasic allocation size (in the example, 128 records/block times 128 +XMbytes per record, or 16K bytes per block). The listing is then +XMfollowed by the number of physical sectors per track and the number +Xof reserved tracks. + + MFor logical drives that share the same physical disk, the +XMnumber of reserved tracks can be quite large because this mechanism +XMis used to skip lower-numbered disk areas allocated to other logical +Xdisks. The command form + + STAT DSK: + +Mproduces a drive characteristics table for all currently active +Xdrives. The final STAT command form is + + + + 1-17 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + STAT USR: + +Mwhich produces a list of the user numbers that have files on the +Xcurrently addressed disk. The display format is + + Active User: 0 + Active Files: 0 1 3 + +Mwhere the first line lists the currently addressed user number, as +XMset by the last CCP USER command, followed by a list of user numbers +XMscanned from the current directory. In this case, the active user +XMnumber is 0 (default at cold start) with three user numbers that +XMhave active files on the current disk. The operator can +XMsubsequently examine the directories of the other user numbers by +XMlogging in with USER 1 or USER 3 commands, followed by a DIR command +Xat the CCP level. + + +W1.6.2 ASM Command + +S&Syntax: + + ASM ufn + + MThe ASM command loads and executes the CP/M 8080 assembler. +XMThe ufn specifies a source file containing assembly language +XMstatements, where the filetype is assumed to be ASM and is not +Xspecified. The following ASM commands are valid: + + ASM X + ASM GAMMA + +MThe two-pass assembler is automatically executed. Assembly errors +Xthat occur during the second pass are printed at the console. + + The assembler produces a file: + + X.PRN + +Mwhere X is the primary name specified in the ASM command. The PRN +XMfile contains a listing of the source program with embedded tab +XMcharacters if present in the source program, along with the machine +XMcode generated for each statement and diagnostic error messages, if +XMany. The PRN file is listed at the console using the TYPE command, +XMor sent to a peripheral device using PIP (see Section 1.6.4). Note +XMthat the PRN file contains the original source program, augmented by +XMmiscellaneous assembly information in the leftmost 16 columns; for +XMexample, program addresses and hexadecimal machine code. The PRN +XMfile serves as a backup for the original source file. If the source +XMfile is accidentally removed or destroyed, the PRN file can be +XMedited by removing the leftmost 16 characters of each line (see +XMSection 2). This is done by issuing a single editor macro command. +XMThe resulting file is identical to the original source file and can +XMbe renamed from PRN to ASM for subsequent editing and assembly. The +Xfile + + + 1-18 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + X.HEX + +Mis also produced, which contains 8080 machine language in Intel HEX +XMformat suitable for subsequent loading and execution (see Section +XM1.6.3). For complete details of CP/M's assembly language program, +Xsee Section 3. + + MThe source file for assembly is taken from an alternate disk by +XMprefixing the assembly language filename by a disk drive name. The +Xcommand + + ASM B:ALPHA + +Mloads the assembler from the currently logged drive and processes +XMthe source program ALPHA.ASM on drive B. The HEX and PRN files are +Xalso placed on drive B in this case. + + +W1.6.3 LOAD Command + +S&Syntax: + + LOAD ufn + + MThe LOAD command reads the file ufn, which is assumed to +XMcontain HEX format machine code, and produces a memory image file +XMthat can subsequently be executed. The filename ufn is assumed to +Xbe of the form: + + X.HEX + +Mand only the filename X need be specified in the command. The LOAD +Xcommand creates a file named + + X.COM + +Mthat marks it as containing machine executable code. The file is +XMactually loaded into memory and executed when the user types the +XMfilename X immediately after the prompting character > printed by +Xthe CCP. + + MGenerally, the CCP reads the filename X following the prompting +XMcharacter and looks for a built-in function name. If no function +XMname is found, the CCP searches the system disk directory for a file +Xby the name + + X.COM + +MIf found, the machine code is loaded into the TPA, and the program +XMexecutes. Thus, the user need only LOAD a hex file once; it can be +XMsubsequently executed any number of times by typing the primary +XMname. This way, you can invent new commands in the CCP. +XMInitialized disks contain the transient commands as COM files, which +XMare optionally deleted. The operation takes place on an alternate +Xdrive if the filename is prefixed by a drive name. Thus, + + 1-19 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + LOAD B:BETA + +Mbrings the LOAD program into the TPA from the currently logged disk +Xand operates on drive B after execution begins. + +MWNote: &Sthe BETA.HEX file must contain valid Intel format hexadecimal +XMmachine code records (as produced by the ASM program, for example) +XMthat begin at 100H of the TPA. The addresses in the hex records +XMmust be in ascending order; gaps in unfilled memory regions are +XMfilled with zeroes by the LOAD command as the hex records are read. +XMThus, LOAD must be used only for creating CP/M standard COM files +XMthat operate in the TPA. Programs that occupy regions of memory +Xother than the TPA are loaded under DDT. + + +W1.6.4 PIP + +S&Syntax: + + PIP + PIP destination=source#1, source#2, ..., source #n + + MPIP is the CP/M Peripheral Interchange Program that implements +XMthe basic media conversion operations necessary to load, print, +XMpunch, copy, and combine disk files. The PIP program is initiated +XbyE typingR one of the following forms: + + PIP + PIP command line + +MIn both cases PIP is loaded into the TPA and executed. In the first +XMform, PIP reads command lines directly from the console, prompted +XMwith the * character, until an empty command line is typed (for +XMexample, a single carriage return is issued by the operator). Each +XMsuccessive command line causes some media conversion to take place +Xaccording to the rules shown below. + + MIn the second form, the PIP command is equivalent to the first, +XMexcept that the single command line given with the PIP command is +XMautomatically executed, and PIP terminates immediately with no +XMfurther prompting of the console for input command lines. The form +Xof each command line is + + destination = source#1, source#2, ..., source#n + +Mwhere destination is the file or peripheral device to receive the +XMdata, and source#1, ..., source#n is a series of one or more files +Xor devices that are copied from left to right to the destination. + + MWhen multiple files are given in the command line (for example, +XMn>1), the individual files are assumed to contain ASCII characters, +XMwith an assumed CP/M end-of-file character (CTRL-Z) at the end of +XMeach file (see the O parameter to override this assumption). Lower- +XMcase ASCII alphabetics are internally translated to upper-case to be + + + 1-M20 + + + +X + +CP/M Operating System Manual 1.6 Transient Commands + + +Mconsistent with CP/M file and device name conventions. Finally, the +XMtotal command line length cannot exceed 255 characters. CTRL-E can +XMbe used to force a physical carriage return for lines that exceed +Xthe console width. + + MThe destination and source elements are unambiguous references +XMto CP/M source files with or without a preceding disk drive name. +XMThat is, any file can be referenced with a preceding drive name (A: +XMthrough P:) that defines the particular drive where the file can be +XMobtained or stored. When the drive name is not included, the +XMcurrently logged disk is assumed. The destination file can also +XMappear as one or more of the source files, in which case the source +XMfile is not altered until the entire concatenation is complete. If +XMit already exists, the destination file is removed if the command +XMline is properly formed. It is not removed if an error condition +XMarises. The following command lines, with explanations to the +Xright, are valid as input to PIP: + + + X=Y MCopies to file X from file Y, where +X MX and Y are unambiguous filenames; +X Y remains unchanged. + + X=Y,Z MConcatenates files Y and z and +X Mcopies to file X, with Y and Z +X unchanged. + + X.ASM=Y.ASM,Z.ASM MCreates the file X.ASM from the +X Mconcatenation of the Y and Z.ASM +X files. + + NEW.ZOT=B:OLD.ZAP MMoves a copy of OLD.ZAPP from drive +X MB to the currently logged disk; +X names the file NEW.ZOT. + + B:A.U=B:B.V,A:C.W,D.X MConcatenates file B.V from drive B +X Mwith C.W from drive a and D.X from +X Mthe logged disk; creates the file +X A.U on drive b. + + + MFor convenience, PIP allows abbreviated commands for +XMtransferring files between disk drives. The abbreviated PIP forms +Xare + + PIP d:=afn + PIP dU1D=dU2D:afn + PIP ufn = dU2D: + PIP dU1D:ufn = dU2D: + +MThe first form copies all files from the currently logged disk that +XMsatisfy the afn to the same files on drive d, where d = A...P. The +XMsecond form is equivalent to the first, where the source for the +XMcopy is drive dU2D, where dU2D = A...P. The third form is equivalent to +XMthe command PIP dU1D:ufn=dU2D:ufn which copies the file given by ufn + + + 1-M21 + + + +X + +CP/M Operating System Manual 1.6 Transient Commands + + +Mfrom drive dU2D to the file ufn on drive dU1D:. The fourth form is +XMequivalent to the third, where the source disk is explicitly given +Xby dU2D:. + + MThe source and destination disks must be different in all of +XMthese cases. If an afn is specified, PIP lists each ufn that +XMsatisfies the afn as it is being copied. If a file exists by the +XMsame name as the destination file, it is removed after successful +Xcompletion of the copy and replaced by the copied file. + + MThe following PIP commands give examples of valid disk-to-disk +Xcopy operations: + + + B:=*.COM MCopies all files that have the secondary +X Mname COM to drive B from the current drive. +X + A:=B:ZAP.* MCopies all files that have the primary name +X ZAP to drive A from drive B. + + ZAP.ASM=B: Same as ZAP.ASM=B:ZAP.ASM + + B:ZOT.COM=A: Same as B:ZOT.COM=A:ZOT.COM + + B:=GAMMA.BAS Same as B:GAMMA.BAS=GAMMA.BAS + + B:=A:GAMMA.BAS Same as B:GAMMA.BAS=A:GAMMA.BAS + + + MPIP allows reference to physical and logical devices that are +XMattached to the CP/M system. The device names are the same as given +XMunder the STAT command, along with a number of specially named +XMdevices. The following is a list of logical devices given in the +XSTAT command + + CON: (console) + RDR: (reader) + PUN: (punch) + LST: (list) + +while the physical devices are + + TTY: (console), reader, punch, or list) + CRT: (console, or list), UC1: (console) + PTR: (reader), UR1: (reader), UR2: (reader) + PTP: (punch), UP1: (punch), UP2: (punch) + LPT: (list), UL1: (list) + +MThe BAT: physical device is not included, because this assignment is +XMused only to indicate that the RDR: and LST: devices are used for +Xconsole input/output. + + MThe RDR, LST, PUN, and CON devices are all defined within the +XMBIOS portion of CP/M, and are easily altered for any particular I/O +XMsystem. The current physical device mapping is defined by IOBYTE; + + + 1-M22 + + + +X + +CP/M Operating System Manual 1.6 Transient Commands + + +Msee Section 6 for a discussion of this function. The destination +XMdevice must be capable of receiving data, for example, data cannot +XMbe sent to the punch, and the source devices must be capable of +Xgenerating data, for example, the LST: device cannot be read. + + MThe following list describes additional device names that can +Xbe used in PIP commands. + + + o MNUL: sends 40 nulls (ASCII 0s) to the device. This can be +X issued at the end of punched output. + + o MEOF: sends a CP/M end-of-file (ASCII CTRL-Z) to the destination +X Mdevice (sent automatically at the end of all ASCII data +X transfers through PIP). + + o MINP: is a special PIP input source that can be patched into the +X MPIP program. PIP gets the input data character-by-character, +X Mby CALLing location 103H, with data returned in location 109H +X (parity bit must be zero). + + o MOUT: is a special PIP output destination that can be patched +X Minto the PIP program. PIP CALLs location 106H with data in +X Mregister C for each character to transmit. Note that locations +X M109H through 1FFH of the PIP memory image are not used and can +X Mbe replaced by special purpose drivers using DDT (see Section +X 4). + + o MPRN: is the same as LST:, except that tabs are expanded at +X Mevery eighth character position, lines are numbered, and page +X Mejects are inserted every 60 lines with an initial eject (same +X as using PIP options [t8np]). + + + MFile and device names can be interspersed in the PIP commands. +XMIn each case, the specific device is read until end-of-file (CTRL-Z +XMfor ASCII files, and end-of-data for non-ASCII disk files). Data +XMfrom each device or file are concatenated from left to right until +Xthe last data source has been read. + + MThe destination device or file is written using the data from +XMthe source files, and an end-of-file character, CTRL-Z, is appended +XMto the result for ASCII files. If the destination is a disk file, a +XMtemporary file is created ($$$ secondary name) that is changed to +XMthe actual filename only on successful completion of the copy. +XFiles with the extension COM are always assumed to be non-ASCII. + + MThe copy operation can be aborted at any time by pressing any +XMkey on the keyboard. PIP responds with the message ABORTED to +XMindicate that the operation has not been completed. If any +XMoperation is aborted, or if an error occurs during processing, PIP +XMremoves any pending commands that were set up while using the SUBMIT +Xcommand. + + + + + 1-23 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + MPIP performs a special function if the destination is a disk +XMfile with type HEX (an Intel hex-formatted machine code file), and +XMthe source is an external peripheral device, such as a paper tape +XMreader. In this case, the PIP program checks to ensure that the +XMsource file contains a properly formed hex file, with legal +Xhexadecimal values and checksum records. + + MWhen an invalid input record is found, PIP reports an error +XMmessage at the console and waits for corrective action. Usually, +XMyou can open the reader and rerun a section of the tape (pull the +XMtape back about 20 inches). When the tape is ready for the reread, +XMa single carriage return is typed at the console, and PIP attempts +XManother read. If the tape position cannot be properly read, +XMcontinue the read by typing a return following the error message, +XMand enter the record manually with the ED program after the disk +Xfile is constructed. + + MPIP allows the end-of-file to be entered from the console if +XMthe source file is an RDR: device. In this case, the PIP program +XMreads the device and monitors the keyboard. If CTRL-Z is typed at +Xthe keyboard, the read operation is terminated normally. + + The following are valid PIP commands: + + + PIP LST: = X.PRN + + MCopies X.PRN to the LST device and +X terminates the PIP program. + + PIP + + MStarts PIP for a sequence of commands. PIP +X prompts with *. + + *CON:=X.ASM,Y.ASM,Z.ASM + + MConcatenates three ASM files and copies to +X the CON device. + + *X.HEX=CON:,Y.HEX,PTR: + + MCreates a HEX file by reading the CON until +X Ma CTRL-Z is typed, followed by data from +X MY.HEX and PTR until a CTRL-Z is +X encountered. + + PIP PUN:=NUL:,X.ASM,EOF:,NUL: + + MSends 40 nulls to the punch device; copies +X Mthe X.ASM file to the punch, followed by an +X Mend-of-file, CTRL-Z, and 40 more null +X characters. + + (carriage return) + + A single carriage return stops PIP. + + 1-24 + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + MYou can also specify one or more PIP parameters, enclosed in +XMleft and right square brackets, separated by zero or more blanks. +XMEach parameter affects the copy operation, and the enclosed list of +XMparameters must immediately follow the affected file or device. +XMGenerally, each parameter can be followed by an optional decimal +XMinteger value (the S and Q parameters are exceptions). Table 1-4 +Xdescribes valid PIP parameters. + + +=WTable 1-4. PIP Parameters + 9 F0 + Parameter Meaning + + B MBlocks mode transfer. Data are buffered by +X MPIP until an ASCII x-off character, CTRL-S, +X Mis received from the source device. This +X Mallows transfer of data to a disk file from a +X Mcontinuous reading device, such as a cassette +X Mreader. Upon receipt of the x-off, PIP +X Mclears the disk buffers and returns for more +X Minput data. The amount of data that can be +X Mbuffered depends on the memory size of the +X Mhost system. PIP issues an error message if +X the buffers overflow. + + Dn MDeletes characters that extend past column n +X Min the transfer of data to the destination +X Mfrom the character source. This parameter is +X Mgenerally used to truncate long lines that +X Mare sent to a narrow printer or console +X device. + + E MEchoes all transfer operations to the console +X as they are being performed. + + F MFilters form-feeds from the file. All +X Membedded form-feeds are removed. The P +X Mparameter can be used simultaneously to +X insert new form-feeds. + + Gn MGets file from user number n (n in the range +X 0-15). + + H MTransfers HEX data. All data are checked for +X Mproper Intel hex file format. Nonessential +X Mcharacters between hex records are removed +X Mduring the copy operation. The console is +X Mprompted for corrective action in case errors +X occur. + + I MIgnores :00 records in the transfer of Intel +X Mhex format file. The I parameter +X automatically sets the H parameter. + + + + 1-25 + + + + 9 K0 + +CP/M Operating System Manual 1.6 Transient Commands + + +=WTable 1-4. (continued) + 9 F0 + Parameter Meaning + + L MTranslates upper-case alphabetics to lower- +X case. + + N MAdds line numbers to each line transferred to +X Mthe destination, starting at one and +X Mincrementing by 1. Leading zeroes are +X Msuppressed, and the number is followed by a +X Mcolon. If N2 is specified, leading zeroes +X Mare included and a tab is inserted following +X Mthe number. The tab is expanded if T is set. +X + O MTransfers non-ASCII object files. The normal +X CP/M end-of-file is ignored. + + Pn MIncludes page ejects at every n lines with an +X Minitial page eject. If n = 1 or is excluded +X Maltogether, page ejects occur every 60 lines. +X MIf the F parameter is used, form-feed +X Msuppression takes place before the new page +X ejects are inserted. + + Qs^Z MQuits copying from the source device or file +X Mwhen the string s, terminated by CTRL-Z, is +X encountered. + + R Reads system files. + + Ss^Z MStart copying from the source device when the +X Mstring s, terminated by CTRL-Z, is +X Mencountered. The S and Q parameters can be +X Mused to abstract a particular section of a +X Mfile, such as a subroutine. The start and +X Mquit strings are always included in the copy +X operation. + + MIf you specify a command line after the PIP +X Mcommand keyword, the CCP translates strings +X Mfollowing the S and Q parameters to upper- +X Mcase. If you do not specify a command line, +X MPIP does not perform the automatic upper-case +X translation. + + Tn MExpands tabs, CTRL-I characters, to every nth +X Mcolumn during the transfer of characters to +X the destination from the source. + + U MTranslates lower-case alphabetics to upper- +X case during the copy operation. + + + + + + 1-26 + + + + 9 K0 + +CP/M Operating System Manual 1.6 Transient Commands + + +=WTable 1-4. (continued) + 9 F0 + Parameter Meaning + + V MVerifies that data have been copied correctly +X Mby rereading after the write operation (the +X destination must be a disk file). + + W MWrites over R/O files without console +X interrogation. + + Z MZeros the parity bit on input for each ASCII +X character. + 9 K0 + + MThe following examples show valid PIP commands that specify +Xparameters in the file transfer. + + + PIP X.ASM=B:[v] + + MCopies X.ASM from drive B to the current +X Mdrive and verifies that the data were +X properly copied. + + + PIP LPT:=X.ASM[nt8u] + + MCopies X.ASM to the LPT: device; numbers +X Meach line, expands tabs to every eighth +X Mcolumn, and translates lower-case +X alphabetics to upper-case. + + + PIP PUN:=X.HEX[i],Y.ZOT[h] + + MFirst copies X.HEX to the PUN: device and +X Mignores the trailing :00 record in X.HEX; +X Mcontinues the transfer of data by reading +X MY.ZOT, which contains HEX records, +X including any :00 records it contains. + + + PIP X.LIB=Y.ASM[sSUBRI:^z qJMP L3^z] + + MCopies from the file Y.ASM into the file +X MX.LIB. The command starts the copy when +X Mthe string SUBR1: has been found, and quits +X Mcopying after the string JMP L3 is +X encountered. + + + + + + + + 1-27 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + PIP PRN:=X.ASM[p50] + + MSends X.ASM to the LST: device with line +X Mnumbers, expands tabs to every eighth +X Mcolumn, and ejects pages at every 50th +X Mline. The assumed parameter list for a PRN +X Mfile is nt8p60; p50 overrides the default +X value. + + + MUnder normal operation, PIP does not overwrite a file that is +XMset to a permanent R/O status. If an attempt is made to overwrite +Xan R/O file, the following prompt appears: + + DESTINATION FILE IS R/O, DELETE (Y/N)? + +MIf you type Y, the file is overwritten. Otherwise, the following +Xresponse appears: + + ** NOT DELETED ** + +MThe file transfer is skipped, and PIP continues with the next +XMoperation in sequence. To avoid the prompt and response in the case +XMof R/O file overwrite, the command line can include the W parameter, +Xas shown in this example: + + PIP A:=B:*.COM[W] + +MThe W parameter copies all nonsystem files to the A drive from the B +XMdrive and overwrites any R/O files in the process. If the operation +XMinvolves several concatenated files, the W parameter need only be +Xincluded with the last file in the list, as in this example: + + PIP A.DAT=B.DAT,F:NEW.DAT,G:OLD.DAT[W] + + MFiles with the system attribute can be included in PIP +XMtransfers if the R parameter is included; otherwise, system files +Xare not recognized. For example, the command line: + + PIP ED.COM=B:ED.COM[R] + +Mreads the ED.COM file from the B drive, even if it has been marked +XMas an R/O and system file. The system file attributes are copied, +Xif present. + + MDownward compatibility with previous versions of CP/M is only +XMmaintained if the file does not exceed one megabyte, no file +XMattributes are set, and the file is created by user 0. If +XMcompatibility is required with nonstandard, for example, double- +XMdensity versions of 1.4, it might be necessary to select 1.4 +XMcompatibility mode when constructing the internal disk parameter +XMblock. See Section 6 and refer to Section 6.10, which describes +XBIOS differences. + + + + + 1-28 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + +MWNote: &Sto copy files into another user area, PIP.COM must be located +XMin that user area. Use the following procedure to make a copy of +XPIP.COM in another user area. + + + USER 0 Log in user 0. + + DDT PIP.COM (note PIP size s) Load PIP to memory. + + GO Return to CCP. + + USER 3 Log in user 3. + + SAVEs PIP.COM + + +MIn this procedure, s is the integral number of memory pages, 256- +XMbyte segments, occupied by PIP. The number s can be determined when +XMPIP.COM is loaded under DDT, by referring to the value under the +XMNEXT display. If, for example, the next available address is 1D00, +XMthen PIP.COM requires 1C hexadecimal pages, or 1 times 16 + 12 = 28 +XMpages, and the value of s is 28 in the subsequent save. Once PIP is +XMcopied in this manner, it can be copied to another disk belonging to +Xthe same user number through normal PIP transfers. + + +W1.6.5 ED Command + +S&Syntax: + + ED ufn + + MThe ED program is the CP/M system context editor that allows +XMcreation and alteration of ASCII files in the CP/M environment. +XMComplete details of operation are given in Section 2. ED allows the +XMoperator to create and operate upon source filesE that aRre organized +XMas a sequence of ASCII characters, separated by end-of-line +XMcharacters (a carriage return/line-feed sequence). There is no +XMpractical restriction on line length (no single line can exceed the +XMsize of the working memory) that is defined by the number of +Xcharacters typed between carriage returns. + + MThe ED program has a number of commands for character string +XMsearching, replacement, and insertion that are useful for creating +XMand correcting programs or text files under CP/M. Although the CP/M +XMhas a limited memory work space area (approximately 5000 characters +XMin a 20K CP/M system), the file size that can be edited is not +Xlimited, since data are easily paged through this work area. + + MIf it does not exist, ED creates the specified source file and +XMopens the file for access. If the source file does exist, the +XMprogrammer appends data for editing (see the A command). The +XMappended data can then be displayed, altered, and written from the +XMwork area back to the disk (see the W command). Particular points +XMin the program can be automatically paged and located by context, + + + 1-M29 + + + +X + +CP/M Operating System Manual 1.6 Transient Commands + + +Mallowing easy access to particular portions of a large file (see the +XN command). + + If you type the following command line: + + ED X.ASM + +the ED program creates an intermediate work file with the name + + X.$$$ + +Mto hold the edited data during the ED run. Upon completion of ED, +XMthe X.ASM file (original file) is renamed to X.BAK, and the edited +XMwork file is renamed to X.ASM. Thus, the X.BAK file contains the +XMoriginal unedited file, and the X.ASM file contains the newly edited +XMfile. The operator can always return to the previous version of a +XMfile by removing the most recent version and renaming the previous +XMversion. If the current X.ASM file has been improperly edited, the +Xfollowing sequence of commands reclaim the back-up file. + + + DIR X.* Checks to see that BAK file is + available. + + ERA X.ASM Erases most recent version. + + REN X.ASM=X.BAK Renames the BAK file to ASM. + + +MYou can abort the edit at any point (reboot, power failure, CTRL-C, +XMor CTRL-Q command) without destroying the original file. In this +XMcase, the BAK file is not created and the original file is always +Xintact. + + MThe ED program allows the user to edit the source on one disk +XMand create the back-up file on another disk. This form of the ED +Xcommand is + + ED ufn d: + +Mwhere ufn is the name of the file to edit on the currently logged +XMdisk and d is the name of an alternate drive. The ED program reads +XMand processes the source file and writes the new file to drive d +XMusing the name ufn. After processing, the original file becomes the +XMback-up file. If the operator is addressing disk A, the following +Xcommand is valid. + + ED X.ASM b: + +MThis edits the file X.ASM on drive A, creating the new file X.$$$ on +XMdrive B. After a successful edit, A:X.ASM is renamed to A:X.BAK, +XMand B:X.$$$ is renamed to B:X.ASM. For convenience, the currently +XMlogged disk becomes drive B at the end of the edit. Note that if a +XMfile named B:X.ASM exists before the editing begins, the following +Xmessage appears on the screen: + + + 1-30 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + FILE EXISTS + +MThis message is a precaution against accidentally destroying a +XMsource file. You should first erase the existing file and then +Xrestart the edit operation. + + MSimilar to other transient commands, editing can take place on +XMa drive different from the currently logged disk by preceding the +XMsource filename by a drive name. The following are examples of +Xvalid edit requests: + + + ED A:X.ASM MEdits the file X.ASM on drive A, with new +X file and back-up on drive A. + + ED B:X.ASM A: MEdits the file X.ASM on drive B to the +X Mtemporary file X.$$$ on drive A. After +X Mediting, this command changes X.ASM on +X Mdrive B to X.BAK and changes X.$$$ on +X drive A to X.ASM. + + +W1.6.6 SYSGEN Command + +S&Syntax: + + SYSGEN + + MThe SYSGEN transient command allows generation of an +XMinitialized disk containing the CP/M operating system. The SYSGEN +Xprogram prompts the console for commands by interacting as shown. + + + SYSGEN + + Initiates the SYSGEN program. + + + SYSGEN VERSION x.x + + SYSGEN sign-on message. + + + SOURCE DRIVE NAME + (OR RETURN TO SKIP) + + MRespond with the drive name (one of the +X Mletters A, B, C, or D) of the disk +X Mcontaining a CP/M system, usually A. If a +X Mcopy of CP/M already exists in memory due +X Mto a MOVCPM command, press only a carriage +X Mreturn. Typing a drive name d causes the +X response: + + + + 1-31 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + SOURCE ON d THEN TYPE RETURN + + MPlace a disk containing the CP/M operating +X Msystem on drive d (d is one of A, B, C, or +X MD). Answer by pressing a carriage return +X when ready. + + + FUNCTION COMPLETE + + MSystem is copied to memory. SYSGEN then +X prompts with the following: + + + DESTINATION DRIVE NAME + (OR RETURN TO REBOOT) + + MIf a disk is being initialized, place the +X Mnew disk into a drive and answer with the +X Mdrive name. Otherwise, press a carriage +X Mreturn and the system reboots from drive A. +X MTyping drive name d causes SYSGEN to prompt +X with the following message: + + + DESTINATION ON d + THEN TYPE RETURN + + MPlace new disk into drive d; press return +X when ready. + + + FUNCTION COMPLETE + + New disk is initialized in drive d. + + +MThe DESTINATION prompt is repeated until a single carriage return is +XMpressed at the console, so that more than one disk can be +Xinitialized. + + MUpon completion of a successful system generation, the new disk +XMcontains the operating system, and only the built-in commands are +XMavailable. An IBM-compatible disk appears to CP/M as a disk with an +XMempty directory; therefore, the operator must copy the appropriate +XMCOM files from an existing CP/M disk to the newly constructed disk +Xusing the PIP transient. + + MYou can copy all files from an existing disk by typing the +Xfollowing PIP command: + + PIP B: = A:*.*[v] + + + + + + 1-32 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + +MThis command copies all files from disk drive A to disk drive B and +XMverifies that each file has been copied correctly. The name of each +Xfile is displayed at the console as the copy operation proceeds. + + MNote that a SYSGEN does not destroy the files that already +XMexist on a disk; it only constructs a new operating system. If a +XMdisk is being used only on drives B through P and will never be the +XMsource of a bootstrap operation on drive A, the SYSGEN need not take +Xplace. + + +W1.6.7 SUBMIT Command + +ESyntax:R + + RSUBMIT ufn parm#1 ... parm#n + + MThe SUBMIT command allows CP/M commands to be batched for +XMautomatic processing. The ufn given in the SUBMIT command must be +XMthe filename of a file that exists on the currently logged disk, +XMwith an assumed file type of SUB. The SUB file contains CP/M +XMprototype commands with possible parameter substitution. The actual +XMparameters parm#1 ... parm#n are substituted into the prototype +XMcommands, and, if no errors occur, the file of substituted commands +Xare processed sequentially by CP/M. + + MThe prototype command file is created using the ED program, +Xwith interspersed $ parameters of the form: + + $1 $2 $3 ...$n + +Mcorresponding to the number of actual parameters that will be +XMincluded when the file is submitted for execution. When the SUBMIT +XMtransient is executed, the actual parameters parm#1 ... parm#n are +XMpaired with the formal parameters $1 ... $n in the prototype +XMcommands. If the numbers of formal and actual parameters do not +XMcorrespond, the SUBMIT function is aborted with an error message at +XMthe console. The SUBMIT function creates a file of substituted +Xcommands with the name + + $$$.SUB + +Mon the logged disk. When the system reboots, at the termination of +XMthe SUBMIT, this command file is read by the CCP as a source of +XMinput rather than the console. If the SUBMIT function is performed +XMon any disk other than drive A, the commands are not processed until +XMthe disk is inserted into drive A and the system reboots. You can +XMabort command processing at any time by pressing the rubout key when +XMthe command is read and echoed. In this case, the $$$.SUB file is +XMremoved and the subsequent commands come from the console. Command +XMprocessing is also aborted if the CCP detects an error in any of the +XMcommands. Programs that execute under CP/M can abort processing of +XMcommand files when error conditions occur by erasing any existing +X$$$.SUB file. + + + + 1-33 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + MTo introduce dollar signs into a SUBMIT file, you can type a $$ +XMwhich reduces to a single $ within the command file. A caret, ^, +XMprecedes an alphabetic character s, which produces a single CTRL-X +Xcharacter within the file. + + MThe last command in a SUB file can initiate another SUB file, +Xallowing chained batch commands: + + MSuppose the file ASMBL.SUB exists on disk and contains the +Xprototype commands + + ASM $1 + DIR $1.* + ERA *.BAK + PIP $2:=$1.PRN + ERA $1.PRN + +then, you issue the following command: + + SUBMIT ASMBL X PRN + +MThe SUBMIT program reads the ASMBL.SUB file, substituting X: for all +XMoccurrences of $1 and PRN for all occurrences of $2. This results +Xin a $$$.SUB file containing the commands: + + ASM X + DIR X.* + ERA *.BAK + PIP PRN:=X.PRN + ERA X.PRN + +which are executed in sequence by the CCP. + + MThe SUBMIT function can access a SUB file on an alternate drive +XMby preceding the filename by a drive name. Submitted files are only +XMacted upon when they appear on drive A. Thus, it is possible to +XMcreate a submitted file on drive B that is executed at a later time +Xwhen inserted in drive A. + + MAn additional utility program called XSUB extends the power of +XMthe SUBMIT facility to include line input to programs as well as the +XMCCP. The XSUB command is included as the first line of the SUBMIT +XMfile. When it is executed, XSUB self-relocates directly below the +XMCCP. All subsequent SUBMIT command lines are processed by XSUB so +XMthat programs that read buffered console input, BDOS Function 10, +XMreceive their input directly from the SUBMIT file. For example, the +Xfile SAVER.SUB can contain the following SUBMIT lines: + + XSUB + DDT + |$1.COM + R + GO + SAVE 1 $2.COM + + + + 1-34 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + +a subsequent SUBMIT command, such as + + A>WSUBMIT SAVER PIP Y + +Ms&Substitutes X for $1 and Y for $2 in the command stream. The XSUB +XMprogram loads, followed by DDT, which is sent to the command lines +XMPIP.COM, R, and G0, thus returning to the CCP. The final command +XSAVE 1 Y.COM is processed by the CCP. + + The XSUB program remains in memory and prints the message + + (xsub active) + +Mon each warm start operation to indicate its presence. Subsequent +XMSUBMIT command streams do not require the XSUB, unless an +XMintervening cold start occurs. Note that XSUB must be loaded after +XMthe optional CP/M DESPOOL utility, if both are to run +Xsimultaneously. + + +W1.6.8 DUMP Command + +ESyntax:R + + RDUMP ufn + + MThe DUMP program types the contents of the disk file (ufn) at +XMthe console in hexadecimal form. The file contents are listed +XMsixteen bytes at a time, with the absolute byte address listed to +XMthe left of each line in hexadecimal. Long typeouts can be aborted +XMby pressing the rubout key during printout. The source listing of +XMthe DUMP program is given in Section 5 as an example of a program +Xwritten for the CP/M environment. + + +W1.6.9 MOVCPM Command + +ESyntax:R + + RMOVCPM + + MThe MOVCPM program allows you to reconfigure the CP/M system +XMfor any particular memory size. Two optional parameters can be used +XMto indicate the desired size of the new system and the disposition +XMof the new system at program termination. If the first parameter is +XMomitted or an * is given, the MOVCPM program reconfigures the system +XMto its maximum size, based upon the kilobytes of contiguous RAM in +XMthe host system (starting at 0000H). If the second parameter is +XMomitted, the system is executed, but not permanently recorded; if * +XMis given, the system is left in memory, ready for a SYSGEN +XMoperation. The MOVCPM program relocates a memory image of CP/M and +XMplaces this image in memory in preparation for a system generation +Xoperation. The following is a list of MOVCPM command forms: + + + + + 1-35 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + MOVCPM MRelocates and executes CP/M for management +X Mof the current memory configuration (memory +X Mis examined for contiguous RAM, starting at +X M100H). On completion of the relocation, the +X Mnew system is executed but not permanently +X Mrecorded on the disk. The system that is +X Mconstructed contains a BIOS for the Intel +X microcomputer development system 800. + + MOVCPM n MCreates a relocated CP/M system for +X Mmanagement of an n kilobyte system (n must +X Mbe in the range of 20 to 64), and executes +X the system as described. + + MOVCPM * * MConstructs a relocated memory image for the +X Mcurrent memory configuration, but leaves the +X Mmemory image in memory in preparation for a +X SYSGEN operation. + + MOVCPM n * MConstructs a relocated memory image for an n +X Mkilobyte memory system, and leaves the +X Mmemory image in preparation for a SYSGEN +X operation. + + + For example, the command, + + MOVCPM * * + +Mconstructs a new version of the CP/M system and leaves it in memory, +Xready for a SYSGEN operation. The message + + READY FOR 'SYSGEN' OR + 'SAVE 34 CPMxx.COM' + +Mappears at the console upon completion, where xx is the current +XMmemory size in kilobytes. You can then type the following sequence: +X + + SYSGEN MThis starts the system +X generation. + + SOURCE DRIVE NAME Respond with a carriage return + (OR RETURN TO SKIP) Mto skip the CP/M read operation, +X Mbecause the system is already +X Min memory as a result of the +X previous MOVCPM operation. + + DESTINATION DRIVE NAME Respond with B to write new + (OR RETURN TO REBOOT) Msystem to the disk in drive B. +X MSYSGEN prompts with the +X following message: + + DESTINATION ON B, Place the new disk on drive B + THEN TYPE RETURN Mand press the RETURN key when +X ready. + + 1-36 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + MIf you respond with A rather than B above, the system is +XMwritten to drive A rather than B. SYSGEN continues to print this +Xprompt: + + DESTINATION DRIVE NAME (OR RETURN TO REBOOT) + +Muntil you respond with a single carriage return, which stops the +XSYSGEN program with a system reboot. + + MYou can then go through the reboot process with the old or new +XMdisk. Instead of performing the SYSGEN operation, you can type a +Xcommand of the form: + + SAVE 34 CPMxx.COM + +Mat the completion of the MOVCPM function, where xx is the value +XMindicated in the SYSGEN message. The CP/M memory image on the +XMcurrently logged disk is in a form that can be patched. This is +XMnecessary when operating in a nonstandard environment where the BIOS +XMmust be altered for a particular peripheral device configuration, as +Xdescribed in Section 6. + + The following are valid MOVCPM commands: + + + MOVCPM 48 MConstructs a 48K version of CP/M and starts +X execution. + + MOVCPM 48 * MConstructs a 48K version of CP/M in +X Mpreparation for permanent recording; the +X response is + + READY FOR 'SYSGEN' OR + 'SAVE 34 CPM48.COM' + + MOVCPM * * MConstructs a maximum memory version of CP/M +X and starts execution. + + MThe newly created system is serialized with the number attached +XMto the original disk and is subject to the conditions of the Digital +XResearch Software Licensing Agreement. + + +W1.7 BDOS Error Messages + + MT&Shere are three error situations that the Basic Disk Operating +XMSystem intercepts during file processing. When one of these +Xconditions is detected, the BDOS prints the message: + + BDOS ERR ON d: error + + + + + + + 1-37 + + + + + +CP/M Operating System Manual 1.7 BDOS Error Messages + + +Mwhere d is the drive name and error is one of the three error +Xmessages: + + BAD SECTOR + SELECT + READ ONLY + + MThe BAD SECTOR message indicates that the disk controller +XMelectronics has detected an error condition in reading or writing +XMthe disk. This condition is generally caused by a malfunctioning +XMdisk controller or an extremely worn disk. If you find that CP/M +XMreports this error more than once a month, the state of the +XMcontroller electronics and the condition of the media should be +Xchecked. + + MYou can also encounter this condition in reading files +XMgenerated by a controller produced by a different manufacturer. +XMEven though controllers claim to be IBM..-compatible, one often +XMfinds small differences in recording formats. The Model 800 +XMcontroller, for example, requires two bytes of one's following the +XMdata CRC byte, which is not required in the IBM format. As a +XMresult, disks generated by the Intel microcomputer development +XMsystem can be read by almost all other IBM-compatible system, while +XMdisk files generated on other manufacturers' equipment produce the +XMBAD SECTOR message when read by the microcomputer development +XMsystem. To recover from this condition, press a CTRL-C to reboot +XM(the safest course), or a return, which ignores the bad sector in +Xthe file operation. + +MWNote: &Spressing a return might destroy disk integrity if the +XMoperation is a directory write. Be sure you have adequate back-ups +Xin this case. + + MThe SELECT error occurs when there is an attempt to address a +XMdrive beyond the range supported by the BIOS. In this case, the +XMvalue of d in the error message gives the selected drive. The +Xsystem reboots following any input from the console. + + MThe READ ONLY message occurs when there is an attempt to write +XMto a disk or file that has been designated as Read-Only in a STAT +XMcommand or has been set to Read-Only by the BDOS. Reboot CP/M by +XMusing the warm start procedure, CTRL-C, or by performing a cold +XMstart whenever the disks are changed. If a changed disk is to be +XMread but not written, BDOS allows the disk to be changed without the +XMwarm or cold start, but internally marks the drive as Read-Only. +XMThe status of the drive is subsequently changed to Read-Write if a +XMwarm or cold start occurs. On issuing this message, CP/M waits for +XMinput from the console. An automatic warm start takes place +Xfollowing any input. + + +W1.8 CP/M Operation on the Model 800 + + + + + + 1-38 + + + + + +CP/M Operating System Manual 1.8 Operation of CP/M on the Model 800 + + + MThis section gives operating procedures for using CP/M on the +XMIntel Model 800 microcomputer development system microcomputer +XMdevelopment system. Basic knowledge of the microcomputer +Xdevelopment system hardware and software systems is assumed. + + MCP/M is initiated in essentially the same manner as the Intel +XMISIS operating system. The disk drives are labeled 0 through 3 on +XMthe microcomputer development system, corresponding to CP/M drives A +XMthrough D, respectively. The CP/M system disk is inserted into +XMdrive 0, and the BOOT and RESET switches are pressed in sequence. +XMThe interrupt 2 light should go on at this point. The space bar is +XMthen pressed on the system console, and the light should go out. If +XMit does not, the user should check connections and baud rates. The +XMBOOT switch is turned off, and the CP/M sign-on message should +XMappear at the selected console device, followed by the A> system +XMprompt. You can then issue the various resident and transient +Xcommands. + + MThe CP/M system can be restarted (warm start) at any time by +XMpushing the INT 0 switch on the front panel. The built-in Intel ROM +XMmonitor can be initiated by pushing the INT 7 switch, which +XMgenerates an RST 7, except when operating under DDT, in which case +Xthe DDT program gets control instead. + + MDiskettes can be removed from the drives at any time, and the +XMsystem can be shut down during operation without affecting data +XMintegrity. Do not remove a disk and replace it with another without +XMrebooting the system (cold or warm start) unless the inserted disk +Xis Read-Only. + + MAs a result of hardware hang-ups or malfunctions, CP/M might +Xprint the following message: + + BDOS ERR ON d: BAD SECTOR + +Mwhere d is the drive that has a permanent error. This error can +XMoccur when drive doors are opened and closed randomly, followed by +XMdisk operations, or can be caused by a disk, drive, or controller +XMfailure. You can optionally elect to ignore the error by pressing a +XMsingle return at the console. The error might produce a bad data +XMrecord, requiring reinitialization of up to 128 bytes of data. You +Xcan reboot the CP/M system and try the operation again. + + MTermination of a CP/M session requires no special action, +XMexcept that it is necessary to remove the disks before turning the +XMpower off to avoid random transients that often make their way to +Xthe drive electronics. + + MYou should use IBM-compatible disks rather than disks that have +XMpreviously been used with any ISIS version. In particular, the ISIS +XMFORMAT operation produces nonstandard sector numbering throughout +XMthe disk. This nonstandard numbering seriously degrades the +XMperformance of CP/M, and causes CP/M to operate noticeably slower +XMthan the distribution version. If it becomes necessary to reformat +XMa disk, which should not be the case for standard disks, a program + + + 1-M39 + + + +X + +CP/M Operating System Manual 1.8 Operation of CP/M on the Model 800 + + +Mcan be written under CP/M that causes the Model 800 controller to +Xreformat with sequential sector numbering (1-26) on each track. + + MGenerally, IBM-compatible 8-inch disks do not need to be +Xformatted. However, 5 1/4-inch disks need to be formatted. + + +=End of Section 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1-40 + + + + + + + + +=WSection 2 + +=WThe CP/M Editor + + + +W2.1 Introduction to Ed + + ME&Sd is the context editor for CP/M, and is used to create and +XMalter CP/M source files. To start ED, type a command of the +Xfollowing form: + + ED filename +or + ED filename.typ + +MGenerally, ED reads segments of the source file given by filename or +XMfilename.typ into the central memory, where you edit the file and it +XMis subsequently written back to disk after alterations. If the +XMsource file does not exist before editing, it is created by ED and +XMinitialized to empty. The overall operation of Ed is shown in +XFigure 2-1. + + +W2.1.1 ED Operation + + ME&Sd operates upon the source file, shown in Figure 2-1 by x.y, +XMand passes all text through a memory buffer where the text can be +XMviewed or altered. The number of lines that can be maintained in +XMthe memory buffer varies with the line length, but has a total +Xcapacity of about 5000 characters in a 20K CP/M system. + + MEdited text material is written into a temporary work file +XMunder your command. Upon termination of the edit, the memory buffer +XMis written to the temporary file, followed by any remaining (unread) +XMtext in the source file. The name of the original file is changed +XMfrom x.y to x.BAK so that the most recent edited source file can be +XMreclaimed if necessary. See the CP/M commands ERASE and RENAME. +XMThe temporary file is then changed from x.$$$ to x.y, which becomes +Xthe resulting edited file. + + MThe memory buffer is logically between the source file and +Xworking file, as shown in Figure 2-2. + + + + + + + + + + + + + + + 2-1 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +=WFigure 2-1. Overall ED Operation + + + + Source File Memory Buffer Temporary File + + 1 First Line 1 First Line 1 First Line + 2 Appended 2 Buffered 2 Processed + 3 Lines 3 Text 3 Text + + + + SP MP TP + + + + Unprocessed Next Free Next Free File + Source Append Memory Write Space + Lines Space + + + + SP = Source Pointer + MP = Memory Pointer + TP = Temporary Pointer + + +=WFigure 2-2. Memory Buffer Organization + + + 2-2 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +W2.1.2 Text Transfer Functions + + MG&Siven that n is an integer value in the range 0 through 65535, +XMseveral single-letter ED commands transfer lines of text from the +XMsource file through the memory buffer to the temporary (and +XMeventually final) file. Single letter commands are shown in upper- +Xcase, but can be typed in either upper- or lower-case. + + +=WTable 2-1. ED Text Transfer Commands + + Command Result + + 9 F0 nA MAppends the next n unprocessed source lines +X Mfrom the source file at SP to the end of the +X Mmemory buffer at MP. Increment SP and MP by n. +X MIf upper-case translation is set (see the U +X Mcommand) and the A command is typed in upper- +X Mcase, all input lines will automatically be +X translated to upper-case. + + nW MWrites the first n lines of the memory buffer +X Mto the temporary file free space. Shift the +X Mremaining lines n+1 through MP to the top of +X the memory buffer. Increment TP by n. + + E MEnds the edit. Copy all buffered text to +X Mtemporary file and copy all unprocessed source +X lines to temporary file. Rename files. + + H MMoves to head of new file by performing +X Mautomatic E command. The temporary file +X Mbecomes the new source file, the memory buffer +X Mis emptied, and a new temporary file is +X Mcreated. The effect is equivalent to issuing +X Man E command, followed by a reinvocation of ED, +X using x.y as the file to edit. + + O MReturns to original file. The memory buffer is +X Memptied, the temporary file is deleted, and the +X MSP is returned to position 1 of the source +X Mfile. The effects of the previous editing +X commands are thus nullified. + + Q MQuits edit with no file alterations, returns to +X CP/M. + 9 K0 + + MThere are a number of special cases to consider. If the +XMinteger n is omitted in any ED command where an integer is allowed, +XMthen 1 is assumed. Thus, the commands A and W append one line and +XMwrite one line, respectively. In addition, if a pound sign # is +XMgiven in the place of n, then the integer 65535 is assumed (the +XMlargest value for n that is allowed). Because most source files can +XMbe contained entirely in the memory buffer, the command #A is often + + + 2-M3 + + + +X + +CP/M Operating System Manual 2.1 Introduction to ED + + +Missued at the beginning of the edit to read the entire source file +XMto memory. Similarly, the command #W writes the entire buffer to +Xthe temporary file. + + MTwo special forms of the A and W commands are provided as a +XMconvenience. The command 0A fills the current memory buffer at +XMleast half full, while 0W writes lines until the buffer is at least +XMhalf empty. An error is issued if the memory buffer size is +XMexceeded. You can then enter any command, such as W, that does not +XMincrease memory requirements. The remainder of any partial line +XMread during the overflow will be brought into memory on the next +Xsuccessful append. + + +W2.1.3 Memory Buffer Organization + + MT&She memory buffer can be considered a sequence of source lines +XMbrought in with the A command from a source file. The memory buffer +XMhas an imaginary character pointer (CP) that moves throughout the +Xmemory buffer under command of the operator. + + MThe memory buffer appears logically as shown in Figure 2-3, +XMwhere the dashes represent characters of the source line of +XMindefinite length, terminated by carriage return () and line- +XMfeed () characters, and CP represents the imaginary character +XMpointer. Note that the CP is always located ahead of the first +XMcharacter of the first line, behind the last character of the last +XMline, or between two characters. The current line CL is the source +Xline that contains the CP. + + + + Memory Buffer + + + first line ----------------------- + + + ----------------------- + + + current line CL --------------------------- + + + CP + + last line ----------------------- + + +W Figure 2-3. Logical Organization of Memory Buffer + + + + + + + + 2-4 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +&SW2.1.4 Line Numbers and ED Start-up + + ME&SD produces absolute line number prefixes that are used to +XMreference a line or range of lines. The absolute line number is +XMdisplayed at the beginning of each line when ED is in insert mode +XM(see the I command in Section 2.1.5). Each line number takes the +Xform + + nnnnn: + +Mwhere nnnnn is an absolute line number in the range of 1 to 65535. +XMIf the memory buffer is empty or if the current line is at the end +Xof the memory buffer, nnnnn appears as 5 blanks. + + MYou can reference an absolute line number by preceding any +XMcommand by a number followed by a colon, in the same format as the +XMline number display. In this case, the ED program moves the current +XMline reference to the absolute line number, if the line exists in +XMthe current memory buffer. The line denoted by the absolute line +XMnumber must be in the memory buffer (see the A command). Thus, the +Xcommand + + 345:T + +Mis interpreted as move to absolute 345, and type the line. +XMAbsolute line numbers are produced only during the editing process +XMand are not recorded with the file. In particular, the line numbers +Xwill change following a deleted or expanded section of text. + + MYou can also reference an absolute line number as a backward or +XMforward distance from the current line by preceding the absolute +Xnumber by a colon. Thus, the command + + :400T + +Mis interpreted as type from the current line number through the line +XMwhose absolute number is 400. Combining the two line reference +Xforms, the command + + 345::400T + +Mis interpreted as move to absolute line 345, then type through +XMabsolute line 400. Absolute line references of this sort can +Xprecede any of the standard ED commands. + + MLine numbering is controlled by the V (Verify Line Numbers) +XMcommand. Line numbering can be turned off by typing the -V command. +X + + + + + + + + + + 2-5 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +MIf the file to edit does not exist, ED displays the following +Xmessage: + + NEW FILE + +MTo move text into the memory buffer, you must enter an i command +XMbefore typing input lines and terminate each line with a carriage +Xreturn. A single CTRL-Z character returns ED to command mode. + + +W2.1.5 Memory Buffer Operation + + MW&Shen ED begins, the memory buffer is empty. You can either +XMappend lines from the source file with the A command, or enter the +XMlines directly from the console with the insert command. The insert +Xcommand takes the following form: + + I + +MED then accepts any number of input lines. You must terminate each +XMline with a (the is supplied automatically). A single +XMCTRL-Z, denoted by a caret (^)Z, returns ED to command mode. The CP +XMis positioned after the last character entered. The following +Xsequence: + + I + NOW IS THE + TIME FOR + ALL GOOD MEN + ^Z + +leaves the memory buffer as + + NOW IS THE + TIME FOR + ALL GOOD MEN + + MGenerally, ED accepts command letters in upper- or lower-case. +XMIf the command is upper-case, all input values associated with the +XMcommand are translated to upper-case. If the I command is typed, +XMall input lines are automatically translated internally to upper- +XMcase. The lower-case form of the i command is most often used to +Xallow both upper- and lower-case letters to be entered. + + MVarious commands can be issued that control the CP or display +XMsource text in the vicinity of the CP. The commands shown below +XMwith a preceding n indicate that an optional unsigned value can be +XMspecified. When preceded by +_, the command can be unsigned, or have +XMan optional preceding plus or minus sign. As before, the pound sign +XM# is replaced by 65535. If an integer n is optional, but not +XMsupplied, then n=1 is assumed. Finally, if a plus sign is optional, +Xbut none is specified, then + is assumed. + + + + + + 2-6 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +=WTable 2-2. Editing Commands + + Command Action + + 9 F0 +_B MMove CP to beginning of memory buffer if + and +X to bottom if -. + + +_nC MMove CP by +_n characters (moving ahead if +), +X counting the as two characters. + + +_nD MDelete n characters ahead of CP if plus and +X behind CP if minus. + + +_nK MKill (remove) +_n lines of source text using CP +X Mas the current reference. If CP is not at the +X Mbeginning of the current line when K is issued, +X Mthe characters before CP remain if + is +X Mspecified, while the characters after CP remain +X if - is given in the command. + + +_nL MIf n = 0, move CP to the beginning of the +X Mcurrent line, if it is not already there. If n +X M=/ 0, first move the CP to the beginning of the +X Mcurrent line and then move it to the beginning +X Mof the line that is n lines down (if +) or up +X M(if -). The CP will stop at the top or bottom +X Mof the memory buffer if too large a value of n +X is specified. + + +_nT MIf n = 0, type the contents of the current line +X Mup to CP. If n = 1, type the contents of the +X Mcurrent line from CP to the end of the line. +X MIf n>1, type the current line along with n - 1 +X Mlines that follow, if + is specified. +X MSimilarly, if n>1 and - is given, type the +X Mprevious n lines up to the CP. Any key can be +X depressed to abort long type-outs. + + +_n MEquivalent to +_nLT, which moves up or down and +X types a single line. + 9 K0 + + +W2.1.6 Command Strings + + MA&Sny number of commands can be typed contiguously (up to the +XMcapacity of the console buffer) and are executed only after you +XMpress the . Table 2-3 summarizes the CP/M console line-editing +Xcommands used to control the input command line. + + + + + + + + + 2-7 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +=WTable 2-3. Line-editing Controls + + Command Result + + 9 F0 CTRL-C MReboots the CP/M system when typed at the +X start of a line. + + CTRL-E MPhysical end of line: carriage is returned, +X Mbut line is not sent until the carriage return +X key is depressed. + + CTRL-H Backspaces one character position. + + CTRL-J Terminates current input (line-feed). + + CTRL-M Terminates current input (carriage return). + + CTRL-R MRetypes current command line: types a clean +X line character deletion with rubouts. + + CTRL-U MDeletes the entire line typed at the console. +X + CTRL-X Same as CTRL-U. + + CTRL-Z MEnds input from the console (used in PIP and +X ED). + + rub/del MDeletes and echos the last character typed at +X the console. + 9 K0 + + MSuppose the memory buffer contains the characters shown in the +XMprevious section, with the CP following the last character of the +XMbuffer. In the following example, the command strings on the left +XMproduce the results shown to the right. Use lower-case command +Xletters to avoid automatic translation of strings to upper-case. + + + Command String Effect + + 9 F0 B2T MMove to beginning of the buffer and type +X two lines: + + NOW IS THE + TIME FOR + The result in the memory buffer is + + NOW IS THE + TIME FOR + ALL GOOD MEN + + + + + + + + 2-8 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + + Command String Effect + + 5C0T MMove CP five characters and type the +X Mbeginning of the line NOW I. The result +X in the memory buffer is + + NOW I S THE + + + 2L-T MMove two lines down and type the previous +X Mline TIME FOR. The result in the memory +X buffer is + + NOW IS THE + TIME FOR + ALL GOOD MEN + + + -L#K MMove up one line, delete 65535 lines that +X Mfollow. The result in the memory buffer +X is + + NOW IS THE + + + I Insert two lines of text with automatic + TIME TO translation to upper-case. The result in + INSERT the memory buffer is + ^Z + + NOW IS THE + TIME TO + INSERT + + + -2L#T MMove up two lines and type 65535 lines +X Mahead of CP NOW IS THE. The result in the +X memory buffer is + + NOW IS THE + TIME TO + INSERT + + + MMove down one line and type one line +X MINSERT. The result in the memory buffer +X is + + NOW IS THE + TIME TO + INSERT + 9 K0 + + + + + + 2-9 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +W2.1.7 Text Search and Alteration + + ME&SD has a command that locates strings within the memory buffer. +XThe command takes the form + + nF s +or + nF s ^Z + +Mwhere s represents the string to match, followed by either a or +XMCTRL-Z, denoted by ^Z. ED starts at the current position of CP and +XMattempts to match the string. The match is attempted n times and, +XMif successful, the CP is moved directly after the string. If the n +XMmatches are not successful, the CP is not moved from its initial +XMposition. Search strings can include CTRL-L, which is replaced by +Xthe pair of symbols . + + The following commands illustrate the use of the F command: + + + Command String Effect + + 9 F0 B#T MMove to the beginning and type the entire +X Mbuffer. The result in the memory buffer +X is + + NOW IS THE + TIME FOR + ALL GOOD MEN + + + FS T MFind the end of the string S T. The +X result in the memory buffer is + + NOW IS T HE + + + FIs^Z0TT MFind the next I and type to the CP; then +X Mtype the remainder of the current line ME +X FOR. The result in the memory buffer is + + NOW IS THE + TI ME FOR + + ALL GOOD MEN + 9 K0 + + MAn abbreviated form of the insert command is also allowed, +XMwhich is often used in conjunction with the F command to make simple +Xtextual changes. The form is + + | s ^Z +or + | s + + + + 2-10 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +Mwhere s is the string to insert. If the insertion string is +XMterminated by a CTRL-Z, the string is inserted directly following +XMthe CP, and the CP is positioned directly after the string. The +XMaction is the same if the command is followed by a except that +XMa is automatically inserted into the text following the +XMstring. The following command sequences are examples of the F and I +Xcommands: + + + Command String Effect + 9 F0 + BITHIS IS ^Z + + MInsert THIS IS at the beginning of the +X text. The result in the memory buffer is + + THIS IS NOW THE + + TIME FOR + ALL GOOD MEN + + + FTIME^Z-4DIPLACE^Z + + MFind TIME and delete it; then insert +X MPLACE. The result in the memory buffer is +X + THIS IS NOW THE + PLACE FOR + + ALL GOOD MEN + + + 3FO^Z-3D5D1 + CHANGES^Z MFind third occurrence of O (that is, the +X Msecond O in GOOD), delete previous 3 +X Mcharacters and the subsequent 5 +X Mcharacters; then insert CHANGES. The +X result in the memory buffer is + + THIS IS NOW THE + PLACE FOR + ALL CHANGES + + + -8CISOURCE + + MMove back 8 characters and insert the line +X MSOURCE. The result in the memory +X buffer is + + THIS IS NOW THE + PLACE FOR + ALL SOURCE + CHANGES + + + 2-11 + + + + 9 K0 + +CP/M Operating System Manual 2.1 Introduction to ED + + + + + MED also provides a single command that combines the F and I +XMcommands to perform simple string substitutions. The command takes +Xthe following form: + + nS sU1D^ZsU2D +or + nS sU1D^ZsU2D ^Z + +Mand has exactly the same effect as applying the following command +Xstring a total of n times: + + F sU1D^Z-kDIsU2 +or + F sU1D^Z-kDIsU2D ^Z + +Mwhere k is the length of the string. ED searches the memory buffer +XMstarting at the current position of CP and successively substitutes +XMthe second string for the first string until the end of buffer, or +Xuntil the substitution has been performed n times. + + MAs a convenience, a command similar to F is provided by ED that +XMautomatically appends and writes lines as the search proceeds. The +Xform is + + n N s +or + n N s ^Z + +Mwhich searches the entire source file for the nth occurrence of the +XMstrings (you should recall that F fails if the string cannot be +XMfound in the current buffer). The operation of the N command is +XMprecisely the same as F except in the case that the string cannot be +XMfound within the current memory buffer. In this case, the entire +XMmemory content is written (that is, an automatic #W is issued). +XMInput lines are then read until the buffer is at least half full, or +XMthe entire source file is exhausted. The search continues in this +XMmanner until the string has been found n times, or until the source +Xfile has been completely transferred to the temporary file. + + MA final line editing function, called the juxtaposition +Xcommand, takes the form + + n J sU1D^ZsU2D^ZsU3D +or + n J sU1D^ZsU2D^ZsU3D ^Z + +Mwith the following action applied n times to the memory buffer: +XMsearch from the current CP for the next occurrence of the string s1. +XMIf found, insert the string s2, and move CP to follow s2. Then +XMdelete all characters following CP up to, but not including, the +XMstring sU3D, leaving CP directly after sU2D. If sU3D cannot be found, +Xthen no deletion is made. If the current line is + + + + 2-12 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + + NOW IS THE TIME + +the command + + JW ^ZWHAT^Z^1 + +results in + + NOW WHAT + +MYou should recall that ^1 (CTRL-L) represents the pair in +Xsearch and substitute strings. + + MThe number of characters ED allows in the F, S, N, and J +Xcommands is limited to 100 symbols. + + +W2.1.8 Source Libraries + + ME&SD also allows the inclusion of source libraries during the +Xediting process with the R command. The form of this command is + + R filename ^Z +or + R filename + +Mwhere filename is the primary filename of a source file on the disk +XMwith an assumed filetype of LIB. ED reads the specified file, and +XMplaces the characters into the memory buffer after CP, in a manner +Xsimilar to the I command. Thus, if the command + + RMACRO + +Mis issued by the operator, ED reads from the file MACRO.LIB until +XMthe end-of-file and automatically inserts the characters into the +Xmemory buffer. + + MED also includes a block move facility implemented through the +XX (Transfer) command. The form + + nX + +Mtransfers the next n lines from the current line to a temporary file +Xcalled + + X$$$$$$.LIB + +Mwhich is active only during the editing process. You can reposition +XMthe current line reference to any portion of the source file and +XMtransfer lines to the temporary file. The transferred lines +XMaccumulate one after another in this file and can be retrieved by +Xsimply typing + + R + + + + 2-13 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +Mwhich is the trivial case of the library read command. In this +XMcase, the entire transferred set of lines is read into the memory +XMbuffer. Note that the X command does not remove the transferred +XMlines from the memory buffer, although a K command can be used +XMdirectly after the X, and the R command does not empty the +XMtransferred LIB file. That is, given that a set of lines has been +XMtransferred with the X command, they can be reread any number of +Xtimes back into the source file. The command + + 0X + +is provided to empty the transferred line file. + + MNote that upon normal completion of the ED program through Q or +XME, the temporary LIB file is removed. If ED is aborted with a CTRL- +XMC, the LIB file will exist if lines have been transferred, but will +XMgenerally be empty (a subsequent ED invocation will erase the +Xtemporary file). + + +W2.1.9 Repetitive Command Execution + + MT&She macro command M allows you to group ED commands together +Xfor repeated evaluation. The M command takes the following form: + + n M CS +or + n M CS ^Z + +Mwhere CS represents a string of ED commands, not including another M +XMcommand. ED executes the command string n times if n>1. If n=0 or +XM1, the command string is executed repetitively until an error +XMcondition is encountered (for example, the end of the memory buffer +Xis reached with an F command). + + MAs an example, the following macro changes all occurrences of +XMGAMMA to DELTA within the current buffer, and types each line that +Xis changed: + + MFGAMMA^Z-5DIDELTA^Z0TT + +or equivalently + + MSGAMMA^ZDELTA^Z0TT + + +W2.2 ED Error Conditions + + MO&Sn error conditions, ED prints the message BREAK X AT C where X +Xis one of the error indicators shown in Table 2-4. + + + + + + + + 2-14 + + + + + +CP/M Operating System Manual 2.2 ED Error Conditions + + +=WTable 2-4. Error Message Symbols + + Symbol Meaning + + 9 H0 ? Unrecognized command. + + > MMemory buffer full (use one of the commands D, K, +X MN, S, or W to remove characters); F, N, or S +X strings too long. + + # MCannot apply command the number of times +X specified (for example, in F command). + + O Cannot open LIB file in R command. + 9 K0 + +If there is a disk error, CP/M displays the following message: + + BDOS ERR on d: BAD SECTOR + +MYou can choose to ignore the error by pressing RETURN at the console +XM(in this case, the memory buffer data should be examined to see if +XMthey were incorrectly read), or you can reset the system with a +XMCTRL-C and reclaim the back-up file if it exists. The file can be +XMreclaimed by first typing the contents of the BAK file to ensure +XMthat it contains the proper information. For example, type the +Xfollowing: + + TYPE x.BAK + +where x is the file being edited. Then remove the primary file + + ERA x.y + +and rename the BAK file + + REN x.y=x.BAK + +The file can then be reedited, starting with the previous version. + + MED also takes file attributes into account. If you attempt to +Xedit a Read-Only file, the message + + ** FILE IS READ/ONLY ** + +Mappears at the console. The file can be loaded and examined, but +XMcannot be altered. You must end the edit session and use STAT to +XMchange the file attribute to R/W. If the edited file has the system +Xattribute set, the following message: + + 'SYSTEM' FILE NOT ACCESSIBLE + +Mis displayed and the edit session is aborted. Again, the STAT +Xprogram can be used to change the system attribute, if desired. + + + + 2-15 + + + + + +CP/M Operating System Manual 2.3 Control Characters and Commands + + +W2.3 Control Characters and Commands + + MT&Sable 2-5 summarizes the control characters and commands +Xavailable in ED. + + +=WTable 2-5. ED Control Characters + + 9 F0 Control Function + Character + + CTRL-C System reboot + + CTRL-E MPhysical (not actually entered in +X command) + + CTRL-H Backspace + + CTRL-J Logical tab (cols 1, 9, 16, ...) + + CTRL-L MLogical in search and substitute +X strings + + CTRL-R Repeat line + + CTRL-U Line delete + + CTRL-X Line delete + + CTRL-Z String terminator + + rub/del Character delete + + 9 K0 + Table 2-6 summarizes the commands used in ED. + + +=WTable 2-6. ED Commands + + Command Function + 9 F0 + nA Append lines + + +_B Begin or bottom of buffer + + +_nC Move character positions + + +_nD Delete characters + + E End edit and close files (normal end) + + nF Find string + + + + + + 2-16 + + + + 9 K0 + +CP/M Operating System Manual 2.3 Control Characters and Commands + + +=WTable 2-6. (continued) + + Command Function + 9 F0 + H End edit, close and reopen files + + I MInsert characters, use i if both upper and +X lower-case characters are to be entered. + + nJ Place strings in juxtaposition + + +_nK Kill lines + + +_nL Move down/up lines + + nM Macro definition + + nN Find next occurrence with autoscan + + O Return to original file + + +_nP Move and print pages + + Q Quit with no file changes + + R Read library file + + nS Substitute strings + + +_nT Type lines + + +_U MTranslate lower- to upper-case if U, no +X translation if -U + + +_V MVerify line numbers, or show remaining +X free character space + + 0V MA special case of the V command, OV, +X Mprints the memory buffer statistics in the +X form + + free/total + + Mwhere free is the number of free bytes in +X Mthe memory buffer (in decimal) and total +X is the size of the memory buffer + + nW Write lines + + nZ Wait (sleep) for approximately n seconds + + +_n Move and type (+_nLT). + 9 K0 + + + + + 2-17 + + + + + +CP/M Operating System Manual 2.3 Control Characters and Commands + + + MBecause of common typographical errors, ED requires several +XMpotentially disastrous commands to be typed as single letters, +Xrather than in composite commands. The following commands: + + o E(end) + o H(head) + o O(original) + o Q(quit) + +must be typed as single letter commands. + + MThe commands I, J, M, N, R, and S should be typed as i, j, m, +XMn, r, and s if both upper- and lower-case characters are used in the +XMoperation, otherwise all characters are converted to upper-case. +XMWhen a command is entered in upper-case, ED automatically converts +Xthe associated string to upper-case, and vice versa. + + +=End of Section 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2-18 + + + + + + + + +=WSection 3 + +=WCP/M Assembler + + + +&SW3.1 Introduction + + MT&She CP/M assembler reads assembly-language source files from +XMthe disk and produces 8080 machine language in Intel hex format. To +XMstart the CP/M assembler, type a command in one of the following +Xforms: + + ASM filename + ASM filename.parms + +MIn both cases, the assembler assumes there is a file on the disk +Xwith the name: + + filename.ASM + +Mwhich contains an 8080 assembly-language source file. The first and +XMsecond forms shown above differ only in that the second form allows +XMparameters to be passed to the assembler to control source file +Xaccess and hex and print file destinations. + + MIn either case, the CP/M assembler loads and prints the +Xmessage: + + CP/M ASSEMBLER VER n.n + +Mwhere n.n is the current version number. In the case of the first +XMcommand, the assembler reads the source file with assumed filetype +XASM and creates two output files + + filename.HEX + filename.PRN + + MThe HEX file contains the machine code corresponding to the +XMoriginal program in Intel hex format, and the PRN file contains an +XMannotated listing showing generated machine code, error flags, and +XMsource lines. If errors occur during translation, they are listed +Xin the PRN file and at the console. + + MThe form ASM filename parms is used to redirect input and +XMoutput files from their defaults. In this case, the parms portion +XMof the command is a three-letter group that specifies the origin of +XMthe source file, the destination of the hex file, and the +Xdestination of the print file. The form is + + + + + + + + + 3-1 + + + + + +CP/M Operating System Manual 3.1 Introduction + + + filename.p1p2p3 + +where p1, p2, and p3 are single letters. P1 can be + + A,B, ...,P + +Mwhich designates the disk name that contains the source file. P2 +Xcan be + + A,B, ...,P + +Mwhich designates the disk name that will receive the hex file; or, +XP2 can be + + Z + +which skips the generation of the hex file. + + P3 can be + + A,B, ...,P + +Mwhich designates the disk name that will receive the print file. P3 +Xcan also be specified as + + X + +which places the listing at the console; or + + Z + +which skips generation of the print file. Thus, the command + + ASM X.AAA + +Mindicates that the source, X.HEX, and print, X.PRN, files are also +XMto be created on disk A. This form of the command is implied if the +XMassembler is run from disk A. Given that you are currently +Xaddressing disk A, the above command is the same as + + ASM X + +The command + + ASM X.ABX + +Mindicates that the source file is to be taken from disk A, the hex +XMfile is to be placed on disk B, and the listing file is to be sent +Xto the console. The command + + ASM X.BZZ + +Mtakes the source file from disk B and skips the generation of the +XMhex and print files. This command is useful for fast execution of +Xthe assembler to check program syntax. + + + 3-2 + + + + + +CP/M Operating System Manual 3.1 Introduction + + + + MThe source program format is compatible with the Intel 8080 +XMassembler. Macros are not implemented in ASM; see the optional MAC +XMmacro assembler. There are certain extensions in the CP/M assembler +XMthat make it somewhat easier to use. These extensions are described +Xbelow. + + +W3.2 Program Format + + MA&Sn assembly-language program acceptable as input to the +Xassembler consists of a sequence of statements of the form + + line# label operation operand ;comment + +Mwhere any or all of the fields may be present in a particular +XMinstance. Each assembly-language statement is terminated with a +XMcarriage return and line-feed (the line-feed is inserted +XMautomatically by the ED program), or with the character !, which is +XMtreated as an end-of-line by the assembler. Thus, multiple +XMassembly-language statements can be written on the same physical +Xline if separated by exclamation point symbols. + + MThe line# is an optional decimal integer value representing the +Xsource program line number, and ASM ignores this field if present. + + The label field takes either of the following forms: + + identifier + identifier: + +MThe label field is optional, except where noted in particular +XMstatement types. The identifier is a sequence of alphanumeric +XMcharacters where the first character is alphabetic. Identifiers can +XMbe freely used by the programmer to label elements such as program +XMsteps and assembler directives, but cannot exceed 16 characters in +XMlength. All characters are significant in an identifier, except for +XMthe embedded dollar symbol $, which can be used to improve +XMreadability of the name. Further, all lower-case alphabetics are +XMtreated as upper-case. The following are all valid instances of +Xlabels: + + + x xy long$name + + x: yxl: longer$named$data: + + X1Y2 X1x2 x234$5678$9012$3456: + + + MThe operation field contains either an assembler directive or +XMpseudo operation, or an 8080 machine operation code. The pseudo +XMoperations and machine operation codes are described in Section 3.3. +X + + + + 3-3 + + + + + +CP/M Operating System Manual 3.2 Program Format + + + MGenerally, the operand field of the statement contains an +XMexpression formed out of constants and labels, along with arithmetic +XMand logical operations on these elements. Again, the complete +Xdetails of properly formed expressions are given in Section 3.3. + + MThe comment field contains arbitrary characters following the +XMsemicolon symbol until the next real or logical end-of-line. These +XMcharacters are read, listed, and otherwise ignored by the assembler. +XMThe CP/M assembler also treats statements that begin with an * in +XMcolumn one as comment statements that are listed and ignored in the +Xassembly process. + + MThe assembly-language program is formulated as a sequence of +XMstatements of the above form, terminated by an optional END +XMstatement. All statements following the END are ignored by the +Xassembler. + + +W3.3 Forming the Operand + + MT&So describe the operation codes and pseudo operations +XMcompletely, it is necessary first to present the form of the operand +XMfield, since it is used in nearly all statements. Expressions in +XMthe operand field consist of simple operands, labels, constants, and +XMreserved words, combined in properly formed subexpressions by +XMarithmetic and logical operators. The expression computation is +XMcarried out by the assembler as the assembly proceeds. Each +XMexpression must produce a 16-bit value during the assembly. +XMFurther, the number of significant digits in the result must not +XMexceed the intended use. If an expression is to be used in a byte +XMmove immediate instruction, the most significant 8 bits of the +XMexpression must be zero. The restriction on the expression +Xsignificance is given with the individual instructions. + + +W3.3.1 Labels + + MA&Ss discussed above, a label is an identifier that occurs on a +XMparticular statement. In general, the label is given a value +XMdetermined by the type of statement that it precedes. If the label +XMoccurs on a statement that generates machine code or reserves memory +XMspace (for example, a MOV instruction or a DS pseudo operation), the +XMlabel is given the value of the program address that it labels. If +XMthe label precedes an EQU or SET, the label is given the value that +XMresults from evaluating the operand field. Except for the SET +Xstatement, an identifier can label only one statement. + + MWhen a label appears in the operand field, its value is +XMsubstituted by the assembler. This value can then be combined with +XMother operands and operators to form the operand field for a +Xparticular instruction. + + + + + + + 3-4 + + + + + +CP/M Operating System Manual 3.3 Forming the Operand + + +W3.3.2 Numeric Constants + + MA&S numeric constant is a 16-bit value in one of several bases. +XMThe base, called the radix of the constant, is denoted by a trailing +Xradix indicator. The following are radix indicators: + + o B is a binary constant (base 2). + o O is a octal constant (base 8). + o Q is a octal constant (base 8). + o D is a decimal constant (base 10). + o H is a hexadecimal constant (base 16). + + MQ is an alternate radix indicator for octal numbers because the +XMletter O is easily confused with the digit 0. Any numeric constant +XMthat does not terminate with a radix indicator is a decimal +Xconstant. + + MA constant is composed as a sequence of digits, followed by an +XMoptional radix indicator, where the digits are in the appropriate +XMrange for the radix. Binary constants must be composed of 0 and 1 +XMdigits, octal constants can contain digits in the range 0-7, while +XMdecimal constants contain decimal digits. Hexadecimal constants +XMcontain decimal digits as well as hexadecimal digits A(10D), B(11D), +XMC(12D), D(13D), E(14D), and F(15D). Note that the leading digit of +XMa hexadecimal constant must be a decimal digit to avoid confusing a +XMhexadecimal constant with an identifier. A leading 0 will always +XMsuffice. A constant composed in this manner must evaluate to a +XMbinary number that can be contained within a 16-bit counter, +Xotherwise it is truncated on the right by the assembler. + + MSimilar to identifiers, embedded $ signs are allowed within +XMconstants to improve their readability. Finally, the radix +XMindicator is translated to upper-case if a lower-case letter is +XMencountered. The following are all valid instances of numeric +Xconstants: + + + 1234 1234D 1100B 1111$0000$1111$0000B + + 1234H OFFEH 3377O 33$77$22Q + + 3377o Ofe3h 1234d Offffh + + +W3.3.3 Reserved Words + + MT&Shere are several reserved character sequences that have +XMpredefined meanings in the operand field of a statement. The names +XMof 8080 registers are given below. When they are encountered, they +Xproduce the values shown to the right. + + + + + + + + 3-5 + + + + + +CP/M Operating System Manual 3.3 Forming the Operand + + +W Table 3-1. Reserved Characters + + Character Value + + A 7 + B 0 + C 1 + D 2 + E 3 + H 4 + L 5 + M 6 + SP 6 + PSW 6 + + + MAgain, lower-case names have the same values as their upper- +XMcase equivalents. Machine instructions can also be used in the +XMoperand field; they evaluate to their internal codes. In the case of +XMinstructions that require operands, where the specific operand +XMbecomes a part of the binary bit pattern of the instruction, for +XMexample, MOV A,B, the value of the instruction, in this case MOV, is +XMthe bit pattern of the instruction with zeros in the optional +Xfields, for example, MOV produces 40H. + + MWhen the symbol $ occurs in the operand field, not embedded +XMwithin identifiers and numeric constants, its value becomes the +XMaddress of the next instruction to generate, not including the +Xinstruction contained within the current logical line. + + +W3.3.4 String Constants + + MS&String constants represent sequences of ASCII characters and +XMare represented by enclosing the characters within apostrophe +XMsymbols. All strings must be fully contained within the current +XMphysical line (thus allowing exclamation point symbols within +XMstrings) and must not exceed 64 characters in length. The +XMapostrophe character itself can be included within a string by +XMrepresenting it as a double apostrophe (the two keystrokes ''), +XMwhich becomes a single apostrophe when read by the assembler. In +XMmost cases, the string length is restricted to either one or two +XMcharacters (the DB pseudo operation is an exception), in which case +XMthe string becomes an 8- or 16-bit value, respectively. Two- +XMcharacter strings become a 16-bit constant, with the second +XMcharacter as the low-order byte, and the first character as the +Xhigh-order byte. + + MThe value of a character is its corresponding ASCII code. +XMThere is no case translation within strings; both upper- and lower- +XMcase characters can be represented. You should note that only +Xgraphic printing ASCII characters are allowed within strings. + + + + + + 3-6 + + + + + +CP/M Operating System Manual 3.3 Forming the Operand + + + Valid strings: How assembler reads strings: + + 'A' 'AB' 'ab' 'c' A AB ab c + '' 'a''' '''' '''' a' ' ' + 'Walla Walla Wash.' Walla Walla Wash. + 'She said ''Hello'' to me.' She said ''Hello'' to me + 'I said ''Hello'' to her.' I said ''Hello'' to her + + +W3.3.5 Arithmetic and Logical Operators + + MT&She operands described in Section 3.3 can be combined in normal +XMalgebraic notation using any combination of properly formed +XMoperands, operators, and parenthesized expressions. The operators +Xrecognized in the operand field are described in Table 3-2. + + +=WTable 3-2. Arithmetic and Logical Operators + 9 F0 + Operators Meaning + + a + b unsigned arithmetic sum of a and b + + a - b Munsigned arithmetic difference between a +X and b + + + b unary plus (produces b) + + - b unary minus (identical to 0 - b) + + a * b Munsigned magnitude multiplication of a and +X b + + a / b unsigned magnitude division of a by b + + a MOD b remainder after a / b. + + NOT b Mlogical inverse of b (all 0s become 1s, 1s +X Mbecome 0s), where b is considered a 16-bit +X value + + a AND b bit-by-bit logical and of a and b + + a OR b bit-by-bit logical or of a and b + + a XOR b bit-by-bit logical exclusive or of a and b + + a SHL b Mthe value that results from shifting a to +X the left by an amount b, with zero fill + + a SHR b Mthe value that results from shifting a to +X the right by an amount b, with zero fill + 9 K0 + + + + + 3-7 + + + + + +CP/M Operating System Manual 3.3 Forming the Operand + + + MIn each case, a and b represent simple operands (labels, +XMnumeric constants, reserved words, and one- or two-character +XMstrings) or fully enclosed parenthesized subexpressions, like those +Xshown in the following examples: + + + 10+20 10h+37Q LI/3 (L2+4) SHR 3 + + ('a' and 5fh) + '0' ('B'+B) OR (PSW+M) + + (1+(2+c)) shr (A-(B+1)) + + + MNote that all computations are performed at assembly time as +XM16-bit unsigned operations. Thus, -1 is computed as 0-1, which +XMresults in the value 0ffffh (that is, all 1s). The resulting +XMexpression must fit the operation code in which it is used. For +XMexample, if the expression is used in an ADI (add immediate) +XMinstruction, the high-order 8 bits of the expression must be zero. +XMAs a result, the operation ADI-1 produces an error message (-1 +XMbecomes 0ffffh, which cannot be represented as an 8-bit value), +XMwhile ADI(-1) AND 0FFH is accepted by the assembler because the AND +Xoperation zeros the high-order bits of the expression. + + +W3.3.6 Precedence of Operators + + MA&Ss a convenience to the programmer, ASM assumes that operators +XMhave a relative precedence of application that allows the programmer +XMto write expressions without nested levels of parentheses. The +XMresulting expression has assumed parentheses that are defined by the +XMrelative precedence. The order of application of operators in +XMunparenthesized expressions is listed below. Operators listed first +XMhave highest precedence (they are applied first in an +XMunparenthesized expression), while operators listed last have lowest +XMprecedence. Operators listed on the same line have equal +XMprecedence, and are applied from left to right as they are +Xencountered in an expression. + + + * / MOD SHL SHR + + - + + + NOT + + AND + + OR XOR + + + MThus, the expressions shown to the left below are interpreted +XMby the assembler as the fully parenthesized expressions shown to the +Xright. + + + + 3-8 + + + + + +CP/M Operating System Manual 3.3 Forming the Operand + + + a*b+c (a*b)+c + + a+b*c a+(b*c) + + a MOD b*c SHL d ((a MOD b)*c) SHL d + + a OR b AND NOT c+d SHL e a OR (b AND (NOT (c+(d SHL e)))) + + + MBalanced, parenthesized subexpressions can always be used to +XMoverride the assumed parentheses; thus, the last expression above +XMcould be rewritten to force application of operators in a different +Xorder, as shown: + + (a OR b) AND (NOT c)+ d SHL e + +This results in these assumed parentheses: + + (a OR b) AND ((NOT c) + (d SHL e)) + + MAn unparenthesized expression is well-formed only if the +XMexpression that results from inserting the assumed parentheses is +Xwell-formed. + + +W3.4 Assembler Directives + + MA&Sssembler directives are used to set labels to specific values +XMduring the assembly, perform conditional assembly, define storage +XMareas, and specify starting addresses in the program. Each +XMassembler directive is denoted by a pseudo operation that appears in +XMthe operation field of the line. The acceptable pseudo operations +Xare shown in Table 3-3. + + +W Table 3-3. Assembler Directives + + Directive Meaning + + ORG set the program or data origin + + END end program, optional start address + + EQU numeric equate + + SET numeric set + + IF begin conditional assembly + + ENDIF end of conditional assembly + + DB define data bytes + + DW define data words + + DS define data storage area + + 3-9 + + + + + +CP/M Operating System Guide 3.4 Assembler Directives + + +W3.4.1 The ORG Directive + + T&She ORG statement takes the form: + + label ORG expression + +Mwhere label is an optional program identifier and expression is a +XM16-bit expression, consisting of operands that are defined before +XMthe ORG statement. The assembler begins machine code generation at +XMthe location specified in the expression. There can be any number +XMof ORG statements within a particular program, and there are no +XMchecks to ensure that the programmer is not defining overlapping +XMmemory areas. Note that most programs written for the CP/M system +Xbegin with an ORG statement of the form: + + ORG 100H + +Mwhich causes machine code generation to begin at the base of the +XMCP/M transient program area. If a label is specified in the ORG +XMstatement, the label is given the value of the expression. This +XMlabel can then be used in the operand field of other statements to +Xrepresent this expression. + + +W3.4.2 The END Directive + + MT&She END statement is optional in an assembly-language program, +XMbut if it is present it must be the last statement. All subsequent +XMstatements are ignored in the assembly. The END statement takes the +Xfollowing two forms: + + label END + + label END expression + +Mwhere the label is again optional. If the first form is used, the +XMassembly process stops, and the default starting address of the +XMprogram is taken as 0000. Otherwise, the expression is evaluated, +XMand becomes the program starting address. This starting address is +XMincluded in the last record of the Intel-formatted machine code hex +XMfile that results from the assembly. Thus, most CP/M assembly- +Xlanguage programs end with the statement: + + END 100H + +Mresulting in the default starting address of 100H (beginning of the +Xtransient program area). + + + + + + + + + + + 3-10 + + + + + +CP/M Operating System Guide 3.4 Assembler Directives + + +W3.4.3 The EQU Directive + + MT&She EQU (equate) statement is used to set up synonyms for +Xparticular numeric values. The EQU statement takes the form: + + label EQU expression + +Mwhere the label must be present and must not label any other +XMstatement. The assembler evaluates the expression and assigns this +XMvalue to the identifier given in the label field. The identifier is +XMusually a name that describes the value in a more human-oriented +XMmanner. Further, this name is used throughout the program to place +XMparameters on certain functions. Suppose data received from a +XMteletype appears on a particular input port, and data is sent to the +XMteletype through the next output port in sequence. For example, you +XMcan use this series of equate statements to define these ports for a +Xparticular hardware environment: + + + TTYBASE EQU 10H ;BASE PORT NUMBER FOR TTY + + TTYIN EQU TTYBASE ;TTY DATA IN + + TTYOUT EQU TTYBASE+1 ;TTY DATA OUT + + + MAt a later point in the program, the statements that access the +Xteletype can appear as follows: + + + IN TTYIN ;READ TTY DATA TO REG-A + + ... + + OUT TTYOUT ;WRITE DATA TO TTY FROM REG-A + + +Mmaking the program more readable than if the absolute I/O ports are +XMused. Further, if the hardware environment is redefined to start +XMthe teletype communications ports at 7FH instead of 10H, the first +Xstatement need only be changed to + + TTYBASE EQU 7FH ;BASE PORT NUMBER FOR TTY + +Mand the program can be reassembled without changing any other +Xstatements. + + +W3.4.4 The SET Directive + + T&She SET statement is similar to the EQU, taking the form: + + label SET expression + +Mexcept that the label can occur on other SET statements within the +XMprogram. The expression is evaluated and becomes the current value + + 3-M11 + + + +X + +CP/M Operating System Guide 3.4 Assembler Directives + + +Massociated with the label. Thus, the EQU statement defines a label +XMwith a single value, while the SET statement defines a value that is +XMvalid from the current SET statement to the point where the label +XMoccurs on the next SET statement. The use of the SET is similar to +XMthe EQU statement, but is used most often in controlling conditional +Xassembly. + + +W3.4.5 The IF and ENDIF Directives + + MT&She IF and ENDIF statements define a range of assembly-language +XMstatements that are to be included or excluded during the assembly +Xprocess. These statements take on the form: + + + IF expression + + statement#1 + + statement#2 + + ... + + statement#n + + ENDIF + + + MWhen encountering the IF statement, the assembler evaluates the +XMexpression following the IF. All operands in the expression must be +XMdefined ahead of the IF statement. If the expression evaluates to a +XMnonzero value, then statement#1 through statement#n are assembled. +XMIf the expression evaluates to zero, the statements are listed but +XMnot assembled. Conditional assembly is often used to write a single +XMgeneric program that includes a number of possible run-time +XMenvironments, with only a few specific portions of the program +XMselected for any particular assembly. The following program +XMsegments, for example, might be part of a program that communicates +XMwith either a teletype or a CRT console (but not both) by selecting +Xa particular value for TTY before the assembly begins. + + + + + + + + + + + + + + + + + + 3-12 + + + + + +CP/M Operating System Guide 3.4 Assembler Directives + + + TRUE EQU OFFFFH ;DEFINE VALUE OF TRUE + FALSE EQU NOT TRUE ;DEFINE VALUE OF FALSE + ; + TTY EQU TRUE ;TRUE IF TTY, FALSE IF CRT + ; + TTYBASE EQU 10H ;BASE OF TTY I/O PORTS + CRTBASE EQU 20H ;BASE OF CRT I/O PORTS + IF TTY ;ASSEMBLE RELATIVE TO + ;TTYBASE + CONIN EQU TTYBASE ;CONSOLE INPUT + CONOUT EQU TTYBASE+1 ;CONSOLE OUTPUT + ENDIF + + ; IF NOT TTY ;ASSEMBLE RELATIVE TO + ;CRTBASE + CONIN EQU CRTBASE ;CONSOLE INPUT + CONOUT EQU CRTBASE+1 ;CONSOLE OUTPUT + + ENDIF + ... + IN CONIN ;READ CONSOLE DATA + ... + OUT CONTOUT ;WRITE CONSOLE DATA + + +MIn this case, the program assembles for an environment where a +XMteletype is connected, based at port 10H. The statement defining +XTTY can be changed to + + TTY EQU FALSE + +Mand, in this case, the program assembles for a CRT based at port +X20H. + + +W3.4.6 The DB Directive + + MT&She DB directive allows the programmer to define initialized +XMstorage areas in single-precision byte format. The DB statement +Xtakes the form: + + label DB e#1, e#2, ..., e#n + +Mwhere e#1 through e#n are either expressions that evaluate to 8-bit +XMvalues (the high-order bit must be zero) or are ASCII strings of +XMlength no greater than 64 characters. There is no practical +XMrestriction on the number of expressions included on a single source +XMline. The expressions are evaluated and placed sequentially into +XMthe machine code file following the last program address generated +XMby the assembler. String characters are similarly placed into +XMmemory starting with the first character and ending with the last +XMcharacter. Strings of length greater than two characters cannot be +Xused as operands in more complicated expressions. + + + + + 3-13 + + + + + +CP/M Operating System Guide 3.4 Assembler Directives + + +MWNote: &SASCII characters are always placed in memory with the parity +XMbit reset (0). Also, there is no translation from lower- to upper- +XMcase within strings. The optional label can be used to reference +XMthe data area throughout the remainder of the program. The +Xfollowing are examples of valid DB statements: + + + data: DB 0,1,2,3,4,5 + DB data and 0ffh,5,377Q,1+2+3+4 + + sign-on: DB 'please type your name',cr,lf,0 + DB 'AB' SHR 8, 'C', 'DE' AND 7FH + + + +W3.4.7 The DW Directive + + MT&She DW statement is similar to the DB statement except double- +XMprecision two-byte words of storage are initialized. The DW +Xstatement takes the form: + + label DW e#1, e#2, ..., e#n + +Mwhere e#1 through e#n are expressions that evaluate to 16-bit +XMresults. Note that ASCII strings of one or two characters are +XMallowed, but strings longer than two characters are disallowed. In +XMall cases, the data storage is consistent with the 8080 processor; +XMthe least significant byte of the expression is stored first in +XMmemory, followed by the most significant byte. The following are +Xexamples of DW statements: + + + doub: DW 0ffefh,doub+4,signon-$,255+255 + DW 'a', 5, 'ab', 'CD', 6 shl 8 or llb. + + + +W3.4.8 The DS Directive + + MT&She DS statement is used to reserve an area of uninitialized +Xmemory, and takes the form: + + label DS expression + +Mwhere the label is optional. The assembler begins subsequent code +XMgeneration after the area reserved by the DS. Thus, the DS +XMstatement given above has exactly the same effect as the following +Xstatement: + + label: EQU $ ;LABEL VALUE IS CURRENT CODE LOCATION + ORG $+expression ;MOVE PAST RESERVED AREA + + + + + + + 3-14 + + + + + +CP/M Operating System Manual 3.5 Operation Codes + + +W3.5 Operation Codes + + MA&Sssembly-language operation codes form the principal part of +XMassembly-language programs and form the operation field of the +XMinstruction. In general, ASM accepts all the standard mnemonics for +XMthe Intel 8080 microcomputer, which are given in detail in the EIntelR +XM8080 Assembly Language Programming Manual.R Labels are optional on +XMeach input line. The individual operators are listed briefly in the +XMfollowing sections for completeness, although the Intel manuals +XMshould be referenced for exact operator details. In Tables 3-4 +Xthrough 3-8, bit values have the following meaning: + + + o Me3 represents a 3-bit value in the range 0-7 that can be one of +X the predefined registers A, B, C, D, E, H, L, M, SP, or PSW. + + o e8 represents an 8-bit value in the range 0-255. + + o e16 represents a 16-bit value in the range 0-65535. + + + MThese expressions can be formed from an arbitrary combination +XMof operands and operators. In some cases, the operands are +XMrestricted to particular values within the allowable range, such as +XMthe PUSH instruction. These cases are noted as they are +Xencountered. + + MIn the sections that follow, each operation code is listed in +XMits most general form, along with a specific example, a short +Xexplanation, and special restrictions. + + +W3.5.1 Jumps, Calls, and Returns + + MT&She Jump, Call, and Return instructions allow several different +XMforms that test the condition flags set in the 8080 microcomputer +XCPU. The forms are shown in Table 3-4. + + +=WTable 3-4. Jumps, Calls, and Returns + 9 I0 + Form Bit Example Meaning + Value + + JMP e16 JMP L1 Jump unconditionally to label + + JNZ e16 JNZ L2 Jump on nonzero condition to label + + JZ e16 JZ 100H Jump on zero condition to label + + JNC e16 JNC L1+4 Jump no carry to label + + JC e16 JC L3 Jump on carry to label + + JPO e16 JPO $+8 Jump on parity odd to label + + + 3-15 + + + + 9 K0 + +CP/M Operating System Manual 3.5 Operation Codes + + +=WTable 3-4. (continued) + 9 I0 + Form Bit Example Meaning + Value + + JPE e16 JPE L4 Jump on even parity to label + + JP e16 JP GAMMA Jump on positive result to label + + JM e16 JM al Jump on minus to label + + + CALL e16 CALL S1 Call subroutine unconditionally + + CNZ e16 CNZ S2 Call subroutine on nonzero + condition + + CZ e16 CZ 100H Call subroutine on zero condition + + CNC e16 CNC S1+4 Call subroutine if no carry set + + CC e16 CC S3 Call subroutine if carry set + + CPO e16 CPO $+8 Call subroutine if parity odd + + CPE e16 CPE $4 Call subroutine if parity even + + CP e16 CP GAMMA Call subroutine if positive result + + CM e16 CM b1$c2 Call subroutine if minus flag + + + RST e3 RST 0 Programmed restart, equivalent to + CALL 8*e3, except one byte call + + RET Return from subroutine + + RNZ Return if nonzero flag set + + RZ Return if zero flag set + + RNC Return if no carry + + RC Return if carry flag set + + RPO Return if parity is odd + + RPE Return if parity is even + + RP Return if positive result + + RM Return if minus flag is set + 9 K0 + + + + + 3-16 + + + + + +CP/M Operating System Manual 3.5 Operation Codes + + +W3.5.2 Immediate Operand Instructions + + MS&Several instructions are available that load single- or double- +XMprecision registers or single-precision memory cells with constant +XMvalues, along with instructions that perform immediate arithmetic or +XMlogical operations on the accumulator (register A). Table 3-5 +Xdescribes the immediate operand instructions. + + +=WTable 3-5. Immediate Operand Instructions + + 9 F0 Form with Example Meaning + Bit Values + + MVI e3,e8 MVI B,255 MMove immediate data to +X Mregister A, B, C, D, E, H, +X L, or M (memory) + + ADI e8 ADI 1 MAdd immediate operand to A +X without carry + + ACI e8 ACI 0FFH MAdd immediate operand to A +X with carry + + SUI e8 SUI L + 3 MSubtract from A without +X borrow (carry) + + SBI e8 SBI L AND 11B MSubtract from A with borrow +X (carry) + + ANI e8 ANI $ AND 7FH MLogical and A with +X immediate data + + XRI e8 XRI 1111$0000B MExclusive or A with +X immediate data + + ORI e8 ORI L AND 1+1 MLogical or A with immediate +X data + + CPI e8 CPI 'a' MCompare A with immediate +X Mdata, same as SUI except +X register A not changed. + + LXI e3,e16 LXI B,100H MLoad extended immediate to +X Mregister pair. e3 must be +X Mequivalent to B, D, H, or +X SP. + 9 K0 + +W3.5.3 Increment and Decrement Instructions + + MT&She 8080 provides instructions for incrementing or decrementing +XMsingle- and double-precision registers. The instructions are +Xdescribed in Table 3-6. + + + + 3-17 + + + + + +CP/M Operating System Manual 3.5 Operation Codes + + +=WTable 3-6. Increment and Decrement Instructions + 9 F0 + Form with Example Meaning + Bit Value + + INR e3 INR E MSingle-precision increment +X Mregister. e3 produces one +X Mof A, B, C, D, E, H, L, M. +X + DCR e3 DCR A MSingle-precision decrement +X Mregister. e3 produces one +X Mof A, B, C, D, E, H, L, M. +X + INX e3 INX SP MDouble-precision increment +X Mregister pair. e3 must be +X Mequivalent to B, D, H, or +X SP. + + DCX e3 DCX B MDouble-precision decrement +X Mregister pair. e3 must be +X Mequivalent to B, D, H, or +X SP. + 9 K0 + + +W3.5.4 Data Movement Instructions + + MI&Snstructions that move data from memory to the CPU and from CPU +Xto memory are given in the following table. + + +=WTable 3-7. Data Movement Instructions + 9 F0 + Form with Example Meaning + Bit Value + + MOV e3,e3 MOV A,B MMove data to leftmost +X Melement from rightmost +X Melement. e3 produces on +X Mof A, B, C, D, E, H, L, or +X MM. MOV M,M is disallowed. +X + LDAX e3 LDAX B MLoad register A from +X Mcomputed address. e3 must +X produce either B or D. + + STAX e3 STAX D MStore register A to +X Mcomputed address. e3 must +X produce either B or D. + + LHLD e16 LHLD L1 MLoad HL direct from +X Mlocation e16. Double- +X Mprecision load to H and L. +X + + + + 3-18 + + + + 9 K0 + +CP/M Operating System Manual 3.5 Operation Codes + + +=WTable 3-7. (continued) + 9 F0 + Form with Example Meaning + Bit Value + + SHLD e16 SHLD L5+x MStore HL direct to +X Mlocation e16. Double- +X Mprecision store from H and +X L to memory. + + LDA e16 LDA Gamma MLoad register A from +X address e16. + + STA e16 STA X3-5 MStore register A into +X memory at e16. + + POP e3 POP PSW MLoad register pair from +X Mstack, set SP. e3 must +X Mproduce one of B, D, H, or +X PSW. + + PUSH e3 PUSH B MStore register pair into +X Mstack, set SP. e3 must +X Mproduce on of B, D, H, or +X PSW. + + IN e8 IN 0 MLoad register A with data +X from port e8. + + OUT e8 OUT 255 MSend data from register A +X to port e8. + + XTHL MExchange data from top of +X stack with HL. + + PCHL MFill program counter with +X data from HL. + + SPHL MFill stack pointer with +X data from HL. + + XCHG MExchange DE pair with HL +X pair. + 9 K0 + + +W3.5.5 Arithmetic Logic Unit Operations + + MI&Snstructions that act upon the single-precision accumulator to +XMperform arithmetic and logic operations are given in the following +Xtable. + + + + + + + 3-19 + + + + + +CP/M Operating System Manual 3.5 Operation Codes + + +=WTable 3-8. Arithmetic Logic Unit Operations + 9 F0 + Form with Example Meaning + Bit Value + + ADD e3 ADD B MAdd register given by e3 to +X Maccumulator without carry. +X Me3 must produce one of A, +X B, C, D, E, H, or L. + + ADC e3 ADC L MAdd register to A with +X carry, e3 as above. + + SUB e3 SUB H MSubtract reg e3 from A +X Mwithout carry, e3 is +X defined as above. + + SBB e3 SBB 2 MSubtract register e3 from A +X Mwith carry, e3 defined as +X above. + + ANA e3 ANA 1+1 MLogical and reg with A, e3 +X as above. + + XRA e3 XRA A MExclusive or with A, e3 as +X above. + + ORA e3 ORA B MLogical or with A, e3 +X defined as above. + + CMP e3 CMP H MCompare register with A, e3 +X as above. + + DAA MDecimal adjust register A +X Mbased upon last arithmetic +X logic unit operation. + + CMA MComplement the bits in +X register A. + + STC Set the carry flag to 1. + + CMC MComplement the carry flag. +X + RLC MRotate bits left, (re)set +X Mcarry as a side effect. +X MHigh-order A bit becomes +X carry. + + RRC MRotate bits right, (re)set +X Mcarry as side effect. +X MLow-order A bit becomes +X carry. + + + + + 3-20 + + + + 9 K0 + +CP/M Operating System Manual 3.5 Operation Codes + + +=WTable 3-8. (continued) + 9 F0 + Form with Example Meaning + Bit Value + + RAL MRotate carry/A register to +X Mleft. Carry is involved +X in the rotate. + + RAR MRotate carry/A register to +X Mright. Carry is involved +X in the rotate. + + DAD e3 DAD B MDouble-precision add +X Mregister pair e3 to HL. +X Me3 must produce B, D, H, +X or SP. + 9 K0 + +W3.5.6 Control Instructions + + MT&She four remaining instructions, categorized as control +Xinstructions, are the following: + + o HLT halts the 8080 processor. + o DI disables the interrupt system. + o EI enables the interrupt system. + o NOP means no operation. + + +W3.6 Error Messages + + MW&Shen errors occur within the assembly-language program, they +XMare listed as single-character flags in the leftmost position of the +XMsource listing. The line in error is also echoed at the console so +XMthat the source listing need not be examined to determine if errors +Xare present. The error codes are listed in the following table. + + +=WTable 3-9. Error Codes + + 9 F0 Error Code Meaning + + D MData error: element in data statement cannot +X be placed in the specified data area. + + E MExpression error: expression is ill-formed +X and cannot be computed at assembly time. + + L MLabel error: label cannot appear in this +X context; might be duplicate label. + + N MNot implemented: features that will appear in +X Mfuture ASM versions. For example, macros are +X recognized, but flagged in this version. + + + 3-21 + + + + 9 K0 + +CP/M Operating System Manual 3.6 Error Messages + + +=WTable 3-9. (continued) + + 9 F0 Error Code Meaning + + O MOverflow: expression is too complicated (too +X Mmany pending operators) to be computed and +X should be simplified. + + P MPhase error: label does not have the same +X Mvalue on two subsequent passes through the +X program. + + R MRegister error: the value specified as a +X Mregister is not compatible with the operation +X code. + + S MSyntax error: statement is not properly +X formed. + + V MValue error: operand encountered in +X expression is improperly formed. + 9 K0 + + MTable 3-10 lists the error messages that are due to terminal +Xerror conditions. + + +=WTable 3-10. Error Messages + + 9 F0 Message Meaning + + NO SOURCE FILE PRESENT + + MThe file specified in the ASM command does +X not exist on disk. + + + NO DIRECTORY SPACE + + MThe disk directory is full; erase files +X that are not needed and retry. + + + SOURCE FILE NAME ERROR + + MImproperly formed ASM filename, for +X example, it is specified with ? fields. + + + SOURCE FILE READ ERROR + + MSource file cannot be read properly by the +X Massembler; execute a TYPE to determine the +X point of error. + + + + 3-22 + + + + 9 K0 + +CP/M Operating System Manual 3.6 Error Messages + + +=WTable 3-10. (continued) + + 9 F0 Message Meaning + + OUTPUT FILE WRITE ERROR + + MOutput files cannot be written properly; +X Mmost likely cause is a full disk, erase and +X retry. + + + CANNOT CLOSE FILE + + MOutput file cannot be closed; check to see +X if disk is write protected. + 9 K0 + + +W3.7 A Sample Session + + MT&She following sample session shows interaction with the +XMassembler and debugger in the development of a simple assembly- +XMlanguage program. The arrow represents a carriage return keystroke. +X + + 9 d0 A>WASM SORT &SAssemble SORT.ASM + +CP/M ASSEMBLER - VER 1.0 + +0015C Next free address +003H USE FACTOR Percent of table used 00 to ff (hexadecimal) +END OF ASSEMBLY + +A>WDIR SORT.* + +&SSORT ASM Source file +SORT BAK Back-up from last edit +SORT PRN Print file (contains tab characters) +SORT HEX Machine code file + +A>WTYPE SORT.PRN +&S Source line + + ; SORT PROGRAM IN CP/M ASSEMBLY LANGUAGE + ; START AT THE BEGINNING OF THE TRANSIENT + PROGRAM AREA + +Machine code location +0100 ORG 100H + +Generated machine code +0100 214601 SORT: LXI H,SW ;ADDRESS SWITCH TOGGLE +0103 3601 MVI M,1 ;SET TO 1 FOR FIRST ITERATION +0105 214701 LXI H,I ;ADDRESS INDEX +0108 3600 MVI M,0 ;I=0 + + + 3-23 + + + + + +CP/M Operating System Manual 3.7 A Sample Session + + + ; + ; COMPARE I WITH ARRAY SIZE +010A 7E COMPL: MOV A,M ;A REGISTER = I +010B FE09 CPI N-1 ;CY SET IF I<(N-1) +010D D21901 JNC CONT ;CONTINUE IF I<=(N-2) + ; + ; END OF ONE PASS THROUGH DATA +0110 214601 LXI H,SW ;CHECK FOR ZERO SWITCHES +0113 7EB7C200001 MOV A, M! ORA A! JNZ SORT ;END OF SORT IF SW=0 + ; +0118 FF RST 7 ;GO TO THE DEBUGGER INSTEAD OF REB + ; + ; CONTINUE THIS PASS +Truncated ; ADDRESSING I, SO LOAD AV(I) INTO REGISTERS +0119 + 5F16002148CONT: MOV E, A! MVI D, 0! LXI H, AV! DAD D! DAD D +0121 4E792346 MOV C, M! MOV A, C! INX H! MOV B, M + ; LOW ORDER BYTE IN A AND C, HIGH ORDER BYTE IN B + ; + ; MOV H AND L TO ADDRESS AV(I+1) +0125 23 INX H + ; + ; COMPARE VALUE WITH REGS CONTAINING AV (I) +0126 965778239E SUB M! MOV D, A! MOV A, B! INX H! SBB M ;SUBTRACT + ; + ; BORROW SET IF AV(I+1)>AV(I) +012B DA3F01 JC INCI ;SKIP IF IN PROPER ORDER + ; + ; CHECK FOR EQUAL VALUES +012E B2CA3F01 ORA D! JZ INCI ;SKIP IF AV(I) = AV(I+1) +0132 56702B5E MOV D, M! MOV M, B! DCX H! MOV E, M +0136 712B722B73 MOV M, C! DCX H! MOV M, D! DCX H! MOV M, E + ; + ; INCREMENT SWITCH COUNT +013B 21460134 LXI H,SW! INR M + ; + ; INCREMENT I +013F 21470134C3INCI:LXI H,I! INR M! JMP COMP + ; + ; DATA DEFINITION SECTION +0146 00 SW: DB 0 ;RESERVE SPACE FOR SWITCH COUNT +0147 I: DS 1 ;SPACE FOR INDEX +0148 050064001EAV: DW 5, 100, 30, 50, 20, 7, 1000, 300, 100, -32767 +000A = N EQU($-AV)/2 ;COMPUTE N INSTEAD OF PRE +015C END +A>WTYPE SORT.HEX &SEquate value + +:10010000214601360121470136007EFE09D2190140 +:100110002146017EB7C20001FF5F16002148011988 Machine code in +:10012000194E79234623965778239EDA3F01B2CAA7 HEX format + +:100130003F0156702B5E712B722B732146013421C7 +:07014000470134C30A01006E Machine code in +:10014800050064001E00320014000700E8032C01BB HEX format +:0401580064000180BE +:0000000000 + + 3-24 + + + + + +CP/M Operating System Manual 3.7 A Sample Session + + +A>WDDT SORT.HEX &SStart debug run + +16K DDT VER 1.0 +NEXT PC +015C 0000 Default address (no address on END statement) +-XP + +P=0000 100 Change PC to 100 + +-UFFFF Untrace for 65535 steps + Abort with rubout +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 LXI H,0146*0100 +-T10 Trace 10U16D steps + +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0100 LXI H, 0146 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M, 01 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H, 0147 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M, 00 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=010A MOV A, M +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010B CPI 09 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010D JNC 0119 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0110 LXI H, 0146 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0113 MOV A, M +C1Z0M1E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0114 ORA A +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0115 JNZ 0100 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0100 LXI H, 0146 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M, 01 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H, 0147 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M, 00 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=010A MOV A, M*010B +-A10D Stopped at 10BH + +010D JC 119 Change to a jump on carry +0110 + +-XP + +P=010B 100 Reset program counter back to beginning of program + +-T10 Trace execution for 10H steps + + Altered instruction +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0100 LXI H,0146 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M,01 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H,0147 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M,00 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010A MOV A,M +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010B CPI 09 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010D JC 0119 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0119 MOV E,A +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=011A MVI D,00 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=011C LXI H,0148 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=011F DAD D +C0Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=0120 DAD D +C0Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=0121 MOV C,M + + + 3-25 + + + + + +CP/M Operating System Manual 3.7 A Sample Session + + +C0Z0M1E0I0 A=00 B=0005 D=0000 H=0148 S=0100 P=0122 MOV A,C +C0Z0M1E0I0 A=05 B=0005 D=0000 H=0148 S=0100 P=0123 INX H +C0Z0M1E0I0 A=05 B=0005 D=0000 H=0149 S=0100 P=0124 MOV B,M*0125 +-L100 Automatic breakpoint + + 0100 LXI H,0146 + 0103 MVI M,01 + 0105 LXI H,0147 + 0108 MVI M,00 + 010A MOV A,M List some code + 010B CPI 09 from 100H + 010D JC 0119 + 0110 LXI H,0146 + 0113 MOV A,M + 0114 ORA A + 0115 JNZ 0100 + -L + + 0118 RST 07 + 0119 MOV E,A List more + 011A MVI D,00 + 011C LXI H,0148 +-Abort list with rubout +-G,11B Start program from current PC (0125H) + and run in real time to 11BH + + + +*0127 Stopped with an external interrupt 7 from front panel +-T4 (program was looping indefinitely) + Look at looping program in trace mode + +C0Z0M0E0I0 A=38 B=0064 D=0006 H=0156 S=0100 P=0127 MOV D,A +C0Z0M0E0I0 A=38 B=0064 D=3806 H=0156 S=0100 P=0128 MOV A,B +C0Z0M0E0I0 A=00 B=0064 D=3806 H=0156 S=0100 P=0129 INX H +C0Z0M0E0I0 A=00 B=0064 D=3806 H=0157 S=0100 P=012A SBB M*012B +-D148 + Data are sorted, but program does not stop. +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D.,........ + +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-G0 Return to CP/M + +A>WDDT SORT.HEX &SReload the memory image + +16K DDT VER 1.0 +NEXT PC +015C 0000 +-XP + +P=0000 100 Set PC to beginning of program + +-L10D List bad OPCODE + + + 3-26 + + + + + +CP/M Operating System Manual 3.7 A Sample Session + + + + 010D JNC 0119 + 0110 LXI H,0146 +-Abort list with rubout +-A10D Assemble new OPCODE + +010D JC 119 + +0110 + +-L100 List starting section of program + + 0100 LXI H,0146 + 0103 MVI M,01 + 0105 LXI H,0147 + 0108 MVI M,00 +-Abort list with rubout +-A103 Change switch initialization to 00 + +0103 MVI M,0 + +0105 + +-^C Return to CP/M with CTRL-C (G0 works as well) + +SAVE 1 SORT.COM Save 1 page (256 bytes, from 100H to 1ffH) on + disk in case there is need to reload later +A>WDDT SORT.COM &SRestart DDT with saved memory image + +16K DDT VER 1.0 +NEXT PC +0200 0100 COM file always starts with address 100H +-G Run the program from PC=100H + +*0118 Programmed stop (RST 7) encountered +-D148 + + Data properly sorted +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D......... + +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ +0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-G0 Return to CP/M + +A>WED SORT.ASM &SMake changes to original program + +*N,0^Z0TT Find next ,0 + MVI M,0 ;I = 0 + +*- Up one line in text + LXI H,I ;ADDRESS INDEX + + + + + 3-27 + + + + + +CP/M Operating System Manual 3.7 A Sample Session + + +*- Up another line + MVI M,1 ;SET TO 1 FOR FIRST ITERATION + +*KT Kill line and type next line + LXI H,I ;ADDRESS INDEX + +*I Insert new line + MVI M,0 ;ZERO SW + +*T + LXI H,I ;ADDRESS INDEX + +*NJNC^Z0T + JNC*T + CONT ;CONTINUE IF I<=(N-2) + +*-2DIC^Z0LT + JC CONT ;CONTINUE IF I<=(N-2) + +*E Source from disk A + HEX to disk A +A>WASM SORT.AAZ &SSkip PRN file + +CP/M ASSEMBLER - VER 1.0 + +015C Next address to assemble +003H USE FACTOR +END OF ASSEMBLY + +A>WDDT SORT.HEX &STest program changes + +16K DDT VER 1.0 +NEXT PC +015C 0000 +-G100 + +*0118 +-D148 + Data sorted +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D.......... +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-Abort with rubout + +-G0 Return to CP/M--program checks OK. + 9 K0 + +=End of Section 3 + + + + + + + + + 3-28 + + + + + + + + +W Section 4 + +W CP/M Dynamic Debugging Tool + + + +&SW4.1 Introduction + + MThe DDT program allows dynamic interactive testing and +XMdebugging of programs generated in the CP/M environment. Invoke the +Xdebugger with a command of one of the following forms: + + DDT + DDT filename.HEX + DDT filename.COM + +Mwhere filename is the name of the program to be loaded and tested. +XMIn both cases, the DDT program is brought into main memory in place +XMof the Console Command Processor (CCP) and resides directly below +XMthe Basic Disk Operating System (BDOS) portion of CP/M. Refer to +XMSection 5 for standard memory organization. The BDOS starting +XMaddress, located in the address field of the JMP instruction at +XMlocation 5H, is altered to reflect the reduced Transient Program +XArea (TPA) size. + + MThe second and third forms of the DDT command perform the same +XMactions as the first, except there is a subsequent automatic load of +XMthe specified HEX or COM file. The action is identical to the +Xfollowing sequence of commands: + + DDT + Ifilename.HEX or Ifilename.COM + R + +Mwhere the I and R commands set up and read the specified program to +XMtest. See the explanation of the I and R commands below for exact +Xdetails. + + Upon initiation, DDT prints a sign-on message in the form: + + DDT VER m.m + +where m.m is the revision number. + + MFollowing the sign-on message, DDT prompts you with the hyphen +XMcharacter, -, and waits for input commands from the console. You +XMcan type any of several single-character commands, followed by a +XMcarriage return to execute the command. Each line of input can be +Xline-edited using the following standard CP/M controls: + + + + + + + + + 4-1 + + + + + +CP/M Operating System Manual 4.1 Introduction + + +=WTable 4-1. Line-editing Controls + 9 F0 + Control Result + + rubout removes the last character typed + + CTRL-U removes the entire line, ready for retyping + + CTRL-C reboots system + 9 K0 + + MAny command can be up to 32 characters in length. An automatic +XMcarriage return is inserted as character 33, where the first +XMcharacter determines the command type. Table 4-2 describes DDT +Xcommands. + + +W Table 4-2. DDT Commands + + Command Result + Character + + 9 C0 A Menters assembly-language mnemonics with +X operands. + + D displays memory in hexadecimal and ASCII. + + F fills memory with constant data. + + G Mbegins execution with optional breakpoints. +X + I Msets up a standard input File Control +X Block. + + L lists memory using assembler mnemonics. + + M Mmoves a memory segment from source to +X destination. + + R reads a program for subsequent testing. + + S substitutes memory values. + + T traces program execution. + + U untraced program monitoring. + + X Mexamines and optionally alters the CPU +X state. + 9 K0 + +MThe command character, in some cases, is followed by zero, one, two, +XMor three hexadecimal values, which are separated by commas or single +XMblank characters. All DDT numeric output is in hexadecimal form. +XMThe commands are not execution until the carriage return is typed at +Xthe end of the command. + + + 4-2 + + + + +CP/M Operating System Manual 4.1 Introduction + + + MAt any point in the debug run, you can stop execution of DDT by +XMusing either a CTRL-C or G0 (jump to location 0000H) and save the +Xcurrent memory image by using a SAVE command of the form: + + SAVE n filename. COM + +Mwhere n is the number of pages (256 byte blocks) to be saved on +XMdisk. The number of blocks is determined by taking the high-order +XMbyte of the address in the TPA and converting this number to +XMdecimal. For example, if the highest address in the TPA is 134H, +XMthe number of pages is 12H or 18 in decimal. You could type a CTRL- +XC during the debug run, returning to the CCP level, followed by + + SAVE 18 X.COM + +MThe memory image is saved as X.COM on the disk and can be directly +XMexecuted by typing the name X. If further testing is required, the +Xmemory image can be recalled by typing + + DDT X.COM + +Mwhich reloads the previously saved program from location 100H +XMthrough page 18, 23FFH. The CPU state is not a part of the COM +XMfile; thus, the program must be restarted from the beginning to test +Xit properly. + + +W4.2 DDT Commands + + MThe individual commands are detailed below. In each case, the +XMoperator must wait for the hyphen prompt character before entering +XMthe command. If control is passed to a program under test, and the +XMprogram has not reached a breakpoint, control can be returned to DDT +XMby executing a RST 7 from the front panel. In the explanation of +XMeach command, the command letter is shown in some cases with numbers +XMseparated by commas, the the numbers are represented by lower-case +XMletters. These numbers are always assumed to be in a hexadecimal +XMradix and from one to four digits in length. Longer numbers are +Xautomatically truncated on the right. + + MMany of the commands operate upon a CPU state that corresponds +XMto the program under test. The CPU state holds the registers of the +XMprogram being debugged and initially contains zeros for all +XMregisters and flags except for the program counter, P, and stack +XMpointer, S, which default to 100H. The program counter is +XMsubsequently set to the starting address given in the last record of +XMa HEX file if a file of this form is loaded, see the I and R +Xcommands. + + +W4.2.1 The A (Assembly) Command + + MDDT allows in-line assembly language to be inserted into the +Xcurrent memory image using the A command, which takes the form: + + + + 4-3 + + + + + +CP/M Operating System Manual 4.2 DDT Commands + + + As + +Mwhere s is the hexadecimal starting address for the in-line +XMassembly. DDT prompts the console with the address of the next +XMinstruction to fill and reads the console, looking for assembly- +XMlanguage mnemonics followed by register references and operands in +XMabsolute hexadecimal form. See the EIntel 8080 Assembly LanguageR +XMReference CardR for a list of mnemonics. Each successive load +XMaddress is printed before reading the console. The A command +Xterminates when the first empty line is input from the console. + + MUpon completion of assembly language input, you can review the +Xmemory segment using the DDT disassembler (see the L command). + + MNote that the assembler/disassembler portion of DDT can be +XMoverlaid by the transient program being tested, in which case the +XMDDT program responds with an error condition when the A and L +Xcommands are used. + + +W4.2.2 The D (Display) Command + + MThe D command allows you to view the contents of memory in +Xhexadecimal and ASCII formats. The D command takes the forms: + + D + Ds + Ds,f + + MIn the first form, memory is displayed from the current display +XMaddress, initially 100H, and continues for 16 display lines. Each +Xdisplay line takes the followng form: + +aaaa bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb cccccccccccccccc + +Mwhere aaaa is the display address in hexadecimal and bb represents +XMdata present in memory starting at aaaa. The ASCII characters +XMstarting at aaaa are to the right (represented by the sequence of +XMcharacter c) where nongraphic characters are printed as a period. +XMYou should note that both upper- and lower-case alphabetics are +XMdisplayed, and will appear as upper-case symbols on a console device +XMthat supports only upper-case. Each display line gives the values +XMof 16 bytes of data, with the first line truncated so that the next +Xline begins at an address that is a multiple of 16. + + MThe second form of the D command is similar to the first, +Xexcept that the display address is first set to address s. + + MThe third form causes the display to continue from address s +XMthrough address f. In all cases, the display address is set to the +XMfirst address not displayed in this command, so that a continuing +XMdisplay can be accomplished by issuing successive D commands with no +Xexplicit addresses. + + + + + 4-4 + + + + + +CP/M Operating System Manual 4.2 DDT Commands + + + MExcessively long displays can be aborted by pressing the return +Xkey. + + +W4.2.3 The F (Fill) Command + + The F command takes the form: + + Fs,f,c, + +Mwhere s is the starting address, f is the final address, and c is a +XMhexadecimal byte constant. DDT stores the constant c at address s, +XMincrements the value of s and test against f. If s exceeds f, the +XMoperation terminates, otherwise the operation is repeated. Thus, +XMthe fill command can be used to set a memory block to a specific +Xconstant value. + + +W4.2.4 The G (Go) Command + + MA program is executed using the G command, with up to two +Xoptional breakpoint addresses. The G command takes the forms: + + + G + Gs + Gs,b + Gs,b,c + G,b + G,b,c + + + MThe first form executes the program at the current value of the +XMprogram counter in the current machine state, with no breakpoints +XMset. The only way to regain control in DDT is through a RST 7 +XMexecution. The current program counter can be viewed by typing an X +Xor XP command. + + MThe second form is similar to the first, except that the +XMprogram counter in the current machine state is set to address s +Xbefore execution begins. + + MThe third form is the same as the second, except that program +XMexecution stops when address b is encountered (b must be in the area +XMof the program under test). The instruction at location b is not +Xexecuted when the breakpoint is encountered. + + MThe fourth form is identical to the third, except that two +XMbreakpoints are specified, one at b and the other at c. +XMEncountering either breakpoint causes execution to stop, and both +XMbreakpoints are cleared. The last two forms take the program +XMcounter from the current machine state and set one and two +Xbreakpoints, respectively. + + + + + 4-5 + + + + + +CP/M Operating System Manual 4.2 DDT Commands + + + MExecution continues from the starting address in real-time to +XMthe next breakpoint. There is no intervention between the starting +XMaddress and the break address by DDT. If the program under test +XMdoes not reach a breakpoint, control cannot return to DDT without +XMexecuting a RST 7 instruction. Upon encountering a breakpoint, DDT +Xstops execution and types + + *d + +Mwhere d is the stop address. The machine state can be examined at +XMthis point using the X (Examine) command. You must specify +XMbreakpoints that differ from the program counter address at the +XMbeginning of the G command. Thus, if the current program counter is +X1234H, then the following commands: + + G,1234 + G400,400 + +Mboth produce an immediate breakpoint without executing any +Xinstructions. + + +W4.2.5 The I (Input) Command + + MThe I command allows you to insert a filename into the default +XMFile Control Block (FCB) at 5CH. The FCB created by CP/M for +XMtransient programs is placed at this location (see Section 5). The +XMdefault FCB can be used by the program under test as if it had been +XMpassed by the CP/M Console Processor. Note that this filename is +XMalso used by DDT for reading additional HEX and COM files. The I +Xcommand takes the forms: + + Ifilename + Ifilename.typ + + MIf the second form is used and the filetype is either HEX or +XMCOM, subsequent R commands can be used to read the pure binary or +Xhex format machine code. Section 4.2.8 gives further details. + + +W4.2.6 The L (List) Command + + MThe L command is used to list assembly-language mnemonics in a +Xparticular program region. The L command takes the forms: + + L + Ls + Ls,f + + MThe first form lists twelve lines of disassembled machine code +XMfrom the current list address. The second form sets the list +XMaddress to s and then lists twelve lines of code. The last form +XMlists disassembled code from s through address f. In all three +XMcases, the list address is set to the next unlisted location in +XMpreparation for a subsequent L command. Upon encountering an + + + 4-M6 + + + +X + +CP/M Operating System Manual 4.2 DDT Commands + + +Mexecution breakpoint, the list address is set to the current value +XMof the program counter (G and T commands). Again, long typeouts can +Xbe aborted by pressing RETURN during the list process. + + +W4.2.7 The M (Move) Command + + MThe M command allows block movement of program or data areas +XMfrom one location to another in memory. The M command takes the +Xform: + + Ms,f,d + +Mwhere s is the start address of the move, f is the final address, +XMand d is the destination address. Data is first removed from s to +XMd, and both addresses are incremented. If s exceeds f, the move +Xoperation stops; otherwise, the move operation is repeated. + + +W4.2.8 The R (Read) Command + + MThe R command is used in conjunction with the I command to read +XMCOM and HEX files from the disk into the transient program area in +Xpreparation for the debug run. The R command takes the forms: + + R + RB + +Mwhere b is an optional bias address that is added to each program or +XMdata address as it is loaded. The load operation must not overwrite +XMany of the system parameters from 000H through 0FFH (that is, the +XMfirst page of memory). If b is omitted, then b=0000 is assumed. +XMThe R command requires a previous I command, specifying the name of +XMa HEX or COM file. The load address for each record is obtained +XMfrom each individual HEX record, while an assumed load address of +XM100H is used for COM files. Note that any number of R commands can +XMbe issued following the I command to reread the program under test, +XMassuming the tested program does not destroy the default area at +XM5CH. Any file specified with the filetype COM is assumed to contain +XMmachine code in pure binary form (created with the LOAD or SAVE +XMcommand), and all others are assumed to contain machine code in +XIntel hex format (produced, for example, with the ASM command). + + Recall that the command, + + DDT filename.filetype + +which initiates the DDT program, equals to the following commands: + + DDT + -Ifilename.filetype + -R + + + + + + 4-7 + + + + + +CP/M Operating System Manual 4.2 DDT Commands + + + + MWhenever the R command is issued, DDT responds with either the +XMerror indicator ? (file cannot be opened, or a checksum error +XMoccurred in a HEX file) or with a load message. The load message +Xtakes the form: + + NEXT PC + nnnn pppp + +Mwhere nnnn is the next address following the loaded program and pppp +XMis the assumed program counter (100H for COM files, or taken from +Xthe last record if a HEX file is specified). + + +W4.2.9 The S (Set) Command + + MThe S command allows memory locations to be examined and +Xoptionally altered. The S command takes the form: + + Ss + +Mwhere s is the hexadecimal starting address for examination and +XMalteration of memory. DDT responds with a numeric prompt, giving +XMthe memory location, along with the data currently held in memory. +XMIf you type a carriage return, the data is not altered. If a byte +XMvalue is typed, the value is stored at the prompted address. In +XMeither case, DDT continues to prompt with successive addresses and +XMvalues until you type either a period or an invalid input value is +Xdetected. + + +W4.2.10 The T (Trace) Command + + MThe T command allows selective tracing of program execution for +X1 to 65535 program steps. The T command takes the forms: + + T + Tn + + MIn the first form, the CPU state is displayed and the next +XMprogram step is executed. The program terminates immediately, with +Xthe termination address displayed as + + *hhhh + +Mwhere hhhh is the next address to execute. The display address +XM(used in the D command) is set to the value of H and L, and the list +XMaddress (used in the L command) is set to hhhh. The CPU state at +Xprogram termination can then be examined using the X command. + + MThe second form of the T command is similar to the first, +XMexcept that execution is traced for n steps (n is a hexadecimal +XMvalue) before a program breakpoint occurs. A breakpoint can be +XMforced in the trace mode by typing a rubout character. The CPU +XMstate is displayed before each program step is taken in trace mode. +XMThe format of the display is the same as described in the X command. +X + + 4-8 + + + + +CP/M Operating System Manual 4.2 DDT Commands + + + MYou should note that program tracing is discontinued at the +XMCP/M interface and resumes after return from CP/M to the program +XMunder test. Thus, CP/M functions that access I/O devices, such as +XMthe disk drive, run in real-time, avoiding I/O timing problems. +XMPrograms running in trace mode execute approximately 500 times +XMslower than real-time because DDT gets control after each user +XMinstruction is executed. Interrupt processing routines can be +XMtraced, but commands that use the breakpoint facility (G, T, and U) +XMaccomplish the break using an RST 7 instruction, which means that +XMthe tested program cannot use this interrupt location. Further, the +XMtrace mode always runs the tested program with interrupts enabled, +XMwhich may cause problems if asynchronous interrupts are received +Xduring tracing. + + MTo get control back to DDT during trace, press RETURN rather +XMthan executing an RST 7. This ensures that the trace for current +Xinstruction is completed before interruption. + + +W4.2.11 The U (Untrace) Command + + MThe U command is identical to the T command, except that +XMintermediate program steps are not displayed. The untrace mode +XMallows from 1 to 65535, (0FFFFH) steps to be executed in monitored +XMmode and is used principally to retain control of an executing +XMprogram while it reaches steady state conditions. All conditions of +Xthe T command apply to the U command. + + +W4.2.12 The X (Examine) Command + + MThe X command allows selective display and alteration of the +XMcurrent CPU state for the program under test. The X command takes +Xthe forms: + + X + Xr + +Mwhere r is one of the 8080 CPU registers listed in the following +Xtable. + + +W Table 4-3. CPU Registers + + Register Meaning Value + + C Carry flag (0/1) + Z Zero flag (0/1) + M Minus flag (0/1) + E Even parity flag (0/1) + I Interdigit carry (0/1) + A Accumulator (0-FF) + B BC register pair (0-FFFF) + D DE register pair (0-FFFF) + + + + 4-9 + + + + + +CP/M Operating System Manual 4.2 DDT Commands + + +W Table 4-3. (continued) + + Register Meaning Value + + H HL register pair (0-FFFF) + S Stack pointer (0-FFFF) + P Program counter (0-FFFF) + + +MIn the first case, the CPU register state is displayed in the +Xformat: + + CfZfMfEflf A=bb B=dddd D=dddd H=dddd S=dddd P=dddd inst + +Mwhere f is a 0 or 1 flag value, bb is a byte value, and dddd is a +XMdouble-byte quantity corresponding to the register pair. The inst +XMfield contains the disassembled instruction, that occurs at the +Xlocation addressed by the CPU state's program counter. + + MThe second form allows display and optional alteration of +XMregister values, where r is one of the registers given above (C, Z, +XMM, E, I, A, B, D, H, S, or P). In each case, the flag or register +XMvalue is first displayed at the console. The DDT program then +XMaccepts input from the console. If a carriage return is typed, the +XMflag or register value is not altered. If a value in the proper +XMrange is typed, the flag or register value is altered. You should +XMnote that BC, DE, and HL are displayed as register pairs. Thus, you +XMmust type the entire register pair when B, C, or the BC pair is +Xaltered. + + +W4.3 Implementation Notes + + MThe organization of DDT allows certain nonessential portions to +XMbe overlaid to gain a larger transient program area for debugging +XMlarge programs. The DDT program consists of two parts: the DDT +XMnucleus and the assembler/disassembler module. The DDT nucleus is +XMloaded over the CCP and, although loaded with the DDT nucleus, the +XMassembler/disassembler is overlayable unless used to assemble or +Xdisassemble. + + MIn particular, the BDOS address at location 6H (address field +XMof the JMP instruction at location 5H) is modified by DDT to address +XMthe base location of the DDT nucleus, which, in turn, contains a JMP +XMinstruction to the BDOS. Thus, programs that use this address field +XMto size memory see the logical end of memory at the base of the DDT +Xnucleus rather than the base of the BDOS. + + MThe assembler/disassembler module resides directly below the +XMDDT nucleus in the transient program area. If the A, L, T, or X +XMcommands are used during the debugging process, the DDT program +XMagain alters the address field at 6H to include this module, further +XMreducing the logical end of memory. If a program loads beyond the +XMbeginning of the assembler/disassembler module, the A and L commands +XMare lost (their use produces a ? in response) and the trace and + + + 4-M10 + + + +X + +CP/M Operating System Manual 4.3 Implementation Notes + + +Mdisplay (T and X) commands list the inst field of the display in +Xhexadecimal, rather than as a decoded instruction. + + +W4.4 A Sample Program + + MThe following example shows an edit, assemble, and debug for a +XMsimple program that reads a set of data values and determines the +XMlargest value in the set. The largest value is taken from the +Xvector and stored into LARGE at the termination of the program. + 9 U0 + +A>WED SCAN.ASM &SCreate source program; + " " represents carriage return. +*I + ORG 1-00H ;START OF TRANSIENT + ;AREA + MVI B, LEN ;LENGTH OF VECTOR TO SCAN + MVI C, 0 ;LARGER_RST VALUE SO FAR +LOOP LXI H, VECT ;BASE OF VECTOR +LOOP: MOV A, M ;GET VALUE + SUB C ;LARGER VALUE IN C? + JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND +; NEW LARGEST VALUE, STORE IT TO C + MOV C, A +NFOUND INX H ;TO NEXT ELEMENT + DCR B ;MORE TO SCAN? + JNZ LOOP ;FOR ANOTHER +; +; END OF SCAN, STORE C + MOV A, C ;GET LARGEST VALUE + STA LARGE + JMP 0 ;REBOOT +; +; TEST DATA +VECT: DB 2,0,4,3,5,6,1,5 +LEN EQU $-VECT ;LENGTH +LARGE: DS 1 ;LARGEST VALUE ON EXIT + END + + + + + + + + + + + + + + + + + + 4-11 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +^-Z +*B0P + ORG 100H ;START OF TRANSIENT AREA + MVI B,LEN ;LENGTH OF VECTOR TO SCAN + MVI C,0 ;LARGEST VALUE SO FAR + LXI H,VECT ;BASE OF VECTOR +LOOP: MOV A,M ;GET VALUE + SUB C ;LARGER VALUE IN C? + JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND +; NEW LARGEST VALUE, STORE IT TO C + MOV C,A +NFOUND: INX H ;TO NEXT ELEMENT + DCR B ;MORE TO SCAN? + JNZ LOOP ;FOR ANOTHER +; END OF SCAN, STORE C + MOV A,C ;GET LARGEST VALUE + STA LARGE + JMP 0 ;REBOOT +; +; TEST DATA + +VECT: DB 2,0,4,3,5,6,1,5 +LEN EQU $-VECT ;LENGTH +LARGE: DS 1 ;LARGEST VALUE ON EXIT + END +*E <--End of edit + +A>WASM SCAN &SStart Assembler + +CP/M ASSEMBLER - VER 1.0 + +0122 +002H USE FACTOR +END OF ASSEMBLY Assembly complete; lock at program listing + +A>WTYPE SCAN.PRN +&S Code address Source program + 0100 ORG 100H ;START OF TRANSIENT AREA + 0100 0608 MVI B,LEN ;LENGTH OF VECTOR TO SCAN + 0102 0E00 Machine code MVI C,0 ;LARGEST VALUE SO FAR + 0104 211901 LXI H,VECT. ;BASE OF VECTOR + 0107 7E LOOP: MOV A,M ;GET VALUE + 0108 91 SUB C ;LARGER VALUE IN C? + 0109 D20D01 JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND + ; NEW LARGEST VALUE, STORE IT TO C + 010C 4F MOV C,A + + + + + + + + + + 4-12 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + + 010D 23 NFOUND: INX H ;TO NEXT ELEMENT + 010E 05 DCR B ;MORE TO SCAN? + 010F C20701 JNZ LOOP ;FOR ANOTHER + ; + ; END OF SCAN, STORE C + 0112 79 MOV A,C ;GET LARGEST VALUE + 0113 322101 STA LARGE + + 0116 C30000 JMP 0 ;REBOOT + Code--data listing; + truncated ; TEST DATA + 0119 0200040305 VECT: DB 2,0,4,3,5,6,1,5 + 0008 = Value of LEN EQU $-VECT ;LENGTH + 0121 equate LARGE: DS 1 ;LARGEST VALUE ON EXIT + 0122 END + + +A>WDDT SCAN.HEX &SStart debugger using hex format machine code + +DDT VER 1.0 +NEXT PC Next instruction +0121 0000 to execute at +-X Last load address + 1 PC=0 + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0000 OUT 7F +-XP Examine registers before debug run + +P=0000 100 Change PC to 100 + +-X Look at registers again + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +-L100 + PC changed Next instruction + to execute at PC=100 + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C Disassembled machine + 0109 JNC 010D code at 100H + 010C MOV C,A (see source listing + 010D INX H for comparison) + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C +-L + + + + + + + + + + + 4-13 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + + 0113 STA 0121 + 0116 JMP 0000 + 0119 STAX B + 011A NOP A little more machine + 011B INR B code. Note that pro- + 011C INX B gram ends at location + 011D DCR B 116 with a JMP to + 011E MVI B,01 0000. Remainder of + 0120 DCR B listing is assembly of + 0121 LXI D,2200 data. + 0124 LXI H,0200 +-A116 Enter in-line assembly mode to change the JMP to 0000 into a RST 7, + which will cause the program under test to return to DDT if 116H is + ever executed. +0116 RST 7 + +0117 (Single carriage return stops assemble mode) + +-L113 List code at 113H to check that RST 7 was properly inserted + + 0113 STA 0121 + 0116 RST 07 in place of JMP + 0117 NOP + 0118 NOP + 0119 STAX B + 011A NOP + 011B INR B + 011C INX B +- + +-X Look at registers + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +-T + Execute Program for one stop. Initial CPU state, before is executed + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08*0102 + Automatic breakpoint + + Trace one step again (note O8H in B) +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0102 MVI C,00*0104 +-T + Trace again (Register C is cleared) +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0104 LXI H,0119*0107 +-T3 Trace three steps +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z0M0E0I0 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JNC 010D*010D +-D119 + Display memory starting at 119H. Automatic breakpoint at 10DH + +0119 02 00 04 03 05 06 01.Program data Lower-case x +0120 05 11 00 22 21 00 02 7E EB 77 13 23 EB 0B 78 B1 ..."!.. . W .#..X. +0130 C2 27 01 C3 03 29 00 00 00 00 00 00 00 00 00 00 ...' ...)......... +0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. + + + 4-14 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Data are displayed +0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 in ASCI with a "." +0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 in the position of +0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 nongraphic........ +01A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 characters........ +01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +01C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +-X + Current CPU state +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +-T5 + Trace 5 steps from current CPU state +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0800 D=0000 H=011A S=0100 P=010E DCR B +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=010F JNZ 0107 +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0700 D=0000 H=011A S=0100 P=0108 SUB C*0109 + +U5 + Automatic breakpoint + Trace without listing intermediate states +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=0109 JNC 010D*0108 +-X + CPU state at end of U5 +C0Z0M0E1I1 A=04 B=0600 D=0000 H=011B S=0100 P=0108 SUB C +-G Run program from current PC until completion (in real-time) + +*0116 breakpoint at 116H, caused by executing RST 7 in machine code. + +-X + CPU state at end of program +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0116 RST 07 +-XP + Examine and change program counter + +P=0116 100 + +-X + +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0100 MVI B,08 +-T10 + + First data element + Current largest value + Subtract for comparison C + Trace 10 (hexadecimal) steps +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0121 S=0100 P=0100 MVI B,08 +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0102 MVI C,00 +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0121 S=0100 P=0104 LXI H,0119 +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z1M0E1I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JNC 010D +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0800 D=0000 H=011A S=0100 P=010E DCR B + + + 4-15 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=010F JNZ 0107 +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0700 D=0000 H=011A S=0100 P=0108 SUB C +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=0109 JNC 010D +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=010D INX H +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011B S=0100 P=010E DCR B +C0Z0M0E1I1 A=00 B=0600 D=0000 H=011B S=0100 P=010F JNZ 0107 +C0Z0M0E1I1 A=00 B=0600 D=0000 H=011B S=0100 P=0107 MOV A,M*0108 +-A109 + Insert a "hot patch" into Program should have moved the + the machine code value from A into C since A>C. +0109 JC 10D to change the Since this code was not executed, + JNC to JC it appears that the JNC should +010C have been a JC instruction + + Stop DDT so that a version of +-G0 the patched program can be saved + +A>WSAVE 1 SCAN.COM &SProgram resides on first + page, so save 1 page. +A>WDDT SCAN.COM +&S Restart DDT with the save memory +DDT VER 1.0 image to continue testing +NEXT PC +0200 0100 + +-L100 List some code + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C + 0109 JC 010D Previous patch is present in X.COM + 010C MOV C,A + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C + -XP + +P=0100 + +-T10 + Trace to see how patched version operates Data is moved from A to C +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0102 MVI C,00 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0104 LXI H,0119 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z0M0E0I0 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JC 010D +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010C MOV C,A +C0Z0M0E0I1 A=02 B=0802 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0802 D=0000 H=011A S=0100 P=010E DCR B +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=010F JNZ 0107 + + + 4-16 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0702 D=0000 H=011A S=0100 P=0108 SUB C +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=0109 JC 010D +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=010D INX H +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011B S=0100 P=010E DCR B +C1Z0M0E1I1 A=FE B=0602 D=0000 H=011B S=0100 P=010F JNZ 0107*0107 +-X Breakpoint after 16 steps + +C1Z0M0E1I1 A=FE B=0602 D=0000 H=011B S=0100 P=0107 MOV A,M +-G,108 Run from current PC and breakpoint at 108H + +*0108 +-X + Next data item +C1Z0M0E1I1 A=04 B=0602 D=0000 H=011B S=0100 P=0108 SUB C +-T + Single step for a few cycles +C1Z0M0E1I1 A=04 B=0602 D=0000 H=011B S=0100 P=0108 SUB C*0109 +-T + +C0Z0M0E0I1 A=02 B=0602 D=0000 H=011B S=0100 P=0109 JC 010D*010C +-X + +C0Z0M0E0I1 A=02 B=0602 D=0000 H=011B S=0100 P=010C MOV C,A +-G Run to completion + +*0116 +-X + +C0Z1M0E1I1 A=03 B=0003 D=0000 H=0121 S=0100 P=0116 RST 07 +-S121 Look at the value of "LARGE" + + 0121 03 Wrong value! + + 0122 00 + + 0123 22 + + 0124 21 + + 0125 00 + + 0126 02 + + 0127 7E _. End of the S command + +-L100 + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C + 0109 JC 010D + 010C MOV C,A + + + 4-17 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C +-L Review the code + + 0113 STA 0121 + 0116 RST 07 + 0117 NOP + 0118 NOP + 0119 STAX B + 011A NOP + 011B INR B + 011C INX B + 011D DCR B + 011E MVI B,01 + 0120 DCR B +-XP + +P=0116 100 Reset the PC + +-T + Single step, and watch data values +C0Z1M0E1I1 A=03 B=0003 D=0000 H=0121 S=0100 P=0100 MVI B,08*0102 +-T + +C0Z1M0E1I1 A=03 B=0803 D=0000 H=0121 S=0100 P=0102 MVI C,00*0104 +-T + Count set Largest set +C0Z1M0E1I1 A=03 B=0800 D=0000 H=0121 S=0100 P=0104 LXI H,0119*0107 +-T + Base address of data set +C0Z1M0E1I1 A=03 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M*0108 +-T + First data item brought to A +C0Z1M0E1I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C*0109 +-T + +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JC 010D*010C +-T + +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010C MOV C,A*010D +-T + First data item moved to C correctly +C0Z0M0E0I1 A=02 B=0802 D=0000 H=0119 S=0100 P=010D INX H*010E +-T + +C0Z0M0E0I1 A=02 B=0802 D=0000 H=011A S=0100 P=010E DCR B*010F +-T + +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=010F JNZ 0107*0107 +-T + +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=0107 MOV A,M*0108 +-T + + + 4-18 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + + Second data item brought to A +C0Z0M0E0I1 A=00 B=0702 D=0000 H=011A S=0100 P=0108 SUB C*0109 +-T + Subtract destroys data value that was loaded! +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=0109 JC 010D*010D +-T + +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=010D INX H*010E +-L100 + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C This should have been a CMP so that register A + 0109 JC 010D would not be destroyed. + 010C MOV C,A + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C + -A108 + +0108 CMP C Hot patch at 108H changes SUB to CMP + +0109 + +-G0 Stop DDT for SAVE + +A>WSAVE 1 SCAN.COM &SSave memory image + +A>WDDT SCAN.COM &SRestart DDT + +DDT VER 1.0 +NEXT PC +0200 0100 +-XP + +P=0100 + +-L116 + + 0116 RST 07 + 0117 NOP + 0118 NOP Look at code to see if it was properly loaded + 0119 STAX B (long typeout aborted with rubout) + 011A NOP + - + +-G,116 Run from 100H to completion + +*0116 +-XC Look at carry (accidental typo) +C1 +-X Look at CPU state + + + 4-19 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +C1Z1M0E1I1 A=06 B=0006 D=0000 H=0121 S=0100 P=0116 RST 07 +-S121 Look at "large"--it appears to be correct. + +0121 06 + +0122 00 + +0123 22 + +-G0 Stop DDT + +A>WED SCAN.ASM &SRe-edit the source program, and make both changes + +*NSUB +*0LT + CTRL-Z SUB C ;LARGER VALUE IN C? +*SSUB^|ZCMP^|Z0LT + CMP D ;LARGER VALUE IN C? +* + JNC NFOUND ;JUMP IF LARGER VALUE NOT FOUND +*SNC^|ZC^|Z0LT + JC NFOUND ;JUMP IF LARGER VALUE NOT FOUND +*E + Reassemble, selecting source from disk A +A>WASM SCAN.AAZ &S<--- Hex to disk A + Print to Z (selects no print file) +CP/M ASSEMBLER VER 1.0 + +0122 +002H USE FACTOR +END OF ASSEMBLY + +A>WDDT SCAN.HEX &SRerun debugger to check changes + +DDT VER 1.0 +NEXT PC +0121 0000 +-L116 + + 0116 JMP 0000 Check to ensure end is still at 116H + + 0119 STAX B + + 011A NOP + 011B INR B + + -(rubout) + +-G100,116 Go from beginning with breakpoint at end + +*0116 Breakpoint reached +-D121 Look at "LARGE" + Correct value computed +0121 06 00 22 21 00 02 7E EB 77 13 23 EB 0B 78 B1 .. '!... W .#..X. +0130 C2 27 01 C3 03 29 00 00 00 00 00 00 00 00 00 00 .'...)........ + + + 4-20 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .............. + +-(rubout) Aborts long typeout + +G0 Stop DDT, debug session complete. + 9 K0 + +=End of Section 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4-21 + + + + + + + + +=WSection 5 + +=&SWCP/M 2 System Interface + + +&S5.1 Introduction + + This chapter describes CP/M (release 2) system organization including the +structure of memory and system entry points. This section provides +the information you need to write programs that operate under CP/M and +that use the peripheral and disk I/O facilities of the system. + + CP/M is logically divided into four parts, called the Basic Input/Output +System (BIOS), the Basic Disk Operating System (BDOS), the Console Command +Processor (CCP), and the Transient Program Area (TPA). The BIOS is a +hardware-dependent module that defines the exact low level interface with a +particular computer system that is necessary for peripheral device I/O. +Although a standard BIOS is supplied by Digital Research, explicit +instructions are provided for field reconfiguration of the BIOS to match +nearly any hardware environment, see Section 6. + + The BIOS and BDOS are +logically combined into a single module with a common entry point and +referred to as the FDOS. The CCP is a distinct program that uses the FDOS to +provide a human-oriented interface with the information that is cataloged on +the back-up storage device. The TPA is an area of memory, +not used by the FDOS and CCP, where various nonresident operating +system commands and user programs are executed. The lower portion of memory +is reserved for system information and is detailed in later sections. Memory +organization of the CP/M system is shown in Figure 5-1. + + + + High + Memory FDOS (BDOS+BIOS) + FBASE: + + CCP + CBASE: + + TPA + TBASE: + + System Parameters + BOOT: + + +=WFigure 5-1. CP/M Memory Organization + + + + M&SThe exact memory addresses corresponding to BOOT, TBASE, CBASE, +XMand FBASE vary from version to version and are described fully in +XMSection 6. All standard CP/M versions assume BOOT=0000H, which is +XMthe base of random access memory. The machine code found at + + + 5-M1 + + + +X + +CP/M Operating System Manual 5.1 Introduction + + +Mlocation BOOT performs a system warm start, which loads and +XMinitializes the programs and variables necessary to return control +XMto the CCP. Thus, transient programs need only jump to location +XMBOOT to return control to CP/M at the command level. Further, the +XMstandard versions assume TBASE=BOOT+0100H, which is normally +XMlocation 0100H. The principal entry point to the FDOS is at +XMlocation BOOT+0005H (normally 0005H) where a jump to FBASE is found. +XMThe address field at BOOT+0006H (normally 0006H) contains the value +XMof FBASE and can be used to determine the size of available memory, +Xassuming that the CCP is being overlaid by a transient program. + + MTransient programs are loaded into the TPA and executed as +XMfollows. The operator communicates with the CCP by typing command +XMlines following each prompt. Each command line takes one of the +Xfollowing forms: + + command + command file1 + command file1 file2 + +Mwhere command is either a built-in function, such as DIR or TYPE, or +XMthe name of a transient command or program. If the command is a +XMbuilt-in function of CP/M, it is executed immediately. Otherwise, +XMthe CCP searches the currently addressed disk for a file by the name +X + command.COM + + MIf the file is found, it is assumed to be a memory image of a +XMprogram that executes in the TPA and thus implicity originates at +XMTBASE in memory. The CCP loads the COM file from the disk into +Xmemory starting at TBASE and can extend up to CBASE. + + MIf the command is followed by one or two file specifications, +XMthe CCP prepares one or two File Control Block (FCB) names in the +XMsystem parameter area. These optional FCBs are in the form +XMnecessary to access files through the FDOS and are described in +XSection 5.2. + + MThe transient program receives control from the CCP and begins +XMexecution, using the I/O facilities of the FDOS. The transient +XMprogram is called from the CCP. Thus, it can simply return to the +XMCCP upon completion of its processing, or can jump to BOOT to pass +XMcontrol back to CP/M. In the first case, the transient program must +XMnot use memory above CBASE, while in the latter case, memory up +Xthrough FBASE-1 can be used. + + MThe transient program can use the CP/M I/O facilities to +XMcommunicate with the operator's console and peripheral devices, +XMincluding the disk subsystem. The I/O system is accessed by passing +XMa function number and an information address to CP/M through the +XMFDOS entry point at BOOT+0005H. In the case of a disk read, for +XMexample, the transient program sends the number corresponding to a +XMdisk read, along with the address of an FCB to the CP/M FDOS. The +XMFDOS, in turn, performs the operation and returns with either a disk +XMread completion indication or an error number indicating that the + + + 5-M2 + + + +X + +CP/M Operating System Manual 5.1 Introduction + + +disk read was unsuccessful. + + +W5.2 Operating System Call Conventions + + MT&Shis section provides detailed information for performing +XMdirect operating system calls from user programs. Many of the +XMfunctions listed below, however, are accessed more simply through +XMthe I/O macro library provided with the MAC macro assembler and +XMlisted in the Digital Research manual entitled, EProgrammer'sR +XUtilities Guide for the CP/M Family of Operating Systems. + + MRCP/M facilities that are available for access by transient +XMprograms fall into two general categories: simple device I/O and +Xdisk file I/O. The simple device operations are + + o read a console character + o write a console character + o read a sequential character + o write a sequential character + o get or set I/O status + o print console buffer + o interrogate console ready + + The following FDOS operations perform disk I/O: + + o disk system reset + o drive selection + o file creation + o file close + o directory search + o file delete + o file rename + o random or sequential read + o random or sequential write + o interrogate available disks + o interrogate selected disk + o set DMA address + o set/reset file indicators. + + MAs mentioned above, access to the FDOS functions is +XMaccomplished by passing a function number and information address +XMthrough the primary point at location BOOT+0005H. In general, the +XMfunction number is passed in register C with the information address +XMin the double byte pair DE. Single byte values are returned in +XMregister A, with double byte values returned in HL, a zero value is +XMreturned when the function number is out of range. For reasons of +XMcompatibility, register A = L and register B = H upon return in all +XMcases. Note that the register passing conventions of CP/M agree +XMwith those of the Intel PL/M systems programming language. CP/M +Xfunctions and their numbers are listed below. + + + + + + + 5-3 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + O System Reset 19 Delete File + 1 Console Input 20 Read Sequential + 2 Console Output 21 Write Sequential + 3 Reader Input 22 Make File + 4 Punch Output 23 Rename File + 5 List Output 24 Return Login Vector + 6 Direct Console I/O 25 Return Current Disk + 7 Get I/O Byte 26 Set DMA Address + 8 Set I/O Byte 27 Get Addr(Alloc) + 9 Print String 28 Write Protect Disk + 10 Read Console Buffer 29 Get R/0 Vector + 11 Get Console Status 30 Set File Attributes + 12 Return Version Number 31 Get Addr(Disk Parms) + 13 Reset Disk System 32 Set/Get User Code + 14 Select Disk 33 Read Random + 15 Open File 34 Write Random + 16 Close File 35 Compute File Size + 17 Search for First 36 Set Random Record + 18 Search for Next 37 Reset Drive + 40 Write Random with Zero Fill + + + MFunctions 28 and 32 should be avoided in application programs +Xto maintain upward compatibility with CP/M. + + MUpon entry to a transient program, the CCP leaves the stack +XMpointer set to an eight-level stack area with the CCP return address +XMpushed onto the stack, leaving seven levels before overflow occurs. +XMAlthough this stack is usually not used by a transient program (most +XMtransients return to the CCP through a jump to location 0000H) it is +XMlarge enough to make CP/M system calls because the FDOS switches to +XMa local stack at system entry. For example, the assembly-language +XMprogram segment below reads characters continuously until an +XMasterisk is encountered, at which time control returns to the CCP, +Xassuming a standard CP/M system with BOOT = 0000H. + + + BDOS EQU 0005H ;STANDARD CP/M ENTRY + CONIN EQU 1 ;CONSOLE INPUT FUNCTION + ; + ORG 0100H ;BASE OF TPA + NEXTC: MVI C,CONIN ;READ NEXT CHARACTER + CALL BDOS ;RETURN CHARACTER IN + CPI '*' ;END OF PROCESSING? + JNZ NEXTC ;LOOP IF NOT + RET ;RETURN TO CCP + END + + + MCP/M implements a named file structure on each disk, providing +XMa logical organization that allows any particular file to contain +XMany number of records from completely empty to the full capacity of +XMthe drive. Each drive is logically distinct with a disk directory +XMand file data area. The disk filenames are in three parts: the +XMdrive select code, the filename (consisting of one to eight nonblank + + + 5-M4 + + + +X + +CP/M Operating System Manual 5.2 Call Conventions + + +Mcharacters), and the filetype (consisting of zero to three nonblank +XMcharacters). The filetype names the generic category of a +XMparticular file, while the filename distinguishes individual files +XMin each category. The filetypes listed in Table 5-1 name a few +XMgeneric categories that have been established, although they are +Xsomewhat arbitrary. + + +W Table 5-1. CP/M Filetypes + + &S Filetype Meaning + + ASM Assembler Source + PRN Printer Listing + HEX Hex Machine Code + BAS Basic Source File + INT Intermediate Code + COM Command File + PLI PL/I Source File + REL Relocatable Module + TEX TEX Formatter Source + BAK ED Source Backup + SYM SID Symbol File + $$$ Temporary File + + + MSource files are treated as a sequence of ASCII characters, +XMwhere each line of the source file is followed by a carriage return, +XMand line-feed sequence (0DH followed by 0AH). Thus, one 128-byte +XMCP/M record can contain several lines of source text. The end of an +XMASCII file is denoted by a CTRL-Z character (1AH) or a real end-of- +XMfile returned by the CP/M read operation. CTRL-Z characters +XMembedded within machine code files (for example, COM files) are +XMignored and the end-of-file condition returned by CP/M is used to +Xterminate read operations. + + MFiles in CP/M can be thought of as a sequence of up to 65536 +XMrecords of 128 bytes each, numbered from 0 through 65535, thus +XMallowing a maximum of 8 megabytes per file. Note, however, that +XMalthough the records may be considered logically contiguous, they +XMmay not be physically contiguous in the disk data area. Internally, +XMall files are divided into 16K byte segments called logical extents, +XMso that counters are easily maintained as 8-bit values. The +XMdivision into extents is discussed in the paragraphs that follow: +XMhowever, they are not particularly significant for the programmer, +XMbecause each extent is automatically accessed in both sequential and +Xrandom access modes. + + MIn the file operations starting with Function 15, DE usually +XMaddresses a FCB. Transient programs often use the default FCB area +XMreserved by CP/M at location BOOT+005CH (normally 005CH) for simple +XMfile operations. The basic unit of file information is a 128-byte +XMrecord used for all file operations. Thus, a default location for +XMdisk I/O is provided by CP/M at location BOOT+0080H (normally 0080H) +Xwhich is the initial default DMA address. See Function 26. + + + 5-5 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + MAll directory operations take place in a reserved area that +XMdoes not affect write buffers as was the case in release 1, with the +XMexception of Search First and Search Next, where compatibility is +Xrequired. + + MThe FCB data area consists of a sequence of 33 bytes for +XMsequential access and a series of 36 bytes in the case when the file +XMis accessed randomly. The default FCB, normally located at 005CH, +XMcan be used for random access files, because the three bytes +XMstarting at BOOT+007DH are available for this purpose. Figure 5-2 +Xshows the FCB format with the following fields. + + + + dr f1 f2 / / f8 t1 t2 t3 ex s1 s2 rc d0 / / dn cr r0 r1 r2 + 00 01 02 ... 08 09 10 11 12 13 14 15 16 ... 31 32 33 34 35 + + +W Figure 5-2. File Control Block Format + + + +MThe following table lists and describes each of the fields in the +XFile Control Block figure. + + +W Table 5-2. File Control Block Fields + + Field Definition + + dr drive code (0-16) + 0 = use default drive for file + 1 = auto disk select drive A, + 2 = auto disk select drive B, + . + . + . + 16= auto disk select drive P. + + f1...f8 contain the filename in ASCII + upper-case, with high bit = 0 + + t1, t2, t3 contain the filetype in ASCII + upper-case, with high bit = 0 + t1', t2', and t3' denote the + bit of these positions, + t1' = 1 =>Read-Only file, + t2' = 1 =>SYS file, no DIR list + + ex contains the current extent + number, normally set to 00 by + the user, but in range 0-31 + during file I/O + + + + 5-6 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + +W Table 5-2. (continued) + +&S Field Definition + + s1 reserved for internal system use + + s2 reserved for internal system use, + set to zero on call to OPEN, MAKE, + SEARCH + + rc record count for extent ex; + takes on values from 0-127 + + d0...dn filled in by CP/M; reserved for + system use + + cr current record to read or write in + a sequential file operation; + normally set to zero by user + + r0, r1, r2 optional random record number in + the range 0-65535, with overflow + to r2, r0, r1 constitute a 16-bit + value with low byte r0, and high + byte r1 + + + MEach file being accessed through CP/M must have a corresponding +XMFCB, which provides the name and allocation information for all +XMsubsequent file operations. When accessing files, it is the +XMprogrammer's responsibility to fill the lower 16 bytes of the FCB +XMand initialize the cr field. Normally, bytes 1 through 11 are set +XMto the ASCII character values for the filename and filetype, while +Xall other fields are zero. + + MFCBs are stored in a directory area of the disk, and are +XMbrought into central memory before the programmer proceeds with file +XMoperations (see the OPEN and MAKE functions). The memory copy of +XMthe FCB is updated as file operations take place and later recorded +XMpermanently on disk at the termination of the file operation, (see +Xthe CLOSE command). + + MThe CCP constructs the first 16 bytes of two optional FCBs for +XMa transient by scanning the remainder of the line following the +XMtransient name, denoted by file1 and file2 in the prototype command +XMline described above, with unspecified fields set to ASCII blanks. +XMThe first FCB is constructed at location BOOT+005CH and can be used +XMas is for subsequent file operations. The second FCB occupies the +XMd0...dn portion of the first FCB and must be moved to another area +XMof memory before use. If, for example, the following command line +Xis typed: + + PROGNAME B:X.ZOT Y.ZAP + + + + + 5-7 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + +Mthe file PROGNAME.COM is loaded into the TPA, and the default FCB at +XMBOOT+005CH is initialized to drive code 2, filename X, and filetype +XMZOT. The second drive code takes the default value 0, which is +XMplaced at BOOT-006CH, with the filename Y placed into location +XMBOOT+006DH and filetype ZAP located 8 bytes later at BOOT+0075H. +XMAll remaining fields through cr are set to zero. Note again that it +XMis the programmer's responsibility to move this second filename and +XMfiletype to another area, usually a separate file control block, +XMbefore opening the file that begins at BOOT+005CH, because the open +Xoperation overwrites the second name and type. + + MIf no filenames are specified in the original command, the +XMfields beginning at BOOT+005DH and BOOT+006DH contain blanks. In +XMall cases, the CCP translates lower-case alphabetics to upper-case +Xto be consistent with the CP/M file naming conventions. + + MAs an added convenience, the default buffer area at location +XMBOOT+0080H is initialized to the command line tail typed by the +XMoperator following the program name. The first position contains +XMthe number of characters, with the characters themselves following +XMthe character count. Given the above command line, the area +Xbeginning at BOOT+0080H is initialized as follows: + + + BOOT+0080H: + + +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +A +B +C +D +E + E '' 'B' ':' 'X' '.' 'Z' 'O' 'T' '' 'Y' '.' 'Z' 'A' 'P' + + +Mwhere the characters are translated to upper-case ASCII with +XMuninitialized memory following the last valid character. Again, it +XMis the responsibility of the programmer to extract the information +XMfrom this buffer before any file operations are performed, unless +Xthe default DMA address is explicitly changed. + + MIndividual functions are described in detail in the pages that +Xfollow. + + + + + + + + + + + + + + + + + + + + 5-8 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 0: SYSTEM RESET + + Entry Parameters: + Register C: 00H + + + + MThe System Reset function returns control to the CP/M operating +XMsystem at the CCP level. The CCP reinitializes the disk subsystem +XMby selecting and logging-in disk drive A. This function has exactly +Xthe same effect as a jump to location BOOT. + + + + + + + FUNCTION 1: CONSOLE INPUT + + Entry Parameters: + Register C: 01H + + Returned Value: + Register A: ASCII Character + + + + MThe Console Input function reads the next console character to +XMregister A. Graphic characters, along with carriage return, line- +XMfeed, and back space (CTRL-H) are echoed to the console. Tab +XMcharacters, CTRL-I, move the cursor to the next tab stop. A check +XMis made for start/stop scroll, CTRL-S, and start/stop printer echo, +XMCTRL-P. The FDOS does not return to the calling program until a +XMcharacter has been typed, thus suspending execution if a character +Xis not ready. + + + + + + + + + + + + + + + + + + + 5-9 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 2: CONSOLE OUTPUT + + Entry Parameters + Register C: 02H + Register E: ASCII Character + + + + MThe ASCII character from register E is sent to the console +XMdevice. As in Function 1, tabs are expanded and checks are made for +Xstart/stop scroll and printer echo. + + + + + + + FUNCTION 3: READER INPUT + + Entry Parameters: + Register C: 03H + + Returned Value: + Register A: ASCII Character + + + + MThe Reader Input function reads the next character from the +XMlogical reader into register A. See the IOBYTE definition in +XMChapter 6. Control does not return until the character has been +Xread. + + + + + + + + + + + + + + + + + + + + + + + 5-10 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 4: PUNCH OUTPUT + + Entry Parameters: + Register C: 04H + register E: ASCII Character + + + + MThe Punch Output function sends the character from register E +Xto the logical punch device. + + + + + + + FUNCTION 5: LIST OUTPUT + + Entry Parameters: + Register C: 05H + Register E: ASCII Character + + + + MThe List Output function sends the ASCII character in register +XE to the logical listing device. + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-11 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 6: DIRECT CONSOLE I/O + + Entry Parameters: + Register C: 06H + Register E: 0FFH (input) or + char (output) + + Returned Value: + Register A: char or status + + + + MDirect Console I/O is supported under CP/M for those +XMspecialized applications where basic console input and output are +XMrequired. Use of this function should, in general, be avoided since +XMit bypasses all of the CP/M normal control character functions (for +XMexample, CTRL-S and CTRL-P). Programs that perform direct I/O +XMthrough the BIOS under previous releases of CP/M, however, should be +XMchanged to use direct I/O under BDOS so that they can be fully +Xsupported under future releases of MP/M and CP/M. + + MUpon entry to Function 6, register E either contains +XMhexadecimal FF, denoting a console input request, or an ASCII +XMcharacter. If the input value is FF, Function 6 returns A = 00 if +XMno character is ready, otherwise A contains the next console input +Xcharacter. + + MIf the input value in E is not FF, Function 6 assumes that E +Xcontains a valid ASCII character that is sent to the console. + + MFunction 6 must not be used in conjunction with other console +XI/O functions. + + + + + + + FUNCTION 7: GET I/O BYTE + + Entry Parameters: + Register C: 07H + + Returned Value: + Register A: I/O Byte Value + + + + MThe Get I/O Byte function returns the current value of IOBYTE +Xin register A. See Chapter 6 for IOBYTE definition. + + + + 5-12 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 8: SET I/O BYTE + + Entry Parameters: + Register C: 08H + Register E: I/O Byte Value + + + + MThe SET I/O Byte function changes the IOBYTE value to that +Xgiven in register E. + + + + + + + FUNCTION 9: PRINT STRING + + Entry Parameters: + Register C: 09H + Registers DE: String Address + + + + MThe Print String function sends the character string stored in +XMmemory at the location given by DE to the console device, until a $ +XMis encountered in the string. Tabs are expanded as in Function 2, +Xand checks are made for start/stop scroll and printer echo. + + + + + + + + + + + + + + + + + + + + + + + + + + 5-13 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 10: READ CONSOLE BUFFER + + Entry Parameters: + Register C: 0AH + Registers DE: Buffer Address + + Returned Value: + Console Characters in Buffer + + + + MThe Read Buffer functions reads a line of edited console input +XMinto a buffer addressed by registers DE. Console input is +XMterminated when either input buffer overflows or a carriage return +Xor line-feed is typed. The Read Buffer takes the form: + + DE:+0 +1 +2 +3 +4 +5 +6 +7 +8 . . .+n + + mx nc c1 c2 c3 c4 c5 c6 c7 ... ?? + +Mwhere mx is the maximum number of characters that the buffer will +XMhold, 1 to 255, and nc is the number of characters read (set by FDOS +XMupon return) followed by the characters read from the console. If +XMnc < mx, then uninitialized positions follow the last character, +XMdenoted by ?? in the above figure. A number of control functions, +Xsummarized in Table 5-3, are recognized during line editing. + + +W Table 5-3. Edit Control Characters + + Character Edit Control Function + + rub/del removes and echoes the last character + + CTRL-C reboots when at the beginning of line + + CTRL-E causes physical end of line + + CTRL-H backspaces one character position + + CTRL-J (line feed) terminates input line + + CTRL-M (return) terminates input line + + CTRL-R retypes the current line after new line + + CTRL-U removes current line + + CTRL-X same as CTRL-U + + + + + 5-14 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + +MThe user should also note that certain functions that return the +XMcarriage to the leftmost position (for example, CTRL-X) do so only +XMto the column position where the prompt ended. In earlier releases, +XMthe carriage returned to the extreme left margin. This convention +Xmakes operator data input and line correction more legible. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-15 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 11: GET CONSOLE STATUS + + Entry Parameters: + Register C: 0BH + + Returned Value: + Register A: Console Status + + + + MThe Console Status function checks to see if a character has +XMbeen typed at the console. If a character is ready, the value 0FFH +Xis returned in register A. Otherwise a 00H value is returned. + + + + + + + FUNCTION 12: RETURN VERSION NUMBER + + Entry Parameters: + Register C: 0CH + + Returned Value: + Registers HL: Version Number + + + + MFunction 12 provides information that allows version +XMindependent programming. A two-byte value is returned, with H = 00 +XMdesignating the CP/M release (H = 01 for MP/M) and L = 00 for all +XMreleases previous to 2.0. CP/M 2.0 returns a hexadecimal 20 in +XMregister L, with subsequent version 2 releases in the hexadecimal +XMrange 21,22, through 2F. Using Function 12, for example, the user +XMcan write application programs that provide both sequential and +Xrandom access functions. + + + + + + + + + + + + + + + + + 5-16 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 13: RESET DISK SYSTEM + + Entry Parameters: + Register C: 0DH + + + + MThe Reset Disk function is used to programmatically restore the +XMfile system to a reset state where all disks are set to Read-Write. +XMSee functions 28 and 29, only disk drive A is selected, and the +XMdefault DMA address is reset to BOOT+0080H. This function can be +XMused, for example, by an application program that requires a disk +Xchange without a system reboot. + + + + + + + FUNCTION 14: SELECT DISK + + Entry Parameters: + Register C: 0EH + Register E: Selected Disk + + + + MThe Select Disk function designates the disk drive named in +XMregister E as the default disk for subsequent file operations, with +XME = O for drive A, 1 for drive B, and so on through 15, +XMcorresponding to drive P in a full 16 drive system. The drive is +XMplaced in an on-line status, which activates its directory until the +XMnext cold start, warm start, or disk system reset operation. If the +XMdisk medium is changed while it is on-line, the drive automatically +XMgoes to a Read-Only status in a standard CP/M environment, see +XMFunction 28. FCBs that specify drive code zero (dr = 00H) +XMautomatically reference the currently selected default drive. Drive +XMcode values between 1 and 16 ignore the selected default drive and +Xdirectly reference drives A through P. + + + + + + + + + + + + + + + 5-17 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 15: OPEN FILE + + Entry Parameters: + Register C: 0FH + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + MThe Open File operation is used to activate a file that +XMcurrently exists in the disk directory for the currently active user +XMnumber. The FDOS scans the referenced disk directory for a match in +XMpositions 1 through 14 of the FCB referenced by DE (byte s1 is +XMautomatically zeroed) where an ASCII question mark (3FH) matches any +XMdirectory character in any of these positions. Normally, no +XMquestion marks are included, and bytes ex and s2 of the FCB are +Xzero. + + MIf a directory element is matched, the relevant directory +XMinformation is copied into bytes d0 through dn of FCB, thus allowing +XMaccess to the files through subsequent read and write operations. +XMThe user should note that an existing file must not be accessed +XMuntil a successful open operation is completed. Upon return, the +XMopen function returns a directory code with the value 0 through 3 if +XMthe open was successful or 0FFH (255 decimal) if the file cannot be +XMfound. If question marks occur in the FCB, the first matching FCB +XMis activated. Note that the current record, (cr) must be zeroed by +XMthe program if the file is to be accessed sequentially from the +Xfirst record. + + + + + + + + + + + + + + + + + + + + + + + 5-18 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 16: CLOSE FILE + + Entry Parameters: + Register C: 10H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + MThe Close File function performs the inverse of the Open File +XMfunction. Given that the FCB addressed by DE has been previously +XMactivated through an open or make function, the close function +XMpermanently records the new FCB in the reference disk directory see +XMfunctions 15 and 22. The FCB matching process for the close is +XMidentical to the open function. The directory code returned for a +XMsuccessful close operation is 0, 1, 2, or 3, while a 0FFH (255 +XMdecimal) is returned if the filename cannot be found in the +XMdirectory. A file need not be closed if only read operations have +XMtaken place. If write operations have occurred, the close operation +Xis necessary to record the new directory information permanently. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-19 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 17: SEARCH FOR FIRST + + Entry Parameters: + Register C: 11H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + MSearch First scans the directory for a match with the file +XMgiven by the FCB addressed by DE. The value 255 (hexadecimal FF) is +XMreturned if the file is not found; otherwise, 0, 1, 2, or 3 is +XMreturned indicating the file is present. When the file is found, +XMthe current DMA address is filled with the record containing the +XMdirectory entry, and the relative starting position is A *32 (that +XMis, rotate the A register left 5 bits, or ADD A five times). +XMAlthough not normally required for application programs, the +XMdirectory information can be extracted from the buffer at this +Xposition. + + MAn ASCII question mark (63 decimal, 3F hexadecimal) in any +XMposition from f1 through ex matches the corresponding field of any +XMdirectory entry on the default or auto-selected disk drive. If the +XMdr field contains an ASCII question mark, the auto disk select +XMfunction is disabled and the default disk is searched, with the +XMsearch function returning any matched entry, allocated or free, +XMbelonging to any user number. This latter function is not normally +XMused by application programs, but it allows complete flexibility to +XMscan all current directory values. If the dr field is not a +Xquestion mark, the s2 byte is automatically zeroed. + + + + + + + + + + + + + + + + + + + + + + 5-20 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 18: SEARCH FOR NEXT + + Entry Parameters: + Register C: 12H + + Returned Value: + Register A: Directory Code + + + + MThe Search Next function is similar to the Search First +XMfunction, except that the directory scan continues from the last +XMmatched entry. Similar to Function 17, Function 18 returns the +Xdecimal value 255 in A when no more directory items match. + + + + + + + FUNCTION 19: DELETE FILE + + Entry Parameters: + Register C: 13H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + MThe Delete File function removes files that match the FCB +XMaddressed by DE. The filename and type may contain ambiguous +XMreferences (that is, question marks in various positions), but the +XMdrive select code cannot be ambiguous, as in the Search and Search +XNext functions. + + MFunction 19 returns a decimal 255 if the referenced file or +XMfiles cannot be found; otherwise, a value in the range 0 to 3 +Xreturned. + + + + + + + + + + + + + + 5-21 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 20: READ SEQUENTIAL + + Entry Parameters: + Register C: 14H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + MGiven that the FCB addressed by DE has been activated through +XMan Open or Make function, the Read Sequential function reads the +XMnext 128-byte record from the file into memory at the current DMA +XMaddress. The record is read from position cr of the extent, and the +XMcr field is automatically incremented to the next record position. +XMIf the cr field overflows, the next logical extent is automatically +XMopened and the cr field is reset to zero in preparation for the next +XMread operation. The value 00H is returned in the A register if the +XMread operation was successful, while a nonzero value is returned if +XMno data exist at the next record position (for example, end-of-file +Xoccurs). + + + + + + + FUNCTION 21: WRITE SEQUENTAIL + + Entry Parameters: + Register C: 15H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + MGiven that the FCB addressed by DE has been activated through +XMan Open or Make function, the Write Sequential function writes the +XM128-byte data record at the current DMA address to the file named by +XMthe FCB. The record is placed at position cr of the file, and the +XMcr field is automatically incremented to the next record position. +XMIf the cr field overflows, the next logical extent is automatically +XMopened and the cr field is reset to zero in preparation for the next +XMwrite operation. Write operations can take place into an existing +XMfile, in which case, newly written records overlay those that +XMalready exist in the file. Register A = 00H upon return from a +XMsuccessful write operation, while a nonzero value indicates an +Xunsuccessful write caused by a full disk. + + + 5-22 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 22: MAKE FILE + + Entry Parameters: + Register C: 16H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + MThe Make File operation is similar to the Open File operation +XMexcept that the FCB must name a file that does not exist in the +XMcurrently referenced disk directory (that is, the one named +XMexplicitly by a nonzero dr code or the default disk if dr is zero). +XMThe FDOS creates the file and initializes both the directory and +XMmain memory value to an empty file. The programmer must ensure that +XMno duplicate filenames occur, and a preceding delete operation is +XMsufficient if there is any possibility of duplication. Upon return, +XMregister A = 0, 1, 2, or 3 if the operation was successful and 0FFH +XM(255 decimal) if no more directory space is available. The Make +XMfunction has the side effect of activating the FCB and thus a +Xsubsequent open is not necessary. + + + + + + + FUNCTION 23: RENAME FILE + + Entry Parameters: + Register C: 17H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + MThe Rename function uses the FCB addressed by DE to change all +XMoccurrences of the file named in the first 16 bytes to the file +XMnamed in the second 16 bytes. The drive code dr at postion 0 is +XMused to select the drive, while the drive code for the new filename +XMat position 16 of the FCB is assumed to be zero. Upon return, +XMregister A is set to a value between 0 and 3 if the rename was +XMsuccessful and 0FFH (255 decimal) if the first filename could not be +Xfound in the directory scan. + + + + + + 5-23 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 24: RETURN LOG-IN VECTOR + + Entry Parameters: + Register C: 18H + + Returned Value: + Registers HL: Log-in Vector + + + + MThe log-in vector value returned by CP/M is a 16-bit value in +XMHL, where the least significant bit of L corresponds to the first +XMdrive A and the high-order bit of H corresponds to the sixteenth +XMdrive, labeled P. A 0 bit indicates that the drive is not on-line, +XMwhile a 1 bit marks a drive that is actively on-line as a result of +XMan explicit disk drive selection or an implicit drive select caused +XMby a file operation that specified a nonzero dr field. The user +XMshould note that compatibility is maintained with earlier releases, +Xbecause registers A and L contain the same values upon return. + + + + + + + FUNCTION 25: RETURN CURRENT DISK + + Entry Parameters: + Register C: 19H + + Returned Value: + Register A: Current Disk + + + + MFunction 25 returns the currently selected default disk number +XMin register A. The disk numbers range from 0 through 15 +Xcorresponding to drives A through P. + + + + + + + + + + + + + + + + 5-24 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 26: SET DMA ADDRESS + + Entry Parameters: + Register C: 1AH + Registers DE: DMA Address + + + + MDMA is an acronym for Direct Memory Address, which is often +XMused in connection with disk controllers that directly access the +XMmemory of the mainframe computer to transfer data to and from the +XMdisk subsystem. Although many computer systems use non-DMA access +XM(that is, the data is transferred through programmed I/O +XMoperations), the DMA address has, in CP/M, come to mean the address +XMat which the 128-byte data record resides before a disk write and +XMafter a disk read. Upon cold start, warm start, or disk system +XMreset, the DMA address is automatically set to BOOT+0080H. The Set +XMDMA function can be used to change this default value to address +XManother area of memory where the data records reside. Thus, the DMA +XMaddress becomes the value specified by DE until it is changed by a +XMsubsequent Set DMA function, cold start, warm start, or disk system +Xreset. + + + + + + + FUNCTION 27: GET ADDR (ALLOC) + + Entry Parameters: + Register C: 1BH + + Returned Value: + Registers HL: ALLOC Address + + + + MAn allocation vector is maintained in main memory for each on- +XMline disk drive. Various system programs use the information +XMprovided by the allocation vector to determine the amount of +XMremaining storage (see the STAT program). Function 27 returns the +XMbase address of the allocation vector for the currently selected +XMdisk drive. However, the allocation information might be invalid if +XMthe selected disk has been marked Read-Only. Although this function +XMis not normally used by application programs, additional details of +Xthe allocation vector are found in Chapter 6. + + + + + + + 5-25 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 28: WRITE PROTECT DISK + + Entry Parameters: + Register C: 1CH + + + + MThe Write Protect Disk function provides temporary write +XMprotection for the currently selected disk. Any attempt to write to +XMthe disk before the next cold or warm start operation produces the +Xmessage: + + BDOS ERR on d:R/O + + + + + + + FUNCTION 29: GET READ-ONLY VECTOR + + Entry Parameters: + Register C: 1DH + + Returned Value: + Registers HL: R/O Vector Value + + + + MFunction 29 returns a bit vector in register pair HL, which +XMindicates drives that have the temporary Read-Only bit set. As in +XMFunction 24, the least significant bit corresponds to drive A, while +XMthe most significant bit corresponds to drive P. The R/O bit is set +XMeither by an explicit call to Function 28 or by the automatic +Xsoftware mechanisms within CP/M that detect changed disks. + + + + + + + + + + + + + + + + + + + 5-26 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 30: SET FILE ATTRIBUTES + + Entry Parameters: + Register C: 1EH + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + MThe Set File Attributes function allows programmatic +XMmanipulation of permanent indicators attached to files. In +XMparticular, the R/O and System attributes (t1' and t2') can be set +XMor reset. The DE pair addresses an unambiguous filename with the +XMappropriate attributes set or reset. Function 30 searches for a +XMmatch and changes the matched directory entry to contain the +XMselected indicators. Indicators f1' through f4' are not currently +XMused, but may be useful for applications programs, since they are +XMnot involved in the matching process during file open and close +XMoperations. Indicators f5' through f8' and t3' are reserved for +Xfuture system expansion. + + + + + + + FUNCTION 31: GET ADDR (DISK PARMS) + + Entry Parameters: + Register C: 1FH + + Returned Value: + Registers HL: DPB Address + + + + MThe address of the BIOS resident disk parameter block is +XMreturned in HL as a result of this function call. This address can +XMbe used for either of two purposes. First, the disk parameter +XMvalues can be extracted for display and space computation purposes, +XMor transient programs can dynamically change the values of current +XMdisk parameters when the disk environment changes, if required. +XNormally, application programs will not require this facility. + + + + + + + + + 5-27 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 32: SET/GET USER CODE + + Entry Parameters: + Register C: 20H + Register E: OFFH (get) or + User Code (set) + + Returned Value: + Register A: Current Code or + (no value) + + + + MAn application program can change or interrogate the currently +XMactive user number by calling Function 32. If register E = 0FFH, +XMthe value of the current user number is returned in register A, +XMwhere the value is in the range of 0 to 15. If register E is not +XM0FFH, the current user number is changed to the value of E, modulo +X16. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-28 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 33: READ RANDOM + + Entry Parameters: + Register C: 21H + + Returned Value: + Register A: Return Code + + + + MThe Read Random function is similar to the sequential file read +XMoperation of previous releases, except that the read operation takes +XMplace at a particular record number, selected by the 24-bit value +XMconstructed from the 3-byte field following the FCB (byte positions +XMr0 at 33, r1 at 34, and r2 at 35). The user should note that the +XMsequence of 24 bits is stored with least significant byte first +XM(r0), middle byte next (r1), and high byte last (r2). CP/M does not +XMreference byte r2, except in computing the size of a file (Function +XM35). Byte r2 must be zero, however, since a nonzero value indicates +Xoverflow past the end of file. + + MThus, the r0, r1 byte pair is treated as a double-byte, or word +XMvalue, that contains the record to read. This value ranges from 0 +XMto 65535, providing access to any particular record of the 8- +XMmegabyte file. To process a file using random access, the base +XMextent (extent 0) must first be opened. Although the base extent +XMmight or might not contain any allocated data, this ensures that the +XMfile is properly recorded in the directory and is visible in DIR +XMrequests. The selected record number is then stored in the random +Xrecord field (r0, r1), and the BDOS is called to read the record. + + MUpon return from the call, register A either contains an error +XMcode, as listed below, or the value 00, indicating the operation was +XMsuccessful. In the latter case, the current DMA address contains +XMthe randomly accessed record. Note that contrary to the sequential +XMread operation, the record number is not advanced. Thus, subsequent +Xrandom read operations continue to read the same record. + + MUpon each random read operation, the logical extent and current +XMrecord values are automatically set. Thus, the file can be +XMsequentially read or written, starting from the current randomly +XMaccessed position. However, note that, in this case, the last +XMrandomly read record will be reread as one switches from random mode +XMto sequential read and the last record will be rewritten as one +XMswitches to a sequential write operation. The user can simply +XMadvance the random record position following each random read or +Xwrite to obtain the effect of sequential I/O operation. + + + + + + + 5-29 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + MError codes returned in register A following a random read are +Xlisted below. + + + 01 reading unwritten data + + 02 (not returned in random mode) + + 03 cannot close current extent + + 04 seek to unwritten extent + + 05 (not returned in read mode) + + 06 seek past physical end of disk + + + MError codes 01 and 04 occur when a random read operation +XMaccesses a data block that has not been previously written or an +XMextent that has not been created, which are equivalent conditions. +XMError code 03 does not normally occur under proper system operation. +XMIf it does, it can be cleared by simply rereading or reopening +XMextent zero as long as the disk is not physically write protected. +XMError code 06 occurs whenever byte r2 is nonzero under the current +XM2.0 release. Normally, nonzero return codes can be treated as +XMmissing data, with zero return codes indicating operation complete. +X + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-30 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 34: WRITE RANDOM + + Entry Parameters: + Register C: 22H + Registers DE: FCB Address + + Returned Value: + Register A: Return Code + + + + MThe Write Random operation is initiated similarly to the Read +XMRandom call, except that data is written to the disk from the +XMcurrent DMA address. Further, if the disk extent or data block that +XMis the target of the write has not yet been allocated, the +XMallocation is performed before the write operation continues. As in +XMthe Read Random operation, the random record number is not changed +XMas a result of the write. The logical extent number and current +XMrecord positions of the FCB are set to correspond to the random +XMrecord that is being written. Again, sequential read or write +XMoperations can begin following a random write, with the notation +XMthat the currently addressed record is either read or rewritten +XMagain as the sequential operation begins. You can also simply +XMadvance the random record position following each write to get the +XMeffect of a sequential write operation. Note that reading or +XMwriting the last record of an extent in random mode does not cause +Xan automatic extent switch as it does in sequential mode. + + MThe error codes returned by a random write are identical to the +XMrandom read operation with the addition of error code 05, which +XMindicates that a new extent cannot be created as a result of +Xdirectory overflow. + + + + + + + + + + + + + + + + + + + + + + 5-31 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 35: COMPUTE FILE SIZE + + Entry Parameters: + Register C: 23H + Registers DE: FCB Address + + Returned Value: + Random Record Field Set + + + + MWhen computing the size of a file, the DE register pair +XMaddresses an FCB in random mode format (bytes r0, r1, and r2 are +XMpresent). The FCB contains an unambiguous filename that is used in +XMthe directory scan. Upon return, the random record bytes contain +XMthe virtual file size, which is, in effect, the record address of +XMthe record following the end of the file. Following a call to +XMFunction 35, if the high record byte r2 is 01, the file contains the +XMmaximum record count 65536. Otherwise, bytes r0 and r1 constitute a +XM16-bit value as before (r0 is the least significant byte), which is +Xthe file size. + + MData can be appended to the end of an existing file by simply +XMcalling Function 35 to set the random record position to the end of +XMfile and then performing a sequence of random writes starting at the +Xpreset record address. + + MThe virtual size of a file corresponds to the physical size +XMwhen the file is written sequentially. If the file was created in +XMrandom mode and holes exist in the allocation, the file might +XMcontain fewer records than the size indicates. For example, if only +XMthe last record of an 8-megabyte file is written in random mode +XM(that is, record number 65535), the virtual size is 65536 records, +Xalthough only one block of data is actually allocated. + + + + + + + + + + + + + + + + + + + + 5-32 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 36: SET RANDOM RECORD + + Entry Parameters: + Register C: 24H + Registers DE: FCB Address + + Returned Value: + Random Record Field Set + + + + MThe Set Random Record function causes the BDOS automatically to +XMproduce the random record position from a file that has been read or +XMwritten sequentially to a particular point. The function can be +Xuseful in two ways. + + MFirst, it is often necessary initially to read and scan a +XMsequential file to extract the positions of various key fields. As +XMeach key is encountered, Function 36 is called to compute the random +XMrecord position for the data corresponding to this key. If the data +XMunit size is 128 bytes, the resulting record position is placed into +XMa table with the key for later retrieval. After scanning the entire +XMfile and tabulating the keys and their record numbers, the user can +XMmove instantly to a particular keyed record by performing a random +XMread, using the corresponding random record number that was saved +XMearlier. The scheme is easily generalized for variable record +XMlengths, because the program need only store the buffer-relative +XMbyte position along with the key and record number to find the exact +Xstarting position of the keyed data at a later time. + + MA second use of Function 36 occurs when switching from a +XMsequential read or write over to random read or write. A file is +XMsequentially accessed to a particular point in the file, Function 36 +XMis called, which sets the record number, and subsequent random read +Xand write operations continue from the selected point in the file. + + + + + + + + + + + + + + + + + + + 5-33 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 37: RESET DRIVE + + Entry Parameters: + Register C: 25H + Registers DE: Drive Vector + + Returned Value: + Register A: 00H + + + + MThe Reset Drive function allows resetting of specified drives. +XMThe passed parameter is a 16-bit vector of drives to be reset; the +Xleast significant bit is drive A:. + + MTo maintain compatibility with MP/M, CP/M returns a zero value. +X + + + + + + FUNCTION 40: WRITE RANDOM WITH ZERO FILL + + Entry Parameters: + Register C: 28H + Registers DE: FCB Address + + Returned Value: + Register A: Return Code + + + + MThe Write With Zero Fill operation is similar to Function 34, +XMwith the exception that a previously unallocated block is filled +Xwith zeros before the data is written. + + + + + + + + + + + + + + + + + + 5-34 + + + + + +CP/M Operating System Manual 5.3 A Sample Copy Program + + +W5.3 A Sample File-to-File Copy Program + + MT&She following program provides a relatively simple example of +XMfile operations. The program source file is created as COPY.ASM +XMusing the CP/M ED program and then assembled using ASM or MAC, +XMresulting in a HEX file. The LOAD program is used to produce a +XMCOPY.COM file that executes directly under the CCP. The program +XMbegins by setting the stack pointer to a local area and proceeds to +XMmove the second name from the default area at 006CH to a 33-byte +XMFile Control Block called DFCB. The DFCB is then prepared for file +XMoperations by clearing the current record field. At this point, +XMthe source and destination FCBs are ready for processing, because +XMthe SFCB at 005CH is properly set up by the CCP upon entry to the +XMCOPY program. That is, the first name is placed into the default +XMFCB, with the proper fields zeroed, including the current record +XMfield at 007CH. The program continues by opening the source file, +XMdeleting any existing destination file, and creating the destination +XMfile. If all this is successful, the program loops at the label +XMCOPY until each record is read from the source file and placed into +XMthe destination file. Upon completion of the data transfer, the +XMdestination file is closed and the program returns to the CCP +Xcommand level by jumping to BOOT. + 9 U0 + + + ; sample file-to-file copy program + ; + ; at the ccp level, the command + ; + ; copy a:x.y b:u.v + ; + ; copies the file named x.y from drive + ; a to a file named u.v. on drive b. + ; +0000 = boot equ 0000h ;system reboot +0005 = bdos equ 0005h ;bdos entry point +005c = fcbl equ 005ch ;first file name +005c = sfcb equ fcbl ;source fcb +006c = fcb2 equ 006ch ;second file name +0080 = dbuff equ 0080h ;default buffer +0100 = tpa equ 0100h ;beginning of tpa + ; +0009 = printf equ 9 ;print buffer func# +000f = openf equ 15 ;open file func# +0010 = closef equ 16 ;close file func# +0013 = deletef equ 19 ;delete file func# +0014 = readf equ 20 ;sequential read +0015 = writef equ 21 ;sequential write +0016 = makef equ 22 ;make file func# + ; +0100 org tpa ;beginning of tpa +0100 311b02 lxi sp,stack ;local stack + ; + ; move second file name to dfcb +0103 0e10 mvi c,16 ;half an fcb + + + 5-35 + + + + + +CP/M Operating System Manual 5.3 A Sample Copy Program + + +0105 116c00 lxi d,fcb2 ;source of move +0108 21da01 lxi h,dfcb ;destination fcb +010b 1a mfcb: Idax d ;source fcb +010c 13 inx d ;ready next +010d 77 mov m,a ;dest fcb +010e 23 inx h ;ready next +010f 0d dcr c ;count 16...0 +0110 c10b01 jnz mfcb ;loop 16 times + ; + ; name has been removed, zero cr +0113 af xra a ;a = 00h +0114 32fa01 sta dfcbcr ;current rec = 0 + ; + ; source and destination fcb's ready + ; +0117 115c00 lxi d,sfcb ;source file +011a cd6901 call open ;error if 255 +011d 118701 lxi d,nofile ;ready message +0120 3c inr a ;255 becomes 0 +0121 cc6101 cz finis ;done if no file + ; + ; source file open, prep destination +0124 11da01 lxi d,dfcb ;destination +0127 cd7301 call delete ;remove if present + ; +012a 11da01 lxi d,dfcb ;destination +012d cd8201 call make ;create the file +0130 119601 lxi d,nodir ;ready message +0133 3c inr a ;255 becomes 0 +0134 cc6101 cz finis ;done if no dir space + ; + ; source file open, dest file open + ; copy until end of file on source + ; +0137 115c00 copy: lxi d,sfcb ;source +013a cd7801 call read ;read next record +013d b7 ora a ;end of file? +013e c25101 jnz eofile ;skip write if so + ; + ; not end of file, write the record +0141 11da01 lix d,dfcb ;destination +0144 cd7d01 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 11da01 lxi d,dfcb ;destination +0154 cd6e01 call close ;255 if error +0157 21bb01 lxi h,wrprot ;ready message +015a 3c inr a ;255 becomes 00 +015b cc6101 cz finis ;shouldn't happen + ; + ; copy operation complete, end + + + 5-36 + + + + + +CP/M Operating System Manual 5.3 A Sample Copy Program + + +015e 11cc01 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 system + ; + ; system interface subroutines + ; (all return directly from bdos) + ; +0169 0e0f open: mvi c,openf +016b c30500 jmp bdos + ; +016e 0e10 close: mvi c,closef +0170 c30500 jmp bdos + ; +0173 0e13 delete mvi c,deletef +0175 c30500 jmp bdos + ; +0178 0e14 read: mvi c,readf +017a c30500 jmp bdos + ; +017d 0e15 write: mvi c,writef +017f c30500 jmp bdos + ; +0182 0e16 make: mvi c,makef +0184 c30500 jmp bdos + ; + ; console messages +0187 6e6f20f nofile: db 'no source file$' +0196 6e6f209 nodir: db 'no directory space$' +01a9 6f7574f space: db 'out of dat space$' +01bb 7772695 wrprot: db 'write protected?$' +01cc 636f700 normal: db 'copy complete$' + ; + ; data areas +01da dfcb: ds 33 ;destination fcb +01fa dfcbcr equ dfcb+32 ;current record + ; +01fb ds 32 ;16 level stack + stack: +021b end + 9 K0 + + + MNote that there are several simplifications in this particular +XMprogram. First, there are no checks for invalid filenames that +XMcould contain ambiguous references. This situation could be +XMdetected by scanning the 32-byte default area starting at location +XM005CH for ASCII question marks. A check should also be make to +XMensure that the filenames have been included (check locations 005DH +XMand 006DH for nonblank ASCII characters). Finally, a check should +XMbe made to ensure that the source and destination filenames are +XMdifferent. An improvement in speed could be obtained by buffering +XMmore data on each read operation. One could, for example, determine + + + 5-M37 + + + +X + +CP/M Operating System Manual 5.3 A Sample Copy Program + + +Mthe size of memory by fetching FBASE from location 0006H and using +XMthe entire remaining portion of memory for a data buffer. In this +XMcase, the programmer simply resets the DMA address to the next +XMsuccessive 128-byte area before each read. Upon writing to the +XMdestination file, the DMA address is reset to the beginning of the +XMbuffer and incremented by 128 bytes to the end as each record is +Xtransferred to the destination file. + + +W5.4 A Sample File Dump Utility + + MT&She following file dump program is slightly more complex than +XMthe simple copy program given in the previous section. The dump +XMprogram reads an input file, specified in the CCP command line, and +XMdisplays the content of each record in hexadecimal format at the +XMconsole. Note that the dump program saves the CCP's stack upon +XMentry, resets the stack to a local area, and restores the CCP's +XMstack before returning directly to the CCP. Thus, the dump program +Xdoes not perform and warm start at the end of processing. + 9 U0 + + +x.in 5 + ;DUMP program reads input file and displays + hex data + ; +0100 org 100h +0005 = bdos equ 0005h = ;bdos entry point +0001 = cons equ 1 ;read console +0002 = typef equ 2 ;type function +0009 = printf equ 9 ;buffer print entry +000b = brkf equ 11 ;break key function + ;(true if char +000f = openf equ 15 ;file open +0014 = readf equ 20 ;read function + ; +005c = fcb equ 5ch ;file control block + ;address +0080 = buff equ 80h ;input disk buffer + ;address + ; + ; non graphic characters +000d = cr equ 0dh ;carriage return +000a = If equ 0ah ;line feed + ; + ; file control block definitions +005c = fcbdn equ fcb+0 ;disk name +005d = fcbfn equ fcb+1 ;file name +0065 = fcbft equ fcb+9 ;disk file type (3 + ;characters) +0068 = fcbrl equ fcb+12 ;file's current reel + ;number +006b = fcbrc equ fcb+15 ;file's record count (0 to + ;128)128) +007c = fcbcr' equ fcb+32 ;current (next) record + + + 5-38 + + + + + +CP/M Operating System Manual 5.4 A Sample File Dump Utility + + + ;number (0 +007d = fcbin equ fcb+33 ;fcb length + ; + ; set up stack +0100 210000 lxi h,0 +0103 39 dad sp + ; entry stack pointer in hl from the ccp +0104 221502 shld oldsp + ; set sp to local stack area (restored at + ; finis) +0107 315702 lxi sp,stktop + ; read and print successive buffers +010a cdc101 call setup ;set up input file +010d feff cpi 255 ;255 if file not present +010f c21b01 jnz openok ;skip if open is ok + ; + ; file not there, give error message and + ; return +0112 11f301 lxi d,opnmsg +0115 cd9c01 call err +0118 c35101 jmp finis ;to return + ; + openok: ;open operation ok, set buffer index to + ;end +011b 3e80 mvi a,80h +011d 321302 sta ibp ;set buffer pointer to 80h + ; hl contains next address to print +0120 210000 lxi h,0 ;start with 0000 + ; + gloop: +0123 e5 push h ;save line position +0124 cda201 call gnb +0127 e1 pop h ;recall line position +0138 da5101 jc finis ;carry set by gnb if end + ;file +012b 47 mov b,a + ; print hex values + ; check for line fold +012c 7d + mov a,l +012d e60f ani 0fh ;check low 4 bits +012f c24401 jnz nonum + ; print line number +0132 cd7201 call crlf + ; + ; check for break key +0135 cd5901 call break + ; accum lsb = 1 if character ready +0138 0f rrc ;into carry +0139 da5101 jc finis ;don't print any more + ; +013c 7c mov a,h +013d cd8f01 call phex +0140 7d mov a,l +0141 cd8f01 call phex + + + 5-39 + + + + + +CP/M Operating System Manual 5.4 A Sample File Dump Utility + + + nonum +0144 23 inx h ;to next line number +0145 3e20 mvi a,'' +0147 cd6501 call pchar +014a 78 mov a,b +014b cd8f01 call phex +014e c32301 jmp gloop + ; + finis + ; end of dump, return to cco + ; (note that a jmp to 0000h reboots) +0151 cd7201 call crif +0154 2a1502 lhld oldsp +0157 f9 sphl + ; stack pointer contains ccp's stack + ; location +0158 c9 ret ;to the ccp + ; + ; + ; subroutines + ; + break: ;check break key (actually any key will + ;do) +0159 e5d5c5 push h! push d! push b; environment + ;saved +015c 0e0b mvi c,brkf +015e cd0500 call bdos +0161 c1d1e1 pop b! pop d! pop h; environment + restored +0164 c9 ret + ; + pchar: ;print a character +0165 e5d5c5 push h! push d! push b; saved +0168 0e02 mvi c, typef +016a 5f mov e,a +016b cd0500 call bdos +016e c1d1e1 pop b! pop d! pop h; restored +0171 c9 ret + ; + crlf +0172 3e0d mvi a,cr +0174 cd6501 call pchar +0177 3e0a mvi a,lf +0179 cd6501 call pchar +017c c9 ret + ; + ; + pnib: ;print nibble in reg a +017d e60f ani ofh ;low 4 bits +017f fe0a cpi 10 +0181 d28901 jnc p10 + ; less than or equal to 9 +0184 c630 adi '0' +0186 c38b01 jmp prn + ; + + + 5-40 + + + + + +CP/M Operating System Manual 5.4 A Sample File Dump Utility + + + ; greater or equal to 10 +0189 c637 p10: adi 'a' - 10 +018b cd6501 prn: call pchar +018e c9 ret + ; + phex ;print hex char in reg a +018f f5 pushpsw +0190 0f rrc +0191 0f rrc +0192 0f rrc +0193 0f rrc +0194 cd7d01 call pnib ;print nibble +0197 f1 pop psw +0198 cd7d01 call pnip +019b c9 ret + ; + err: ;print error message + ; d,e addresses message ending with "$" +019c 0e09 mvi c,printf ;print buffer + ;function +019e cd0500 call bdos +01a1 c9 ret + ; + ; + gnb: ;get next byte +01a2 3a1302 lda ibp +01a5 fe80 cpi 80h +01a7 c2b301 jnz g0 + ; read another buffer + ; + ; + 01aa cdce01 call diskr +01ad b7 ora a ;zero value if read ok +01ae cab301 jz g0 ;for another byte + ; end of data, return with carry set for eof +01b1 37 stc +01b2 c9 ret + ; + g0: ;read the byte at buff+reg a +01b3 5f mov e,a ;Is byte of buffer index +01b4 1600 mvi d,0 ;double precision + ;index to de +01b6 3c inr a ;index=index+1 +01b7 321302 sta ibp ;back to memory + ; pointer is incremented + ; save the current file address +01ba 218000 lxi h,buff +01bd 19 dad d + ; absolute character address is in hl +01be 7e mov a,m + ; byte is in the accumulator +01bf b7 ora a ;reset carry bit +01c0 c9 ret + ; + setup: ;set up file + + + 5-41 + + + + + +CP/M Operating System Manual 5.4 A Sample File Dump Utility + + + ; open the file for input +01c1 af xra a ;zero to accum +01c2 327c00 sta fcbcr ;clear current record + ; +01c5 115c00 lxi d,fcb +01c8 0e0f mvi c,openf +01ca cd0500 call bdos + ; 255 in accum if open error +01cd c9 ret + ; + diskr: ;read disk file record +01ce e5d5c5 push h! push d! push b +01d1 115c00 lxi d,fcb +01d4 0e14 mvi c,readf +01d6 cd0500 call bdos +01d9 c1d1e1 pop b! pop d! pop h +01dc c9 ret + ; + ; fixed message area +01dd 46494c0 signon: db 'file dump version 2.0$' +01f3 0d0a4e0 opnmsg: db cr,lf,'no input file present on + disk$' + + ; variable area +0213 ibp: ds 2 ;input buffer pointer +0215 oldsp: ds 2 ;entry sp value from ccp + ; + ; stack area +0217 ; ds 64 ;reserve 32 level stack + stktop: + ; +0257 end + 9 K0 + + +W5.5 A Sample Random Access Program + + MT&Shis chapter concludes with an extensive example of random +XMaccess operation. The program listed below performs the simple +XMfunction of reading or writing random records upon command from the +XMterminal. When a program has been created, assembled, and placed +Xinto a file labeled RANDOM.COM, the CCP level command + + RANDOM X.DAT + +Mstarts the test program. The program looks for a file by the name +XMX.DAT and, if found, proceeds to prompt the console for input. If +XMnot found, the file is created before the prompt is given. Each +Xprompt takes the form + + next command? + +Mand is followed by operator input, followed by a carriage return. +XThe input commands take the form + + + + 5-42 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + + nW nR Q + +Mwhere n is an integer value in the range 0 to 65535, and W, R, and Q +XMare simple command characters corresponding to random write, random +XMread, and quit processing, respectively. If the W command is +Xissued, the RANDOM program issues the prompt + + type data: + +MThe operator then responds by typing up to 127 characters, followed +XMby a carriage return. RANDOM then writes the character string into +XMthe X.DAT file at record n. If the R command is issued, RANDOM +XMreads record number n and displays the string value at the console, +XMIf the Q command is issued, the X.DAT file is closed, and the +XMprogram returns to the CCP. In the interest of brevity, the only +Xerror message is + + error, try again. + + MThe program begins with an initialization section where the +XMinput file is opened or created, followed by a continuous loop at +XMthe label ready where the individual commands are interpreted. The +XMDFBC at 005CH and the default buffer at 0080H are used in all disk +XMoperations. The utility subroutines then follow, which contain the +XMprincipal input line processor, called readc. This particular +XMprogram shows the elements of random access processing, and can be +Xused as the basis for further program development. + 9 U0 + + +W Sample Random Access Program for CP/M 2.0 + +&S0100 org 100h ;base of tpa + ; +0000 = reboot equ 0000h ;system reboot +0005 = bdos equ 0005h ;bdos entry point + ; +0001 = coninp equ 1 ;console input function +0002 = conout equ 2 ;console output function +0009 = pstring equ 9 ;print string until '$' +000a = rstring equ 10 ;read console buffer +000c = version equ 12 ;return version number +000f = openf equ 15 ;file open function +0010 = closef equ 16 ;close function +0016 = makef equ 22 ;make file function +0021 = readr equ 33 ;read random +0022 = writer equ 34 ;write random + ; +005c = fcb equ 005ch ;default file control + ;block +007d = ranrec equ fcb+33 ;random record position +007f = ranovf equ fcb+35 ;high order (overflow) + ;byte +0080 = buff equ 0080h ;buffer address + ; + + + 5-43 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + +000d = cr equ 0dh ;carriage return +000a = lf equ 0ah ;line feed + ; + + +W Load SP, Set-Up File for Random Access + +&S0100 31bc00 lxi sp,stack + ; + ; version 2.0 +0103 0e0c mvi c,version +0105 cd0500 call bdos +0108 fe20 cpi 20h ;version 2.0 or better? +010a d21600 jnc versok + ; bad version, message and go back +010d 111b00 lxi d,badver +0110 cdda00 call print +0113 c30000 jmp reboot + ; + versok: + ; correct versionm for random access +0116 0e0f mvi c,openf ;open default fcb +0118 115c00 lxi d,fcb +011b cd 0500 call bdos +011e 3c inr a ;err 255 becomes zero +011f c23700 jnz ready + ; + ; connot open file, so create it +0122 0e16 mvi c,makef +0124 115c00 lxi d,fcb +0127 cd0500 call bdos +012a 3c inr a ;err 255 becomes zero +012b c23700 jnz ready + ; + ; cannot create file, directory full +012e 113a00 lxi d,nospace +0131 cdda00 call print +0134 c30000 jmp reboot ;back to ccp + + +W Loop Back to Ready After Each Command + +&S ; + ready: + ; file is ready for processing + ; +0137 cde500 call readcom ;read next command +013a 227d00 shld ranrec ;store input record# +013d 217f00 lxi h,ranovf +0140 3600 mvi m,0 ;clear high byte if set +0142 fe51 cpi 'Q' ;quit? +0144 c25600 jnz notq + ; + ; quit processing, close file +0147 0e10 mvi c,closef + + + 5-44 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + +0149 115c00 lxi d,fcb +014c cd0500 call bdos +014f 3c inr a ;err 255 becomes 0 +0150 cab900 jz error ;error message, retry +0153 c30000 jmp reboot ;back to ccp + ; + + +W End of Quit Command, Process Write + +&S notq: + ; not the quit command, random write? +0156 fe57 cpi 'W' +0158 c28900 jnz notw + ; + ; this is a random write, fill buffer untill cr +015b 114d00 lxi d,datmsg +015e cdda00 call print ;data prompt +0161 0e7f mvi c,127 ;up to 127 characters +0163 218000 lxi h,buff ;destination + rloop: ;read next character to buff +0166 c5 push b ;save counter +0167 e5 push h ;next destination +0168 cdc200 call getchr ;character to a +016b e1 pop h ;restore counter +016c c1 pop b ;restore next to fill +016d fe0d cpi cr ;end of line? +016f ca7800 jz erloop + ; not end, store character +0172 77 mov m,a +0173 23 inx h ;next to fill +0174 0d dcr c ;counter goes down +0175 c26600 jnz rloop ;end of buffer? + erloop: + ; end of read loop, store 00 +0178 3600 mvi m,0 + ; + ; write the record to selected record number +017a 0e22 mvi c,writer +017c 115c00 lxi d,fcb +017c cd0500 call bdos +0182 b7 ora a ;erro code zero? +0183 c2b900 jnz error ;message if not +0186 c33700 jmp ready ;for another record + ; + + +W End of Write Command, Process Read + +&S notw: + ; not a write command, read record? +0189 fe52 cpi 'R' +018b c2b900 jnz error ;skip if not + ; + ; read random record + + + 5-45 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + +018e 0e21 mvi c,readr +0190 115c00 lxi d,fcb +0193 cd0500 call bdos +0196 b7 ora a ;return code 00? +0197 c2b900 jnz error + ; + ; read was successful, write to console +019a cdcf00 call crlf ;new line +019d 0e80 mvi c,128 ;max 128 characters +019f 218000 lxi h,buff ;next to get + wloop: +01a2 7e mov a,m ;next character +01a3 23 inx h ;next to get +01a4 e67f ani 7fh ;mask parity +01a6 ca3700 jz ready ;for another command + ;if 00 +01a9 c5 push b ;save counter +01aa e5 push h ;save next to get +01ab fe20 cpi '' ;graphic? +01ad d4c800 cnc putchr ;skip output if not +01b0 e1 pop h +01b1 c1 pop b +01b2 0d dcr c ;count=count-1 +01b3 c2a200 jnz wloop +01b6 c33700 jmp ready + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-46 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + +W End of Read Command, All Errors End Up Here + +&S ; + error: +01b9 115900 lxi d,errmsg +01bc cdda00 call print +01bf c33700 jmp ready + ; + + +W Utility Subroutines for Console I/O + +&S getchr: + ;read next console character to a +01c2 0e01 mvi c,coninp +01c4 cd0500 call bdos +01c7 c9 ret + ; + putchr: + ;write character from a to console +01c8 0e02 mvi c,conout +01ca 5f mov e,a ;character to send +01cb cd0500 call bdos ;send character +01ce c9 ret + ; + crlf: + ;send carriage return line feed +01cf 3e0d mvi a,cr ;carriage return +01d1 cdc800 call putchr +01d4 3e0a mvi a,lf ;line feed +01d6 cdc800 call putchr +01d9 c9 ret + ; + print: + ;print the buffer addressed by de untill $ +01da d5 push d +01db cdcf00 call crlf +01de d1 pop d ;new line +01df 0e09 mvi c,pstring +01e0 cd0500 call bdos ;print the string +01e4 c9 ret + ; + readcom: + ;read the next command line to the conbuf +01e5 116b00 lxi d,prompt +01e8 cdda00 call print ;command? +01eb 0e0a mvi c,rstring +01ed 117a00 lxi d,conbuf +01f0 cd0500 call bdos ;read command line + ; command line is present, scan it +01f3 210000 lxi h,0 ;start with 0000 +01f6 117c00 lxi d,conlin ;command line +01f9 1a readc: ldax d ;next command + ;character +01fa 13 inx d ;to next command + + + 5-47 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + + ;position +01fb b7 ora a ;cannot be end of + ;command +01fc c8 rz + ; not zero, numeric? +01fd d630 sui '0' +01ff fe0a cpi 10 ;carry if numeric +0201 d21300 jnc endrd + ; add-in next digit +0204 29 dad h ;*2 +0205 4d mov c,l +0206 44 mov b,h ;bc = value * 2 +0207 29 dad h ;*4 +0208 29 dad h ;*8 +0209 09 dad b ;*2 + *8 = *10 +020a 85 add l ;*digit +020b 6f mov l,a +020c d2f900 jnc readc ;for another char +020f24 inr h ;overflow +0210 c3f900 jmp readc ;for another char + endrd: + ; end of read, restore value in a +0213 c630 adi '0' ;command +0215 fe61 cpi 'a' ;translate case? +0217 d8 rc + ; lower case, mask lower case bits +0218 e65f ani 101$1111b +021a c9 ret + ; + + +W String Data Area for Console Messages + +&S badver: +021b 536f79 db 'sorry, you need cp/m version 2$' + nospace: +023a 4e6f29 db 'no directory space$' + datmsg: +024d 547970 db 'type data: $' + errmsg: +0259 457272 db 'error, try again.$' + prompt: +026b 4e6570 db 'next command? $' + ; + + +W Fixed and Variable Data Area + +&S027a 21 conbuf: db conlen ;length of console buffer +027b consiz: ds 1 ;resulting size after read +027c conlin: ds 32 ;length 32 buffer +0021 = conlen equ $-consiz + ; +029c ds 32 ;16 level stack + stack: +02bc end + + 5-48 + + + + 9 K0 + +CP/M Operating System Manual 5.5 Sample Random Access Program + + + + MMajor improvements could be made to this particular program to +XMenhance its operation. In fact, with some work, this program could +XMevolve into a simple data base management system. One could, for +XMexample, assume a standard record size of 128 bytes, consisting to +XMarbitrary fields within the record. A program, called GETKEY, could +XMbe developed that first reads a sequential file and extracts a +Xspecific field defined by the operator. For example, the command + + GETKEY NAMES.DAT LASTNAME 10 20 + +Mwould cause GETKEY to read the data base file NAMES.DAT and extract +XMthe LAST-NAME field from each record, starting in position 10 and +XMending at character 20. GETKEY builds a table in memory consisting +XMof each particular LASTNAME field, along with its 16-bit record +XMnumber location within the file. The GETKEY program then sorts this +XMlist and writes a new file, called LASTNAME.KEY, which is an +XMalphabetical list of LASTNAME fields with their corresponding record +XMnumbers. This list is called an inverted index in information +Xretrieval parlance. + + MIf the programmer were to rename the program shown above as +XMQUERY and modify it so that it reads a sorted key file into memory, +Xthe command line might appear as + + QUERY NAMES.DAT LASTNAME.KEY + +MInstead of reading a number, the QUERY program reads an alphanumeric +XMstring that is a particular key to find in the NAMES.DAT data base. +XMBecause the LASTNAME.KEY list is sorted, one can find a particular +XMentry rapidly by performing a binary search, similar to looking up a +XMname in the telephone book. Starting at both ends of the list, one +XMexamines the entry halfway in between and, if not matched, splits +XMeither the upper half or the lower half for the next search. You +XMwill quickly reach the item you are looking for and find the +XMcorresponding record number. You should fetch and display this +XMrecord at the console, just as was done in the program shown above. +X + MWith some more work, you can allow a fixed grouping size that +XMdiffers from the 128-byte record shown above. This is accomplished +XMby keeping track of the record number and the byte offset within the +XMrecord. Knowing the group size, you randomly access the record +XMcontaining the proper group, offset to the beginning of the group +XMwithin the record read sequentially until the group size has been +Xexhausted. + + MFinally, you can improve QUERY considerably by allowing boolean +XMexpressions, which compute the set of records that satisfy several +XMrelationships, such as a LASTNAME between HARDY and LAUREL and an +XMAGE lower than 45. Display all the records that fit this +XMdescription. Finally, if your lists are getting too big to fit into +Xmemory, randomly access key files from the disk as well. + + + + + + 5-49 + + + + + +CP/M Operating System Manual 5.6 System Function Summary + + +W5.6 System Function Summary + +F&Sunction Function Input Output +Number Name + +Decimal Hex + + 0 0 System Reset C = 00H none + 1 1 Console Input C = 01H A = ASCII char + 2 2 Console Output E = char none + 3 3 Reader Input A = ASCII char + 4 4 Punch Output E = char none + 5 5 List Output E = char none + 6 6 Direct Console I/O C = 06H A = char or status + + E = 0FFH (input) or (no value) + 0FEH (status) or + char (output) + 7 7 Get I/O Byte none A = I/O byte + Value + 8 8 Set I/O Byte E = I/O Byte none + 9 9 Print String DE = Buffer Address none +10 A Read Console Buffer DE = Buffer Console + Characters + in Buffer +11 B Get Console Status none A = 00/non zero +12 C Return Version Number none HL: Version + Number +13 D Reset Disk System none none +14 E Select Disk E = Disk Number none +15 F Open File DE = FCB Address FF if not found +16 10 Close File DE = FCB Address FF if not found +17 11 Search For First DE = FCB Address A = Directory + Code +18 12 Search For Next none A = Directory + Code +19 13 Delete File DE = FCB Address A = none +20 14 Read Sequential DE = FCB Address A = Error Code +21 15 Write Sequential DE = FCB Address A = Error Code +22 16 Make File DE = FCB Address A = FF if no DIR + Space +23 17 Rename File DE = FCB Address A = FF in not + found +24 18 Return Login Vector none HL = Login + Vector* +25 19 Return Current Disk none A = Current Disk + Number +26 1A Set DMA Address DE = DMA Address none +27 1B Get ADDR (ALLOC) none HL = ALLOC + Address* +28 1C Write Protect Disk none none +29 1D Get Read/only Vector none HL = R/O + Vector Value* +30 1E Set File Attributes DE = FCB Address A = none +31 1F Get ADDR (Disk Parms) none HL = DPB + + + 5-50 + + + + + +CP/M Operating System Manual 5.6 System Function Summary + + + Address +32 20 Set/Get User Code E = 0FFH for Get User Number + E = 00 to 0FH for Set +33 21 Read Random DE = FCB Address A = Error Code +34 22 Write Random DE = FCB Address A = Error Code +35 23 Compute File Size DE = FCB Address r0, r1, r2 +36 24 Set Random Record DE = FCB Address r0, r1, r2 +37 25 Reset Drive DE = Drive Vector A = 0 +38 26 Access Drive not supported +39 27 Free Drive not supported +40 28 Write Random with Fill DE = FCB A = Error Code + + + + +*Note that A = L, and B = H upon return. + + +=End of Section 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-51 + + + + + + + + +=WSection 6 + +=&SWCP/M 2 Alteration + + + +&SW6.1 Introduction + + MT&She standard CP/M system assumes operation on an Intel Model +XM800 microcomputer development system , but is designed so you can +XMalter a specific set of subroutines that define the hardware +Xoperating environment. + + MAlthough standard CP/M 2 is configured for single-density +XMfloppy disks, field-alteration features allow adaptation to a wide +XMvariety of disk subsystems from single-drive minidisks to high- +XMcapacity, hard disk systems. To simplify the following adaptation +XMprocess, it is assumed that CP/M 2 is first configured for single- +XMdensity floppy disks where minimal editing and debugging tools are +XMavailable. If an earlier version of CP/M is available, the +XMcustomizing process is eased considerably. In this latter case, you +XMmight want to review the system generation process and skip to later +XMsections that discuss system alteration for nonstandard disk +Xsystems. + + MTo achieve device independence, CP/M is separated into three +Xdistinct modules: + + o BIOS is the Basic I/O System, which is environment dependent. + + o MBDOS is the Basic Disk Operating System, which is not dependent +X upon the hardware configuration. + + o CCP is the Console Command Processor, which uses the BDOS. + + MOf these modules, only the BIOS is dependent upon the +XMparticular hardware. You can patch the distribution version of CP/M +XMto provide a new BIOS that provides a customized interface between +XMthe remaining CP/M modules and the hardware system. This document +XMprovides a step-by-step procedure for patching a new BIOS into CP/M. +X + MAll disk-dependent portions of CP/M 2 are placed into a BIOS, a +XMresident disk parameter block, which is either hand coded or +XMproduced automatically using the disk definition macro library +XMprovided with CP/M 2. The end user need only specify the maximum +XMnumber of active disks, the starting and ending sector numbers, the +XMdata allocation size, the maximum extent of the logical disk, +XMdirectory size information, and reserved track values. The macros +XMuse this information to generate the appropriate tables and table +XMreferences for use during CP/M 2 operation. Deblocking information +XMis provided, which aids in assembly or disassembly of sector sizes +XMthat are multiples of the fundamental 128-byte data unit, and the +XMsystem alteration manual includes general purpose subroutines that +XMuse the deblocking information to take advantage of larger sector +XMsizes. Use of these subroutines, together with the table-drive data +XMaccess algorithms, makes CP/M 2 a universal data management system. +X + + 6-1 + + + + +CP/M Operating System Manual 6.1 Introduction + + + MFile expansion is achieved by providing up to 512 logical file +XMextents, where each logical extent contains 16K bytes of data. CP/M +XM2 is structured, however, so that as much as 128K bytes of data are +XMaddressed by a single physical extent, corresponding to a single +XMdirectory entry, maintaining compatibility with previous versions +Xwhile taking advantage of directory space. + + MIf CP/M is being tailored to a computer system for the first +XMtime, the new BIOS requires some simple software development and +XMtesting. The standard BIOS is listed in Appendix A and can be used +XMas a model for the customized package. A skeletal version of the +XMBIOS given in Appendix B can serve as the basis for a modified BIOS. +X + MIn addition to the BIOS, you must write a simple memory loader, +XMcalled GETSYS, which brings the operating system into memory. To +XMpatch the new BIOS into CP/M, you must write the reverse of GETSYS, +XMcalled PUTSYS, which places an altered version of CP/M back onto the +XMdisk. PUTSYS can be derived from GETSYS by changing the disk read +XMcommands into disk write commands. Sample skeletal GETSYS and +XMPUTSYS programs are described in Section 6.4 and listed in Appendix +XC. + + MTo make the CP/M system load automatically, you must also +XMsupply a cold start loader, similar to the one provided with CP/M, +XMlisted in Appendixes A and D. A skeletal form of a cold start +XMloader is given in Appendix E, which serves as a model for the +Xloader. + + +W6.2 First-level System Regeneration + + MT&She procedure to patch the CP/M system is given below. Address +XMreferences in each step are shown with H denoting the hexadecimal +XMradix, and are given for a 20K CP/M system. For larger CP/M +XMsystems, a bias is added to each address that is shown with a +b +XMfollowing it, where b is equal to the memory size-20K. Values for b +Xin various standard memory sizes are listed in Table 6-1. + + +W Table 6-1. Standard Memory Size Values + + Memory Size Value + + 24K: b = 24K - 20K = 4K = 1000H + + 32K: b = 32K - 20K = 12K = 3000H + + 40K: b = 40K - 20K = 20K = 5000H + + 48K: b = 48K - 20K = 28K = 7000H + + 56K: b = 56K - 20K = 36K = 9000H + + 62K: b = 62K - 20K = 42K = A800H + + 64K: b = 64K - 20K = 44K = B000H + + + 6-2 + + + + +CP/M Operating System Manual 6.2 First-level Regeneration + + + MNote that the standard distribution version of CP/M is set for +XMoperation within a 20K CP/M system. Therefore, you must first bring +XMup the 20K CP/M system, then configure it for actual memory size +X(see Section 6.3). + + Follow these steps to patch your CP/M system: + + + 1) MRead Section 6.4 and write a GETSYS program that reads the +X Mfirst two tracks of a disk into memory. The program from +X Mthe disk must be loaded starting at location 3380H. GETSYS +X Mis coded to start at location 100H (base of the TPA) as +X shown in Appendix C. + + 2) MTest the GETSYS program by reading a blank disk into memory, +X Mand check to see that the data has been read properly and +X Mthat the disk has not been altered in any way by the GETSYS +X program. + + 3) MRun the GETSYS program using an initialized CP/M disk to see +X Mif GETSYS loads CP/M starting at 3380H (the operating +X system actually starts 128 bytes later at 3400H). + + 4) MRead Section 6.4 and write the PUTSYS program. This writes +X Mmemory starting at 3380H back onto the first two tracks of +X Mthe disk. The PUTSYS program should be located at 200H, as +X shown in Appendix C. + + 5) MTest the PUTSYS program using a blank, uninitialized disk by +X Mwriting a portion of memory to the first two tracks; clear +X Mmemory and read it back using GETSYS. Test PUTSYS +X Mcompletely, because this program will be used to alter CP/M +X on disk. + + 6) MStudy Sections 6.5, 6.6, and 6.7 along with the distribution +X Mversion of the BIOS given in Appendix A and write a simple +X Mversion that performs a similar function for the customized +X Menvironment. Use the program given in Appendix B as a +X Mmodel. Call this new BIOS by name CBIOS (customized BIOS). +X MImplement only the primitive disk operations on a single +X Mdrive and simple console input/output functions in this +X phase. + + 7) MTest CBIOS completely to ensure that it properly performs +X Mconsole character I/O and disk reads and writes. Be +X Mcareful to ensure that no disk write operations occur +X Mduring read operations and check that the proper track and +X Msectors are addressed on all reads and writes. Failure to +X Mmake these checks might cause destruction of the +X initialized CP/M system after it is patched. + + 8) MReferring to Table 6-3 in Section 6.5, note that the BIOS is +X Mplaced between locations 4A00H and 4FFFH. Read the CP/M +X Msystem using GETSYS and replace the BIOS segment by the +X MCBIOS developed in step 6 and tested in step 7. This +X replacement is done in memory. + + + 6-3 + + + + +CP/M Operating System Manual 6.2 First-level Regeneration + + + 9) MUse PUTSYS to place the patched memory image of CP/M onto +X the first two tracks of a blank disk for testing. + + 10) MUse GETSYS to bring the copied memory image from the test +X Mdisk back into memory at 3380H and check to ensure that it +X Mhas loaded back properly (clear memory, if possible, before +X Mthe load). Upon successful load, branch to the cold start +X Mcode at location 4A00H. The cold start routine initializes +X Mpage zero, then jumps to the CCP at location 3400H, which +X Mcalls the BDOS, which calls the CBIOS. The CCP asks the +X MCBIOS to read sixteen sectors on track 2, and CP/M types +X A>, the system prompt. + + MIf difficulties are encountered, use whatever debug +X Mfacilities are available to trace and breakpoint the CBIOS. +X + 11) MUpon completion of step 10, CP/M has prompted the console +X Mfor a command input. To test the disk write operation, +X type + + SAVE 1 X.COM + + MAll commands must be followed by a carriage return. CP/M +X responds with another prompt after several disk accesses: + + A> + + If it does not, debug the disk write functions and retry. + + 12) Test the directory command by typing + + DIR + + CP/M responds with + + A:X COM + + 13) Test the erase command by typing + + ERA X.COM + + MCP/M responds with the A prompt. This is now an +X Moperational system that only requires a bootstrap loader to +X function completely. + + 14) MWrite a bootstrap loader that is similar to GETSYS and place +X Mit on track 0, sector 1, using PUTSYS (again using the test +X Mdisk, not the distribution disk). See Sections 6.5 and 6.8 +X for more information on the bootstrap operation. + + 15) MRetest the new test disk with the bootstrap loader installed +X Mby executing steps 11, 12, and 13. Upon completion of +X Mthese tests, type a CTRL-C. The system executes a warm +X start, which reboots the system, and types the A prompt. + + + + 6-4 + + + + + +CP/M Operating System Manual 6.2 First-level Regeneration + + + 16) MAt this point, there is probably a good version of the +X Mcustomized CP/M system on the test disk. Use GETSYS to +X Mload CP/M from the test disk. Remove the test disk, place +X Mthe distribution disk, or a legal copy, into the drive, and +X Muse PUTSYS to replace the distribution version with the +X Mcustomized version. Do not make this replacement if you +X Mare unsure of the patch because this step destroys the +X system that was obtained from Digital Research. + + 17) Load the modified CP/M system and test it by typing + + DIR + + MCP/M responds with a list of files that are provided on the +X Minitialized disk. The file DDT.COM is the memory image for +X Mthe debugger. Note that from now on, you must always +X Mreboot the CP/M system (CTRL-C is sufficient) when the disk +X Mis removed and replaced by another disk, unless the new +X disk is to be Read-Only. + + 18) Load and test the debugger by typing + + DDT + + See Chapter 4 for operating procedures. + + 19) MBefore making further CBIOS modifications, practice using +X Mthe editor (see Chapter 2), and assembler (see Chapter 3). +X MRecode and test the GETSYS, PUTSYS, and CBIOS programs +X Musing ED, ASM, and DDT. Code and test a COPY program that +X Mdoes a sector-to-sector copy from one disk to another to +X Mobtain back-up copies of the original disk. Read the CP/M +X MLicensing Agreement specifying legal responsibilities when +X Mcopying the CP/M system. Place the following copyright +X notice: + + Copyright (c), 1983 + Digital Research + + on each copy that is made with the COPY program. + + 20) MModify the CBIOS to include the extra functions for punches, +X Mreaders, and sign-on messages, and add the facilities for +X Madditional disk drives, if desired. These changes can be +X Mmade with the GETSYS and PUTSYS programs or by referring to +X the regeneration process in Section 6.3. + + + MYou should now have a good copy of the customized CP/M system. +XMAlthough the CBIOS portion of CP/M belongs to the user, the modified +Xversion cannot be legally copied. + + MIt should be noted that the system remains file-compatible with +XMall other CP/M systems (assuming media compatibility) which allows +Xtransfer of nonproprietary software between CP/M users. + + + 6-5 + + + + + +CP/M Operating System Manual 6.3 Second-level System Generation + + +W6.3 Second-level System Generation + + MO&Snce the system is running, the next step is to configure CP/M +XMfor the desired memory size. Usually, a memory image is first +XMproduced with the MOVCPM program (system relocator) and then placed +XMinto a named disk file. The disk file can then be loaded, examined, +XMpatched, and replaced using the debugger and the system generation +Xprogram (refer to Chapter 1). + + MThe CBIOS and BOOT are modified using ED and assembled using +XMASM, producing files called CBIOS.HEX and BOOT.HEX, which contain +Xthe code for CBIOS and BOOT in Intel hex format. + + MTo get the memory image of CP/M into the TPA configured for the +Xdesired memory size, type the command: + + MOVCPM xx* + +Mwhere xx is the memory size in decimal K bytes, for example, 32 for +X32K. The response is as follows: + + CONSTRUCTING xxK CP/M VERS 2.0 + + READY FOR "SYSGEN" OR + + "SAVE 34 CPMxx.COM" + + MAn image of CP/M in the TPA is configured for the requested +XMmemory size. The memory image is at location 0900H through 227FH, +XMthat is, the BOOT is at 0900H, the CCP is at 980H, the BDOS starts +XMat 1180H, and the BIOS is at 1F80H. Note that the memory image has +XMthe standard Model 800 BIOS and BOOT on it. It is now necessary to +XMsave the memory image in a file so that you can patch the CBIOS and +XCBOOT into it: + + SAVE 34 CPMxx.COM + + MThe memory image created by the MOVCPM program is offset by a +XMnegative bias so that it loads into the free area of the TPA, and +XMthus does not interfere with the operation of CP/M in higher memory. +XMThis memory image can be subsequently loaded under DDT and examined +XMor changed in preparation for a new generation of the system. DDT +Xis loaded with the memory image by typing: + + DDT CPMxx.COM Loads DDT, then reads the CP/M image. + +DDT should respond with the following: + + NEXT PC + 2300 0100 + - The DDT prompt + +MYou can then give the display and disassembly commands to examine +XMportions of the memory image between 900H and 227FH. Note, however, +XMthat to find any particular address within the memory image, you + + + 6-M6 + + + +X + +CP/M Operating System Manual 6.3 Second-level System Generation + + +Mmust apply the negative bias to the CP/M address to find the actual +XMaddress. Track 00, sector 01, is loaded to location 900H (the user +XMshould find the cold start loader at 900H to 97FH); track 00, sector +XM02, is loaded into 980H (this is the base of the CCP); and so on +XMthrough the entire CP/M system load. In a 20K system, for example, +XMthe CCP resides at the CP/M address 3400H, but is placed into memory +XMat 980H by the SYSGEN program. Thus, the negative bias, denoted by +Xn, satisfies + + 3400H + n = 980H, or n =980H - 3400H + +MAssuming two's complement arithmetic, n = D580H, which can be +Xchecked by + + 3400H + D580H = 10980H = 0980H (ignoring high-order + overflow). + + Note that for larger systems, n satisfies + + (3400H+b) + n = 980H, or + n = 980H - (3400H + b), or + n = D580H - b + +The value of n for common CP/M systems is given below. + + +W Table 6-2. Common Values for CP/M Systems + + Memory Size BIAS b Negative Offset n + + 20K 0000H D580H - 0000H = D580H + 24K 1000H D580H - 1000H = C580H + 32K 3000H D580H - 3000H = A580H + 40K 5000H D580H - 5000H = 8580H + 48K 7000H D580H - 7000H = 6580H + 56K 9000H D580H - 9000H = 4580H + 62K A800H D580H - A800H = 2D80H + 64K B000H D580H - B000H = 2580H + + + MIf you want to locate the address x within the memory image +Xloaded under DDT in a 20K system, first type + + Hx,n Hexadecimal sum and difference + +Mand DDT responds with the value of x+n (sum) and x-n (difference). +XMThe first number printed by DDT is the actual memory address in the +XMimage where the data or code is located. For example, the following +XDDT command: + + H3400,D580 + +Mproduces 980H as the sum, which is where the CCP is located in the +Xmemory image under DDT. + + + + 6-7 + + + + + +CP/M Operating System Manual 6.3 Second-level System Generation + + + MType the L command to disassemble portions of the BIOS located +XMat (4A00H+b)-n, which, when one uses the H command, produces an +XMactual address of 1F80H. The disassembly command would thus be as +Xfollows: + + L1F80 + +MIt is now necessary to patch in the CBOOT and CBIOS routines. The +XMBOOT resides at location 0900H in the memory image. If the actual +XMload address is n, then to calculate the bias (m), type the command: +X + MH900,n Subtract load address from target address. +X + MThe second number typed by DDT in response to the command is +XMthe desired bias (m). For example, if the BOOT executes at 0080H, +Xthe command + + H900,80 + +produces + + 0980 0880 Sum and difference in hex. + +MTherefore, the bias m would be 0880H. To read-in the BOOT, give the +Xcommand: + + ICBOOT.HEX Input file CBOOT.HEX + +Then + + Rm Read CBOOT with a bias of m (=900H-n). + +Examine the CBOOT with + + L900 + +MYou are now ready to replace the CBIOS by examining the area at +XM1F80H, where the original version of the CBIOS resides, and then +Xtyping + + ICBIOS.HEX Ready the hex file for loading. + + MAssume that the CBIOS is being integrated into a 20K CP/M +XMsystem and thus originates at location 4A00H. To locate the CBIOS +XMproperly in the memory image under DDT, you must apply the negative +XMbias n for a 20K system when loading the hex file. This is +Xaccomplished by typing + + RD580 Read the file with bias D580H. + +MUpon completion of the read, reexamine the area where the CBIOS has +XMbeen loaded (use an L1F80 command) to ensure that it is properly +XMloaded. When you are satisfied that the change has been made, +Xreturn from DDT using a CTRL-C or, G0 command. + + + + 6-8 + + + + + +CP/M Operating System Manual 6.3 Second-level System Generation + + + MSYSGEN is used to replace the patched memory image back onto a +XMdisk (you use a test disk until sure of the patch) as shown in the +Xfollowing interaction: + + + SYSGEN Start the SYSGEN program. + + SYSGEN VERSION 2.0 Sign-on message from SYSGEN. + + SOURCE DRIVE NAME Respond with a carriage return + (OR RETURN TO SKIP) to skip the CP/M read operation + because the system is already + in memory. + + DESTINATION DRIVE NAME Respond with B to write the new + (OR RETURN TO REBOOT) system to the disk in drive B. + + + DESTINATION ON B, Place a scratch disk in drive + THEN TYPE RETURN B, then press RETURN. + + FUNCTION COMPLETE + DESTINATION DRIVE NAME + (OR RETURN TO REBOOT) + + + MPlace the scratch disk in drive A, then perform a cold start to +Xbring up the newly-configured CP/M system. + + MThe new CP/M system is then tested and the Digital Research +XMcopyright notice is placed on the disk, as specified in the +XLicensing Agreement: + + Copyright (c), 1979 + Digital Research + + +W6.4 Sample GETSYS and PUTSYS Programs + + MT&She following program provides a framework for the GETSYS and +XMPUTSYS programs referenced in Sections 6.1 and 6.2. To read and +XMwrite the specific sectors, you must insert the READSEC and WRITESEC +Xsubroutines. + + + + + + + + + + + + + + + 6-9 + + + + + +CP/M Operating System Manual 6.4 Sample GETSYS and PUTSYS + + +; GETSYS PROGRAM -- READ TRACKS 0 AND 1 TO MEMORY AT 3380H +; REGISTER USE + +; A (SCRATCH REGISTER) + +; B TRACK COUNT (0, 1) + +; C SECTOR COUNT (1,2,...,26) + +; DE (SCRATCH REGISTER PAIR) + +; HL LOAD ADDRESS + +; SP SET TO STACK ADDRESS + +; +START: LXI SP,3380H ;SET STACK POINTER TO SCRATCH + ;AREA + LXI H,3380H ;SET BASE LOAD ADDRESS + MVI B,0 ;START WITH TRACK 0 +RDTRK: ;READ NEXT TRACK (INITIALLY 0) + MVI C,1 ;READ STARTING WITH SECTOR 1 + +RDSEC: ;READ NEXT SECTOR + CALL READSEC ;USER-SUPPLIED SUBROUTINE + LXI D,128 ;MOVE LOAD ADDRESS TO NEXT 1/2 + ;PAGE + DAD D ;HL = HL + 128 + INR C ;SECTOR = SECTOR + 1 + MOV A,C ;CHECK FOR END OF TRACK + CPI 27 + JC RDSEC ;CARRY GENERATED IF SECTOR <27 + +; +; ARRIVE HERE AT END OF TRACK, MOVE TO NEXT TRACK + INR B + MOV A,B ;TEST FOR LAST TRACK + CPI 2 + JC RDTRK ;CARRY GENERATED IF TRACK <2 + +; +; USER-SUPPLIED SUBROUTINE TO READ THE DISK +READSEC: +; ENTER WITH TRACK NUMBER IN REGISTER B, + SECTOR NUMBER IN REGISTER C, AND + +; ADDRESS TO FILL IN HL + +; + PUSH B ;SAVE B AND C REGISTERS + PUSH H ;SAVE HL REGISTERS + + +W Listing 6-1. GETSYS Program + + + + 6-10 + + + + + +CP/M Operating System Manual 6.4 Sample GETSYS and PUTSYS + + + ................................................. + perform disk read at this point, branch to + label START if an error occurs + ................................................. + POP H ;RECOVER HL + POP B ;RECOVER B AND C REGISTERS + RET ;BACK TO MAIN PROGRAM + + END START + + +W Listing 6-1. (continued) + + + + MThis program is assembled and listed in Appendix B for +XMreference purposes, with an assumed origin of 100H. The hexadecimal +XMoperation codes that are listed on the left might be useful if the +Xprogram has to be entered through the panel switches. + + MThe PUTSYS program can be constructed from GETSYS by changing +XMonly a few operations in the GETSYS program given above, as shown in +XMAppendix C. The register pair HL becomes the dump address, next +XMaddress to write, and operations on these registers do not change +XMwithin the program. The READSEC subroutine is replaced by a +XMWRITESEC subroutine, which performs the opposite function; data from +XMaddress HL is written to the track given by register B and sector +XMgiven by register C. It is often useful to combine GETSYS and +XMPUTSYS into a single program during the test and development phase, +Xas shown in Appendix C. + + +W6.5 Disk Organization + + MT&She sector allocation for the standard distribution version of +XMCP/M is given here for reference purposes. The first sector +XMcontains an optional software boot section (see the table on the +XMfollowing page. Disk controllers are often set up to bring track +XM0, sector 1, into memory at a specific location, often location +XM0000H. The program in this sector, called BOOT, has the +XMresponsibility of bringing the remaining sectors into memory +XMstarting at location 3400H+b. If the controller does not have a +XMbuilt-in sector load, the program in track 0, sector 1 can be +XMignored. In this case, load the program from track 0, sector 2, to +Xlocation 3400H+b. + + MAs an example, the Intel Model 800 hardware cold start loader +XMbrings track 0, sector 1, into absolute address 3000H. Upon loading +XMthis sector, control transfers to location 3000H, where the +XMbootstrap operation commences by loading the remainder of track 0 +XMand all of track 1 into memory, starting at 3400H+b. Note that this +XMbootstrap loader is of little use in a non-microcomputer development +XMsystem environment, although it is useful to examine it because some +XMof the boot actions will have to be duplicated in the user's cold +Xstart loader. + + + 6-11 + + + + + +CP/M Operating System Manual 6.5 Disk Organization + + +W Table 6-3. CP/M Disk Sector Allocation + +Track # Sector Page# Memory Address CP/M Module name + + 00 01 (boot address) Cold Start Loader + 00 02 00 3400H+b CCP + ' 03 ' 3480H+b ' + ' 04 01 3500H+b ' + ' 05 ' 3580H+b ' + ' 06 02 3600H+b ' + ' 07 ' 3680H+b ' + ' 08 03 3700H+b ' + ' 09 ' 3780H+b ' + ' 10 04 3800H+b ' + ' 11 ' 3880H+b ' + ' 12 05 3900H+b ' + ' 13 ' 3980H+b ' + ' 14 06 3A00H+b ' + ' 15 ' 3A80H+b ' + ' 16 07 3B00H+b ' + 00 17 ' 3B80H+b CCP + 00 18 08 3C00H+b BDOS + ' 19 ' 3C80H+b ' + ' 20 09 3D00H+b ' + ' 21 ' 3D80H+b ' + ' 22 10 3E00H+b ' + ' 23 ' 3E80H+b ' + ' 24 11 3F00H+b ' + ' 25 ' 3F80H+b ' + ' 26 12 4000H+b ' + 01 01 ' 4080H+b ' + ' 02 13 4100H+b ' + ' 03 ' 4180H+B ' + ' 04 14 4200H+b ' + ' 05 ' 4280H+b ' + ' 06 15 4300H+b ' + ' 07 ' 4380H+b ' + ' 08 16 4400H+b ' + ' 09 ' 4480H+b ' + ' 10 17 4500H+b ' + ' 11 ' 4580H+b ' + ' 12 18 4600H+b ' + ' 13 ' 4680H+b ' + ' 14 19 4700H+b ' + ' 15 ' 4780H+b ' + ' 16 20 4800H+b ' + ' 17 ' 4880H+b ' + ' 18 21 4900H+b ' + 01 19 ' 4900H+b BDOS + 07 20 22 4A00H+b BIOS + ' 21 ' 4A80H+b ' + ' 22 23 4B00H+b ' + ' 23 ' 4B80H+b ' + ' 24 24 4C00H+b ' + 01 25 ' 4C80H+b BIOS + 01 26 25 4D00H+b BIOS +02-76 01-26 (directory and data) + + 6-12 + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + +W6.6 The BIOS Entry Points + + MT&She entry points into the BIOS from the cold start loader and +XMBDOS are detailed below. Entry to the BIOS is through a jump vector +XMlocated at 4A00H+b, as shown below. See Appendixes A and B. The +XMjump vector is a sequence of 17 jump instructions that send program +XMcontrol to the individual BIOS subroutines. The BIOS subroutines +XMmight be empty for certain functions (they might contain a single +XMRET operation) during reconfiguration of CP/M, but the entries must +Xbe present in the jump vector. + + MThe jump vector at 4A00H+b takes the form shown below, where +Xthe individual jump addresses are given to the left: + + + 4A00H+b JMP BOOT ;ARRIVE HERE FROM COLD + START LOAD + + 4A03H+b JMP WBOOT ;ARRIVE HERE FOR WARM START + + 4A06H+b JMP CONST ;CHECK FOR CONSOLE CHAR + READY + + 4A09H+b JMP CONIN ;READ CONSOLE CHARACTER IN + + 4A0CH+b JMP CONOUT ;WRITE CONSOLE CHARACTER + OUT + + 4A0FH+b JMP LIST ;WRITE LISTING CHARACTER OUT + + 4A12H+b JMP PUNCH ;WRITE CHARACTER TO PUNCH + DEVICE + + 4A15H+b JMP READER ;READ READER DEVICE + + 4A18H+b JMP HOME ;MOVE TO TRACK 00 ON + SELECTED DISK + + 4A1BH+b JMP SELDSK ;SELECT DISK DRIVE + + 4A1EH+b JMP SETTRK ;SET TRACK NUMBER + + 4A21H+b JMP SETSEC ;SET SECTOR NUMBER + + 4A24H+b JMP SETDMA ;SET DMA ADDRESS + + 4A27H+b JMP READ ;READ SELECTED SECTOR + + 4A2AH+b JMP WRITE ;WRITE SELECTED SECTOR + + 4A2DH+b JMP LISTST ;RETURN LIST STATUS + + 4A30H+b JMP SECTRAN ;SECTOR TRANSLATE + SUBROUTINE + + +W Listing 6-2. BIOS Entry Points + + 6-13 + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + + MEach jump address corresponds to a particular subroutine that +XMperforms the specific function, as outlined below. There are three +XMmajor divisions in the jump table: the system reinitialization, +XMwhich results from calls on BOOT and WBOOT; simple character I/O, +XMperformed by calls on CONST, CONIN, CONOUT, LIST, PUNCH, READER, and +XMLISTST; and disk I/O, performed by calls on HOME, SELDSK, SETTRK, +XSETSEC, SETDMA, READ, WRITE, and SECTRAN. + + MAll simple character I/O operations are assumed to be performed +XMin ASCII, upper- and lower-case, with high-order (parity bit) set to +XMzero. An end-of-file condition for an input device is given by an +XMASCII CTRL-Z (1AH). Peripheral devices are seen by CP/M as logical +Xdevices and are assigned to physical devices within the BIOS. + + MTo operate, the BDOS needs only the CONST, CONIN, and CONOUT +XMsubroutines. LIST, PUNCH, and READER can be used by PIP, but not +XMthe BDOS. Further, the LISTST entry is currently used only by +XMDESPOOL, the print spooling utility. Thus, the initial version of +XCBIOS can have empty subroutines for the remaining ASCII devices. + + MThe following list describes the characteristics of each +Xdevice. + + + o MCONSOLE is the principal interactive console that communicates +X Mwith the operator and it is accessed through CONST, CONIN, and +X MCONOUT. Typically, the CONSOLE is a device such as a CRT or +X teletype. + + o MLIST is the principal listing device. If it exists on the +X Muser's system, it is usually a hard-copy device, such as a +X printer or teletype. + + o MPUNCH is the principal tape punching device. If it exists, it +X is normally a high-speed paper tape punch or teletype. + + o MREADER is the principal tape reading device, such as a simple +X optical reader or teletype. + + + MA single peripheral can be assigned as the LIST, PUNCH, and +XMREADER device simultaneously. If no peripheral device is assigned +XMas the LIST, PUNCH, or READER device, the CBIOS gives an appropriate +XMerror message so that the system does not hang if the device is +XMaccessed by PIP or some other user program. Alternately, the PUNCH +XMand LIST routines can just simply return, and the READER routine can +XMreturn with a 1AH (CTRL-Z) in register A to indicate immediate end- +Xof-file. + + MFor added flexibility, you can optionally implement the IOBYTE +XMfunction, which allows reassignment of physical devices. The IOBYTE +XMfunction creates a mapping of logical-to-physical devices that can +XMbe altered during CP/M processing, see the STAT command in Section +X1.6.1. + + + + + 6-14 + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + MThe definition of the IOBYTE function corresponds to the Intel +XMstandard as follows: a single location in memory, currently +XMlocation 0003H, is maintained, called IOBYTE, which defines the +XMlogical-to-physical device mapping that is in effect at a particular +XMtime. The mapping is performed by splitting the IOBYTE into four +XMdistinct fields of two bits each, called the CONSOLE, READER, PUNCH, +Xand LIST fields, as shown in the following figure. + + + most significant least significant + + IOBYTE AT 003H LIST PUNCH READER CONSOLE + + bits 6,7 bits 4,5 bits 2,3 bits 0,1 + + +W Figure 6-1. IOBYTE Fields + + + + MThe value in each field can be in the range 0-3, defining the +XMassigned source or destination of each logical device. Table 6-4 +Xgives the values that can be assigned to each field. + + +W Table 6-4. IOBYTE Field Values + + Value Meaning + + CONSOLE field (bits 0,1) + + 0 console is assigned to the console printer + device (TTY:) + 1 console is assigned to the CRT device (CRT:) + 2 batch mode: use the READER as the CONSOLE input, + and the LIST device as the CONSOLE output (BAT:) + 3 user-defined console device (UC1:) + + READER field (bits 2,3) + + 0 READER is the teletype device (TTY:) + 1 READER is the high speed reader device (PTR:) + 2 user-defined reader #1 (UR1:) + 3 user-defined reader #2 (UR2:) + + PUNCH field (bits 4,5) + + 0 PUNCH is the teletype device (TTY:) + 1 PUNCH is the high speed punch device (PTP:) + 2 user-defined punch #1 (UP1:) + 3 user-defined punch #2 (UP2:) + + LIST field (bits 6,7) + + 0 LIST is the teletype device (TTY:) + 1 LIST is the CRT device (CRT:) + 2 LIST is the line printer device (LPT:) + 3 user-defined list device (UL1:) + + 6-15 + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + + MThe implementation of the IOBYTE is optional and effects only +XMthe organization of the CBIOS. No CP/M systems use the IOBYTE +XM(although they tolerate the existence of the IOBYTE at location +XM0003H) except for PIP, which allows access to the physical devices, +XMand STAT, which allows logical-physical assignments to be make or +XMdisplayed. For more information see Section 1. In any case the +XMIOBYTE implementation should be omitted until the basic CBIOS is +XMfully implemented and tested; then you should add the IOBYTE to +Xincrease the facilities. + + MDisk I/O is always performed through a sequence of calls on the +XMvarious disk access subroutines that set up the disk number to +XMaccess, the track and sector on a particular disk, and the Direct +XMMemory Access (DMA) address involved in the I/O operation. After +XMall these parameters have been set up, a call is made to the READ or +XWRITE function to perform the actual I/O operation. + + MThere is often a single call to SELDSK to select a disk drive, +XMfollowed by a number of read or write operations to the selected +XMdisk before selecting another drive for subsequent operations. +XMSimilarly, there might be a single call to set the DMA address, +XMfollowed by several calls that read or write from the selected DMA +XMaddress before the DMA address is changed. The track and sector +XMsubroutines are always called before the READ or WRITE operations +Xare performed. + + MThe READ and WRITE routines should perform several retries (10 +XMis standard) before reporting the error condition to the BDOS. If +XMthe error condition is returned to the BDOS, it reports the error to +XMthe user. The HOME subroutine might or might not actually perform +XMthe track 00 seek, depending upon controller characteristics; the +XMimportant point is that track 00 has been selected for the next +XMoperation and is often treated in exactly the same manner as SETTRK +Xwith a parameter of 00. + + MThe following table describes the exact responsibilities of +Xeach BIOS entry point subroutine. + + +W Table 6-5. BIOS Entry Points + + Entry Point Function + + 9 F0 BOOT MThe BOOT entry point gets control from the cold +X Mstart loader and is responsible for basic +X Msystem initialization, including sending a +X Msign-on message, which can be omitted in the +X Mfirst version. If the IOBYTE function is +X Mimplemented, it must be set at this point. The +X Mvarious system parameters that are set by the +X MWBOOT entry point must be initialized, and +X Mcontrol is transferred to the CCP at 3400+b for +X Mfurther processing. Note that register C must +X be set to zero to select drive A. + + + + 6-16 + + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + +W Table 6-5. (continued) + + Entry Point Function + + WBOOT MThe WBOOT entry point gets control when a warm +X Mstart occurs. A warm start is performed +X Mwhenever a user program branches to location +X M0000H, or when the CPU is reset from the front +X Mpanel. The CP/M system must be loaded from the +X Mfirst two tracks of drive A up to, but not +X Mincluding, the BIOS, or CBIOS, if the user has +X Mcompleted the patch. System parameters must be +X initialized as follows: + + location 0,1,2 MSet to JMP WBOOT for warm +X starts (000H: JMP 4A03H+b) + + location 3 MSet initial value of IOBYTE, +X if implemented in the CBIOS + + location 4 MHigh nibble = current user no; +X low nibble = current drive + + location 5,6,7 MSet to JMP BDOS, which is the +X Mprimary entry point to CP/M +X Mfor transient programs. +X (0005H: JMP 3C06H+b) + + MRefer to Section 6.9 for complete details of +X Mpage zero use. Upon completion of the +X Minitialization, the WBOOT program must branch +X Mto the CCP at 3400H+b to restart the system. +X MUpon entry to the CCP, register C is set to the +X Mdrive to select after system initialization. +X MThe WBOOT routine should read location 4 in +X Mmemory, verify that is a legal drive, and pass +X it to the CCP in register C. + + CONST MYou should sample the status of the currently +X Massigned console device and return 0FFH in +X Mregister A if a character is ready to read and +X M00H in register A if no console characters are +X ready. + + CONIN MThe next console character is read into +X Mregister A, and the parity bit is set, high- +X Morder bit, to zero. If no console character is +X Mready, wait until a character is typed before +X returning. + + + + + + + + + 6-17 + + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + +W Table 6-5. (continued) + + Entry Point Function + + CONOUT MThe character is sent from register C to the +X Mconsole output device. The character is in +X MASCII, with high-order parity bit set to zero. +X MYou might want to include a time-out on a line- +X Mfeed or carriage return, if the console device +X Mrequires some time interval at the end of the +X Mline (such as a TI Silent 700 terminal). You +X Mcan filter out control characters that cause +X Mthe console device to react in a strange way +X M(CTRL-Z causes the Lear-Seigler terminal to +X clear the screen, for example). + + LIST MThe character is sent from register C to the +X Mcurrently assigned listing device. The +X character is in ASCII with zero parity bit. + + PUNCH MThe character is sent from register C to the +X Mcurrently assigned punch device. The character +X is in ASCII with zero parity. + + READER MThe next character is read from the currently +X Massigned reader device into register A with +X Mzero parity (high-order bit must be zero); an +X Mend-of-file condition is reported by returning +X an ASCII CTRL-Z(1AH). + + HOME MThe disk head of the currently selected disk +X M(initially disk A) is moved to the track 00 +X Mposition. If the controller allows access to +X Mthe track 0 flag from the drive, the head is +X Mstepped until the track 0 flag is detected. If +X Mthe controller does not support this feature, +X Mthe HOME call is translated into a call to +X SETTRK with a parameter of 0. + + SELDSK MThe disk drive given by register C is selected +X Mfor further operations, where register C +X Mcontains 0 for drive A, 1 for drive B, and so +X Mon up to 15 for drive P (the standard CP/M +X Mdistribution version supports four drives). On +X Meach disk select, SELDSK must return in HL the +X Mbase address of a 16-byte area, called the Disk +X MParameter Header, described in Section 6.10. +X MFor standard floppy disk drives, the contents +X Mof the header and associated tables do not +X Mchange; thus, the program segment included in +X Mthe sample CBIOS performs this operation +X automatically. + + + + + + 6-18 + + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + +W Table 6-5. (continued) + + Entry Point Function + + MIf there is an attempt to select a nonexistent +X Mdrive, SELDSK returns HL=0000H as an error +X Mindicator. Although SELDSK must return the +X Mheader address on each call, it is advisable to +X Mpostpone the physical disk select operation +X Muntil an I/O function (seek, read, or write) is +X Mactually performed, because disk selects often +X Moccur without utimately performing any disk +X MI/O, and many controllers unload the head of +X Mthe current disk before selecting the new +X Mdrive. This causes an excessive amount of +X Mnoise and disk wear. The least significant bit +X Mof register E is zero if this is the first +X Moccurrence of the drive select since the last +X cold or warm start. + + SETTRK MRegister BC contains the track number for +X Msubsequent disk accesses on the currently +X Mselected drive. The sector number in BC is the +X Msame as the number returned from the SECTRAN +X Mentry point. You can choose to seek the +X Mselected track at this time or delay the seek +X Muntil the next read or write actually occurs. +X MRegister BC can take on values in the range 0- +X M76 corresponding to valid track numbers for +X Mstandard floppy disk drives and 0-65535 for +X nonstandard disk subsystems. + + SETSEC MRegister BC contains the sector number, 1 +X Mthrough 26, for subsequent disk accesses on the +X Mcurrently selected drive. The sector number in +X MBC is the same as the number returned from the +X MSECTRAN entry point. You can choose to send +X Mthis information to the controller at this +X Mpoint or delay sector selection until a read or +X write operation occurs. + + SETDMA MRegister BC contains the DMA (Disk Memory +X MAccess) address for subsequent read or write +X Moperations. For example, if B = 00H and C = +X M80H when SETDMA is called, all subsequent read +X Moperations read their data into 80H through +X M0FFH and all subsequent write operations get +X Mtheir data from 80H through 0FFH, until the +X Mnext call to SETDMA occurs. The initial DMA +X Maddress is assumed to be 80H. The controller +X Mneed not actually support Direct Memory Access. +X MIf, for example, all data transfers are through +X MI/O ports, the CBIOS that is constructed uses +X Mthe 128-byte area starting at the selected DMA +X Maddress for the memory buffer during the +X subsequent read or write operations. + + + 6-19 + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + +W Table 6-5. (continued) + + Entry Point Function + + READ MAssuming the drive has been selected, the track +X Mhas been set, and the DMA address has been +X Mspecified, the READ subroutine attempts to read +X Mone sector based upon these parameters and +X Mreturns the following error codes in register +X A: + + 0 no errors occurred + + 1 nonrecoverable error condition occurred + + MCurrently, CP/M responds only to a zero or +X Mnonzero value as the return code. That is, if +X Mthe value in register A is 0, CP/M assumes that +X Mthe disk operation was completed properly. IF +X Man error occurs the CBIOS should attempt at +X Mleast 10 retries to see if the error is +X Mrecoverable. When an error is reported the +X MBDOS prints the message BDOS ERR ONx: BAD +X MSECTOR. The operator then has the option of +X Mpressing a carriage return to ignore the error, +X or CTRL-C to abort. + + WRITE MData is written from the currently selected DMA +X Maddress to the currently selected drive, track, +X Mand sector. For floppy disks, the data should +X Mbe marked as nondeleted data to maintain +X Mcompatibility with other CP/M systems. The +X Merror codes given in the READ command are +X Mreturned in register A, with error recovery +X attempts as described above. + + LISTST MYou return the ready status of the list device +X Mused by the DESPOOL program to improve console +X Mresponse during its operation. The value 00 is +X Mreturned in A if the list device is not ready +X Mto accept a character and 0FFH if a character +X Mcan be sent to the printer. A 00 value should +X Mbe returned if LIST status is not implemented. +X + + + + + + + + + + + + + + 6-20 + + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + +W Table 6-5. (continued) + + Entry Point Function + + SECTRAN MLogical-to-physical sector translation is +X Mperformed to improve the overall response of +X MCP/M. Standard CP/M systems are shipped with a +X Mskew factor of 6, where six physical sectors +X Mare skipped between each logical read +X Moperation. This skew factor allows enough time +X Mbetween sectors for most programs to load their +X Mbuffers without missing the next sector. In +X Mparticular computer systems that use fast +X Mprocessors, memory, and disk subsystems, the +X Mskew factor might be changed to improve overall +X Mresponse. However, the user should maintain a +X Msingle-density IBM-compatible version of CP/M +X Mfor information transfer into and out of the +X computer system, using a skew factor of 6. + + MIn general, SECTRAN receives a logical sector +X Mnumber relative to zero in BC and a translate +X Mtable address in DE. The sector number is used +X Mas an index into the translate table, with the +X Mresulting physical sector number in HL. For +X Mstandard systems, the table and indexing code +X Mis provided in the CBIOS and need not be +X changed. + 9 K0 + +W6.7 A Sample BIOS + + MT&She program shown in Appendix B can serve as a basis for your +XMfirst BIOS. The simplest functions are assumed in this BIOS, so +XMthat you can enter it through a front panel, if absolutely +XMnecessary. You must alter and insert code into the subroutines for +XMCONST, CONIN, CONOUT, READ, WRITE, and WAITIO subroutines. Storage +XMis reserved for user-supplied code in these regions. The scratch +XMarea reserved in page zero (see Section 6.9) for the BIOS is used in +Xthis program, so that it could be implemented in ROM, if desired. + + MOnce operational, this skeletal version can be enhanced to +XMprint the initial sign-on message and perform better error recovery. +XMThe subroutines for LIST, PUNCH, and READER can be filled out and +Xthe IOBYTE function can be implemented. + + +W6.8 A Sample Cold Start Loader + + MT&She program shown in Appendix E can serve as a basis for a cold +XMstart loader. The disk read function must be supplied by the user, +XMand the program must be loaded somehow starting at location 0000. +XMSpace is reserved for the patch code so that the total amount of +Xstorage required for the cold start loader is 128 bytes. + + + + 6-21 + + + + + +CP/M Operating System Manual 6.8 A Sample Cold Start Loader + + + MEventually, you might want to get this loader onto the first +XMdisk sector (track 0, sector 1) and cause the controller to load it +XMinto memory automatically upon system start up. Alternatively, the +XMcold start loader can be placed into ROM, and above the CP/M system. +XMIn this case, it is necessary to originate the program at a higher +XMaddress and key in a jump instruction at system start up that +XMbranches to the loader. Subsequent warm starts do not require this +XMkey-in operation, because the entry point WBOOT gets control, thus +XMbringing the system in from disk automatically. The skeletal cold +XMstart loader has minimal error recovery, which might be enhanced in +Xlater versions. + + +W6.9 Reserved Locations in Page Zero + + MM&Sain memory page zero, between locations 00H and 0FFH, contains +XMseveral segments of code and data that are used during CP/M +XMprocessing. The code and data areas are given in the following +Xtable. + + +W Table 6-6. Reserved Locations in Page Zero + + Locations Contents + + 9 F0 000H-0002H MContains a jump instruction to the warm +X Mstart entry location 4A03H+b. This +X Mallows a simple programmed restart (JMP +X M0000H) or manual restart from the front +X panel. + + 0003H-0003H MContains the Intel standard IOBYTE is +X Moptionally included in the user's CBIOS +X (refer to Section 6.6). + + 0004H-0004H MCurrent default drive number +X (0=A,...,15=P). + + 0005H-0007H MContains a jump instruction to the BDOS +X Mand serves two purposes: JMP 0005H +X Mprovides the primary entry point to the +X MBDOS, as described in Chapter 5, and +X MLHLD 0006H brings the address field of +X Mthe instruction to the HL register +X Mpair. This value is the lowest address +X Min memory used by CP/M, assuming the +X MCCP is being overlaid. The DDT program +X Mchanges the address field to reflect +X Mthe reduced memory size in debug mode. +X + 0008H-0027H MInterrupt locations 1 through 5 not +X used. + + 0030H-0037H MInterrupt location 6 (not currently +X used) is reserved. + + + 6-22 + + + + + +CP/M Operating System Manual 6.9 Reserved Locations in Page Zero + + +W Table 6-6. (continued) + + Locations Contents + + 0038H-003AH MRestart 7; contains a jump instruction +X Minto the DDT or SID program when +X Mrunning in debug mode for programmed +X Mbreakpoints, but is not otherwise used +X by CP/M. + + 003BH-003FH Not currently used; reserved. + + 0040H-004FH MA 16-byte area reserved for scratch by +X MCBIOS, but is not used for any purpose +X in the distribution version of CP/M. + + 0050H-005BH Not currently used; reserved. + + 005CH-007CH MDefault File Control Block produced for +X a transient program by the CCP. + + 007DH-007FH MOptional default random record position. +X + 0080H-00FFH MDefault 128-byte disk buffer, also +X Mfilled with the command line when a +X transient is loaded under the CCP. + 9 K0 + + MThis information is set up for normal operation under the CP/M +XMsystem, but can be overwritten by a transient program if the BDOS +Xfacilities are not required by the transient. + + MIf, for example, a particular program performs only simple I/O +XMand must begin execution at location 0, it can first be loaded into +XMthe TPA, using normal CP/M facilities, with a small memory move +XMprogram that gets control when loaded. The memory move program must +XMget control from location 0100H, which is the assumed beginning of +XMall transient programs. The move program can then proceed to the +XMentire memory image down to location 0 and pass control to the +Xstarting address of the memory load. + + MIf the BIOS is overwritten or if location 0, containing the +XMwarm start entry point, is overwritten, the operator must bring the +XCP/M system back into memory with a cold start sequence. + + +W6.10 Disk Parameter Tables + + MT&Sables are included in the BIOS that describe the particular +XMcharacteristics of the disk subsystem used with CP/M. These tables +XMcan be either hand-coded, as shown in the sample CBIOS in Appendix +XMB, or automatically generated using the DISKDEF macro library, as +XMshown in Appendix F. The purpose here is to describe the elements +Xof these tables. + + + + + 6-23 + + + + +CP/M Operating System Manual 6.10 Disk Parameter Tables + + + + MIn general, each disk drive has an associated (16-byte) disk +XMparameter header that contains information about the disk drive and +XMprovides a scratch pad area for certain BDOS operations. The format +XMof the disk parameter header for each drive is shown in Figure 6-2, +Xwhere each element is a word (16-bit) value. + + + +XLT 0000 0000 0000 DIRBUF DPB CSV ALV +16b 16b 16b 16b 16b 16b 16b 16b + + +W Figure 6-2. Disk Parameter Header Format + + + + MThe meaning of each Disk Parameter Header (DPH) element is +Xdetailed in Table 6-7. + + +W Table 6-7. Disk Parameter Headers + + Disk Parameter Meaning + Header + 9 F0 + XLT MAddress of the logical-to-physical +X Mtranslation vector, if used for this +X Mparticular drive, or the value 0000H if no +X Msector translation takes place (that is, +X Mthe physical and logical sector numbers +X Mare the same). Disk drives with identical +X Msector skew factors share the same +X translate tables. + + 0000 MScratch pad values for use within the +X BDOS, initial value is unimportant. + + DIRBUF MAddress of a 128-byte scratch pad area for +X Mdirectory operations within BDOS. All +X DPHs address the same scratch pad area. + + DPB MAddress of a disk parameter block for this +X Mdrive. Drives with identical disk +X Mcharacteristics address the same disk +X parameter block. + + CSV MAddress of a scratch pad area used for +X Msoftware check for changed disks. This +X address is different for each DPH. + + ALV MAddress of a scratch pad area used by the +X MBDOS to keep disk storage allocation +X Minformation. This address is different +X for each DPH. + + + 6-24 + + + + 9 K0 + +CP/M Operating System Manual 6.10 Disk Parameter Tables + + + + MGiven n disk drives, the DPHs are arranged in a table whose +XMfirst row of 16 bytes corresponds to drive 0, with the last row +XMcorresponding to drive n-1. In the following figure the lable +XDPBASE defines the base address of the DPH table. + + + + DPBASE: + + 00 XLT 00 0000 0000 0000 DIRBUF DBP 00 CSV 00 ALV 00 + + 01 XLT 01 0000 0000 0000 DIRBUF DBP 01 CSV 01 ALV 01 + . + . + . + n-1 XLTn-1 0000 0000 0000 DIRBUF DBTn-1 CSVn-1 ALVn-1 + + +W Figure 6-3. Disk Parameter Header Table + + + + MA responsibility of the SELDSK subroutine is to return the base +XMaddress of the DPH for the selected drive. The following sequence +XMof operations returns the table address, with a 0000H returned if +Xthe selected drive does not exist. + + + NDISKS EQU 4 ;NUMBER OF DISK DRIVES + ..... + SELDSK: ;SELECT DISK GIVEN BY BC + LSI H,0000H ;ERROR CODE + MOV A,C ;DRIVE OK? + CPI NDISKS ;CY IF SO + RNC ;RET IF ERROR + ;NO ERROR, CONTINUE + MOV L,C ;LOW(DISK) + MOV H,B ;HIGH(DISK) + DAD H ;*2 + DAD H ;*4 + DAD H ;*8 + DAD H ;*16 + LXI D,DPBASE;FIRST DPH + DAD D ;DPH(DISK) + RET + + + MThe translation vectors, XLT 00 through XLTn-1, are located +XMelsewhere in the BIOS, and simply correspond one-for-one with the +XMlogical sector numbers zero through the sector count 1. The Disk +XMParameter Block (DPB) for each drive is more complex. As shown in +XMFigure 6-4, particular DPB, that is addressed by one or more DPHs, +Xtakes the general form: + + + + 6-25 + + + + + +CP/M Operating System Manual 6.10 Disk Parameter Tables + + + SPT BSH BLM EXM DSM DRM AL0 AL1 CKS 0FF + 16b 8b 8b 8b 16b 16b 8b 8b 16b 16b + + +W Figure 6-4. Disk Parameter Block Format + + + +Mwhere each is a byte or word value, as shown by the 8b or 16b +Xindicator below the field. + + The following field abbreviations are used in Figure 6-4: + + + o SPT is the total number of sectors per track. + + o MBSH is the data allocation block shift factor, determined by +X the data block allocation size. + + o BLM is the data allocation block mask (2[BSH-1]). + + o MEXM is the extent mask, determined by the data block allocation +X size and the number of disk blocks. + + o DSM determines the total storage capacity of the disk drive. + + o MDRM determines the total number of directory entries that can +X Mbe stored on this drive. AL0, AL1 determine reserved directory +X blocks. + + o CKS is the size of the directory check vector. + + o M0FF is the number of reserved tracks at the beginning of the +X (logical) disk. + +MThe values of BSH and BLM determine the data allocation size BLS, +XMwhich is not an entry in the DPB. Given that the designer has +XMselected a value for BLS, the values of BSH and BLM are shown Table +X6-8. + + +W Table 6-8. BSH and BLM Values + + BLS BSH BLM + + 1024 3 7 + 2048 4 15 + 4096 5 31 + 8192 6 63 + 16,384 7 127 + + +Mwhere all values are in decimal. The value of EXM depends upon both +XMthe BLS and whether the DSM value is less than 256 or greater than +X255, as shown in Table 6-9. + + + 6-26 + + + + + +CP/M Operating System Manual 6.10 Disk Parameter Tables + + +W Table 6-9. EXM Values + + BLS EXM values + + DSM<256 DSM>255 + + 1024 0 N/A + 2048 1 0 + 4096 3 1 + 8192 7 3 + 16,384 15 7 + + + MThe value of DSM is the maximum data block number supported by +XMthis particular drive, measured in BLS units. The product (DSM+1) +XMis the total number of bytes held by the drive and must be within +XMthe capacity of the physical disk, not counting the reserved +Xoperating system tracks. + + MThe DRM entry is the one less than the total number of +XMdirectory entries that can take on a 16-bit value. The values of +XMAL0 and AL1, however, are determined by DRM. The values AL0 and AL1 +XMcan together be considered a string of 16-bits, as shown in Figure +X6-5. + + + + AL0 AL1 + + 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 + + +W Figure 6-5. AL0 and AL1 + + + + MPosition 00 corresponds to the high-order bit of the byte +XMlabeled AL0 and 15 corresponds to the low-order bit of the byte +XMlabeled AL1. Each bit position reserves a data block for number of +XMdirectory entries, thus allowing a total of 16 data blocks to be +XMassigned for directory entries (bits are assigned starting at 00 and +XMfilled to the right until position 15). Each directory entry +Xoccupies 32 bytes, resulting in the following tabulation: + + +W Table 6-10. BLS Tabulation + + BLS Directory Entries + + 1024 32 times # bits + 2048 64 times # bits + 4096 128 times # bits + 8192 256 times # bits + 16,384 512 times # bits + + + + 6-27 + + + + + +CP/M Operating System Manual 6.10 Disk Parameter Tables + + + + MThus, if DRM = 127 (128 directory entries) and BLS = 1024, +XMthere are 32 directory entries per block, requiring 4 reserved +XMblocks. In this case, the 4 high-order bits of AL0 are set, +Xresulting in the values AL0 = 0F0H and AL1 = 00H. + + MThe CKS value is determined as follows: if the disk drive +XMmedia is removable, then CKS = (DRM+1)/4, where DRM is the last +XMdirectory entry number. If the media are fixed, then set CKS = 0 +X(no directory records are checked in this case). + + MFinally, the 0FF field determines the number of tracks that are +XMskipped at the beginning of the physical disk. This value is +XMautomatically added whenever SETTRK is called and can be used as a +XMmechanism for skipping reserved operating system tracks or for +Xpartitioning a large disk into smaller segmented sections. + + MTo complete the discussion of the DPB, several DPHs can address +XMthe same DPB if their drive characteristics are identical. Further, +XMthe DPB can be dynamically changed when a new drive is addressed by +XMsimply changing the pointer in the DPH; because the BDOS copies the +XMDPB values to a local area whenever the SELDSK function is invoked. +X + MReturning back to DPH for a particular drive, the two address +XMvalues CSV and ALV remain. Both addresses reference an area of +XMuninitialized memory following the BIOS. The areas must be unique +XMfor each drive, and the size of each area is determined by the +Xvalues in the DPB. + + MThe size of the area addressed by CSV is CKS bytes, which is +XMsufficient to hold the directory check information for this +XMparticular drive, If CKS = (DRM+1)/4, you must reserve (DRM+1)/4 +XMbytes for directory check use. If CKS = 0, no storage is reserved. +X + MThe size of the area addressed by ALV is determined by the +XMmaximum number of data blocks allowed for this particular disk and +Xis computed as (DSM/8)+1. + + MThe CBIOS shown in Appendix B demonstrates an instance of these +XMtables for standard 8-inch, single-density drives. It might be +XMuseful to examine this program and compare the tabular values with +Xthe definitions given above. + + +W6.11 The DISKDEF Macro Library + + MA&S macro library called DISKDEF (shown in Appendix F), greatly +XMsimplifies the table construction process. You must have access to +XMthe MAC macro assembler, of course, to use the DISKDEF facility, +XMwhile the macro library is included with all CP.M 2 distribution +Xdisks. + + + + + + + 6-28 + + + + + +CP/M Operating System Manual 6.11 The DISKDEF Macro Library + + + + MA BIOS disk definition consists of the following sequence of +Xmacro statements: + + MACLIB DISKDEF + ..... + DISKS n + DISKDEF 0,... + DISKDEF 1,... + ..... + DISKDEF n-1 + ..... + ENDEF + +Mwhere the MACLIB statement loads the DISKDEF.LIB file, on the same +XMdisk as the BIOS, into MAC's internal tables. The DISKS macro call +XMfollows, which specifies the number of drives to be configured with +XMthe user's system, where n is an integer in the range 1 to 16. A +XMseries of DISKDEF macro calls then follow that define the +XMcharacteristics of each logical disk, 0 through n-1, corresponding +XMto logical drives A through P. The DISKS and DISKDEF macros +XMgenerate the in-line fixed data tables described in the previous +XMsection and thus must be placed in a nonexecutable portion of the +XBIOS, typically directly following the BIOS jump vector. + + MThe remaining portion of the BIOS is defined following the +XMDISKDEF macros, with the ENDEF macro call immediately preceding the +XMEND statement. The ENDEF (End of Diskdef) macro generates the +XMnecessary uninitialized RAM areas that are located in memory above +Xthe BIOS. + + The DISKDEF macro call takes the form: + + DISKDEF dn,fsc,lsc,[skf],bls dks,dir,cks,ofs,[0] + +where + + o dn is the logical disk number, 0 to n-1. + o fsc is the first physical sector number (0 or 1). + o lsc is the last sector number. + o skf is the optional sector skew factor. + o bls is the data allocation block size. + o dks is the number of blocks on the disk. + o dir is the number of directory entries. + o cks is the number of checked directory entries. + o ofs is the track offset to logical track 00. + o [0] is an optional 1.4 compatibility flag. + + + MThe value dn is the drive number being defined with this +XMDISKDEF macro invocation. The fsc parameter accounts for differing +XMsector numbering systems and is usually 0 to 1. The lsc is the last +XMnumbered sector on a track. When present, the skf parameter defines +XMthe sector skew factor, which is used to create a sector translation +Xtable according to the skew. + + + 6-29 + + + + + +CP/M Operating System Manual 6.11 The DISKDEF Macro Library + + + + MIf the number of sectors is less than 256, a single-byte table +XMis created, otherwise each translation table element occupies two +XMbytes. No translation table is created if the skf parameter is +Xomitted, or equal to 0. + + MThe bls parameter specifies the number of bytes allocated to +XMeach data block, and takes on the values 1024, 2048, 4096, 8192, or +XM16384. Generally, performance increases with larger data block +XMsizes because there are fewer directory references, and logically +XMconnected data records are physically close on the disk. Further, +XMeach directory entry addresses more data and the BIOS-resident RAM +Xspace is reduced. + + MThe dks parameter specifies the total disk size in bls units. +XMThat is, if the bls = 2048 and dks = 1000, the total disk capacity +XMis 2,048,000 bytes. If dks is greater than 255, the block size +XMparameter bls must be greater than 1024. The value of dir is the +XMtotal number of directory entries that might exceed 255, if desired. +X + MThe cks parameter determines the number of directory items to +XMcheck on each directory scan and is used internally to detect +XMchanged disks during system operation, where an intervening cold or +XMwarm start has not occurred. When this situation is detected, CP/M +XMautomatically marks the disk Read-Only so that data is not +Xsubsequently destroyed. + + MAs stated in the previous section, the value of cks = dir when +XMthe medium is easily changed, as is the case with a floppy disk +XMsubsystem. If the disk is permanently mounted, the value of cks is +XMtypically 0, because the probability of changing disks without a +Xrestart is low. + + MThe ofs value determines the number of tracks to skip when this +XMparticular drive is addressed, which can be used to reserve +XMadditional operating system space or to simulate several logical +XMdrives on a single large capacity physical drive. Finally, the [0] +XMparameter is included when file compatibility is required with +XMversions of 1.4 that have been modified for higher density disks. +XMThis parameter ensures that only 16K is allocated for each directory +XMrecord, as was the case for previous versions. Normally, this +Xparameter is not included. + + For convenience and economy of table space, the special form: + + DISKDEF i,j + +Mgives disk i the same characteristics as a previously defined drive +XMj. A standard four-drive, single-density system, which is +XMcompatible with version 1.4, is defined using the following macro +Xinvocations: + + DISKS 4 + DISKDEF 0,1,26,6,1024,243,64,2 + DISKDEF 1,0 + + + 6-30 + + + + + +CP/M Operating System Manual 6.11 The DISKDEF Macro Library + + + DISKDEF 2,0 + DISKDEF 3,0 + .... + ENDEF + +Mwith all disks having the same parameter values of 26 sectors per +XMtrack, numbered 1 through 26, with 6 sectors skipped between each +XMaccess, 1024 bytes per data block, 243 data blocks for a total of +XM243K-byte disk capacity, 64 checked directory entries, and two +Xoperating system tracks. + + MThe DISKS macro generates n DPHs, starting at the DPH table +XMaddress DPBASE generated by the macro. Each disk header block +XMcontains sixteen bytes, as described above, and correspond one-for- +XMone to each of the defined drives. In the four-drive standard +Xsystem, for example, the DISKS macro generates a table of the form: + + DPBASE EQU$ + DPE0: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV0,ALV0 + DPE1: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV1,ALV1 + DPE2: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV2,ALV2 + DPE3: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV3,ALV3 + +Mwhere the DPH labels are included for reference purposes to show the +XMbeginning table addresses for each drive 0 through 3. The values +XMcontained within the DPH are described in detail in the previous +XMsection. The check and allocation vector addresses are generated by +XMthe ENDEF macro in the ram area following the BIOS code and tables. +X + MNote that if the skf (skew factor) parameter is omitted, or +XMequal to 0, the translation table is omitted and a 0000H value is +XMinserted in the XLT position of the DPH for the disk. In a +XMsubsequent call to perform the logical-to-physical translation, +XMSECTRAN receives a translation table address of DE = 0000H and +XMsimply returns the original logical sector from BC in the HL +Xregister pair. + + MA translate table is constructed when the skf parameter is +XMpresent, and the (nonzero) table address is placed into the +XMcorresponding DPHs. The following for example, is constructed when +XMthe standard skew factor skf = 6 is specified in the DISKDEF macro +Xcall: + + XLT0: DB 1,7,13,19,25,5,11,17,23,3,9,15,21 + DB 2,8,14,20,26,6,12,18,24,4,10,16,22 + + MFollowing the ENDEF macro call, a number of uninitialized data +XMareas are defined. These data areas need not be a part of the BIOS +XMthat is loaded upon cold start, but must be available between the +XMBIOS and the end of memory. The size of the uninitialized RAM area +XMis determined by EQU statements generated by the ENDEF macro. For a +XMstandard four-drive system, the ENDEF macro might produce the +Xfollowing EQU statement: + + + + + 6-31 + + + + + +CP/M Operating System Manual 6.11 The DISKDEF Macro Library + + + 4C72 = BEGDAT EQU $ + (data areas) + + 4DB0 = ENDDAT EQU $ + + 013C = DATSIZ EQU $-BEGDAT + +Mwhich indicates that uninitialized RAM begins at location 4C72H, +XMends at 4DB0H-1, and occupies 013CH bytes. You must ensure that +Xthese addresses are free for use after the system is loaded. + + MAfter modification, you can use the STAT program to check drive +XMcharacteristics, because STAT uses the disk parameter block to +Xdecode the drive information. A STAT command of the form: + + STAT d:DSK: + +Mdecodes the disk parameter block for drive d (d=A,...,P) and +Xdisplays the following values: + + + r: 128-byte record capacity + k: kilobyte drive capacity + d: 32-byte directory entries + c: checked directory entries + e: records/extent + b: records/block + s: sectors/track + t: reserved tracks + + + MThree examples of DISKDEF macro invocations are shown below +XMwith corresponding STAT parameter values. The last example produces +Xa full 8-megabyte system. + + DISKDEF 0,1,58,,2048,256,128,128,2 + r=4096, k=512, d=128, c=128, e=256, b=16, s=58, t=2 + + DISKDEF 0,1,58,,2048,1024,300,0,2 + r=16348, k=2048, d=300, c=0, e=128, b=16, s=58, t=2 + + DISKDEF 0,1,58,,16348,512,128,128,2 + r=65536, k=8192, d=128, c=128, e=1024, b=128, s=58, t=2 + + +W6.12 Sector Blocking and Deblocking + + MU&Spon each call to BIOS WRITE entry point, the CP/M BDOS +XMincludes information that allows effective sector blocking and +XMdeblocking where the host disk subsystem has a sector size that is a +XMmultiple of the basic 128-byte unit. The purpose here is to present +XMa general-purpose algorithm that can be included within the BIOS and +XMthat uses the BDOS information to perform the operations +Xautomatically. + + + + 6-32 + + + + + +CP/M Operating System Manual 6.12 Blocking and Deblocking + + + MOn each call to WRITE, the BDOS provides the following +Xinformation in register C: + + 0 = (normal sector write) + 1 = (write to directory sector) + 2 = (write to the first sector + of a new data block) + + MCondition 0 occurs whenever the next write operation is into a +XMpreviously written area, such as a random mode record update; when +XMthe write is to other than the first sector of an unallocated block; +XMor when the write is not into the directory area. Condition 1 +XMoccurs when a write into the directory area is performed. Condition +XM2 occurs when the first record (only) of a newly allocated data +XMblock is written. In most cases, application programs read or write +XMmultiple 128-byte sectors in sequence; thus, there is little +XMoverhead involved in either operation when blocking and deblocking +XMrecords, because preread operations can be avoided when writing +Xrecords. + + MAppendix G lists the blocking and deblocking algorithms in +XMskeletal form; this file is included on your CP/M disk. Generally, +XMthe algorithms map all CP/M sector read operations onto the host +XMdisk through an intermediate buffer that is the size of the host +XMdisk sector. Throughout the program, values and variables that +XMrelate to the CP/M sector involved in a seek operation are prefixed +XMby sek, while those related to the host disk system are prefixed by +XMhst. The equate statements beginning on line 29 of Appendix G +XMdefine the mapping between CP/M and the host system, and must be +Xchanged if other than the sample host system is involved. + + MThe entry points BOOT and WBOOT must contain the initialization +XMcode starting on line 57, while the SELDSK entry point must be +XMaugmented by the code starting on line 65. Note that although the +XMSELDSK entry point computes and returns the Disk Parameter Header +XMaddress, it does not physically select the host disk at this point +XM(it is selected later at READHST or WRITEHST). Further, SETTRK, +XMSETTRK, and SETMA simply store the values, but do not take any other +XMaction at this point. SECTRAN performs a trivial function of +Xreturning the physical sector number. + + MThe principal entry points are READ and WRITE, starting on +XMlines 110 and 125, respectively. These subroutines take the place +Xof your previous READ and WRITE operations. + + MThe actual physical read or write takes place at either +XMWRITEHST or READHST, where all values have been prepared: hstdsk is +XMthe host disk number, hsttrk is the host track number, and hstsec is +XMthe host sector number, which may require translation to physical +XMsector number. You must insert code at this point that performs the +XMfull sector read or write into or out of the buffer at hstbuf of +XMlength hstsiz. All other mapping functions are performed by the +Xalgorithms. + + + + + 6-33 + + + + + +CP/M Operating System Manual 6.12 Blocking and Deblocking + + + MThis particular algorithm was tested using an 80-megabyte hard +XMdisk unit that was originally configured for 128-byte sectors, +XMproducing approximately 35 megabytes of formatted storage. When +XMconfigured for 512-byte host sectors, usable storage increased to 57 +XMmegabytes, with a corresponding 400% improvement in overall +XMresponse. In this situation, there is no apparent overhead involved +XMin deblocking sectors, with the advantage that user programs still +XMmaintain 128-byte sectors. This is primarily because of the +XMinformation provided by the BDOS, which eliminates the necessity for +Xpreread operations. + + +=End of Section 6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6-34 + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/part1.tex b/Source/Doc/CPM 22 Manual - Testing/part1.tex new file mode 100644 index 00000000..7e98c4ef --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/part1.tex @@ -0,0 +1,2 @@ +.nx front + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/part1.txt b/Source/Doc/CPM 22 Manual - Testing/part1.txt new file mode 100644 index 00000000..e30fd5c9 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/part1.txt @@ -0,0 +1,13350 @@ + N + + + + + + + + + + + + + + + + + + + + + +CP/M + +Operating System + +Manual + + + + + + + + + + +Copyright (c) 1982 + +Digital Research +P.O. Box 579 +160 Central Avenue +Pacific Grove, CA 93950 +(408) 649-3896 +TWX 910 360 5001 + + + + +All Rights Reserved + + + + + + + + + + + + + + + + + +C + + + + + + +COPYRIGHT + +Copyright (c) 1976, 1977, 1978, 1979, 1982, 1983, +and 1984 by Digital Research Inc. All rights +reserved. No part of this publication may be +reproduced, transmitted, transcribed, stored in a +retrieval system, or translated into any language or +computer language, in any form or by any means, +electronic, mechanical, magnetic, optical, chemical, +manual or otherwise, without the prior written +permission of Digital Research Inc., Post Office Box +579, Pacific Grove, California, 93950. + +Thus, readers are granted permission to include the +example programs, either in whole or in part, in +their own programs. + + +DISCLAIMER + +Digital Research Inc. makes no representations or +warranties with respect to the contents hereof and +specifically disclaims any implied warranties of +merchantability or fitness for any particular +purpose. Further, Digital Research Inc. reserves +the right to revise this publication and to make +changes from time to time in the content hereof +without obligation of Digital Research Inc. to +notify any person of such revision or changes. + + +TRADEMARKS + +CP/M, CP/NET, and Digital Research and its logo are +registered trademarks of Digital Research. ASM, +DESPOOL, DDT, LINK-80, MAC, MP/M, PL/I-80 and SID +are trademarks of Digital Research. IBM is a +registered trademark of International Business +Machines. Intel is a registered trademark of Intel +Corporation. TI Silent 700 is a trademark of Texas +Instruments Incorporated. Zilog and Z80 are +registered trademarks of Zilog, Inc. + + + +The CP/M Operating System Manual was prepared using +the Digital Research TEX Text Formatter and printed +in the United States of America. + + +********************************* +* First Edition: 1976 * +* Second Edition: July 1982 * +* Third Edition: March 1983 * +* Fourth Edition: March 1984 * +********************************* + + + + + K + + + + + +Table of Contents + + + +1 CP/M Features and Facilities + + 1.1 Introduction . . . . . . . . . . . . . . . . . . . 1-1 + + 1.2 Functional Description . . . . . . . . . . . . . . 1-3 + + 1.2.1 General Command Structure . . . . . . . . . 1-3 + 1.2.2 File References . . . . . . . . . . . . . . 1-3 + + 1.3 Switching Disks . . . . . . . . . . . . . . . . . . 1-5 + 1.4 Built-in Commands . . . . . . . . . . . . . . . . . 1-6 + + 1.4.1 ERA Command . . . . . . . . . . . . . . . . 1-6 + 1.4.2 DIR Command . . . . . . . . . . . . . . . . 1-7 + 1.4.3 REN Command . . . . . . . . . . . . . . . . 1-8 + 1.4.4 SAVE Command . . . . . . . . . . . . . . . . 1-8 + 1.4.5 TYPE Command . . . . . . . . . . . . . . . . 1-9 + 1.4.6 USER Command . . . . . . . . . . . . . . . . 1-9 + + 1.5 Line Editing and Output Control . . . . . . . . . . 1-10 + + 1.6 Transient Commands . . . . . . . . . . . . . . . . 1-11 + + 1.6.1 STAT Command . . . . . . . . . . . . . . . . 1-12 + 1.6.2 ASM Command . . . . . . . . . . . . . . . . 1-18 + 1.6.3 LOAD Command . . . . . . . . . . . . . . . . 1-19 + 1.6.4 PIP . . . . . . . . . . . . . . . . . . . . 1-20 + 1.6.5 ED Command . . . . . . . . . . . . . . . . . 1-29 + 1.6.6 SYSGEN Command . . . . . . . . . . . . . . . 1-31 + 1.6.7 SUBMIT Command . . . . . . . . . . . . . . . 1-33 + 1.6.8 DUMP Command . . . . . . . . . . . . . . . . 1-35 + 1.6.9 MOVCPM Command . . . . . . . . . . . . . . . 1-35 + + 1.7 BDOS Error Messages . . . . . . . . . . . . . . . . 1-37 + + 1.8 CP/M Operation on the Model 800 . . . . . . . . . . 1-38 + + +2 The CP/M Editor + + 2.1 Introduction to ED . . . . . . . . . . . . . . . . 2-1 + + 2.1.1 ED Operation . . . . . . . . . . . . . . . . 2-1 + 2.1.2 Text Transfer Functions . . . . . . . . . . 2-3 + 2.1.3 Memory Buffer Organization . . . . . . . . . 2-4 + 2.1.4 Line Numbers and ED Start-up . . . . . . . . 2-5 + 2.1.5 Memory Buffer Operation . . . . . . . . . . 2-6 + 2.1.6 Command Strings . . . . . . . . . . . . . . 2-7 + 2.1.7 Text Search and Alteration . . . . . . . . . 2-10 + 2.1.8 Source Libraries . . . . . . . . . . . . . . 2-13 + 2.1.9 Repetitive Command Execution . . . . . . . . 2-14 + + + iii + + + + + + + + +Table of Contents + +(continued) + + + + 2.2 ED Error Conditions . . . . . . . . . . . . . . . . 2-14 + + 2.3 Control Characters and Commands . . . . . . . . . . 2-16 + + +3 CP/M Assembler + + 3.1 Introduction . . . . . . . . . . . . . . . . . . . 3-1 + + 3.2 Program Format . . . . . . . . . . . . . . . . . . 3-3 + + 3.3 Forming the Operand . . . . . . . . . . . . . . . . 3-4 + + 3.3.1 Labels . . . . . . . . . . . . . . . . . . . 3-4 + 3.3.2 Numeric Constants . . . . . . . . . . . . . 3-5 + 3.3.3 Reserved Words . . . . . . . . . . . . . . . 3-5 + 3.3.4 String Constants . . . . . . . . . . . . . . 3-6 + 3.3.5 Arithmetic and Logical Operators . . . . . . 3-7 + 3.3.6 Precedence of Operators . . . . . . . . . . 3-8 + + 3.4 Assembler Directives . . . . . . . . . . . . . . . 3-9 + + 3.4.1 The ORG Directive . . . . . . . . . . . . . 3-10 + 3.4.2 The END Directive . . . . . . . . . . . . . 3-10 + 3.4.3 The EQU Directive . . . . . . . . . . . . . 3-11 + 3.4.4 The SET Directive . . . . . . . . . . . . . 3-11 + 3.4.5 The IF and ENDIF Directives . . . . . . . . 3-12 + 3.4.6 The DB Directive . . . . . . . . . . . . . . 3-13 + 3.4.7 The DW Directive . . . . . . . . . . . . . . 3-14 + 3.4.8 The DS Directive . . . . . . . . . . . . . . 3-14 + + 3.5 Operation Codes . . . . . . . . . . . . . . . . . . 3-15 + + 3.5.1 Jumps, Calls, and Returns . . . . . . . . . 3-15 + 3.5.2 Immediate Operand Instructions . . . . . . . 3-17 + 3.5.3 Increment and Decrement Instructions . . . . 3-17 + 3.5.4 Data Movement Instructions . . . . . . . . . 3-18 + 3.5.5 Arithmetic Logic Unit Operations . . . . . . 3-19 + 3.5.6 Control Instructions . . . . . . . . . . . . 3-21 + + 3.6 Error Messages . . . . . . . . . . . . . . . . . . 3-21 + + 3.7 A Sample Session . . . . . . . . . . . . . . . . . 3-23 + + + + + + + + + iv + + + + + + + + +Table of Contents + +(continued) + + + +4 CP/M Dynamic Debugging Tool + + 4.1 Introduction . . . . . . . . . . . . . . . . . . . 4-1 + + 4.2 DDT Commands . . . . . . . . . . . . . . . . . . . 4-3 + + 4.2.1 The A (Assembly) Command . . . . . . . . . . 4-3 + 4.2.2 The D (Display) Command . . . . . . . . . . 4-4 + 4.2.3 The F (Fill) Command . . . . . . . . . . . . 4-5 + 4.2.4 The G (Go) Command . . . . . . . . . . . . . 4-5 + 4.2.5 The I (Input) Command . . . . . . . . . . . 4-6 + 4.2.6 The L (List) Command . . . . . . . . . . . . 4-6 + 4.2.7 The M (Move) Command . . . . . . . . . . . . 4-7 + 4.2.8 The R (Read) Command . . . . . . . . . . . . 4-7 + 4.2.9 The S (Set) Command . . . . . . . . . . . . 4-8 + 4.2.1- The T (Trace) Command . . . . . . . . . . . 4-8 + 4.2.11 The U (Untrace) Command . . . . . . . . . . 4-9 + 4.2.12 The X (Examine) Command . . . . . . . . . . 4-9 + + 4.3 Implementation Notes . . . . . . . . . . . . . . . 4-10 + + 4.4 A Sample Program . . . . . . . . . . . . . . . . . 4-11 + + +5 CP/M 2 System Interface + + 5.1 Introduction . . . . . . . . . . . . . . . . . . . 5-1 + + 5.2 Operating System Call Conventions . . . . . . . . . 5-3 + + 5.3 A Sample File-to-File Copy Program . . . . . . . . 5-35 + + 5.4 A Sample File Dump Utility . . . . . . . . . . . . 5-38 + + 5.5 A Sample Random Access Program . . . . . . . . . . 5-42 + + 5.6 System Function Summary . . . . . . . . . . . . . . 5-50 + + +6 CP/M 2 Alteration + + 6.1 Introduction . . . . . . . . . . . . . . . . . . . 6-1 + + 6.2 First-level System Regeneration . . . . . . . . . . 6-2 + + 6.3 Second-level System Generation . . . . . . . . . . 6-5 + + 6.4 Sample GETSYS and PUTSYS Programs . . . . . . . . . 6-9 + + + + v + + + + + + + + +Table of Contents + +(continued) + + + + 6.5 Disk Organization . . . . . . . . . . . . . . . . . 6-11 + + 6.6 The BIOS Entry Points . . . . . . . . . . . . . . . 6-13 + + 6.7 A Sample BIOS . . . . . . . . . . . . . . . . . . . 6-21 + + 6.8 A Sample Cold Start Loader . . . . . . . . . . . . 6-21 + + 6.9 Reserved Locations in Page Zero . . . . . . . . . . 6-22 + + 6.10 Disk Parameter Tables . . . . . . . . . . . . . . 6-23 + + 6.11 The DISKDEF Macro Library . . . . . . . . . . . . 6-28 + + 6.12 Sector Blocking and Deblocking . . . . . . . . . . 6-32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vi + + + + + + + + +Appendixes + + + +A Basic Input/Output System (BIOS) . . . . . . . . . . . A-1 + + +B A Skeletal CBIOS . . . . . . . . . . . . . . . . . . . B-1 + + +C A Skeletal GETSYS/PUTSYS Program . . . . . . . . . . . C-1 + + +D The Model 800 Cold Start Loader for CP/M 2 . . . . . . D-1 + + +E A Skeletal Cold Start Loader . . . . . . . . . . . . . E-1 + + +F CP/M Disk Definition Library . . . . . . . . . . . . . F-1 + + +G Blocking and Deblocking Algorithms . . . . . . . . . . G-1 + + +H Glossary . . . . . . . . . . . . . . . . . . . . . . . H-1 + + +I CP/M Error Messages . . . . . . . . . . . . . . . . . . I-1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vii + + + + + + + + +Tables, Figures, and Listings + + + +Tables + + 1-1. Line-editing Control Characters . . . . . . . . 1-10 + 1-2. CP/M Transient Commands . . . . . . . . . . . . 1-11 + 1-3. Physical Devices . . . . . . . . . . . . . . . 1-14 + 1-4. PIP Parameters . . . . . . . . . . . . . . . . 1-24 + + 2-1. ED Text Transfer Commands . . . . . . . . . . . 2-3 + 2-2. Editing Commands . . . . . . . . . . . . . . . 2-6 + 2-3. Line-editing Controls . . . . . . . . . . . . . 2-7 + 2-4. Error Message Symbols . . . . . . . . . . . . . 2-13 + 2-5. ED Control Characters . . . . . . . . . . . . . 2-14 + 2-6. ED Commands . . . . . . . . . . . . . . . . . . 2-15 + + 3-1. Reserved Characters . . . . . . . . . . . . . . 3-6 + 3-2. Arithmetic and Logical Operators . . . . . . . 3-7 + 3-3. Assembler Directives . . . . . . . . . . . . . 3-9 + 3-4. Jumps, Calls, and Returns . . . . . . . . . . . 3-15 + 3-5. Immediate Operand Instructions . . . . . . . . 3-16 + 3-6. Increment and Decrement Instructions . . . . . 3-17 + 3-7. Data Movement Instructions . . . . . . . . . . 3-17 + 3-8. Arithmetic Logic Unit Operations . . . . . . . 3-18 + 3-9. Error Codes . . . . . . . . . . . . . . . . . . 3-20 + 3-10. Error Messages . . . . . . . . . . . . . . . . 3-21 + + 4-1. Line-editing Controls . . . . . . . . . . . . . 4-2 + 4-2. DDT Commands . . . . . . . . . . . . . . . . . 4-2 + 4-3. CPU Registers . . . . . . . . . . . . . . . . . 4-9 + + 5-1. CP/M Filetypes . . . . . . . . . . . . . . . . 5-6 + 5-2. File Control Block Fields . . . . . . . . . . . 5-7 + 5-3. Edit Control Characters . . . . . . . . . . . . 5-20 + + 6-1. Standard Memory Size Values . . . . . . . . . . 6-2 + 6-2. Common Values for CP/M Systems . . . . . . . . 6-7 + 6-3. CP/M Disk Sector Allocation . . . . . . . . . . 6-11 + 6-4. IOBYTE Field Values . . . . . . . . . . . . . . 6-15 + 6-5. BIOS Entry Points . . . . . . . . . . . . . . . 6-16 + 6-6. Reserved Locations in Page Zero . . . . . . . . 6-21 + 6-7. Disk Parameter Headers . . . . . . . . . . . . 6-23 + 6-8. BSH and BLM Values . . . . . . . . . . . . . . 6-25 + 6-9. EXM Values . . . . . . . . . . . . . . . . . . 6-25 + 6-10. BLS Tabluation . . . . . . . . . . . . . . . . 6-26 + + I-1. CP/M Error Messages . . . . . . . . . . . . . . I-1 + + +Figures + + 2-1. Overall ED Operation . . . . . . . . . . . . . 2-2 + 2-2. Memory Buffer Organization . . . . . . . . . . 2-2 + + + viii + + + + + + + + +Tables, Figures, and Listings + +(continued) + + + +Figures + + 2-3. Logical Organization of Memory Buffer . . . . . 2-4 + + 5-1. CP/M Memory Organization . . . . . . . . . . . 5-1 + 5-2. File Control Block Format . . . . . . . . . . . 5-7 + + 6-1. IOBYTE Fields . . . . . . . . . . . . . . . . . 6-15 + 6-2. Disk Parameter Header Format . . . . . . . . . 6-22 + 6-3. Disk Parameter Header Table . . . . . . . . . . 6-23 + 6-4. Disk Parameter Block Format . . . . . . . . . . 6-24 + 6-5. AL0 and AL1 . . . . . . . . . . . . . . . . . . 6-25 + + +Listings + + 6-1. GETSYS Program . . . . . . . . . . . . . . . . 6-9 + 6-2. BIOS Entry Points . . . . . . . . . . . . . . . 6-13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ix + + + + + + + + +Section 1 + +CP/M Features and Facilities + + + +1.1 Introduction + + CP/M is a monitor control program for microcomputer system +development that uses floppy disks or Winchester hard disks for +backup storage. Using a computer system based on the Intel 8080 +microcomputer, CP/M provides an environment for program +construction, storage, and editing, along with assembly and program +check-out facilities. CP/M can be easily altered to execute with +any computer configuration that uses a Zilog Z80 or an Intel 8080 +Central Processing Unit (CPU) and has at least 20K bytes of main +memory with up to 16 disk drives. A detailed discussion of the +modifications required for any particular hardware environment is +given in Section 6. Although the standard Digital Research version +operates on a single-density Intel Model 800, microcomputer +development system several different hardware manufacturers support +their own input-output (I/O) drivers for CP/M. + + The CP/M monitor provides rapid access to programs through a +comprehensive file management package. The file subsystem supports +a named file structure, allowing dynamic allocation of file space as +well as sequential and random file access. Using this file system, +a large number of programs can be stored in both source and machine- +executable form. + + CP/M 2 is a high-performance, single console operating system +that uses table-driven techniques to allow field reconfiguration to +match a wide variety of disk capacities. All fundamental file +restrictions are removed, maintaining upward compatibility from +previous versions of release 1. + + Features of CP/M 2 include field specification of one to +sixteen logical drives, each containing up to eight megabytes. Any +particular file can reach the full drive size with the capability of +expanding to thirty-two megabytes in future releases. The directory +size can be field-configured to contain any reasonable number of +entries, and each file is optionally tagged with Read-Only and +system attributes. Users of CP/M 2 are physically separated by user +numbers, with facilities for file copy operations from one user area +to another. Powerful relative-record random access functions are +present in CP/M 2 that provide direct access to any of the 65536 +records of an eight-megabyte file. + + CP/M also supports ED, a powerful context editor, ASM , an +Intel-compatible assembler, and DDT , debugger subsystems. Optional +software includes a powerful Intel-compatible macro assembler, +symbolic debugger, along with various high-level languages. When +coupled with CP/M's Console Command Processor (CCP), the resulting +facilities equal or exceed similar large computer facilities. + + + + 1-1 + + + + + +CP/M Operating System Manual 1.1 Introduction + + + CP/M is logically divided into several distinct parts: + + o BIOS (Basic I/O System), hardware-dependent + o BDOS (Basic Disk Operating System) + o CCP (Console Command Processor) + o TPA (Transient Program Area) + + The BIOS provides the primitive operations necessary to access +the disk drives and to interface standard peripherals: teletype, +CRT, paper tape reader/punch, and user-defined peripherals. You can +tailor peripherals for any particular hardware environment by +patching this portion of CP/M. The BDOS provides disk management by +controlling one or more disk drives containing independent file +directories. The BDOS implements disk allocation strategies that +provide fully dynamic file construction while minimizing head +movement across the disk during access. The BDOS has entry points +that include the following primitive operations, which the program +accesses: + + o SEARCH looks for a particular disk file by name. + o OPEN opens a file for further operations. + o CLOSE closes a file after processing. + o RENAME changes the name of a particular file. + o READ reads a record from a particular file. + o WRITE writes a record to a particular file. + o SELECT selects a particular disk drive for further operations. + + The CCP provides a symbolic interface between your console and +the remainder of the CP/M system. The CCP reads the console device +and processes commands, which include listing the file directory, +printing the contents of files, and controlling the operation of +transient programs, such as assemblers, editors, and debuggers. The +standard commands that are available in the CCP are listed in +Section 1.2.1. + + The last segment of CP/M is the area called the Transient +Program Area (TPA). The TPA holds programs that are loaded from the +disk under command of the CCP. During program editing, for example, +the TPA holds the CP/M text editor machine code and data areas. +Similarly, programs created under CP/M can be checked out by loading +and executing these programs in the TPA. + + Any or all of the CP/M component subsystems can be overlaid by +an executing program. That is, once a user's program is loaded into +the TPA, the CCP, BDOS, and BIOS areas can be used as the program's +data area. A bootstrap loader is programmatically accessible +whenever the BIOS portion is not overlaid; thus, the user program +need only branch to the bootstrap loader at the end of execution and +the complete CP/M monitor is reloaded from disk. + + The CP/M operating system is partitioned into distinct modules, +including the BIOS portion that defines the hardware environment in +which CP/M is executing. Thus, the standard system is easily +modified to any nonstandard environment by changing the peripheral +drivers to handle the custom system. + + + 1-2 + + + + + +CP/M Operating System Manual 1.2 Functional Description + + +1.2 Functional Description + + You interact with CP/M primarily through the CCP, which reads +and interprets commands entered through the console. In general, +the CCP addresses one of several disks that are on-line. The +standard system addresses up to sixteen different disk drives. +These disk drives are labeled A through P. A disk is logged-in if +the CCP is currently addressing the disk. To clearly indicate which +disk is the currently logged disk, the CCP always prompts the +operator with the disk name followed by the symbol >, indicating +that the CCP is ready for another command. Upon initial start-up, +the CP/M system is loaded from disk A, and the CCP displays the +following message: + + CP/M VER x.x + +where x.x is the CP/M version number. All CP/M systems are +initially set to operate in a 20K memory space, but can be easily +reconfigured to fit any memory size on the host system (see Section +1.6.9). Following system sign-on, CP/M automatically logs in disk +A, prompts you with the symbol A>, indicating that CP/M is currently +addressing disk A, and waits for a command. The commands are +implemented at two levels: built-in commands and transient +commands. + + +1.2.1 General Command Structure + + Built-in commands are a part of the CCP program, while +transient commands are loaded into the TPA from disk and executed. +The following are built-in commands: + + o ERA erases specified files. + o DIR lists filenames in the directory. + o REN renames the specified file. + o SAVE saves memory contents in a file. + o TYPE types the contents of a file on the logged disk. + +Most of the commands reference a particular file or group of files. +The form of a file reference is specified in Section 1.2.2. + + +1.2.2 File References + + A file reference identifies a particular file or group of files +on a particular disk attached to CP/M. These file references are +either unambiguous (ufn) or ambiguous (afn). An unambiguous file +reference uniquely identifies a single file, while an ambiguous file +reference is satisfied by a number of different files. + + File references consist of two parts: the primary filename and +the filetype. Although the filetype is optional, it usually is +generic. For example, the filetype ASM is used to denote that the +file is an assembly language source file, while the primary filename +distinguishes each particular source file. The two names are +separated by a period, as shown in the following example: + + 1-3 + + + + + +CP/M Operating System Manual 1.2 Functional Description + + + filename.typ + +In this example, filename is the primary filename of eight +characters or less, and typ is the filetype of no more than three +characters. As mentioned above, the name + + filename + +is also allowed and is equivalent to a filetype consisting of three +blanks. The characters used in specifying an unambiguous file +reference cannot contain any of the following special characters: + + < > . , ; : = ? * [ ] _ % | ( ) / \textbackslash + +while all alphanumerics and remaining special characters are +allowed. + + An ambiguous file reference is used for directory search and +pattern matching. The form of an ambiguous file reference is +similar to an unambiguous reference, except the symbol ? can be +interspersed throughout the primary and secondary names. In various +commands throughout CP/M, the ? symbol matches any character of a +filename in the ? position. Thus, the ambiguous reference + + X?Z.C?M + +matches the following unambiguous filenames + + XYZ.COM + +and + + X3Z.CAM + +The * wildcard character can also be used in an ambiguous file +reference. The * character replaces all or part of a filename or +filetype. Note that + + *.* + +equals the ambiguous file reference + + ????????.??? + +while + + filename.* + +and + + *.typ + +are abbreviations for + + filename.??? + + + 1-4 + + + + + +CP/M Operating System Manual 1.2 Functional Description + + + +and + + ????????.typ + +respectively. As an example, + + A>DIR *.* + +is interpreted by the CCP as a command to list the names of all disk +files in the directory. The following example searches only for a +file by the name X.Y: + + A>DIR X,Y + +Similarly, the command + + A>DIR X?Y.C?M + +causes a search for all unambiguous filenames on the disk that +satisfy this ambiguous reference. + + The following file references are valid unambiguous file +references: + + X + X.Y + XYZ + XYZ.COM + GAMMA + GAMMA.1 + + As an added convenience, the programmer can generally specify +the disk drive name along with the filename. In this case, the +drive name is given as a letter A through P followed by a colon (:). +The specified drive is then logged-in before the file operation +occurs. Thus, the following are valid file references with disk +name prefixes: + + A:X.Y + P:XYZ.COM + B:XYZ + B:X.A?M + C:GAMMA + C:*.ASM + +All alphabetic lower-case letters in file and drive names are +translated to upper-case when they are processed by the CCP. + + +1.3 Switching Disks + + The operator can switch the currently logged disk by typing the +disk drive name, A through P, followed by a colon when the CCP is +waiting for console input. The following sequence of prompts and +commands can occur after the CP/M system is loaded from disk A: + + 1-5 + + + + + +CP/M Operating System Manual 1.3 Switching Disks + + + + CP/M VER 2.2 + A>DIR List all files on disk A. + A:SAMPLE ASM SAMPLE PRN + A>B: Switch to disk B. + B>DIR *.ASM List all ASM files on B. + B:DUMP ASM FILES ASM + b>A: Switch back to A. + + +1.4 Built-in Commands + + The file and device reference forms described can now be used +to fully specify the structure of the built-in commands. Assume the +following abbreviations in the description below: + + ufn unambiguous file reference + afn ambiguous file reference + +Recall that the CCP always translates lower-case characters to +upper-case characters internally. Thus, lower-case alphabetics are +treated as if they are upper-case in command names and file +references. + + +1.4.1 ERA Command + +Syntax: + + ERA afn + + The ERA (erase) command removes files from the currently +logged-in disk, for example, the disk name currently prompted by +CP/M preceding the >. The files that are erased are those that +satisfy the ambiguous file reference afn. The following examples +illustrate the use of ERA: + + + ERA X.Y The file named X.Y on the currently logged + disk is removed from the disk directory and + the space is returned. + + ERA X.* All files with primary name X are removed + from the current disk. + + ERA *.ASM All files with secondary name ASM are + removed from the current disk. + + ERA X?Y.C?M All files on the current disk that satisfy + the ambiguous reference X?Y.C?M are + deleted. + + + + + + + 1-6 + + + + + +CP/M Operating System Manual 1.4 Built-in Commands + + + ERA *.* Erase all files on the current disk. In + this case, the CCP prompts the console with + the message + + ALL FILES (Y/N)? + + which requires a Y response before files + are actually removed. + + ERA b:*.PRN All files on drive B that satisfy the + ambiguous reference ????????.PRN are + deleted, independently of the currently + logged disk. + + + +1.4.2 DIR Command + +Syntax: + + DIR afn + + The DIR (directory) command causes the names of all files that +satisfy the ambiguous filename afn to be listed at the console +device. As a special case, the command + + DIR + +lists the files on the currently logged disk (the command DIR is +equivalent to the command DIR *.*). The following are valid DIR +commands: + + DIR X.Y + DIR X?Z.C?M + DIR ??.Y + + Similar to other CCP commands, the afn can be preceded by a +drive name. The following DIR commands cause the selected drive to +be addressed before the directory search takes place: + + DIR B: + DIR B:X.Y + DIR B:*.A?M + + If no files on the selected disk satisfy the directory request, +the message NO FILE appears at the console. + + + + + + + + + + + + 1-7 + + + + + +CP/M Operating System Manual 1.4 Built-in Commands + + +1.4.3 REN Command + +Syntax: + + REN ufn1=ufn2 + + The REN (rename) command allows you to change the names of +files on disk. The file satisfying ufn2 is changed to ufn1. The +currently logged disk is assumed to contain the file to rename +(ufn2). You can also type a left-directed arrow instead of the +equal sign if the console supports this graphic character. The +following are examples of the REN command: + + + REN X.Y=Q.R The file Q.R is changed to X.Y. + + REN XYZ.COM=XYZ.XXX The file XYZ.XXX is changed to + XYZ.COM. + + + The operator precedes either ufn1 or ufn2 (or both) by an +optional drive address. If ufn1 is preceded by a drive name, then +ufn2 is assumed to exist on the same drive. Similarly, if ufn2 is +preceded by a drive name, then ufn1 is assumed to exist on the drive +as well. The same drive must be specified in both cases if both +ufn1 and ufn2 are preceded by drive names. The following REN +commands illustrate this format: + + + REN A:X.ASM=Y.ASM The file Y.ASM is changed to X.ASM + on drive A. + + REN B:ZAP.BAS=ZOT.BAS The file ZOT.BAS is changed to + ZAP.BAS on drive B. + + REN B:A.ASM=B:A.BAK The file A.BAK is renamed to A.ASM + on drive B. + + + If ufn1 is already present, the REN command responds with the +error FILE EXISTS and not perform the change. If ufn2 does not +exist on the specified disk, the message NO FILE is printed at the +console. + + +1.4.4 SAVE Command + +Syntax: + + SAVE n ufn + + The SAVE command places n pages (256-byte blocks) onto disk +from the TPA and names this file ufn. In the CP/M distribution +system, the TPA starts at 100H (hexadecimal) which is the second +page of memory. The SAVE command must specify 2 pages of memory if + + + 1-8 + + + + + +CP/M Operating System Manual 1.4 Built-in Commands + + +the user's program occupies the area from 100H through 2FFH. The +machine code file can be subsequently loaded and executed. The +following are examples of the SAVE command: + + + SAVE 3X.COM Copies 100H through 3FFH to X.COM. + + SAVE 40 Q Copies 100H through 28FFH to Q. + Note that 28 is the page count in + 28FFH, and that 28H = 2*16+8=40 + decimal. + + SAVE 4 X.Y Copies 100H through 4FFH to X.Y. + + +The SAVE command can also specify a disk drive in the ufn portion of +the command, as shown in the following example: + + SAVE 10 B:ZOT.COM Copies 10 pages, 100H through 0AFFH, + to the file ZOT.COM on drive B. + + + +1.4.5 TYPE Command + +Syntax: + + TYPE ufn + + The TYPE command displays the content of the ASCII source file +ufn on the currently logged disk at the console device. The +following are valid TYPE commands: + + TYPE X.Y + TYPE X.PLM + TYPE XXX + + The TYPE command expands tabs, CTRL-I characters, assuming tab +positions are set at every eighth column. The ufn can also +reference a drive name. + + TYPE B:X.PRN The file X.PRN from drive B is displayed. + + +1.4.6 USER Command + +Syntax: + + USER n + + The USER command allows maintenance of separate files in the +same directory. In the syntax line, n is an integer value in the +range 0 to 15. On cold start, the operator is automatically logged +into user area number 0, which is compatible with standard CP/M 1 +directories. You can issue the USER command at any time to move to + + + 1-9 + + + + + +CP/M Operating System Manual 1.4 Built-in Commands + + +another logical area within the same directory. Drives that are +logged-in while addressing one user number are automatically active +when the operator moves to another. A user number is simply a +prefix that accesses particular directory entries on the active +disks. + + The active user number is maintained until changed by a +subsequent USER command, or until a cold start when user 0 is again +assumed. + + +1.5 Line Editing and Output Control + + The CCP allows certain line-editing functions while typing +command lines. The CTRL-key sequences are obtained by pressing the +control and letter keys simultaneously. Further, CCP command lines +are generally up to 255 characters in length; they are not acted +upon until the carriage return key is pressed. + + +Table 1-1. Line-editing Control Characters + + F + Character Meaning + + CTRL-C Reboots CP/M system when pressed at start of + line. + + CTRL-E Physical end of line; carriage is returned, + but line is not sent until the carriage + return key is pressed. + + CTRL-H Backspaces one character position. + + CTRL-J Terminates current input (line feed). + + CTRL-M Terminates current input (carriage return). + + CTRL-P Copies all subsequent console output to the + currently assigned list device (see Section + 1.6.1). Output is sent to the list device + and the console device until the next CTRL-P + is pressed. + + CTRL-R Retypes current command line; types a clean + line following character deletion with + rubouts. + + CTRL-S Stops the console output temporarily. + Program execution and output continue when + you press any character at the console, for + example another CTRL-S. This feature stops + output on high speed consoles, such as CRTs, + in order to view a segment of output before + continuing. + + + + 1-10 + + + + K + + +CP/M Operating System Manual 1.5 Line Editing and Output Control + + +Table 1-1. (continued) + + F + Character Meaning + + CTRL-U Deletes the entire line typed at the + console. + + CTRL-X Same as CTRL-U. + + CTRL-Z Ends input from the console (used in PIP and + ED). + + RUB/DEL Deletes and echoes the last character typed + at the console. + K + + +1.6 Transient Commands + + Transient commands are loaded from the currently logged disk +and executed in the TPA. The transient commands for execution under +the CCP are below. Additional functions are easily defined by the +user (see Section 1.6.3). + + +Table 1-2. CP/M Transient Commands + + F + Command Function + + STAT Lists the number of bytes of storage remaining + on the currently logged disk, provides + statistical information about particular + files, and displays or alters device + assignment. + + ASM Loads the CP/M assembler and assembles the + specified program from disk. + + LOAD Loads the file in Intel HEX machine code + format and produces a file in machine + executable form which can be loaded into the + TPA. This loaded program becomes a new + command under the CCP. + + DDT Loads the CP/M debugger into TPA and starts + execution. + + PIP Loads the Peripheral Interchange Program for + subsequent disk file and peripheral transfer + operations. + + ED Loads and executes the CP/M text editor + program. + + SYSGEN Creates a new CP/M system disk. + + + + 1-11 + + + + K + + +CP/M Operating System Manual 1.6 Transient Commands + + +Table 1-2. (continued) + + F + Command Function + + SUBMIT Submits a file of commands for batch + processing. + + DUMP Dumps the contents of a file in hex. + + MOVCPM Regenerates the CP/M system for a particular + memory size. + + K + + Transient commands are specified in the same manner as built-in +commands, and additional commands are easily defined by the user. +For convenience, the transient command can be preceded by a drive +name which causes the transient to be loaded from the specified +drive into the TPA for execution. Thus, the command + + B:STAT + +causes CP/M to temporarily log in drive B for the source of the STAT +transient, and then return to the original logged disk for +subsequent processing. + + +1.6.1 STAT Command + +Syntax: + + STAT + STAT "command line" + + The STAT command provides general statistical information about +file storage and device assignment. Special forms of the command +line allow the current device assignment to be examined and altered. +The various command lines that can be specified are shown with an +explanation of each form to the right. + + + STAT If you type an empty command line, the STAT + transient calculates the storage remaining + on all active drives, and prints one of the + following messages: + + d: R/W, SPACE: nnnK + + d: R/O, SPACE: nnnK + + for each active drive d:, where R/W + indicates the drive can be read or written, + and R/O indicates the drive is Read-Only (a + drive becomes R/O by explicitly setting it + to Read-Only, as shown below, or by + inadvertently changing disks without + + + 1-12 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + performing a warm start). The space + remaining on the disk in drive d: is given + in kilobytes by nnn. + + STAT d: If a drive name is given, then the drive is + selected before the storage is computed. + Thus, the command STAT B: could be issued + while logged into drive A, resulting in the + message + + BYTES REMAINING ON B: nnnK + + STAT afn The command line can also specify a set of + files to be scanned by STAT. The files + that satisfy afn are listed in alphabetical + order, with storage requirements for each + file under the heading: + + RECS BYTES EXT D:FILENAME.TYP + rrrr bbbK ee d:filename.typ + + where rrrr is the number of 128-byte + records allocated to the file, bbb is the + number of kilobytes allocated to the file + (bbb=rrrr*128/1024), ee is the number of + 16K extensions (ee=bbb/16), d is the drive + name containing the file (A...P), filename + is the eight-character primary filename, + and typ is the three-character filetype. + After listing the individual files, the + storage usage is summarized. + + STAT d:afn The drive name can be given ahead of the + afn. The specified drive is first + selected, and the form STAT afn is + executed. + + STAT d:=R/O This form sets the drive given by d to + Read-Only, remaining in effect until the + next warm or cold start takes place. When + a disk is Read-Only, the message + + BDOS ERR ON d: Read-Only + + appears if there is an attempt to write to + the Read-Only disk. CP/M waits until a key + is pressed before performing an automatic + warm start, at which time the disk becomes + R/W. + + + + + + + + + 1-13 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + The STAT command allows you to control the physical-to-logical +device assignment. See the IOBYTE function described in Sections 5 +and 6. There are four logical peripheral devices that are, at any +particular instant, each assigned one of several physical peripheral +devices. The following is a list of the four logical devices: + + + o CON: is the system console device, used by CCP for + communication with the operator. + + o RDR: is the paper tape reader device. + + o PUN: is the paper tape punch device. + + o LST: is the output list device. + + + The actual devices attached to any particular computer system +are driven by subroutines in the BIOS portion of CP/M. Thus, the +logical RDR: device, for example, could actually be a high speed +reader, teletype reader, or cassette tape. To allow some +flexibility in device naming and assignment, several physical +devices are defined in Table 1-3. + + +Table 1-3. Physical Devices + F + + Device Meaning + + TTY: Teletype device (slow speed console) + + CRT: Cathode ray tube device (high speed console) + + BAT: Batch processing (console is current RDR:, + output goes to current LST: device) + + UC1: User-defined console + + PTR: Paper tape reader (high speed reader) + + UR1: User-defined reader #1 + + UR2: User-defined reader #2 + + PTP: Paper tape punch (high speed punch) + + UP1: User-defined punch #1 + + UP2: User-defined punch #2 + + LPT: Line printer + + UL1: User-defined list device #1 + K + + + + 1-14 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + It is emphasized that the physical device names might not +actually correspond to devices that the names imply. That is, you +can implement the PTP: device as a cassette write operation. The +exact correspondence and driving subroutine is defined in the BIOS +portion of CP/M. In the standard distribution version of CP/M, +these devices correspond to their names on the Model 800 development +system. + + The command, + + STAT VAL: + +produces a summary of the available status commands, resulting in +the output: + + Temp R/O Disk d:$R/O + Set Indicator: filename.typ $R/O $R/W $SYS $DIR + Disk Status: DSK: d:DSK + Iobyte Assign: + +which gives an instant summary of the possible STAT commands and +shows the permissible logical-to-physical device assignments: + + CON: = TTY: CRT: BAT: UC1: + RDR: = TTY: PTR: UR1: UR2: + PUN: = TTY: PTP: UP1: UP2: + LST: = TTY: CRT: LPT: UL1: + +The logical device to the left takes any of the four physical +assignments shown to the right. The current logical-to-physical +mapping is displayed by typing the command: + + STAT DEV: + +This command produces a list of each logical device to the left and +the current corresponding physical device to the right. For +example, the list might appear as follows: + + CON: = CRT: + RDR: = UR1: + PUN: = PTP: + LST: = TTY: + +The current logical-to-physical device assignment is changed by +typing a STAT command of the form: + + STAT ld1 = pd1, ld2 = pd2, ... , ldn = pdn + +where ld1 through ldn are logical device names and pd1 through pdn +are compatible physical device names. For example, ldi and pdi +appear on the same line in the VAL: command shown above. The +following example shows valid STAT commands that change the current +logical-to-physical device assignments: + + + + 1-15 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + STAT CON:=CRT: + STAT PUN:=TTY:, LST:=LPT:, RDR:=TTY: + + The command form, + + STAT d:filename.typ $S + +where d: is an optional drive name and filename.typ is an +unambiguous or ambiguous filename, produces the following output +display format: + + + Size Recs Bytes Ext Acc + + 48 48 6K 1 R/O A:ED.COM + 55 55 12K 1 R/O (A:PIP.COM) + 65536 128 16K 2 R/W A:X.DAT + + +where the $S parameter causes the Size field to be displayed. +Without the $S, the Size field is skipped, but the remaining fields +are displayed. The Size field lists the virtual file size in +records, while the Recs field sums the number of virtual records in +each extent. For files constructed sequentially, the Size and Recs +fields are identical. The Bytes field lists the actual number of +bytes allocated to the corresponding file. The minimum allocation +unit is determined at configuration time; thus, the number of bytes +corresponds to the record count plus the remaining unused space in +the last allocated block for sequential files. Random access files +are given data areas only when written, so the Bytes field contains +the only accurate allocation figure. In the case of random access, +the Size field gives the logical end-of-file record position and the +Recs field counts the logical records of each extent. Each of these +extents, however, can contain unallocated holes even though they are +added into the record count. + + The Ext field counts the number of physical extents allocated +to the file. The Ext count corresponds to the number of directory +entries given to the file. Depending on allocation size, there can +be up to 128K bytes (8 logical extents) directly addressed by a +single directory entry. In a special case, there are actually 256K +bytes that can be directly addressed by a physical extent. + + The Acc field gives the R/O or R/W file indicator, which you +can change using the commands shown. The four command forms, + + STAT d:filename.typ $R/O + STAT d:filename.typ $R/W + STAT d:filename.typ $SYS + STAT d:filename.typ $DIR + +set or reset various permanent file indicators. The R/O indicator +places the file, or set of files, in a Read-Only status until +changed by a subsequent STAT command. The R/O status is recorded in +the directory with the file so that it remains R/O through + + + 1-16 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + +intervening cold start operations. The R/W indicator places the +file in a permanent Read-Write status. The SYS indicator attaches +the system indicator to the file, while the DIR command removes the +system indicator. The filename.typ may be ambiguous or unambiguous, +but files whose attributes are changed are listed at the console +when the change occurs. The drive name denoted by d: is optional. + + When a file is marked R/O, subsequent attempts to erase or +write into the file produce the following BDOS message at your +screen: + + BDOS Err on d: File R/O + +lists the drive characteristics of the disk named by d: that is in +the range A:, B:,...,P:. The drive characteristics are listed in +the following format: + + d: Drive Characteristics + 65536: 128 Byte Record Capacity + 8192: Kilobyte Drive Capacity + 128: 32 Byte Directory Entries + 0: Checked Directory Entries + 1024: Records/Extent + 128: Records/Block + 58: Sectors/Track + 2: Reserved Tracks + +where d: is the selected drive, followed by the total record +capacity (65536 is an eight-megabyte drive), followed by the total +capacity listed in kilobytes. The directory size is listed next, +followed by the checked entries. The number of checked entries is +usually identical to the directory size for removable media, because +this mechanism is used to detect changed media during CP/M operation +without an intervening warm start. For fixed media, the number is +usually zero, because the media are not changed without at least a +cold or warm start. + + The number of records per extent determines the addressing +capacity of each directory entry (1024 times 128 bytes, or 128K in +the previous example). The number of records per block shows the +basic allocation size (in the example, 128 records/block times 128 +bytes per record, or 16K bytes per block). The listing is then +followed by the number of physical sectors per track and the number +of reserved tracks. + + For logical drives that share the same physical disk, the +number of reserved tracks can be quite large because this mechanism +is used to skip lower-numbered disk areas allocated to other logical +disks. The command form + + STAT DSK: + +produces a drive characteristics table for all currently active +drives. The final STAT command form is + + + + 1-17 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + STAT USR: + +which produces a list of the user numbers that have files on the +currently addressed disk. The display format is + + Active User: 0 + Active Files: 0 1 3 + +where the first line lists the currently addressed user number, as +set by the last CCP USER command, followed by a list of user numbers +scanned from the current directory. In this case, the active user +number is 0 (default at cold start) with three user numbers that +have active files on the current disk. The operator can +subsequently examine the directories of the other user numbers by +logging in with USER 1 or USER 3 commands, followed by a DIR command +at the CCP level. + + +1.6.2 ASM Command + +Syntax: + + ASM ufn + + The ASM command loads and executes the CP/M 8080 assembler. +The ufn specifies a source file containing assembly language +statements, where the filetype is assumed to be ASM and is not +specified. The following ASM commands are valid: + + ASM X + ASM GAMMA + +The two-pass assembler is automatically executed. Assembly errors +that occur during the second pass are printed at the console. + + The assembler produces a file: + + X.PRN + +where X is the primary name specified in the ASM command. The PRN +file contains a listing of the source program with embedded tab +characters if present in the source program, along with the machine +code generated for each statement and diagnostic error messages, if +any. The PRN file is listed at the console using the TYPE command, +or sent to a peripheral device using PIP (see Section 1.6.4). Note +that the PRN file contains the original source program, augmented by +miscellaneous assembly information in the leftmost 16 columns; for +example, program addresses and hexadecimal machine code. The PRN +file serves as a backup for the original source file. If the source +file is accidentally removed or destroyed, the PRN file can be +edited by removing the leftmost 16 characters of each line (see +Section 2). This is done by issuing a single editor macro command. +The resulting file is identical to the original source file and can +be renamed from PRN to ASM for subsequent editing and assembly. The +file + + + 1-18 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + X.HEX + +is also produced, which contains 8080 machine language in Intel HEX +format suitable for subsequent loading and execution (see Section +1.6.3). For complete details of CP/M's assembly language program, +see Section 3. + + The source file for assembly is taken from an alternate disk by +prefixing the assembly language filename by a disk drive name. The +command + + ASM B:ALPHA + +loads the assembler from the currently logged drive and processes +the source program ALPHA.ASM on drive B. The HEX and PRN files are +also placed on drive B in this case. + + +1.6.3 LOAD Command + +Syntax: + + LOAD ufn + + The LOAD command reads the file ufn, which is assumed to +contain HEX format machine code, and produces a memory image file +that can subsequently be executed. The filename ufn is assumed to +be of the form: + + X.HEX + +and only the filename X need be specified in the command. The LOAD +command creates a file named + + X.COM + +that marks it as containing machine executable code. The file is +actually loaded into memory and executed when the user types the +filename X immediately after the prompting character > printed by +the CCP. + + Generally, the CCP reads the filename X following the prompting +character and looks for a built-in function name. If no function +name is found, the CCP searches the system disk directory for a file +by the name + + X.COM + +If found, the machine code is loaded into the TPA, and the program +executes. Thus, the user need only LOAD a hex file once; it can be +subsequently executed any number of times by typing the primary +name. This way, you can invent new commands in the CCP. +Initialized disks contain the transient commands as COM files, which +are optionally deleted. The operation takes place on an alternate +drive if the filename is prefixed by a drive name. Thus, + + 1-19 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + LOAD B:BETA + +brings the LOAD program into the TPA from the currently logged disk +and operates on drive B after execution begins. + +Note: the BETA.HEX file must contain valid Intel format hexadecimal +machine code records (as produced by the ASM program, for example) +that begin at 100H of the TPA. The addresses in the hex records +must be in ascending order; gaps in unfilled memory regions are +filled with zeroes by the LOAD command as the hex records are read. +Thus, LOAD must be used only for creating CP/M standard COM files +that operate in the TPA. Programs that occupy regions of memory +other than the TPA are loaded under DDT. + + +1.6.4 PIP + +Syntax: + + PIP + PIP destination=source#1, source#2, ..., source #n + + PIP is the CP/M Peripheral Interchange Program that implements +the basic media conversion operations necessary to load, print, +punch, copy, and combine disk files. The PIP program is initiated +by typing one of the following forms: + + PIP + PIP command line + +In both cases PIP is loaded into the TPA and executed. In the first +form, PIP reads command lines directly from the console, prompted +with the * character, until an empty command line is typed (for +example, a single carriage return is issued by the operator). Each +successive command line causes some media conversion to take place +according to the rules shown below. + + In the second form, the PIP command is equivalent to the first, +except that the single command line given with the PIP command is +automatically executed, and PIP terminates immediately with no +further prompting of the console for input command lines. The form +of each command line is + + destination = source#1, source#2, ..., source#n + +where destination is the file or peripheral device to receive the +data, and source#1, ..., source#n is a series of one or more files +or devices that are copied from left to right to the destination. + + When multiple files are given in the command line (for example, +n>1), the individual files are assumed to contain ASCII characters, +with an assumed CP/M end-of-file character (CTRL-Z) at the end of +each file (see the O parameter to override this assumption). Lower- +case ASCII alphabetics are internally translated to upper-case to be + + + 1-20 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + +consistent with CP/M file and device name conventions. Finally, the +total command line length cannot exceed 255 characters. CTRL-E can +be used to force a physical carriage return for lines that exceed +the console width. + + The destination and source elements are unambiguous references +to CP/M source files with or without a preceding disk drive name. +That is, any file can be referenced with a preceding drive name (A: +through P:) that defines the particular drive where the file can be +obtained or stored. When the drive name is not included, the +currently logged disk is assumed. The destination file can also +appear as one or more of the source files, in which case the source +file is not altered until the entire concatenation is complete. If +it already exists, the destination file is removed if the command +line is properly formed. It is not removed if an error condition +arises. The following command lines, with explanations to the +right, are valid as input to PIP: + + + X=Y Copies to file X from file Y, where + X and Y are unambiguous filenames; + Y remains unchanged. + + X=Y,Z Concatenates files Y and z and + copies to file X, with Y and Z + unchanged. + + X.ASM=Y.ASM,Z.ASM Creates the file X.ASM from the + concatenation of the Y and Z.ASM + files. + + NEW.ZOT=B:OLD.ZAP Moves a copy of OLD.ZAPP from drive + B to the currently logged disk; + names the file NEW.ZOT. + + B:A.U=B:B.V,A:C.W,D.X Concatenates file B.V from drive B + with C.W from drive a and D.X from + the logged disk; creates the file + A.U on drive b. + + + For convenience, PIP allows abbreviated commands for +transferring files between disk drives. The abbreviated PIP forms +are + + PIP d:=afn + PIP d1=d2:afn + PIP ufn = d2: + PIP d1:ufn = d2: + +The first form copies all files from the currently logged disk that +satisfy the afn to the same files on drive d, where d = A...P. The +second form is equivalent to the first, where the source for the +copy is drive d2, where d2 = A...P. The third form is equivalent to +the command PIP d1:ufn=d2:ufn which copies the file given by ufn + + + 1-21 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + +from drive d2 to the file ufn on drive d1:. The fourth form is +equivalent to the third, where the source disk is explicitly given +by d2:. + + The source and destination disks must be different in all of +these cases. If an afn is specified, PIP lists each ufn that +satisfies the afn as it is being copied. If a file exists by the +same name as the destination file, it is removed after successful +completion of the copy and replaced by the copied file. + + The following PIP commands give examples of valid disk-to-disk +copy operations: + + + B:=*.COM Copies all files that have the secondary + name COM to drive B from the current drive. + + A:=B:ZAP.* Copies all files that have the primary name + ZAP to drive A from drive B. + + ZAP.ASM=B: Same as ZAP.ASM=B:ZAP.ASM + + B:ZOT.COM=A: Same as B:ZOT.COM=A:ZOT.COM + + B:=GAMMA.BAS Same as B:GAMMA.BAS=GAMMA.BAS + + B:=A:GAMMA.BAS Same as B:GAMMA.BAS=A:GAMMA.BAS + + + PIP allows reference to physical and logical devices that are +attached to the CP/M system. The device names are the same as given +under the STAT command, along with a number of specially named +devices. The following is a list of logical devices given in the +STAT command + + CON: (console) + RDR: (reader) + PUN: (punch) + LST: (list) + +while the physical devices are + + TTY: (console), reader, punch, or list) + CRT: (console, or list), UC1: (console) + PTR: (reader), UR1: (reader), UR2: (reader) + PTP: (punch), UP1: (punch), UP2: (punch) + LPT: (list), UL1: (list) + +The BAT: physical device is not included, because this assignment is +used only to indicate that the RDR: and LST: devices are used for +console input/output. + + The RDR, LST, PUN, and CON devices are all defined within the +BIOS portion of CP/M, and are easily altered for any particular I/O +system. The current physical device mapping is defined by IOBYTE; + + + 1-22 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + +see Section 6 for a discussion of this function. The destination +device must be capable of receiving data, for example, data cannot +be sent to the punch, and the source devices must be capable of +generating data, for example, the LST: device cannot be read. + + The following list describes additional device names that can +be used in PIP commands. + + + o NUL: sends 40 nulls (ASCII 0s) to the device. This can be + issued at the end of punched output. + + o EOF: sends a CP/M end-of-file (ASCII CTRL-Z) to the destination + device (sent automatically at the end of all ASCII data + transfers through PIP). + + o INP: is a special PIP input source that can be patched into the + PIP program. PIP gets the input data character-by-character, + by CALLing location 103H, with data returned in location 109H + (parity bit must be zero). + + o OUT: is a special PIP output destination that can be patched + into the PIP program. PIP CALLs location 106H with data in + register C for each character to transmit. Note that locations + 109H through 1FFH of the PIP memory image are not used and can + be replaced by special purpose drivers using DDT (see Section + 4). + + o PRN: is the same as LST:, except that tabs are expanded at + every eighth character position, lines are numbered, and page + ejects are inserted every 60 lines with an initial eject (same + as using PIP options [t8np]). + + + File and device names can be interspersed in the PIP commands. +In each case, the specific device is read until end-of-file (CTRL-Z +for ASCII files, and end-of-data for non-ASCII disk files). Data +from each device or file are concatenated from left to right until +the last data source has been read. + + The destination device or file is written using the data from +the source files, and an end-of-file character, CTRL-Z, is appended +to the result for ASCII files. If the destination is a disk file, a +temporary file is created ($$$ secondary name) that is changed to +the actual filename only on successful completion of the copy. +Files with the extension COM are always assumed to be non-ASCII. + + The copy operation can be aborted at any time by pressing any +key on the keyboard. PIP responds with the message ABORTED to +indicate that the operation has not been completed. If any +operation is aborted, or if an error occurs during processing, PIP +removes any pending commands that were set up while using the SUBMIT +command. + + + + + 1-23 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + PIP performs a special function if the destination is a disk +file with type HEX (an Intel hex-formatted machine code file), and +the source is an external peripheral device, such as a paper tape +reader. In this case, the PIP program checks to ensure that the +source file contains a properly formed hex file, with legal +hexadecimal values and checksum records. + + When an invalid input record is found, PIP reports an error +message at the console and waits for corrective action. Usually, +you can open the reader and rerun a section of the tape (pull the +tape back about 20 inches). When the tape is ready for the reread, +a single carriage return is typed at the console, and PIP attempts +another read. If the tape position cannot be properly read, +continue the read by typing a return following the error message, +and enter the record manually with the ED program after the disk +file is constructed. + + PIP allows the end-of-file to be entered from the console if +the source file is an RDR: device. In this case, the PIP program +reads the device and monitors the keyboard. If CTRL-Z is typed at +the keyboard, the read operation is terminated normally. + + The following are valid PIP commands: + + + PIP LST: = X.PRN + + Copies X.PRN to the LST device and + terminates the PIP program. + + PIP + + Starts PIP for a sequence of commands. PIP + prompts with *. + + *CON:=X.ASM,Y.ASM,Z.ASM + + Concatenates three ASM files and copies to + the CON device. + + *X.HEX=CON:,Y.HEX,PTR: + + Creates a HEX file by reading the CON until + a CTRL-Z is typed, followed by data from + Y.HEX and PTR until a CTRL-Z is + encountered. + + PIP PUN:=NUL:,X.ASM,EOF:,NUL: + + Sends 40 nulls to the punch device; copies + the X.ASM file to the punch, followed by an + end-of-file, CTRL-Z, and 40 more null + characters. + + (carriage return) + + A single carriage return stops PIP. + + 1-24 + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + You can also specify one or more PIP parameters, enclosed in +left and right square brackets, separated by zero or more blanks. +Each parameter affects the copy operation, and the enclosed list of +parameters must immediately follow the affected file or device. +Generally, each parameter can be followed by an optional decimal +integer value (the S and Q parameters are exceptions). Table 1-4 +describes valid PIP parameters. + + +Table 1-4. PIP Parameters + F + + Parameter Meaning + + B Blocks mode transfer. Data are buffered by + PIP until an ASCII x-off character, CTRL-S, + is received from the source device. This + allows transfer of data to a disk file from a + continuous reading device, such as a cassette + reader. Upon receipt of the x-off, PIP + clears the disk buffers and returns for more + input data. The amount of data that can be + buffered depends on the memory size of the + host system. PIP issues an error message if + the buffers overflow. + + Dn Deletes characters that extend past column n + in the transfer of data to the destination + from the character source. This parameter is + generally used to truncate long lines that + are sent to a narrow printer or console + device. + + E Echoes all transfer operations to the console + as they are being performed. + + F Filters form-feeds from the file. All + embedded form-feeds are removed. The P + parameter can be used simultaneously to + insert new form-feeds. + + Gn Gets file from user number n (n in the range + 0-15). + + H Transfers HEX data. All data are checked for + proper Intel hex file format. Nonessential + characters between hex records are removed + during the copy operation. The console is + prompted for corrective action in case errors + occur. + + I Ignores :00 records in the transfer of Intel + hex format file. The I parameter + automatically sets the H parameter. + + + + 1-25 + + + + K + + +CP/M Operating System Manual 1.6 Transient Commands + + +Table 1-4. (continued) + F + + Parameter Meaning + + L Translates upper-case alphabetics to lower- + case. + + N Adds line numbers to each line transferred to + the destination, starting at one and + incrementing by 1. Leading zeroes are + suppressed, and the number is followed by a + colon. If N2 is specified, leading zeroes + are included and a tab is inserted following + the number. The tab is expanded if T is set. + + O Transfers non-ASCII object files. The normal + CP/M end-of-file is ignored. + + Pn Includes page ejects at every n lines with an + initial page eject. If n = 1 or is excluded + altogether, page ejects occur every 60 lines. + If the F parameter is used, form-feed + suppression takes place before the new page + ejects are inserted. + + Qs^Z Quits copying from the source device or file + when the string s, terminated by CTRL-Z, is + encountered. + + R Reads system files. + + Ss^Z Start copying from the source device when the + string s, terminated by CTRL-Z, is + encountered. The S and Q parameters can be + used to abstract a particular section of a + file, such as a subroutine. The start and + quit strings are always included in the copy + operation. + + If you specify a command line after the PIP + command keyword, the CCP translates strings + following the S and Q parameters to upper- + case. If you do not specify a command line, + PIP does not perform the automatic upper-case + translation. + + Tn Expands tabs, CTRL-I characters, to every nth + column during the transfer of characters to + the destination from the source. + + U Translates lower-case alphabetics to upper- + case during the copy operation. + + + + + + 1-26 + + + + K + + +CP/M Operating System Manual 1.6 Transient Commands + + +Table 1-4. (continued) + F + + Parameter Meaning + + V Verifies that data have been copied correctly + by rereading after the write operation (the + destination must be a disk file). + + W Writes over R/O files without console + interrogation. + + Z Zeros the parity bit on input for each ASCII + character. + K + + + The following examples show valid PIP commands that specify +parameters in the file transfer. + + + PIP X.ASM=B:[v] + + Copies X.ASM from drive B to the current + drive and verifies that the data were + properly copied. + + + PIP LPT:=X.ASM[nt8u] + + Copies X.ASM to the LPT: device; numbers + each line, expands tabs to every eighth + column, and translates lower-case + alphabetics to upper-case. + + + PIP PUN:=X.HEX[i],Y.ZOT[h] + + First copies X.HEX to the PUN: device and + ignores the trailing :00 record in X.HEX; + continues the transfer of data by reading + Y.ZOT, which contains HEX records, + including any :00 records it contains. + + + PIP X.LIB=Y.ASM[sSUBRI:^z qJMP L3^z] + + Copies from the file Y.ASM into the file + X.LIB. The command starts the copy when + the string SUBR1: has been found, and quits + copying after the string JMP L3 is + encountered. + + + + + + + + 1-27 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + PIP PRN:=X.ASM[p50] + + Sends X.ASM to the LST: device with line + numbers, expands tabs to every eighth + column, and ejects pages at every 50th + line. The assumed parameter list for a PRN + file is nt8p60; p50 overrides the default + value. + + + Under normal operation, PIP does not overwrite a file that is +set to a permanent R/O status. If an attempt is made to overwrite +an R/O file, the following prompt appears: + + DESTINATION FILE IS R/O, DELETE (Y/N)? + +If you type Y, the file is overwritten. Otherwise, the following +response appears: + + ** NOT DELETED ** + +The file transfer is skipped, and PIP continues with the next +operation in sequence. To avoid the prompt and response in the case +of R/O file overwrite, the command line can include the W parameter, +as shown in this example: + + PIP A:=B:*.COM[W] + +The W parameter copies all nonsystem files to the A drive from the B +drive and overwrites any R/O files in the process. If the operation +involves several concatenated files, the W parameter need only be +included with the last file in the list, as in this example: + + PIP A.DAT=B.DAT,F:NEW.DAT,G:OLD.DAT[W] + + Files with the system attribute can be included in PIP +transfers if the R parameter is included; otherwise, system files +are not recognized. For example, the command line: + + PIP ED.COM=B:ED.COM[R] + +reads the ED.COM file from the B drive, even if it has been marked +as an R/O and system file. The system file attributes are copied, +if present. + + Downward compatibility with previous versions of CP/M is only +maintained if the file does not exceed one megabyte, no file +attributes are set, and the file is created by user 0. If +compatibility is required with nonstandard, for example, double- +density versions of 1.4, it might be necessary to select 1.4 +compatibility mode when constructing the internal disk parameter +block. See Section 6 and refer to Section 6.10, which describes +BIOS differences. + + + + + 1-28 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + +Note: to copy files into another user area, PIP.COM must be located +in that user area. Use the following procedure to make a copy of +PIP.COM in another user area. + + + USER 0 Log in user 0. + + DDT PIP.COM (note PIP size s) Load PIP to memory. + + GO Return to CCP. + + USER 3 Log in user 3. + + SAVEs PIP.COM + + +In this procedure, s is the integral number of memory pages, 256- +byte segments, occupied by PIP. The number s can be determined when +PIP.COM is loaded under DDT, by referring to the value under the +NEXT display. If, for example, the next available address is 1D00, +then PIP.COM requires 1C hexadecimal pages, or 1 times 16 + 12 = 28 +pages, and the value of s is 28 in the subsequent save. Once PIP is +copied in this manner, it can be copied to another disk belonging to +the same user number through normal PIP transfers. + + +1.6.5 ED Command + +Syntax: + + ED ufn + + The ED program is the CP/M system context editor that allows +creation and alteration of ASCII files in the CP/M environment. +Complete details of operation are given in Section 2. ED allows the +operator to create and operate upon source files that are organized +as a sequence of ASCII characters, separated by end-of-line +characters (a carriage return/line-feed sequence). There is no +practical restriction on line length (no single line can exceed the +size of the working memory) that is defined by the number of +characters typed between carriage returns. + + The ED program has a number of commands for character string +searching, replacement, and insertion that are useful for creating +and correcting programs or text files under CP/M. Although the CP/M +has a limited memory work space area (approximately 5000 characters +in a 20K CP/M system), the file size that can be edited is not +limited, since data are easily paged through this work area. + + If it does not exist, ED creates the specified source file and +opens the file for access. If the source file does exist, the +programmer appends data for editing (see the A command). The +appended data can then be displayed, altered, and written from the +work area back to the disk (see the W command). Particular points +in the program can be automatically paged and located by context, + + + 1-29 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + +allowing easy access to particular portions of a large file (see the +N command). + + If you type the following command line: + + ED X.ASM + +the ED program creates an intermediate work file with the name + + X.$$$ + +to hold the edited data during the ED run. Upon completion of ED, +the X.ASM file (original file) is renamed to X.BAK, and the edited +work file is renamed to X.ASM. Thus, the X.BAK file contains the +original unedited file, and the X.ASM file contains the newly edited +file. The operator can always return to the previous version of a +file by removing the most recent version and renaming the previous +version. If the current X.ASM file has been improperly edited, the +following sequence of commands reclaim the back-up file. + + + DIR X.* Checks to see that BAK file is + available. + + ERA X.ASM Erases most recent version. + + REN X.ASM=X.BAK Renames the BAK file to ASM. + + +You can abort the edit at any point (reboot, power failure, CTRL-C, +or CTRL-Q command) without destroying the original file. In this +case, the BAK file is not created and the original file is always +intact. + + The ED program allows the user to edit the source on one disk +and create the back-up file on another disk. This form of the ED +command is + + ED ufn d: + +where ufn is the name of the file to edit on the currently logged +disk and d is the name of an alternate drive. The ED program reads +and processes the source file and writes the new file to drive d +using the name ufn. After processing, the original file becomes the +back-up file. If the operator is addressing disk A, the following +command is valid. + + ED X.ASM b: + +This edits the file X.ASM on drive A, creating the new file X.$$$ on +drive B. After a successful edit, A:X.ASM is renamed to A:X.BAK, +and B:X.$$$ is renamed to B:X.ASM. For convenience, the currently +logged disk becomes drive B at the end of the edit. Note that if a +file named B:X.ASM exists before the editing begins, the following +message appears on the screen: + + + 1-30 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + FILE EXISTS + +This message is a precaution against accidentally destroying a +source file. You should first erase the existing file and then +restart the edit operation. + + Similar to other transient commands, editing can take place on +a drive different from the currently logged disk by preceding the +source filename by a drive name. The following are examples of +valid edit requests: + + + ED A:X.ASM Edits the file X.ASM on drive A, with new + file and back-up on drive A. + + ED B:X.ASM A: Edits the file X.ASM on drive B to the + temporary file X.$$$ on drive A. After + editing, this command changes X.ASM on + drive B to X.BAK and changes X.$$$ on + drive A to X.ASM. + + +1.6.6 SYSGEN Command + +Syntax: + + SYSGEN + + The SYSGEN transient command allows generation of an +initialized disk containing the CP/M operating system. The SYSGEN +program prompts the console for commands by interacting as shown. + + + SYSGEN + + Initiates the SYSGEN program. + + + SYSGEN VERSION x.x + + SYSGEN sign-on message. + + + SOURCE DRIVE NAME + (OR RETURN TO SKIP) + + Respond with the drive name (one of the + letters A, B, C, or D) of the disk + containing a CP/M system, usually A. If a + copy of CP/M already exists in memory due + to a MOVCPM command, press only a carriage + return. Typing a drive name d causes the + response: + + + + 1-31 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + SOURCE ON d THEN TYPE RETURN + + Place a disk containing the CP/M operating + system on drive d (d is one of A, B, C, or + D). Answer by pressing a carriage return + when ready. + + + FUNCTION COMPLETE + + System is copied to memory. SYSGEN then + prompts with the following: + + + DESTINATION DRIVE NAME + (OR RETURN TO REBOOT) + + If a disk is being initialized, place the + new disk into a drive and answer with the + drive name. Otherwise, press a carriage + return and the system reboots from drive A. + Typing drive name d causes SYSGEN to prompt + with the following message: + + + DESTINATION ON d + THEN TYPE RETURN + + Place new disk into drive d; press return + when ready. + + + FUNCTION COMPLETE + + New disk is initialized in drive d. + + +The DESTINATION prompt is repeated until a single carriage return is +pressed at the console, so that more than one disk can be +initialized. + + Upon completion of a successful system generation, the new disk +contains the operating system, and only the built-in commands are +available. An IBM-compatible disk appears to CP/M as a disk with an +empty directory; therefore, the operator must copy the appropriate +COM files from an existing CP/M disk to the newly constructed disk +using the PIP transient. + + You can copy all files from an existing disk by typing the +following PIP command: + + PIP B: = A:*.*[v] + + + + + + 1-32 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + +This command copies all files from disk drive A to disk drive B and +verifies that each file has been copied correctly. The name of each +file is displayed at the console as the copy operation proceeds. + + Note that a SYSGEN does not destroy the files that already +exist on a disk; it only constructs a new operating system. If a +disk is being used only on drives B through P and will never be the +source of a bootstrap operation on drive A, the SYSGEN need not take +place. + + +1.6.7 SUBMIT Command + +Syntax: + + SUBMIT ufn parm#1 ... parm#n + + The SUBMIT command allows CP/M commands to be batched for +automatic processing. The ufn given in the SUBMIT command must be +the filename of a file that exists on the currently logged disk, +with an assumed file type of SUB. The SUB file contains CP/M +prototype commands with possible parameter substitution. The actual +parameters parm#1 ... parm#n are substituted into the prototype +commands, and, if no errors occur, the file of substituted commands +are processed sequentially by CP/M. + + The prototype command file is created using the ED program, +with interspersed $ parameters of the form: + + $1 $2 $3 ...$n + +corresponding to the number of actual parameters that will be +included when the file is submitted for execution. When the SUBMIT +transient is executed, the actual parameters parm#1 ... parm#n are +paired with the formal parameters $1 ... $n in the prototype +commands. If the numbers of formal and actual parameters do not +correspond, the SUBMIT function is aborted with an error message at +the console. The SUBMIT function creates a file of substituted +commands with the name + + $$$.SUB + +on the logged disk. When the system reboots, at the termination of +the SUBMIT, this command file is read by the CCP as a source of +input rather than the console. If the SUBMIT function is performed +on any disk other than drive A, the commands are not processed until +the disk is inserted into drive A and the system reboots. You can +abort command processing at any time by pressing the rubout key when +the command is read and echoed. In this case, the $$$.SUB file is +removed and the subsequent commands come from the console. Command +processing is also aborted if the CCP detects an error in any of the +commands. Programs that execute under CP/M can abort processing of +command files when error conditions occur by erasing any existing +$$$.SUB file. + + + + 1-33 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + To introduce dollar signs into a SUBMIT file, you can type a $$ +which reduces to a single $ within the command file. A caret, ^, +precedes an alphabetic character s, which produces a single CTRL-X +character within the file. + + The last command in a SUB file can initiate another SUB file, +allowing chained batch commands: + + Suppose the file ASMBL.SUB exists on disk and contains the +prototype commands + + ASM $1 + DIR $1.* + ERA *.BAK + PIP $2:=$1.PRN + ERA $1.PRN + +then, you issue the following command: + + SUBMIT ASMBL X PRN + +The SUBMIT program reads the ASMBL.SUB file, substituting X: for all +occurrences of $1 and PRN for all occurrences of $2. This results +in a $$$.SUB file containing the commands: + + ASM X + DIR X.* + ERA *.BAK + PIP PRN:=X.PRN + ERA X.PRN + +which are executed in sequence by the CCP. + + The SUBMIT function can access a SUB file on an alternate drive +by preceding the filename by a drive name. Submitted files are only +acted upon when they appear on drive A. Thus, it is possible to +create a submitted file on drive B that is executed at a later time +when inserted in drive A. + + An additional utility program called XSUB extends the power of +the SUBMIT facility to include line input to programs as well as the +CCP. The XSUB command is included as the first line of the SUBMIT +file. When it is executed, XSUB self-relocates directly below the +CCP. All subsequent SUBMIT command lines are processed by XSUB so +that programs that read buffered console input, BDOS Function 10, +receive their input directly from the SUBMIT file. For example, the +file SAVER.SUB can contain the following SUBMIT lines: + + XSUB + DDT + |$1.COM + R + GO + SAVE 1 $2.COM + + + + 1-34 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + +a subsequent SUBMIT command, such as + + A>SUBMIT SAVER PIP Y + +substitutes X for $1 and Y for $2 in the command stream. The XSUB +program loads, followed by DDT, which is sent to the command lines +PIP.COM, R, and G0, thus returning to the CCP. The final command +SAVE 1 Y.COM is processed by the CCP. + + The XSUB program remains in memory and prints the message + + (xsub active) + +on each warm start operation to indicate its presence. Subsequent +SUBMIT command streams do not require the XSUB, unless an +intervening cold start occurs. Note that XSUB must be loaded after +the optional CP/M DESPOOL utility, if both are to run +simultaneously. + + +1.6.8 DUMP Command + +Syntax: + + DUMP ufn + + The DUMP program types the contents of the disk file (ufn) at +the console in hexadecimal form. The file contents are listed +sixteen bytes at a time, with the absolute byte address listed to +the left of each line in hexadecimal. Long typeouts can be aborted +by pressing the rubout key during printout. The source listing of +the DUMP program is given in Section 5 as an example of a program +written for the CP/M environment. + + +1.6.9 MOVCPM Command + +Syntax: + + MOVCPM + + The MOVCPM program allows you to reconfigure the CP/M system +for any particular memory size. Two optional parameters can be used +to indicate the desired size of the new system and the disposition +of the new system at program termination. If the first parameter is +omitted or an * is given, the MOVCPM program reconfigures the system +to its maximum size, based upon the kilobytes of contiguous RAM in +the host system (starting at 0000H). If the second parameter is +omitted, the system is executed, but not permanently recorded; if * +is given, the system is left in memory, ready for a SYSGEN +operation. The MOVCPM program relocates a memory image of CP/M and +places this image in memory in preparation for a system generation +operation. The following is a list of MOVCPM command forms: + + + + + 1-35 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + MOVCPM Relocates and executes CP/M for management + of the current memory configuration (memory + is examined for contiguous RAM, starting at + 100H). On completion of the relocation, the + new system is executed but not permanently + recorded on the disk. The system that is + constructed contains a BIOS for the Intel + microcomputer development system 800. + + MOVCPM n Creates a relocated CP/M system for + management of an n kilobyte system (n must + be in the range of 20 to 64), and executes + the system as described. + + MOVCPM * * Constructs a relocated memory image for the + current memory configuration, but leaves the + memory image in memory in preparation for a + SYSGEN operation. + + MOVCPM n * Constructs a relocated memory image for an n + kilobyte memory system, and leaves the + memory image in preparation for a SYSGEN + operation. + + + For example, the command, + + MOVCPM * * + +constructs a new version of the CP/M system and leaves it in memory, +ready for a SYSGEN operation. The message + + READY FOR 'SYSGEN' OR + 'SAVE 34 CPMxx.COM' + +appears at the console upon completion, where xx is the current +memory size in kilobytes. You can then type the following sequence: + + + SYSGEN This starts the system + generation. + + SOURCE DRIVE NAME Respond with a carriage return + (OR RETURN TO SKIP) to skip the CP/M read operation, + because the system is already + in memory as a result of the + previous MOVCPM operation. + + DESTINATION DRIVE NAME Respond with B to write new + (OR RETURN TO REBOOT) system to the disk in drive B. + SYSGEN prompts with the + following message: + + DESTINATION ON B, Place the new disk on drive B + THEN TYPE RETURN and press the RETURN key when + ready. + + 1-36 + + + + + +CP/M Operating System Manual 1.6 Transient Commands + + + + If you respond with A rather than B above, the system is +written to drive A rather than B. SYSGEN continues to print this +prompt: + + DESTINATION DRIVE NAME (OR RETURN TO REBOOT) + +until you respond with a single carriage return, which stops the +SYSGEN program with a system reboot. + + You can then go through the reboot process with the old or new +disk. Instead of performing the SYSGEN operation, you can type a +command of the form: + + SAVE 34 CPMxx.COM + +at the completion of the MOVCPM function, where xx is the value +indicated in the SYSGEN message. The CP/M memory image on the +currently logged disk is in a form that can be patched. This is +necessary when operating in a nonstandard environment where the BIOS +must be altered for a particular peripheral device configuration, as +described in Section 6. + + The following are valid MOVCPM commands: + + + MOVCPM 48 Constructs a 48K version of CP/M and starts + execution. + + MOVCPM 48 * Constructs a 48K version of CP/M in + preparation for permanent recording; the + response is + + READY FOR 'SYSGEN' OR + 'SAVE 34 CPM48.COM' + + MOVCPM * * Constructs a maximum memory version of CP/M + and starts execution. + + The newly created system is serialized with the number attached +to the original disk and is subject to the conditions of the Digital +Research Software Licensing Agreement. + + +1.7 BDOS Error Messages + + There are three error situations that the Basic Disk Operating +System intercepts during file processing. When one of these +conditions is detected, the BDOS prints the message: + + BDOS ERR ON d: error + + + + + + + 1-37 + + + + + +CP/M Operating System Manual 1.7 BDOS Error Messages + + +where d is the drive name and error is one of the three error +messages: + + BAD SECTOR + SELECT + READ ONLY + + The BAD SECTOR message indicates that the disk controller +electronics has detected an error condition in reading or writing +the disk. This condition is generally caused by a malfunctioning +disk controller or an extremely worn disk. If you find that CP/M +reports this error more than once a month, the state of the +controller electronics and the condition of the media should be +checked. + + You can also encounter this condition in reading files +generated by a controller produced by a different manufacturer. +Even though controllers claim to be IBM..-compatible, one often +finds small differences in recording formats. The Model 800 +controller, for example, requires two bytes of one's following the +data CRC byte, which is not required in the IBM format. As a +result, disks generated by the Intel microcomputer development +system can be read by almost all other IBM-compatible system, while +disk files generated on other manufacturers' equipment produce the +BAD SECTOR message when read by the microcomputer development +system. To recover from this condition, press a CTRL-C to reboot +(the safest course), or a return, which ignores the bad sector in +the file operation. + +Note: pressing a return might destroy disk integrity if the +operation is a directory write. Be sure you have adequate back-ups +in this case. + + The SELECT error occurs when there is an attempt to address a +drive beyond the range supported by the BIOS. In this case, the +value of d in the error message gives the selected drive. The +system reboots following any input from the console. + + The READ ONLY message occurs when there is an attempt to write +to a disk or file that has been designated as Read-Only in a STAT +command or has been set to Read-Only by the BDOS. Reboot CP/M by +using the warm start procedure, CTRL-C, or by performing a cold +start whenever the disks are changed. If a changed disk is to be +read but not written, BDOS allows the disk to be changed without the +warm or cold start, but internally marks the drive as Read-Only. +The status of the drive is subsequently changed to Read-Write if a +warm or cold start occurs. On issuing this message, CP/M waits for +input from the console. An automatic warm start takes place +following any input. + + +1.8 CP/M Operation on the Model 800 + + + + + + 1-38 + + + + + +CP/M Operating System Manual 1.8 Operation of CP/M on the Model 800 + + + This section gives operating procedures for using CP/M on the +Intel Model 800 microcomputer development system microcomputer +development system. Basic knowledge of the microcomputer +development system hardware and software systems is assumed. + + CP/M is initiated in essentially the same manner as the Intel +ISIS operating system. The disk drives are labeled 0 through 3 on +the microcomputer development system, corresponding to CP/M drives A +through D, respectively. The CP/M system disk is inserted into +drive 0, and the BOOT and RESET switches are pressed in sequence. +The interrupt 2 light should go on at this point. The space bar is +then pressed on the system console, and the light should go out. If +it does not, the user should check connections and baud rates. The +BOOT switch is turned off, and the CP/M sign-on message should +appear at the selected console device, followed by the A> system +prompt. You can then issue the various resident and transient +commands. + + The CP/M system can be restarted (warm start) at any time by +pushing the INT 0 switch on the front panel. The built-in Intel ROM +monitor can be initiated by pushing the INT 7 switch, which +generates an RST 7, except when operating under DDT, in which case +the DDT program gets control instead. + + Diskettes can be removed from the drives at any time, and the +system can be shut down during operation without affecting data +integrity. Do not remove a disk and replace it with another without +rebooting the system (cold or warm start) unless the inserted disk +is Read-Only. + + As a result of hardware hang-ups or malfunctions, CP/M might +print the following message: + + BDOS ERR ON d: BAD SECTOR + +where d is the drive that has a permanent error. This error can +occur when drive doors are opened and closed randomly, followed by +disk operations, or can be caused by a disk, drive, or controller +failure. You can optionally elect to ignore the error by pressing a +single return at the console. The error might produce a bad data +record, requiring reinitialization of up to 128 bytes of data. You +can reboot the CP/M system and try the operation again. + + Termination of a CP/M session requires no special action, +except that it is necessary to remove the disks before turning the +power off to avoid random transients that often make their way to +the drive electronics. + + You should use IBM-compatible disks rather than disks that have +previously been used with any ISIS version. In particular, the ISIS +FORMAT operation produces nonstandard sector numbering throughout +the disk. This nonstandard numbering seriously degrades the +performance of CP/M, and causes CP/M to operate noticeably slower +than the distribution version. If it becomes necessary to reformat +a disk, which should not be the case for standard disks, a program + + + 1-39 + + + + + +CP/M Operating System Manual 1.8 Operation of CP/M on the Model 800 + + +can be written under CP/M that causes the Model 800 controller to +reformat with sequential sector numbering (1-26) on each track. + + Generally, IBM-compatible 8-inch disks do not need to be +formatted. However, 5 1/4-inch disks need to be formatted. + + +End of Section 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1-40 + + + + + + + + +Section 2 + +The CP/M Editor + + + +2.1 Introduction to Ed + + Ed is the context editor for CP/M, and is used to create and +alter CP/M source files. To start ED, type a command of the +following form: + + ED filename +or + ED filename.typ + +Generally, ED reads segments of the source file given by filename or +filename.typ into the central memory, where you edit the file and it +is subsequently written back to disk after alterations. If the +source file does not exist before editing, it is created by ED and +initialized to empty. The overall operation of Ed is shown in +Figure 2-1. + + +2.1.1 ED Operation + + Ed operates upon the source file, shown in Figure 2-1 by x.y, +and passes all text through a memory buffer where the text can be +viewed or altered. The number of lines that can be maintained in +the memory buffer varies with the line length, but has a total +capacity of about 5000 characters in a 20K CP/M system. + + Edited text material is written into a temporary work file +under your command. Upon termination of the edit, the memory buffer +is written to the temporary file, followed by any remaining (unread) +text in the source file. The name of the original file is changed +from x.y to x.BAK so that the most recent edited source file can be +reclaimed if necessary. See the CP/M commands ERASE and RENAME. +The temporary file is then changed from x.$$$ to x.y, which becomes +the resulting edited file. + + The memory buffer is logically between the source file and +working file, as shown in Figure 2-2. + + + + + + + + + + + + + + + 2-1 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Figure 2-1. Overall ED Operation + + + + Source File Memory Buffer Temporary File + + 1 First Line 1 First Line 1 First Line + 2 Appended 2 Buffered 2 Processed + 3 Lines 3 Text 3 Text + + + + SP MP TP + + + + Unprocessed Next Free Next Free File + Source Append Memory Write Space + Lines Space + + + + SP = Source Pointer + MP = Memory Pointer + TP = Temporary Pointer + + +Figure 2-2. Memory Buffer Organization + + + 2-2 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +2.1.2 Text Transfer Functions + + Given that n is an integer value in the range 0 through 65535, +several single-letter ED commands transfer lines of text from the +source file through the memory buffer to the temporary (and +eventually final) file. Single letter commands are shown in upper- +case, but can be typed in either upper- or lower-case. + + +Table 2-1. ED Text Transfer Commands + + Command Result + + F + nA Appends the next n unprocessed source lines + from the source file at SP to the end of the + memory buffer at MP. Increment SP and MP by n. + If upper-case translation is set (see the U + command) and the A command is typed in upper- + case, all input lines will automatically be + translated to upper-case. + + nW Writes the first n lines of the memory buffer + to the temporary file free space. Shift the + remaining lines n+1 through MP to the top of + the memory buffer. Increment TP by n. + + E Ends the edit. Copy all buffered text to + temporary file and copy all unprocessed source + lines to temporary file. Rename files. + + H Moves to head of new file by performing + automatic E command. The temporary file + becomes the new source file, the memory buffer + is emptied, and a new temporary file is + created. The effect is equivalent to issuing + an E command, followed by a reinvocation of ED, + using x.y as the file to edit. + + O Returns to original file. The memory buffer is + emptied, the temporary file is deleted, and the + SP is returned to position 1 of the source + file. The effects of the previous editing + commands are thus nullified. + + Q Quits edit with no file alterations, returns to + CP/M. + K + + + There are a number of special cases to consider. If the +integer n is omitted in any ED command where an integer is allowed, +then 1 is assumed. Thus, the commands A and W append one line and +write one line, respectively. In addition, if a pound sign # is +given in the place of n, then the integer 65535 is assumed (the +largest value for n that is allowed). Because most source files can +be contained entirely in the memory buffer, the command #A is often + + + 2-3 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +issued at the beginning of the edit to read the entire source file +to memory. Similarly, the command #W writes the entire buffer to +the temporary file. + + Two special forms of the A and W commands are provided as a +convenience. The command 0A fills the current memory buffer at +least half full, while 0W writes lines until the buffer is at least +half empty. An error is issued if the memory buffer size is +exceeded. You can then enter any command, such as W, that does not +increase memory requirements. The remainder of any partial line +read during the overflow will be brought into memory on the next +successful append. + + +2.1.3 Memory Buffer Organization + + The memory buffer can be considered a sequence of source lines +brought in with the A command from a source file. The memory buffer +has an imaginary character pointer (CP) that moves throughout the +memory buffer under command of the operator. + + The memory buffer appears logically as shown in Figure 2-3, +where the dashes represent characters of the source line of +indefinite length, terminated by carriage return () and line- +feed () characters, and CP represents the imaginary character +pointer. Note that the CP is always located ahead of the first +character of the first line, behind the last character of the last +line, or between two characters. The current line CL is the source +line that contains the CP. + + + + Memory Buffer + + + first line ----------------------- + + + ----------------------- + + + current line CL --------------------------- + + + CP + + last line ----------------------- + + + Figure 2-3. Logical Organization of Memory Buffer + + + + + + + + 2-4 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +2.1.4 Line Numbers and ED Start-up + + ED produces absolute line number prefixes that are used to +reference a line or range of lines. The absolute line number is +displayed at the beginning of each line when ED is in insert mode +(see the I command in Section 2.1.5). Each line number takes the +form + + nnnnn: + +where nnnnn is an absolute line number in the range of 1 to 65535. +If the memory buffer is empty or if the current line is at the end +of the memory buffer, nnnnn appears as 5 blanks. + + You can reference an absolute line number by preceding any +command by a number followed by a colon, in the same format as the +line number display. In this case, the ED program moves the current +line reference to the absolute line number, if the line exists in +the current memory buffer. The line denoted by the absolute line +number must be in the memory buffer (see the A command). Thus, the +command + + 345:T + +is interpreted as move to absolute 345, and type the line. +Absolute line numbers are produced only during the editing process +and are not recorded with the file. In particular, the line numbers +will change following a deleted or expanded section of text. + + You can also reference an absolute line number as a backward or +forward distance from the current line by preceding the absolute +number by a colon. Thus, the command + + :400T + +is interpreted as type from the current line number through the line +whose absolute number is 400. Combining the two line reference +forms, the command + + 345::400T + +is interpreted as move to absolute line 345, then type through +absolute line 400. Absolute line references of this sort can +precede any of the standard ED commands. + + Line numbering is controlled by the V (Verify Line Numbers) +command. Line numbering can be turned off by typing the -V command. + + + + + + + + + + + 2-5 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +If the file to edit does not exist, ED displays the following +message: + + NEW FILE + +To move text into the memory buffer, you must enter an i command +before typing input lines and terminate each line with a carriage +return. A single CTRL-Z character returns ED to command mode. + + +2.1.5 Memory Buffer Operation + + When ED begins, the memory buffer is empty. You can either +append lines from the source file with the A command, or enter the +lines directly from the console with the insert command. The insert +command takes the following form: + + I + +ED then accepts any number of input lines. You must terminate each +line with a (the is supplied automatically). A single +CTRL-Z, denoted by a caret (^)Z, returns ED to command mode. The CP +is positioned after the last character entered. The following +sequence: + + I + NOW IS THE + TIME FOR + ALL GOOD MEN + ^Z + +leaves the memory buffer as + + NOW IS THE + TIME FOR + ALL GOOD MEN + + Generally, ED accepts command letters in upper- or lower-case. +If the command is upper-case, all input values associated with the +command are translated to upper-case. If the I command is typed, +all input lines are automatically translated internally to upper- +case. The lower-case form of the i command is most often used to +allow both upper- and lower-case letters to be entered. + + Various commands can be issued that control the CP or display +source text in the vicinity of the CP. The commands shown below +with a preceding n indicate that an optional unsigned value can be +specified. When preceded by +_, the command can be unsigned, or have +an optional preceding plus or minus sign. As before, the pound sign +# is replaced by 65535. If an integer n is optional, but not +supplied, then n=1 is assumed. Finally, if a plus sign is optional, +but none is specified, then + is assumed. + + + + + + 2-6 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +Table 2-2. Editing Commands + + Command Action + + F + +_B Move CP to beginning of memory buffer if + and + to bottom if -. + + +_nC Move CP by +_n characters (moving ahead if +), + counting the as two characters. + + +_nD Delete n characters ahead of CP if plus and + behind CP if minus. + + +_nK Kill (remove) +_n lines of source text using CP + as the current reference. If CP is not at the + beginning of the current line when K is issued, + the characters before CP remain if + is + specified, while the characters after CP remain + if - is given in the command. + + +_nL If n = 0, move CP to the beginning of the + current line, if it is not already there. If n + =/ 0, first move the CP to the beginning of the + current line and then move it to the beginning + of the line that is n lines down (if +) or up + (if -). The CP will stop at the top or bottom + of the memory buffer if too large a value of n + is specified. + + +_nT If n = 0, type the contents of the current line + up to CP. If n = 1, type the contents of the + current line from CP to the end of the line. + If n>1, type the current line along with n - 1 + lines that follow, if + is specified. + Similarly, if n>1 and - is given, type the + previous n lines up to the CP. Any key can be + depressed to abort long type-outs. + + +_n Equivalent to +_nLT, which moves up or down and + types a single line. + K + + + +2.1.6 Command Strings + + Any number of commands can be typed contiguously (up to the +capacity of the console buffer) and are executed only after you +press the . Table 2-3 summarizes the CP/M console line-editing +commands used to control the input command line. + + + + + + + + + 2-7 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +Table 2-3. Line-editing Controls + + Command Result + + F + CTRL-C Reboots the CP/M system when typed at the + start of a line. + + CTRL-E Physical end of line: carriage is returned, + but line is not sent until the carriage return + key is depressed. + + CTRL-H Backspaces one character position. + + CTRL-J Terminates current input (line-feed). + + CTRL-M Terminates current input (carriage return). + + CTRL-R Retypes current command line: types a clean + line character deletion with rubouts. + + CTRL-U Deletes the entire line typed at the console. + + CTRL-X Same as CTRL-U. + + CTRL-Z Ends input from the console (used in PIP and + ED). + + rub/del Deletes and echos the last character typed at + the console. + K + + + Suppose the memory buffer contains the characters shown in the +previous section, with the CP following the last character of the +buffer. In the following example, the command strings on the left +produce the results shown to the right. Use lower-case command +letters to avoid automatic translation of strings to upper-case. + + + Command String Effect + + F + B2T Move to beginning of the buffer and type + two lines: + + NOW IS THE + TIME FOR + The result in the memory buffer is + + NOW IS THE + TIME FOR + ALL GOOD MEN + + + + + + + + 2-8 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + + Command String Effect + + 5C0T Move CP five characters and type the + beginning of the line NOW I. The result + in the memory buffer is + + NOW I S THE + + + 2L-T Move two lines down and type the previous + line TIME FOR. The result in the memory + buffer is + + NOW IS THE + TIME FOR + ALL GOOD MEN + + + -L#K Move up one line, delete 65535 lines that + follow. The result in the memory buffer + is + + NOW IS THE + + + I Insert two lines of text with automatic + TIME TO translation to upper-case. The result in + INSERT the memory buffer is + ^Z + + NOW IS THE + TIME TO + INSERT + + + -2L#T Move up two lines and type 65535 lines + ahead of CP NOW IS THE. The result in the + memory buffer is + + NOW IS THE + TIME TO + INSERT + + + Move down one line and type one line + INSERT. The result in the memory buffer + is + + NOW IS THE + TIME TO + INSERT + K + + + + + + + 2-9 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +2.1.7 Text Search and Alteration + + ED has a command that locates strings within the memory buffer. +The command takes the form + + nF s +or + nF s ^Z + +where s represents the string to match, followed by either a or +CTRL-Z, denoted by ^Z. ED starts at the current position of CP and +attempts to match the string. The match is attempted n times and, +if successful, the CP is moved directly after the string. If the n +matches are not successful, the CP is not moved from its initial +position. Search strings can include CTRL-L, which is replaced by +the pair of symbols . + + The following commands illustrate the use of the F command: + + + Command String Effect + + F + B#T Move to the beginning and type the entire + buffer. The result in the memory buffer + is + + NOW IS THE + TIME FOR + ALL GOOD MEN + + + FS T Find the end of the string S T. The + result in the memory buffer is + + NOW IS T HE + + + FIs^Z0TT Find the next I and type to the CP; then + type the remainder of the current line ME + FOR. The result in the memory buffer is + + NOW IS THE + TI ME FOR + + ALL GOOD MEN + K + + + An abbreviated form of the insert command is also allowed, +which is often used in conjunction with the F command to make simple +textual changes. The form is + + | s ^Z +or + | s + + + + 2-10 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +where s is the string to insert. If the insertion string is +terminated by a CTRL-Z, the string is inserted directly following +the CP, and the CP is positioned directly after the string. The +action is the same if the command is followed by a except that +a is automatically inserted into the text following the +string. The following command sequences are examples of the F and I +commands: + + + Command String Effect + F + + BITHIS IS ^Z + + Insert THIS IS at the beginning of the + text. The result in the memory buffer is + + THIS IS NOW THE + + TIME FOR + ALL GOOD MEN + + + FTIME^Z-4DIPLACE^Z + + Find TIME and delete it; then insert + PLACE. The result in the memory buffer is + + THIS IS NOW THE + PLACE FOR + + ALL GOOD MEN + + + 3FO^Z-3D5D1 + CHANGES^Z Find third occurrence of O (that is, the + second O in GOOD), delete previous 3 + characters and the subsequent 5 + characters; then insert CHANGES. The + result in the memory buffer is + + THIS IS NOW THE + PLACE FOR + ALL CHANGES + + + -8CISOURCE + + Move back 8 characters and insert the line + SOURCE. The result in the memory + buffer is + + THIS IS NOW THE + PLACE FOR + ALL SOURCE + CHANGES + + + 2-11 + + + + K + + +CP/M Operating System Manual 2.1 Introduction to ED + + + + + ED also provides a single command that combines the F and I +commands to perform simple string substitutions. The command takes +the following form: + + nS s1^Zs2 +or + nS s1^Zs2 ^Z + +and has exactly the same effect as applying the following command +string a total of n times: + + F s1^Z-kDIs2 +or + F s1^Z-kDIs2 ^Z + +where k is the length of the string. ED searches the memory buffer +starting at the current position of CP and successively substitutes +the second string for the first string until the end of buffer, or +until the substitution has been performed n times. + + As a convenience, a command similar to F is provided by ED that +automatically appends and writes lines as the search proceeds. The +form is + + n N s +or + n N s ^Z + +which searches the entire source file for the nth occurrence of the +strings (you should recall that F fails if the string cannot be +found in the current buffer). The operation of the N command is +precisely the same as F except in the case that the string cannot be +found within the current memory buffer. In this case, the entire +memory content is written (that is, an automatic #W is issued). +Input lines are then read until the buffer is at least half full, or +the entire source file is exhausted. The search continues in this +manner until the string has been found n times, or until the source +file has been completely transferred to the temporary file. + + A final line editing function, called the juxtaposition +command, takes the form + + n J s1^Zs2^Zs3 +or + n J s1^Zs2^Zs3 ^Z + +with the following action applied n times to the memory buffer: +search from the current CP for the next occurrence of the string s1. +If found, insert the string s2, and move CP to follow s2. Then +delete all characters following CP up to, but not including, the +string s3, leaving CP directly after s2. If s3 cannot be found, +then no deletion is made. If the current line is + + + + 2-12 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + + NOW IS THE TIME + +the command + + JW ^ZWHAT^Z^1 + +results in + + NOW WHAT + +You should recall that ^1 (CTRL-L) represents the pair in +search and substitute strings. + + The number of characters ED allows in the F, S, N, and J +commands is limited to 100 symbols. + + +2.1.8 Source Libraries + + ED also allows the inclusion of source libraries during the +editing process with the R command. The form of this command is + + R filename ^Z +or + R filename + +where filename is the primary filename of a source file on the disk +with an assumed filetype of LIB. ED reads the specified file, and +places the characters into the memory buffer after CP, in a manner +similar to the I command. Thus, if the command + + RMACRO + +is issued by the operator, ED reads from the file MACRO.LIB until +the end-of-file and automatically inserts the characters into the +memory buffer. + + ED also includes a block move facility implemented through the +X (Transfer) command. The form + + nX + +transfers the next n lines from the current line to a temporary file +called + + X$$$$$$.LIB + +which is active only during the editing process. You can reposition +the current line reference to any portion of the source file and +transfer lines to the temporary file. The transferred lines +accumulate one after another in this file and can be retrieved by +simply typing + + R + + + + 2-13 + + + + + +CP/M Operating System Manual 2.1 Introduction to ED + + +which is the trivial case of the library read command. In this +case, the entire transferred set of lines is read into the memory +buffer. Note that the X command does not remove the transferred +lines from the memory buffer, although a K command can be used +directly after the X, and the R command does not empty the +transferred LIB file. That is, given that a set of lines has been +transferred with the X command, they can be reread any number of +times back into the source file. The command + + 0X + +is provided to empty the transferred line file. + + Note that upon normal completion of the ED program through Q or +E, the temporary LIB file is removed. If ED is aborted with a CTRL- +C, the LIB file will exist if lines have been transferred, but will +generally be empty (a subsequent ED invocation will erase the +temporary file). + + +2.1.9 Repetitive Command Execution + + The macro command M allows you to group ED commands together +for repeated evaluation. The M command takes the following form: + + n M CS +or + n M CS ^Z + +where CS represents a string of ED commands, not including another M +command. ED executes the command string n times if n>1. If n=0 or +1, the command string is executed repetitively until an error +condition is encountered (for example, the end of the memory buffer +is reached with an F command). + + As an example, the following macro changes all occurrences of +GAMMA to DELTA within the current buffer, and types each line that +is changed: + + MFGAMMA^Z-5DIDELTA^Z0TT + +or equivalently + + MSGAMMA^ZDELTA^Z0TT + + +2.2 ED Error Conditions + + On error conditions, ED prints the message BREAK X AT C where X +is one of the error indicators shown in Table 2-4. + + + + + + + + 2-14 + + + + + +CP/M Operating System Manual 2.2 ED Error Conditions + + +Table 2-4. Error Message Symbols + + Symbol Meaning + + H + ? Unrecognized command. + + > Memory buffer full (use one of the commands D, K, + N, S, or W to remove characters); F, N, or S + strings too long. + + # Cannot apply command the number of times + specified (for example, in F command). + + O Cannot open LIB file in R command. + K + + +If there is a disk error, CP/M displays the following message: + + BDOS ERR on d: BAD SECTOR + +You can choose to ignore the error by pressing RETURN at the console +(in this case, the memory buffer data should be examined to see if +they were incorrectly read), or you can reset the system with a +CTRL-C and reclaim the back-up file if it exists. The file can be +reclaimed by first typing the contents of the BAK file to ensure +that it contains the proper information. For example, type the +following: + + TYPE x.BAK + +where x is the file being edited. Then remove the primary file + + ERA x.y + +and rename the BAK file + + REN x.y=x.BAK + +The file can then be reedited, starting with the previous version. + + ED also takes file attributes into account. If you attempt to +edit a Read-Only file, the message + + ** FILE IS READ/ONLY ** + +appears at the console. The file can be loaded and examined, but +cannot be altered. You must end the edit session and use STAT to +change the file attribute to R/W. If the edited file has the system +attribute set, the following message: + + 'SYSTEM' FILE NOT ACCESSIBLE + +is displayed and the edit session is aborted. Again, the STAT +program can be used to change the system attribute, if desired. + + + + 2-15 + + + + + +CP/M Operating System Manual 2.3 Control Characters and Commands + + +2.3 Control Characters and Commands + + Table 2-5 summarizes the control characters and commands +available in ED. + + +Table 2-5. ED Control Characters + + F + Control Function + Character + + CTRL-C System reboot + + CTRL-E Physical (not actually entered in + command) + + CTRL-H Backspace + + CTRL-J Logical tab (cols 1, 9, 16, ...) + + CTRL-L Logical in search and substitute + strings + + CTRL-R Repeat line + + CTRL-U Line delete + + CTRL-X Line delete + + CTRL-Z String terminator + + rub/del Character delete + + K + + Table 2-6 summarizes the commands used in ED. + + +Table 2-6. ED Commands + + Command Function + F + + nA Append lines + + +_B Begin or bottom of buffer + + +_nC Move character positions + + +_nD Delete characters + + E End edit and close files (normal end) + + nF Find string + + + + + + 2-16 + + + + K + + +CP/M Operating System Manual 2.3 Control Characters and Commands + + +Table 2-6. (continued) + + Command Function + F + + H End edit, close and reopen files + + I Insert characters, use i if both upper and + lower-case characters are to be entered. + + nJ Place strings in juxtaposition + + +_nK Kill lines + + +_nL Move down/up lines + + nM Macro definition + + nN Find next occurrence with autoscan + + O Return to original file + + +_nP Move and print pages + + Q Quit with no file changes + + R Read library file + + nS Substitute strings + + +_nT Type lines + + +_U Translate lower- to upper-case if U, no + translation if -U + + +_V Verify line numbers, or show remaining + free character space + + 0V A special case of the V command, OV, + prints the memory buffer statistics in the + form + + free/total + + where free is the number of free bytes in + the memory buffer (in decimal) and total + is the size of the memory buffer + + nW Write lines + + nZ Wait (sleep) for approximately n seconds + + +_n Move and type (+_nLT). + K + + + + + + 2-17 + + + + + +CP/M Operating System Manual 2.3 Control Characters and Commands + + + Because of common typographical errors, ED requires several +potentially disastrous commands to be typed as single letters, +rather than in composite commands. The following commands: + + o E(end) + o H(head) + o O(original) + o Q(quit) + +must be typed as single letter commands. + + The commands I, J, M, N, R, and S should be typed as i, j, m, +n, r, and s if both upper- and lower-case characters are used in the +operation, otherwise all characters are converted to upper-case. +When a command is entered in upper-case, ED automatically converts +the associated string to upper-case, and vice versa. + + +End of Section 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2-18 + + + + + + + + +Section 3 + +CP/M Assembler + + + +3.1 Introduction + + The CP/M assembler reads assembly-language source files from +the disk and produces 8080 machine language in Intel hex format. To +start the CP/M assembler, type a command in one of the following +forms: + + ASM filename + ASM filename.parms + +In both cases, the assembler assumes there is a file on the disk +with the name: + + filename.ASM + +which contains an 8080 assembly-language source file. The first and +second forms shown above differ only in that the second form allows +parameters to be passed to the assembler to control source file +access and hex and print file destinations. + + In either case, the CP/M assembler loads and prints the +message: + + CP/M ASSEMBLER VER n.n + +where n.n is the current version number. In the case of the first +command, the assembler reads the source file with assumed filetype +ASM and creates two output files + + filename.HEX + filename.PRN + + The HEX file contains the machine code corresponding to the +original program in Intel hex format, and the PRN file contains an +annotated listing showing generated machine code, error flags, and +source lines. If errors occur during translation, they are listed +in the PRN file and at the console. + + The form ASM filename parms is used to redirect input and +output files from their defaults. In this case, the parms portion +of the command is a three-letter group that specifies the origin of +the source file, the destination of the hex file, and the +destination of the print file. The form is + + + + + + + + + 3-1 + + + + + +CP/M Operating System Manual 3.1 Introduction + + + filename.p1p2p3 + +where p1, p2, and p3 are single letters. P1 can be + + A,B, ...,P + +which designates the disk name that contains the source file. P2 +can be + + A,B, ...,P + +which designates the disk name that will receive the hex file; or, +P2 can be + + Z + +which skips the generation of the hex file. + + P3 can be + + A,B, ...,P + +which designates the disk name that will receive the print file. P3 +can also be specified as + + X + +which places the listing at the console; or + + Z + +which skips generation of the print file. Thus, the command + + ASM X.AAA + +indicates that the source, X.HEX, and print, X.PRN, files are also +to be created on disk A. This form of the command is implied if the +assembler is run from disk A. Given that you are currently +addressing disk A, the above command is the same as + + ASM X + +The command + + ASM X.ABX + +indicates that the source file is to be taken from disk A, the hex +file is to be placed on disk B, and the listing file is to be sent +to the console. The command + + ASM X.BZZ + +takes the source file from disk B and skips the generation of the +hex and print files. This command is useful for fast execution of +the assembler to check program syntax. + + + 3-2 + + + + + +CP/M Operating System Manual 3.1 Introduction + + + + The source program format is compatible with the Intel 8080 +assembler. Macros are not implemented in ASM; see the optional MAC +macro assembler. There are certain extensions in the CP/M assembler +that make it somewhat easier to use. These extensions are described +below. + + +3.2 Program Format + + An assembly-language program acceptable as input to the +assembler consists of a sequence of statements of the form + + line# label operation operand ;comment + +where any or all of the fields may be present in a particular +instance. Each assembly-language statement is terminated with a +carriage return and line-feed (the line-feed is inserted +automatically by the ED program), or with the character !, which is +treated as an end-of-line by the assembler. Thus, multiple +assembly-language statements can be written on the same physical +line if separated by exclamation point symbols. + + The line# is an optional decimal integer value representing the +source program line number, and ASM ignores this field if present. + + The label field takes either of the following forms: + + identifier + identifier: + +The label field is optional, except where noted in particular +statement types. The identifier is a sequence of alphanumeric +characters where the first character is alphabetic. Identifiers can +be freely used by the programmer to label elements such as program +steps and assembler directives, but cannot exceed 16 characters in +length. All characters are significant in an identifier, except for +the embedded dollar symbol $, which can be used to improve +readability of the name. Further, all lower-case alphabetics are +treated as upper-case. The following are all valid instances of +labels: + + + x xy long$name + + x: yxl: longer$named$data: + + X1Y2 X1x2 x234$5678$9012$3456: + + + The operation field contains either an assembler directive or +pseudo operation, or an 8080 machine operation code. The pseudo +operations and machine operation codes are described in Section 3.3. + + + + + 3-3 + + + + + +CP/M Operating System Manual 3.2 Program Format + + + Generally, the operand field of the statement contains an +expression formed out of constants and labels, along with arithmetic +and logical operations on these elements. Again, the complete +details of properly formed expressions are given in Section 3.3. + + The comment field contains arbitrary characters following the +semicolon symbol until the next real or logical end-of-line. These +characters are read, listed, and otherwise ignored by the assembler. +The CP/M assembler also treats statements that begin with an * in +column one as comment statements that are listed and ignored in the +assembly process. + + The assembly-language program is formulated as a sequence of +statements of the above form, terminated by an optional END +statement. All statements following the END are ignored by the +assembler. + + +3.3 Forming the Operand + + To describe the operation codes and pseudo operations +completely, it is necessary first to present the form of the operand +field, since it is used in nearly all statements. Expressions in +the operand field consist of simple operands, labels, constants, and +reserved words, combined in properly formed subexpressions by +arithmetic and logical operators. The expression computation is +carried out by the assembler as the assembly proceeds. Each +expression must produce a 16-bit value during the assembly. +Further, the number of significant digits in the result must not +exceed the intended use. If an expression is to be used in a byte +move immediate instruction, the most significant 8 bits of the +expression must be zero. The restriction on the expression +significance is given with the individual instructions. + + +3.3.1 Labels + + As discussed above, a label is an identifier that occurs on a +particular statement. In general, the label is given a value +determined by the type of statement that it precedes. If the label +occurs on a statement that generates machine code or reserves memory +space (for example, a MOV instruction or a DS pseudo operation), the +label is given the value of the program address that it labels. If +the label precedes an EQU or SET, the label is given the value that +results from evaluating the operand field. Except for the SET +statement, an identifier can label only one statement. + + When a label appears in the operand field, its value is +substituted by the assembler. This value can then be combined with +other operands and operators to form the operand field for a +particular instruction. + + + + + + + 3-4 + + + + + +CP/M Operating System Manual 3.3 Forming the Operand + + +3.3.2 Numeric Constants + + A numeric constant is a 16-bit value in one of several bases. +The base, called the radix of the constant, is denoted by a trailing +radix indicator. The following are radix indicators: + + o B is a binary constant (base 2). + o O is a octal constant (base 8). + o Q is a octal constant (base 8). + o D is a decimal constant (base 10). + o H is a hexadecimal constant (base 16). + + Q is an alternate radix indicator for octal numbers because the +letter O is easily confused with the digit 0. Any numeric constant +that does not terminate with a radix indicator is a decimal +constant. + + A constant is composed as a sequence of digits, followed by an +optional radix indicator, where the digits are in the appropriate +range for the radix. Binary constants must be composed of 0 and 1 +digits, octal constants can contain digits in the range 0-7, while +decimal constants contain decimal digits. Hexadecimal constants +contain decimal digits as well as hexadecimal digits A(10D), B(11D), +C(12D), D(13D), E(14D), and F(15D). Note that the leading digit of +a hexadecimal constant must be a decimal digit to avoid confusing a +hexadecimal constant with an identifier. A leading 0 will always +suffice. A constant composed in this manner must evaluate to a +binary number that can be contained within a 16-bit counter, +otherwise it is truncated on the right by the assembler. + + Similar to identifiers, embedded $ signs are allowed within +constants to improve their readability. Finally, the radix +indicator is translated to upper-case if a lower-case letter is +encountered. The following are all valid instances of numeric +constants: + + + 1234 1234D 1100B 1111$0000$1111$0000B + + 1234H OFFEH 3377O 33$77$22Q + + 3377o Ofe3h 1234d Offffh + + +3.3.3 Reserved Words + + There are several reserved character sequences that have +predefined meanings in the operand field of a statement. The names +of 8080 registers are given below. When they are encountered, they +produce the values shown to the right. + + + + + + + + 3-5 + + + + + +CP/M Operating System Manual 3.3 Forming the Operand + + + Table 3-1. Reserved Characters + + Character Value + + A 7 + B 0 + C 1 + D 2 + E 3 + H 4 + L 5 + M 6 + SP 6 + PSW 6 + + + Again, lower-case names have the same values as their upper- +case equivalents. Machine instructions can also be used in the +operand field; they evaluate to their internal codes. In the case of +instructions that require operands, where the specific operand +becomes a part of the binary bit pattern of the instruction, for +example, MOV A,B, the value of the instruction, in this case MOV, is +the bit pattern of the instruction with zeros in the optional +fields, for example, MOV produces 40H. + + When the symbol $ occurs in the operand field, not embedded +within identifiers and numeric constants, its value becomes the +address of the next instruction to generate, not including the +instruction contained within the current logical line. + + +3.3.4 String Constants + + String constants represent sequences of ASCII characters and +are represented by enclosing the characters within apostrophe +symbols. All strings must be fully contained within the current +physical line (thus allowing exclamation point symbols within +strings) and must not exceed 64 characters in length. The +apostrophe character itself can be included within a string by +representing it as a double apostrophe (the two keystrokes ''), +which becomes a single apostrophe when read by the assembler. In +most cases, the string length is restricted to either one or two +characters (the DB pseudo operation is an exception), in which case +the string becomes an 8- or 16-bit value, respectively. Two- +character strings become a 16-bit constant, with the second +character as the low-order byte, and the first character as the +high-order byte. + + The value of a character is its corresponding ASCII code. +There is no case translation within strings; both upper- and lower- +case characters can be represented. You should note that only +graphic printing ASCII characters are allowed within strings. + + + + + + 3-6 + + + + + +CP/M Operating System Manual 3.3 Forming the Operand + + + Valid strings: How assembler reads strings: + + 'A' 'AB' 'ab' 'c' A AB ab c + '' 'a''' '''' '''' a' ' ' + 'Walla Walla Wash.' Walla Walla Wash. + 'She said ''Hello'' to me.' She said ''Hello'' to me + 'I said ''Hello'' to her.' I said ''Hello'' to her + + +3.3.5 Arithmetic and Logical Operators + + The operands described in Section 3.3 can be combined in normal +algebraic notation using any combination of properly formed +operands, operators, and parenthesized expressions. The operators +recognized in the operand field are described in Table 3-2. + + +Table 3-2. Arithmetic and Logical Operators + F + + Operators Meaning + + a + b unsigned arithmetic sum of a and b + + a - b unsigned arithmetic difference between a + and b + + + b unary plus (produces b) + + - b unary minus (identical to 0 - b) + + a * b unsigned magnitude multiplication of a and + b + + a / b unsigned magnitude division of a by b + + a MOD b remainder after a / b. + + NOT b logical inverse of b (all 0s become 1s, 1s + become 0s), where b is considered a 16-bit + value + + a AND b bit-by-bit logical and of a and b + + a OR b bit-by-bit logical or of a and b + + a XOR b bit-by-bit logical exclusive or of a and b + + a SHL b the value that results from shifting a to + the left by an amount b, with zero fill + + a SHR b the value that results from shifting a to + the right by an amount b, with zero fill + K + + + + + + 3-7 + + + + + +CP/M Operating System Manual 3.3 Forming the Operand + + + In each case, a and b represent simple operands (labels, +numeric constants, reserved words, and one- or two-character +strings) or fully enclosed parenthesized subexpressions, like those +shown in the following examples: + + + 10+20 10h+37Q LI/3 (L2+4) SHR 3 + + ('a' and 5fh) + '0' ('B'+B) OR (PSW+M) + + (1+(2+c)) shr (A-(B+1)) + + + Note that all computations are performed at assembly time as +16-bit unsigned operations. Thus, -1 is computed as 0-1, which +results in the value 0ffffh (that is, all 1s). The resulting +expression must fit the operation code in which it is used. For +example, if the expression is used in an ADI (add immediate) +instruction, the high-order 8 bits of the expression must be zero. +As a result, the operation ADI-1 produces an error message (-1 +becomes 0ffffh, which cannot be represented as an 8-bit value), +while ADI(-1) AND 0FFH is accepted by the assembler because the AND +operation zeros the high-order bits of the expression. + + +3.3.6 Precedence of Operators + + As a convenience to the programmer, ASM assumes that operators +have a relative precedence of application that allows the programmer +to write expressions without nested levels of parentheses. The +resulting expression has assumed parentheses that are defined by the +relative precedence. The order of application of operators in +unparenthesized expressions is listed below. Operators listed first +have highest precedence (they are applied first in an +unparenthesized expression), while operators listed last have lowest +precedence. Operators listed on the same line have equal +precedence, and are applied from left to right as they are +encountered in an expression. + + + * / MOD SHL SHR + + - + + + NOT + + AND + + OR XOR + + + Thus, the expressions shown to the left below are interpreted +by the assembler as the fully parenthesized expressions shown to the +right. + + + + 3-8 + + + + + +CP/M Operating System Manual 3.3 Forming the Operand + + + a*b+c (a*b)+c + + a+b*c a+(b*c) + + a MOD b*c SHL d ((a MOD b)*c) SHL d + + a OR b AND NOT c+d SHL e a OR (b AND (NOT (c+(d SHL e)))) + + + Balanced, parenthesized subexpressions can always be used to +override the assumed parentheses; thus, the last expression above +could be rewritten to force application of operators in a different +order, as shown: + + (a OR b) AND (NOT c)+ d SHL e + +This results in these assumed parentheses: + + (a OR b) AND ((NOT c) + (d SHL e)) + + An unparenthesized expression is well-formed only if the +expression that results from inserting the assumed parentheses is +well-formed. + + +3.4 Assembler Directives + + Assembler directives are used to set labels to specific values +during the assembly, perform conditional assembly, define storage +areas, and specify starting addresses in the program. Each +assembler directive is denoted by a pseudo operation that appears in +the operation field of the line. The acceptable pseudo operations +are shown in Table 3-3. + + + Table 3-3. Assembler Directives + + Directive Meaning + + ORG set the program or data origin + + END end program, optional start address + + EQU numeric equate + + SET numeric set + + IF begin conditional assembly + + ENDIF end of conditional assembly + + DB define data bytes + + DW define data words + + DS define data storage area + + 3-9 + + + + + +CP/M Operating System Guide 3.4 Assembler Directives + + +3.4.1 The ORG Directive + + The ORG statement takes the form: + + label ORG expression + +where label is an optional program identifier and expression is a +16-bit expression, consisting of operands that are defined before +the ORG statement. The assembler begins machine code generation at +the location specified in the expression. There can be any number +of ORG statements within a particular program, and there are no +checks to ensure that the programmer is not defining overlapping +memory areas. Note that most programs written for the CP/M system +begin with an ORG statement of the form: + + ORG 100H + +which causes machine code generation to begin at the base of the +CP/M transient program area. If a label is specified in the ORG +statement, the label is given the value of the expression. This +label can then be used in the operand field of other statements to +represent this expression. + + +3.4.2 The END Directive + + The END statement is optional in an assembly-language program, +but if it is present it must be the last statement. All subsequent +statements are ignored in the assembly. The END statement takes the +following two forms: + + label END + + label END expression + +where the label is again optional. If the first form is used, the +assembly process stops, and the default starting address of the +program is taken as 0000. Otherwise, the expression is evaluated, +and becomes the program starting address. This starting address is +included in the last record of the Intel-formatted machine code hex +file that results from the assembly. Thus, most CP/M assembly- +language programs end with the statement: + + END 100H + +resulting in the default starting address of 100H (beginning of the +transient program area). + + + + + + + + + + + 3-10 + + + + + +CP/M Operating System Guide 3.4 Assembler Directives + + +3.4.3 The EQU Directive + + The EQU (equate) statement is used to set up synonyms for +particular numeric values. The EQU statement takes the form: + + label EQU expression + +where the label must be present and must not label any other +statement. The assembler evaluates the expression and assigns this +value to the identifier given in the label field. The identifier is +usually a name that describes the value in a more human-oriented +manner. Further, this name is used throughout the program to place +parameters on certain functions. Suppose data received from a +teletype appears on a particular input port, and data is sent to the +teletype through the next output port in sequence. For example, you +can use this series of equate statements to define these ports for a +particular hardware environment: + + + TTYBASE EQU 10H ;BASE PORT NUMBER FOR TTY + + TTYIN EQU TTYBASE ;TTY DATA IN + + TTYOUT EQU TTYBASE+1 ;TTY DATA OUT + + + At a later point in the program, the statements that access the +teletype can appear as follows: + + + IN TTYIN ;READ TTY DATA TO REG-A + + ... + + OUT TTYOUT ;WRITE DATA TO TTY FROM REG-A + + +making the program more readable than if the absolute I/O ports are +used. Further, if the hardware environment is redefined to start +the teletype communications ports at 7FH instead of 10H, the first +statement need only be changed to + + TTYBASE EQU 7FH ;BASE PORT NUMBER FOR TTY + +and the program can be reassembled without changing any other +statements. + + +3.4.4 The SET Directive + + The SET statement is similar to the EQU, taking the form: + + label SET expression + +except that the label can occur on other SET statements within the +program. The expression is evaluated and becomes the current value + + 3-11 + + + + + +CP/M Operating System Guide 3.4 Assembler Directives + + +associated with the label. Thus, the EQU statement defines a label +with a single value, while the SET statement defines a value that is +valid from the current SET statement to the point where the label +occurs on the next SET statement. The use of the SET is similar to +the EQU statement, but is used most often in controlling conditional +assembly. + + +3.4.5 The IF and ENDIF Directives + + The IF and ENDIF statements define a range of assembly-language +statements that are to be included or excluded during the assembly +process. These statements take on the form: + + + IF expression + + statement#1 + + statement#2 + + ... + + statement#n + + ENDIF + + + When encountering the IF statement, the assembler evaluates the +expression following the IF. All operands in the expression must be +defined ahead of the IF statement. If the expression evaluates to a +nonzero value, then statement#1 through statement#n are assembled. +If the expression evaluates to zero, the statements are listed but +not assembled. Conditional assembly is often used to write a single +generic program that includes a number of possible run-time +environments, with only a few specific portions of the program +selected for any particular assembly. The following program +segments, for example, might be part of a program that communicates +with either a teletype or a CRT console (but not both) by selecting +a particular value for TTY before the assembly begins. + + + + + + + + + + + + + + + + + + 3-12 + + + + + +CP/M Operating System Guide 3.4 Assembler Directives + + + TRUE EQU OFFFFH ;DEFINE VALUE OF TRUE + FALSE EQU NOT TRUE ;DEFINE VALUE OF FALSE + ; + TTY EQU TRUE ;TRUE IF TTY, FALSE IF CRT + ; + TTYBASE EQU 10H ;BASE OF TTY I/O PORTS + CRTBASE EQU 20H ;BASE OF CRT I/O PORTS + IF TTY ;ASSEMBLE RELATIVE TO + ;TTYBASE + CONIN EQU TTYBASE ;CONSOLE INPUT + CONOUT EQU TTYBASE+1 ;CONSOLE OUTPUT + ENDIF + + ; IF NOT TTY ;ASSEMBLE RELATIVE TO + ;CRTBASE + CONIN EQU CRTBASE ;CONSOLE INPUT + CONOUT EQU CRTBASE+1 ;CONSOLE OUTPUT + + ENDIF + ... + IN CONIN ;READ CONSOLE DATA + ... + OUT CONTOUT ;WRITE CONSOLE DATA + + +In this case, the program assembles for an environment where a +teletype is connected, based at port 10H. The statement defining +TTY can be changed to + + TTY EQU FALSE + +and, in this case, the program assembles for a CRT based at port +20H. + + +3.4.6 The DB Directive + + The DB directive allows the programmer to define initialized +storage areas in single-precision byte format. The DB statement +takes the form: + + label DB e#1, e#2, ..., e#n + +where e#1 through e#n are either expressions that evaluate to 8-bit +values (the high-order bit must be zero) or are ASCII strings of +length no greater than 64 characters. There is no practical +restriction on the number of expressions included on a single source +line. The expressions are evaluated and placed sequentially into +the machine code file following the last program address generated +by the assembler. String characters are similarly placed into +memory starting with the first character and ending with the last +character. Strings of length greater than two characters cannot be +used as operands in more complicated expressions. + + + + + 3-13 + + + + + +CP/M Operating System Guide 3.4 Assembler Directives + + +Note: ASCII characters are always placed in memory with the parity +bit reset (0). Also, there is no translation from lower- to upper- +case within strings. The optional label can be used to reference +the data area throughout the remainder of the program. The +following are examples of valid DB statements: + + + data: DB 0,1,2,3,4,5 + DB data and 0ffh,5,377Q,1+2+3+4 + + sign-on: DB 'please type your name',cr,lf,0 + DB 'AB' SHR 8, 'C', 'DE' AND 7FH + + + +3.4.7 The DW Directive + + The DW statement is similar to the DB statement except double- +precision two-byte words of storage are initialized. The DW +statement takes the form: + + label DW e#1, e#2, ..., e#n + +where e#1 through e#n are expressions that evaluate to 16-bit +results. Note that ASCII strings of one or two characters are +allowed, but strings longer than two characters are disallowed. In +all cases, the data storage is consistent with the 8080 processor; +the least significant byte of the expression is stored first in +memory, followed by the most significant byte. The following are +examples of DW statements: + + + doub: DW 0ffefh,doub+4,signon-$,255+255 + DW 'a', 5, 'ab', 'CD', 6 shl 8 or llb. + + + +3.4.8 The DS Directive + + The DS statement is used to reserve an area of uninitialized +memory, and takes the form: + + label DS expression + +where the label is optional. The assembler begins subsequent code +generation after the area reserved by the DS. Thus, the DS +statement given above has exactly the same effect as the following +statement: + + label: EQU $ ;LABEL VALUE IS CURRENT CODE LOCATION + ORG $+expression ;MOVE PAST RESERVED AREA + + + + + + + 3-14 + + + + + +CP/M Operating System Manual 3.5 Operation Codes + + +3.5 Operation Codes + + Assembly-language operation codes form the principal part of +assembly-language programs and form the operation field of the +instruction. In general, ASM accepts all the standard mnemonics for +the Intel 8080 microcomputer, which are given in detail in the Intel +8080 Assembly Language Programming Manual. Labels are optional on +each input line. The individual operators are listed briefly in the +following sections for completeness, although the Intel manuals +should be referenced for exact operator details. In Tables 3-4 +through 3-8, bit values have the following meaning: + + + o e3 represents a 3-bit value in the range 0-7 that can be one of + the predefined registers A, B, C, D, E, H, L, M, SP, or PSW. + + o e8 represents an 8-bit value in the range 0-255. + + o e16 represents a 16-bit value in the range 0-65535. + + + These expressions can be formed from an arbitrary combination +of operands and operators. In some cases, the operands are +restricted to particular values within the allowable range, such as +the PUSH instruction. These cases are noted as they are +encountered. + + In the sections that follow, each operation code is listed in +its most general form, along with a specific example, a short +explanation, and special restrictions. + + +3.5.1 Jumps, Calls, and Returns + + The Jump, Call, and Return instructions allow several different +forms that test the condition flags set in the 8080 microcomputer +CPU. The forms are shown in Table 3-4. + + +Table 3-4. Jumps, Calls, and Returns + I + + Form Bit Example Meaning + Value + + JMP e16 JMP L1 Jump unconditionally to label + + JNZ e16 JNZ L2 Jump on nonzero condition to label + + JZ e16 JZ 100H Jump on zero condition to label + + JNC e16 JNC L1+4 Jump no carry to label + + JC e16 JC L3 Jump on carry to label + + JPO e16 JPO $+8 Jump on parity odd to label + + + 3-15 + + + + K + + +CP/M Operating System Manual 3.5 Operation Codes + + +Table 3-4. (continued) + I + + Form Bit Example Meaning + Value + + JPE e16 JPE L4 Jump on even parity to label + + JP e16 JP GAMMA Jump on positive result to label + + JM e16 JM al Jump on minus to label + + + CALL e16 CALL S1 Call subroutine unconditionally + + CNZ e16 CNZ S2 Call subroutine on nonzero + condition + + CZ e16 CZ 100H Call subroutine on zero condition + + CNC e16 CNC S1+4 Call subroutine if no carry set + + CC e16 CC S3 Call subroutine if carry set + + CPO e16 CPO $+8 Call subroutine if parity odd + + CPE e16 CPE $4 Call subroutine if parity even + + CP e16 CP GAMMA Call subroutine if positive result + + CM e16 CM b1$c2 Call subroutine if minus flag + + + RST e3 RST 0 Programmed restart, equivalent to + CALL 8*e3, except one byte call + + RET Return from subroutine + + RNZ Return if nonzero flag set + + RZ Return if zero flag set + + RNC Return if no carry + + RC Return if carry flag set + + RPO Return if parity is odd + + RPE Return if parity is even + + RP Return if positive result + + RM Return if minus flag is set + K + + + + + + 3-16 + + + + + +CP/M Operating System Manual 3.5 Operation Codes + + +3.5.2 Immediate Operand Instructions + + Several instructions are available that load single- or double- +precision registers or single-precision memory cells with constant +values, along with instructions that perform immediate arithmetic or +logical operations on the accumulator (register A). Table 3-5 +describes the immediate operand instructions. + + +Table 3-5. Immediate Operand Instructions + + F + Form with Example Meaning + Bit Values + + MVI e3,e8 MVI B,255 Move immediate data to + register A, B, C, D, E, H, + L, or M (memory) + + ADI e8 ADI 1 Add immediate operand to A + without carry + + ACI e8 ACI 0FFH Add immediate operand to A + with carry + + SUI e8 SUI L + 3 Subtract from A without + borrow (carry) + + SBI e8 SBI L AND 11B Subtract from A with borrow + (carry) + + ANI e8 ANI $ AND 7FH Logical and A with + immediate data + + XRI e8 XRI 1111$0000B Exclusive or A with + immediate data + + ORI e8 ORI L AND 1+1 Logical or A with immediate + data + + CPI e8 CPI 'a' Compare A with immediate + data, same as SUI except + register A not changed. + + LXI e3,e16 LXI B,100H Load extended immediate to + register pair. e3 must be + equivalent to B, D, H, or + SP. + K + + +3.5.3 Increment and Decrement Instructions + + The 8080 provides instructions for incrementing or decrementing +single- and double-precision registers. The instructions are +described in Table 3-6. + + + + 3-17 + + + + + +CP/M Operating System Manual 3.5 Operation Codes + + +Table 3-6. Increment and Decrement Instructions + F + + Form with Example Meaning + Bit Value + + INR e3 INR E Single-precision increment + register. e3 produces one + of A, B, C, D, E, H, L, M. + + DCR e3 DCR A Single-precision decrement + register. e3 produces one + of A, B, C, D, E, H, L, M. + + INX e3 INX SP Double-precision increment + register pair. e3 must be + equivalent to B, D, H, or + SP. + + DCX e3 DCX B Double-precision decrement + register pair. e3 must be + equivalent to B, D, H, or + SP. + K + + + +3.5.4 Data Movement Instructions + + Instructions that move data from memory to the CPU and from CPU +to memory are given in the following table. + + +Table 3-7. Data Movement Instructions + F + + Form with Example Meaning + Bit Value + + MOV e3,e3 MOV A,B Move data to leftmost + element from rightmost + element. e3 produces on + of A, B, C, D, E, H, L, or + M. MOV M,M is disallowed. + + LDAX e3 LDAX B Load register A from + computed address. e3 must + produce either B or D. + + STAX e3 STAX D Store register A to + computed address. e3 must + produce either B or D. + + LHLD e16 LHLD L1 Load HL direct from + location e16. Double- + precision load to H and L. + + + + + 3-18 + + + + K + + +CP/M Operating System Manual 3.5 Operation Codes + + +Table 3-7. (continued) + F + + Form with Example Meaning + Bit Value + + SHLD e16 SHLD L5+x Store HL direct to + location e16. Double- + precision store from H and + L to memory. + + LDA e16 LDA Gamma Load register A from + address e16. + + STA e16 STA X3-5 Store register A into + memory at e16. + + POP e3 POP PSW Load register pair from + stack, set SP. e3 must + produce one of B, D, H, or + PSW. + + PUSH e3 PUSH B Store register pair into + stack, set SP. e3 must + produce on of B, D, H, or + PSW. + + IN e8 IN 0 Load register A with data + from port e8. + + OUT e8 OUT 255 Send data from register A + to port e8. + + XTHL Exchange data from top of + stack with HL. + + PCHL Fill program counter with + data from HL. + + SPHL Fill stack pointer with + data from HL. + + XCHG Exchange DE pair with HL + pair. + K + + + +3.5.5 Arithmetic Logic Unit Operations + + Instructions that act upon the single-precision accumulator to +perform arithmetic and logic operations are given in the following +table. + + + + + + + 3-19 + + + + + +CP/M Operating System Manual 3.5 Operation Codes + + +Table 3-8. Arithmetic Logic Unit Operations + F + + Form with Example Meaning + Bit Value + + ADD e3 ADD B Add register given by e3 to + accumulator without carry. + e3 must produce one of A, + B, C, D, E, H, or L. + + ADC e3 ADC L Add register to A with + carry, e3 as above. + + SUB e3 SUB H Subtract reg e3 from A + without carry, e3 is + defined as above. + + SBB e3 SBB 2 Subtract register e3 from A + with carry, e3 defined as + above. + + ANA e3 ANA 1+1 Logical and reg with A, e3 + as above. + + XRA e3 XRA A Exclusive or with A, e3 as + above. + + ORA e3 ORA B Logical or with A, e3 + defined as above. + + CMP e3 CMP H Compare register with A, e3 + as above. + + DAA Decimal adjust register A + based upon last arithmetic + logic unit operation. + + CMA Complement the bits in + register A. + + STC Set the carry flag to 1. + + CMC Complement the carry flag. + + RLC Rotate bits left, (re)set + carry as a side effect. + High-order A bit becomes + carry. + + RRC Rotate bits right, (re)set + carry as side effect. + Low-order A bit becomes + carry. + + + + + 3-20 + + + + K + + +CP/M Operating System Manual 3.5 Operation Codes + + +Table 3-8. (continued) + F + + Form with Example Meaning + Bit Value + + RAL Rotate carry/A register to + left. Carry is involved + in the rotate. + + RAR Rotate carry/A register to + right. Carry is involved + in the rotate. + + DAD e3 DAD B Double-precision add + register pair e3 to HL. + e3 must produce B, D, H, + or SP. + K + + +3.5.6 Control Instructions + + The four remaining instructions, categorized as control +instructions, are the following: + + o HLT halts the 8080 processor. + o DI disables the interrupt system. + o EI enables the interrupt system. + o NOP means no operation. + + +3.6 Error Messages + + When errors occur within the assembly-language program, they +are listed as single-character flags in the leftmost position of the +source listing. The line in error is also echoed at the console so +that the source listing need not be examined to determine if errors +are present. The error codes are listed in the following table. + + +Table 3-9. Error Codes + + F + Error Code Meaning + + D Data error: element in data statement cannot + be placed in the specified data area. + + E Expression error: expression is ill-formed + and cannot be computed at assembly time. + + L Label error: label cannot appear in this + context; might be duplicate label. + + N Not implemented: features that will appear in + future ASM versions. For example, macros are + recognized, but flagged in this version. + + + 3-21 + + + + K + + +CP/M Operating System Manual 3.6 Error Messages + + +Table 3-9. (continued) + + F + Error Code Meaning + + O Overflow: expression is too complicated (too + many pending operators) to be computed and + should be simplified. + + P Phase error: label does not have the same + value on two subsequent passes through the + program. + + R Register error: the value specified as a + register is not compatible with the operation + code. + + S Syntax error: statement is not properly + formed. + + V Value error: operand encountered in + expression is improperly formed. + K + + + Table 3-10 lists the error messages that are due to terminal +error conditions. + + +Table 3-10. Error Messages + + F + Message Meaning + + NO SOURCE FILE PRESENT + + The file specified in the ASM command does + not exist on disk. + + + NO DIRECTORY SPACE + + The disk directory is full; erase files + that are not needed and retry. + + + SOURCE FILE NAME ERROR + + Improperly formed ASM filename, for + example, it is specified with ? fields. + + + SOURCE FILE READ ERROR + + Source file cannot be read properly by the + assembler; execute a TYPE to determine the + point of error. + + + + 3-22 + + + + K + + +CP/M Operating System Manual 3.6 Error Messages + + +Table 3-10. (continued) + + F + Message Meaning + + OUTPUT FILE WRITE ERROR + + Output files cannot be written properly; + most likely cause is a full disk, erase and + retry. + + + CANNOT CLOSE FILE + + Output file cannot be closed; check to see + if disk is write protected. + K + + + +3.7 A Sample Session + + The following sample session shows interaction with the +assembler and debugger in the development of a simple assembly- +language program. The arrow represents a carriage return keystroke. + + + d +A>ASM SORT Assemble SORT.ASM + +CP/M ASSEMBLER - VER 1.0 + +0015C Next free address +003H USE FACTOR Percent of table used 00 to ff (hexadecimal) +END OF ASSEMBLY + +A>DIR SORT.* + +SORT ASM Source file +SORT BAK Back-up from last edit +SORT PRN Print file (contains tab characters) +SORT HEX Machine code file + +A>TYPE SORT.PRN + Source line + + ; SORT PROGRAM IN CP/M ASSEMBLY LANGUAGE + ; START AT THE BEGINNING OF THE TRANSIENT + PROGRAM AREA + +Machine code location +0100 ORG 100H + +Generated machine code +0100 214601 SORT: LXI H,SW ;ADDRESS SWITCH TOGGLE +0103 3601 MVI M,1 ;SET TO 1 FOR FIRST ITERATION +0105 214701 LXI H,I ;ADDRESS INDEX +0108 3600 MVI M,0 ;I=0 + + + 3-23 + + + + + +CP/M Operating System Manual 3.7 A Sample Session + + + ; + ; COMPARE I WITH ARRAY SIZE +010A 7E COMPL: MOV A,M ;A REGISTER = I +010B FE09 CPI N-1 ;CY SET IF I<(N-1) +010D D21901 JNC CONT ;CONTINUE IF I<=(N-2) + ; + ; END OF ONE PASS THROUGH DATA +0110 214601 LXI H,SW ;CHECK FOR ZERO SWITCHES +0113 7EB7C200001 MOV A, M! ORA A! JNZ SORT ;END OF SORT IF SW=0 + ; +0118 FF RST 7 ;GO TO THE DEBUGGER INSTEAD OF REB + ; + ; CONTINUE THIS PASS +Truncated ; ADDRESSING I, SO LOAD AV(I) INTO REGISTERS +0119 + 5F16002148CONT: MOV E, A! MVI D, 0! LXI H, AV! DAD D! DAD D +0121 4E792346 MOV C, M! MOV A, C! INX H! MOV B, M + ; LOW ORDER BYTE IN A AND C, HIGH ORDER BYTE IN B + ; + ; MOV H AND L TO ADDRESS AV(I+1) +0125 23 INX H + ; + ; COMPARE VALUE WITH REGS CONTAINING AV (I) +0126 965778239E SUB M! MOV D, A! MOV A, B! INX H! SBB M ;SUBTRACT + ; + ; BORROW SET IF AV(I+1)>AV(I) +012B DA3F01 JC INCI ;SKIP IF IN PROPER ORDER + ; + ; CHECK FOR EQUAL VALUES +012E B2CA3F01 ORA D! JZ INCI ;SKIP IF AV(I) = AV(I+1) +0132 56702B5E MOV D, M! MOV M, B! DCX H! MOV E, M +0136 712B722B73 MOV M, C! DCX H! MOV M, D! DCX H! MOV M, E + ; + ; INCREMENT SWITCH COUNT +013B 21460134 LXI H,SW! INR M + ; + ; INCREMENT I +013F 21470134C3INCI:LXI H,I! INR M! JMP COMP + ; + ; DATA DEFINITION SECTION +0146 00 SW: DB 0 ;RESERVE SPACE FOR SWITCH COUNT +0147 I: DS 1 ;SPACE FOR INDEX +0148 050064001EAV: DW 5, 100, 30, 50, 20, 7, 1000, 300, 100, -32767 +000A = N EQU($-AV)/2 ;COMPUTE N INSTEAD OF PRE +015C END +A>TYPE SORT.HEX Equate value + +:10010000214601360121470136007EFE09D2190140 +:100110002146017EB7C20001FF5F16002148011988 Machine code in +:10012000194E79234623965778239EDA3F01B2CAA7 HEX format + +:100130003F0156702B5E712B722B732146013421C7 +:07014000470134C30A01006E Machine code in +:10014800050064001E00320014000700E8032C01BB HEX format +:0401580064000180BE +:0000000000 + + 3-24 + + + + + +CP/M Operating System Manual 3.7 A Sample Session + + +A>DDT SORT.HEX Start debug run + +16K DDT VER 1.0 +NEXT PC +015C 0000 Default address (no address on END statement) +-XP + +P=0000 100 Change PC to 100 + +-UFFFF Untrace for 65535 steps + Abort with rubout +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 LXI H,0146*0100 +-T10 Trace 1016 steps + +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0100 LXI H, 0146 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M, 01 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H, 0147 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M, 00 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=010A MOV A, M +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010B CPI 09 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010D JNC 0119 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0110 LXI H, 0146 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0113 MOV A, M +C1Z0M1E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0114 ORA A +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0115 JNZ 0100 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0100 LXI H, 0146 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M, 01 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H, 0147 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M, 00 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=010A MOV A, M*010B +-A10D Stopped at 10BH + +010D JC 119 Change to a jump on carry +0110 + +-XP + +P=010B 100 Reset program counter back to beginning of program + +-T10 Trace execution for 10H steps + + Altered instruction +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0100 LXI H,0146 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M,01 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H,0147 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M,00 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010A MOV A,M +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010B CPI 09 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010D JC 0119 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0119 MOV E,A +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=011A MVI D,00 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=011C LXI H,0148 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=011F DAD D +C0Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=0120 DAD D +C0Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=0121 MOV C,M + + + 3-25 + + + + + +CP/M Operating System Manual 3.7 A Sample Session + + +C0Z0M1E0I0 A=00 B=0005 D=0000 H=0148 S=0100 P=0122 MOV A,C +C0Z0M1E0I0 A=05 B=0005 D=0000 H=0148 S=0100 P=0123 INX H +C0Z0M1E0I0 A=05 B=0005 D=0000 H=0149 S=0100 P=0124 MOV B,M*0125 +-L100 Automatic breakpoint + + 0100 LXI H,0146 + 0103 MVI M,01 + 0105 LXI H,0147 + 0108 MVI M,00 + 010A MOV A,M List some code + 010B CPI 09 from 100H + 010D JC 0119 + 0110 LXI H,0146 + 0113 MOV A,M + 0114 ORA A + 0115 JNZ 0100 + -L + + 0118 RST 07 + 0119 MOV E,A List more + 011A MVI D,00 + 011C LXI H,0148 +-Abort list with rubout +-G,11B Start program from current PC (0125H) + and run in real time to 11BH + + + +*0127 Stopped with an external interrupt 7 from front panel +-T4 (program was looping indefinitely) + Look at looping program in trace mode + +C0Z0M0E0I0 A=38 B=0064 D=0006 H=0156 S=0100 P=0127 MOV D,A +C0Z0M0E0I0 A=38 B=0064 D=3806 H=0156 S=0100 P=0128 MOV A,B +C0Z0M0E0I0 A=00 B=0064 D=3806 H=0156 S=0100 P=0129 INX H +C0Z0M0E0I0 A=00 B=0064 D=3806 H=0157 S=0100 P=012A SBB M*012B +-D148 + Data are sorted, but program does not stop. +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D.,........ + +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-G0 Return to CP/M + +A>DDT SORT.HEX Reload the memory image + +16K DDT VER 1.0 +NEXT PC +015C 0000 +-XP + +P=0000 100 Set PC to beginning of program + +-L10D List bad OPCODE + + + 3-26 + + + + + +CP/M Operating System Manual 3.7 A Sample Session + + + + 010D JNC 0119 + 0110 LXI H,0146 +-Abort list with rubout +-A10D Assemble new OPCODE + +010D JC 119 + +0110 + +-L100 List starting section of program + + 0100 LXI H,0146 + 0103 MVI M,01 + 0105 LXI H,0147 + 0108 MVI M,00 +-Abort list with rubout +-A103 Change switch initialization to 00 + +0103 MVI M,0 + +0105 + +-^C Return to CP/M with CTRL-C (G0 works as well) + +SAVE 1 SORT.COM Save 1 page (256 bytes, from 100H to 1ffH) on + disk in case there is need to reload later +A>DDT SORT.COM Restart DDT with saved memory image + +16K DDT VER 1.0 +NEXT PC +0200 0100 COM file always starts with address 100H +-G Run the program from PC=100H + +*0118 Programmed stop (RST 7) encountered +-D148 + + Data properly sorted +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D......... + +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ +0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-G0 Return to CP/M + +A>ED SORT.ASM Make changes to original program + +*N,0^Z0TT Find next ,0 + MVI M,0 ;I = 0 + +*- Up one line in text + LXI H,I ;ADDRESS INDEX + + + + + 3-27 + + + + + +CP/M Operating System Manual 3.7 A Sample Session + + +*- Up another line + MVI M,1 ;SET TO 1 FOR FIRST ITERATION + +*KT Kill line and type next line + LXI H,I ;ADDRESS INDEX + +*I Insert new line + MVI M,0 ;ZERO SW + +*T + LXI H,I ;ADDRESS INDEX + +*NJNC^Z0T + JNC*T + CONT ;CONTINUE IF I<=(N-2) + +*-2DIC^Z0LT + JC CONT ;CONTINUE IF I<=(N-2) + +*E Source from disk A + HEX to disk A +A>ASM SORT.AAZ Skip PRN file + +CP/M ASSEMBLER - VER 1.0 + +015C Next address to assemble +003H USE FACTOR +END OF ASSEMBLY + +A>DDT SORT.HEX Test program changes + +16K DDT VER 1.0 +NEXT PC +015C 0000 +-G100 + +*0118 +-D148 + Data sorted +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D.......... +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-Abort with rubout + +-G0 Return to CP/M--program checks OK. + K + + +End of Section 3 + + + + + + + + + 3-28 + + + + + + + + + Section 4 + + CP/M Dynamic Debugging Tool + + + +4.1 Introduction + + The DDT program allows dynamic interactive testing and +debugging of programs generated in the CP/M environment. Invoke the +debugger with a command of one of the following forms: + + DDT + DDT filename.HEX + DDT filename.COM + +where filename is the name of the program to be loaded and tested. +In both cases, the DDT program is brought into main memory in place +of the Console Command Processor (CCP) and resides directly below +the Basic Disk Operating System (BDOS) portion of CP/M. Refer to +Section 5 for standard memory organization. The BDOS starting +address, located in the address field of the JMP instruction at +location 5H, is altered to reflect the reduced Transient Program +Area (TPA) size. + + The second and third forms of the DDT command perform the same +actions as the first, except there is a subsequent automatic load of +the specified HEX or COM file. The action is identical to the +following sequence of commands: + + DDT + Ifilename.HEX or Ifilename.COM + R + +where the I and R commands set up and read the specified program to +test. See the explanation of the I and R commands below for exact +details. + + Upon initiation, DDT prints a sign-on message in the form: + + DDT VER m.m + +where m.m is the revision number. + + Following the sign-on message, DDT prompts you with the hyphen +character, -, and waits for input commands from the console. You +can type any of several single-character commands, followed by a +carriage return to execute the command. Each line of input can be +line-edited using the following standard CP/M controls: + + + + + + + + + 4-1 + + + + + +CP/M Operating System Manual 4.1 Introduction + + +Table 4-1. Line-editing Controls + F + + Control Result + + rubout removes the last character typed + + CTRL-U removes the entire line, ready for retyping + + CTRL-C reboots system + K + + + Any command can be up to 32 characters in length. An automatic +carriage return is inserted as character 33, where the first +character determines the command type. Table 4-2 describes DDT +commands. + + + Table 4-2. DDT Commands + + Command Result + Character + + C + A enters assembly-language mnemonics with + operands. + + D displays memory in hexadecimal and ASCII. + + F fills memory with constant data. + + G begins execution with optional breakpoints. + + I sets up a standard input File Control + Block. + + L lists memory using assembler mnemonics. + + M moves a memory segment from source to + destination. + + R reads a program for subsequent testing. + + S substitutes memory values. + + T traces program execution. + + U untraced program monitoring. + + X examines and optionally alters the CPU + state. + K + + +The command character, in some cases, is followed by zero, one, two, +or three hexadecimal values, which are separated by commas or single +blank characters. All DDT numeric output is in hexadecimal form. +The commands are not execution until the carriage return is typed at +the end of the command. + + + 4-2 + + + + +CP/M Operating System Manual 4.1 Introduction + + + At any point in the debug run, you can stop execution of DDT by +using either a CTRL-C or G0 (jump to location 0000H) and save the +current memory image by using a SAVE command of the form: + + SAVE n filename. COM + +where n is the number of pages (256 byte blocks) to be saved on +disk. The number of blocks is determined by taking the high-order +byte of the address in the TPA and converting this number to +decimal. For example, if the highest address in the TPA is 134H, +the number of pages is 12H or 18 in decimal. You could type a CTRL- +C during the debug run, returning to the CCP level, followed by + + SAVE 18 X.COM + +The memory image is saved as X.COM on the disk and can be directly +executed by typing the name X. If further testing is required, the +memory image can be recalled by typing + + DDT X.COM + +which reloads the previously saved program from location 100H +through page 18, 23FFH. The CPU state is not a part of the COM +file; thus, the program must be restarted from the beginning to test +it properly. + + +4.2 DDT Commands + + The individual commands are detailed below. In each case, the +operator must wait for the hyphen prompt character before entering +the command. If control is passed to a program under test, and the +program has not reached a breakpoint, control can be returned to DDT +by executing a RST 7 from the front panel. In the explanation of +each command, the command letter is shown in some cases with numbers +separated by commas, the the numbers are represented by lower-case +letters. These numbers are always assumed to be in a hexadecimal +radix and from one to four digits in length. Longer numbers are +automatically truncated on the right. + + Many of the commands operate upon a CPU state that corresponds +to the program under test. The CPU state holds the registers of the +program being debugged and initially contains zeros for all +registers and flags except for the program counter, P, and stack +pointer, S, which default to 100H. The program counter is +subsequently set to the starting address given in the last record of +a HEX file if a file of this form is loaded, see the I and R +commands. + + +4.2.1 The A (Assembly) Command + + DDT allows in-line assembly language to be inserted into the +current memory image using the A command, which takes the form: + + + + 4-3 + + + + + +CP/M Operating System Manual 4.2 DDT Commands + + + As + +where s is the hexadecimal starting address for the in-line +assembly. DDT prompts the console with the address of the next +instruction to fill and reads the console, looking for assembly- +language mnemonics followed by register references and operands in +absolute hexadecimal form. See the Intel 8080 Assembly Language +Reference Card for a list of mnemonics. Each successive load +address is printed before reading the console. The A command +terminates when the first empty line is input from the console. + + Upon completion of assembly language input, you can review the +memory segment using the DDT disassembler (see the L command). + + Note that the assembler/disassembler portion of DDT can be +overlaid by the transient program being tested, in which case the +DDT program responds with an error condition when the A and L +commands are used. + + +4.2.2 The D (Display) Command + + The D command allows you to view the contents of memory in +hexadecimal and ASCII formats. The D command takes the forms: + + D + Ds + Ds,f + + In the first form, memory is displayed from the current display +address, initially 100H, and continues for 16 display lines. Each +display line takes the followng form: + +aaaa bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb cccccccccccccccc + +where aaaa is the display address in hexadecimal and bb represents +data present in memory starting at aaaa. The ASCII characters +starting at aaaa are to the right (represented by the sequence of +character c) where nongraphic characters are printed as a period. +You should note that both upper- and lower-case alphabetics are +displayed, and will appear as upper-case symbols on a console device +that supports only upper-case. Each display line gives the values +of 16 bytes of data, with the first line truncated so that the next +line begins at an address that is a multiple of 16. + + The second form of the D command is similar to the first, +except that the display address is first set to address s. + + The third form causes the display to continue from address s +through address f. In all cases, the display address is set to the +first address not displayed in this command, so that a continuing +display can be accomplished by issuing successive D commands with no +explicit addresses. + + + + + 4-4 + + + + + +CP/M Operating System Manual 4.2 DDT Commands + + + Excessively long displays can be aborted by pressing the return +key. + + +4.2.3 The F (Fill) Command + + The F command takes the form: + + Fs,f,c, + +where s is the starting address, f is the final address, and c is a +hexadecimal byte constant. DDT stores the constant c at address s, +increments the value of s and test against f. If s exceeds f, the +operation terminates, otherwise the operation is repeated. Thus, +the fill command can be used to set a memory block to a specific +constant value. + + +4.2.4 The G (Go) Command + + A program is executed using the G command, with up to two +optional breakpoint addresses. The G command takes the forms: + + + G + Gs + Gs,b + Gs,b,c + G,b + G,b,c + + + The first form executes the program at the current value of the +program counter in the current machine state, with no breakpoints +set. The only way to regain control in DDT is through a RST 7 +execution. The current program counter can be viewed by typing an X +or XP command. + + The second form is similar to the first, except that the +program counter in the current machine state is set to address s +before execution begins. + + The third form is the same as the second, except that program +execution stops when address b is encountered (b must be in the area +of the program under test). The instruction at location b is not +executed when the breakpoint is encountered. + + The fourth form is identical to the third, except that two +breakpoints are specified, one at b and the other at c. +Encountering either breakpoint causes execution to stop, and both +breakpoints are cleared. The last two forms take the program +counter from the current machine state and set one and two +breakpoints, respectively. + + + + + 4-5 + + + + + +CP/M Operating System Manual 4.2 DDT Commands + + + Execution continues from the starting address in real-time to +the next breakpoint. There is no intervention between the starting +address and the break address by DDT. If the program under test +does not reach a breakpoint, control cannot return to DDT without +executing a RST 7 instruction. Upon encountering a breakpoint, DDT +stops execution and types + + *d + +where d is the stop address. The machine state can be examined at +this point using the X (Examine) command. You must specify +breakpoints that differ from the program counter address at the +beginning of the G command. Thus, if the current program counter is +1234H, then the following commands: + + G,1234 + G400,400 + +both produce an immediate breakpoint without executing any +instructions. + + +4.2.5 The I (Input) Command + + The I command allows you to insert a filename into the default +File Control Block (FCB) at 5CH. The FCB created by CP/M for +transient programs is placed at this location (see Section 5). The +default FCB can be used by the program under test as if it had been +passed by the CP/M Console Processor. Note that this filename is +also used by DDT for reading additional HEX and COM files. The I +command takes the forms: + + Ifilename + Ifilename.typ + + If the second form is used and the filetype is either HEX or +COM, subsequent R commands can be used to read the pure binary or +hex format machine code. Section 4.2.8 gives further details. + + +4.2.6 The L (List) Command + + The L command is used to list assembly-language mnemonics in a +particular program region. The L command takes the forms: + + L + Ls + Ls,f + + The first form lists twelve lines of disassembled machine code +from the current list address. The second form sets the list +address to s and then lists twelve lines of code. The last form +lists disassembled code from s through address f. In all three +cases, the list address is set to the next unlisted location in +preparation for a subsequent L command. Upon encountering an + + + 4-6 + + + + + +CP/M Operating System Manual 4.2 DDT Commands + + +execution breakpoint, the list address is set to the current value +of the program counter (G and T commands). Again, long typeouts can +be aborted by pressing RETURN during the list process. + + +4.2.7 The M (Move) Command + + The M command allows block movement of program or data areas +from one location to another in memory. The M command takes the +form: + + Ms,f,d + +where s is the start address of the move, f is the final address, +and d is the destination address. Data is first removed from s to +d, and both addresses are incremented. If s exceeds f, the move +operation stops; otherwise, the move operation is repeated. + + +4.2.8 The R (Read) Command + + The R command is used in conjunction with the I command to read +COM and HEX files from the disk into the transient program area in +preparation for the debug run. The R command takes the forms: + + R + RB + +where b is an optional bias address that is added to each program or +data address as it is loaded. The load operation must not overwrite +any of the system parameters from 000H through 0FFH (that is, the +first page of memory). If b is omitted, then b=0000 is assumed. +The R command requires a previous I command, specifying the name of +a HEX or COM file. The load address for each record is obtained +from each individual HEX record, while an assumed load address of +100H is used for COM files. Note that any number of R commands can +be issued following the I command to reread the program under test, +assuming the tested program does not destroy the default area at +5CH. Any file specified with the filetype COM is assumed to contain +machine code in pure binary form (created with the LOAD or SAVE +command), and all others are assumed to contain machine code in +Intel hex format (produced, for example, with the ASM command). + + Recall that the command, + + DDT filename.filetype + +which initiates the DDT program, equals to the following commands: + + DDT + -Ifilename.filetype + -R + + + + + + 4-7 + + + + + +CP/M Operating System Manual 4.2 DDT Commands + + + + Whenever the R command is issued, DDT responds with either the +error indicator ? (file cannot be opened, or a checksum error +occurred in a HEX file) or with a load message. The load message +takes the form: + + NEXT PC + nnnn pppp + +where nnnn is the next address following the loaded program and pppp +is the assumed program counter (100H for COM files, or taken from +the last record if a HEX file is specified). + + +4.2.9 The S (Set) Command + + The S command allows memory locations to be examined and +optionally altered. The S command takes the form: + + Ss + +where s is the hexadecimal starting address for examination and +alteration of memory. DDT responds with a numeric prompt, giving +the memory location, along with the data currently held in memory. +If you type a carriage return, the data is not altered. If a byte +value is typed, the value is stored at the prompted address. In +either case, DDT continues to prompt with successive addresses and +values until you type either a period or an invalid input value is +detected. + + +4.2.10 The T (Trace) Command + + The T command allows selective tracing of program execution for +1 to 65535 program steps. The T command takes the forms: + + T + Tn + + In the first form, the CPU state is displayed and the next +program step is executed. The program terminates immediately, with +the termination address displayed as + + *hhhh + +where hhhh is the next address to execute. The display address +(used in the D command) is set to the value of H and L, and the list +address (used in the L command) is set to hhhh. The CPU state at +program termination can then be examined using the X command. + + The second form of the T command is similar to the first, +except that execution is traced for n steps (n is a hexadecimal +value) before a program breakpoint occurs. A breakpoint can be +forced in the trace mode by typing a rubout character. The CPU +state is displayed before each program step is taken in trace mode. +The format of the display is the same as described in the X command. + + + 4-8 + + + + +CP/M Operating System Manual 4.2 DDT Commands + + + You should note that program tracing is discontinued at the +CP/M interface and resumes after return from CP/M to the program +under test. Thus, CP/M functions that access I/O devices, such as +the disk drive, run in real-time, avoiding I/O timing problems. +Programs running in trace mode execute approximately 500 times +slower than real-time because DDT gets control after each user +instruction is executed. Interrupt processing routines can be +traced, but commands that use the breakpoint facility (G, T, and U) +accomplish the break using an RST 7 instruction, which means that +the tested program cannot use this interrupt location. Further, the +trace mode always runs the tested program with interrupts enabled, +which may cause problems if asynchronous interrupts are received +during tracing. + + To get control back to DDT during trace, press RETURN rather +than executing an RST 7. This ensures that the trace for current +instruction is completed before interruption. + + +4.2.11 The U (Untrace) Command + + The U command is identical to the T command, except that +intermediate program steps are not displayed. The untrace mode +allows from 1 to 65535, (0FFFFH) steps to be executed in monitored +mode and is used principally to retain control of an executing +program while it reaches steady state conditions. All conditions of +the T command apply to the U command. + + +4.2.12 The X (Examine) Command + + The X command allows selective display and alteration of the +current CPU state for the program under test. The X command takes +the forms: + + X + Xr + +where r is one of the 8080 CPU registers listed in the following +table. + + + Table 4-3. CPU Registers + + Register Meaning Value + + C Carry flag (0/1) + Z Zero flag (0/1) + M Minus flag (0/1) + E Even parity flag (0/1) + I Interdigit carry (0/1) + A Accumulator (0-FF) + B BC register pair (0-FFFF) + D DE register pair (0-FFFF) + + + + 4-9 + + + + + +CP/M Operating System Manual 4.2 DDT Commands + + + Table 4-3. (continued) + + Register Meaning Value + + H HL register pair (0-FFFF) + S Stack pointer (0-FFFF) + P Program counter (0-FFFF) + + +In the first case, the CPU register state is displayed in the +format: + + CfZfMfEflf A=bb B=dddd D=dddd H=dddd S=dddd P=dddd inst + +where f is a 0 or 1 flag value, bb is a byte value, and dddd is a +double-byte quantity corresponding to the register pair. The inst +field contains the disassembled instruction, that occurs at the +location addressed by the CPU state's program counter. + + The second form allows display and optional alteration of +register values, where r is one of the registers given above (C, Z, +M, E, I, A, B, D, H, S, or P). In each case, the flag or register +value is first displayed at the console. The DDT program then +accepts input from the console. If a carriage return is typed, the +flag or register value is not altered. If a value in the proper +range is typed, the flag or register value is altered. You should +note that BC, DE, and HL are displayed as register pairs. Thus, you +must type the entire register pair when B, C, or the BC pair is +altered. + + +4.3 Implementation Notes + + The organization of DDT allows certain nonessential portions to +be overlaid to gain a larger transient program area for debugging +large programs. The DDT program consists of two parts: the DDT +nucleus and the assembler/disassembler module. The DDT nucleus is +loaded over the CCP and, although loaded with the DDT nucleus, the +assembler/disassembler is overlayable unless used to assemble or +disassemble. + + In particular, the BDOS address at location 6H (address field +of the JMP instruction at location 5H) is modified by DDT to address +the base location of the DDT nucleus, which, in turn, contains a JMP +instruction to the BDOS. Thus, programs that use this address field +to size memory see the logical end of memory at the base of the DDT +nucleus rather than the base of the BDOS. + + The assembler/disassembler module resides directly below the +DDT nucleus in the transient program area. If the A, L, T, or X +commands are used during the debugging process, the DDT program +again alters the address field at 6H to include this module, further +reducing the logical end of memory. If a program loads beyond the +beginning of the assembler/disassembler module, the A and L commands +are lost (their use produces a ? in response) and the trace and + + + 4-10 + + + + + +CP/M Operating System Manual 4.3 Implementation Notes + + +display (T and X) commands list the inst field of the display in +hexadecimal, rather than as a decoded instruction. + + +4.4 A Sample Program + + The following example shows an edit, assemble, and debug for a +simple program that reads a set of data values and determines the +largest value in the set. The largest value is taken from the +vector and stored into LARGE at the termination of the program. + U + + +A>ED SCAN.ASM Create source program; + " " represents carriage return. +*I + ORG 1-00H ;START OF TRANSIENT + ;AREA + MVI B, LEN ;LENGTH OF VECTOR TO SCAN + MVI C, 0 ;LARGER_RST VALUE SO FAR +LOOP LXI H, VECT ;BASE OF VECTOR +LOOP: MOV A, M ;GET VALUE + SUB C ;LARGER VALUE IN C? + JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND +; NEW LARGEST VALUE, STORE IT TO C + MOV C, A +NFOUND INX H ;TO NEXT ELEMENT + DCR B ;MORE TO SCAN? + JNZ LOOP ;FOR ANOTHER +; +; END OF SCAN, STORE C + MOV A, C ;GET LARGEST VALUE + STA LARGE + JMP 0 ;REBOOT +; +; TEST DATA +VECT: DB 2,0,4,3,5,6,1,5 +LEN EQU $-VECT ;LENGTH +LARGE: DS 1 ;LARGEST VALUE ON EXIT + END + + + + + + + + + + + + + + + + + + 4-11 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +^-Z +*B0P + ORG 100H ;START OF TRANSIENT AREA + MVI B,LEN ;LENGTH OF VECTOR TO SCAN + MVI C,0 ;LARGEST VALUE SO FAR + LXI H,VECT ;BASE OF VECTOR +LOOP: MOV A,M ;GET VALUE + SUB C ;LARGER VALUE IN C? + JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND +; NEW LARGEST VALUE, STORE IT TO C + MOV C,A +NFOUND: INX H ;TO NEXT ELEMENT + DCR B ;MORE TO SCAN? + JNZ LOOP ;FOR ANOTHER +; END OF SCAN, STORE C + MOV A,C ;GET LARGEST VALUE + STA LARGE + JMP 0 ;REBOOT +; +; TEST DATA + +VECT: DB 2,0,4,3,5,6,1,5 +LEN EQU $-VECT ;LENGTH +LARGE: DS 1 ;LARGEST VALUE ON EXIT + END +*E <--End of edit + +A>ASM SCAN Start Assembler + +CP/M ASSEMBLER - VER 1.0 + +0122 +002H USE FACTOR +END OF ASSEMBLY Assembly complete; lock at program listing + +A>TYPE SCAN.PRN + Code address Source program + 0100 ORG 100H ;START OF TRANSIENT AREA + 0100 0608 MVI B,LEN ;LENGTH OF VECTOR TO SCAN + 0102 0E00 Machine code MVI C,0 ;LARGEST VALUE SO FAR + 0104 211901 LXI H,VECT. ;BASE OF VECTOR + 0107 7E LOOP: MOV A,M ;GET VALUE + 0108 91 SUB C ;LARGER VALUE IN C? + 0109 D20D01 JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND + ; NEW LARGEST VALUE, STORE IT TO C + 010C 4F MOV C,A + + + + + + + + + + 4-12 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + + 010D 23 NFOUND: INX H ;TO NEXT ELEMENT + 010E 05 DCR B ;MORE TO SCAN? + 010F C20701 JNZ LOOP ;FOR ANOTHER + ; + ; END OF SCAN, STORE C + 0112 79 MOV A,C ;GET LARGEST VALUE + 0113 322101 STA LARGE + + 0116 C30000 JMP 0 ;REBOOT + Code--data listing; + truncated ; TEST DATA + 0119 0200040305 VECT: DB 2,0,4,3,5,6,1,5 + 0008 = Value of LEN EQU $-VECT ;LENGTH + 0121 equate LARGE: DS 1 ;LARGEST VALUE ON EXIT + 0122 END + + +A>DDT SCAN.HEX Start debugger using hex format machine code + +DDT VER 1.0 +NEXT PC Next instruction +0121 0000 to execute at +-X Last load address + 1 PC=0 + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0000 OUT 7F +-XP Examine registers before debug run + +P=0000 100 Change PC to 100 + +-X Look at registers again + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +-L100 + PC changed Next instruction + to execute at PC=100 + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C Disassembled machine + 0109 JNC 010D code at 100H + 010C MOV C,A (see source listing + 010D INX H for comparison) + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C +-L + + + + + + + + + + + 4-13 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + + 0113 STA 0121 + 0116 JMP 0000 + 0119 STAX B + 011A NOP A little more machine + 011B INR B code. Note that pro- + 011C INX B gram ends at location + 011D DCR B 116 with a JMP to + 011E MVI B,01 0000. Remainder of + 0120 DCR B listing is assembly of + 0121 LXI D,2200 data. + 0124 LXI H,0200 +-A116 Enter in-line assembly mode to change the JMP to 0000 into a RST 7, + which will cause the program under test to return to DDT if 116H is + ever executed. +0116 RST 7 + +0117 (Single carriage return stops assemble mode) + +-L113 List code at 113H to check that RST 7 was properly inserted + + 0113 STA 0121 + 0116 RST 07 in place of JMP + 0117 NOP + 0118 NOP + 0119 STAX B + 011A NOP + 011B INR B + 011C INX B +- + +-X Look at registers + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +-T + Execute Program for one stop. Initial CPU state, before is executed + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08*0102 + Automatic breakpoint + + Trace one step again (note O8H in B) +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0102 MVI C,00*0104 +-T + Trace again (Register C is cleared) +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0104 LXI H,0119*0107 +-T3 Trace three steps +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z0M0E0I0 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JNC 010D*010D +-D119 + Display memory starting at 119H. Automatic breakpoint at 10DH + +0119 02 00 04 03 05 06 01.Program data Lower-case x +0120 05 11 00 22 21 00 02 7E EB 77 13 23 EB 0B 78 B1 ..."!.. . W .#..X. +0130 C2 27 01 C3 03 29 00 00 00 00 00 00 00 00 00 00 ...' ...)......... +0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. + + + 4-14 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Data are displayed +0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 in ASCI with a "." +0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 in the position of +0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 nongraphic........ +01A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 characters........ +01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +01C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +-X + Current CPU state +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +-T5 + Trace 5 steps from current CPU state +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0800 D=0000 H=011A S=0100 P=010E DCR B +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=010F JNZ 0107 +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0700 D=0000 H=011A S=0100 P=0108 SUB C*0109 + +U5 + Automatic breakpoint + Trace without listing intermediate states +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=0109 JNC 010D*0108 +-X + CPU state at end of U5 +C0Z0M0E1I1 A=04 B=0600 D=0000 H=011B S=0100 P=0108 SUB C +-G Run program from current PC until completion (in real-time) + +*0116 breakpoint at 116H, caused by executing RST 7 in machine code. + +-X + CPU state at end of program +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0116 RST 07 +-XP + Examine and change program counter + +P=0116 100 + +-X + +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0100 MVI B,08 +-T10 + + First data element + Current largest value + Subtract for comparison C + Trace 10 (hexadecimal) steps +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0121 S=0100 P=0100 MVI B,08 +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0102 MVI C,00 +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0121 S=0100 P=0104 LXI H,0119 +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z1M0E1I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JNC 010D +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0800 D=0000 H=011A S=0100 P=010E DCR B + + + 4-15 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=010F JNZ 0107 +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0700 D=0000 H=011A S=0100 P=0108 SUB C +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=0109 JNC 010D +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=010D INX H +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011B S=0100 P=010E DCR B +C0Z0M0E1I1 A=00 B=0600 D=0000 H=011B S=0100 P=010F JNZ 0107 +C0Z0M0E1I1 A=00 B=0600 D=0000 H=011B S=0100 P=0107 MOV A,M*0108 +-A109 + Insert a "hot patch" into Program should have moved the + the machine code value from A into C since A>C. +0109 JC 10D to change the Since this code was not executed, + JNC to JC it appears that the JNC should +010C have been a JC instruction + + Stop DDT so that a version of +-G0 the patched program can be saved + +A>SAVE 1 SCAN.COM Program resides on first + page, so save 1 page. +A>DDT SCAN.COM + Restart DDT with the save memory +DDT VER 1.0 image to continue testing +NEXT PC +0200 0100 + +-L100 List some code + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C + 0109 JC 010D Previous patch is present in X.COM + 010C MOV C,A + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C + -XP + +P=0100 + +-T10 + Trace to see how patched version operates Data is moved from A to C +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0102 MVI C,00 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0104 LXI H,0119 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z0M0E0I0 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JC 010D +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010C MOV C,A +C0Z0M0E0I1 A=02 B=0802 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0802 D=0000 H=011A S=0100 P=010E DCR B +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=010F JNZ 0107 + + + 4-16 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0702 D=0000 H=011A S=0100 P=0108 SUB C +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=0109 JC 010D +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=010D INX H +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011B S=0100 P=010E DCR B +C1Z0M0E1I1 A=FE B=0602 D=0000 H=011B S=0100 P=010F JNZ 0107*0107 +-X Breakpoint after 16 steps + +C1Z0M0E1I1 A=FE B=0602 D=0000 H=011B S=0100 P=0107 MOV A,M +-G,108 Run from current PC and breakpoint at 108H + +*0108 +-X + Next data item +C1Z0M0E1I1 A=04 B=0602 D=0000 H=011B S=0100 P=0108 SUB C +-T + Single step for a few cycles +C1Z0M0E1I1 A=04 B=0602 D=0000 H=011B S=0100 P=0108 SUB C*0109 +-T + +C0Z0M0E0I1 A=02 B=0602 D=0000 H=011B S=0100 P=0109 JC 010D*010C +-X + +C0Z0M0E0I1 A=02 B=0602 D=0000 H=011B S=0100 P=010C MOV C,A +-G Run to completion + +*0116 +-X + +C0Z1M0E1I1 A=03 B=0003 D=0000 H=0121 S=0100 P=0116 RST 07 +-S121 Look at the value of "LARGE" + + 0121 03 Wrong value! + + 0122 00 + + 0123 22 + + 0124 21 + + 0125 00 + + 0126 02 + + 0127 7E _. End of the S command + +-L100 + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C + 0109 JC 010D + 010C MOV C,A + + + 4-17 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C +-L Review the code + + 0113 STA 0121 + 0116 RST 07 + 0117 NOP + 0118 NOP + 0119 STAX B + 011A NOP + 011B INR B + 011C INX B + 011D DCR B + 011E MVI B,01 + 0120 DCR B +-XP + +P=0116 100 Reset the PC + +-T + Single step, and watch data values +C0Z1M0E1I1 A=03 B=0003 D=0000 H=0121 S=0100 P=0100 MVI B,08*0102 +-T + +C0Z1M0E1I1 A=03 B=0803 D=0000 H=0121 S=0100 P=0102 MVI C,00*0104 +-T + Count set Largest set +C0Z1M0E1I1 A=03 B=0800 D=0000 H=0121 S=0100 P=0104 LXI H,0119*0107 +-T + Base address of data set +C0Z1M0E1I1 A=03 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M*0108 +-T + First data item brought to A +C0Z1M0E1I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C*0109 +-T + +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JC 010D*010C +-T + +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010C MOV C,A*010D +-T + First data item moved to C correctly +C0Z0M0E0I1 A=02 B=0802 D=0000 H=0119 S=0100 P=010D INX H*010E +-T + +C0Z0M0E0I1 A=02 B=0802 D=0000 H=011A S=0100 P=010E DCR B*010F +-T + +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=010F JNZ 0107*0107 +-T + +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=0107 MOV A,M*0108 +-T + + + 4-18 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + + Second data item brought to A +C0Z0M0E0I1 A=00 B=0702 D=0000 H=011A S=0100 P=0108 SUB C*0109 +-T + Subtract destroys data value that was loaded! +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=0109 JC 010D*010D +-T + +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=010D INX H*010E +-L100 + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C This should have been a CMP so that register A + 0109 JC 010D would not be destroyed. + 010C MOV C,A + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C + -A108 + +0108 CMP C Hot patch at 108H changes SUB to CMP + +0109 + +-G0 Stop DDT for SAVE + +A>SAVE 1 SCAN.COM Save memory image + +A>DDT SCAN.COM Restart DDT + +DDT VER 1.0 +NEXT PC +0200 0100 +-XP + +P=0100 + +-L116 + + 0116 RST 07 + 0117 NOP + 0118 NOP Look at code to see if it was properly loaded + 0119 STAX B (long typeout aborted with rubout) + 011A NOP + - + +-G,116 Run from 100H to completion + +*0116 +-XC Look at carry (accidental typo) +C1 +-X Look at CPU state + + + 4-19 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +C1Z1M0E1I1 A=06 B=0006 D=0000 H=0121 S=0100 P=0116 RST 07 +-S121 Look at "large"--it appears to be correct. + +0121 06 + +0122 00 + +0123 22 + +-G0 Stop DDT + +A>ED SCAN.ASM Re-edit the source program, and make both changes + +*NSUB +*0LT + CTRL-Z SUB C ;LARGER VALUE IN C? +*SSUB^|ZCMP^|Z0LT + CMP D ;LARGER VALUE IN C? +* + JNC NFOUND ;JUMP IF LARGER VALUE NOT FOUND +*SNC^|ZC^|Z0LT + JC NFOUND ;JUMP IF LARGER VALUE NOT FOUND +*E + Reassemble, selecting source from disk A +A>ASM SCAN.AAZ <--- Hex to disk A + Print to Z (selects no print file) +CP/M ASSEMBLER VER 1.0 + +0122 +002H USE FACTOR +END OF ASSEMBLY + +A>DDT SCAN.HEX Rerun debugger to check changes + +DDT VER 1.0 +NEXT PC +0121 0000 +-L116 + + 0116 JMP 0000 Check to ensure end is still at 116H + + 0119 STAX B + + 011A NOP + 011B INR B + + -(rubout) + +-G100,116 Go from beginning with breakpoint at end + +*0116 Breakpoint reached +-D121 Look at "LARGE" + Correct value computed +0121 06 00 22 21 00 02 7E EB 77 13 23 EB 0B 78 B1 .. '!... W .#..X. +0130 C2 27 01 C3 03 29 00 00 00 00 00 00 00 00 00 00 .'...)........ + + + 4-20 + + + + + +CP/M Operating System Manual 4.4 A Sample Program + + +0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .............. + +-(rubout) Aborts long typeout + +G0 Stop DDT, debug session complete. + K + + +End of Section 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4-21 + + + + + + + + +Section 5 + +CP/M 2 System Interface + + +5.1 Introduction + + This chapter describes CP/M (release 2) system organization including the +structure of memory and system entry points. This section provides +the information you need to write programs that operate under CP/M and +that use the peripheral and disk I/O facilities of the system. + + CP/M is logically divided into four parts, called the Basic Input/Output +System (BIOS), the Basic Disk Operating System (BDOS), the Console Command +Processor (CCP), and the Transient Program Area (TPA). The BIOS is a +hardware-dependent module that defines the exact low level interface with a +particular computer system that is necessary for peripheral device I/O. +Although a standard BIOS is supplied by Digital Research, explicit +instructions are provided for field reconfiguration of the BIOS to match +nearly any hardware environment, see Section 6. + + The BIOS and BDOS are +logically combined into a single module with a common entry point and +referred to as the FDOS. The CCP is a distinct program that uses the FDOS to +provide a human-oriented interface with the information that is cataloged on +the back-up storage device. The TPA is an area of memory, +not used by the FDOS and CCP, where various nonresident operating +system commands and user programs are executed. The lower portion of memory +is reserved for system information and is detailed in later sections. Memory +organization of the CP/M system is shown in Figure 5-1. + + + + High + Memory FDOS (BDOS+BIOS) + FBASE: + + CCP + CBASE: + + TPA + TBASE: + + System Parameters + BOOT: + + +Figure 5-1. CP/M Memory Organization + + + + The exact memory addresses corresponding to BOOT, TBASE, CBASE, +and FBASE vary from version to version and are described fully in +Section 6. All standard CP/M versions assume BOOT=0000H, which is +the base of random access memory. The machine code found at + + + 5-1 + + + + + +CP/M Operating System Manual 5.1 Introduction + + +location BOOT performs a system warm start, which loads and +initializes the programs and variables necessary to return control +to the CCP. Thus, transient programs need only jump to location +BOOT to return control to CP/M at the command level. Further, the +standard versions assume TBASE=BOOT+0100H, which is normally +location 0100H. The principal entry point to the FDOS is at +location BOOT+0005H (normally 0005H) where a jump to FBASE is found. +The address field at BOOT+0006H (normally 0006H) contains the value +of FBASE and can be used to determine the size of available memory, +assuming that the CCP is being overlaid by a transient program. + + Transient programs are loaded into the TPA and executed as +follows. The operator communicates with the CCP by typing command +lines following each prompt. Each command line takes one of the +following forms: + + command + command file1 + command file1 file2 + +where command is either a built-in function, such as DIR or TYPE, or +the name of a transient command or program. If the command is a +built-in function of CP/M, it is executed immediately. Otherwise, +the CCP searches the currently addressed disk for a file by the name + + command.COM + + If the file is found, it is assumed to be a memory image of a +program that executes in the TPA and thus implicity originates at +TBASE in memory. The CCP loads the COM file from the disk into +memory starting at TBASE and can extend up to CBASE. + + If the command is followed by one or two file specifications, +the CCP prepares one or two File Control Block (FCB) names in the +system parameter area. These optional FCBs are in the form +necessary to access files through the FDOS and are described in +Section 5.2. + + The transient program receives control from the CCP and begins +execution, using the I/O facilities of the FDOS. The transient +program is called from the CCP. Thus, it can simply return to the +CCP upon completion of its processing, or can jump to BOOT to pass +control back to CP/M. In the first case, the transient program must +not use memory above CBASE, while in the latter case, memory up +through FBASE-1 can be used. + + The transient program can use the CP/M I/O facilities to +communicate with the operator's console and peripheral devices, +including the disk subsystem. The I/O system is accessed by passing +a function number and an information address to CP/M through the +FDOS entry point at BOOT+0005H. In the case of a disk read, for +example, the transient program sends the number corresponding to a +disk read, along with the address of an FCB to the CP/M FDOS. The +FDOS, in turn, performs the operation and returns with either a disk +read completion indication or an error number indicating that the + + + 5-2 + + + + + +CP/M Operating System Manual 5.1 Introduction + + +disk read was unsuccessful. + + +5.2 Operating System Call Conventions + + This section provides detailed information for performing +direct operating system calls from user programs. Many of the +functions listed below, however, are accessed more simply through +the I/O macro library provided with the MAC macro assembler and +listed in the Digital Research manual entitled, Programmer's +Utilities Guide for the CP/M Family of Operating Systems. + + CP/M facilities that are available for access by transient +programs fall into two general categories: simple device I/O and +disk file I/O. The simple device operations are + + o read a console character + o write a console character + o read a sequential character + o write a sequential character + o get or set I/O status + o print console buffer + o interrogate console ready + + The following FDOS operations perform disk I/O: + + o disk system reset + o drive selection + o file creation + o file close + o directory search + o file delete + o file rename + o random or sequential read + o random or sequential write + o interrogate available disks + o interrogate selected disk + o set DMA address + o set/reset file indicators. + + As mentioned above, access to the FDOS functions is +accomplished by passing a function number and information address +through the primary point at location BOOT+0005H. In general, the +function number is passed in register C with the information address +in the double byte pair DE. Single byte values are returned in +register A, with double byte values returned in HL, a zero value is +returned when the function number is out of range. For reasons of +compatibility, register A = L and register B = H upon return in all +cases. Note that the register passing conventions of CP/M agree +with those of the Intel PL/M systems programming language. CP/M +functions and their numbers are listed below. + + + + + + + 5-3 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + O System Reset 19 Delete File + 1 Console Input 20 Read Sequential + 2 Console Output 21 Write Sequential + 3 Reader Input 22 Make File + 4 Punch Output 23 Rename File + 5 List Output 24 Return Login Vector + 6 Direct Console I/O 25 Return Current Disk + 7 Get I/O Byte 26 Set DMA Address + 8 Set I/O Byte 27 Get Addr(Alloc) + 9 Print String 28 Write Protect Disk + 10 Read Console Buffer 29 Get R/0 Vector + 11 Get Console Status 30 Set File Attributes + 12 Return Version Number 31 Get Addr(Disk Parms) + 13 Reset Disk System 32 Set/Get User Code + 14 Select Disk 33 Read Random + 15 Open File 34 Write Random + 16 Close File 35 Compute File Size + 17 Search for First 36 Set Random Record + 18 Search for Next 37 Reset Drive + 40 Write Random with Zero Fill + + + Functions 28 and 32 should be avoided in application programs +to maintain upward compatibility with CP/M. + + Upon entry to a transient program, the CCP leaves the stack +pointer set to an eight-level stack area with the CCP return address +pushed onto the stack, leaving seven levels before overflow occurs. +Although this stack is usually not used by a transient program (most +transients return to the CCP through a jump to location 0000H) it is +large enough to make CP/M system calls because the FDOS switches to +a local stack at system entry. For example, the assembly-language +program segment below reads characters continuously until an +asterisk is encountered, at which time control returns to the CCP, +assuming a standard CP/M system with BOOT = 0000H. + + + BDOS EQU 0005H ;STANDARD CP/M ENTRY + CONIN EQU 1 ;CONSOLE INPUT FUNCTION + ; + ORG 0100H ;BASE OF TPA + NEXTC: MVI C,CONIN ;READ NEXT CHARACTER + CALL BDOS ;RETURN CHARACTER IN + CPI '*' ;END OF PROCESSING? + JNZ NEXTC ;LOOP IF NOT + RET ;RETURN TO CCP + END + + + CP/M implements a named file structure on each disk, providing +a logical organization that allows any particular file to contain +any number of records from completely empty to the full capacity of +the drive. Each drive is logically distinct with a disk directory +and file data area. The disk filenames are in three parts: the +drive select code, the filename (consisting of one to eight nonblank + + + 5-4 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + +characters), and the filetype (consisting of zero to three nonblank +characters). The filetype names the generic category of a +particular file, while the filename distinguishes individual files +in each category. The filetypes listed in Table 5-1 name a few +generic categories that have been established, although they are +somewhat arbitrary. + + + Table 5-1. CP/M Filetypes + + Filetype Meaning + + ASM Assembler Source + PRN Printer Listing + HEX Hex Machine Code + BAS Basic Source File + INT Intermediate Code + COM Command File + PLI PL/I Source File + REL Relocatable Module + TEX TEX Formatter Source + BAK ED Source Backup + SYM SID Symbol File + $$$ Temporary File + + + Source files are treated as a sequence of ASCII characters, +where each line of the source file is followed by a carriage return, +and line-feed sequence (0DH followed by 0AH). Thus, one 128-byte +CP/M record can contain several lines of source text. The end of an +ASCII file is denoted by a CTRL-Z character (1AH) or a real end-of- +file returned by the CP/M read operation. CTRL-Z characters +embedded within machine code files (for example, COM files) are +ignored and the end-of-file condition returned by CP/M is used to +terminate read operations. + + Files in CP/M can be thought of as a sequence of up to 65536 +records of 128 bytes each, numbered from 0 through 65535, thus +allowing a maximum of 8 megabytes per file. Note, however, that +although the records may be considered logically contiguous, they +may not be physically contiguous in the disk data area. Internally, +all files are divided into 16K byte segments called logical extents, +so that counters are easily maintained as 8-bit values. The +division into extents is discussed in the paragraphs that follow: +however, they are not particularly significant for the programmer, +because each extent is automatically accessed in both sequential and +random access modes. + + In the file operations starting with Function 15, DE usually +addresses a FCB. Transient programs often use the default FCB area +reserved by CP/M at location BOOT+005CH (normally 005CH) for simple +file operations. The basic unit of file information is a 128-byte +record used for all file operations. Thus, a default location for +disk I/O is provided by CP/M at location BOOT+0080H (normally 0080H) +which is the initial default DMA address. See Function 26. + + + 5-5 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + All directory operations take place in a reserved area that +does not affect write buffers as was the case in release 1, with the +exception of Search First and Search Next, where compatibility is +required. + + The FCB data area consists of a sequence of 33 bytes for +sequential access and a series of 36 bytes in the case when the file +is accessed randomly. The default FCB, normally located at 005CH, +can be used for random access files, because the three bytes +starting at BOOT+007DH are available for this purpose. Figure 5-2 +shows the FCB format with the following fields. + + + + dr f1 f2 / / f8 t1 t2 t3 ex s1 s2 rc d0 / / dn cr r0 r1 r2 + 00 01 02 ... 08 09 10 11 12 13 14 15 16 ... 31 32 33 34 35 + + + Figure 5-2. File Control Block Format + + + +The following table lists and describes each of the fields in the +File Control Block figure. + + + Table 5-2. File Control Block Fields + + Field Definition + + dr drive code (0-16) + 0 = use default drive for file + 1 = auto disk select drive A, + 2 = auto disk select drive B, + . + . + . + 16= auto disk select drive P. + + f1...f8 contain the filename in ASCII + upper-case, with high bit = 0 + + t1, t2, t3 contain the filetype in ASCII + upper-case, with high bit = 0 + t1', t2', and t3' denote the + bit of these positions, + t1' = 1 =>Read-Only file, + t2' = 1 =>SYS file, no DIR list + + ex contains the current extent + number, normally set to 00 by + the user, but in range 0-31 + during file I/O + + + + 5-6 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + Table 5-2. (continued) + + Field Definition + + s1 reserved for internal system use + + s2 reserved for internal system use, + set to zero on call to OPEN, MAKE, + SEARCH + + rc record count for extent ex; + takes on values from 0-127 + + d0...dn filled in by CP/M; reserved for + system use + + cr current record to read or write in + a sequential file operation; + normally set to zero by user + + r0, r1, r2 optional random record number in + the range 0-65535, with overflow + to r2, r0, r1 constitute a 16-bit + value with low byte r0, and high + byte r1 + + + Each file being accessed through CP/M must have a corresponding +FCB, which provides the name and allocation information for all +subsequent file operations. When accessing files, it is the +programmer's responsibility to fill the lower 16 bytes of the FCB +and initialize the cr field. Normally, bytes 1 through 11 are set +to the ASCII character values for the filename and filetype, while +all other fields are zero. + + FCBs are stored in a directory area of the disk, and are +brought into central memory before the programmer proceeds with file +operations (see the OPEN and MAKE functions). The memory copy of +the FCB is updated as file operations take place and later recorded +permanently on disk at the termination of the file operation, (see +the CLOSE command). + + The CCP constructs the first 16 bytes of two optional FCBs for +a transient by scanning the remainder of the line following the +transient name, denoted by file1 and file2 in the prototype command +line described above, with unspecified fields set to ASCII blanks. +The first FCB is constructed at location BOOT+005CH and can be used +as is for subsequent file operations. The second FCB occupies the +d0...dn portion of the first FCB and must be moved to another area +of memory before use. If, for example, the following command line +is typed: + + PROGNAME B:X.ZOT Y.ZAP + + + + + 5-7 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + +the file PROGNAME.COM is loaded into the TPA, and the default FCB at +BOOT+005CH is initialized to drive code 2, filename X, and filetype +ZOT. The second drive code takes the default value 0, which is +placed at BOOT-006CH, with the filename Y placed into location +BOOT+006DH and filetype ZAP located 8 bytes later at BOOT+0075H. +All remaining fields through cr are set to zero. Note again that it +is the programmer's responsibility to move this second filename and +filetype to another area, usually a separate file control block, +before opening the file that begins at BOOT+005CH, because the open +operation overwrites the second name and type. + + If no filenames are specified in the original command, the +fields beginning at BOOT+005DH and BOOT+006DH contain blanks. In +all cases, the CCP translates lower-case alphabetics to upper-case +to be consistent with the CP/M file naming conventions. + + As an added convenience, the default buffer area at location +BOOT+0080H is initialized to the command line tail typed by the +operator following the program name. The first position contains +the number of characters, with the characters themselves following +the character count. Given the above command line, the area +beginning at BOOT+0080H is initialized as follows: + + + BOOT+0080H: + + +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +A +B +C +D +E + E '' 'B' ':' 'X' '.' 'Z' 'O' 'T' '' 'Y' '.' 'Z' 'A' 'P' + + +where the characters are translated to upper-case ASCII with +uninitialized memory following the last valid character. Again, it +is the responsibility of the programmer to extract the information +from this buffer before any file operations are performed, unless +the default DMA address is explicitly changed. + + Individual functions are described in detail in the pages that +follow. + + + + + + + + + + + + + + + + + + + + 5-8 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 0: SYSTEM RESET + + Entry Parameters: + Register C: 00H + + + + The System Reset function returns control to the CP/M operating +system at the CCP level. The CCP reinitializes the disk subsystem +by selecting and logging-in disk drive A. This function has exactly +the same effect as a jump to location BOOT. + + + + + + + FUNCTION 1: CONSOLE INPUT + + Entry Parameters: + Register C: 01H + + Returned Value: + Register A: ASCII Character + + + + The Console Input function reads the next console character to +register A. Graphic characters, along with carriage return, line- +feed, and back space (CTRL-H) are echoed to the console. Tab +characters, CTRL-I, move the cursor to the next tab stop. A check +is made for start/stop scroll, CTRL-S, and start/stop printer echo, +CTRL-P. The FDOS does not return to the calling program until a +character has been typed, thus suspending execution if a character +is not ready. + + + + + + + + + + + + + + + + + + + 5-9 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 2: CONSOLE OUTPUT + + Entry Parameters + Register C: 02H + Register E: ASCII Character + + + + The ASCII character from register E is sent to the console +device. As in Function 1, tabs are expanded and checks are made for +start/stop scroll and printer echo. + + + + + + + FUNCTION 3: READER INPUT + + Entry Parameters: + Register C: 03H + + Returned Value: + Register A: ASCII Character + + + + The Reader Input function reads the next character from the +logical reader into register A. See the IOBYTE definition in +Chapter 6. Control does not return until the character has been +read. + + + + + + + + + + + + + + + + + + + + + + + 5-10 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 4: PUNCH OUTPUT + + Entry Parameters: + Register C: 04H + register E: ASCII Character + + + + The Punch Output function sends the character from register E +to the logical punch device. + + + + + + + FUNCTION 5: LIST OUTPUT + + Entry Parameters: + Register C: 05H + Register E: ASCII Character + + + + The List Output function sends the ASCII character in register +E to the logical listing device. + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-11 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 6: DIRECT CONSOLE I/O + + Entry Parameters: + Register C: 06H + Register E: 0FFH (input) or + char (output) + + Returned Value: + Register A: char or status + + + + Direct Console I/O is supported under CP/M for those +specialized applications where basic console input and output are +required. Use of this function should, in general, be avoided since +it bypasses all of the CP/M normal control character functions (for +example, CTRL-S and CTRL-P). Programs that perform direct I/O +through the BIOS under previous releases of CP/M, however, should be +changed to use direct I/O under BDOS so that they can be fully +supported under future releases of MP/M and CP/M. + + Upon entry to Function 6, register E either contains +hexadecimal FF, denoting a console input request, or an ASCII +character. If the input value is FF, Function 6 returns A = 00 if +no character is ready, otherwise A contains the next console input +character. + + If the input value in E is not FF, Function 6 assumes that E +contains a valid ASCII character that is sent to the console. + + Function 6 must not be used in conjunction with other console +I/O functions. + + + + + + + FUNCTION 7: GET I/O BYTE + + Entry Parameters: + Register C: 07H + + Returned Value: + Register A: I/O Byte Value + + + + The Get I/O Byte function returns the current value of IOBYTE +in register A. See Chapter 6 for IOBYTE definition. + + + + 5-12 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 8: SET I/O BYTE + + Entry Parameters: + Register C: 08H + Register E: I/O Byte Value + + + + The SET I/O Byte function changes the IOBYTE value to that +given in register E. + + + + + + + FUNCTION 9: PRINT STRING + + Entry Parameters: + Register C: 09H + Registers DE: String Address + + + + The Print String function sends the character string stored in +memory at the location given by DE to the console device, until a $ +is encountered in the string. Tabs are expanded as in Function 2, +and checks are made for start/stop scroll and printer echo. + + + + + + + + + + + + + + + + + + + + + + + + + + 5-13 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 10: READ CONSOLE BUFFER + + Entry Parameters: + Register C: 0AH + Registers DE: Buffer Address + + Returned Value: + Console Characters in Buffer + + + + The Read Buffer functions reads a line of edited console input +into a buffer addressed by registers DE. Console input is +terminated when either input buffer overflows or a carriage return +or line-feed is typed. The Read Buffer takes the form: + + DE:+0 +1 +2 +3 +4 +5 +6 +7 +8 . . .+n + + mx nc c1 c2 c3 c4 c5 c6 c7 ... ?? + +where mx is the maximum number of characters that the buffer will +hold, 1 to 255, and nc is the number of characters read (set by FDOS +upon return) followed by the characters read from the console. If +nc < mx, then uninitialized positions follow the last character, +denoted by ?? in the above figure. A number of control functions, +summarized in Table 5-3, are recognized during line editing. + + + Table 5-3. Edit Control Characters + + Character Edit Control Function + + rub/del removes and echoes the last character + + CTRL-C reboots when at the beginning of line + + CTRL-E causes physical end of line + + CTRL-H backspaces one character position + + CTRL-J (line feed) terminates input line + + CTRL-M (return) terminates input line + + CTRL-R retypes the current line after new line + + CTRL-U removes current line + + CTRL-X same as CTRL-U + + + + + 5-14 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + +The user should also note that certain functions that return the +carriage to the leftmost position (for example, CTRL-X) do so only +to the column position where the prompt ended. In earlier releases, +the carriage returned to the extreme left margin. This convention +makes operator data input and line correction more legible. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-15 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 11: GET CONSOLE STATUS + + Entry Parameters: + Register C: 0BH + + Returned Value: + Register A: Console Status + + + + The Console Status function checks to see if a character has +been typed at the console. If a character is ready, the value 0FFH +is returned in register A. Otherwise a 00H value is returned. + + + + + + + FUNCTION 12: RETURN VERSION NUMBER + + Entry Parameters: + Register C: 0CH + + Returned Value: + Registers HL: Version Number + + + + Function 12 provides information that allows version +independent programming. A two-byte value is returned, with H = 00 +designating the CP/M release (H = 01 for MP/M) and L = 00 for all +releases previous to 2.0. CP/M 2.0 returns a hexadecimal 20 in +register L, with subsequent version 2 releases in the hexadecimal +range 21,22, through 2F. Using Function 12, for example, the user +can write application programs that provide both sequential and +random access functions. + + + + + + + + + + + + + + + + + 5-16 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 13: RESET DISK SYSTEM + + Entry Parameters: + Register C: 0DH + + + + The Reset Disk function is used to programmatically restore the +file system to a reset state where all disks are set to Read-Write. +See functions 28 and 29, only disk drive A is selected, and the +default DMA address is reset to BOOT+0080H. This function can be +used, for example, by an application program that requires a disk +change without a system reboot. + + + + + + + FUNCTION 14: SELECT DISK + + Entry Parameters: + Register C: 0EH + Register E: Selected Disk + + + + The Select Disk function designates the disk drive named in +register E as the default disk for subsequent file operations, with +E = O for drive A, 1 for drive B, and so on through 15, +corresponding to drive P in a full 16 drive system. The drive is +placed in an on-line status, which activates its directory until the +next cold start, warm start, or disk system reset operation. If the +disk medium is changed while it is on-line, the drive automatically +goes to a Read-Only status in a standard CP/M environment, see +Function 28. FCBs that specify drive code zero (dr = 00H) +automatically reference the currently selected default drive. Drive +code values between 1 and 16 ignore the selected default drive and +directly reference drives A through P. + + + + + + + + + + + + + + + 5-17 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 15: OPEN FILE + + Entry Parameters: + Register C: 0FH + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + The Open File operation is used to activate a file that +currently exists in the disk directory for the currently active user +number. The FDOS scans the referenced disk directory for a match in +positions 1 through 14 of the FCB referenced by DE (byte s1 is +automatically zeroed) where an ASCII question mark (3FH) matches any +directory character in any of these positions. Normally, no +question marks are included, and bytes ex and s2 of the FCB are +zero. + + If a directory element is matched, the relevant directory +information is copied into bytes d0 through dn of FCB, thus allowing +access to the files through subsequent read and write operations. +The user should note that an existing file must not be accessed +until a successful open operation is completed. Upon return, the +open function returns a directory code with the value 0 through 3 if +the open was successful or 0FFH (255 decimal) if the file cannot be +found. If question marks occur in the FCB, the first matching FCB +is activated. Note that the current record, (cr) must be zeroed by +the program if the file is to be accessed sequentially from the +first record. + + + + + + + + + + + + + + + + + + + + + + + 5-18 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 16: CLOSE FILE + + Entry Parameters: + Register C: 10H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + The Close File function performs the inverse of the Open File +function. Given that the FCB addressed by DE has been previously +activated through an open or make function, the close function +permanently records the new FCB in the reference disk directory see +functions 15 and 22. The FCB matching process for the close is +identical to the open function. The directory code returned for a +successful close operation is 0, 1, 2, or 3, while a 0FFH (255 +decimal) is returned if the filename cannot be found in the +directory. A file need not be closed if only read operations have +taken place. If write operations have occurred, the close operation +is necessary to record the new directory information permanently. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-19 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 17: SEARCH FOR FIRST + + Entry Parameters: + Register C: 11H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + Search First scans the directory for a match with the file +given by the FCB addressed by DE. The value 255 (hexadecimal FF) is +returned if the file is not found; otherwise, 0, 1, 2, or 3 is +returned indicating the file is present. When the file is found, +the current DMA address is filled with the record containing the +directory entry, and the relative starting position is A *32 (that +is, rotate the A register left 5 bits, or ADD A five times). +Although not normally required for application programs, the +directory information can be extracted from the buffer at this +position. + + An ASCII question mark (63 decimal, 3F hexadecimal) in any +position from f1 through ex matches the corresponding field of any +directory entry on the default or auto-selected disk drive. If the +dr field contains an ASCII question mark, the auto disk select +function is disabled and the default disk is searched, with the +search function returning any matched entry, allocated or free, +belonging to any user number. This latter function is not normally +used by application programs, but it allows complete flexibility to +scan all current directory values. If the dr field is not a +question mark, the s2 byte is automatically zeroed. + + + + + + + + + + + + + + + + + + + + + + 5-20 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 18: SEARCH FOR NEXT + + Entry Parameters: + Register C: 12H + + Returned Value: + Register A: Directory Code + + + + The Search Next function is similar to the Search First +function, except that the directory scan continues from the last +matched entry. Similar to Function 17, Function 18 returns the +decimal value 255 in A when no more directory items match. + + + + + + + FUNCTION 19: DELETE FILE + + Entry Parameters: + Register C: 13H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + The Delete File function removes files that match the FCB +addressed by DE. The filename and type may contain ambiguous +references (that is, question marks in various positions), but the +drive select code cannot be ambiguous, as in the Search and Search +Next functions. + + Function 19 returns a decimal 255 if the referenced file or +files cannot be found; otherwise, a value in the range 0 to 3 +returned. + + + + + + + + + + + + + + 5-21 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 20: READ SEQUENTIAL + + Entry Parameters: + Register C: 14H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + Given that the FCB addressed by DE has been activated through +an Open or Make function, the Read Sequential function reads the +next 128-byte record from the file into memory at the current DMA +address. The record is read from position cr of the extent, and the +cr field is automatically incremented to the next record position. +If the cr field overflows, the next logical extent is automatically +opened and the cr field is reset to zero in preparation for the next +read operation. The value 00H is returned in the A register if the +read operation was successful, while a nonzero value is returned if +no data exist at the next record position (for example, end-of-file +occurs). + + + + + + + FUNCTION 21: WRITE SEQUENTAIL + + Entry Parameters: + Register C: 15H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + Given that the FCB addressed by DE has been activated through +an Open or Make function, the Write Sequential function writes the +128-byte data record at the current DMA address to the file named by +the FCB. The record is placed at position cr of the file, and the +cr field is automatically incremented to the next record position. +If the cr field overflows, the next logical extent is automatically +opened and the cr field is reset to zero in preparation for the next +write operation. Write operations can take place into an existing +file, in which case, newly written records overlay those that +already exist in the file. Register A = 00H upon return from a +successful write operation, while a nonzero value indicates an +unsuccessful write caused by a full disk. + + + 5-22 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 22: MAKE FILE + + Entry Parameters: + Register C: 16H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + The Make File operation is similar to the Open File operation +except that the FCB must name a file that does not exist in the +currently referenced disk directory (that is, the one named +explicitly by a nonzero dr code or the default disk if dr is zero). +The FDOS creates the file and initializes both the directory and +main memory value to an empty file. The programmer must ensure that +no duplicate filenames occur, and a preceding delete operation is +sufficient if there is any possibility of duplication. Upon return, +register A = 0, 1, 2, or 3 if the operation was successful and 0FFH +(255 decimal) if no more directory space is available. The Make +function has the side effect of activating the FCB and thus a +subsequent open is not necessary. + + + + + + + FUNCTION 23: RENAME FILE + + Entry Parameters: + Register C: 17H + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + The Rename function uses the FCB addressed by DE to change all +occurrences of the file named in the first 16 bytes to the file +named in the second 16 bytes. The drive code dr at postion 0 is +used to select the drive, while the drive code for the new filename +at position 16 of the FCB is assumed to be zero. Upon return, +register A is set to a value between 0 and 3 if the rename was +successful and 0FFH (255 decimal) if the first filename could not be +found in the directory scan. + + + + + + 5-23 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 24: RETURN LOG-IN VECTOR + + Entry Parameters: + Register C: 18H + + Returned Value: + Registers HL: Log-in Vector + + + + The log-in vector value returned by CP/M is a 16-bit value in +HL, where the least significant bit of L corresponds to the first +drive A and the high-order bit of H corresponds to the sixteenth +drive, labeled P. A 0 bit indicates that the drive is not on-line, +while a 1 bit marks a drive that is actively on-line as a result of +an explicit disk drive selection or an implicit drive select caused +by a file operation that specified a nonzero dr field. The user +should note that compatibility is maintained with earlier releases, +because registers A and L contain the same values upon return. + + + + + + + FUNCTION 25: RETURN CURRENT DISK + + Entry Parameters: + Register C: 19H + + Returned Value: + Register A: Current Disk + + + + Function 25 returns the currently selected default disk number +in register A. The disk numbers range from 0 through 15 +corresponding to drives A through P. + + + + + + + + + + + + + + + + 5-24 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 26: SET DMA ADDRESS + + Entry Parameters: + Register C: 1AH + Registers DE: DMA Address + + + + DMA is an acronym for Direct Memory Address, which is often +used in connection with disk controllers that directly access the +memory of the mainframe computer to transfer data to and from the +disk subsystem. Although many computer systems use non-DMA access +(that is, the data is transferred through programmed I/O +operations), the DMA address has, in CP/M, come to mean the address +at which the 128-byte data record resides before a disk write and +after a disk read. Upon cold start, warm start, or disk system +reset, the DMA address is automatically set to BOOT+0080H. The Set +DMA function can be used to change this default value to address +another area of memory where the data records reside. Thus, the DMA +address becomes the value specified by DE until it is changed by a +subsequent Set DMA function, cold start, warm start, or disk system +reset. + + + + + + + FUNCTION 27: GET ADDR (ALLOC) + + Entry Parameters: + Register C: 1BH + + Returned Value: + Registers HL: ALLOC Address + + + + An allocation vector is maintained in main memory for each on- +line disk drive. Various system programs use the information +provided by the allocation vector to determine the amount of +remaining storage (see the STAT program). Function 27 returns the +base address of the allocation vector for the currently selected +disk drive. However, the allocation information might be invalid if +the selected disk has been marked Read-Only. Although this function +is not normally used by application programs, additional details of +the allocation vector are found in Chapter 6. + + + + + + + 5-25 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 28: WRITE PROTECT DISK + + Entry Parameters: + Register C: 1CH + + + + The Write Protect Disk function provides temporary write +protection for the currently selected disk. Any attempt to write to +the disk before the next cold or warm start operation produces the +message: + + BDOS ERR on d:R/O + + + + + + + FUNCTION 29: GET READ-ONLY VECTOR + + Entry Parameters: + Register C: 1DH + + Returned Value: + Registers HL: R/O Vector Value + + + + Function 29 returns a bit vector in register pair HL, which +indicates drives that have the temporary Read-Only bit set. As in +Function 24, the least significant bit corresponds to drive A, while +the most significant bit corresponds to drive P. The R/O bit is set +either by an explicit call to Function 28 or by the automatic +software mechanisms within CP/M that detect changed disks. + + + + + + + + + + + + + + + + + + + 5-26 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 30: SET FILE ATTRIBUTES + + Entry Parameters: + Register C: 1EH + Registers DE: FCB Address + + Returned Value: + Register A: Directory Code + + + + The Set File Attributes function allows programmatic +manipulation of permanent indicators attached to files. In +particular, the R/O and System attributes (t1' and t2') can be set +or reset. The DE pair addresses an unambiguous filename with the +appropriate attributes set or reset. Function 30 searches for a +match and changes the matched directory entry to contain the +selected indicators. Indicators f1' through f4' are not currently +used, but may be useful for applications programs, since they are +not involved in the matching process during file open and close +operations. Indicators f5' through f8' and t3' are reserved for +future system expansion. + + + + + + + FUNCTION 31: GET ADDR (DISK PARMS) + + Entry Parameters: + Register C: 1FH + + Returned Value: + Registers HL: DPB Address + + + + The address of the BIOS resident disk parameter block is +returned in HL as a result of this function call. This address can +be used for either of two purposes. First, the disk parameter +values can be extracted for display and space computation purposes, +or transient programs can dynamically change the values of current +disk parameters when the disk environment changes, if required. +Normally, application programs will not require this facility. + + + + + + + + + 5-27 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 32: SET/GET USER CODE + + Entry Parameters: + Register C: 20H + Register E: OFFH (get) or + User Code (set) + + Returned Value: + Register A: Current Code or + (no value) + + + + An application program can change or interrogate the currently +active user number by calling Function 32. If register E = 0FFH, +the value of the current user number is returned in register A, +where the value is in the range of 0 to 15. If register E is not +0FFH, the current user number is changed to the value of E, modulo +16. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-28 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 33: READ RANDOM + + Entry Parameters: + Register C: 21H + + Returned Value: + Register A: Return Code + + + + The Read Random function is similar to the sequential file read +operation of previous releases, except that the read operation takes +place at a particular record number, selected by the 24-bit value +constructed from the 3-byte field following the FCB (byte positions +r0 at 33, r1 at 34, and r2 at 35). The user should note that the +sequence of 24 bits is stored with least significant byte first +(r0), middle byte next (r1), and high byte last (r2). CP/M does not +reference byte r2, except in computing the size of a file (Function +35). Byte r2 must be zero, however, since a nonzero value indicates +overflow past the end of file. + + Thus, the r0, r1 byte pair is treated as a double-byte, or word +value, that contains the record to read. This value ranges from 0 +to 65535, providing access to any particular record of the 8- +megabyte file. To process a file using random access, the base +extent (extent 0) must first be opened. Although the base extent +might or might not contain any allocated data, this ensures that the +file is properly recorded in the directory and is visible in DIR +requests. The selected record number is then stored in the random +record field (r0, r1), and the BDOS is called to read the record. + + Upon return from the call, register A either contains an error +code, as listed below, or the value 00, indicating the operation was +successful. In the latter case, the current DMA address contains +the randomly accessed record. Note that contrary to the sequential +read operation, the record number is not advanced. Thus, subsequent +random read operations continue to read the same record. + + Upon each random read operation, the logical extent and current +record values are automatically set. Thus, the file can be +sequentially read or written, starting from the current randomly +accessed position. However, note that, in this case, the last +randomly read record will be reread as one switches from random mode +to sequential read and the last record will be rewritten as one +switches to a sequential write operation. The user can simply +advance the random record position following each random read or +write to obtain the effect of sequential I/O operation. + + + + + + + 5-29 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + Error codes returned in register A following a random read are +listed below. + + + 01 reading unwritten data + + 02 (not returned in random mode) + + 03 cannot close current extent + + 04 seek to unwritten extent + + 05 (not returned in read mode) + + 06 seek past physical end of disk + + + Error codes 01 and 04 occur when a random read operation +accesses a data block that has not been previously written or an +extent that has not been created, which are equivalent conditions. +Error code 03 does not normally occur under proper system operation. +If it does, it can be cleared by simply rereading or reopening +extent zero as long as the disk is not physically write protected. +Error code 06 occurs whenever byte r2 is nonzero under the current +2.0 release. Normally, nonzero return codes can be treated as +missing data, with zero return codes indicating operation complete. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-30 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 34: WRITE RANDOM + + Entry Parameters: + Register C: 22H + Registers DE: FCB Address + + Returned Value: + Register A: Return Code + + + + The Write Random operation is initiated similarly to the Read +Random call, except that data is written to the disk from the +current DMA address. Further, if the disk extent or data block that +is the target of the write has not yet been allocated, the +allocation is performed before the write operation continues. As in +the Read Random operation, the random record number is not changed +as a result of the write. The logical extent number and current +record positions of the FCB are set to correspond to the random +record that is being written. Again, sequential read or write +operations can begin following a random write, with the notation +that the currently addressed record is either read or rewritten +again as the sequential operation begins. You can also simply +advance the random record position following each write to get the +effect of a sequential write operation. Note that reading or +writing the last record of an extent in random mode does not cause +an automatic extent switch as it does in sequential mode. + + The error codes returned by a random write are identical to the +random read operation with the addition of error code 05, which +indicates that a new extent cannot be created as a result of +directory overflow. + + + + + + + + + + + + + + + + + + + + + + 5-31 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 35: COMPUTE FILE SIZE + + Entry Parameters: + Register C: 23H + Registers DE: FCB Address + + Returned Value: + Random Record Field Set + + + + When computing the size of a file, the DE register pair +addresses an FCB in random mode format (bytes r0, r1, and r2 are +present). The FCB contains an unambiguous filename that is used in +the directory scan. Upon return, the random record bytes contain +the virtual file size, which is, in effect, the record address of +the record following the end of the file. Following a call to +Function 35, if the high record byte r2 is 01, the file contains the +maximum record count 65536. Otherwise, bytes r0 and r1 constitute a +16-bit value as before (r0 is the least significant byte), which is +the file size. + + Data can be appended to the end of an existing file by simply +calling Function 35 to set the random record position to the end of +file and then performing a sequence of random writes starting at the +preset record address. + + The virtual size of a file corresponds to the physical size +when the file is written sequentially. If the file was created in +random mode and holes exist in the allocation, the file might +contain fewer records than the size indicates. For example, if only +the last record of an 8-megabyte file is written in random mode +(that is, record number 65535), the virtual size is 65536 records, +although only one block of data is actually allocated. + + + + + + + + + + + + + + + + + + + + 5-32 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 36: SET RANDOM RECORD + + Entry Parameters: + Register C: 24H + Registers DE: FCB Address + + Returned Value: + Random Record Field Set + + + + The Set Random Record function causes the BDOS automatically to +produce the random record position from a file that has been read or +written sequentially to a particular point. The function can be +useful in two ways. + + First, it is often necessary initially to read and scan a +sequential file to extract the positions of various key fields. As +each key is encountered, Function 36 is called to compute the random +record position for the data corresponding to this key. If the data +unit size is 128 bytes, the resulting record position is placed into +a table with the key for later retrieval. After scanning the entire +file and tabulating the keys and their record numbers, the user can +move instantly to a particular keyed record by performing a random +read, using the corresponding random record number that was saved +earlier. The scheme is easily generalized for variable record +lengths, because the program need only store the buffer-relative +byte position along with the key and record number to find the exact +starting position of the keyed data at a later time. + + A second use of Function 36 occurs when switching from a +sequential read or write over to random read or write. A file is +sequentially accessed to a particular point in the file, Function 36 +is called, which sets the record number, and subsequent random read +and write operations continue from the selected point in the file. + + + + + + + + + + + + + + + + + + + 5-33 + + + + + +CP/M Operating System Manual 5.2 Call Conventions + + + + + + + FUNCTION 37: RESET DRIVE + + Entry Parameters: + Register C: 25H + Registers DE: Drive Vector + + Returned Value: + Register A: 00H + + + + The Reset Drive function allows resetting of specified drives. +The passed parameter is a 16-bit vector of drives to be reset; the +least significant bit is drive A:. + + To maintain compatibility with MP/M, CP/M returns a zero value. + + + + + + + FUNCTION 40: WRITE RANDOM WITH ZERO FILL + + Entry Parameters: + Register C: 28H + Registers DE: FCB Address + + Returned Value: + Register A: Return Code + + + + The Write With Zero Fill operation is similar to Function 34, +with the exception that a previously unallocated block is filled +with zeros before the data is written. + + + + + + + + + + + + + + + + + + 5-34 + + + + + +CP/M Operating System Manual 5.3 A Sample Copy Program + + +5.3 A Sample File-to-File Copy Program + + The following program provides a relatively simple example of +file operations. The program source file is created as COPY.ASM +using the CP/M ED program and then assembled using ASM or MAC, +resulting in a HEX file. The LOAD program is used to produce a +COPY.COM file that executes directly under the CCP. The program +begins by setting the stack pointer to a local area and proceeds to +move the second name from the default area at 006CH to a 33-byte +File Control Block called DFCB. The DFCB is then prepared for file +operations by clearing the current record field. At this point, +the source and destination FCBs are ready for processing, because +the SFCB at 005CH is properly set up by the CCP upon entry to the +COPY program. That is, the first name is placed into the default +FCB, with the proper fields zeroed, including the current record +field at 007CH. The program continues by opening the source file, +deleting any existing destination file, and creating the destination +file. If all this is successful, the program loops at the label +COPY until each record is read from the source file and placed into +the destination file. Upon completion of the data transfer, the +destination file is closed and the program returns to the CCP +command level by jumping to BOOT. + U + + + + ; sample file-to-file copy program + ; + ; at the ccp level, the command + ; + ; copy a:x.y b:u.v + ; + ; copies the file named x.y from drive + ; a to a file named u.v. on drive b. + ; +0000 = boot equ 0000h ;system reboot +0005 = bdos equ 0005h ;bdos entry point +005c = fcbl equ 005ch ;first file name +005c = sfcb equ fcbl ;source fcb +006c = fcb2 equ 006ch ;second file name +0080 = dbuff equ 0080h ;default buffer +0100 = tpa equ 0100h ;beginning of tpa + ; +0009 = printf equ 9 ;print buffer func# +000f = openf equ 15 ;open file func# +0010 = closef equ 16 ;close file func# +0013 = deletef equ 19 ;delete file func# +0014 = readf equ 20 ;sequential read +0015 = writef equ 21 ;sequential write +0016 = makef equ 22 ;make file func# + ; +0100 org tpa ;beginning of tpa +0100 311b02 lxi sp,stack ;local stack + ; + ; move second file name to dfcb +0103 0e10 mvi c,16 ;half an fcb + + + 5-35 + + + + + +CP/M Operating System Manual 5.3 A Sample Copy Program + + +0105 116c00 lxi d,fcb2 ;source of move +0108 21da01 lxi h,dfcb ;destination fcb +010b 1a mfcb: Idax d ;source fcb +010c 13 inx d ;ready next +010d 77 mov m,a ;dest fcb +010e 23 inx h ;ready next +010f 0d dcr c ;count 16...0 +0110 c10b01 jnz mfcb ;loop 16 times + ; + ; name has been removed, zero cr +0113 af xra a ;a = 00h +0114 32fa01 sta dfcbcr ;current rec = 0 + ; + ; source and destination fcb's ready + ; +0117 115c00 lxi d,sfcb ;source file +011a cd6901 call open ;error if 255 +011d 118701 lxi d,nofile ;ready message +0120 3c inr a ;255 becomes 0 +0121 cc6101 cz finis ;done if no file + ; + ; source file open, prep destination +0124 11da01 lxi d,dfcb ;destination +0127 cd7301 call delete ;remove if present + ; +012a 11da01 lxi d,dfcb ;destination +012d cd8201 call make ;create the file +0130 119601 lxi d,nodir ;ready message +0133 3c inr a ;255 becomes 0 +0134 cc6101 cz finis ;done if no dir space + ; + ; source file open, dest file open + ; copy until end of file on source + ; +0137 115c00 copy: lxi d,sfcb ;source +013a cd7801 call read ;read next record +013d b7 ora a ;end of file? +013e c25101 jnz eofile ;skip write if so + ; + ; not end of file, write the record +0141 11da01 lix d,dfcb ;destination +0144 cd7d01 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 11da01 lxi d,dfcb ;destination +0154 cd6e01 call close ;255 if error +0157 21bb01 lxi h,wrprot ;ready message +015a 3c inr a ;255 becomes 00 +015b cc6101 cz finis ;shouldn't happen + ; + ; copy operation complete, end + + + 5-36 + + + + + +CP/M Operating System Manual 5.3 A Sample Copy Program + + +015e 11cc01 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 system + ; + ; system interface subroutines + ; (all return directly from bdos) + ; +0169 0e0f open: mvi c,openf +016b c30500 jmp bdos + ; +016e 0e10 close: mvi c,closef +0170 c30500 jmp bdos + ; +0173 0e13 delete mvi c,deletef +0175 c30500 jmp bdos + ; +0178 0e14 read: mvi c,readf +017a c30500 jmp bdos + ; +017d 0e15 write: mvi c,writef +017f c30500 jmp bdos + ; +0182 0e16 make: mvi c,makef +0184 c30500 jmp bdos + ; + ; console messages +0187 6e6f20f nofile: db 'no source file$' +0196 6e6f209 nodir: db 'no directory space$' +01a9 6f7574f space: db 'out of dat space$' +01bb 7772695 wrprot: db 'write protected?$' +01cc 636f700 normal: db 'copy complete$' + ; + ; data areas +01da dfcb: ds 33 ;destination fcb +01fa dfcbcr equ dfcb+32 ;current record + ; +01fb ds 32 ;16 level stack + stack: +021b end + K + + + + Note that there are several simplifications in this particular +program. First, there are no checks for invalid filenames that +could contain ambiguous references. This situation could be +detected by scanning the 32-byte default area starting at location +005CH for ASCII question marks. A check should also be make to +ensure that the filenames have been included (check locations 005DH +and 006DH for nonblank ASCII characters). Finally, a check should +be made to ensure that the source and destination filenames are +different. An improvement in speed could be obtained by buffering +more data on each read operation. One could, for example, determine + + + 5-37 + + + + + +CP/M Operating System Manual 5.3 A Sample Copy Program + + +the size of memory by fetching FBASE from location 0006H and using +the entire remaining portion of memory for a data buffer. In this +case, the programmer simply resets the DMA address to the next +successive 128-byte area before each read. Upon writing to the +destination file, the DMA address is reset to the beginning of the +buffer and incremented by 128 bytes to the end as each record is +transferred to the destination file. + + +5.4 A Sample File Dump Utility + + The following file dump program is slightly more complex than +the simple copy program given in the previous section. The dump +program reads an input file, specified in the CCP command line, and +displays the content of each record in hexadecimal format at the +console. Note that the dump program saves the CCP's stack upon +entry, resets the stack to a local area, and restores the CCP's +stack before returning directly to the CCP. Thus, the dump program +does not perform and warm start at the end of processing. + U + + + +x.in 5 + ;DUMP program reads input file and displays + hex data + ; +0100 org 100h +0005 = bdos equ 0005h = ;bdos entry point +0001 = cons equ 1 ;read console +0002 = typef equ 2 ;type function +0009 = printf equ 9 ;buffer print entry +000b = brkf equ 11 ;break key function + ;(true if char +000f = openf equ 15 ;file open +0014 = readf equ 20 ;read function + ; +005c = fcb equ 5ch ;file control block + ;address +0080 = buff equ 80h ;input disk buffer + ;address + ; + ; non graphic characters +000d = cr equ 0dh ;carriage return +000a = If equ 0ah ;line feed + ; + ; file control block definitions +005c = fcbdn equ fcb+0 ;disk name +005d = fcbfn equ fcb+1 ;file name +0065 = fcbft equ fcb+9 ;disk file type (3 + ;characters) +0068 = fcbrl equ fcb+12 ;file's current reel + ;number +006b = fcbrc equ fcb+15 ;file's record count (0 to + ;128)128) +007c = fcbcr' equ fcb+32 ;current (next) record + + + 5-38 + + + + + +CP/M Operating System Manual 5.4 A Sample File Dump Utility + + + ;number (0 +007d = fcbin equ fcb+33 ;fcb length + ; + ; set up stack +0100 210000 lxi h,0 +0103 39 dad sp + ; entry stack pointer in hl from the ccp +0104 221502 shld oldsp + ; set sp to local stack area (restored at + ; finis) +0107 315702 lxi sp,stktop + ; read and print successive buffers +010a cdc101 call setup ;set up input file +010d feff cpi 255 ;255 if file not present +010f c21b01 jnz openok ;skip if open is ok + ; + ; file not there, give error message and + ; return +0112 11f301 lxi d,opnmsg +0115 cd9c01 call err +0118 c35101 jmp finis ;to return + ; + openok: ;open operation ok, set buffer index to + ;end +011b 3e80 mvi a,80h +011d 321302 sta ibp ;set buffer pointer to 80h + ; hl contains next address to print +0120 210000 lxi h,0 ;start with 0000 + ; + gloop: +0123 e5 push h ;save line position +0124 cda201 call gnb +0127 e1 pop h ;recall line position +0138 da5101 jc finis ;carry set by gnb if end + ;file +012b 47 mov b,a + ; print hex values + ; check for line fold +012c 7d + mov a,l +012d e60f ani 0fh ;check low 4 bits +012f c24401 jnz nonum + ; print line number +0132 cd7201 call crlf + ; + ; check for break key +0135 cd5901 call break + ; accum lsb = 1 if character ready +0138 0f rrc ;into carry +0139 da5101 jc finis ;don't print any more + ; +013c 7c mov a,h +013d cd8f01 call phex +0140 7d mov a,l +0141 cd8f01 call phex + + + 5-39 + + + + + +CP/M Operating System Manual 5.4 A Sample File Dump Utility + + + nonum +0144 23 inx h ;to next line number +0145 3e20 mvi a,'' +0147 cd6501 call pchar +014a 78 mov a,b +014b cd8f01 call phex +014e c32301 jmp gloop + ; + finis + ; end of dump, return to cco + ; (note that a jmp to 0000h reboots) +0151 cd7201 call crif +0154 2a1502 lhld oldsp +0157 f9 sphl + ; stack pointer contains ccp's stack + ; location +0158 c9 ret ;to the ccp + ; + ; + ; subroutines + ; + break: ;check break key (actually any key will + ;do) +0159 e5d5c5 push h! push d! push b; environment + ;saved +015c 0e0b mvi c,brkf +015e cd0500 call bdos +0161 c1d1e1 pop b! pop d! pop h; environment + restored +0164 c9 ret + ; + pchar: ;print a character +0165 e5d5c5 push h! push d! push b; saved +0168 0e02 mvi c, typef +016a 5f mov e,a +016b cd0500 call bdos +016e c1d1e1 pop b! pop d! pop h; restored +0171 c9 ret + ; + crlf +0172 3e0d mvi a,cr +0174 cd6501 call pchar +0177 3e0a mvi a,lf +0179 cd6501 call pchar +017c c9 ret + ; + ; + pnib: ;print nibble in reg a +017d e60f ani ofh ;low 4 bits +017f fe0a cpi 10 +0181 d28901 jnc p10 + ; less than or equal to 9 +0184 c630 adi '0' +0186 c38b01 jmp prn + ; + + + 5-40 + + + + + +CP/M Operating System Manual 5.4 A Sample File Dump Utility + + + ; greater or equal to 10 +0189 c637 p10: adi 'a' - 10 +018b cd6501 prn: call pchar +018e c9 ret + ; + phex ;print hex char in reg a +018f f5 pushpsw +0190 0f rrc +0191 0f rrc +0192 0f rrc +0193 0f rrc +0194 cd7d01 call pnib ;print nibble +0197 f1 pop psw +0198 cd7d01 call pnip +019b c9 ret + ; + err: ;print error message + ; d,e addresses message ending with "$" +019c 0e09 mvi c,printf ;print buffer + ;function +019e cd0500 call bdos +01a1 c9 ret + ; + ; + gnb: ;get next byte +01a2 3a1302 lda ibp +01a5 fe80 cpi 80h +01a7 c2b301 jnz g0 + ; read another buffer + ; + ; + 01aa cdce01 call diskr +01ad b7 ora a ;zero value if read ok +01ae cab301 jz g0 ;for another byte + ; end of data, return with carry set for eof +01b1 37 stc +01b2 c9 ret + ; + g0: ;read the byte at buff+reg a +01b3 5f mov e,a ;Is byte of buffer index +01b4 1600 mvi d,0 ;double precision + ;index to de +01b6 3c inr a ;index=index+1 +01b7 321302 sta ibp ;back to memory + ; pointer is incremented + ; save the current file address +01ba 218000 lxi h,buff +01bd 19 dad d + ; absolute character address is in hl +01be 7e mov a,m + ; byte is in the accumulator +01bf b7 ora a ;reset carry bit +01c0 c9 ret + ; + setup: ;set up file + + + 5-41 + + + + + +CP/M Operating System Manual 5.4 A Sample File Dump Utility + + + ; open the file for input +01c1 af xra a ;zero to accum +01c2 327c00 sta fcbcr ;clear current record + ; +01c5 115c00 lxi d,fcb +01c8 0e0f mvi c,openf +01ca cd0500 call bdos + ; 255 in accum if open error +01cd c9 ret + ; + diskr: ;read disk file record +01ce e5d5c5 push h! push d! push b +01d1 115c00 lxi d,fcb +01d4 0e14 mvi c,readf +01d6 cd0500 call bdos +01d9 c1d1e1 pop b! pop d! pop h +01dc c9 ret + ; + ; fixed message area +01dd 46494c0 signon: db 'file dump version 2.0$' +01f3 0d0a4e0 opnmsg: db cr,lf,'no input file present on + disk$' + + ; variable area +0213 ibp: ds 2 ;input buffer pointer +0215 oldsp: ds 2 ;entry sp value from ccp + ; + ; stack area +0217 ; ds 64 ;reserve 32 level stack + stktop: + ; +0257 end + K + + + +5.5 A Sample Random Access Program + + This chapter concludes with an extensive example of random +access operation. The program listed below performs the simple +function of reading or writing random records upon command from the +terminal. When a program has been created, assembled, and placed +into a file labeled RANDOM.COM, the CCP level command + + RANDOM X.DAT + +starts the test program. The program looks for a file by the name +X.DAT and, if found, proceeds to prompt the console for input. If +not found, the file is created before the prompt is given. Each +prompt takes the form + + next command? + +and is followed by operator input, followed by a carriage return. +The input commands take the form + + + + 5-42 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + + nW nR Q + +where n is an integer value in the range 0 to 65535, and W, R, and Q +are simple command characters corresponding to random write, random +read, and quit processing, respectively. If the W command is +issued, the RANDOM program issues the prompt + + type data: + +The operator then responds by typing up to 127 characters, followed +by a carriage return. RANDOM then writes the character string into +the X.DAT file at record n. If the R command is issued, RANDOM +reads record number n and displays the string value at the console, +If the Q command is issued, the X.DAT file is closed, and the +program returns to the CCP. In the interest of brevity, the only +error message is + + error, try again. + + The program begins with an initialization section where the +input file is opened or created, followed by a continuous loop at +the label ready where the individual commands are interpreted. The +DFBC at 005CH and the default buffer at 0080H are used in all disk +operations. The utility subroutines then follow, which contain the +principal input line processor, called readc. This particular +program shows the elements of random access processing, and can be +used as the basis for further program development. + U + + + + Sample Random Access Program for CP/M 2.0 + +0100 org 100h ;base of tpa + ; +0000 = reboot equ 0000h ;system reboot +0005 = bdos equ 0005h ;bdos entry point + ; +0001 = coninp equ 1 ;console input function +0002 = conout equ 2 ;console output function +0009 = pstring equ 9 ;print string until '$' +000a = rstring equ 10 ;read console buffer +000c = version equ 12 ;return version number +000f = openf equ 15 ;file open function +0010 = closef equ 16 ;close function +0016 = makef equ 22 ;make file function +0021 = readr equ 33 ;read random +0022 = writer equ 34 ;write random + ; +005c = fcb equ 005ch ;default file control + ;block +007d = ranrec equ fcb+33 ;random record position +007f = ranovf equ fcb+35 ;high order (overflow) + ;byte +0080 = buff equ 0080h ;buffer address + ; + + + 5-43 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + +000d = cr equ 0dh ;carriage return +000a = lf equ 0ah ;line feed + ; + + + Load SP, Set-Up File for Random Access + +0100 31bc00 lxi sp,stack + ; + ; version 2.0 +0103 0e0c mvi c,version +0105 cd0500 call bdos +0108 fe20 cpi 20h ;version 2.0 or better? +010a d21600 jnc versok + ; bad version, message and go back +010d 111b00 lxi d,badver +0110 cdda00 call print +0113 c30000 jmp reboot + ; + versok: + ; correct versionm for random access +0116 0e0f mvi c,openf ;open default fcb +0118 115c00 lxi d,fcb +011b cd 0500 call bdos +011e 3c inr a ;err 255 becomes zero +011f c23700 jnz ready + ; + ; connot open file, so create it +0122 0e16 mvi c,makef +0124 115c00 lxi d,fcb +0127 cd0500 call bdos +012a 3c inr a ;err 255 becomes zero +012b c23700 jnz ready + ; + ; cannot create file, directory full +012e 113a00 lxi d,nospace +0131 cdda00 call print +0134 c30000 jmp reboot ;back to ccp + + + Loop Back to Ready After Each Command + + ; + ready: + ; file is ready for processing + ; +0137 cde500 call readcom ;read next command +013a 227d00 shld ranrec ;store input record# +013d 217f00 lxi h,ranovf +0140 3600 mvi m,0 ;clear high byte if set +0142 fe51 cpi 'Q' ;quit? +0144 c25600 jnz notq + ; + ; quit processing, close file +0147 0e10 mvi c,closef + + + 5-44 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + +0149 115c00 lxi d,fcb +014c cd0500 call bdos +014f 3c inr a ;err 255 becomes 0 +0150 cab900 jz error ;error message, retry +0153 c30000 jmp reboot ;back to ccp + ; + + + End of Quit Command, Process Write + + notq: + ; not the quit command, random write? +0156 fe57 cpi 'W' +0158 c28900 jnz notw + ; + ; this is a random write, fill buffer untill cr +015b 114d00 lxi d,datmsg +015e cdda00 call print ;data prompt +0161 0e7f mvi c,127 ;up to 127 characters +0163 218000 lxi h,buff ;destination + rloop: ;read next character to buff +0166 c5 push b ;save counter +0167 e5 push h ;next destination +0168 cdc200 call getchr ;character to a +016b e1 pop h ;restore counter +016c c1 pop b ;restore next to fill +016d fe0d cpi cr ;end of line? +016f ca7800 jz erloop + ; not end, store character +0172 77 mov m,a +0173 23 inx h ;next to fill +0174 0d dcr c ;counter goes down +0175 c26600 jnz rloop ;end of buffer? + erloop: + ; end of read loop, store 00 +0178 3600 mvi m,0 + ; + ; write the record to selected record number +017a 0e22 mvi c,writer +017c 115c00 lxi d,fcb +017c cd0500 call bdos +0182 b7 ora a ;erro code zero? +0183 c2b900 jnz error ;message if not +0186 c33700 jmp ready ;for another record + ; + + + End of Write Command, Process Read + + notw: + ; not a write command, read record? +0189 fe52 cpi 'R' +018b c2b900 jnz error ;skip if not + ; + ; read random record + + + 5-45 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + +018e 0e21 mvi c,readr +0190 115c00 lxi d,fcb +0193 cd0500 call bdos +0196 b7 ora a ;return code 00? +0197 c2b900 jnz error + ; + ; read was successful, write to console +019a cdcf00 call crlf ;new line +019d 0e80 mvi c,128 ;max 128 characters +019f 218000 lxi h,buff ;next to get + wloop: +01a2 7e mov a,m ;next character +01a3 23 inx h ;next to get +01a4 e67f ani 7fh ;mask parity +01a6 ca3700 jz ready ;for another command + ;if 00 +01a9 c5 push b ;save counter +01aa e5 push h ;save next to get +01ab fe20 cpi '' ;graphic? +01ad d4c800 cnc putchr ;skip output if not +01b0 e1 pop h +01b1 c1 pop b +01b2 0d dcr c ;count=count-1 +01b3 c2a200 jnz wloop +01b6 c33700 jmp ready + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-46 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + + End of Read Command, All Errors End Up Here + + ; + error: +01b9 115900 lxi d,errmsg +01bc cdda00 call print +01bf c33700 jmp ready + ; + + + Utility Subroutines for Console I/O + + getchr: + ;read next console character to a +01c2 0e01 mvi c,coninp +01c4 cd0500 call bdos +01c7 c9 ret + ; + putchr: + ;write character from a to console +01c8 0e02 mvi c,conout +01ca 5f mov e,a ;character to send +01cb cd0500 call bdos ;send character +01ce c9 ret + ; + crlf: + ;send carriage return line feed +01cf 3e0d mvi a,cr ;carriage return +01d1 cdc800 call putchr +01d4 3e0a mvi a,lf ;line feed +01d6 cdc800 call putchr +01d9 c9 ret + ; + print: + ;print the buffer addressed by de untill $ +01da d5 push d +01db cdcf00 call crlf +01de d1 pop d ;new line +01df 0e09 mvi c,pstring +01e0 cd0500 call bdos ;print the string +01e4 c9 ret + ; + readcom: + ;read the next command line to the conbuf +01e5 116b00 lxi d,prompt +01e8 cdda00 call print ;command? +01eb 0e0a mvi c,rstring +01ed 117a00 lxi d,conbuf +01f0 cd0500 call bdos ;read command line + ; command line is present, scan it +01f3 210000 lxi h,0 ;start with 0000 +01f6 117c00 lxi d,conlin ;command line +01f9 1a readc: ldax d ;next command + ;character +01fa 13 inx d ;to next command + + + 5-47 + + + + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + + ;position +01fb b7 ora a ;cannot be end of + ;command +01fc c8 rz + ; not zero, numeric? +01fd d630 sui '0' +01ff fe0a cpi 10 ;carry if numeric +0201 d21300 jnc endrd + ; add-in next digit +0204 29 dad h ;*2 +0205 4d mov c,l +0206 44 mov b,h ;bc = value * 2 +0207 29 dad h ;*4 +0208 29 dad h ;*8 +0209 09 dad b ;*2 + *8 = *10 +020a 85 add l ;*digit +020b 6f mov l,a +020c d2f900 jnc readc ;for another char +020f24 inr h ;overflow +0210 c3f900 jmp readc ;for another char + endrd: + ; end of read, restore value in a +0213 c630 adi '0' ;command +0215 fe61 cpi 'a' ;translate case? +0217 d8 rc + ; lower case, mask lower case bits +0218 e65f ani 101$1111b +021a c9 ret + ; + + + String Data Area for Console Messages + + badver: +021b 536f79 db 'sorry, you need cp/m version 2$' + nospace: +023a 4e6f29 db 'no directory space$' + datmsg: +024d 547970 db 'type data: $' + errmsg: +0259 457272 db 'error, try again.$' + prompt: +026b 4e6570 db 'next command? $' + ; + + + Fixed and Variable Data Area + +027a 21 conbuf: db conlen ;length of console buffer +027b consiz: ds 1 ;resulting size after read +027c conlin: ds 32 ;length 32 buffer +0021 = conlen equ $-consiz + ; +029c ds 32 ;16 level stack + stack: +02bc end + + 5-48 + + + + K + + +CP/M Operating System Manual 5.5 Sample Random Access Program + + + + Major improvements could be made to this particular program to +enhance its operation. In fact, with some work, this program could +evolve into a simple data base management system. One could, for +example, assume a standard record size of 128 bytes, consisting to +arbitrary fields within the record. A program, called GETKEY, could +be developed that first reads a sequential file and extracts a +specific field defined by the operator. For example, the command + + GETKEY NAMES.DAT LASTNAME 10 20 + +would cause GETKEY to read the data base file NAMES.DAT and extract +the LAST-NAME field from each record, starting in position 10 and +ending at character 20. GETKEY builds a table in memory consisting +of each particular LASTNAME field, along with its 16-bit record +number location within the file. The GETKEY program then sorts this +list and writes a new file, called LASTNAME.KEY, which is an +alphabetical list of LASTNAME fields with their corresponding record +numbers. This list is called an inverted index in information +retrieval parlance. + + If the programmer were to rename the program shown above as +QUERY and modify it so that it reads a sorted key file into memory, +the command line might appear as + + QUERY NAMES.DAT LASTNAME.KEY + +Instead of reading a number, the QUERY program reads an alphanumeric +string that is a particular key to find in the NAMES.DAT data base. +Because the LASTNAME.KEY list is sorted, one can find a particular +entry rapidly by performing a binary search, similar to looking up a +name in the telephone book. Starting at both ends of the list, one +examines the entry halfway in between and, if not matched, splits +either the upper half or the lower half for the next search. You +will quickly reach the item you are looking for and find the +corresponding record number. You should fetch and display this +record at the console, just as was done in the program shown above. + + With some more work, you can allow a fixed grouping size that +differs from the 128-byte record shown above. This is accomplished +by keeping track of the record number and the byte offset within the +record. Knowing the group size, you randomly access the record +containing the proper group, offset to the beginning of the group +within the record read sequentially until the group size has been +exhausted. + + Finally, you can improve QUERY considerably by allowing boolean +expressions, which compute the set of records that satisfy several +relationships, such as a LASTNAME between HARDY and LAUREL and an +AGE lower than 45. Display all the records that fit this +description. Finally, if your lists are getting too big to fit into +memory, randomly access key files from the disk as well. + + + + + + 5-49 + + + + + +CP/M Operating System Manual 5.6 System Function Summary + + +5.6 System Function Summary + +Function Function Input Output +Number Name + +Decimal Hex + + 0 0 System Reset C = 00H none + 1 1 Console Input C = 01H A = ASCII char + 2 2 Console Output E = char none + 3 3 Reader Input A = ASCII char + 4 4 Punch Output E = char none + 5 5 List Output E = char none + 6 6 Direct Console I/O C = 06H A = char or status + + E = 0FFH (input) or (no value) + 0FEH (status) or + char (output) + 7 7 Get I/O Byte none A = I/O byte + Value + 8 8 Set I/O Byte E = I/O Byte none + 9 9 Print String DE = Buffer Address none +10 A Read Console Buffer DE = Buffer Console + Characters + in Buffer +11 B Get Console Status none A = 00/non zero +12 C Return Version Number none HL: Version + Number +13 D Reset Disk System none none +14 E Select Disk E = Disk Number none +15 F Open File DE = FCB Address FF if not found +16 10 Close File DE = FCB Address FF if not found +17 11 Search For First DE = FCB Address A = Directory + Code +18 12 Search For Next none A = Directory + Code +19 13 Delete File DE = FCB Address A = none +20 14 Read Sequential DE = FCB Address A = Error Code +21 15 Write Sequential DE = FCB Address A = Error Code +22 16 Make File DE = FCB Address A = FF if no DIR + Space +23 17 Rename File DE = FCB Address A = FF in not + found +24 18 Return Login Vector none HL = Login + Vector* +25 19 Return Current Disk none A = Current Disk + Number +26 1A Set DMA Address DE = DMA Address none +27 1B Get ADDR (ALLOC) none HL = ALLOC + Address* +28 1C Write Protect Disk none none +29 1D Get Read/only Vector none HL = R/O + Vector Value* +30 1E Set File Attributes DE = FCB Address A = none +31 1F Get ADDR (Disk Parms) none HL = DPB + + + 5-50 + + + + + +CP/M Operating System Manual 5.6 System Function Summary + + + Address +32 20 Set/Get User Code E = 0FFH for Get User Number + E = 00 to 0FH for Set +33 21 Read Random DE = FCB Address A = Error Code +34 22 Write Random DE = FCB Address A = Error Code +35 23 Compute File Size DE = FCB Address r0, r1, r2 +36 24 Set Random Record DE = FCB Address r0, r1, r2 +37 25 Reset Drive DE = Drive Vector A = 0 +38 26 Access Drive not supported +39 27 Free Drive not supported +40 28 Write Random with Fill DE = FCB A = Error Code + + + + +*Note that A = L, and B = H upon return. + + +End of Section 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5-51 + + + + + + + + +Section 6 + +CP/M 2 Alteration + + + +6.1 Introduction + + The standard CP/M system assumes operation on an Intel Model +800 microcomputer development system , but is designed so you can +alter a specific set of subroutines that define the hardware +operating environment. + + Although standard CP/M 2 is configured for single-density +floppy disks, field-alteration features allow adaptation to a wide +variety of disk subsystems from single-drive minidisks to high- +capacity, hard disk systems. To simplify the following adaptation +process, it is assumed that CP/M 2 is first configured for single- +density floppy disks where minimal editing and debugging tools are +available. If an earlier version of CP/M is available, the +customizing process is eased considerably. In this latter case, you +might want to review the system generation process and skip to later +sections that discuss system alteration for nonstandard disk +systems. + + To achieve device independence, CP/M is separated into three +distinct modules: + + o BIOS is the Basic I/O System, which is environment dependent. + + o BDOS is the Basic Disk Operating System, which is not dependent + upon the hardware configuration. + + o CCP is the Console Command Processor, which uses the BDOS. + + Of these modules, only the BIOS is dependent upon the +particular hardware. You can patch the distribution version of CP/M +to provide a new BIOS that provides a customized interface between +the remaining CP/M modules and the hardware system. This document +provides a step-by-step procedure for patching a new BIOS into CP/M. + + All disk-dependent portions of CP/M 2 are placed into a BIOS, a +resident disk parameter block, which is either hand coded or +produced automatically using the disk definition macro library +provided with CP/M 2. The end user need only specify the maximum +number of active disks, the starting and ending sector numbers, the +data allocation size, the maximum extent of the logical disk, +directory size information, and reserved track values. The macros +use this information to generate the appropriate tables and table +references for use during CP/M 2 operation. Deblocking information +is provided, which aids in assembly or disassembly of sector sizes +that are multiples of the fundamental 128-byte data unit, and the +system alteration manual includes general purpose subroutines that +use the deblocking information to take advantage of larger sector +sizes. Use of these subroutines, together with the table-drive data +access algorithms, makes CP/M 2 a universal data management system. + + + 6-1 + + + + +CP/M Operating System Manual 6.1 Introduction + + + File expansion is achieved by providing up to 512 logical file +extents, where each logical extent contains 16K bytes of data. CP/M +2 is structured, however, so that as much as 128K bytes of data are +addressed by a single physical extent, corresponding to a single +directory entry, maintaining compatibility with previous versions +while taking advantage of directory space. + + If CP/M is being tailored to a computer system for the first +time, the new BIOS requires some simple software development and +testing. The standard BIOS is listed in Appendix A and can be used +as a model for the customized package. A skeletal version of the +BIOS given in Appendix B can serve as the basis for a modified BIOS. + + In addition to the BIOS, you must write a simple memory loader, +called GETSYS, which brings the operating system into memory. To +patch the new BIOS into CP/M, you must write the reverse of GETSYS, +called PUTSYS, which places an altered version of CP/M back onto the +disk. PUTSYS can be derived from GETSYS by changing the disk read +commands into disk write commands. Sample skeletal GETSYS and +PUTSYS programs are described in Section 6.4 and listed in Appendix +C. + + To make the CP/M system load automatically, you must also +supply a cold start loader, similar to the one provided with CP/M, +listed in Appendixes A and D. A skeletal form of a cold start +loader is given in Appendix E, which serves as a model for the +loader. + + +6.2 First-level System Regeneration + + The procedure to patch the CP/M system is given below. Address +references in each step are shown with H denoting the hexadecimal +radix, and are given for a 20K CP/M system. For larger CP/M +systems, a bias is added to each address that is shown with a +b +following it, where b is equal to the memory size-20K. Values for b +in various standard memory sizes are listed in Table 6-1. + + + Table 6-1. Standard Memory Size Values + + Memory Size Value + + 24K: b = 24K - 20K = 4K = 1000H + + 32K: b = 32K - 20K = 12K = 3000H + + 40K: b = 40K - 20K = 20K = 5000H + + 48K: b = 48K - 20K = 28K = 7000H + + 56K: b = 56K - 20K = 36K = 9000H + + 62K: b = 62K - 20K = 42K = A800H + + 64K: b = 64K - 20K = 44K = B000H + + + 6-2 + + + + +CP/M Operating System Manual 6.2 First-level Regeneration + + + Note that the standard distribution version of CP/M is set for +operation within a 20K CP/M system. Therefore, you must first bring +up the 20K CP/M system, then configure it for actual memory size +(see Section 6.3). + + Follow these steps to patch your CP/M system: + + + 1) Read Section 6.4 and write a GETSYS program that reads the + first two tracks of a disk into memory. The program from + the disk must be loaded starting at location 3380H. GETSYS + is coded to start at location 100H (base of the TPA) as + shown in Appendix C. + + 2) Test the GETSYS program by reading a blank disk into memory, + and check to see that the data has been read properly and + that the disk has not been altered in any way by the GETSYS + program. + + 3) Run the GETSYS program using an initialized CP/M disk to see + if GETSYS loads CP/M starting at 3380H (the operating + system actually starts 128 bytes later at 3400H). + + 4) Read Section 6.4 and write the PUTSYS program. This writes + memory starting at 3380H back onto the first two tracks of + the disk. The PUTSYS program should be located at 200H, as + shown in Appendix C. + + 5) Test the PUTSYS program using a blank, uninitialized disk by + writing a portion of memory to the first two tracks; clear + memory and read it back using GETSYS. Test PUTSYS + completely, because this program will be used to alter CP/M + on disk. + + 6) Study Sections 6.5, 6.6, and 6.7 along with the distribution + version of the BIOS given in Appendix A and write a simple + version that performs a similar function for the customized + environment. Use the program given in Appendix B as a + model. Call this new BIOS by name CBIOS (customized BIOS). + Implement only the primitive disk operations on a single + drive and simple console input/output functions in this + phase. + + 7) Test CBIOS completely to ensure that it properly performs + console character I/O and disk reads and writes. Be + careful to ensure that no disk write operations occur + during read operations and check that the proper track and + sectors are addressed on all reads and writes. Failure to + make these checks might cause destruction of the + initialized CP/M system after it is patched. + + 8) Referring to Table 6-3 in Section 6.5, note that the BIOS is + placed between locations 4A00H and 4FFFH. Read the CP/M + system using GETSYS and replace the BIOS segment by the + CBIOS developed in step 6 and tested in step 7. This + replacement is done in memory. + + + 6-3 + + + + +CP/M Operating System Manual 6.2 First-level Regeneration + + + 9) Use PUTSYS to place the patched memory image of CP/M onto + the first two tracks of a blank disk for testing. + + 10) Use GETSYS to bring the copied memory image from the test + disk back into memory at 3380H and check to ensure that it + has loaded back properly (clear memory, if possible, before + the load). Upon successful load, branch to the cold start + code at location 4A00H. The cold start routine initializes + page zero, then jumps to the CCP at location 3400H, which + calls the BDOS, which calls the CBIOS. The CCP asks the + CBIOS to read sixteen sectors on track 2, and CP/M types + A>, the system prompt. + + If difficulties are encountered, use whatever debug + facilities are available to trace and breakpoint the CBIOS. + + 11) Upon completion of step 10, CP/M has prompted the console + for a command input. To test the disk write operation, + type + + SAVE 1 X.COM + + All commands must be followed by a carriage return. CP/M + responds with another prompt after several disk accesses: + + A> + + If it does not, debug the disk write functions and retry. + + 12) Test the directory command by typing + + DIR + + CP/M responds with + + A:X COM + + 13) Test the erase command by typing + + ERA X.COM + + CP/M responds with the A prompt. This is now an + operational system that only requires a bootstrap loader to + function completely. + + 14) Write a bootstrap loader that is similar to GETSYS and place + it on track 0, sector 1, using PUTSYS (again using the test + disk, not the distribution disk). See Sections 6.5 and 6.8 + for more information on the bootstrap operation. + + 15) Retest the new test disk with the bootstrap loader installed + by executing steps 11, 12, and 13. Upon completion of + these tests, type a CTRL-C. The system executes a warm + start, which reboots the system, and types the A prompt. + + + + 6-4 + + + + + +CP/M Operating System Manual 6.2 First-level Regeneration + + + 16) At this point, there is probably a good version of the + customized CP/M system on the test disk. Use GETSYS to + load CP/M from the test disk. Remove the test disk, place + the distribution disk, or a legal copy, into the drive, and + use PUTSYS to replace the distribution version with the + customized version. Do not make this replacement if you + are unsure of the patch because this step destroys the + system that was obtained from Digital Research. + + 17) Load the modified CP/M system and test it by typing + + DIR + + CP/M responds with a list of files that are provided on the + initialized disk. The file DDT.COM is the memory image for + the debugger. Note that from now on, you must always + reboot the CP/M system (CTRL-C is sufficient) when the disk + is removed and replaced by another disk, unless the new + disk is to be Read-Only. + + 18) Load and test the debugger by typing + + DDT + + See Chapter 4 for operating procedures. + + 19) Before making further CBIOS modifications, practice using + the editor (see Chapter 2), and assembler (see Chapter 3). + Recode and test the GETSYS, PUTSYS, and CBIOS programs + using ED, ASM, and DDT. Code and test a COPY program that + does a sector-to-sector copy from one disk to another to + obtain back-up copies of the original disk. Read the CP/M + Licensing Agreement specifying legal responsibilities when + copying the CP/M system. Place the following copyright + notice: + + Copyright (c), 1983 + Digital Research + + on each copy that is made with the COPY program. + + 20) Modify the CBIOS to include the extra functions for punches, + readers, and sign-on messages, and add the facilities for + additional disk drives, if desired. These changes can be + made with the GETSYS and PUTSYS programs or by referring to + the regeneration process in Section 6.3. + + + You should now have a good copy of the customized CP/M system. +Although the CBIOS portion of CP/M belongs to the user, the modified +version cannot be legally copied. + + It should be noted that the system remains file-compatible with +all other CP/M systems (assuming media compatibility) which allows +transfer of nonproprietary software between CP/M users. + + + 6-5 + + + + + +CP/M Operating System Manual 6.3 Second-level System Generation + + +6.3 Second-level System Generation + + Once the system is running, the next step is to configure CP/M +for the desired memory size. Usually, a memory image is first +produced with the MOVCPM program (system relocator) and then placed +into a named disk file. The disk file can then be loaded, examined, +patched, and replaced using the debugger and the system generation +program (refer to Chapter 1). + + The CBIOS and BOOT are modified using ED and assembled using +ASM, producing files called CBIOS.HEX and BOOT.HEX, which contain +the code for CBIOS and BOOT in Intel hex format. + + To get the memory image of CP/M into the TPA configured for the +desired memory size, type the command: + + MOVCPM xx* + +where xx is the memory size in decimal K bytes, for example, 32 for +32K. The response is as follows: + + CONSTRUCTING xxK CP/M VERS 2.0 + + READY FOR "SYSGEN" OR + + "SAVE 34 CPMxx.COM" + + An image of CP/M in the TPA is configured for the requested +memory size. The memory image is at location 0900H through 227FH, +that is, the BOOT is at 0900H, the CCP is at 980H, the BDOS starts +at 1180H, and the BIOS is at 1F80H. Note that the memory image has +the standard Model 800 BIOS and BOOT on it. It is now necessary to +save the memory image in a file so that you can patch the CBIOS and +CBOOT into it: + + SAVE 34 CPMxx.COM + + The memory image created by the MOVCPM program is offset by a +negative bias so that it loads into the free area of the TPA, and +thus does not interfere with the operation of CP/M in higher memory. +This memory image can be subsequently loaded under DDT and examined +or changed in preparation for a new generation of the system. DDT +is loaded with the memory image by typing: + + DDT CPMxx.COM Loads DDT, then reads the CP/M image. + +DDT should respond with the following: + + NEXT PC + 2300 0100 + - The DDT prompt + +You can then give the display and disassembly commands to examine +portions of the memory image between 900H and 227FH. Note, however, +that to find any particular address within the memory image, you + + + 6-6 + + + + + +CP/M Operating System Manual 6.3 Second-level System Generation + + +must apply the negative bias to the CP/M address to find the actual +address. Track 00, sector 01, is loaded to location 900H (the user +should find the cold start loader at 900H to 97FH); track 00, sector +02, is loaded into 980H (this is the base of the CCP); and so on +through the entire CP/M system load. In a 20K system, for example, +the CCP resides at the CP/M address 3400H, but is placed into memory +at 980H by the SYSGEN program. Thus, the negative bias, denoted by +n, satisfies + + 3400H + n = 980H, or n =980H - 3400H + +Assuming two's complement arithmetic, n = D580H, which can be +checked by + + 3400H + D580H = 10980H = 0980H (ignoring high-order + overflow). + + Note that for larger systems, n satisfies + + (3400H+b) + n = 980H, or + n = 980H - (3400H + b), or + n = D580H - b + +The value of n for common CP/M systems is given below. + + + Table 6-2. Common Values for CP/M Systems + + Memory Size BIAS b Negative Offset n + + 20K 0000H D580H - 0000H = D580H + 24K 1000H D580H - 1000H = C580H + 32K 3000H D580H - 3000H = A580H + 40K 5000H D580H - 5000H = 8580H + 48K 7000H D580H - 7000H = 6580H + 56K 9000H D580H - 9000H = 4580H + 62K A800H D580H - A800H = 2D80H + 64K B000H D580H - B000H = 2580H + + + If you want to locate the address x within the memory image +loaded under DDT in a 20K system, first type + + Hx,n Hexadecimal sum and difference + +and DDT responds with the value of x+n (sum) and x-n (difference). +The first number printed by DDT is the actual memory address in the +image where the data or code is located. For example, the following +DDT command: + + H3400,D580 + +produces 980H as the sum, which is where the CCP is located in the +memory image under DDT. + + + + 6-7 + + + + + +CP/M Operating System Manual 6.3 Second-level System Generation + + + Type the L command to disassemble portions of the BIOS located +at (4A00H+b)-n, which, when one uses the H command, produces an +actual address of 1F80H. The disassembly command would thus be as +follows: + + L1F80 + +It is now necessary to patch in the CBOOT and CBIOS routines. The +BOOT resides at location 0900H in the memory image. If the actual +load address is n, then to calculate the bias (m), type the command: + + H900,n Subtract load address from target address. + + The second number typed by DDT in response to the command is +the desired bias (m). For example, if the BOOT executes at 0080H, +the command + + H900,80 + +produces + + 0980 0880 Sum and difference in hex. + +Therefore, the bias m would be 0880H. To read-in the BOOT, give the +command: + + ICBOOT.HEX Input file CBOOT.HEX + +Then + + Rm Read CBOOT with a bias of m (=900H-n). + +Examine the CBOOT with + + L900 + +You are now ready to replace the CBIOS by examining the area at +1F80H, where the original version of the CBIOS resides, and then +typing + + ICBIOS.HEX Ready the hex file for loading. + + Assume that the CBIOS is being integrated into a 20K CP/M +system and thus originates at location 4A00H. To locate the CBIOS +properly in the memory image under DDT, you must apply the negative +bias n for a 20K system when loading the hex file. This is +accomplished by typing + + RD580 Read the file with bias D580H. + +Upon completion of the read, reexamine the area where the CBIOS has +been loaded (use an L1F80 command) to ensure that it is properly +loaded. When you are satisfied that the change has been made, +return from DDT using a CTRL-C or, G0 command. + + + + 6-8 + + + + + +CP/M Operating System Manual 6.3 Second-level System Generation + + + SYSGEN is used to replace the patched memory image back onto a +disk (you use a test disk until sure of the patch) as shown in the +following interaction: + + + SYSGEN Start the SYSGEN program. + + SYSGEN VERSION 2.0 Sign-on message from SYSGEN. + + SOURCE DRIVE NAME Respond with a carriage return + (OR RETURN TO SKIP) to skip the CP/M read operation + because the system is already + in memory. + + DESTINATION DRIVE NAME Respond with B to write the new + (OR RETURN TO REBOOT) system to the disk in drive B. + + + DESTINATION ON B, Place a scratch disk in drive + THEN TYPE RETURN B, then press RETURN. + + FUNCTION COMPLETE + DESTINATION DRIVE NAME + (OR RETURN TO REBOOT) + + + Place the scratch disk in drive A, then perform a cold start to +bring up the newly-configured CP/M system. + + The new CP/M system is then tested and the Digital Research +copyright notice is placed on the disk, as specified in the +Licensing Agreement: + + Copyright (c), 1979 + Digital Research + + +6.4 Sample GETSYS and PUTSYS Programs + + The following program provides a framework for the GETSYS and +PUTSYS programs referenced in Sections 6.1 and 6.2. To read and +write the specific sectors, you must insert the READSEC and WRITESEC +subroutines. + + + + + + + + + + + + + + + 6-9 + + + + + +CP/M Operating System Manual 6.4 Sample GETSYS and PUTSYS + + +; GETSYS PROGRAM -- READ TRACKS 0 AND 1 TO MEMORY AT 3380H +; REGISTER USE + +; A (SCRATCH REGISTER) + +; B TRACK COUNT (0, 1) + +; C SECTOR COUNT (1,2,...,26) + +; DE (SCRATCH REGISTER PAIR) + +; HL LOAD ADDRESS + +; SP SET TO STACK ADDRESS + +; +START: LXI SP,3380H ;SET STACK POINTER TO SCRATCH + ;AREA + LXI H,3380H ;SET BASE LOAD ADDRESS + MVI B,0 ;START WITH TRACK 0 +RDTRK: ;READ NEXT TRACK (INITIALLY 0) + MVI C,1 ;READ STARTING WITH SECTOR 1 + +RDSEC: ;READ NEXT SECTOR + CALL READSEC ;USER-SUPPLIED SUBROUTINE + LXI D,128 ;MOVE LOAD ADDRESS TO NEXT 1/2 + ;PAGE + DAD D ;HL = HL + 128 + INR C ;SECTOR = SECTOR + 1 + MOV A,C ;CHECK FOR END OF TRACK + CPI 27 + JC RDSEC ;CARRY GENERATED IF SECTOR <27 + +; +; ARRIVE HERE AT END OF TRACK, MOVE TO NEXT TRACK + INR B + MOV A,B ;TEST FOR LAST TRACK + CPI 2 + JC RDTRK ;CARRY GENERATED IF TRACK <2 + +; +; USER-SUPPLIED SUBROUTINE TO READ THE DISK +READSEC: +; ENTER WITH TRACK NUMBER IN REGISTER B, + SECTOR NUMBER IN REGISTER C, AND + +; ADDRESS TO FILL IN HL + +; + PUSH B ;SAVE B AND C REGISTERS + PUSH H ;SAVE HL REGISTERS + + + Listing 6-1. GETSYS Program + + + + 6-10 + + + + + +CP/M Operating System Manual 6.4 Sample GETSYS and PUTSYS + + + ................................................. + perform disk read at this point, branch to + label START if an error occurs + ................................................. + POP H ;RECOVER HL + POP B ;RECOVER B AND C REGISTERS + RET ;BACK TO MAIN PROGRAM + + END START + + + Listing 6-1. (continued) + + + + This program is assembled and listed in Appendix B for +reference purposes, with an assumed origin of 100H. The hexadecimal +operation codes that are listed on the left might be useful if the +program has to be entered through the panel switches. + + The PUTSYS program can be constructed from GETSYS by changing +only a few operations in the GETSYS program given above, as shown in +Appendix C. The register pair HL becomes the dump address, next +address to write, and operations on these registers do not change +within the program. The READSEC subroutine is replaced by a +WRITESEC subroutine, which performs the opposite function; data from +address HL is written to the track given by register B and sector +given by register C. It is often useful to combine GETSYS and +PUTSYS into a single program during the test and development phase, +as shown in Appendix C. + + +6.5 Disk Organization + + The sector allocation for the standard distribution version of +CP/M is given here for reference purposes. The first sector +contains an optional software boot section (see the table on the +following page. Disk controllers are often set up to bring track +0, sector 1, into memory at a specific location, often location +0000H. The program in this sector, called BOOT, has the +responsibility of bringing the remaining sectors into memory +starting at location 3400H+b. If the controller does not have a +built-in sector load, the program in track 0, sector 1 can be +ignored. In this case, load the program from track 0, sector 2, to +location 3400H+b. + + As an example, the Intel Model 800 hardware cold start loader +brings track 0, sector 1, into absolute address 3000H. Upon loading +this sector, control transfers to location 3000H, where the +bootstrap operation commences by loading the remainder of track 0 +and all of track 1 into memory, starting at 3400H+b. Note that this +bootstrap loader is of little use in a non-microcomputer development +system environment, although it is useful to examine it because some +of the boot actions will have to be duplicated in the user's cold +start loader. + + + 6-11 + + + + + +CP/M Operating System Manual 6.5 Disk Organization + + + Table 6-3. CP/M Disk Sector Allocation + +Track # Sector Page# Memory Address CP/M Module name + + 00 01 (boot address) Cold Start Loader + 00 02 00 3400H+b CCP + ' 03 ' 3480H+b ' + ' 04 01 3500H+b ' + ' 05 ' 3580H+b ' + ' 06 02 3600H+b ' + ' 07 ' 3680H+b ' + ' 08 03 3700H+b ' + ' 09 ' 3780H+b ' + ' 10 04 3800H+b ' + ' 11 ' 3880H+b ' + ' 12 05 3900H+b ' + ' 13 ' 3980H+b ' + ' 14 06 3A00H+b ' + ' 15 ' 3A80H+b ' + ' 16 07 3B00H+b ' + 00 17 ' 3B80H+b CCP + 00 18 08 3C00H+b BDOS + ' 19 ' 3C80H+b ' + ' 20 09 3D00H+b ' + ' 21 ' 3D80H+b ' + ' 22 10 3E00H+b ' + ' 23 ' 3E80H+b ' + ' 24 11 3F00H+b ' + ' 25 ' 3F80H+b ' + ' 26 12 4000H+b ' + 01 01 ' 4080H+b ' + ' 02 13 4100H+b ' + ' 03 ' 4180H+B ' + ' 04 14 4200H+b ' + ' 05 ' 4280H+b ' + ' 06 15 4300H+b ' + ' 07 ' 4380H+b ' + ' 08 16 4400H+b ' + ' 09 ' 4480H+b ' + ' 10 17 4500H+b ' + ' 11 ' 4580H+b ' + ' 12 18 4600H+b ' + ' 13 ' 4680H+b ' + ' 14 19 4700H+b ' + ' 15 ' 4780H+b ' + ' 16 20 4800H+b ' + ' 17 ' 4880H+b ' + ' 18 21 4900H+b ' + 01 19 ' 4900H+b BDOS + 07 20 22 4A00H+b BIOS + ' 21 ' 4A80H+b ' + ' 22 23 4B00H+b ' + ' 23 ' 4B80H+b ' + ' 24 24 4C00H+b ' + 01 25 ' 4C80H+b BIOS + 01 26 25 4D00H+b BIOS +02-76 01-26 (directory and data) + + 6-12 + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + +6.6 The BIOS Entry Points + + The entry points into the BIOS from the cold start loader and +BDOS are detailed below. Entry to the BIOS is through a jump vector +located at 4A00H+b, as shown below. See Appendixes A and B. The +jump vector is a sequence of 17 jump instructions that send program +control to the individual BIOS subroutines. The BIOS subroutines +might be empty for certain functions (they might contain a single +RET operation) during reconfiguration of CP/M, but the entries must +be present in the jump vector. + + The jump vector at 4A00H+b takes the form shown below, where +the individual jump addresses are given to the left: + + + 4A00H+b JMP BOOT ;ARRIVE HERE FROM COLD + START LOAD + + 4A03H+b JMP WBOOT ;ARRIVE HERE FOR WARM START + + 4A06H+b JMP CONST ;CHECK FOR CONSOLE CHAR + READY + + 4A09H+b JMP CONIN ;READ CONSOLE CHARACTER IN + + 4A0CH+b JMP CONOUT ;WRITE CONSOLE CHARACTER + OUT + + 4A0FH+b JMP LIST ;WRITE LISTING CHARACTER OUT + + 4A12H+b JMP PUNCH ;WRITE CHARACTER TO PUNCH + DEVICE + + 4A15H+b JMP READER ;READ READER DEVICE + + 4A18H+b JMP HOME ;MOVE TO TRACK 00 ON + SELECTED DISK + + 4A1BH+b JMP SELDSK ;SELECT DISK DRIVE + + 4A1EH+b JMP SETTRK ;SET TRACK NUMBER + + 4A21H+b JMP SETSEC ;SET SECTOR NUMBER + + 4A24H+b JMP SETDMA ;SET DMA ADDRESS + + 4A27H+b JMP READ ;READ SELECTED SECTOR + + 4A2AH+b JMP WRITE ;WRITE SELECTED SECTOR + + 4A2DH+b JMP LISTST ;RETURN LIST STATUS + + 4A30H+b JMP SECTRAN ;SECTOR TRANSLATE + SUBROUTINE + + + Listing 6-2. BIOS Entry Points + + 6-13 + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + + Each jump address corresponds to a particular subroutine that +performs the specific function, as outlined below. There are three +major divisions in the jump table: the system reinitialization, +which results from calls on BOOT and WBOOT; simple character I/O, +performed by calls on CONST, CONIN, CONOUT, LIST, PUNCH, READER, and +LISTST; and disk I/O, performed by calls on HOME, SELDSK, SETTRK, +SETSEC, SETDMA, READ, WRITE, and SECTRAN. + + All simple character I/O operations are assumed to be performed +in ASCII, upper- and lower-case, with high-order (parity bit) set to +zero. An end-of-file condition for an input device is given by an +ASCII CTRL-Z (1AH). Peripheral devices are seen by CP/M as logical +devices and are assigned to physical devices within the BIOS. + + To operate, the BDOS needs only the CONST, CONIN, and CONOUT +subroutines. LIST, PUNCH, and READER can be used by PIP, but not +the BDOS. Further, the LISTST entry is currently used only by +DESPOOL, the print spooling utility. Thus, the initial version of +CBIOS can have empty subroutines for the remaining ASCII devices. + + The following list describes the characteristics of each +device. + + + o CONSOLE is the principal interactive console that communicates + with the operator and it is accessed through CONST, CONIN, and + CONOUT. Typically, the CONSOLE is a device such as a CRT or + teletype. + + o LIST is the principal listing device. If it exists on the + user's system, it is usually a hard-copy device, such as a + printer or teletype. + + o PUNCH is the principal tape punching device. If it exists, it + is normally a high-speed paper tape punch or teletype. + + o READER is the principal tape reading device, such as a simple + optical reader or teletype. + + + A single peripheral can be assigned as the LIST, PUNCH, and +READER device simultaneously. If no peripheral device is assigned +as the LIST, PUNCH, or READER device, the CBIOS gives an appropriate +error message so that the system does not hang if the device is +accessed by PIP or some other user program. Alternately, the PUNCH +and LIST routines can just simply return, and the READER routine can +return with a 1AH (CTRL-Z) in register A to indicate immediate end- +of-file. + + For added flexibility, you can optionally implement the IOBYTE +function, which allows reassignment of physical devices. The IOBYTE +function creates a mapping of logical-to-physical devices that can +be altered during CP/M processing, see the STAT command in Section +1.6.1. + + + + + 6-14 + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + The definition of the IOBYTE function corresponds to the Intel +standard as follows: a single location in memory, currently +location 0003H, is maintained, called IOBYTE, which defines the +logical-to-physical device mapping that is in effect at a particular +time. The mapping is performed by splitting the IOBYTE into four +distinct fields of two bits each, called the CONSOLE, READER, PUNCH, +and LIST fields, as shown in the following figure. + + + most significant least significant + + IOBYTE AT 003H LIST PUNCH READER CONSOLE + + bits 6,7 bits 4,5 bits 2,3 bits 0,1 + + + Figure 6-1. IOBYTE Fields + + + + The value in each field can be in the range 0-3, defining the +assigned source or destination of each logical device. Table 6-4 +gives the values that can be assigned to each field. + + + Table 6-4. IOBYTE Field Values + + Value Meaning + + CONSOLE field (bits 0,1) + + 0 console is assigned to the console printer + device (TTY:) + 1 console is assigned to the CRT device (CRT:) + 2 batch mode: use the READER as the CONSOLE input, + and the LIST device as the CONSOLE output (BAT:) + 3 user-defined console device (UC1:) + + READER field (bits 2,3) + + 0 READER is the teletype device (TTY:) + 1 READER is the high speed reader device (PTR:) + 2 user-defined reader #1 (UR1:) + 3 user-defined reader #2 (UR2:) + + PUNCH field (bits 4,5) + + 0 PUNCH is the teletype device (TTY:) + 1 PUNCH is the high speed punch device (PTP:) + 2 user-defined punch #1 (UP1:) + 3 user-defined punch #2 (UP2:) + + LIST field (bits 6,7) + + 0 LIST is the teletype device (TTY:) + 1 LIST is the CRT device (CRT:) + 2 LIST is the line printer device (LPT:) + 3 user-defined list device (UL1:) + + 6-15 + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + + The implementation of the IOBYTE is optional and effects only +the organization of the CBIOS. No CP/M systems use the IOBYTE +(although they tolerate the existence of the IOBYTE at location +0003H) except for PIP, which allows access to the physical devices, +and STAT, which allows logical-physical assignments to be make or +displayed. For more information see Section 1. In any case the +IOBYTE implementation should be omitted until the basic CBIOS is +fully implemented and tested; then you should add the IOBYTE to +increase the facilities. + + Disk I/O is always performed through a sequence of calls on the +various disk access subroutines that set up the disk number to +access, the track and sector on a particular disk, and the Direct +Memory Access (DMA) address involved in the I/O operation. After +all these parameters have been set up, a call is made to the READ or +WRITE function to perform the actual I/O operation. + + There is often a single call to SELDSK to select a disk drive, +followed by a number of read or write operations to the selected +disk before selecting another drive for subsequent operations. +Similarly, there might be a single call to set the DMA address, +followed by several calls that read or write from the selected DMA +address before the DMA address is changed. The track and sector +subroutines are always called before the READ or WRITE operations +are performed. + + The READ and WRITE routines should perform several retries (10 +is standard) before reporting the error condition to the BDOS. If +the error condition is returned to the BDOS, it reports the error to +the user. The HOME subroutine might or might not actually perform +the track 00 seek, depending upon controller characteristics; the +important point is that track 00 has been selected for the next +operation and is often treated in exactly the same manner as SETTRK +with a parameter of 00. + + The following table describes the exact responsibilities of +each BIOS entry point subroutine. + + + Table 6-5. BIOS Entry Points + + Entry Point Function + + F + BOOT The BOOT entry point gets control from the cold + start loader and is responsible for basic + system initialization, including sending a + sign-on message, which can be omitted in the + first version. If the IOBYTE function is + implemented, it must be set at this point. The + various system parameters that are set by the + WBOOT entry point must be initialized, and + control is transferred to the CCP at 3400+b for + further processing. Note that register C must + be set to zero to select drive A. + + + + 6-16 + + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + + Table 6-5. (continued) + + Entry Point Function + + WBOOT The WBOOT entry point gets control when a warm + start occurs. A warm start is performed + whenever a user program branches to location + 0000H, or when the CPU is reset from the front + panel. The CP/M system must be loaded from the + first two tracks of drive A up to, but not + including, the BIOS, or CBIOS, if the user has + completed the patch. System parameters must be + initialized as follows: + + location 0,1,2 Set to JMP WBOOT for warm + starts (000H: JMP 4A03H+b) + + location 3 Set initial value of IOBYTE, + if implemented in the CBIOS + + location 4 High nibble = current user no; + low nibble = current drive + + location 5,6,7 Set to JMP BDOS, which is the + primary entry point to CP/M + for transient programs. + (0005H: JMP 3C06H+b) + + Refer to Section 6.9 for complete details of + page zero use. Upon completion of the + initialization, the WBOOT program must branch + to the CCP at 3400H+b to restart the system. + Upon entry to the CCP, register C is set to the + drive to select after system initialization. + The WBOOT routine should read location 4 in + memory, verify that is a legal drive, and pass + it to the CCP in register C. + + CONST You should sample the status of the currently + assigned console device and return 0FFH in + register A if a character is ready to read and + 00H in register A if no console characters are + ready. + + CONIN The next console character is read into + register A, and the parity bit is set, high- + order bit, to zero. If no console character is + ready, wait until a character is typed before + returning. + + + + + + + + + 6-17 + + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + + Table 6-5. (continued) + + Entry Point Function + + CONOUT The character is sent from register C to the + console output device. The character is in + ASCII, with high-order parity bit set to zero. + You might want to include a time-out on a line- + feed or carriage return, if the console device + requires some time interval at the end of the + line (such as a TI Silent 700 terminal). You + can filter out control characters that cause + the console device to react in a strange way + (CTRL-Z causes the Lear-Seigler terminal to + clear the screen, for example). + + LIST The character is sent from register C to the + currently assigned listing device. The + character is in ASCII with zero parity bit. + + PUNCH The character is sent from register C to the + currently assigned punch device. The character + is in ASCII with zero parity. + + READER The next character is read from the currently + assigned reader device into register A with + zero parity (high-order bit must be zero); an + end-of-file condition is reported by returning + an ASCII CTRL-Z(1AH). + + HOME The disk head of the currently selected disk + (initially disk A) is moved to the track 00 + position. If the controller allows access to + the track 0 flag from the drive, the head is + stepped until the track 0 flag is detected. If + the controller does not support this feature, + the HOME call is translated into a call to + SETTRK with a parameter of 0. + + SELDSK The disk drive given by register C is selected + for further operations, where register C + contains 0 for drive A, 1 for drive B, and so + on up to 15 for drive P (the standard CP/M + distribution version supports four drives). On + each disk select, SELDSK must return in HL the + base address of a 16-byte area, called the Disk + Parameter Header, described in Section 6.10. + For standard floppy disk drives, the contents + of the header and associated tables do not + change; thus, the program segment included in + the sample CBIOS performs this operation + automatically. + + + + + + 6-18 + + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + + Table 6-5. (continued) + + Entry Point Function + + If there is an attempt to select a nonexistent + drive, SELDSK returns HL=0000H as an error + indicator. Although SELDSK must return the + header address on each call, it is advisable to + postpone the physical disk select operation + until an I/O function (seek, read, or write) is + actually performed, because disk selects often + occur without utimately performing any disk + I/O, and many controllers unload the head of + the current disk before selecting the new + drive. This causes an excessive amount of + noise and disk wear. The least significant bit + of register E is zero if this is the first + occurrence of the drive select since the last + cold or warm start. + + SETTRK Register BC contains the track number for + subsequent disk accesses on the currently + selected drive. The sector number in BC is the + same as the number returned from the SECTRAN + entry point. You can choose to seek the + selected track at this time or delay the seek + until the next read or write actually occurs. + Register BC can take on values in the range 0- + 76 corresponding to valid track numbers for + standard floppy disk drives and 0-65535 for + nonstandard disk subsystems. + + SETSEC Register BC contains the sector number, 1 + through 26, for subsequent disk accesses on the + currently selected drive. The sector number in + BC is the same as the number returned from the + SECTRAN entry point. You can choose to send + this information to the controller at this + point or delay sector selection until a read or + write operation occurs. + + SETDMA Register BC contains the DMA (Disk Memory + Access) address for subsequent read or write + operations. For example, if B = 00H and C = + 80H when SETDMA is called, all subsequent read + operations read their data into 80H through + 0FFH and all subsequent write operations get + their data from 80H through 0FFH, until the + next call to SETDMA occurs. The initial DMA + address is assumed to be 80H. The controller + need not actually support Direct Memory Access. + If, for example, all data transfers are through + I/O ports, the CBIOS that is constructed uses + the 128-byte area starting at the selected DMA + address for the memory buffer during the + subsequent read or write operations. + + + 6-19 + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + + Table 6-5. (continued) + + Entry Point Function + + READ Assuming the drive has been selected, the track + has been set, and the DMA address has been + specified, the READ subroutine attempts to read + one sector based upon these parameters and + returns the following error codes in register + A: + + 0 no errors occurred + + 1 nonrecoverable error condition occurred + + Currently, CP/M responds only to a zero or + nonzero value as the return code. That is, if + the value in register A is 0, CP/M assumes that + the disk operation was completed properly. IF + an error occurs the CBIOS should attempt at + least 10 retries to see if the error is + recoverable. When an error is reported the + BDOS prints the message BDOS ERR ONx: BAD + SECTOR. The operator then has the option of + pressing a carriage return to ignore the error, + or CTRL-C to abort. + + WRITE Data is written from the currently selected DMA + address to the currently selected drive, track, + and sector. For floppy disks, the data should + be marked as nondeleted data to maintain + compatibility with other CP/M systems. The + error codes given in the READ command are + returned in register A, with error recovery + attempts as described above. + + LISTST You return the ready status of the list device + used by the DESPOOL program to improve console + response during its operation. The value 00 is + returned in A if the list device is not ready + to accept a character and 0FFH if a character + can be sent to the printer. A 00 value should + be returned if LIST status is not implemented. + + + + + + + + + + + + + + + 6-20 + + + + + +CP/M Operating System Manual 6.6 BIOS Entry Points + + + Table 6-5. (continued) + + Entry Point Function + + SECTRAN Logical-to-physical sector translation is + performed to improve the overall response of + CP/M. Standard CP/M systems are shipped with a + skew factor of 6, where six physical sectors + are skipped between each logical read + operation. This skew factor allows enough time + between sectors for most programs to load their + buffers without missing the next sector. In + particular computer systems that use fast + processors, memory, and disk subsystems, the + skew factor might be changed to improve overall + response. However, the user should maintain a + single-density IBM-compatible version of CP/M + for information transfer into and out of the + computer system, using a skew factor of 6. + + In general, SECTRAN receives a logical sector + number relative to zero in BC and a translate + table address in DE. The sector number is used + as an index into the translate table, with the + resulting physical sector number in HL. For + standard systems, the table and indexing code + is provided in the CBIOS and need not be + changed. + K + + +6.7 A Sample BIOS + + The program shown in Appendix B can serve as a basis for your +first BIOS. The simplest functions are assumed in this BIOS, so +that you can enter it through a front panel, if absolutely +necessary. You must alter and insert code into the subroutines for +CONST, CONIN, CONOUT, READ, WRITE, and WAITIO subroutines. Storage +is reserved for user-supplied code in these regions. The scratch +area reserved in page zero (see Section 6.9) for the BIOS is used in +this program, so that it could be implemented in ROM, if desired. + + Once operational, this skeletal version can be enhanced to +print the initial sign-on message and perform better error recovery. +The subroutines for LIST, PUNCH, and READER can be filled out and +the IOBYTE function can be implemented. + + +6.8 A Sample Cold Start Loader + + The program shown in Appendix E can serve as a basis for a cold +start loader. The disk read function must be supplied by the user, +and the program must be loaded somehow starting at location 0000. +Space is reserved for the patch code so that the total amount of +storage required for the cold start loader is 128 bytes. + + + + 6-21 + + + + + +CP/M Operating System Manual 6.8 A Sample Cold Start Loader + + + Eventually, you might want to get this loader onto the first +disk sector (track 0, sector 1) and cause the controller to load it +into memory automatically upon system start up. Alternatively, the +cold start loader can be placed into ROM, and above the CP/M system. +In this case, it is necessary to originate the program at a higher +address and key in a jump instruction at system start up that +branches to the loader. Subsequent warm starts do not require this +key-in operation, because the entry point WBOOT gets control, thus +bringing the system in from disk automatically. The skeletal cold +start loader has minimal error recovery, which might be enhanced in +later versions. + + +6.9 Reserved Locations in Page Zero + + Main memory page zero, between locations 00H and 0FFH, contains +several segments of code and data that are used during CP/M +processing. The code and data areas are given in the following +table. + + + Table 6-6. Reserved Locations in Page Zero + + Locations Contents + + F + 000H-0002H Contains a jump instruction to the warm + start entry location 4A03H+b. This + allows a simple programmed restart (JMP + 0000H) or manual restart from the front + panel. + + 0003H-0003H Contains the Intel standard IOBYTE is + optionally included in the user's CBIOS + (refer to Section 6.6). + + 0004H-0004H Current default drive number + (0=A,...,15=P). + + 0005H-0007H Contains a jump instruction to the BDOS + and serves two purposes: JMP 0005H + provides the primary entry point to the + BDOS, as described in Chapter 5, and + LHLD 0006H brings the address field of + the instruction to the HL register + pair. This value is the lowest address + in memory used by CP/M, assuming the + CCP is being overlaid. The DDT program + changes the address field to reflect + the reduced memory size in debug mode. + + 0008H-0027H Interrupt locations 1 through 5 not + used. + + 0030H-0037H Interrupt location 6 (not currently + used) is reserved. + + + 6-22 + + + + + +CP/M Operating System Manual 6.9 Reserved Locations in Page Zero + + + Table 6-6. (continued) + + Locations Contents + + 0038H-003AH Restart 7; contains a jump instruction + into the DDT or SID program when + running in debug mode for programmed + breakpoints, but is not otherwise used + by CP/M. + + 003BH-003FH Not currently used; reserved. + + 0040H-004FH A 16-byte area reserved for scratch by + CBIOS, but is not used for any purpose + in the distribution version of CP/M. + + 0050H-005BH Not currently used; reserved. + + 005CH-007CH Default File Control Block produced for + a transient program by the CCP. + + 007DH-007FH Optional default random record position. + + 0080H-00FFH Default 128-byte disk buffer, also + filled with the command line when a + transient is loaded under the CCP. + K + + + This information is set up for normal operation under the CP/M +system, but can be overwritten by a transient program if the BDOS +facilities are not required by the transient. + + If, for example, a particular program performs only simple I/O +and must begin execution at location 0, it can first be loaded into +the TPA, using normal CP/M facilities, with a small memory move +program that gets control when loaded. The memory move program must +get control from location 0100H, which is the assumed beginning of +all transient programs. The move program can then proceed to the +entire memory image down to location 0 and pass control to the +starting address of the memory load. + + If the BIOS is overwritten or if location 0, containing the +warm start entry point, is overwritten, the operator must bring the +CP/M system back into memory with a cold start sequence. + + +6.10 Disk Parameter Tables + + Tables are included in the BIOS that describe the particular +characteristics of the disk subsystem used with CP/M. These tables +can be either hand-coded, as shown in the sample CBIOS in Appendix +B, or automatically generated using the DISKDEF macro library, as +shown in Appendix F. The purpose here is to describe the elements +of these tables. + + + + + 6-23 + + + + +CP/M Operating System Manual 6.10 Disk Parameter Tables + + + + In general, each disk drive has an associated (16-byte) disk +parameter header that contains information about the disk drive and +provides a scratch pad area for certain BDOS operations. The format +of the disk parameter header for each drive is shown in Figure 6-2, +where each element is a word (16-bit) value. + + + +XLT 0000 0000 0000 DIRBUF DPB CSV ALV +16b 16b 16b 16b 16b 16b 16b 16b + + + Figure 6-2. Disk Parameter Header Format + + + + The meaning of each Disk Parameter Header (DPH) element is +detailed in Table 6-7. + + + Table 6-7. Disk Parameter Headers + + Disk Parameter Meaning + Header + F + + XLT Address of the logical-to-physical + translation vector, if used for this + particular drive, or the value 0000H if no + sector translation takes place (that is, + the physical and logical sector numbers + are the same). Disk drives with identical + sector skew factors share the same + translate tables. + + 0000 Scratch pad values for use within the + BDOS, initial value is unimportant. + + DIRBUF Address of a 128-byte scratch pad area for + directory operations within BDOS. All + DPHs address the same scratch pad area. + + DPB Address of a disk parameter block for this + drive. Drives with identical disk + characteristics address the same disk + parameter block. + + CSV Address of a scratch pad area used for + software check for changed disks. This + address is different for each DPH. + + ALV Address of a scratch pad area used by the + BDOS to keep disk storage allocation + information. This address is different + for each DPH. + + + 6-24 + + + + K + + +CP/M Operating System Manual 6.10 Disk Parameter Tables + + + + Given n disk drives, the DPHs are arranged in a table whose +first row of 16 bytes corresponds to drive 0, with the last row +corresponding to drive n-1. In the following figure the lable +DPBASE defines the base address of the DPH table. + + + + DPBASE: + + 00 XLT 00 0000 0000 0000 DIRBUF DBP 00 CSV 00 ALV 00 + + 01 XLT 01 0000 0000 0000 DIRBUF DBP 01 CSV 01 ALV 01 + . + . + . + n-1 XLTn-1 0000 0000 0000 DIRBUF DBTn-1 CSVn-1 ALVn-1 + + + Figure 6-3. Disk Parameter Header Table + + + + A responsibility of the SELDSK subroutine is to return the base +address of the DPH for the selected drive. The following sequence +of operations returns the table address, with a 0000H returned if +the selected drive does not exist. + + + NDISKS EQU 4 ;NUMBER OF DISK DRIVES + ..... + SELDSK: ;SELECT DISK GIVEN BY BC + LSI H,0000H ;ERROR CODE + MOV A,C ;DRIVE OK? + CPI NDISKS ;CY IF SO + RNC ;RET IF ERROR + ;NO ERROR, CONTINUE + MOV L,C ;LOW(DISK) + MOV H,B ;HIGH(DISK) + DAD H ;*2 + DAD H ;*4 + DAD H ;*8 + DAD H ;*16 + LXI D,DPBASE;FIRST DPH + DAD D ;DPH(DISK) + RET + + + The translation vectors, XLT 00 through XLTn-1, are located +elsewhere in the BIOS, and simply correspond one-for-one with the +logical sector numbers zero through the sector count 1. The Disk +Parameter Block (DPB) for each drive is more complex. As shown in +Figure 6-4, particular DPB, that is addressed by one or more DPHs, +takes the general form: + + + + 6-25 + + + + + +CP/M Operating System Manual 6.10 Disk Parameter Tables + + + SPT BSH BLM EXM DSM DRM AL0 AL1 CKS 0FF + 16b 8b 8b 8b 16b 16b 8b 8b 16b 16b + + + Figure 6-4. Disk Parameter Block Format + + + +where each is a byte or word value, as shown by the 8b or 16b +indicator below the field. + + The following field abbreviations are used in Figure 6-4: + + + o SPT is the total number of sectors per track. + + o BSH is the data allocation block shift factor, determined by + the data block allocation size. + + o BLM is the data allocation block mask (2[BSH-1]). + + o EXM is the extent mask, determined by the data block allocation + size and the number of disk blocks. + + o DSM determines the total storage capacity of the disk drive. + + o DRM determines the total number of directory entries that can + be stored on this drive. AL0, AL1 determine reserved directory + blocks. + + o CKS is the size of the directory check vector. + + o 0FF is the number of reserved tracks at the beginning of the + (logical) disk. + +The values of BSH and BLM determine the data allocation size BLS, +which is not an entry in the DPB. Given that the designer has +selected a value for BLS, the values of BSH and BLM are shown Table +6-8. + + + Table 6-8. BSH and BLM Values + + BLS BSH BLM + + 1024 3 7 + 2048 4 15 + 4096 5 31 + 8192 6 63 + 16,384 7 127 + + +where all values are in decimal. The value of EXM depends upon both +the BLS and whether the DSM value is less than 256 or greater than +255, as shown in Table 6-9. + + + 6-26 + + + + + +CP/M Operating System Manual 6.10 Disk Parameter Tables + + + Table 6-9. EXM Values + + BLS EXM values + + DSM<256 DSM>255 + + 1024 0 N/A + 2048 1 0 + 4096 3 1 + 8192 7 3 + 16,384 15 7 + + + The value of DSM is the maximum data block number supported by +this particular drive, measured in BLS units. The product (DSM+1) +is the total number of bytes held by the drive and must be within +the capacity of the physical disk, not counting the reserved +operating system tracks. + + The DRM entry is the one less than the total number of +directory entries that can take on a 16-bit value. The values of +AL0 and AL1, however, are determined by DRM. The values AL0 and AL1 +can together be considered a string of 16-bits, as shown in Figure +6-5. + + + + AL0 AL1 + + 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 + + + Figure 6-5. AL0 and AL1 + + + + Position 00 corresponds to the high-order bit of the byte +labeled AL0 and 15 corresponds to the low-order bit of the byte +labeled AL1. Each bit position reserves a data block for number of +directory entries, thus allowing a total of 16 data blocks to be +assigned for directory entries (bits are assigned starting at 00 and +filled to the right until position 15). Each directory entry +occupies 32 bytes, resulting in the following tabulation: + + + Table 6-10. BLS Tabulation + + BLS Directory Entries + + 1024 32 times # bits + 2048 64 times # bits + 4096 128 times # bits + 8192 256 times # bits + 16,384 512 times # bits + + + + 6-27 + + + + + +CP/M Operating System Manual 6.10 Disk Parameter Tables + + + + Thus, if DRM = 127 (128 directory entries) and BLS = 1024, +there are 32 directory entries per block, requiring 4 reserved +blocks. In this case, the 4 high-order bits of AL0 are set, +resulting in the values AL0 = 0F0H and AL1 = 00H. + + The CKS value is determined as follows: if the disk drive +media is removable, then CKS = (DRM+1)/4, where DRM is the last +directory entry number. If the media are fixed, then set CKS = 0 +(no directory records are checked in this case). + + Finally, the 0FF field determines the number of tracks that are +skipped at the beginning of the physical disk. This value is +automatically added whenever SETTRK is called and can be used as a +mechanism for skipping reserved operating system tracks or for +partitioning a large disk into smaller segmented sections. + + To complete the discussion of the DPB, several DPHs can address +the same DPB if their drive characteristics are identical. Further, +the DPB can be dynamically changed when a new drive is addressed by +simply changing the pointer in the DPH; because the BDOS copies the +DPB values to a local area whenever the SELDSK function is invoked. + + Returning back to DPH for a particular drive, the two address +values CSV and ALV remain. Both addresses reference an area of +uninitialized memory following the BIOS. The areas must be unique +for each drive, and the size of each area is determined by the +values in the DPB. + + The size of the area addressed by CSV is CKS bytes, which is +sufficient to hold the directory check information for this +particular drive, If CKS = (DRM+1)/4, you must reserve (DRM+1)/4 +bytes for directory check use. If CKS = 0, no storage is reserved. + + The size of the area addressed by ALV is determined by the +maximum number of data blocks allowed for this particular disk and +is computed as (DSM/8)+1. + + The CBIOS shown in Appendix B demonstrates an instance of these +tables for standard 8-inch, single-density drives. It might be +useful to examine this program and compare the tabular values with +the definitions given above. + + +6.11 The DISKDEF Macro Library + + A macro library called DISKDEF (shown in Appendix F), greatly +simplifies the table construction process. You must have access to +the MAC macro assembler, of course, to use the DISKDEF facility, +while the macro library is included with all CP.M 2 distribution +disks. + + + + + + + 6-28 + + + + + +CP/M Operating System Manual 6.11 The DISKDEF Macro Library + + + + A BIOS disk definition consists of the following sequence of +macro statements: + + MACLIB DISKDEF + ..... + DISKS n + DISKDEF 0,... + DISKDEF 1,... + ..... + DISKDEF n-1 + ..... + ENDEF + +where the MACLIB statement loads the DISKDEF.LIB file, on the same +disk as the BIOS, into MAC's internal tables. The DISKS macro call +follows, which specifies the number of drives to be configured with +the user's system, where n is an integer in the range 1 to 16. A +series of DISKDEF macro calls then follow that define the +characteristics of each logical disk, 0 through n-1, corresponding +to logical drives A through P. The DISKS and DISKDEF macros +generate the in-line fixed data tables described in the previous +section and thus must be placed in a nonexecutable portion of the +BIOS, typically directly following the BIOS jump vector. + + The remaining portion of the BIOS is defined following the +DISKDEF macros, with the ENDEF macro call immediately preceding the +END statement. The ENDEF (End of Diskdef) macro generates the +necessary uninitialized RAM areas that are located in memory above +the BIOS. + + The DISKDEF macro call takes the form: + + DISKDEF dn,fsc,lsc,[skf],bls dks,dir,cks,ofs,[0] + +where + + o dn is the logical disk number, 0 to n-1. + o fsc is the first physical sector number (0 or 1). + o lsc is the last sector number. + o skf is the optional sector skew factor. + o bls is the data allocation block size. + o dks is the number of blocks on the disk. + o dir is the number of directory entries. + o cks is the number of checked directory entries. + o ofs is the track offset to logical track 00. + o [0] is an optional 1.4 compatibility flag. + + + The value dn is the drive number being defined with this +DISKDEF macro invocation. The fsc parameter accounts for differing +sector numbering systems and is usually 0 to 1. The lsc is the last +numbered sector on a track. When present, the skf parameter defines +the sector skew factor, which is used to create a sector translation +table according to the skew. + + + 6-29 + + + + + +CP/M Operating System Manual 6.11 The DISKDEF Macro Library + + + + If the number of sectors is less than 256, a single-byte table +is created, otherwise each translation table element occupies two +bytes. No translation table is created if the skf parameter is +omitted, or equal to 0. + + The bls parameter specifies the number of bytes allocated to +each data block, and takes on the values 1024, 2048, 4096, 8192, or +16384. Generally, performance increases with larger data block +sizes because there are fewer directory references, and logically +connected data records are physically close on the disk. Further, +each directory entry addresses more data and the BIOS-resident RAM +space is reduced. + + The dks parameter specifies the total disk size in bls units. +That is, if the bls = 2048 and dks = 1000, the total disk capacity +is 2,048,000 bytes. If dks is greater than 255, the block size +parameter bls must be greater than 1024. The value of dir is the +total number of directory entries that might exceed 255, if desired. + + The cks parameter determines the number of directory items to +check on each directory scan and is used internally to detect +changed disks during system operation, where an intervening cold or +warm start has not occurred. When this situation is detected, CP/M +automatically marks the disk Read-Only so that data is not +subsequently destroyed. + + As stated in the previous section, the value of cks = dir when +the medium is easily changed, as is the case with a floppy disk +subsystem. If the disk is permanently mounted, the value of cks is +typically 0, because the probability of changing disks without a +restart is low. + + The ofs value determines the number of tracks to skip when this +particular drive is addressed, which can be used to reserve +additional operating system space or to simulate several logical +drives on a single large capacity physical drive. Finally, the [0] +parameter is included when file compatibility is required with +versions of 1.4 that have been modified for higher density disks. +This parameter ensures that only 16K is allocated for each directory +record, as was the case for previous versions. Normally, this +parameter is not included. + + For convenience and economy of table space, the special form: + + DISKDEF i,j + +gives disk i the same characteristics as a previously defined drive +j. A standard four-drive, single-density system, which is +compatible with version 1.4, is defined using the following macro +invocations: + + DISKS 4 + DISKDEF 0,1,26,6,1024,243,64,2 + DISKDEF 1,0 + + + 6-30 + + + + + +CP/M Operating System Manual 6.11 The DISKDEF Macro Library + + + DISKDEF 2,0 + DISKDEF 3,0 + .... + ENDEF + +with all disks having the same parameter values of 26 sectors per +track, numbered 1 through 26, with 6 sectors skipped between each +access, 1024 bytes per data block, 243 data blocks for a total of +243K-byte disk capacity, 64 checked directory entries, and two +operating system tracks. + + The DISKS macro generates n DPHs, starting at the DPH table +address DPBASE generated by the macro. Each disk header block +contains sixteen bytes, as described above, and correspond one-for- +one to each of the defined drives. In the four-drive standard +system, for example, the DISKS macro generates a table of the form: + + DPBASE EQU$ + DPE0: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV0,ALV0 + DPE1: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV1,ALV1 + DPE2: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV2,ALV2 + DPE3: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV3,ALV3 + +where the DPH labels are included for reference purposes to show the +beginning table addresses for each drive 0 through 3. The values +contained within the DPH are described in detail in the previous +section. The check and allocation vector addresses are generated by +the ENDEF macro in the ram area following the BIOS code and tables. + + Note that if the skf (skew factor) parameter is omitted, or +equal to 0, the translation table is omitted and a 0000H value is +inserted in the XLT position of the DPH for the disk. In a +subsequent call to perform the logical-to-physical translation, +SECTRAN receives a translation table address of DE = 0000H and +simply returns the original logical sector from BC in the HL +register pair. + + A translate table is constructed when the skf parameter is +present, and the (nonzero) table address is placed into the +corresponding DPHs. The following for example, is constructed when +the standard skew factor skf = 6 is specified in the DISKDEF macro +call: + + XLT0: DB 1,7,13,19,25,5,11,17,23,3,9,15,21 + DB 2,8,14,20,26,6,12,18,24,4,10,16,22 + + Following the ENDEF macro call, a number of uninitialized data +areas are defined. These data areas need not be a part of the BIOS +that is loaded upon cold start, but must be available between the +BIOS and the end of memory. The size of the uninitialized RAM area +is determined by EQU statements generated by the ENDEF macro. For a +standard four-drive system, the ENDEF macro might produce the +following EQU statement: + + + + + 6-31 + + + + + +CP/M Operating System Manual 6.11 The DISKDEF Macro Library + + + 4C72 = BEGDAT EQU $ + (data areas) + + 4DB0 = ENDDAT EQU $ + + 013C = DATSIZ EQU $-BEGDAT + +which indicates that uninitialized RAM begins at location 4C72H, +ends at 4DB0H-1, and occupies 013CH bytes. You must ensure that +these addresses are free for use after the system is loaded. + + After modification, you can use the STAT program to check drive +characteristics, because STAT uses the disk parameter block to +decode the drive information. A STAT command of the form: + + STAT d:DSK: + +decodes the disk parameter block for drive d (d=A,...,P) and +displays the following values: + + + r: 128-byte record capacity + k: kilobyte drive capacity + d: 32-byte directory entries + c: checked directory entries + e: records/extent + b: records/block + s: sectors/track + t: reserved tracks + + + Three examples of DISKDEF macro invocations are shown below +with corresponding STAT parameter values. The last example produces +a full 8-megabyte system. + + DISKDEF 0,1,58,,2048,256,128,128,2 + r=4096, k=512, d=128, c=128, e=256, b=16, s=58, t=2 + + DISKDEF 0,1,58,,2048,1024,300,0,2 + r=16348, k=2048, d=300, c=0, e=128, b=16, s=58, t=2 + + DISKDEF 0,1,58,,16348,512,128,128,2 + r=65536, k=8192, d=128, c=128, e=1024, b=128, s=58, t=2 + + +6.12 Sector Blocking and Deblocking + + Upon each call to BIOS WRITE entry point, the CP/M BDOS +includes information that allows effective sector blocking and +deblocking where the host disk subsystem has a sector size that is a +multiple of the basic 128-byte unit. The purpose here is to present +a general-purpose algorithm that can be included within the BIOS and +that uses the BDOS information to perform the operations +automatically. + + + + 6-32 + + + + + +CP/M Operating System Manual 6.12 Blocking and Deblocking + + + On each call to WRITE, the BDOS provides the following +information in register C: + + 0 = (normal sector write) + 1 = (write to directory sector) + 2 = (write to the first sector + of a new data block) + + Condition 0 occurs whenever the next write operation is into a +previously written area, such as a random mode record update; when +the write is to other than the first sector of an unallocated block; +or when the write is not into the directory area. Condition 1 +occurs when a write into the directory area is performed. Condition +2 occurs when the first record (only) of a newly allocated data +block is written. In most cases, application programs read or write +multiple 128-byte sectors in sequence; thus, there is little +overhead involved in either operation when blocking and deblocking +records, because preread operations can be avoided when writing +records. + + Appendix G lists the blocking and deblocking algorithms in +skeletal form; this file is included on your CP/M disk. Generally, +the algorithms map all CP/M sector read operations onto the host +disk through an intermediate buffer that is the size of the host +disk sector. Throughout the program, values and variables that +relate to the CP/M sector involved in a seek operation are prefixed +by sek, while those related to the host disk system are prefixed by +hst. The equate statements beginning on line 29 of Appendix G +define the mapping between CP/M and the host system, and must be +changed if other than the sample host system is involved. + + The entry points BOOT and WBOOT must contain the initialization +code starting on line 57, while the SELDSK entry point must be +augmented by the code starting on line 65. Note that although the +SELDSK entry point computes and returns the Disk Parameter Header +address, it does not physically select the host disk at this point +(it is selected later at READHST or WRITEHST). Further, SETTRK, +SETTRK, and SETMA simply store the values, but do not take any other +action at this point. SECTRAN performs a trivial function of +returning the physical sector number. + + The principal entry points are READ and WRITE, starting on +lines 110 and 125, respectively. These subroutines take the place +of your previous READ and WRITE operations. + + The actual physical read or write takes place at either +WRITEHST or READHST, where all values have been prepared: hstdsk is +the host disk number, hsttrk is the host track number, and hstsec is +the host sector number, which may require translation to physical +sector number. You must insert code at this point that performs the +full sector read or write into or out of the buffer at hstbuf of +length hstsiz. All other mapping functions are performed by the +algorithms. + + + + + 6-33 + + + + + +CP/M Operating System Manual 6.12 Blocking and Deblocking + + + This particular algorithm was tested using an 80-megabyte hard +disk unit that was originally configured for 128-byte sectors, +producing approximately 35 megabytes of formatted storage. When +configured for 512-byte host sectors, usable storage increased to 57 +megabytes, with a corresponding 400% improvement in overall +response. In this situation, there is no apparent overhead involved +in deblocking sectors, with the advantage that user programs still +maintain 128-byte sectors. This is primarily because of the +information provided by the BDOS, which eliminates the necessity for +preread operations. + + +End of Section 6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6-34 + + diff --git a/Source/Doc/CPM 22 Manual - Testing/part2.prn b/Source/Doc/CPM 22 Manual - Testing/part2.prn new file mode 100644 index 00000000..4d83d7d6 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/part2.prn @@ -0,0 +1,3010 @@ +XS 9 N0 + + + + + + Appendix A + + The Microcomputer Development System Basic Input/Output System (BIOS) + + + + 1 ; mds-800 i/o drivers for cp/m 2.2 + 2 ; (four drive single density version) + 3 ; + 4 ; version 2.2 february, 1980 + 5 ; + 6 0016 = vers equ 22 ;version 2.2 + 7 ; + 8 ; copyright (c) 1980 + 9 ; digital research + 10 ; box 579, pacific grove + 11 ; california, 93950 + 12 ; + 13 ; + 14 ffff = true equ 0fffh ;value of "true" + 15 0000 = false equ not true ;"false" + 16 0000 = test equ false ;true if test bios + 17 ; + 18 if test + 19 bias equ 03400h ;base of ccp in test system + 20 endif + 21 if not test + 22 0000 = bias equ 0000h ;generate relocatable cp/m system + 23 endif + 24 ; + 25 1600 = patch equ 1600h + 26 ; + 27 1600 org patch + 28 0000 = cpmb equ $-patch ;base of cpm console processor + 29 0806 = bdos equ 806h+cpmb ;basic dos (resident portion) + 30 1600 = cpml equ $-cpmb ;length (in bytes) of cpm system + 31 002c = nsects equ cpml/128 ;number of sectors to load + 32 0002 = offset equ 2 ;number of disk tracks used by cp/m + 33 0004 = cdisk equ 0004h ;address of last logged disk on warm start + 34 0080 = buff equ 0080h ;default buffer address + + A-1 + + + + + + + + + + 35 000a = retry equ 10 ;max retries on disk i/o before error + 36 ; + 37 ; perform following functions + 38 ; boot cold start + 39 ; wboot warm start (save i/o byte) + 40 ; (boot and wboot are the same for mds) + 41 ; const console status + 42 ; reg-a = 00 if no character ready + 43 ; reg-a = ff if character ready + 44 ; conin console character in (result in reg-a) + 45 ; conout console character out (char in reg-c) + 46 ; list list out (char in reg-c) + 47 ; punch punch out (char in reg-c) + 48 ; reader paper tape reader in (result to reg-a) + 49 ; home move to track 00 + 50 ; + 51 ; (the following calls set-up the io parameter block for the + 52 ; mds, which is used to perform subsequent reads and writes) + 53 ; seldsk select disk given by reg-c (0, 1, 2...) + 54 ; settrk set track address (0,...76) for subsequent read-write + 55 ; setsec set sector address (1,...,26) for subsequent read-write + 56 ; setdma set subsequent dma address (initially 80h) + 57 ; + 58 ; (read and write assume previous calls to set up the io parameters) + 59 ; read read track/sector to preset dma address + 60 ; write track/sector from preset dma address + 61 ; + 62 ; jump vector for individual routines + 63 1600 c3b316 jmp boot + 64 1603 c3c316 wboote: jmp wboot + 65 1606 c36117 jmp const + 66 1609 c36417 jmp conin + 67 160c c36a17 jmp conout + 68 160f c36d17 jmp list + 69 1612 c37217 jmp punch + 70 1615 c37517 jmp reader + 71 1618 c37817 jmp home + 72 161b c37d17 jmp seldsk + 73 161e c3a717 jmp settrk + 74 1621 c3ac17 jmp setsec + + A-2 + + + + + + + + + + 75 1624 c3bb17 jmp setdma + 76 1627 c3c117 jmp read + 77 162a c3ca17 jmp write + 78 162d c37017 jmp listst ;list status + 79 1630 c3b117 jmp sectran + 80 ; + 81 maclib diskdef ;load the disk definition library + 82 disks 4 ;four disks + 83 1633+= dpbase equ $ ;base of disk parameter blocks + 84 1633+82160000 dpe0: dw xlt0, 0000h ;translate table + 85 1637+00000000 dw 0000h, 0000h ;scratch area + 86 163b+6e187316 dw dirbuf, dpb0 ;dir buff, parm block + 87 163f+0d19ee18 dw csv0, alv0 ;check, alloc vectors + 88 1643+82160000 dpe1: dw xlt1, 0000h ;translate table + 89 1647+00000000 dw 0000h, 0000h ;scratch area + 90 164b+6e187316 dw dirbuf, dpb1 ;dir buff, parm block + 91 164f+3c191d19 dw csv1, alv1 ;check, alloc vectors + 92 1653+82160000 dpe2: dw xlt2, 0000h ;translate table + 93 1657+00000000 dw 0000h, 0000h ;scratch area + 94 165b+6e187316 dw dirbuf, dpb2 ;dir buff, parm block + 95 165f+6b194c19 dw csv2, alv2 ;check, alloc vectors + 96 1663+82160000 dpe3: dw xlt3, 0000h ;translate table + 97 1667+00000000 dw 0000h, 0000h ;scratch area + 98 166b+6e187316 dw dirbuf, dpb3 ;check, alloc block + 99 166f+9a197b19 dw csv3, alv3 ;dir buff, parm vectors +100 diskdef 0, 1, 26, 6, 1024, 243, 64, 64, offset +101 1673+= dpb0 equ $ ;disk parm block +102 1673+1a00 dw 26 ;sec per track +103 1675+03 db 3 ;block shift +104 1676+07 db 7 ;block mask +105 1677+00 db 0 ;extnt mask +106 1678+f200 dw 242 ;disk size-1 +107 167a+3f00 dw 63 ;directory max +108 167c+c0 db 192 ;alloc0 +109 167d+00 db 0 ;alloc1 +110 167e+1000 dw 16 ;check size +111 1680+0200 dw 2 ;offset +112 1682+= xlt0 equ $ ;translate table +113 1682+01 db 1 +114 1683+07 db 7 + + A-3 + + + + + + + + + +115 1684+0d db 13 +116 1685+13 db 19 +117 1686+19 db 25 +118 1687+05 db 5 +119 1688+0b db 11 +120 1689+11 db 17 +121 168a+17 db 23 +122 168b+03 db 3 +123 168c+09 db 9 +124 168d+0f db 15 +125 168e+15 db 21 +126 168f+02 db 2 +127 1690+08 db 8 +128 1691+0e db 14 +129 1692+14 db 20 +130 1693+1a db 26 +131 1694+06 db 6 +132 1695+0c db 12 +133 1696+12 db 18 +134 1697+18 db 24 +135 1698+04 db 4 +136 1699+0a db 10 +137 169a+10 db 16 +138 169b+16 db 22 +139 diskdef 1,0 +140 1673+ = dpb1 equ dpb0 ;equivalent parameters +141 001f+ = als1 equ als0 ;same allocation vector size +142 0010+ = css1 equ css0 ;same checksum vector size +143 1682+ = xlt1 equ xlt0 ;same translate table +144 diskdef 2, 0 +145 1673+ = dpb2 equ dpb0 ;equivalent parameters +146 001f+ = als2 equ als0 ;same allocation vector size +147 0010+ = css2 equ css0 ;same checksum vector size +148 1682+ = xlt2 equ xlt0 ;same translate table +149 diskdef 3, 0 +150 1673+ = dpb3 equ dpb0 ;equivalent parameters +151 001f+ = als3 equ als0 ;same allocation vector size +152 0010+ = css3 equ css0 ;same checksum vector size +153 1682+ = xlt3 equ xlt0 ;same translate table +154 ; endef occurs at end of assembly + + A-4 + + + + + + + + + +155 ; +156 ; end of controller--independent code, the remaining subroutines +157 ; are tailored to the particular operating environment, and must +158 ; be altered for any system which differs from the intel mds. +159 ; +160 ; the following code assumes the mds monitor exists at 0f800h +161 ; and uses the i/o subroutines within the monitor +162 ; +163 ; we also assume the mds system has four disk drives +164 00fd = revrt equ 0fdh ;interrupt revert port +165 00fc = intc equ 0fch ;interrupt mask port +166 00f3 = icon equ 0f3h ;interrupt control port +167 007E = inte equ 0111$1110b ;enable rst 0 (warm boot), rst 7 (monitor) +168 ; +169 ; mds monitor equates +170 f800 = mon80 equ 0f800h ;mds monitor +171 ff0f = rmon80 equ 0ff0fh ;restart mon80 (boot error) +172 f803 = ci equ 0f803h ;console character to reg-a +173 f806 = ri equ 0f806h ;reader in to reg-a +174 f809 = co equ 0f809h ;console char from c to console out +175 f80c = po equ 0f80ch ;punch char from c to punch device +176 f80f = lo equ 0f80fh ;list from c to list device +177 f812 = csts equ 0f812h ;console status 00/ff to register a +178 ; +179 ; disk ports and commands +180 0078 = base equ 78h ;base of disk command io ports +181 0078 = dstat equ base ;disk status (input) +182 0079 = rtype equ base+1 ;result type (input) +183 007b = rbyte equ base+3 ;result byte (input) +184 ; +185 0079 = ilow equ base+1 ;iopb low address (output) +186 007a = ihigh equ base+2 ;iopb high address (output) +187 ; +188 0004 = readf equ 4h ;read function +189 0006 = writf equ 6h ;write function +190 0003 = recal equ 3h ;recalibrate drive +191 0004 = iordy equ 4h ;i/o finished mask +192 000d = cr equ 0dh ;carriage return +193 000a = lf equ 0ah ;line-feed +194 ; + + A-5 + + + + + + + + + +195 signon: ;signon message: xxk cp/m vers y.y +196 169c 0d0a0a db cr, lf, lf +197 if test +198 db '32' ;32k example bios +199 endif +200 if not test +201 169f 3030 db '00' ;memory size filled by relocator +202 endif +203 16a1 6b2043502f db 'k cp/m vers ' +204 16ad 322e32 db ver/10+'0', ',' vers mod 10+'0' +205 16b0 0d0a00 db cr, lf, 0 +206 ; +207 boot: ;print signon message and go to ccp +208 ; (note: mds boot initialized iobyte at 0003h) +209 16b3 310001 lxi sp, buff+80h +210 16b6 219c16 lxi h, signon +211 16b9 cdd317 call prmsg ;print message +212 16bc af xra a ;clear accumulator +213 16bd 320400 sta cdisk ;set initially to disk a +214 16c0 c30f17 jmp gocpm ;go to cp/m +215 ; +216 ; +217 wboot:; loader on track 0, sector 1, which will be skipped for warm +218 ; read cp/m from disk--assuming there is a 128 byte cold start +219 ; start +220 ; +221 16c3 318000 lxi sp, buff ;using dma--thus 80 thru ff available for stack +222 ; +223 16c6 0e0a mvi c, retry ;max retries +224 16c8 c5 push b +225 wboot0: ;enter here on error retries +226 16c9 010000 lxi b, cpmb ;set dma address to start of disk system +227 16cc cdbb17 call setdma +228 16cf 0e00 mvi c, 0 ;boot from drive 0 +229 16d1 cd7d17 call seldsk +230 16d4 0e00 mvi c, 0 +231 16d6 cda717 call settrk ;start with track 0 +232 16d9 0e02 mvi c, 2 ;start reading sector 2 +233 16db cdac17 call setsec +234 ; + + A-6 + + + + + + + + + +235 ; read sectors, count nsects to zero +236 16de c1 pop b ;10-error count +237 16df 062c mvi b, nsects +238 rdsec: ;read next sector +239 16e1 c5 push b ;save sector count +240 16e2 cdc117 call read +241 16e5 c24917 jnz booterr ;retry if errors occur +242 16e8 2a6c18 lhld iod ;increment dma address +243 16eb 118000 lxi d, 128 ;sector size +244 16ee 19 dad d ;incremented dma address in hl +245 16ef 44 mov b, h +246 16f0 4d mov c, l ;ready for call to set dma +247 16f1 cdbb17 call setdma +248 16f4 3a6b18 lda ios ;sector number just read +249 16f7 fe1a cpi 26 ;read last sector? +250 16f9 da0517 jc rd1 +251 ; must be sector 26, zero and go to next track +252 16fc 3a6a18 lda iot ;get track to register a +253 16ff 3c inr a +254 1700 4f mov c, a ;read for call +255 1701 cda717 call settrk +256 1704 af xra a ;clear sector number +257 1705 3c rd1: inr a ;to next sector +258 1706 4f mov c, a ;ready for call +259 1707 cdac17 call setsec +260 170a c1 pop b ;recall sector count +261 170b 05 dcr b ;done? +262 170c c2e116 jnz rdsec +263 ; +264 ; done with the load, reset default buffer address +265 gocpm: ;(enter here from cold start boot) +266 ; enable rst0 and rst7 +267 170f f3 di +268 1710 3e12 mvi a, 12h ;initialize command +269 1712 d3fd out revrt +270 1714 af xra a +271 1715 d3fc out intc ;cleared +272 1717 3e7e mvi a, inte ;rst0 and rst7 bits on +273 1719 d3fc out intc +274 171b af xra a + + A-7 + + + + + + + + + +275 171c d3f3 out icon ;interrupt control +276 ; +277 ; set default buffer address to 80h +278 171e 018000 lxi b, buff +279 1721 cdbb17 call setdma +280 ; +281 ; reset monitor entry points +282 1724 3ec3 mvi a, jmp +283 1726 320000 sta 0 +284 1729 210316 lxi h, wboote +285 172c 220100 shld 1 ;jump wboot at location 00 +286 172f 320500 sta 5 +287 1732 210608 lxi h, bdos +288 1735 220600 shld 6 ;jmp bdos at location 5 +289 if not test +290 1738 323800 sta 7*8 ;jmp to mon80 (may have changed by ddt) +291 173b 2100f8 lxi h, mon80 +292 173e 223900 shld 7*8+1 +293 endif +294 ; leave iobyte set +295 ; previously selected disk was b, send parameter to cpm +296 1741 3a0400 lda cdisk ;last logged disk number +297 1744 4f mov c, a ;send to ccp to log it in +298 1745 fb ei +299 1746 c30000 jmp cpmb +300 ; +301 ; error condition occurred, print message and retry +302 booterr: +303 1749 c1 pop b ;recall counts +304 174a 0d dcr c +305 174b ca5217 jz booter0 +306 ; try again +307 174e c5 push b +308 174f c3c916 jmp wboot0 +309 ; +310 booter0: +311 ; otherwise too many retries +312 1752 215b17 lxi h, bootmsg +313 1755 cdd317 call prmsg +314 1758 c30fff jmp rmon80 ;mds hardware monitor + + A-8 + + + + + + + + + +315 ; +316 bootmsg: +317 175b 3f626f6f74 db '?boot', 0 +318 ; +319 ; +320 const: console status to reg-a +321 ; (exactly the same as mds call) +322 1761 c312f8 jmp csts +323 ; +324 conin: ;console character to reg-a +325 1764 cd03f8 call ci +326 1767 e67f ani 7fh ;remove parity bit +327 1769 c9 ret +328 ; +329 conout: ;console character from c to console out +330 176a c309f8 jmp co +331 ; +332 list: ;list device out +333 ; (exactly the same as mds call) +334 176d c30ff8 jmp lo +335 ; +336 listst: +337 ;return list status +338 1770 af xra a +339 1771 c9 ret ;always not ready +340 ; +341 punch: ;punch device out +342 ; (exactly the same as mds call) +343 1772 c30cf8 jmp po +344 ; +345 reader: ;reader character in to reg-a +346 ; (exactly the same as mds call) +347 1775 c306f8 jmp ri +348 ; +349 home: ;move to home position +350 ; treat as track 00 seek +351 1778 0e00 mvi c, 0 +352 177a c3a717 jmp settrk +353 ; +354 seldsk: ;select disk given by register c + + A-9 + + + + + + + + + +355 177d 210000 lxi h, 0000h ;return 0000 if error +356 1780 79 mov a, c +357 1781 fe04 cpi ndisks ;too large? +358 1783 d0 rnc ;leave hl = 0000 +359 ; +360 1784 e602 ani 10b ;00 00 for drive 0, 1 and 10 10 for drive 2, 3 +361 1786 326618 sta dbank ;to select drive bank +362 1789 79 mov a, c ;00, 01, 10, 11 +363 178a e601 ani 1b ;mds has 0, 1 at 78, 2, 3 at 88 +364 178c b7 ora a ;result 00? +365 178d ca9217 jz setdrive +366 1790 3e30 mvi a, 00110000b ;selects drive 1 in bank +367 setdrive: +368 1792 47 mov b, a ;save the function +369 1793 216818 lxi h, iof ;io function +370 1796 7e mov a, m +371 1797 e6cf ani 11001111b ;mask out disk number +372 1799 b0 ora b ;mask in new disk number +373 179a 77 mov m, a ;save it in iopb +374 179b 69 mov l, c +375 179c 2600 mvi h, 0 ;hl=disk number +376 179e 29 dad h ;*2 +377 179f 29 dad h ;*4 +378 17a0 29 dad h ;*8 +379 17a1 29 dad h ;*16 +380 17a2 113316 lxi d, dpbase +381 17a5 19 dad d ;hl=disk header table address +382 17a6 c9 ret +383 ; +384 ; +385 settrk: ;set track address given by c +386 17a7 216a18 lxi h, iot +387 17aa 71 mov m, c +388 17ab c9 ret +389 ; +390 setsec: ;set sector number given by c +391 17ac 216b18 lxi h, ios +392 17af 71 mov m, c +393 17b0 c9 ret +394 sectran: + + A-10 + + + + + + + + + +395 ;translate sector bc using table at de +396 17b1 0600 mvi b, 0 ;double-precision sector number in bc +397 17b3 eb xchg ;translate table address to hl +398 17b4 09 dad b ;translate (sector) address +399 17b5 7e mov a, m ;translated sector number to a +400 17b6 326b18 sta ios +401 17b9 6f mov l, a ;return sector number in l +402 17ba c9 ret +403 ; +404 setdma: ;set dma address given by regs b, c +405 17bb 69 mov l, c +406 17bc 60 mov h, b +407 17bd 226c18 shld iod +408 17c0 c9 ret +409 ; +410 read: ;read next disk record (assuming disk/trk/sec/dma set) +411 17c1 0e04 mvi c, readf ;set to read function +412 17c3 cde017 call setfunc +413 17c6 cdf017 call waitio ;perform read function +414 17c9 c9 ret ;may have error set in reg-a +415 ; +416 ; +417 write: ;disk write function +418 17ca 0e06 mvi c, writf +419 17cc cde017 call setfunc ;set to write function +420 17cf cdf017 call waitio +421 17d2 c9 ret ;may have error set +422 ; +423 ; +424 ; utility subroutines +425 prmsg: ;print message at h, l to 0 +426 17d3 7e mov a, m +427 17d4 b7 ora a zero? +428 17d5 c8 rz +429 ; more to print +430 17d6 e5 push h +431 17d7 4f mov c,a +432 17d8 cd6a17 call conout +433 17db e1 pop h +434 17dc 23 inx h + + A-11 + + + + + + + + + +435 17dd c3d317 jmp prmsg +436 ; +437 setfunc: +438 ; set function for next i/o (command in reg-c) +439 17e0 216818 lxi h, iof ;io function address +440 17e3 7e mov a, m ;get it to accumulator for masking +441 17e4 e6f8 ani 11111000b ;remove previous command +442 17e6 b1 ora c ;set to new command +443 17e7 77 mov m, a ;replaced in iopb +444 ; the mds-800 controller requires disk bank bit in sector byte +445 ; mask the bit from the current i/o function +446 17e8 e620 ani 00100000b ;mask the disk select bit +447 17ea 216b18 lxi h, ios ;address the sector select byte +448 17ed b6 ora m ;select proper disk bank +449 17ee 77 mov m, a ;set disk select bit on/off +450 17ef c9 ret +451 ; +452 waitio: +453 17f0 0e0a mvi c, retry ;max retries before perm error +454 rewait: +455 ; start the i/o function and wait for completion +456 17f2 cd3f18 call intype ;in rtype +457 17f5 cd4c18 call inbyte ;clears the controller +458 ; +459 17f8 3a6618 lda dbank ;set bank flags +460 17fb b7 ora a ;zero if drive 0, 1 and nz if 2, 3 +461 17fc 3e67 mvi a, iopb and offh ;low address for iopb +462 17fe 0618 mvi b, iopb shr 8 ;high address for iopb +463 1800 c20b18 jnz iodr1 ;drive bank 1? +464 1803 d379 out ilow ;low address to controller +465 1805 78 mov a, b +466 1806 d37a out ihigh ;high address +467 1808 c31018 jmp waito ;to wait for complete +468 ; +469 iodr1: ;drive bank 1 +470 180b d389 out ilow+10h ;88 for drive bank 10 +471 180d 78 mov a, b +472 180e d38a out ihigh+10h +473 ; +474 1810 cd5918 waito: call instat ;wait for completion + + A-12 + + + + + + + + + +475 1813 e604 ani iordy ;ready? +476 1815 ca1018 jz waito +477 ; +478 ; check io completion ok +479 1818 cd3f18 call intype ;must be io complete (00) unlinked +480 ; 00 unlinked i/o complete, 01 linked i/o complete (not used) +481 ; io disk status changed 11 (not used) +482 181b fe02 cpi 10b ;ready status change? +483 181d ca3218 jz wready +484 ; +485 ; must be 00 in the accumulator +486 1820 b7 ora a +487 1821 c23818 jnz werror ;some other condition, retry +488 ; +489 ; check i/o error bits +490 1824 cd4c18 call inbyte +491 1827 17 ral +492 1828 da3218 jc wready ;unit not ready +493 182b 1f rar +494 182c e6fe ani 11111110b ;any other errors? (deleted data ok) +495 182e c23818 jnz werror +496 ; +497 ; read or write is ok, accumulator contains zero +498 1831 c9 ret +499 ; +500 wready: ;not ready, treat as error for now +501 1832 cd4c18 call inbyte ;clear result byte +502 1835 c33818 jmp trycount +503 ; +504 werror: ;return hardware malfunction (crc, track, seek, etc.) +505 ; the mds controller has returned a bit in each position +506 ; of the accumulator, corresponding to the conditions: +507 ; 0 -deleted data (accepted as ok above) +508 ; 1 -crc error +509 ; 2 -seek error +510 ; 3 -address error (hardware malfunction) +511 ; 4 -data over/under flow (hardware malfunction) +512 ; 5 -write protect (treated as not ready) +513 ; 6 -write error (hardware malfunction) +514 ; j -not ready + + A-13 + + + + + + + + + +515 ; (accumulator bits are numbered 7 6 5 4 3 2 1 0) +516 ; +517 ; it may be useful to filter out the various conditions, +518 ; but we will get a permanent error message if it is not +519 ; recoverable. in any case, the not ready condition is +520 ; treated as a separated condition for later improvement +521 trycount: +522 ; register c contains retry count, decrement 'til zero +523 1838 0d dcr c +524 1839 c2f217 jnz rewait ;for another try +525 ; +526 ; cannot recover from error +527 183c 3e01 mvi a, 1 ;error code +528 183e c9 ret +529 ; +530 ; intype, inbyte, instat read drive bank 00 or 10 +531 183f 3a6618 intype: lda dbank +532 1842 b7 ora a +533 1843 c24918 jnz intyp1 ;skip to bank 10 +534 1846 db79 in rtype +535 1848 c9 ret +536 1849 db89 intyp1: in rtype+10h ;78 for 0, 1 88 for 2, 3 +537 184b c9 ret +538 ; +539 184c 3a6618 inbyte: lda dbank +540 184f b7 ora a +541 1850 c25618 jnz inbyt1 +542 1853 db7b in rbyte +543 1855 c9 ret +544 1856 db8b inbyt1: in rbyte+10h +545 1858 c9 ret +546 ; +547 1859 3a6618 instat: lda dbank +548 185c b7 ora a +549 185d c26318 jnz insta1 +550 1860 db78 in dstat +551 1862 c9 ret +552 1863 db88 insta1: in dstat+10h +553 1865 c9 ret +554 ; + + A-14 + + + + + + + + + +555 ; +556 ; +557 ; data areas (must be in ram) +558 1866 00 dbank: db 0 ;disk bank 00 if drive 0, 1 +559 ; 10 if drive 2, 3 +560 iopb: ;io parameter block +561 1867 80 db 80h ;normal i/o operation +562 1868 04 iof: db readf ;io function, initial read +563 1869 01 ion: db 1 ;number of sectors to read +564 186a 02 iot: db offset ;track number +565 186b 01 ios: db 1 ;sector number +566 186c 8000 iod: dw buff ;io address +567 ; +568 ; +569 ; define ram areas for bdos operation +570 endef +571 186e+= begdat equ $ +572 186e+ dirbuf: ds 128 ;directory access buffer +573 18ee+ alv0: ds 31 +574 190d+ csv0: ds 16 +575 191d+ alv1: ds 31 +576 193c+ csv1: ds 16 +577 194c+ alv2: ds 31 +578 196b+ csv2: ds 16 +579 197b+ alv3: ds 31 +580 199a+ csv3: ds 16 +581 19aa+= enddat equ $ +582 013c+= datsiz equ $-begdat +583 19aa end + + +als1 001f 141# +als2 001f 146# +als3 001f 151# +alv0 18ee 87 573# +alv1 191d 91 575# +alv2 194c 95 577# +alv3 197b 99 579# +base 0078 180# 181 182 183 185 186 +bdos 0806 29# 287 + + A-15 + + + + + + + + + +begdat 186e 571# 582 +bias 0000 19# 22# +boot 16b3 63 207# +booter0 1752 305 310# +booterr 1749 241 302# +bootmsg 175b 312 316# +buff 0080 34# 209 221 278 566 +cdisk 0004 33# 213 296 +ci f803 172# 325 +co f809 174# 330 +conin 1764 66 324# +conout 176a 67 329# 432 +const 1761 65 320# +cpmb 0000 28# 29 30 226 299 +cpml 1600 30# 31 +cr 000d 192# 196 205 +css1 0010 142# +css2 0010 147# +css3 0010 152# +csts f812 177# 322 +csv0 190d 87 574# +csv1 193c 91 576# +csv2 196b 95 578# +csv3 199a 99 580# +datsiz 013c 582# +dbank 1866 361 459 531 539 539 547 558# +dirbuf 186e 86 90 94 98 572# +dpb0 1673 86 101# 140 145 150 +dpb1 1673 90 140# +dpb2 1673 94 145# +dpb3 1673 98 150# +dpbase 1633 83# 380 +dpe0 1633 84# +dpe1 1643 88# +dpe2 1653 92# +dpe3 1663 96# +dstat 0078 181# 550 552 +enddat 19aa 581# +false 0000 15# 16 +gocpm 170f 214 265# + + A-16 + + + + + + + + + +home 1778 71 349# +icon 00fe 166# 275 +ihigh 007a 186# 466 472 +ilow 0079 185# 464 470 +inbyt1 1856 541 544# +inbyte 184c 457 490 501 539# +insta1 1863 549 552# +instat 1859 474 547# +intc 00fc 165# 271 273 +inte 007e 167# 272 +intyp1 1849 533 536# +intype 183f 456 479 531# +iod 186c 242 407 566# +iodr1 180b 463 469# +iof 1868 369 439 562# +ion 1869 563# +iopb 1867 461 462 560# +iordy 0004 191# 475 +ios 186b 248 391 400 447 565# +iot 186a 252 386 564# +lf 000a 193# 196 196 205 +list 176d 68 332# +listst 1770 78 336# +lo f80f 176# 334 +mon80 f800 170# 291 +nsects 002c 31# 237 +offset 0002 32# 100 564 +patch 1600 25# 27 28 +po f80c 175# 343 +prmsg 17d3 211 313 425# 435 +punch 1772 69 341# +rbyte 007b 183# 542 544 +rd1 1705 250 257# +rdsec 16e1 238# 262 +read 17c1 76 240 410# +reader 1775 70 345# +readf 0004 188# 411 562 +recal 0003 190# +retry 000a 35# 223 453 +revrt 00fd 164# 269 + + A-17 + + + + + + + + + +rewait 17f2 454# 524 +ri f806 173# 347 +rmon80 ff0f 171# 314 +rtype 0079 182# 534 536 +sectran 17b1 79 394# +seldsk 177d 72 229 354# +setdma 17bb 75 227 247 279 404# +setdrive 1792 365 367# +setfunc 17e0 412 419 437# +setsec 17ac 74 233 259 390# +settrk 17a7 73 231 255 352 385# +signon 169c 195# 210 +test 0000 16# 18 21 197 200 289 +true ffff 14# 15 +trycount 1838 502 521# +vers 0016 6# 204 204 +waito 1810 467 474# 476 +waitio 17f0 413 420 452# +wboot 16c3 64 217# +wboot0 16c9 225# 308 +wboote 1603 64# 284 +werror 1838 487 495 504# +wready 1832 483 492 500# +write 17ca 77 417# +writf 0006 189# 418 +xlt0 1682 84 112# 143 148 153 +xlt1 1682 88 143# +xlt2 1682 92 148# +xlt3 1682 96 153# + + + + + + + + + + + + + A-18 + + + + + + + + + + Appendix B + + A Skeletal CBIOS + + + + + 1 ; skeletal cbios for first level of cp/m 2.0 alteration + 2 ; + 3 0014 = msize equ 20 ;cp/m version memory size in kilobytes + 4 ; + 5 ; "bias" is address offset from 3400h for memory systems + 6 ; than 16k (referred to as "b" throughout the text) + 7 ; + 8 0000 = bias equ (msize-20)*1024 + 9 3400 = ccp equ 3400h+bias ;base of ccp + 10 3c06 = bdos equ ccp+806h ;base of bdos + 11 4a00 = bios equ ccp+1600h ;base of bios + 12 0004 = cdisk equ 0004h ;current disk number 0=a,..., 15=p + 13 0003 = iobyte equ 0003h ;intel i/o byte + 14 ; + 15 4a00 org bios ;origin of this program + 16 002c = nsects equ ($-ccp)/128 ;warm start sector count + 17 ; + 18 ; jump vector for individual subroutines + 19 4a00 c39c4a jmp boot ;cold start + 20 4a03 c3a64a wboote: jmp wboot ;warm start + 21 4a06 c3114b jmp const ;console status + 22 4a09 c3244b jmp conin ;console character in + 23 4a0c c3374b jmp conout ;console character out + 24 4a0f c3494b jmp list ;list character out + 25 4a12 c34d4b jmp punch ;punch character out + 26 4a15 c34f4b jmp reader ;reader character out + 27 4a18 c3544b jmp home ;move head to home position + 28 4a1b c35a4b jmp seldsk ;select disk + 29 4a1e c37d4b jmp settrk ;set track number + 30 4a21 c3924b jmp setsec ;set sector number + 31 4a24 c3ad4b jmp setdma ;set dma address + 32 4a27 c3c34b jmp read ;read disk + 33 4a2a c3d64b jmp write ;write disk + + B-1 + + + + + + + + + + 34 4a2d c34b4b jmp listst ;return list status + 35 4a30 c3a74b jmp sectran ;sector translate + 36 ; + 37 ; fixed data tables for four-drive standard + 38 ; ibm-compatible 8" disks + 39 ; disk parameter header for disk 00 + 40 4a33 734a0000 dpbase: dw trans, 0000h + 41 4a37 00000000 dw 0000h, 0000h + 42 4a3b f04c8d4a dw dirbf, dpblk + 43 4a3f ec4d704d dw chk00, all00 + 44 ; disk parameter header for disk 01 + 45 4a43 734a0000 dw trans, 0000h + 46 4a47 00000000 dw 0000h, 0000h + 47 4a4b f04c8d4a dw dirbf, dpblk + 48 4a4f fc4d8f4d dw chk01, all01 + 49 ; disk parameter header for disk 02 + 50 4a53 734a0000 dw trans, 0000h + 51 4a57 00000000 dw 0000h, 0000h + 52 4a5b f04c8d4a dw dirbf, dpblk + 53 4a5f 0c4eae4d dw chk02, all02 + 54 ; disk parameter header for disk 03 + 55 4a63 734a0000 dw trans, 0000h + 56 4a67 00000000 dw 0000h, 0000h + 57 4a6b f04c8d4a dw dirbf, dpblk + 58 4a6f 1c4ecd4d dw chk03, all03 + 59 ; + 60 ; sector translate vector + 61 4a73 01070d13 trans: db 1, 7, 13, 19 ;sectors 1, 2, 3, 4 + 62 4a77 19050b11 db 25, 5, 11, 17 ;sectors 5, 6, 7, 8 + 63 4a7b 1703090f db 23, 3, 9, 15 ;sectors 9, 10, 11, 12 + 64 4a7f 1502080e db 21, 2, 8, 14 ;sectors 13, 14, 15, 16 + 65 4a83 141a060c db 20, 26, 6, 12 ;sectors 17, 18, 19, 20 + 66 4a87 1218040a db 18, 24, 4, 10 ;sectors 21, 22, 23, 24 + 67 4a8b 1016 db 16, 22 ;sectors 25, 26 + 68 ; + 69 dpblk: ;disk parameter block, common to all disks + 70 4a8d 1a00 dw 26 ;sectors per track + 71 4a8f 03 db 3 ;block shift factor + 72 4a90 07 db 7 ;block mask + 73 4a91 00 db 0 ;null mask + + B-2 + + + + + + + + + + 74 4a92 f200 dw 242 ;disk size-1 + 75 4a94 3f00 dw 63 ;directory max + 76 4a96 c0 db 192 ;alloc 0 + 77 4a97 00 db 0 ;alloc 1 + 78 4a98 1000 dw 16 ;check size + 79 4a9a 0200 dw 2 ;track offset + 80 ; + 81 ; end of fixed tables + 82 ; + 83 ; individual subroutines to perform each function + 84 boot: ;simplest case is to just perform parameter initialization + 85 4a9c af xra a ;zero in the accum + 86 4a9d 320300 sta iobyte ;clear the iobyte + 87 4aa0 320400 sta cdisk ;select disk zero + 88 4aa3 c3ef4a jmp gocpm ;initialize and go to cp/m + 89 ; + 90 wboot: ;simplest case is to read the disk until all sectors loaded + 91 4aa6 318000 lxi sp, 80h ;use space below buffer for stack + 92 4aa9 0e00 mvi c, 0 ;select disk 0 + 93 4aab cd5a4b call seldsk + 94 4aae cd544b call home ;go to track 00 + 95 ; + 96 4ab1 062c mvi b, nsects ;b counts # of sectors to load + 97 4ab3 0e00 mvi c, 0 ;c has the current track number + 98 4ab5 1602 mvi d, 2 ;d has the next sector to read + 99 ; note that we begin by reading track 0, sector 2 since sector 1 +100 ; contains the cold start loader, which is skipped in a warm start +101 4ab7 210034 lxi h, ccp ;base of cp/m (initial load point) +102 load1: ;load one more sector +103 4aba c5 push b ;save sector count, current track +104 4abb d5 push d ;save next sector to read +105 4abc e5 push h ;save dma address +106 4abd 4a mov c, d ;get sector address to register c +107 4abe cd924b call setsec ;set sector address from register c +108 4ac1 c1 pop b ;recall dma address to b, c +109 4ac2 c5 push b ;replace on stack for later recall +110 4ac3 cdad4b call setdma ;set dma address from b, c +111 ; +112 ; drive set to 0, track set, sector set, dma address set +113 4ac6 cdc34b call read + + B-3 + + + + + + + + + +114 4ac9 fe00 cpi 00h ;any errors? +115 4acb c2a64a jnz wboot ;retry the entire boot if an error occurs +116 ; +117 ; no error, move to next sector +118 4ace e1 pop h ;recall dma address +119 4acf 118000 lxi d, 128 ;dma=dma+128 +120 4ad2 19 dad d ;new dma address is in h, l +121 4ad3 d1 pop d ;recall sector address +122 4ad4 c1 pop b ;recall number of sectors remaining, and current trk +123 4ad5 05 dcr b ;sectors=sectors-1 +124 4ad6 caef4a jz gocpm ;transfer to cp/m if all have been loaded +125 ; +126 ; more sectors remain to load, check for track change +127 4ad9 14 inr d +128 4ada 7a mov a,d ;sector=27?, if so, change tracks +129 4adb fe1b cpi 27 +130 4add daba4a jc load1 ;carry generated if sector<27 +131 ; +132 ; end of current track, go to next track +133 4ae0 1601 mvi d, 1 ;begin with first sector of next track +134 4ae2 0c inr c ;track=track+1 +135 ; +136 ; save register state, and change tracks +137 4ae3 c5 push b +138 4ae4 d5 push d +139 4ae5 e5 push h +140 4ae6 cd7d4b call settrk ;track address set from register c +141 4ae9 e1 pop h +142 4aea d1 pop d +143 4aeb c1 pop b +144 4aec c3ba4a jmp load1 ;for another sector +145 ; +146 ; end of load operation, set parameters and go to cp/m +147 gocpm: +148 4aef 3ec3 mvi a, 0c3h ;c3 is a jmp instruction +149 4af1 320000 sta 0 ;for jmp to wboot +150 4af4 21034a lxi h, wboote ;wboot entry point +151 4af7 220100 shld 1 ;set address field for jmp at 0 +152 ; +153 4afa 320500 sta 5 ;for jmp to bdos + + B-4 + + + + + + + + + +154 4afd 21063c lxi h, bdos ;bdos entry point +155 4b00 220600 shld 6 ;address field of jump at 5 to bdos +156 ; +157 4b03 018000 lxi b, 80h ;default dma address is 80h +158 4b06 cdad4b call setdma +159 ; +160 4b09 fb ei ;enable the interrupt system +161 4b0a 3a0400 lda cdisk ;get current disk number +162 4b0d 4f mov c, a ;send to the ccp +163 4b0e c30034 jmp ccp ;go to cp/m for further processing +164 ; +165 ; +166 ; simple i/o handlers (must be filled in by user) +167 ; in each case, the entry point is provided, with space reserved +168 ; to insert your own code +169 ; +170 const: ;console status, return 0ffh if character ready, 00h if not +171 4b11 ds 10h ;space for status subroutine +172 4b21 3e00 mvi a, 00h +173 4b23 c9 ret +174 ; +175 conin: ;console character into register a +176 4b24 ds 10h ;space for input routine +177 4b34 e67f ani 7fh ;strip parity bit +178 4b36 c9 ret +179 ; +180 conout: ;console character output from register c +181 4b37 79 mov a, c ;get to accumulator +182 4b38 ds 10h ;space for output routine +183 4b48 c9 ret +184 ; +185 list: ;list character from register c +186 4b49 79 mov a, c ;character to register a +187 4b4a c9 ret ;null subroutine +188 ; +189 listst: ;return list status (0 if not ready, 1 if ready) +190 4b4b af xra a ;0 is always ok to return +191 4b4c c9 ret +192 ; +193 punch: ;punch character from register c + + B-5 + + + + + + + + + +194 4b4d 79 mov a, c ;character to register a +195 4b4e c9 ret ;null subroutine +196 ; +197 ; +198 reader: ;reader character into register a from reader device +199 4b4f 3e1a mvi a, 1ah ;enter end of file for now (replace later) +200 4b51 e67f ani 7fh ;remember to strip parity bit +201 4b53 c9 ret +202 ; +203 ; +204 ; i/o drivers for the disk follow +205 ; for now, we will simply store the parameters away for use +206 ; in the read and write subroutines +207 ; +208 home: ;move to the track 00 position of current drive +209 ; translate this call into a settrk call with parameter 00 +210 4b54 0e00 mvi c, 0 ;select track 0 +211 4b56 cd7d4b call settrk +212 4b59 c9 ret ;we will move to 00 on first read/write +213 ; +214 seldsk: ;select disk given by register c +215 4b51 210000 lxi h, 0000h ;error return code +216 4b5d 79 mov a, c +217 4b5e 32ef4c sta diskno +218 4b61 fe04 cpi 4 ;must be between 0 and 3 +219 4b63 d0 rnc ;no carry if 4, 5,... +220 ; disk number is in the proper range +221 4b64 ds 10 ;space for disk select +222 ; compute proper disk parameter header address +223 4b6e 3aef4c lda diskno +224 4b71 6f mov l, a ;l=disk number 0, 1, 2, 3 +225 4b72 2600 mvi h, 0 ;high order zero +226 4b74 29 dad h ;*2 +227 4b75 29 dad h ;*4 +228 4b76 29 dad h ;*8 +229 4b77 29 dad h ;*16 (size of each header) +230 4b78 11334a lxi d, dpbase +231 4b7b 19 dad 0 ;hl=.dpbase (diskno*16) +232 4b7c c9 ret +233 ; + + B-6 + + + + + + + + + +234 settrk: ;set track given by register c +235 4b7d 79 mov a, c +236 4b7e 32e94c sta track +237 4b81 ds 10h ;space for track select +238 4b91 c9 ret +239 ; +240 setsec: ;set sector given by register c +241 4b92 79 mov a, c +242 4b93 32eb4c sta sector +243 4b96 ds 10h ;space for sector select +244 4ba6 c9 ret +245 ; +246 sectran: +247 ;translate the sector given by bc using the +248 ;translate table given by de +249 4ba7 eb xchg ;hl=.trans +250 4ba8 09 dad b ;hl=.trans (sector) +251 4ba9 6e mov l, m ;l=trans (sector) +252 4baa 2600 mvi h, 0 ;hl=trans (sector) +253 4bac c9 ret ;with value in hl +254 ; +255 setdma: ;set dma address given by registers b and c +256 4bad 69 mov l, c ;low order address +257 4bae 60 mov h, b ;high order address +258 4baf 22ed4c shld dmaad ;save the address +259 4bb2 ds 10h ;space for setting the dma address +260 4bc2 c9 ret +261 ; +262 read: ;perform read operation (usually this is similar to write +263 ; so we will allow space to set up read command, then use +264 ; common code in write) +265 4bc3 ds 10h ;set up read command +266 4bd3 c3e64b jmp waitio ;to perform the actual i/o +267 ; +268 write: ;perform a write operation +269 4bd6 ds 10h ;set up write command +270 ; +271 waitio: ;enter here from read and write to perform the actual i/o +272 ; operation. return a 00h in register a if the operation completes +273 ; properly, and 01h if an error occurs during the read or write + + B-7 + + + + + + + + + +274 ; +275 ; in this case, we have saved the disk number in 'diskno' (0, 1) +276 ; the track number in 'track' (0-76) +277 ; the sector number in 'sector' (1-26) +278 ; the dma address in 'dmaad' (0-65535) +279 4be6 ds 256 ;space reserved for i/o drivers +280 4ce6 3e01 mvi a, 1 ;error condition +281 4ce8 c9 ret ;replaced when filled-in +282 ; +283 ; the remainder of the cbios is reserved uninitialized +284 ; data area, and does not need to be a part of the +285 ; system memory image (the space must be available, +286 ; however, between "begdat" and "enddat"). +287 ; +288 4ce9 track: ds 2 ;two bytes for expansion +289 4ceb sector: ds 2 ;two bytes for expansion +290 4ced dmaad: ds 2 ;direct memory address +291 4cef diskno: ds 1 ;disk number 0-15 +292 ; +293 ; scratch ram area for bdos use +294 4cf0= begdat equ $ ;beginning of data area +295 4cf0 dirfb: ds 128 ;scratch directory area +296 4d70 all00: ds 31 ;allocation vector 0 +297 4d8f all01: ds 31 ;allocation vector 1 +298 4dae all02: ds 31 ;allocation vector 2 +299 4dcd all03: ds 31 ;allocation vector 3 +300 4dec chk00: ds 16 ;check vector 0 +301 4dfc chk01: ds 16 ;check vector 1 +302 4e0c chk02: ds 16 ;check vector 2 +303 4e1c chk03: ds 16 ;check vector 3 +304 ; +305 4e2c enddat equ $ ;end of data area +306 013c= datsiz equ $-begdat; ;size of data area +307 4e2c end + +all00 4d70 43 296# +all01 4d8f 48 297# +all02 4dae 53 298# +all03 4dcd 58 299# +bdos 3c06 10# 154 + + B-8 + + + + + + + + + +begdat 4cf0 294# 306 +bias 0000 8# 9 +bios 4a00 11# 15 +boot 4a9c 19 84# +ccp 3400 9# 10 11 16 101 163 +cdisk 0004 12# 87 161 +chk00 4dec 43 300# +chk01 4dfc 48 301# +chk02 4e0c 53 302# +chk03 4e1c 58 303# +conin 4b24 22 175# +conout 4b37 23 180# +const 4b11 21 170# +datsiz 013c 306# +dirbf 4cf0 42 47 52 57 295# +diskno 4cef 217 223 291# +dmaad 4ced 258 290# +dpbase 4a33 40# 230 +dpblk 4a8d 42 47 52 57 69# +enddat 4e2c 305# +gocpm 4aef 88 124 147# +home 4b54 27 94 208# +iobyte 0003 13# 86 +list 4b49 24 185# +listst 4b4b 34 189# +load1 4aba 102# 130 144 +msize 0014 3# 8 +nsects 002c 16# 96 +punch 4b4d 25 193# +read 4bc3 32 113 262# +reader 4b4f 26 198# +sector 4ceb 242 289# +sectran 4ba7 35 246# +seldsk 4b5a 28 93 214# +setdma 4bad 31 110 158 255# +setsec 4b92 30 107 240# +settrk 4b7d 29 140 211 234# +track 4ce9 236 288# +trans 4a73 40 45 50 55 61# +waitio 4be6 266 271# + + B-9 + + + + + + + + + +wboot 4aa6 20 90# 115 +wboote 4a03 20# 150 +write 4bd6 33 268# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + B-10 + + + + + + + + + + Appendix C + + A Skeletal GETSYS/PUTSYS Program + + + + ; combined getsys and putsys programs from + ; Sec 6.4 + ; Start the programs at the base of the TPA + +0100 org 0100h + +0014 = msize equ 20 ;size of cp/m in Kbytes + + ;"bias" is the amount to add to addresses for > 20k + ; (referred to as "b" throughout the text) + +0000 = bias equ (msize-20)*1024 +3400 = ccp equ 3400h+bias +3c00 = bdos equ ccp+0800h +4a00 = bios equ ccp+1600h + + ; getsys programs tracks 0 and 1 to memory at + ; 3880h + bias + + ; register usage + ; a (scratch register) + ; b track count (0...76) + ; c sector count (1...26) + ; d,e (scratch register pair) + ; h,l load address + ; sp set to track address + + gstart: ;start of getsys +0100 318033 lxi sp,ccp-0080h ;convenient place +0103 218033 lxi h,ccp-0080h ;set initial load +0106 0600 mvi b 0 ;start with track + rd$trk: ;read next track +0108 0e01 mvi c,1 ;each track start + rd$sec: + + C-1 + + + + + + + + + +010a cd0003 call read$sec ;get the next sector +010d 118000 lxi d,128 ;offset by one sector +0110 19 dad d ; (hl=hl+128) +0111 0c inr c ;next sector +0112 79 mov a,c ;fetch sector number +0113 felb cpi 27 ;and see if last +0115 da0a01 jc rdsec ;<, do one more + + ;arrive here at end of track, move to next track + +0118 04 inr b ;track = track+1 +0119 78 mov a,b ;check for last +011a fe02 cpi 2 ;track = 2 ? +011c da0801 jc rd$trk ;<, do another + + ;arrive here at end of load, halt for lack of anything + ;better + +011f fb ei +0120 76 hlt + ; putsys program, places memory image + ; starting at + ; 3880h + bias back to tracks 0 and 1 + ; start this program at the next page boundary +0200 org ($+0100h) and 0ff00h + + put$sys: +0200 318033 lxi sp,ccp-0080h ;convenient place +0203 218033 lxi h,ccp-0080h ;start of dump +0206 0600 mvi b,0 ;start with track + wr$trk: +0208 0e01 mvi b,1 ;start with sector + wr$sec: +020a cd0004 call write$sec ;write one sector +020d 118000 lxi d,128 ;length of each +0210 19 dad d ;= + 128 +0211 0c inr c ; = + 1 +0212 79 mov a,c ;see if +0213 felb cpi 27 ;past end of track +0215 da0a02 jc wr$sec ;no, do another + + C-2 + + + + + + + + + + + ;arrive here at end of track, move to next track + +0218 04 inr b ;track = track+1 +0219 78 mov a,b ;see if +021a fe02 cpi 2 ;last track +021c da0802 jc wr$trk ;no, do another + + ; done with putsys, halt for lack of anything + ; better + +02lf fb ei +0220 76 hit + + ;user supplied subroutines for sector read and write + + ; move to next page boundary + +0300 org ($+0100h) and 0ff00h + + read$sec: + ;read the next sector + ;track in , + ;sector in + ;dmaaddr in + +0300 c5 push b +0301 e5 push h + + ;user defined read operation goes here +0302 ds 64 + +0342 el pop h +0343 cl pop b +0344 c9 ret + +0400 org ($+0100h) and 0ff00h ;another page + ;boundary + + write$sec: + + C-3 + + + + + + + + + + + ;same parameters as read$sec + +0400 c5 push b +0401 e5 push h + + ;user defined write operation goes here +0402 ds 64 + +0442 el pop h +0443 cl pop b +0444 c9 ret + + ;end of getsys/putsys program + +0445 end + + + + + + + + + + + + + + + + + + + + + + + + + + C-4 + + + + + + + + + + Appendix D + + The Microcomputer Development System-800 Cold Start Loader for CP/M 2 + + + + 1 title mds cold start loader at 3000h' + 2 ; + 3 ; mds-800 cold start loader for cp/m 2.0 + 4 ; + 5 ; version 2.0 august, 1979 + 6 ; + 7 0000 = false equ 0 + 8 ffff true equ not false + 9 0000 = testing equ false if true, then go to mon80 on errors + 10 ; + 11 if testing + 12 bias equ 03400h + 13 endif + 14 if not testing + 15 0000 = bias equ 0000h + 16 endif + 17 0000 = cpmb equ bias ;base of dos load + 18 0806 = bdos equ 806h+bias ;entry to dos for calls + 19 1880 = bdose equ 1880h+bias ;end of dos load + 20 1600 = boot equ 1600h+bias ;cold start entry point + 21 1603 = rboot equ boot+3 ;warm start entry point + 22 ; + 23 3000 org 03000h ;loaded down from hardware boot at 3000H + 24 ; + 25 1880 = bdosl equ bdose-cpmb + 26 0002 = ntrks equ 2 ;number of tracks to read + 27 0031 = bdoss equ bdosl/128 ;number of sectors in dos + 28 0019 = bdoso equ 25 ;number of bdos sectors on track 0 + 29 0018 = bdos1 equ bdoss-bdoso ;number of sectors on track 1 + 30 ; + 31 f800 = mon80 equ 0f800h ;intel monitor base + 32 ff0f = rmon80 equ 0ff0fh ;restart location for mon80 + 33 0078 = base equ 078h ;'base' used by controller + 34 0079 = rtype equ base+1 ;result type + + D-1 + + + + + + + + + + 35 007b = rbyte equ base+3 ;result byte + 36 007f = reset equ base+7 ;reset controller + 37 ; + 38 0078 = dstat equ base ;disk status port + 39 0079 = ilow equ base+1 ;low iopb address + 40 007a = ihigh equ base+2 ;high iopb address + 41 00ff = bsw equ 0ffh ;boot switch + 42 0003 = recal equ 3h ;recalibrate selected drive + 43 0004 = readf equ 4h ;disk read function + 44 0100 = stack equ 100h ;use end of boot for stack + 45 ; + 46 rstart: + 47 3000 310001 lxi sp,stack; ;in case of call to mon80 + 48 ; clear disk status + 49 3003 db79 in rtype + 50 3005 db7b in rbyte + 51 ; check if boot switch if off + 52 coldstart: + 53 3007 dbff in bsw + 54 3009 e602 ani 02h ;switch on? + 55 300b c20730 jnz coldstart + 56 ; clear the controller + 57 300e d37f out reset ;logic cleared + 58 ; + 59 ; + 60 3010 0602 mvi b,ntrks ;number of tracks to read + 61 3012 214230 lxi h,iopbo + 62 ; + 63 start: + 64 ; + 65 ; read first/next track into cpmb + 66 3015 7d mov a,l + 67 3016 d379 out ilow + 68 3018 7c mov a,h + 69 3019 d37a out ihigh + 70 301b db78 waito: in dstat + 71 301d e604 ani 4 + 72 301f ca1b30 jz waito + 73 ; + 74 ; check disk status + + D-2 + + + + + + + + + + 75 3022 db79 in rtype + 76 3024 e603 ani 11b + 77 3026 fe02 cpi 2 + 78 ; + 79 if testing + 80 cnc rmon80 ;go to monitor if 11 or 10 + 81 endif + 82 if not testing + 83 3028 d20030 jnc rstart ;retry the load + 84 endif + 85 ; + 86 302b db7b in rbyte ;i/o complete, check status + 87 ; if not ready, then go to mon80 + 88 302d 17 ral + 89 302e dc0fff cc rmon80 ;not ready bit set + 90 3031 1f rar ;restore + 91 3032 e61e ani 11110b ;overrun/addr err/seek/crc/xxxx + 92 ; + 93 if testing + 94 cnz rmon80 ;go to monitor + 95 endif + 96 if not testing + 97 3034 c20030 jnz rstart ;retry the load + 98 endif + 99 ; +100 ; +101 3037 110700 lxi d,iopbl ;length of iopb +102 303a 19 dad d ;addressing next iopb +103 303b 05 dcr b ;count down tracks +104 303c c21530 jnz start +105 ; +106 ; +107 ; jmp to boot to print initial message, and set up jmps +108 303f c30016 jmp boot +109 ; +110 ; parameter blocks +111 3042 80 iopbo: db 80h ;iocw, no update +112 3043 04 db readf ;read function +113 3044 19 db bdoso ;#sectors to read on track 0 +114 3045 00 db 0 ;track 0 + + D-3 + + + + + + + + + +115 3046 02 db 2 ;start with sector 2 on track 0 +116 3047 0000 dw cpmb ;start at base of bdos +117 0007 = iopbl equ $-iopbo +118 ; +119 3049 80 iopb1: db 80h +120 304a 04 db readf +121 304b 18 db bdos1 ;sectors to read on track 1 +122 304c 01 db 1 ;track 1 +123 304d 01 db 1 ;sector 1 +124 304e 800c dw cmpb+bdos0*128;base of second read +125 ; +126 3050 end + + +base 0078 33# 34 35 36 38 39 40 +bdos 0806 18# +bdoso 0019 28# 29 113 124 +bdos1 0018 29# 121 +bdose 1880 19# 25 +bdosl 1880 25# 27 +bdoss 0031 27# 29 +bias 0000 12# 15# 17 18 19 20 +boot 1600 20# 21 108 +bsw 00ff 41# 53 +coldstart 3007 52# 55 +cpmb 0000 17# 25 116 124 +dstat 0078 38# 70 +false 0000 7# 8 9 +ihigh 007a 40# 69 +ilow 0079 39# 67 +iopbo 3042 61 111# 117 +iopb1 3049 119# +iopbl 0007 101 117# +mon80 f800 31# +ntrks 0002 26# 60 +rboot 1603 21# +rbyte 007b 35# 50 86 +readf 0004 43# 112 120 +recal 0003 42# +reset 007f 36# 57 + + D-4 + + + + + + + + + +rmon80 ff0f 32# 80 89 94 +rstart 3000 46# 83 97 +rtype 0079 34# 49 75 +stack 0100 44# 47 +start 3015 63# 104 +testing 0000 9# 11 14 79 82 93 96 +true ffff 8# +waito 301b 70# 72 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + D-5 + + + + + + + + + + Appendix E + + A Skeletal Cold Start Loader + + + + ;this is a sample cold start loader, which, when + ;modified + ;resides on track 00, sector 01 (the first sector on the + ;diskette). we assume that the controller has loaded + ;this sector into memory upon system start-up (this + ;program can be keyed-in, or can exist in read-only + ;memory + ;beyond the address space of the cp/m version you are + ;running). the cold start loader brings the cp/m system + ;into memory at "loadp" (3400h + "bias"). in a 20k + ;memory system, the value of "bias" is 000h, with + ;large + ;values for increased memory sizes (see section 2). + ;after + ;loading the cp/m system, the cold start loader + ;branches + ;to the "boot" entry point of the bios, which beings at + ;"bios" + "bias". the cold start loader is not used un- + ;til the system is powered up again, as long as the bios + ;is not overwritten. the origin is assumed at 0000h, and + ;must be changed if the controller brings the cold start + ;loader into another area, or if a read-only memory + ;area + ;is used. + +0000 org 0 ;base of ram in + ;cp/m + +0014 = msize equ 20 ;min mem size in + ;kbytes +0000 = bias equ (msize-20)*1024 ;offset from 20k + ;system +3400 = ccp equ 3400h+bias ;base of the ccp +4a00 = bios equ ccp+1600h ;base of the bios + + E-1 + + + + + + + + + +0300 = biosl equ 0300h ;length of the bios +4a00 = boot equ bios +1900 = size equ bios+biosl-ccp ;size of cp/m + ;system +0032 = sects equ size/128 ;# of sectors to load + + ; begin the load operation + + cold: +0000 010200 lxi b,2 ;b=0, c=sector 2 +0003 1632 mvi d,sects ;d=# sectors to + ;load +0005 210034 lxi h,ccp ;base transfer + ;address + lsect: ;load the next sector + + ; insert inline code at this point to + ; read one 128 byte sector from the + ; track given in register b, sector + ; given in register c, + ; into the address given by + ;branch to location "cold" if a read error occurs + ; + ; + ; user supplied read operation goes + ; here... + ; + ; + +0008 c36b00 jmp past$patch ;remove this + ;when patched +000b ds 60h + + past$patch: + ;go to next sector if load is incomplete +006b 15 dcr d ;sects=sects-1 +006c ca004a jz boot ;head for the bios + + ; more sectors to load + ; + + E-2 + + + + + + + + + + ;we aren't using a stack, so use as scratch + ;register + ; to hold the load address increment + +006f 318000 lxi sp,128 ;128 bytes per + ;sector +0072 39 dad sp ; = + + 128 +0073 0c inr c ;sector=sector + 1 +0074 79 mov a,c +0075 felb cpi 27 ;last sector of + ;track? +0077 da0800 jc lsect ;no, go read + ;another + + ;end of track, increment to next track + +007a 0e01 mvi c,l ;sector = 1 +007c 04 inr b ;track = track + 1 +007d c30800 jmp lsect ;for another group +0080 end ;of boot loader + + + + + + + + + + + + + + + + + + + + + E-3 + + + + + + + + + + Appendix F + + CP/M Disk Definition Library + + + 1:; CP/M 2.0 disk re-definition library + 2:; + 3:; Copyright (c) 1979 + 4:; Digital Research + 5:; Box 579 + 6:; Pacific Grove, CA + 7:; 93950 + 8:; + 9:; CP/M logical disk drives are defined using the + 10:; macros given below, where the sequence of calls + 11:; is: + 12:; + 13:; disks n + 14:; diskdef parameter-list-0 + 15:; diskdef parameter-list-1 + 16:; ... + 17:; diskdef parameter-list-n + 18:; endef + 19:; + 20:; where n is the number of logical disk drives attached + 21:; to the CP/M system, and parameter-list-i defines the + 22:; characteristics of the ith drive (i=0,1,...,n-1) + 23:; + 24:; each parameter-list-i takes the form + 25:; dn,fsc,lsc,[skf],bls,dks,dir,cks,ofs,[0] + 26:; where + 27:; dn is the disk number 0,1,...,n-1 + 28:; fsc is the first sector number (usually 0 or 1) + 29:; lsc is the last sector number on a track + 30:; skf is optional "skew factor" for sector translate + 31:; bls is the data block size (1024,2048,...,16384) + 32:; dks is the disk size in bls increments (word) + 33:; dir is the number of directory elements (word) + 34:; cks is the number of dir elements to checksum + 35:; ofs is the number of tracks to skip (word) + + F-1 + + + + + + + + + + 36:; [0] is an optional 0 which forces 16K/directory end + 37:; + 38:; for convenience, the form + 39:; dn,dm + 40:; defines disk dn as having the same characteristics as + 41:; a previously defined disk dm. + 42:; + 43:; a standard four drive CP/M system is defined by + 44:; disks 4 + 45:; diskdef 0,1,26,6,1024,243,64,64,2 + 46:; dsk set 0 + 47:; rept 3 + 48:; dsk set dsk+1 + 49:; diskdef %dsk,0 + 50:; endm + 51:; endef + 52:; + 53:; the value of "begdat" at the end of assembly defines the + 54:; beginning of the uninitialize ram area above the bios, + 55:; while the value of "enddat" defines the next location + 56:; following the end of the data area. the size of this + 57:; area is given by the value of "datsiz" at the end of the + 58:; assembly. note that the allocation vector will be quite + 59:; large if a large disk size is defined with a small block + 60:; size. + 61:; + 62:dskhdr macro dn + 63:;; define a single disk header list + 64:dpe&dn: dw xlt&dn,0000h ;translate table + 65: dw 0000h,0000h ;scratch area + 66: dw dirbuf,dpb&dn ;dir buff,parm block + 67: dw csv&dn,alv&dn ;check, alloc vectors + 68: endm + 69:; + 70:disks macro nd + 71:;; define nd disks + 72:ndisks set nd ;;for later reference + 73:dpbase equ $ ;base of disk parameter blocks + 74:;; generate the nd elements + 75:disknxt set 0 + + F-2 + + + + + + + + + + 76: rept nd + 77: dskhdr %dsknxt + 78:dsknxt set dsknxc+1 + 79: endm + 80: endm + 81:; + 82:dpbhdr macro dn + 83:dpb&dn equ $ ;disk parm block + 84: endm + 85:; + 86:ddb macro data,comment + 87:;; define a db statement + 88: db data comment + 89: endm + 90:; + 91:ddw macro data,comment + 92:;; define a dw statement + 93: dw data comment + 94: endm + 95:; + 96:gcd macro m,n + 97:;; greatest common divisor of m,n + 98:;; produces value gcdn as result + 99:;; (used in sector translate table generation) +100:gcdm set m ;;variable for m +101:gcdn set n ;;variable for n +102:gcdr set 0 ;;variable for r +103: rept 65535 +104:gcdx set gcdm/gcdn +105:gcdr set gcdm-gcdx*gcdn +106: if gcdr = 0 +107: exitm +108: endif +109:gcdm set gcdn +110:gcdn set gcdr +111: endm +112: endm +113:; +114:diskdef macro dn,fsc,lsc,skf,bls,dks,dir,cks,ofs,k16 +115:;; generate the set statements for later tables + + F-3 + + + + + + + + + +116: if nul lsc +117:;; current disk dn same as previous fsc +118:dpb&dn equ dpb&fsc ;equivalent parameters +119:als&dn equ als&fsc ;same allocation vector size +120:css&dn equ css&fsc ;same checksum vector size +121:xlt&dn equ xlt&fsc ;same translate table +122: else +123:secmax set lsc-(fsc) ;;sectors 0...secmax +124:sectors set secmax+1 ;;number of sectors +125:als&dn set (dks)/8 ;;size of allocation vector +126: if ((dks)mod8) ne 0 +127:als&dn set als&dn+1 +128: endif +129:css&dn set (cks)/4 ;;number of checksum elements +130:;; generate the block shift value +131:blkval set bls/128 ;;number of sectors/block +132:blkshf set 0 ;;counts right 0's in blkval +133:blkmsk set 0 ;;fills with l's from right +134: rept 16 ;;once for each bit position +135: if blkval=1 +136: exitm +137: endif +138:;; otherwise, high order 1 not found yet +139:blkshf set blkshf+1 +140:blkmsk set (blkmsk shl l) or l +141:blkval set blkval/2 +142: endm +143:;; generate the extent mask byte +144:blkval set bls/1024 ;;number of kilobytes/block +145:extmsk set 0 ;;fill from right with l's +146: rept 16 +147: if blkval=1 +148: exitm +149: endif +150:;; otherwise more to shift +151:extmsk set (extmsk shl l) or l +152:blkval set blkval/2 +153: endm +154:;; may be double byte allocation +155: if (dks)>256 + + F-4 + + + + + + + + + +156:extmsk set (extmsk shr l) +157: endif +158:;; may be optional [0] in last position +159: if not nul k16 +160:extmsk set k16 +161: endif +162:;; now generate directory reservation bit vector +163:dirrem set dir ;;#remaining to process +164:dirbks set bls/32 ;;number of entries per block +165:dirblk set 0 ;;fill with l's on each loop +166: rept 16 +167: if dirrem=0 +168: exitm +169: endif +170:;; not complete, iterate once again +171:;; shift right and add 1 high order bit +172:dirblk set (dirblk shr l) or 8000h +173: if dirrem>dirbks +174:dirrem set dirrem-dirbks +175: else +176:direem set 0 +177: endif +178: endm +179: dpbhdr dn ;;generate equ $ +180: ddw %sectors,<;sec per track> +181: ddb %blkshf,<;block shift> +182: ddb %blkmsk,<;block mask> +183: ddb %extmsk,<;extnt mask> +184: ddw %(dks)-1,<;disk size-1> +185: ddw %(dir)-1, +186: ddb %dirblk shr 8,<;alloc0> +187: ddb %dirblk and 0ffh,<;allocl> +188: ddw %(cks)/4,<;check size> +189: ddw %ofs,<;offset> +190:;; generate the translate table, if requested +191: if nul skf +192:xlt&dn equ 0 ;no xlate table +193: else +194: if skf = 0 +195:xlt&dn equ 0 ;no xlate table + + F-5 + + + + + + + + + +196: else +197:;; generate the translate table +198:nxtsec set 0 ;;next sector to fill +199:nxtbas set 0 ;;moves by one on overflow +200: gcd %sectors,skf +201:;; gcdn = gcd(sectors,skew) +202:neltst set sectors/gcdn +203:;; neltst is number of elements to generate +204:;; before we overlap previous elements +205:nelts set neltst ;;counter +206:xlt&dn equ $ ;;translate table +207: rept sectors ;;once for each sector +208: if sectors<256 +209: ddb %nxtsec+(fsc) +210: else +211: ddw %nxtsec+(fsc) +212: endif +213:nxtsec set nxtsec+(skf) +214: if nxtsec>=sectors +215:nxtsec set nxtsec-sectors +216: endif +217:nelts set nelts-1 +218: if nelts = 0 +219:nxtbas set nxtbas+1 +220:nxtsec set nxtbas +221:nelts set neltst +222: endif +223: endm +224: endif ;;end of nul fac test +225: endif ;;end of nul bls test +226: endm +227:; +228:defds macro lab,space +229:lab: ds space +230: endm +231:; +232:lds macro lb,dn,val +233: defds lb&dn,%val&dn +234: endm +235:; + + F-6 + + + + + + + + + +236:endef macro +237:;; generate the necessary ram data areas +238:begdat equ $ +239:dirbuf: ds 128 ;directory access buffer +240:dsknxt set 0 +241: rept ndisks ;;once for each disk +242: lds alv,%dsknxt,als +243: lds csv,%dsknxt,ccs +244:dsknxt set dsknxt+1 +245: endm +246:enddat equ $ +247:datsiz equ $-begdat +248:;; db 0 at this point forces hex record +249: endm + + + + + + + + + + + + + + + + + + + + + + + + + + + + F-7 + + + + + + + + + + Appendix G + + Blocking and Deblocking Algorithms + + + + 1 ; + 2 ; + 3 ; sector deblocking algorithms for cp/m 2.0 + 4 ; + 5 ; + 6 ; + 7 ; utility macro to compute sector mask + 8 smask macro hblk + 9 ;; compute log2(hblk), return @x as result + 10 ;; (2 ** @x = hblk on return) + 11 @y set hblk + 12 @x set 0 + 13 ;; count right shifts of @y until = 1 + 14 rept 8 + 15 if @y = 1 + 16 exitm + 17 endif + 18 ;; @y is not 1, shift right one position + 19 @y set @y shr 1 + 20 @x set @x + 1 + 21 endm + 22 endm + 23 ; + 24 ; + 25 ; + 26 ; cp/m to host disk constants + 27 ; + 28 ; + 29 0800 = blksiz equ 2048 ;cp/m allocation size + 30 0200 = hstsiz equ 512 ;host disk sector size + 31 0014 = hstspt equ 20 ;host disk sectors/trk + 32 0004 = hstblk equ hstsiz/128 ;cp/m sects/host buff + 33 0050 = cpmspt equ hstblk * hstspt ;cp/m sectors/track + 34 0003 = secmsk equ hstblk-1 ;sector mask + + G-1 + + + + + + + + + + 35 smask hstblk ;compute sector mask + 36 0002 = secshf equ @x ;log2(hstblk) + 37 ; + 38 ; + 39 ; + 40 ; bdos constants on entry to write + 41 ; + 42 ; + 43 0000 = wrall equ 0 ;write to allocated + 44 0001 = wrdir equ 1 ;write to directory + 45 0002 = wrual equ 2 ;write to unallocated + 46 ; + 47 ; + 48 ; + 49 ; the bdos entry points given below show the + 50 ; code which is relevant to deblocking only. + 51 ; + 52 ; + 53 ; + 54 ; diskdef macro, or hand coded tables go here + 55 0000 = dpbase equ $ ;disk param block base + 56 ; + 57 boot: + 58 wboot: + 59 ;enter here on system boot to initialize + 60 0000 af xra a ;0 to accumulator + 61 0001 326a01 sta hstact ;host buffer inactive + 62 0004 326c01 sta unacnt ;clear unalloc count + 63 0007 c9 ret + 64 ; + 65 home: + 66 ;home the selected disk + 67 home: + 68 0008 3a6b01 lda hstwrt ;check for pending write + 69 000b b7 ora a + 70 000c c21200 jnz homed + 71 000f 326a01 sta hstact ;clear host active flag + 72 homed: + 73 0012 c9 ret + 74 ; + + G-2 + + + + + + + + + + 75 seldsk: + 76 ;select disk + 77 0013 79 mov a,c ;selected disk number + 78 0014 326101 sta sekdsk ;seek disk number + 79 0017 6f mov l,a ;disk number to hl + 80 0018 2600 mvi h,0 + 81 rept 4 ;multiply by 16 + 82 dad h + 83 endm + 84 001a+29 dad h + 85 001b+29 dad h + 86 001c+29 dad h + 87 001d+29 dad h + 88 001e 110000 lxi d,dpbase ;base of parm block + 89 0021 19 dad d ;hl=.dpb(curdsk) + 90 0022 c9 ret + 91 ; + 92 settrk: + 93 ;set track given by registers bc + 94 0023 60 mov h,b + 95 0024 69 mov l,c + 96 0025 226201 shld sektrk ;track to seek + 97 0028 c9 ret + 98 ; + 99 setsec: +100 ;set sector given by register c +101 0029 79 mov a,c +102 002a 326401 sta seksec ;sector to seek +103 002d c9 ret +104 ; +105 setdma: +106 ;set dma address given by bc +107 002e 60 mov h,b +108 002f 69 mov l,c +109 0030 227501 shld dmaadr +110 0033 c9 ret +111 ; +112 sectran: +113 ;translate sector number bc +114 0034 60 mov h,b + + G-3 + + + + + + + + + +115 0035 69 mov l,c +116 0036 c9 ret +117 ; +118 ; +119 ; +120 ; the read entry point takes the place of +121 ; the previous bios definition for read. +122 ; +123 ; +124 read: +125 ;read the selected cp/m sector +126 0037 af xra a +127 0038 326c01 sta unacnt +128 003b 3e01 mvi a,1 +129 003d 327301 sta readop ;read operation +130 0040 327201 sta rsflag ;must read data +131 0043 3e02 mvi a,wrual +132 0045 327401 sta wrtype ;treat as unalloc +133 0048 c3b600 jmp rwoper ;to perform the read +134 ; +135 ; +136 ; +137 ; the write entry point takes the place of +138 ; the previous bios definition for write. +139 ; +140 ; +141 write: +142 ;write the selected cp/m sector +143 004b af xra a ;0 to accumulator +144 004c 327301 sta readop ;not a read operation +145 004f 79 mov a,c ;write type in c +146 0050 327401 sta wrtype +147 0053 fe02 cpi wrual ;write unallocated? +148 0050 c26f00 jnz chkuna ;check for unalloc +149 ; +150 ; write to unallocated, set parameters +151 0058 3e10 mvi a,blksiz/128 ;next unalloc recs +152 005a 326c01 sta unacnt +153 005d 3a6101 lda sekdsk ;disk to seek +154 0060 326d01 sta unadsk ;unadsk = sekdsk + + G-4 + + + + + + + + + +155 0063 2a6201 lhld settrk +156 0066 226e01 shld unatrk ;unatrk = sectrk +157 0069 3a6401 lda seksec +158 006c 327001 sta unasec ;unasec = seksec +159 ; +160 chkuna: +161 ;check for write to unallocated sector +162 006f 3a6c01 lda unacnt ;any unalloc remain? +163 0072 b7 ora a +164 0073 caae00 jz alloc ;skip if not +165 ; +166 ; more unallocated records remain +167 0076 3d dcr a ;unacnt = unacnt-1 +168 0077 326c01 sta unacnt +169 007a 3a6101 lda sekdsk ;same disk? +170 007d 216d01 lxi h,unadsk +171 0080 be cmp m ;sekdsk = unadsk? +172 0081 c2ae00 jnz alloc ;skip if not +173 ; +174 ; disks are the same +175 0084 216e01 lxi h,unatrk +176 0087 cd5301 call sektrkcmp ;saektrk = unatrk? +177 008a c2ae00 jnz alloc ;skip if not +178 ; +179 ; tracks are the same +180 008d 3a6401 lda seksec ;same sector? +181 0090 217001 lxi h,unasec +182 0093 be cmp m ;seksec = unasec? +183 0094 c2ae00 jnz alloc ;skip if not +184 ; +185 ; match, move to next sector for future ref +186 0097 34 inr m ;unasec = unasec+1 +187 0098 7e mov a,m ;end of track? +188 0099 fe50 cpi cpmspt ;count cp/m sectors +189 009b daa700 jc noovf ;skip if no overflow +190 ; +191 ; overflow to next track +192 009e 3600 mvi m,o ;unasec = 0 +193 00a0 2a6e01 lhld unatrk +194 00a3 23 inx h + + G-5 + + + + + + + + + +195 00a4 226e01 shld unatrk ;unatrk = unatrk+1 +196 ; +197 noovf: +198 ;match found, mark as unnecessary read +199 00a7 af xra a ;0 to accumulator +200 00ab 327201 sta rsflag ;rsflag = 0 +201 00ab c3b600 jmp rwoper ;to perform the write +202 ; +203 alloc: +204 ;not an unallocated record, requires pre-read +205 00ae af xra a ;0 to accum +206 00af 326c01 sta unacnt ;unacnt = 0 +207 00b2 3c inr a ;1 to accum +208 00b3 327201 sta rsflag = 1 ;rsflag = 1 +209 ; +210 ; +211 ; +212 ; common code for read and write follows +213 ; +214 ; +215 rwoper: +216 ;enter here to perform the read-write +217 00b6 af xra a ;zero to accum +218 00b7 327101 sta erflag ;no errors (yet) +219 00ba 3a6401 lda seksec ;compute host sector +220 rept secshf +221 ora a ;carry = 0 +222 rar ;shift right +223 endm +224 00bd+b7 ora a ;carry = 0 +225 00be+1f rar ;shift right +226 00bf+b7 ora a ;carry = 0 +227 00c0+1f rar ;shift right +228 00c1 326901 sta sekhst ;host sector to seek +229 ; +230 ; active host sector? +231 00c4 216a01 lxi h,hstact ;host active flag +232 00c7 7e mov a,m +233 00c8 3601 mvi m,1 ;always becomes 1 +234 00ca b7 ora a ;was it already? + + G-6 + + + + + + + + + +235 00cb caf200 jz filhst ;fill host if not +236 ; +237 ; host buffer active, same as seek buffer? +238 00ce 3a6101 lda sekdsk +239 00d1 216501 lxi h,hstdsk ;same disk? +240 00d4 be cmp m ;sekdsk = hstdsk? +241 00d5 c2eb00 jnz nomatch +242 ; +243 ; same disk, same track? +244 00d8 216601 lxi h,hsttrk +245 00db cd5301 call sektrkcmp ;sektrk = hsttrk? +246 00de c2eb00 jnz nomatch +247 ; +248 ; same disk, same track, same buffer? +249 00e1 3a6901 lda sekhst +250 00e4 216801 lxi h,hstsec ;sekhst = hstsec? +251 00e7 be cmp m +252 00e8 ca0f01 jz match ;skip if match +253 ; +254 nomatch: +255 ;proper disk, but not correct sector +256 00eb 3a6b01 lda hstwrt ;host written? +257 00ee b7 ora a +258 00ef c45f01 cnz writehst ;clear host buff +259 ; +260 filhst: +261 ;may have to fill the host buffer +262 00f2 3a6101 lda sekdsk +263 00f5 326501 sta hstdsk +264 00f8 2a6201 lhld sektrk +265 00fb 226601 shld hsttrk +266 00fe 3a6901 lda sekhst +267 0101 326801 sta hstsec +268 0104 3a7201 lda rsflag ;need to read? +269 0107 b7 ora a +270 0108 c46001 cnz readhst ;yes, if 1 +271 010b af xra a ;0 to accum +272 010c 326b01 sta hstwrt ;no pending write +273 ; +274 match: + + G-7 + + + + + + + + + +275 ;copy data to or from buffer +276 010f 3a6401 lda seksec ;mask buffer number +277 0112 e603 ani secmsk ;least signif bits +278 0114 6f mov l,a ;ready to shift +279 0115 2600 mvi h,0 ;double count +280 rept 7 ;shift left 7 +281 dad h +282 endm +283 0117+29 dad h +284 0118+29 dad h +285 0119+29 dad h +286 011a+29 dad h +287 011b+29 dad h +288 011c+29 dad h +289 011d+29 dad h +290 ; hl has relative host buffer address +291 011e 117701 lxi d,hstbuf +292 0121 19 dad d ;hl = host address +293 0122 eb xchg ;now in de +294 0123 2a7501 lhld dmaadr ;get/put cp/m data +295 0126 0e80 mvi c,128 ;length of move +296 0128 3a7301 lda readop ;which way? +297 012b b7 ora a +298 012c c23501 jnz rwmove ;skip if read +299 ; +300 ; write operation, mark and switch direction +301 012f 3e01 mvi a,1 +302 0131 326b01 sta hstwrt ;hstwrt = 1 +303 0134 eb xchg ;source/dest swap +304 ; +305 rwmove: +306 ;c initially 128, de is source, hl is dest +307 0135 1a ldax d ;source character +308 0136 13 inx d +309 0137 77 mov m,a ;to dest +310 0138 23 inx h +311 0139 od dcr c ;loop 128 times +312 013a c23501 jnz rwmove +313 ; +314 ; data has been moved to/from host buffer + + G-8 + + + + + + + + + +315 013d 3a7401 lda wrtype ;write type +316 0140 fe01 cpi wrdir ;to directory? +317 0142 3a7101 lda erflag ;in case of errors +318 0145 c0 rnz ;no further processing +319 ; +320 ; clear host buffer for directory write +321 0146 b7 ora a ;errors? +322 0147 c0 rnz ;skip if so +323 0148 af xra a ;0 to accum +324 0149 326b01 sta hstwrt ;buffer written +325 014c cd5f01 call writehst +326 014f 3a7101 lda erflag +327 0152 c9 +328 ; +329 ; +330 ; +331 ; utility subroutine for 16-bit compare +332 ; +333 ; +334 sektrkcmp: +335 ;hl = .unatrk or .hsttrk, compare with sektrk +336 0153 eb xchg +337 0154 216201 lxi h,sektrk +338 0157 1a ldax d ;low byte compare +339 0158 be cmp m ;same? +340 0159 c0 rnz ;return if not +341 ; low bytes equal, test high 1s +342 015a 13 inx d +343 015b 23 inx h +344 015c 1a ldax d +345 015d be cmp m ;sets flags +346 015e c9 ret +347 ; +348 ; +349 ; +350 ; writehst performs the physical write to +351 ; the host disk, readhst reads the physical +352 ; disk. +353 ; +354 ; + + G-9 + + + + + + + + + +355 writehst: +356 ;hstdsk = host disk #, hsttrk = host track #, +357 ;hstsec = host sect #. write "hstsiz" bytes +358 ;from hstbuf and return error flag in erflag. +359 ;return erflag non-zero if error +360 015f c9 ret +361 ; +362 readhst: +363 ;hstdsk = host disk #, hsttrk = host track #, +364 ;hstsec = host sect #. read "hstsiz" bytes +365 ;into hstbuf and return error flag in erflag. +366 0160 c9 ret +367 ; +368 ; +369 ; +370 ; uninitialized ram data areas +371 ; +372 ; +373 ; +374 0161 sekdsk: ds 1 ;seek disk number +375 0162 sektrk: ds 2 ;seek track number +376 0164 seksec: ds 1 ;seek sector number +377 ; +378 0165 hstdsk: ds 1 ;host disk number +379 0166 hsttrk: ds 2 ;host track number +380 0168 hstsec: ds 1 ;host sector number +381 ; +382 0169 sekhst: ds 1 ;seek shr secshf +383 016a hstact: ds 1 ;host active flag +384 016b hstwrt: ds 1 ;host written flag +385 ; +386 016c unacnt: ds 1 ;unalloc rec cnt +387 016d unadsk: ds 1 ;last unalloc disk +388 016e unatrk: ds 2 ;last unalloc track +389 0170 unasec: ds 1 ;last unalloc sector +390 ; +391 0171 erflag: ds 1 ;error reporting +392 0172 rsflag: ds 1 ;read sector flag +393 0173 readop: ds 1 ;1 if read operation +394 0174 wrtype: ds 1 ;write operation type + + G-10 + + + + + + + + + +395 0175 dmaadr: ds 2 ;last dma address +396 0177 hstbuf: ds hstsiz ;host buffer +397 ; +398 ; +399 ; +400 ; the endef macro invocation goes here +401 ; +402 ; +403 0377 end + + + + + + + + + +alloc 00ae 164 172 177 183 203# +blksiz 0800 29# 151 +boot 0000 57# +chkuna 006f 148 160# +cpmspt 0050 33# 188 +dmaadr 0175 109 294 395# +dpbase 0000 55# 88 +erflag 0171 218 317 326 391# +filhst 00f2 235 260# +home 0008 65# 67# +homed 0012 70 72# +hstact 016a 61 71 231 383# +hstblk 0004 32# 33 34 35 +hstbuf 0177 291 396# +hstdsk 0165 239 263 378# +hstsec 0168 250 267 380# +hstsiz 0200 30# 32 396 +hstspt 0014 31# 33 +hsttrk 0166 244 265 379# +hstwrt 016b 68 256 272 302 324 384# +match 010fl 252 274# +nomatch 00eb 241 246 254# + + G-11 + + + + + + + + + +noovf 00a7 189 197# +read 0037 124# +readhst 0160 270 362# +readop 0173 129 144 296 393# +rsflag 0172 130 200 208 268 392# +rwmove 0135 298 305# 312 +rwoper 00b6 133 201 215# +secmsk 0003 34# 277 +secshf 0002 36# 220 +sectran 0034 112# +sekdsk 0161 78 153 169 238 262 374# +sekhst 0169 228 249 266 382# +seksec 0164 102 157 180 219 276 376# +sektrk 0162 96 155 264 337 375# +sektrkcmp 0153 176 245 334# +seldsk 0013 75# +setdma 002e 105# +setsec 0029 99# +settrk 0023 92# +unacnt 016c 62 127 152 162 168 206 386# +unadsk 016d 154 170 387# +unasec 0170 158 181 389# +unatrk 016e 156 175 193 195 388# +wboot 0000 58# +wrall 0000 43# +wrdir 0001 44# 316 +write 004b 141# +writehst 015f 258 325 355# +wrtype 0174 132 146 315 394# +wrual 0002 45# 131 147 + + + + + + + + + + + + G-12 + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/part2.tex b/Source/Doc/CPM 22 Manual - Testing/part2.tex new file mode 100644 index 00000000..75330cc4 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/part2.tex @@ -0,0 +1,2 @@ +.nx appa.tex + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/part2.txt b/Source/Doc/CPM 22 Manual - Testing/part2.txt new file mode 100644 index 00000000..0d8c02cf --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/part2.txt @@ -0,0 +1,3009 @@ + N + + + + + + + Appendix A + + The Microcomputer Development System Basic Input/Output System (BIOS) + + + + 1 ; mds-800 i/o drivers for cp/m 2.2 + 2 ; (four drive single density version) + 3 ; + 4 ; version 2.2 february, 1980 + 5 ; + 6 0016 = vers equ 22 ;version 2.2 + 7 ; + 8 ; copyright (c) 1980 + 9 ; digital research + 10 ; box 579, pacific grove + 11 ; california, 93950 + 12 ; + 13 ; + 14 ffff = true equ 0fffh ;value of "true" + 15 0000 = false equ not true ;"false" + 16 0000 = test equ false ;true if test bios + 17 ; + 18 if test + 19 bias equ 03400h ;base of ccp in test system + 20 endif + 21 if not test + 22 0000 = bias equ 0000h ;generate relocatable cp/m system + 23 endif + 24 ; + 25 1600 = patch equ 1600h + 26 ; + 27 1600 org patch + 28 0000 = cpmb equ $-patch ;base of cpm console processor + 29 0806 = bdos equ 806h+cpmb ;basic dos (resident portion) + 30 1600 = cpml equ $-cpmb ;length (in bytes) of cpm system + 31 002c = nsects equ cpml/128 ;number of sectors to load + 32 0002 = offset equ 2 ;number of disk tracks used by cp/m + 33 0004 = cdisk equ 0004h ;address of last logged disk on warm start + 34 0080 = buff equ 0080h ;default buffer address + + A-1 + + + + + + + + + + 35 000a = retry equ 10 ;max retries on disk i/o before error + 36 ; + 37 ; perform following functions + 38 ; boot cold start + 39 ; wboot warm start (save i/o byte) + 40 ; (boot and wboot are the same for mds) + 41 ; const console status + 42 ; reg-a = 00 if no character ready + 43 ; reg-a = ff if character ready + 44 ; conin console character in (result in reg-a) + 45 ; conout console character out (char in reg-c) + 46 ; list list out (char in reg-c) + 47 ; punch punch out (char in reg-c) + 48 ; reader paper tape reader in (result to reg-a) + 49 ; home move to track 00 + 50 ; + 51 ; (the following calls set-up the io parameter block for the + 52 ; mds, which is used to perform subsequent reads and writes) + 53 ; seldsk select disk given by reg-c (0, 1, 2...) + 54 ; settrk set track address (0,...76) for subsequent read-write + 55 ; setsec set sector address (1,...,26) for subsequent read-write + 56 ; setdma set subsequent dma address (initially 80h) + 57 ; + 58 ; (read and write assume previous calls to set up the io parameters) + 59 ; read read track/sector to preset dma address + 60 ; write track/sector from preset dma address + 61 ; + 62 ; jump vector for individual routines + 63 1600 c3b316 jmp boot + 64 1603 c3c316 wboote: jmp wboot + 65 1606 c36117 jmp const + 66 1609 c36417 jmp conin + 67 160c c36a17 jmp conout + 68 160f c36d17 jmp list + 69 1612 c37217 jmp punch + 70 1615 c37517 jmp reader + 71 1618 c37817 jmp home + 72 161b c37d17 jmp seldsk + 73 161e c3a717 jmp settrk + 74 1621 c3ac17 jmp setsec + + A-2 + + + + + + + + + + 75 1624 c3bb17 jmp setdma + 76 1627 c3c117 jmp read + 77 162a c3ca17 jmp write + 78 162d c37017 jmp listst ;list status + 79 1630 c3b117 jmp sectran + 80 ; + 81 maclib diskdef ;load the disk definition library + 82 disks 4 ;four disks + 83 1633+= dpbase equ $ ;base of disk parameter blocks + 84 1633+82160000 dpe0: dw xlt0, 0000h ;translate table + 85 1637+00000000 dw 0000h, 0000h ;scratch area + 86 163b+6e187316 dw dirbuf, dpb0 ;dir buff, parm block + 87 163f+0d19ee18 dw csv0, alv0 ;check, alloc vectors + 88 1643+82160000 dpe1: dw xlt1, 0000h ;translate table + 89 1647+00000000 dw 0000h, 0000h ;scratch area + 90 164b+6e187316 dw dirbuf, dpb1 ;dir buff, parm block + 91 164f+3c191d19 dw csv1, alv1 ;check, alloc vectors + 92 1653+82160000 dpe2: dw xlt2, 0000h ;translate table + 93 1657+00000000 dw 0000h, 0000h ;scratch area + 94 165b+6e187316 dw dirbuf, dpb2 ;dir buff, parm block + 95 165f+6b194c19 dw csv2, alv2 ;check, alloc vectors + 96 1663+82160000 dpe3: dw xlt3, 0000h ;translate table + 97 1667+00000000 dw 0000h, 0000h ;scratch area + 98 166b+6e187316 dw dirbuf, dpb3 ;check, alloc block + 99 166f+9a197b19 dw csv3, alv3 ;dir buff, parm vectors +100 diskdef 0, 1, 26, 6, 1024, 243, 64, 64, offset +101 1673+= dpb0 equ $ ;disk parm block +102 1673+1a00 dw 26 ;sec per track +103 1675+03 db 3 ;block shift +104 1676+07 db 7 ;block mask +105 1677+00 db 0 ;extnt mask +106 1678+f200 dw 242 ;disk size-1 +107 167a+3f00 dw 63 ;directory max +108 167c+c0 db 192 ;alloc0 +109 167d+00 db 0 ;alloc1 +110 167e+1000 dw 16 ;check size +111 1680+0200 dw 2 ;offset +112 1682+= xlt0 equ $ ;translate table +113 1682+01 db 1 +114 1683+07 db 7 + + A-3 + + + + + + + + + +115 1684+0d db 13 +116 1685+13 db 19 +117 1686+19 db 25 +118 1687+05 db 5 +119 1688+0b db 11 +120 1689+11 db 17 +121 168a+17 db 23 +122 168b+03 db 3 +123 168c+09 db 9 +124 168d+0f db 15 +125 168e+15 db 21 +126 168f+02 db 2 +127 1690+08 db 8 +128 1691+0e db 14 +129 1692+14 db 20 +130 1693+1a db 26 +131 1694+06 db 6 +132 1695+0c db 12 +133 1696+12 db 18 +134 1697+18 db 24 +135 1698+04 db 4 +136 1699+0a db 10 +137 169a+10 db 16 +138 169b+16 db 22 +139 diskdef 1,0 +140 1673+ = dpb1 equ dpb0 ;equivalent parameters +141 001f+ = als1 equ als0 ;same allocation vector size +142 0010+ = css1 equ css0 ;same checksum vector size +143 1682+ = xlt1 equ xlt0 ;same translate table +144 diskdef 2, 0 +145 1673+ = dpb2 equ dpb0 ;equivalent parameters +146 001f+ = als2 equ als0 ;same allocation vector size +147 0010+ = css2 equ css0 ;same checksum vector size +148 1682+ = xlt2 equ xlt0 ;same translate table +149 diskdef 3, 0 +150 1673+ = dpb3 equ dpb0 ;equivalent parameters +151 001f+ = als3 equ als0 ;same allocation vector size +152 0010+ = css3 equ css0 ;same checksum vector size +153 1682+ = xlt3 equ xlt0 ;same translate table +154 ; endef occurs at end of assembly + + A-4 + + + + + + + + + +155 ; +156 ; end of controller--independent code, the remaining subroutines +157 ; are tailored to the particular operating environment, and must +158 ; be altered for any system which differs from the intel mds. +159 ; +160 ; the following code assumes the mds monitor exists at 0f800h +161 ; and uses the i/o subroutines within the monitor +162 ; +163 ; we also assume the mds system has four disk drives +164 00fd = revrt equ 0fdh ;interrupt revert port +165 00fc = intc equ 0fch ;interrupt mask port +166 00f3 = icon equ 0f3h ;interrupt control port +167 007E = inte equ 0111$1110b ;enable rst 0 (warm boot), rst 7 (monitor) +168 ; +169 ; mds monitor equates +170 f800 = mon80 equ 0f800h ;mds monitor +171 ff0f = rmon80 equ 0ff0fh ;restart mon80 (boot error) +172 f803 = ci equ 0f803h ;console character to reg-a +173 f806 = ri equ 0f806h ;reader in to reg-a +174 f809 = co equ 0f809h ;console char from c to console out +175 f80c = po equ 0f80ch ;punch char from c to punch device +176 f80f = lo equ 0f80fh ;list from c to list device +177 f812 = csts equ 0f812h ;console status 00/ff to register a +178 ; +179 ; disk ports and commands +180 0078 = base equ 78h ;base of disk command io ports +181 0078 = dstat equ base ;disk status (input) +182 0079 = rtype equ base+1 ;result type (input) +183 007b = rbyte equ base+3 ;result byte (input) +184 ; +185 0079 = ilow equ base+1 ;iopb low address (output) +186 007a = ihigh equ base+2 ;iopb high address (output) +187 ; +188 0004 = readf equ 4h ;read function +189 0006 = writf equ 6h ;write function +190 0003 = recal equ 3h ;recalibrate drive +191 0004 = iordy equ 4h ;i/o finished mask +192 000d = cr equ 0dh ;carriage return +193 000a = lf equ 0ah ;line-feed +194 ; + + A-5 + + + + + + + + + +195 signon: ;signon message: xxk cp/m vers y.y +196 169c 0d0a0a db cr, lf, lf +197 if test +198 db '32' ;32k example bios +199 endif +200 if not test +201 169f 3030 db '00' ;memory size filled by relocator +202 endif +203 16a1 6b2043502f db 'k cp/m vers ' +204 16ad 322e32 db ver/10+'0', ',' vers mod 10+'0' +205 16b0 0d0a00 db cr, lf, 0 +206 ; +207 boot: ;print signon message and go to ccp +208 ; (note: mds boot initialized iobyte at 0003h) +209 16b3 310001 lxi sp, buff+80h +210 16b6 219c16 lxi h, signon +211 16b9 cdd317 call prmsg ;print message +212 16bc af xra a ;clear accumulator +213 16bd 320400 sta cdisk ;set initially to disk a +214 16c0 c30f17 jmp gocpm ;go to cp/m +215 ; +216 ; +217 wboot:; loader on track 0, sector 1, which will be skipped for warm +218 ; read cp/m from disk--assuming there is a 128 byte cold start +219 ; start +220 ; +221 16c3 318000 lxi sp, buff ;using dma--thus 80 thru ff available for stack +222 ; +223 16c6 0e0a mvi c, retry ;max retries +224 16c8 c5 push b +225 wboot0: ;enter here on error retries +226 16c9 010000 lxi b, cpmb ;set dma address to start of disk system +227 16cc cdbb17 call setdma +228 16cf 0e00 mvi c, 0 ;boot from drive 0 +229 16d1 cd7d17 call seldsk +230 16d4 0e00 mvi c, 0 +231 16d6 cda717 call settrk ;start with track 0 +232 16d9 0e02 mvi c, 2 ;start reading sector 2 +233 16db cdac17 call setsec +234 ; + + A-6 + + + + + + + + + +235 ; read sectors, count nsects to zero +236 16de c1 pop b ;10-error count +237 16df 062c mvi b, nsects +238 rdsec: ;read next sector +239 16e1 c5 push b ;save sector count +240 16e2 cdc117 call read +241 16e5 c24917 jnz booterr ;retry if errors occur +242 16e8 2a6c18 lhld iod ;increment dma address +243 16eb 118000 lxi d, 128 ;sector size +244 16ee 19 dad d ;incremented dma address in hl +245 16ef 44 mov b, h +246 16f0 4d mov c, l ;ready for call to set dma +247 16f1 cdbb17 call setdma +248 16f4 3a6b18 lda ios ;sector number just read +249 16f7 fe1a cpi 26 ;read last sector? +250 16f9 da0517 jc rd1 +251 ; must be sector 26, zero and go to next track +252 16fc 3a6a18 lda iot ;get track to register a +253 16ff 3c inr a +254 1700 4f mov c, a ;read for call +255 1701 cda717 call settrk +256 1704 af xra a ;clear sector number +257 1705 3c rd1: inr a ;to next sector +258 1706 4f mov c, a ;ready for call +259 1707 cdac17 call setsec +260 170a c1 pop b ;recall sector count +261 170b 05 dcr b ;done? +262 170c c2e116 jnz rdsec +263 ; +264 ; done with the load, reset default buffer address +265 gocpm: ;(enter here from cold start boot) +266 ; enable rst0 and rst7 +267 170f f3 di +268 1710 3e12 mvi a, 12h ;initialize command +269 1712 d3fd out revrt +270 1714 af xra a +271 1715 d3fc out intc ;cleared +272 1717 3e7e mvi a, inte ;rst0 and rst7 bits on +273 1719 d3fc out intc +274 171b af xra a + + A-7 + + + + + + + + + +275 171c d3f3 out icon ;interrupt control +276 ; +277 ; set default buffer address to 80h +278 171e 018000 lxi b, buff +279 1721 cdbb17 call setdma +280 ; +281 ; reset monitor entry points +282 1724 3ec3 mvi a, jmp +283 1726 320000 sta 0 +284 1729 210316 lxi h, wboote +285 172c 220100 shld 1 ;jump wboot at location 00 +286 172f 320500 sta 5 +287 1732 210608 lxi h, bdos +288 1735 220600 shld 6 ;jmp bdos at location 5 +289 if not test +290 1738 323800 sta 7*8 ;jmp to mon80 (may have changed by ddt) +291 173b 2100f8 lxi h, mon80 +292 173e 223900 shld 7*8+1 +293 endif +294 ; leave iobyte set +295 ; previously selected disk was b, send parameter to cpm +296 1741 3a0400 lda cdisk ;last logged disk number +297 1744 4f mov c, a ;send to ccp to log it in +298 1745 fb ei +299 1746 c30000 jmp cpmb +300 ; +301 ; error condition occurred, print message and retry +302 booterr: +303 1749 c1 pop b ;recall counts +304 174a 0d dcr c +305 174b ca5217 jz booter0 +306 ; try again +307 174e c5 push b +308 174f c3c916 jmp wboot0 +309 ; +310 booter0: +311 ; otherwise too many retries +312 1752 215b17 lxi h, bootmsg +313 1755 cdd317 call prmsg +314 1758 c30fff jmp rmon80 ;mds hardware monitor + + A-8 + + + + + + + + + +315 ; +316 bootmsg: +317 175b 3f626f6f74 db '?boot', 0 +318 ; +319 ; +320 const: console status to reg-a +321 ; (exactly the same as mds call) +322 1761 c312f8 jmp csts +323 ; +324 conin: ;console character to reg-a +325 1764 cd03f8 call ci +326 1767 e67f ani 7fh ;remove parity bit +327 1769 c9 ret +328 ; +329 conout: ;console character from c to console out +330 176a c309f8 jmp co +331 ; +332 list: ;list device out +333 ; (exactly the same as mds call) +334 176d c30ff8 jmp lo +335 ; +336 listst: +337 ;return list status +338 1770 af xra a +339 1771 c9 ret ;always not ready +340 ; +341 punch: ;punch device out +342 ; (exactly the same as mds call) +343 1772 c30cf8 jmp po +344 ; +345 reader: ;reader character in to reg-a +346 ; (exactly the same as mds call) +347 1775 c306f8 jmp ri +348 ; +349 home: ;move to home position +350 ; treat as track 00 seek +351 1778 0e00 mvi c, 0 +352 177a c3a717 jmp settrk +353 ; +354 seldsk: ;select disk given by register c + + A-9 + + + + + + + + + +355 177d 210000 lxi h, 0000h ;return 0000 if error +356 1780 79 mov a, c +357 1781 fe04 cpi ndisks ;too large? +358 1783 d0 rnc ;leave hl = 0000 +359 ; +360 1784 e602 ani 10b ;00 00 for drive 0, 1 and 10 10 for drive 2, 3 +361 1786 326618 sta dbank ;to select drive bank +362 1789 79 mov a, c ;00, 01, 10, 11 +363 178a e601 ani 1b ;mds has 0, 1 at 78, 2, 3 at 88 +364 178c b7 ora a ;result 00? +365 178d ca9217 jz setdrive +366 1790 3e30 mvi a, 00110000b ;selects drive 1 in bank +367 setdrive: +368 1792 47 mov b, a ;save the function +369 1793 216818 lxi h, iof ;io function +370 1796 7e mov a, m +371 1797 e6cf ani 11001111b ;mask out disk number +372 1799 b0 ora b ;mask in new disk number +373 179a 77 mov m, a ;save it in iopb +374 179b 69 mov l, c +375 179c 2600 mvi h, 0 ;hl=disk number +376 179e 29 dad h ;*2 +377 179f 29 dad h ;*4 +378 17a0 29 dad h ;*8 +379 17a1 29 dad h ;*16 +380 17a2 113316 lxi d, dpbase +381 17a5 19 dad d ;hl=disk header table address +382 17a6 c9 ret +383 ; +384 ; +385 settrk: ;set track address given by c +386 17a7 216a18 lxi h, iot +387 17aa 71 mov m, c +388 17ab c9 ret +389 ; +390 setsec: ;set sector number given by c +391 17ac 216b18 lxi h, ios +392 17af 71 mov m, c +393 17b0 c9 ret +394 sectran: + + A-10 + + + + + + + + + +395 ;translate sector bc using table at de +396 17b1 0600 mvi b, 0 ;double-precision sector number in bc +397 17b3 eb xchg ;translate table address to hl +398 17b4 09 dad b ;translate (sector) address +399 17b5 7e mov a, m ;translated sector number to a +400 17b6 326b18 sta ios +401 17b9 6f mov l, a ;return sector number in l +402 17ba c9 ret +403 ; +404 setdma: ;set dma address given by regs b, c +405 17bb 69 mov l, c +406 17bc 60 mov h, b +407 17bd 226c18 shld iod +408 17c0 c9 ret +409 ; +410 read: ;read next disk record (assuming disk/trk/sec/dma set) +411 17c1 0e04 mvi c, readf ;set to read function +412 17c3 cde017 call setfunc +413 17c6 cdf017 call waitio ;perform read function +414 17c9 c9 ret ;may have error set in reg-a +415 ; +416 ; +417 write: ;disk write function +418 17ca 0e06 mvi c, writf +419 17cc cde017 call setfunc ;set to write function +420 17cf cdf017 call waitio +421 17d2 c9 ret ;may have error set +422 ; +423 ; +424 ; utility subroutines +425 prmsg: ;print message at h, l to 0 +426 17d3 7e mov a, m +427 17d4 b7 ora a zero? +428 17d5 c8 rz +429 ; more to print +430 17d6 e5 push h +431 17d7 4f mov c,a +432 17d8 cd6a17 call conout +433 17db e1 pop h +434 17dc 23 inx h + + A-11 + + + + + + + + + +435 17dd c3d317 jmp prmsg +436 ; +437 setfunc: +438 ; set function for next i/o (command in reg-c) +439 17e0 216818 lxi h, iof ;io function address +440 17e3 7e mov a, m ;get it to accumulator for masking +441 17e4 e6f8 ani 11111000b ;remove previous command +442 17e6 b1 ora c ;set to new command +443 17e7 77 mov m, a ;replaced in iopb +444 ; the mds-800 controller requires disk bank bit in sector byte +445 ; mask the bit from the current i/o function +446 17e8 e620 ani 00100000b ;mask the disk select bit +447 17ea 216b18 lxi h, ios ;address the sector select byte +448 17ed b6 ora m ;select proper disk bank +449 17ee 77 mov m, a ;set disk select bit on/off +450 17ef c9 ret +451 ; +452 waitio: +453 17f0 0e0a mvi c, retry ;max retries before perm error +454 rewait: +455 ; start the i/o function and wait for completion +456 17f2 cd3f18 call intype ;in rtype +457 17f5 cd4c18 call inbyte ;clears the controller +458 ; +459 17f8 3a6618 lda dbank ;set bank flags +460 17fb b7 ora a ;zero if drive 0, 1 and nz if 2, 3 +461 17fc 3e67 mvi a, iopb and offh ;low address for iopb +462 17fe 0618 mvi b, iopb shr 8 ;high address for iopb +463 1800 c20b18 jnz iodr1 ;drive bank 1? +464 1803 d379 out ilow ;low address to controller +465 1805 78 mov a, b +466 1806 d37a out ihigh ;high address +467 1808 c31018 jmp waito ;to wait for complete +468 ; +469 iodr1: ;drive bank 1 +470 180b d389 out ilow+10h ;88 for drive bank 10 +471 180d 78 mov a, b +472 180e d38a out ihigh+10h +473 ; +474 1810 cd5918 waito: call instat ;wait for completion + + A-12 + + + + + + + + + +475 1813 e604 ani iordy ;ready? +476 1815 ca1018 jz waito +477 ; +478 ; check io completion ok +479 1818 cd3f18 call intype ;must be io complete (00) unlinked +480 ; 00 unlinked i/o complete, 01 linked i/o complete (not used) +481 ; io disk status changed 11 (not used) +482 181b fe02 cpi 10b ;ready status change? +483 181d ca3218 jz wready +484 ; +485 ; must be 00 in the accumulator +486 1820 b7 ora a +487 1821 c23818 jnz werror ;some other condition, retry +488 ; +489 ; check i/o error bits +490 1824 cd4c18 call inbyte +491 1827 17 ral +492 1828 da3218 jc wready ;unit not ready +493 182b 1f rar +494 182c e6fe ani 11111110b ;any other errors? (deleted data ok) +495 182e c23818 jnz werror +496 ; +497 ; read or write is ok, accumulator contains zero +498 1831 c9 ret +499 ; +500 wready: ;not ready, treat as error for now +501 1832 cd4c18 call inbyte ;clear result byte +502 1835 c33818 jmp trycount +503 ; +504 werror: ;return hardware malfunction (crc, track, seek, etc.) +505 ; the mds controller has returned a bit in each position +506 ; of the accumulator, corresponding to the conditions: +507 ; 0 -deleted data (accepted as ok above) +508 ; 1 -crc error +509 ; 2 -seek error +510 ; 3 -address error (hardware malfunction) +511 ; 4 -data over/under flow (hardware malfunction) +512 ; 5 -write protect (treated as not ready) +513 ; 6 -write error (hardware malfunction) +514 ; j -not ready + + A-13 + + + + + + + + + +515 ; (accumulator bits are numbered 7 6 5 4 3 2 1 0) +516 ; +517 ; it may be useful to filter out the various conditions, +518 ; but we will get a permanent error message if it is not +519 ; recoverable. in any case, the not ready condition is +520 ; treated as a separated condition for later improvement +521 trycount: +522 ; register c contains retry count, decrement 'til zero +523 1838 0d dcr c +524 1839 c2f217 jnz rewait ;for another try +525 ; +526 ; cannot recover from error +527 183c 3e01 mvi a, 1 ;error code +528 183e c9 ret +529 ; +530 ; intype, inbyte, instat read drive bank 00 or 10 +531 183f 3a6618 intype: lda dbank +532 1842 b7 ora a +533 1843 c24918 jnz intyp1 ;skip to bank 10 +534 1846 db79 in rtype +535 1848 c9 ret +536 1849 db89 intyp1: in rtype+10h ;78 for 0, 1 88 for 2, 3 +537 184b c9 ret +538 ; +539 184c 3a6618 inbyte: lda dbank +540 184f b7 ora a +541 1850 c25618 jnz inbyt1 +542 1853 db7b in rbyte +543 1855 c9 ret +544 1856 db8b inbyt1: in rbyte+10h +545 1858 c9 ret +546 ; +547 1859 3a6618 instat: lda dbank +548 185c b7 ora a +549 185d c26318 jnz insta1 +550 1860 db78 in dstat +551 1862 c9 ret +552 1863 db88 insta1: in dstat+10h +553 1865 c9 ret +554 ; + + A-14 + + + + + + + + + +555 ; +556 ; +557 ; data areas (must be in ram) +558 1866 00 dbank: db 0 ;disk bank 00 if drive 0, 1 +559 ; 10 if drive 2, 3 +560 iopb: ;io parameter block +561 1867 80 db 80h ;normal i/o operation +562 1868 04 iof: db readf ;io function, initial read +563 1869 01 ion: db 1 ;number of sectors to read +564 186a 02 iot: db offset ;track number +565 186b 01 ios: db 1 ;sector number +566 186c 8000 iod: dw buff ;io address +567 ; +568 ; +569 ; define ram areas for bdos operation +570 endef +571 186e+= begdat equ $ +572 186e+ dirbuf: ds 128 ;directory access buffer +573 18ee+ alv0: ds 31 +574 190d+ csv0: ds 16 +575 191d+ alv1: ds 31 +576 193c+ csv1: ds 16 +577 194c+ alv2: ds 31 +578 196b+ csv2: ds 16 +579 197b+ alv3: ds 31 +580 199a+ csv3: ds 16 +581 19aa+= enddat equ $ +582 013c+= datsiz equ $-begdat +583 19aa end + + +als1 001f 141# +als2 001f 146# +als3 001f 151# +alv0 18ee 87 573# +alv1 191d 91 575# +alv2 194c 95 577# +alv3 197b 99 579# +base 0078 180# 181 182 183 185 186 +bdos 0806 29# 287 + + A-15 + + + + + + + + + +begdat 186e 571# 582 +bias 0000 19# 22# +boot 16b3 63 207# +booter0 1752 305 310# +booterr 1749 241 302# +bootmsg 175b 312 316# +buff 0080 34# 209 221 278 566 +cdisk 0004 33# 213 296 +ci f803 172# 325 +co f809 174# 330 +conin 1764 66 324# +conout 176a 67 329# 432 +const 1761 65 320# +cpmb 0000 28# 29 30 226 299 +cpml 1600 30# 31 +cr 000d 192# 196 205 +css1 0010 142# +css2 0010 147# +css3 0010 152# +csts f812 177# 322 +csv0 190d 87 574# +csv1 193c 91 576# +csv2 196b 95 578# +csv3 199a 99 580# +datsiz 013c 582# +dbank 1866 361 459 531 539 539 547 558# +dirbuf 186e 86 90 94 98 572# +dpb0 1673 86 101# 140 145 150 +dpb1 1673 90 140# +dpb2 1673 94 145# +dpb3 1673 98 150# +dpbase 1633 83# 380 +dpe0 1633 84# +dpe1 1643 88# +dpe2 1653 92# +dpe3 1663 96# +dstat 0078 181# 550 552 +enddat 19aa 581# +false 0000 15# 16 +gocpm 170f 214 265# + + A-16 + + + + + + + + + +home 1778 71 349# +icon 00fe 166# 275 +ihigh 007a 186# 466 472 +ilow 0079 185# 464 470 +inbyt1 1856 541 544# +inbyte 184c 457 490 501 539# +insta1 1863 549 552# +instat 1859 474 547# +intc 00fc 165# 271 273 +inte 007e 167# 272 +intyp1 1849 533 536# +intype 183f 456 479 531# +iod 186c 242 407 566# +iodr1 180b 463 469# +iof 1868 369 439 562# +ion 1869 563# +iopb 1867 461 462 560# +iordy 0004 191# 475 +ios 186b 248 391 400 447 565# +iot 186a 252 386 564# +lf 000a 193# 196 196 205 +list 176d 68 332# +listst 1770 78 336# +lo f80f 176# 334 +mon80 f800 170# 291 +nsects 002c 31# 237 +offset 0002 32# 100 564 +patch 1600 25# 27 28 +po f80c 175# 343 +prmsg 17d3 211 313 425# 435 +punch 1772 69 341# +rbyte 007b 183# 542 544 +rd1 1705 250 257# +rdsec 16e1 238# 262 +read 17c1 76 240 410# +reader 1775 70 345# +readf 0004 188# 411 562 +recal 0003 190# +retry 000a 35# 223 453 +revrt 00fd 164# 269 + + A-17 + + + + + + + + + +rewait 17f2 454# 524 +ri f806 173# 347 +rmon80 ff0f 171# 314 +rtype 0079 182# 534 536 +sectran 17b1 79 394# +seldsk 177d 72 229 354# +setdma 17bb 75 227 247 279 404# +setdrive 1792 365 367# +setfunc 17e0 412 419 437# +setsec 17ac 74 233 259 390# +settrk 17a7 73 231 255 352 385# +signon 169c 195# 210 +test 0000 16# 18 21 197 200 289 +true ffff 14# 15 +trycount 1838 502 521# +vers 0016 6# 204 204 +waito 1810 467 474# 476 +waitio 17f0 413 420 452# +wboot 16c3 64 217# +wboot0 16c9 225# 308 +wboote 1603 64# 284 +werror 1838 487 495 504# +wready 1832 483 492 500# +write 17ca 77 417# +writf 0006 189# 418 +xlt0 1682 84 112# 143 148 153 +xlt1 1682 88 143# +xlt2 1682 92 148# +xlt3 1682 96 153# + + + + + + + + + + + + + A-18 + + + + + + + + + + Appendix B + + A Skeletal CBIOS + + + + + 1 ; skeletal cbios for first level of cp/m 2.0 alteration + 2 ; + 3 0014 = msize equ 20 ;cp/m version memory size in kilobytes + 4 ; + 5 ; "bias" is address offset from 3400h for memory systems + 6 ; than 16k (referred to as "b" throughout the text) + 7 ; + 8 0000 = bias equ (msize-20)*1024 + 9 3400 = ccp equ 3400h+bias ;base of ccp + 10 3c06 = bdos equ ccp+806h ;base of bdos + 11 4a00 = bios equ ccp+1600h ;base of bios + 12 0004 = cdisk equ 0004h ;current disk number 0=a,..., 15=p + 13 0003 = iobyte equ 0003h ;intel i/o byte + 14 ; + 15 4a00 org bios ;origin of this program + 16 002c = nsects equ ($-ccp)/128 ;warm start sector count + 17 ; + 18 ; jump vector for individual subroutines + 19 4a00 c39c4a jmp boot ;cold start + 20 4a03 c3a64a wboote: jmp wboot ;warm start + 21 4a06 c3114b jmp const ;console status + 22 4a09 c3244b jmp conin ;console character in + 23 4a0c c3374b jmp conout ;console character out + 24 4a0f c3494b jmp list ;list character out + 25 4a12 c34d4b jmp punch ;punch character out + 26 4a15 c34f4b jmp reader ;reader character out + 27 4a18 c3544b jmp home ;move head to home position + 28 4a1b c35a4b jmp seldsk ;select disk + 29 4a1e c37d4b jmp settrk ;set track number + 30 4a21 c3924b jmp setsec ;set sector number + 31 4a24 c3ad4b jmp setdma ;set dma address + 32 4a27 c3c34b jmp read ;read disk + 33 4a2a c3d64b jmp write ;write disk + + B-1 + + + + + + + + + + 34 4a2d c34b4b jmp listst ;return list status + 35 4a30 c3a74b jmp sectran ;sector translate + 36 ; + 37 ; fixed data tables for four-drive standard + 38 ; ibm-compatible 8" disks + 39 ; disk parameter header for disk 00 + 40 4a33 734a0000 dpbase: dw trans, 0000h + 41 4a37 00000000 dw 0000h, 0000h + 42 4a3b f04c8d4a dw dirbf, dpblk + 43 4a3f ec4d704d dw chk00, all00 + 44 ; disk parameter header for disk 01 + 45 4a43 734a0000 dw trans, 0000h + 46 4a47 00000000 dw 0000h, 0000h + 47 4a4b f04c8d4a dw dirbf, dpblk + 48 4a4f fc4d8f4d dw chk01, all01 + 49 ; disk parameter header for disk 02 + 50 4a53 734a0000 dw trans, 0000h + 51 4a57 00000000 dw 0000h, 0000h + 52 4a5b f04c8d4a dw dirbf, dpblk + 53 4a5f 0c4eae4d dw chk02, all02 + 54 ; disk parameter header for disk 03 + 55 4a63 734a0000 dw trans, 0000h + 56 4a67 00000000 dw 0000h, 0000h + 57 4a6b f04c8d4a dw dirbf, dpblk + 58 4a6f 1c4ecd4d dw chk03, all03 + 59 ; + 60 ; sector translate vector + 61 4a73 01070d13 trans: db 1, 7, 13, 19 ;sectors 1, 2, 3, 4 + 62 4a77 19050b11 db 25, 5, 11, 17 ;sectors 5, 6, 7, 8 + 63 4a7b 1703090f db 23, 3, 9, 15 ;sectors 9, 10, 11, 12 + 64 4a7f 1502080e db 21, 2, 8, 14 ;sectors 13, 14, 15, 16 + 65 4a83 141a060c db 20, 26, 6, 12 ;sectors 17, 18, 19, 20 + 66 4a87 1218040a db 18, 24, 4, 10 ;sectors 21, 22, 23, 24 + 67 4a8b 1016 db 16, 22 ;sectors 25, 26 + 68 ; + 69 dpblk: ;disk parameter block, common to all disks + 70 4a8d 1a00 dw 26 ;sectors per track + 71 4a8f 03 db 3 ;block shift factor + 72 4a90 07 db 7 ;block mask + 73 4a91 00 db 0 ;null mask + + B-2 + + + + + + + + + + 74 4a92 f200 dw 242 ;disk size-1 + 75 4a94 3f00 dw 63 ;directory max + 76 4a96 c0 db 192 ;alloc 0 + 77 4a97 00 db 0 ;alloc 1 + 78 4a98 1000 dw 16 ;check size + 79 4a9a 0200 dw 2 ;track offset + 80 ; + 81 ; end of fixed tables + 82 ; + 83 ; individual subroutines to perform each function + 84 boot: ;simplest case is to just perform parameter initialization + 85 4a9c af xra a ;zero in the accum + 86 4a9d 320300 sta iobyte ;clear the iobyte + 87 4aa0 320400 sta cdisk ;select disk zero + 88 4aa3 c3ef4a jmp gocpm ;initialize and go to cp/m + 89 ; + 90 wboot: ;simplest case is to read the disk until all sectors loaded + 91 4aa6 318000 lxi sp, 80h ;use space below buffer for stack + 92 4aa9 0e00 mvi c, 0 ;select disk 0 + 93 4aab cd5a4b call seldsk + 94 4aae cd544b call home ;go to track 00 + 95 ; + 96 4ab1 062c mvi b, nsects ;b counts # of sectors to load + 97 4ab3 0e00 mvi c, 0 ;c has the current track number + 98 4ab5 1602 mvi d, 2 ;d has the next sector to read + 99 ; note that we begin by reading track 0, sector 2 since sector 1 +100 ; contains the cold start loader, which is skipped in a warm start +101 4ab7 210034 lxi h, ccp ;base of cp/m (initial load point) +102 load1: ;load one more sector +103 4aba c5 push b ;save sector count, current track +104 4abb d5 push d ;save next sector to read +105 4abc e5 push h ;save dma address +106 4abd 4a mov c, d ;get sector address to register c +107 4abe cd924b call setsec ;set sector address from register c +108 4ac1 c1 pop b ;recall dma address to b, c +109 4ac2 c5 push b ;replace on stack for later recall +110 4ac3 cdad4b call setdma ;set dma address from b, c +111 ; +112 ; drive set to 0, track set, sector set, dma address set +113 4ac6 cdc34b call read + + B-3 + + + + + + + + + +114 4ac9 fe00 cpi 00h ;any errors? +115 4acb c2a64a jnz wboot ;retry the entire boot if an error occurs +116 ; +117 ; no error, move to next sector +118 4ace e1 pop h ;recall dma address +119 4acf 118000 lxi d, 128 ;dma=dma+128 +120 4ad2 19 dad d ;new dma address is in h, l +121 4ad3 d1 pop d ;recall sector address +122 4ad4 c1 pop b ;recall number of sectors remaining, and current trk +123 4ad5 05 dcr b ;sectors=sectors-1 +124 4ad6 caef4a jz gocpm ;transfer to cp/m if all have been loaded +125 ; +126 ; more sectors remain to load, check for track change +127 4ad9 14 inr d +128 4ada 7a mov a,d ;sector=27?, if so, change tracks +129 4adb fe1b cpi 27 +130 4add daba4a jc load1 ;carry generated if sector<27 +131 ; +132 ; end of current track, go to next track +133 4ae0 1601 mvi d, 1 ;begin with first sector of next track +134 4ae2 0c inr c ;track=track+1 +135 ; +136 ; save register state, and change tracks +137 4ae3 c5 push b +138 4ae4 d5 push d +139 4ae5 e5 push h +140 4ae6 cd7d4b call settrk ;track address set from register c +141 4ae9 e1 pop h +142 4aea d1 pop d +143 4aeb c1 pop b +144 4aec c3ba4a jmp load1 ;for another sector +145 ; +146 ; end of load operation, set parameters and go to cp/m +147 gocpm: +148 4aef 3ec3 mvi a, 0c3h ;c3 is a jmp instruction +149 4af1 320000 sta 0 ;for jmp to wboot +150 4af4 21034a lxi h, wboote ;wboot entry point +151 4af7 220100 shld 1 ;set address field for jmp at 0 +152 ; +153 4afa 320500 sta 5 ;for jmp to bdos + + B-4 + + + + + + + + + +154 4afd 21063c lxi h, bdos ;bdos entry point +155 4b00 220600 shld 6 ;address field of jump at 5 to bdos +156 ; +157 4b03 018000 lxi b, 80h ;default dma address is 80h +158 4b06 cdad4b call setdma +159 ; +160 4b09 fb ei ;enable the interrupt system +161 4b0a 3a0400 lda cdisk ;get current disk number +162 4b0d 4f mov c, a ;send to the ccp +163 4b0e c30034 jmp ccp ;go to cp/m for further processing +164 ; +165 ; +166 ; simple i/o handlers (must be filled in by user) +167 ; in each case, the entry point is provided, with space reserved +168 ; to insert your own code +169 ; +170 const: ;console status, return 0ffh if character ready, 00h if not +171 4b11 ds 10h ;space for status subroutine +172 4b21 3e00 mvi a, 00h +173 4b23 c9 ret +174 ; +175 conin: ;console character into register a +176 4b24 ds 10h ;space for input routine +177 4b34 e67f ani 7fh ;strip parity bit +178 4b36 c9 ret +179 ; +180 conout: ;console character output from register c +181 4b37 79 mov a, c ;get to accumulator +182 4b38 ds 10h ;space for output routine +183 4b48 c9 ret +184 ; +185 list: ;list character from register c +186 4b49 79 mov a, c ;character to register a +187 4b4a c9 ret ;null subroutine +188 ; +189 listst: ;return list status (0 if not ready, 1 if ready) +190 4b4b af xra a ;0 is always ok to return +191 4b4c c9 ret +192 ; +193 punch: ;punch character from register c + + B-5 + + + + + + + + + +194 4b4d 79 mov a, c ;character to register a +195 4b4e c9 ret ;null subroutine +196 ; +197 ; +198 reader: ;reader character into register a from reader device +199 4b4f 3e1a mvi a, 1ah ;enter end of file for now (replace later) +200 4b51 e67f ani 7fh ;remember to strip parity bit +201 4b53 c9 ret +202 ; +203 ; +204 ; i/o drivers for the disk follow +205 ; for now, we will simply store the parameters away for use +206 ; in the read and write subroutines +207 ; +208 home: ;move to the track 00 position of current drive +209 ; translate this call into a settrk call with parameter 00 +210 4b54 0e00 mvi c, 0 ;select track 0 +211 4b56 cd7d4b call settrk +212 4b59 c9 ret ;we will move to 00 on first read/write +213 ; +214 seldsk: ;select disk given by register c +215 4b51 210000 lxi h, 0000h ;error return code +216 4b5d 79 mov a, c +217 4b5e 32ef4c sta diskno +218 4b61 fe04 cpi 4 ;must be between 0 and 3 +219 4b63 d0 rnc ;no carry if 4, 5,... +220 ; disk number is in the proper range +221 4b64 ds 10 ;space for disk select +222 ; compute proper disk parameter header address +223 4b6e 3aef4c lda diskno +224 4b71 6f mov l, a ;l=disk number 0, 1, 2, 3 +225 4b72 2600 mvi h, 0 ;high order zero +226 4b74 29 dad h ;*2 +227 4b75 29 dad h ;*4 +228 4b76 29 dad h ;*8 +229 4b77 29 dad h ;*16 (size of each header) +230 4b78 11334a lxi d, dpbase +231 4b7b 19 dad 0 ;hl=.dpbase (diskno*16) +232 4b7c c9 ret +233 ; + + B-6 + + + + + + + + + +234 settrk: ;set track given by register c +235 4b7d 79 mov a, c +236 4b7e 32e94c sta track +237 4b81 ds 10h ;space for track select +238 4b91 c9 ret +239 ; +240 setsec: ;set sector given by register c +241 4b92 79 mov a, c +242 4b93 32eb4c sta sector +243 4b96 ds 10h ;space for sector select +244 4ba6 c9 ret +245 ; +246 sectran: +247 ;translate the sector given by bc using the +248 ;translate table given by de +249 4ba7 eb xchg ;hl=.trans +250 4ba8 09 dad b ;hl=.trans (sector) +251 4ba9 6e mov l, m ;l=trans (sector) +252 4baa 2600 mvi h, 0 ;hl=trans (sector) +253 4bac c9 ret ;with value in hl +254 ; +255 setdma: ;set dma address given by registers b and c +256 4bad 69 mov l, c ;low order address +257 4bae 60 mov h, b ;high order address +258 4baf 22ed4c shld dmaad ;save the address +259 4bb2 ds 10h ;space for setting the dma address +260 4bc2 c9 ret +261 ; +262 read: ;perform read operation (usually this is similar to write +263 ; so we will allow space to set up read command, then use +264 ; common code in write) +265 4bc3 ds 10h ;set up read command +266 4bd3 c3e64b jmp waitio ;to perform the actual i/o +267 ; +268 write: ;perform a write operation +269 4bd6 ds 10h ;set up write command +270 ; +271 waitio: ;enter here from read and write to perform the actual i/o +272 ; operation. return a 00h in register a if the operation completes +273 ; properly, and 01h if an error occurs during the read or write + + B-7 + + + + + + + + + +274 ; +275 ; in this case, we have saved the disk number in 'diskno' (0, 1) +276 ; the track number in 'track' (0-76) +277 ; the sector number in 'sector' (1-26) +278 ; the dma address in 'dmaad' (0-65535) +279 4be6 ds 256 ;space reserved for i/o drivers +280 4ce6 3e01 mvi a, 1 ;error condition +281 4ce8 c9 ret ;replaced when filled-in +282 ; +283 ; the remainder of the cbios is reserved uninitialized +284 ; data area, and does not need to be a part of the +285 ; system memory image (the space must be available, +286 ; however, between "begdat" and "enddat"). +287 ; +288 4ce9 track: ds 2 ;two bytes for expansion +289 4ceb sector: ds 2 ;two bytes for expansion +290 4ced dmaad: ds 2 ;direct memory address +291 4cef diskno: ds 1 ;disk number 0-15 +292 ; +293 ; scratch ram area for bdos use +294 4cf0= begdat equ $ ;beginning of data area +295 4cf0 dirfb: ds 128 ;scratch directory area +296 4d70 all00: ds 31 ;allocation vector 0 +297 4d8f all01: ds 31 ;allocation vector 1 +298 4dae all02: ds 31 ;allocation vector 2 +299 4dcd all03: ds 31 ;allocation vector 3 +300 4dec chk00: ds 16 ;check vector 0 +301 4dfc chk01: ds 16 ;check vector 1 +302 4e0c chk02: ds 16 ;check vector 2 +303 4e1c chk03: ds 16 ;check vector 3 +304 ; +305 4e2c enddat equ $ ;end of data area +306 013c= datsiz equ $-begdat; ;size of data area +307 4e2c end + +all00 4d70 43 296# +all01 4d8f 48 297# +all02 4dae 53 298# +all03 4dcd 58 299# +bdos 3c06 10# 154 + + B-8 + + + + + + + + + +begdat 4cf0 294# 306 +bias 0000 8# 9 +bios 4a00 11# 15 +boot 4a9c 19 84# +ccp 3400 9# 10 11 16 101 163 +cdisk 0004 12# 87 161 +chk00 4dec 43 300# +chk01 4dfc 48 301# +chk02 4e0c 53 302# +chk03 4e1c 58 303# +conin 4b24 22 175# +conout 4b37 23 180# +const 4b11 21 170# +datsiz 013c 306# +dirbf 4cf0 42 47 52 57 295# +diskno 4cef 217 223 291# +dmaad 4ced 258 290# +dpbase 4a33 40# 230 +dpblk 4a8d 42 47 52 57 69# +enddat 4e2c 305# +gocpm 4aef 88 124 147# +home 4b54 27 94 208# +iobyte 0003 13# 86 +list 4b49 24 185# +listst 4b4b 34 189# +load1 4aba 102# 130 144 +msize 0014 3# 8 +nsects 002c 16# 96 +punch 4b4d 25 193# +read 4bc3 32 113 262# +reader 4b4f 26 198# +sector 4ceb 242 289# +sectran 4ba7 35 246# +seldsk 4b5a 28 93 214# +setdma 4bad 31 110 158 255# +setsec 4b92 30 107 240# +settrk 4b7d 29 140 211 234# +track 4ce9 236 288# +trans 4a73 40 45 50 55 61# +waitio 4be6 266 271# + + B-9 + + + + + + + + + +wboot 4aa6 20 90# 115 +wboote 4a03 20# 150 +write 4bd6 33 268# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + B-10 + + + + + + + + + + Appendix C + + A Skeletal GETSYS/PUTSYS Program + + + + ; combined getsys and putsys programs from + ; Sec 6.4 + ; Start the programs at the base of the TPA + +0100 org 0100h + +0014 = msize equ 20 ;size of cp/m in Kbytes + + ;"bias" is the amount to add to addresses for > 20k + ; (referred to as "b" throughout the text) + +0000 = bias equ (msize-20)*1024 +3400 = ccp equ 3400h+bias +3c00 = bdos equ ccp+0800h +4a00 = bios equ ccp+1600h + + ; getsys programs tracks 0 and 1 to memory at + ; 3880h + bias + + ; register usage + ; a (scratch register) + ; b track count (0...76) + ; c sector count (1...26) + ; d,e (scratch register pair) + ; h,l load address + ; sp set to track address + + gstart: ;start of getsys +0100 318033 lxi sp,ccp-0080h ;convenient place +0103 218033 lxi h,ccp-0080h ;set initial load +0106 0600 mvi b 0 ;start with track + rd$trk: ;read next track +0108 0e01 mvi c,1 ;each track start + rd$sec: + + C-1 + + + + + + + + + +010a cd0003 call read$sec ;get the next sector +010d 118000 lxi d,128 ;offset by one sector +0110 19 dad d ; (hl=hl+128) +0111 0c inr c ;next sector +0112 79 mov a,c ;fetch sector number +0113 felb cpi 27 ;and see if last +0115 da0a01 jc rdsec ;<, do one more + + ;arrive here at end of track, move to next track + +0118 04 inr b ;track = track+1 +0119 78 mov a,b ;check for last +011a fe02 cpi 2 ;track = 2 ? +011c da0801 jc rd$trk ;<, do another + + ;arrive here at end of load, halt for lack of anything + ;better + +011f fb ei +0120 76 hlt + ; putsys program, places memory image + ; starting at + ; 3880h + bias back to tracks 0 and 1 + ; start this program at the next page boundary +0200 org ($+0100h) and 0ff00h + + put$sys: +0200 318033 lxi sp,ccp-0080h ;convenient place +0203 218033 lxi h,ccp-0080h ;start of dump +0206 0600 mvi b,0 ;start with track + wr$trk: +0208 0e01 mvi b,1 ;start with sector + wr$sec: +020a cd0004 call write$sec ;write one sector +020d 118000 lxi d,128 ;length of each +0210 19 dad d ;= + 128 +0211 0c inr c ; = + 1 +0212 79 mov a,c ;see if +0213 felb cpi 27 ;past end of track +0215 da0a02 jc wr$sec ;no, do another + + C-2 + + + + + + + + + + + ;arrive here at end of track, move to next track + +0218 04 inr b ;track = track+1 +0219 78 mov a,b ;see if +021a fe02 cpi 2 ;last track +021c da0802 jc wr$trk ;no, do another + + ; done with putsys, halt for lack of anything + ; better + +02lf fb ei +0220 76 hit + + ;user supplied subroutines for sector read and write + + ; move to next page boundary + +0300 org ($+0100h) and 0ff00h + + read$sec: + ;read the next sector + ;track in , + ;sector in + ;dmaaddr in + +0300 c5 push b +0301 e5 push h + + ;user defined read operation goes here +0302 ds 64 + +0342 el pop h +0343 cl pop b +0344 c9 ret + +0400 org ($+0100h) and 0ff00h ;another page + ;boundary + + write$sec: + + C-3 + + + + + + + + + + + ;same parameters as read$sec + +0400 c5 push b +0401 e5 push h + + ;user defined write operation goes here +0402 ds 64 + +0442 el pop h +0443 cl pop b +0444 c9 ret + + ;end of getsys/putsys program + +0445 end + + + + + + + + + + + + + + + + + + + + + + + + + + C-4 + + + + + + + + + + Appendix D + + The Microcomputer Development System-800 Cold Start Loader for CP/M 2 + + + + 1 title mds cold start loader at 3000h' + 2 ; + 3 ; mds-800 cold start loader for cp/m 2.0 + 4 ; + 5 ; version 2.0 august, 1979 + 6 ; + 7 0000 = false equ 0 + 8 ffff true equ not false + 9 0000 = testing equ false if true, then go to mon80 on errors + 10 ; + 11 if testing + 12 bias equ 03400h + 13 endif + 14 if not testing + 15 0000 = bias equ 0000h + 16 endif + 17 0000 = cpmb equ bias ;base of dos load + 18 0806 = bdos equ 806h+bias ;entry to dos for calls + 19 1880 = bdose equ 1880h+bias ;end of dos load + 20 1600 = boot equ 1600h+bias ;cold start entry point + 21 1603 = rboot equ boot+3 ;warm start entry point + 22 ; + 23 3000 org 03000h ;loaded down from hardware boot at 3000H + 24 ; + 25 1880 = bdosl equ bdose-cpmb + 26 0002 = ntrks equ 2 ;number of tracks to read + 27 0031 = bdoss equ bdosl/128 ;number of sectors in dos + 28 0019 = bdoso equ 25 ;number of bdos sectors on track 0 + 29 0018 = bdos1 equ bdoss-bdoso ;number of sectors on track 1 + 30 ; + 31 f800 = mon80 equ 0f800h ;intel monitor base + 32 ff0f = rmon80 equ 0ff0fh ;restart location for mon80 + 33 0078 = base equ 078h ;'base' used by controller + 34 0079 = rtype equ base+1 ;result type + + D-1 + + + + + + + + + + 35 007b = rbyte equ base+3 ;result byte + 36 007f = reset equ base+7 ;reset controller + 37 ; + 38 0078 = dstat equ base ;disk status port + 39 0079 = ilow equ base+1 ;low iopb address + 40 007a = ihigh equ base+2 ;high iopb address + 41 00ff = bsw equ 0ffh ;boot switch + 42 0003 = recal equ 3h ;recalibrate selected drive + 43 0004 = readf equ 4h ;disk read function + 44 0100 = stack equ 100h ;use end of boot for stack + 45 ; + 46 rstart: + 47 3000 310001 lxi sp,stack; ;in case of call to mon80 + 48 ; clear disk status + 49 3003 db79 in rtype + 50 3005 db7b in rbyte + 51 ; check if boot switch if off + 52 coldstart: + 53 3007 dbff in bsw + 54 3009 e602 ani 02h ;switch on? + 55 300b c20730 jnz coldstart + 56 ; clear the controller + 57 300e d37f out reset ;logic cleared + 58 ; + 59 ; + 60 3010 0602 mvi b,ntrks ;number of tracks to read + 61 3012 214230 lxi h,iopbo + 62 ; + 63 start: + 64 ; + 65 ; read first/next track into cpmb + 66 3015 7d mov a,l + 67 3016 d379 out ilow + 68 3018 7c mov a,h + 69 3019 d37a out ihigh + 70 301b db78 waito: in dstat + 71 301d e604 ani 4 + 72 301f ca1b30 jz waito + 73 ; + 74 ; check disk status + + D-2 + + + + + + + + + + 75 3022 db79 in rtype + 76 3024 e603 ani 11b + 77 3026 fe02 cpi 2 + 78 ; + 79 if testing + 80 cnc rmon80 ;go to monitor if 11 or 10 + 81 endif + 82 if not testing + 83 3028 d20030 jnc rstart ;retry the load + 84 endif + 85 ; + 86 302b db7b in rbyte ;i/o complete, check status + 87 ; if not ready, then go to mon80 + 88 302d 17 ral + 89 302e dc0fff cc rmon80 ;not ready bit set + 90 3031 1f rar ;restore + 91 3032 e61e ani 11110b ;overrun/addr err/seek/crc/xxxx + 92 ; + 93 if testing + 94 cnz rmon80 ;go to monitor + 95 endif + 96 if not testing + 97 3034 c20030 jnz rstart ;retry the load + 98 endif + 99 ; +100 ; +101 3037 110700 lxi d,iopbl ;length of iopb +102 303a 19 dad d ;addressing next iopb +103 303b 05 dcr b ;count down tracks +104 303c c21530 jnz start +105 ; +106 ; +107 ; jmp to boot to print initial message, and set up jmps +108 303f c30016 jmp boot +109 ; +110 ; parameter blocks +111 3042 80 iopbo: db 80h ;iocw, no update +112 3043 04 db readf ;read function +113 3044 19 db bdoso ;#sectors to read on track 0 +114 3045 00 db 0 ;track 0 + + D-3 + + + + + + + + + +115 3046 02 db 2 ;start with sector 2 on track 0 +116 3047 0000 dw cpmb ;start at base of bdos +117 0007 = iopbl equ $-iopbo +118 ; +119 3049 80 iopb1: db 80h +120 304a 04 db readf +121 304b 18 db bdos1 ;sectors to read on track 1 +122 304c 01 db 1 ;track 1 +123 304d 01 db 1 ;sector 1 +124 304e 800c dw cmpb+bdos0*128;base of second read +125 ; +126 3050 end + + +base 0078 33# 34 35 36 38 39 40 +bdos 0806 18# +bdoso 0019 28# 29 113 124 +bdos1 0018 29# 121 +bdose 1880 19# 25 +bdosl 1880 25# 27 +bdoss 0031 27# 29 +bias 0000 12# 15# 17 18 19 20 +boot 1600 20# 21 108 +bsw 00ff 41# 53 +coldstart 3007 52# 55 +cpmb 0000 17# 25 116 124 +dstat 0078 38# 70 +false 0000 7# 8 9 +ihigh 007a 40# 69 +ilow 0079 39# 67 +iopbo 3042 61 111# 117 +iopb1 3049 119# +iopbl 0007 101 117# +mon80 f800 31# +ntrks 0002 26# 60 +rboot 1603 21# +rbyte 007b 35# 50 86 +readf 0004 43# 112 120 +recal 0003 42# +reset 007f 36# 57 + + D-4 + + + + + + + + + +rmon80 ff0f 32# 80 89 94 +rstart 3000 46# 83 97 +rtype 0079 34# 49 75 +stack 0100 44# 47 +start 3015 63# 104 +testing 0000 9# 11 14 79 82 93 96 +true ffff 8# +waito 301b 70# 72 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + D-5 + + + + + + + + + + Appendix E + + A Skeletal Cold Start Loader + + + + ;this is a sample cold start loader, which, when + ;modified + ;resides on track 00, sector 01 (the first sector on the + ;diskette). we assume that the controller has loaded + ;this sector into memory upon system start-up (this + ;program can be keyed-in, or can exist in read-only + ;memory + ;beyond the address space of the cp/m version you are + ;running). the cold start loader brings the cp/m system + ;into memory at "loadp" (3400h + "bias"). in a 20k + ;memory system, the value of "bias" is 000h, with + ;large + ;values for increased memory sizes (see section 2). + ;after + ;loading the cp/m system, the cold start loader + ;branches + ;to the "boot" entry point of the bios, which beings at + ;"bios" + "bias". the cold start loader is not used un- + ;til the system is powered up again, as long as the bios + ;is not overwritten. the origin is assumed at 0000h, and + ;must be changed if the controller brings the cold start + ;loader into another area, or if a read-only memory + ;area + ;is used. + +0000 org 0 ;base of ram in + ;cp/m + +0014 = msize equ 20 ;min mem size in + ;kbytes +0000 = bias equ (msize-20)*1024 ;offset from 20k + ;system +3400 = ccp equ 3400h+bias ;base of the ccp +4a00 = bios equ ccp+1600h ;base of the bios + + E-1 + + + + + + + + + +0300 = biosl equ 0300h ;length of the bios +4a00 = boot equ bios +1900 = size equ bios+biosl-ccp ;size of cp/m + ;system +0032 = sects equ size/128 ;# of sectors to load + + ; begin the load operation + + cold: +0000 010200 lxi b,2 ;b=0, c=sector 2 +0003 1632 mvi d,sects ;d=# sectors to + ;load +0005 210034 lxi h,ccp ;base transfer + ;address + lsect: ;load the next sector + + ; insert inline code at this point to + ; read one 128 byte sector from the + ; track given in register b, sector + ; given in register c, + ; into the address given by + ;branch to location "cold" if a read error occurs + ; + ; + ; user supplied read operation goes + ; here... + ; + ; + +0008 c36b00 jmp past$patch ;remove this + ;when patched +000b ds 60h + + past$patch: + ;go to next sector if load is incomplete +006b 15 dcr d ;sects=sects-1 +006c ca004a jz boot ;head for the bios + + ; more sectors to load + ; + + E-2 + + + + + + + + + + ;we aren't using a stack, so use as scratch + ;register + ; to hold the load address increment + +006f 318000 lxi sp,128 ;128 bytes per + ;sector +0072 39 dad sp ; = + + 128 +0073 0c inr c ;sector=sector + 1 +0074 79 mov a,c +0075 felb cpi 27 ;last sector of + ;track? +0077 da0800 jc lsect ;no, go read + ;another + + ;end of track, increment to next track + +007a 0e01 mvi c,l ;sector = 1 +007c 04 inr b ;track = track + 1 +007d c30800 jmp lsect ;for another group +0080 end ;of boot loader + + + + + + + + + + + + + + + + + + + + + E-3 + + + + + + + + + + Appendix F + + CP/M Disk Definition Library + + + 1:; CP/M 2.0 disk re-definition library + 2:; + 3:; Copyright (c) 1979 + 4:; Digital Research + 5:; Box 579 + 6:; Pacific Grove, CA + 7:; 93950 + 8:; + 9:; CP/M logical disk drives are defined using the + 10:; macros given below, where the sequence of calls + 11:; is: + 12:; + 13:; disks n + 14:; diskdef parameter-list-0 + 15:; diskdef parameter-list-1 + 16:; ... + 17:; diskdef parameter-list-n + 18:; endef + 19:; + 20:; where n is the number of logical disk drives attached + 21:; to the CP/M system, and parameter-list-i defines the + 22:; characteristics of the ith drive (i=0,1,...,n-1) + 23:; + 24:; each parameter-list-i takes the form + 25:; dn,fsc,lsc,[skf],bls,dks,dir,cks,ofs,[0] + 26:; where + 27:; dn is the disk number 0,1,...,n-1 + 28:; fsc is the first sector number (usually 0 or 1) + 29:; lsc is the last sector number on a track + 30:; skf is optional "skew factor" for sector translate + 31:; bls is the data block size (1024,2048,...,16384) + 32:; dks is the disk size in bls increments (word) + 33:; dir is the number of directory elements (word) + 34:; cks is the number of dir elements to checksum + 35:; ofs is the number of tracks to skip (word) + + F-1 + + + + + + + + + + 36:; [0] is an optional 0 which forces 16K/directory end + 37:; + 38:; for convenience, the form + 39:; dn,dm + 40:; defines disk dn as having the same characteristics as + 41:; a previously defined disk dm. + 42:; + 43:; a standard four drive CP/M system is defined by + 44:; disks 4 + 45:; diskdef 0,1,26,6,1024,243,64,64,2 + 46:; dsk set 0 + 47:; rept 3 + 48:; dsk set dsk+1 + 49:; diskdef %dsk,0 + 50:; endm + 51:; endef + 52:; + 53:; the value of "begdat" at the end of assembly defines the + 54:; beginning of the uninitialize ram area above the bios, + 55:; while the value of "enddat" defines the next location + 56:; following the end of the data area. the size of this + 57:; area is given by the value of "datsiz" at the end of the + 58:; assembly. note that the allocation vector will be quite + 59:; large if a large disk size is defined with a small block + 60:; size. + 61:; + 62:dskhdr macro dn + 63:;; define a single disk header list + 64:dpe&dn: dw xlt&dn,0000h ;translate table + 65: dw 0000h,0000h ;scratch area + 66: dw dirbuf,dpb&dn ;dir buff,parm block + 67: dw csv&dn,alv&dn ;check, alloc vectors + 68: endm + 69:; + 70:disks macro nd + 71:;; define nd disks + 72:ndisks set nd ;;for later reference + 73:dpbase equ $ ;base of disk parameter blocks + 74:;; generate the nd elements + 75:disknxt set 0 + + F-2 + + + + + + + + + + 76: rept nd + 77: dskhdr %dsknxt + 78:dsknxt set dsknxc+1 + 79: endm + 80: endm + 81:; + 82:dpbhdr macro dn + 83:dpb&dn equ $ ;disk parm block + 84: endm + 85:; + 86:ddb macro data,comment + 87:;; define a db statement + 88: db data comment + 89: endm + 90:; + 91:ddw macro data,comment + 92:;; define a dw statement + 93: dw data comment + 94: endm + 95:; + 96:gcd macro m,n + 97:;; greatest common divisor of m,n + 98:;; produces value gcdn as result + 99:;; (used in sector translate table generation) +100:gcdm set m ;;variable for m +101:gcdn set n ;;variable for n +102:gcdr set 0 ;;variable for r +103: rept 65535 +104:gcdx set gcdm/gcdn +105:gcdr set gcdm-gcdx*gcdn +106: if gcdr = 0 +107: exitm +108: endif +109:gcdm set gcdn +110:gcdn set gcdr +111: endm +112: endm +113:; +114:diskdef macro dn,fsc,lsc,skf,bls,dks,dir,cks,ofs,k16 +115:;; generate the set statements for later tables + + F-3 + + + + + + + + + +116: if nul lsc +117:;; current disk dn same as previous fsc +118:dpb&dn equ dpb&fsc ;equivalent parameters +119:als&dn equ als&fsc ;same allocation vector size +120:css&dn equ css&fsc ;same checksum vector size +121:xlt&dn equ xlt&fsc ;same translate table +122: else +123:secmax set lsc-(fsc) ;;sectors 0...secmax +124:sectors set secmax+1 ;;number of sectors +125:als&dn set (dks)/8 ;;size of allocation vector +126: if ((dks)mod8) ne 0 +127:als&dn set als&dn+1 +128: endif +129:css&dn set (cks)/4 ;;number of checksum elements +130:;; generate the block shift value +131:blkval set bls/128 ;;number of sectors/block +132:blkshf set 0 ;;counts right 0's in blkval +133:blkmsk set 0 ;;fills with l's from right +134: rept 16 ;;once for each bit position +135: if blkval=1 +136: exitm +137: endif +138:;; otherwise, high order 1 not found yet +139:blkshf set blkshf+1 +140:blkmsk set (blkmsk shl l) or l +141:blkval set blkval/2 +142: endm +143:;; generate the extent mask byte +144:blkval set bls/1024 ;;number of kilobytes/block +145:extmsk set 0 ;;fill from right with l's +146: rept 16 +147: if blkval=1 +148: exitm +149: endif +150:;; otherwise more to shift +151:extmsk set (extmsk shl l) or l +152:blkval set blkval/2 +153: endm +154:;; may be double byte allocation +155: if (dks)>256 + + F-4 + + + + + + + + + +156:extmsk set (extmsk shr l) +157: endif +158:;; may be optional [0] in last position +159: if not nul k16 +160:extmsk set k16 +161: endif +162:;; now generate directory reservation bit vector +163:dirrem set dir ;;#remaining to process +164:dirbks set bls/32 ;;number of entries per block +165:dirblk set 0 ;;fill with l's on each loop +166: rept 16 +167: if dirrem=0 +168: exitm +169: endif +170:;; not complete, iterate once again +171:;; shift right and add 1 high order bit +172:dirblk set (dirblk shr l) or 8000h +173: if dirrem>dirbks +174:dirrem set dirrem-dirbks +175: else +176:direem set 0 +177: endif +178: endm +179: dpbhdr dn ;;generate equ $ +180: ddw %sectors,<;sec per track> +181: ddb %blkshf,<;block shift> +182: ddb %blkmsk,<;block mask> +183: ddb %extmsk,<;extnt mask> +184: ddw %(dks)-1,<;disk size-1> +185: ddw %(dir)-1, +186: ddb %dirblk shr 8,<;alloc0> +187: ddb %dirblk and 0ffh,<;allocl> +188: ddw %(cks)/4,<;check size> +189: ddw %ofs,<;offset> +190:;; generate the translate table, if requested +191: if nul skf +192:xlt&dn equ 0 ;no xlate table +193: else +194: if skf = 0 +195:xlt&dn equ 0 ;no xlate table + + F-5 + + + + + + + + + +196: else +197:;; generate the translate table +198:nxtsec set 0 ;;next sector to fill +199:nxtbas set 0 ;;moves by one on overflow +200: gcd %sectors,skf +201:;; gcdn = gcd(sectors,skew) +202:neltst set sectors/gcdn +203:;; neltst is number of elements to generate +204:;; before we overlap previous elements +205:nelts set neltst ;;counter +206:xlt&dn equ $ ;;translate table +207: rept sectors ;;once for each sector +208: if sectors<256 +209: ddb %nxtsec+(fsc) +210: else +211: ddw %nxtsec+(fsc) +212: endif +213:nxtsec set nxtsec+(skf) +214: if nxtsec>=sectors +215:nxtsec set nxtsec-sectors +216: endif +217:nelts set nelts-1 +218: if nelts = 0 +219:nxtbas set nxtbas+1 +220:nxtsec set nxtbas +221:nelts set neltst +222: endif +223: endm +224: endif ;;end of nul fac test +225: endif ;;end of nul bls test +226: endm +227:; +228:defds macro lab,space +229:lab: ds space +230: endm +231:; +232:lds macro lb,dn,val +233: defds lb&dn,%val&dn +234: endm +235:; + + F-6 + + + + + + + + + +236:endef macro +237:;; generate the necessary ram data areas +238:begdat equ $ +239:dirbuf: ds 128 ;directory access buffer +240:dsknxt set 0 +241: rept ndisks ;;once for each disk +242: lds alv,%dsknxt,als +243: lds csv,%dsknxt,ccs +244:dsknxt set dsknxt+1 +245: endm +246:enddat equ $ +247:datsiz equ $-begdat +248:;; db 0 at this point forces hex record +249: endm + + + + + + + + + + + + + + + + + + + + + + + + + + + + F-7 + + + + + + + + + + Appendix G + + Blocking and Deblocking Algorithms + + + + 1 ; + 2 ; + 3 ; sector deblocking algorithms for cp/m 2.0 + 4 ; + 5 ; + 6 ; + 7 ; utility macro to compute sector mask + 8 smask macro hblk + 9 ;; compute log2(hblk), return @x as result + 10 ;; (2 ** @x = hblk on return) + 11 @y set hblk + 12 @x set 0 + 13 ;; count right shifts of @y until = 1 + 14 rept 8 + 15 if @y = 1 + 16 exitm + 17 endif + 18 ;; @y is not 1, shift right one position + 19 @y set @y shr 1 + 20 @x set @x + 1 + 21 endm + 22 endm + 23 ; + 24 ; + 25 ; + 26 ; cp/m to host disk constants + 27 ; + 28 ; + 29 0800 = blksiz equ 2048 ;cp/m allocation size + 30 0200 = hstsiz equ 512 ;host disk sector size + 31 0014 = hstspt equ 20 ;host disk sectors/trk + 32 0004 = hstblk equ hstsiz/128 ;cp/m sects/host buff + 33 0050 = cpmspt equ hstblk * hstspt ;cp/m sectors/track + 34 0003 = secmsk equ hstblk-1 ;sector mask + + G-1 + + + + + + + + + + 35 smask hstblk ;compute sector mask + 36 0002 = secshf equ @x ;log2(hstblk) + 37 ; + 38 ; + 39 ; + 40 ; bdos constants on entry to write + 41 ; + 42 ; + 43 0000 = wrall equ 0 ;write to allocated + 44 0001 = wrdir equ 1 ;write to directory + 45 0002 = wrual equ 2 ;write to unallocated + 46 ; + 47 ; + 48 ; + 49 ; the bdos entry points given below show the + 50 ; code which is relevant to deblocking only. + 51 ; + 52 ; + 53 ; + 54 ; diskdef macro, or hand coded tables go here + 55 0000 = dpbase equ $ ;disk param block base + 56 ; + 57 boot: + 58 wboot: + 59 ;enter here on system boot to initialize + 60 0000 af xra a ;0 to accumulator + 61 0001 326a01 sta hstact ;host buffer inactive + 62 0004 326c01 sta unacnt ;clear unalloc count + 63 0007 c9 ret + 64 ; + 65 home: + 66 ;home the selected disk + 67 home: + 68 0008 3a6b01 lda hstwrt ;check for pending write + 69 000b b7 ora a + 70 000c c21200 jnz homed + 71 000f 326a01 sta hstact ;clear host active flag + 72 homed: + 73 0012 c9 ret + 74 ; + + G-2 + + + + + + + + + + 75 seldsk: + 76 ;select disk + 77 0013 79 mov a,c ;selected disk number + 78 0014 326101 sta sekdsk ;seek disk number + 79 0017 6f mov l,a ;disk number to hl + 80 0018 2600 mvi h,0 + 81 rept 4 ;multiply by 16 + 82 dad h + 83 endm + 84 001a+29 dad h + 85 001b+29 dad h + 86 001c+29 dad h + 87 001d+29 dad h + 88 001e 110000 lxi d,dpbase ;base of parm block + 89 0021 19 dad d ;hl=.dpb(curdsk) + 90 0022 c9 ret + 91 ; + 92 settrk: + 93 ;set track given by registers bc + 94 0023 60 mov h,b + 95 0024 69 mov l,c + 96 0025 226201 shld sektrk ;track to seek + 97 0028 c9 ret + 98 ; + 99 setsec: +100 ;set sector given by register c +101 0029 79 mov a,c +102 002a 326401 sta seksec ;sector to seek +103 002d c9 ret +104 ; +105 setdma: +106 ;set dma address given by bc +107 002e 60 mov h,b +108 002f 69 mov l,c +109 0030 227501 shld dmaadr +110 0033 c9 ret +111 ; +112 sectran: +113 ;translate sector number bc +114 0034 60 mov h,b + + G-3 + + + + + + + + + +115 0035 69 mov l,c +116 0036 c9 ret +117 ; +118 ; +119 ; +120 ; the read entry point takes the place of +121 ; the previous bios definition for read. +122 ; +123 ; +124 read: +125 ;read the selected cp/m sector +126 0037 af xra a +127 0038 326c01 sta unacnt +128 003b 3e01 mvi a,1 +129 003d 327301 sta readop ;read operation +130 0040 327201 sta rsflag ;must read data +131 0043 3e02 mvi a,wrual +132 0045 327401 sta wrtype ;treat as unalloc +133 0048 c3b600 jmp rwoper ;to perform the read +134 ; +135 ; +136 ; +137 ; the write entry point takes the place of +138 ; the previous bios definition for write. +139 ; +140 ; +141 write: +142 ;write the selected cp/m sector +143 004b af xra a ;0 to accumulator +144 004c 327301 sta readop ;not a read operation +145 004f 79 mov a,c ;write type in c +146 0050 327401 sta wrtype +147 0053 fe02 cpi wrual ;write unallocated? +148 0050 c26f00 jnz chkuna ;check for unalloc +149 ; +150 ; write to unallocated, set parameters +151 0058 3e10 mvi a,blksiz/128 ;next unalloc recs +152 005a 326c01 sta unacnt +153 005d 3a6101 lda sekdsk ;disk to seek +154 0060 326d01 sta unadsk ;unadsk = sekdsk + + G-4 + + + + + + + + + +155 0063 2a6201 lhld settrk +156 0066 226e01 shld unatrk ;unatrk = sectrk +157 0069 3a6401 lda seksec +158 006c 327001 sta unasec ;unasec = seksec +159 ; +160 chkuna: +161 ;check for write to unallocated sector +162 006f 3a6c01 lda unacnt ;any unalloc remain? +163 0072 b7 ora a +164 0073 caae00 jz alloc ;skip if not +165 ; +166 ; more unallocated records remain +167 0076 3d dcr a ;unacnt = unacnt-1 +168 0077 326c01 sta unacnt +169 007a 3a6101 lda sekdsk ;same disk? +170 007d 216d01 lxi h,unadsk +171 0080 be cmp m ;sekdsk = unadsk? +172 0081 c2ae00 jnz alloc ;skip if not +173 ; +174 ; disks are the same +175 0084 216e01 lxi h,unatrk +176 0087 cd5301 call sektrkcmp ;saektrk = unatrk? +177 008a c2ae00 jnz alloc ;skip if not +178 ; +179 ; tracks are the same +180 008d 3a6401 lda seksec ;same sector? +181 0090 217001 lxi h,unasec +182 0093 be cmp m ;seksec = unasec? +183 0094 c2ae00 jnz alloc ;skip if not +184 ; +185 ; match, move to next sector for future ref +186 0097 34 inr m ;unasec = unasec+1 +187 0098 7e mov a,m ;end of track? +188 0099 fe50 cpi cpmspt ;count cp/m sectors +189 009b daa700 jc noovf ;skip if no overflow +190 ; +191 ; overflow to next track +192 009e 3600 mvi m,o ;unasec = 0 +193 00a0 2a6e01 lhld unatrk +194 00a3 23 inx h + + G-5 + + + + + + + + + +195 00a4 226e01 shld unatrk ;unatrk = unatrk+1 +196 ; +197 noovf: +198 ;match found, mark as unnecessary read +199 00a7 af xra a ;0 to accumulator +200 00ab 327201 sta rsflag ;rsflag = 0 +201 00ab c3b600 jmp rwoper ;to perform the write +202 ; +203 alloc: +204 ;not an unallocated record, requires pre-read +205 00ae af xra a ;0 to accum +206 00af 326c01 sta unacnt ;unacnt = 0 +207 00b2 3c inr a ;1 to accum +208 00b3 327201 sta rsflag = 1 ;rsflag = 1 +209 ; +210 ; +211 ; +212 ; common code for read and write follows +213 ; +214 ; +215 rwoper: +216 ;enter here to perform the read-write +217 00b6 af xra a ;zero to accum +218 00b7 327101 sta erflag ;no errors (yet) +219 00ba 3a6401 lda seksec ;compute host sector +220 rept secshf +221 ora a ;carry = 0 +222 rar ;shift right +223 endm +224 00bd+b7 ora a ;carry = 0 +225 00be+1f rar ;shift right +226 00bf+b7 ora a ;carry = 0 +227 00c0+1f rar ;shift right +228 00c1 326901 sta sekhst ;host sector to seek +229 ; +230 ; active host sector? +231 00c4 216a01 lxi h,hstact ;host active flag +232 00c7 7e mov a,m +233 00c8 3601 mvi m,1 ;always becomes 1 +234 00ca b7 ora a ;was it already? + + G-6 + + + + + + + + + +235 00cb caf200 jz filhst ;fill host if not +236 ; +237 ; host buffer active, same as seek buffer? +238 00ce 3a6101 lda sekdsk +239 00d1 216501 lxi h,hstdsk ;same disk? +240 00d4 be cmp m ;sekdsk = hstdsk? +241 00d5 c2eb00 jnz nomatch +242 ; +243 ; same disk, same track? +244 00d8 216601 lxi h,hsttrk +245 00db cd5301 call sektrkcmp ;sektrk = hsttrk? +246 00de c2eb00 jnz nomatch +247 ; +248 ; same disk, same track, same buffer? +249 00e1 3a6901 lda sekhst +250 00e4 216801 lxi h,hstsec ;sekhst = hstsec? +251 00e7 be cmp m +252 00e8 ca0f01 jz match ;skip if match +253 ; +254 nomatch: +255 ;proper disk, but not correct sector +256 00eb 3a6b01 lda hstwrt ;host written? +257 00ee b7 ora a +258 00ef c45f01 cnz writehst ;clear host buff +259 ; +260 filhst: +261 ;may have to fill the host buffer +262 00f2 3a6101 lda sekdsk +263 00f5 326501 sta hstdsk +264 00f8 2a6201 lhld sektrk +265 00fb 226601 shld hsttrk +266 00fe 3a6901 lda sekhst +267 0101 326801 sta hstsec +268 0104 3a7201 lda rsflag ;need to read? +269 0107 b7 ora a +270 0108 c46001 cnz readhst ;yes, if 1 +271 010b af xra a ;0 to accum +272 010c 326b01 sta hstwrt ;no pending write +273 ; +274 match: + + G-7 + + + + + + + + + +275 ;copy data to or from buffer +276 010f 3a6401 lda seksec ;mask buffer number +277 0112 e603 ani secmsk ;least signif bits +278 0114 6f mov l,a ;ready to shift +279 0115 2600 mvi h,0 ;double count +280 rept 7 ;shift left 7 +281 dad h +282 endm +283 0117+29 dad h +284 0118+29 dad h +285 0119+29 dad h +286 011a+29 dad h +287 011b+29 dad h +288 011c+29 dad h +289 011d+29 dad h +290 ; hl has relative host buffer address +291 011e 117701 lxi d,hstbuf +292 0121 19 dad d ;hl = host address +293 0122 eb xchg ;now in de +294 0123 2a7501 lhld dmaadr ;get/put cp/m data +295 0126 0e80 mvi c,128 ;length of move +296 0128 3a7301 lda readop ;which way? +297 012b b7 ora a +298 012c c23501 jnz rwmove ;skip if read +299 ; +300 ; write operation, mark and switch direction +301 012f 3e01 mvi a,1 +302 0131 326b01 sta hstwrt ;hstwrt = 1 +303 0134 eb xchg ;source/dest swap +304 ; +305 rwmove: +306 ;c initially 128, de is source, hl is dest +307 0135 1a ldax d ;source character +308 0136 13 inx d +309 0137 77 mov m,a ;to dest +310 0138 23 inx h +311 0139 od dcr c ;loop 128 times +312 013a c23501 jnz rwmove +313 ; +314 ; data has been moved to/from host buffer + + G-8 + + + + + + + + + +315 013d 3a7401 lda wrtype ;write type +316 0140 fe01 cpi wrdir ;to directory? +317 0142 3a7101 lda erflag ;in case of errors +318 0145 c0 rnz ;no further processing +319 ; +320 ; clear host buffer for directory write +321 0146 b7 ora a ;errors? +322 0147 c0 rnz ;skip if so +323 0148 af xra a ;0 to accum +324 0149 326b01 sta hstwrt ;buffer written +325 014c cd5f01 call writehst +326 014f 3a7101 lda erflag +327 0152 c9 +328 ; +329 ; +330 ; +331 ; utility subroutine for 16-bit compare +332 ; +333 ; +334 sektrkcmp: +335 ;hl = .unatrk or .hsttrk, compare with sektrk +336 0153 eb xchg +337 0154 216201 lxi h,sektrk +338 0157 1a ldax d ;low byte compare +339 0158 be cmp m ;same? +340 0159 c0 rnz ;return if not +341 ; low bytes equal, test high 1s +342 015a 13 inx d +343 015b 23 inx h +344 015c 1a ldax d +345 015d be cmp m ;sets flags +346 015e c9 ret +347 ; +348 ; +349 ; +350 ; writehst performs the physical write to +351 ; the host disk, readhst reads the physical +352 ; disk. +353 ; +354 ; + + G-9 + + + + + + + + + +355 writehst: +356 ;hstdsk = host disk #, hsttrk = host track #, +357 ;hstsec = host sect #. write "hstsiz" bytes +358 ;from hstbuf and return error flag in erflag. +359 ;return erflag non-zero if error +360 015f c9 ret +361 ; +362 readhst: +363 ;hstdsk = host disk #, hsttrk = host track #, +364 ;hstsec = host sect #. read "hstsiz" bytes +365 ;into hstbuf and return error flag in erflag. +366 0160 c9 ret +367 ; +368 ; +369 ; +370 ; uninitialized ram data areas +371 ; +372 ; +373 ; +374 0161 sekdsk: ds 1 ;seek disk number +375 0162 sektrk: ds 2 ;seek track number +376 0164 seksec: ds 1 ;seek sector number +377 ; +378 0165 hstdsk: ds 1 ;host disk number +379 0166 hsttrk: ds 2 ;host track number +380 0168 hstsec: ds 1 ;host sector number +381 ; +382 0169 sekhst: ds 1 ;seek shr secshf +383 016a hstact: ds 1 ;host active flag +384 016b hstwrt: ds 1 ;host written flag +385 ; +386 016c unacnt: ds 1 ;unalloc rec cnt +387 016d unadsk: ds 1 ;last unalloc disk +388 016e unatrk: ds 2 ;last unalloc track +389 0170 unasec: ds 1 ;last unalloc sector +390 ; +391 0171 erflag: ds 1 ;error reporting +392 0172 rsflag: ds 1 ;read sector flag +393 0173 readop: ds 1 ;1 if read operation +394 0174 wrtype: ds 1 ;write operation type + + G-10 + + + + + + + + + +395 0175 dmaadr: ds 2 ;last dma address +396 0177 hstbuf: ds hstsiz ;host buffer +397 ; +398 ; +399 ; +400 ; the endef macro invocation goes here +401 ; +402 ; +403 0377 end + + + + + + + + + +alloc 00ae 164 172 177 183 203# +blksiz 0800 29# 151 +boot 0000 57# +chkuna 006f 148 160# +cpmspt 0050 33# 188 +dmaadr 0175 109 294 395# +dpbase 0000 55# 88 +erflag 0171 218 317 326 391# +filhst 00f2 235 260# +home 0008 65# 67# +homed 0012 70 72# +hstact 016a 61 71 231 383# +hstblk 0004 32# 33 34 35 +hstbuf 0177 291 396# +hstdsk 0165 239 263 378# +hstsec 0168 250 267 380# +hstsiz 0200 30# 32 396 +hstspt 0014 31# 33 +hsttrk 0166 244 265 379# +hstwrt 016b 68 256 272 302 324 384# +match 010fl 252 274# +nomatch 00eb 241 246 254# + + G-11 + + + + + + + + + +noovf 00a7 189 197# +read 0037 124# +readhst 0160 270 362# +readop 0173 129 144 296 393# +rsflag 0172 130 200 208 268 392# +rwmove 0135 298 305# 312 +rwoper 00b6 133 201 215# +secmsk 0003 34# 277 +secshf 0002 36# 220 +sectran 0034 112# +sekdsk 0161 78 153 169 238 262 374# +sekhst 0169 228 249 266 382# +seksec 0164 102 157 180 219 276 376# +sektrk 0162 96 155 264 337 375# +sektrkcmp 0153 176 245 334# +seldsk 0013 75# +setdma 002e 105# +setsec 0029 99# +settrk 0023 92# +unacnt 016c 62 127 152 162 168 206 386# +unadsk 016d 154 170 387# +unasec 0170 158 181 389# +unatrk 016e 156 175 193 195 388# +wboot 0000 58# +wrall 0000 43# +wrdir 0001 44# 316 +write 004b 141# +writehst 015f 258 325 355# +wrtype 0174 132 146 315 394# +wrual 0002 45# 131 147 + + + + + + + + + + + + G-12 + + diff --git a/Source/Doc/CPM 22 Manual - Testing/part3.ix b/Source/Doc/CPM 22 Manual - Testing/part3.ix new file mode 100644 index 00000000..2039f723 Binary files /dev/null and b/Source/Doc/CPM 22 Manual - Testing/part3.ix differ diff --git a/Source/Doc/CPM 22 Manual - Testing/part3.prn b/Source/Doc/CPM 22 Manual - Testing/part3.prn new file mode 100644 index 00000000..c4880949 Binary files /dev/null and b/Source/Doc/CPM 22 Manual - Testing/part3.prn differ diff --git a/Source/Doc/CPM 22 Manual - Testing/part3.tex b/Source/Doc/CPM 22 Manual - Testing/part3.tex new file mode 100644 index 00000000..e8e80d7e --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/part3.tex @@ -0,0 +1,2 @@ +.nx apph.tex + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/part3.txt b/Source/Doc/CPM 22 Manual - Testing/part3.txt new file mode 100644 index 00000000..4b87d790 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/part3.txt @@ -0,0 +1,2511 @@ + N + K + + + + + +Appendix H + +Glossary + + + +address: Number representing the location of a byte in memory. +Within CP/M there are two kinds of addresses: logical and physical. +A physical address refers to an absolute and unique location within +the computer's memory space. A logical address refers to the offset +or displacement of a byte in relation to a base location. A +standard CP/M program is loaded at address 0100H, the base value; +the first instruction of a program has a physical address of 0100H +and a relative address or offset of OH. + +allocation vector (ALV): An allocation vector is maintained in the +BIOS for each logged-in disk drive. A vector consists of a string +of bits, one for each block on the drive. The bit corresponding to +a particular block is set to one when the block has been allocated +and to zero otherwise. The first two bytes of this vector are +initialized with the bytes AL0 and AL1 on, thus allocating the +directory blocks. CP/M Function 27 returns the allocation vector +address. + +AL0, AL1: Two bytes in the disk parameter block that reserve data +blocks for the directory. These two bytes are copied into the first +two bytes of the allocation vector when a drive is logged in. See +allocation vector. + +ALV: See allocation vector. + +ambiguous filename: Filename that contains either of the CP/M +wildcard characters, ? or *, in the primary filename, filetype, or +both. When you replace characters in a filename with these wildcard +characters, you create an ambiguous filename and can easily +reference more than one CP/M file in a single command line. + +American Standard Code for Information Interchange: See ASCII. + +applications program: Program designed to solve a specific problem. +Typical applications programs are business accounting packages, word +processing (editing) programs and mailing list programs. + +archive attribute: File attribute controlled by the high-order bit +of the t3 byte (FCB+11) in a directory element. This attribute is +set if the file has been archived. + +argument: Symbol, usually a letter, indicating a place into which +you can substitute a number, letter, or name to give an appropriate +meaning to the formula in question. + +ASCII: American Standard Code for Information Interchange. ASCII +is a standard set of seven-bit numeric character codes used to +represent characters in memory. Each character requires one byte of +memory with the high-order bit usually set to zero. Characters can + + + H-1 + + + + + +CP/M Operating System Manual H Glossary + + +be numbers, letters, and symbols. An ASCII file can be intelligibly +displayed on the video screen or printed on paper. + +assembler: Program that translates assembly language into the +binary machine code. Assembly language is simply a set of mnemonics +used to designate the instruction set of the CPU. See ASM in +Section 3 of this manual. + +back-up: Copy of a disk or file made for safekeeping, or the +creation of the duplicate disk or file. + +Basic Disk Operating System: See BDOS. + +BDOS: Basic Disk Operating System. The BDOS module of the CP/M +operating system provides an interface for a user program to the +operating system. This interface is in the form of a set of +function calls which may be made to the BDOS through calls to +location 0005H in page zero. The user program specifies the number +of the desired function in register C. User programs running under +CP/M should use BDOS functions for all I/O operations to remain +compatible with other CP/M systems and future releases. The BDOS +normally resides in high memory directly below the BIOS. + +bias: Address value which when added to the origin address of your +BIOS module produces 1F80H, the address of the BIOS module in the +MOVCPM image. There is also a bias value that when added to the +BOOT module origin produces 0900H, the address of the BOOT module in +the MOVCPM image. You must use these bias values with the R command +under DDT or SID when you patch a CP/M system. If you do not, the +patched system may fail to function. + +binary: Base 2 numbering system. A binary digit can have one of +two values: 0 or 1. Binary numbers are used in computers because +the hardware can most easily exhibit two states: off and on. +Generally, a bit in memory represents one binary digit. + +Basic Input/Output System: See BIOS. + +BIOS: Basic Input/Output System. The BIOS is the only hardware- +dependent module of the CP/M system. It provides the BDOS with a +set of primitive I/O operations. The BIOS is an assembly language +module usually written by the user, hardware manufacturer, or +independent software vendor, and is the key to CP/M's portability. +The BIOS interfaces the CP/M system to its hardware environment +through a standardized jump table at the front of the BIOS routine +and through a set of disk parameter tables which define the disk +environment. Thus, the BIOS provides CP/M with a completely table- +driven I/O system. + +BIOS base: Lowest address of the BIOS module in memory, that by +definition must be the first entry point in the BIOS jump table. + + + + + + + H-2 + + + + + +CP/M Operating System Manual H Glossary + + +bit: Switch in memory that can be set to on (1) or off (0). Bits +are grouped into bytes, eight bits to a byte, which is the smallest +directly addressable unit in an Intel 8080 or Zilog Z80. By common +convention, the bits in a byte are numbered from right, 0 for the +low-order bit, to left, 7 for the high-order bit. Bit values are +often represented in hexadecimal notation by grouping the bits from +the low-order bit in groups of four. Each group of four bits can +have a value from 0 to 15 and thus can easily be represented by one +hexadecimal digit. + +BLM: See block mask. + +block: Basic unit of disk space allocation. Each disk drive has a +fixed block size (BLS) defined in its disk parameter block in the +BIOS. A block can consist of 1K, 2K, 4K, 8K, or 16K consecutive +bytes. Blocks are numbered relative to zero so that each block is +unique and has a byte displacement in a file equal to the block +number times the block size. + +block mask (BLM): Byte value in the disk parameter block at DPB + +3. The block mask is always one less than the number of 128 byte +sectors that are in one block. Note that BLM = (2 ** BSH) - 1. + +block shift (BSH): Byte parameter in the disk parameter block at +DPB + 2. Block shift and block mask (BLM) values are determined by +the block size (BLS). Note that BLM = (2 ** BSH) - 1. + +blocking & deblocking algorithm: In some disk subsystems the disk +sector size is larger than 128 bytes, usually 256, 512, 1024, or +2048 bytes. When the host sector size is larger than 128 bytes, +host sectors must be buffered in memory and the 128-byte CP/M +sectors must be blocked and deblocked by adding an additional +module, the blocking and deblocking algorithm, between the BIOS disk +I/O routines and the actual disk I/O. The host sector size must be +an even multiple of 128 bytes for the algorithm to work correctly. +The blocking and deblocking algorithm allows the BDOS and BIOS to +function exactly as if the entire disk consisted only of 128-byte +sectors, as in the standard CP/M installation. + +BLS: Block size in bytes. See block. + +boot: Process of loading an operating system into memory. A boot +program is a small piece of code that is automatically executed when +you power-up or reset your computer. The boot program loads the +rest of the operating system into memory in a manner similar to a +person pulling himself up by his own bootstraps. This process is +sometimes called a cold boot or cold start. Bootstrap pocedures +vary from system to system. The boot program must be customized for +the memory size and hardware environment that the operating system +manages. Typically, the boot resides on the first sector of the +system tracks on your system disk. When executed, the boot loads +the remaining sectors of the system tracks into high memory at the +location for which the CP/M system has been configured. Finally, +the boot transfers execution to the boot entry point in the BIOS +jump table so that the system can initialize itself. In this case, + + + H-3 + + + + + +CP/M Operating System Manual H Glossary + + +the boot program should be placed at 900H in the SYSGEN image. +Alternatively, the boot program may be located in ROM. + +bootstrap: See boot. + +BSH: See block shift. + +BTREE: General purpose file access method that has become the +standard organization for indexes in large data base systems. BTREE +provides near optimum performance over the full range of file +operations, such as insertion, deletion, search, and search next. + +buffer: Area of memory that temporarily stores data during the +transfer of information. + +built-in commands: Commands that permanently reside in memory. +They respond quickly because they are not accessed from a disk. + +byte: Unit of memory or disk storage containing eight bits. A byte +can represent a binary number between 0 and 255, and is the smallest +unit of memory that can be addressed directly in 8-bit CPUs such as +the Intel 8080 or Zilog Z80. + +CCP: Console Command Processor. The CCP is a module of the CP/M +operating system. It is loaded directly below the BDOS module and +interprets and executes commands typed by the console user. Usually +these commands are programs that the CCP loads and calls. Upon +completion, a command program may return control to the CCP if it +has not overwritten it. If it has, the program can reload the CCP +into memory by a warm boot operation initiated by either a jump to +zero, BDOS system reset (Function 0), or a cold boot. Except for +its location in high memory, the CCP works like any other standard +CP/M program; that is, it makes only BDOS function calls for its I/O +operations. + +CCP base: Lowest address of the CCP module in memory. This term +sometimes refers to the base of the CP/M system in memory, as the +CCP is normally the lowest CP/M module in high memory. + +checksum vector (CSV): Contiguous data area in the BIOS, with one +byte for each directory sector to be checked, that is, CKS bytes. +See CKS. A checksum vector is initialized and maintained for each +logged-in drive. Each directory access by the system results in a +checksum calculation that is compared with the one in the checksum +vector. If there is a discrepancy, the drive is set to Read-Only +status. This feature prevents the user from inadvertently switching +disks without logging in the new disk. If the new disk is not +logged-in, it is treated the same as the old one, and data on it +might be destroyed if writing is done. + +CKS: Number of directory records to be checked summed on directory +accesses. This is a parameter in the disk parameter block located +in the BIOS. If the value of CKS is zero, then no directory records +are checked. CKS is also a parameter in the diskdef macro library, +where it is the actual number of directory elements to be checked +rather than the number of directory records. + + H-4 + + + + + +CP/M Operating System Manual H Glossary + + + +cold boot: See boot. Cold boot also refers to a jump to the boot +entry point in the BIOS jump table. + +COM: Filetype for a CP/M command file. See command file. + +command: CP/M command line. In general, a CP/M command line has +three parts: the command keyword, command tail, and a carriage +return. To execute a command, enter a CP/M command line directly +after the CP/M prompt at the console and press the carriage return +or enter key. + +command file: Executable program file of filetype COM. A command +file is a machine language object module ready to be loaded and +executed at the absolute address of 0100H. To execute a command +file, enter its primary filename as the command keyword in a CP/M +command line. + +command keyword: Name that identifies a CP/M command, usually the +primary filename of a file of type COM, or a built-in command. The +command keyword precedes the command tail and the carriage return in +the command line. + +command syntax: Statement that defines the correct way to enter a +command. The correct structure generally includes the command +keyword, the command tail, and a carriage return. A syntax line +usually contains symbols that you should replace with actual values +when you enter the command. + +command tail: Part of a command that follows the command keyword in +the command line. The command tail can include a drive +specification, a filename and filetype, and options or parameters. +Some commands do not require a command tail. + +CON: Mnemonic that represents the CP/M console device. For +example, the CP/M command PIP CON:=TEST.SUB displays the file +TEST.SUB on the console device. The explanation of the STAT command +tells how to assign the logical device CON: to various physical +devices. See console. + +concatenate: Name of the PIP operation that copies two or more +separate files into one new file in the the specified sequence. + +concurrency: Execution of two processes or operations +simultaneously. + +CONIN: BIOS entry point to a routine that reads a character from +the console device. + +CONOUT: BIOS entry point to a routine that sends a character to the +console device. + + + + + + + H-5 + + + + + +CP/M Operating System Manual H Glossary + + +console: Primary input/output device. The console consists of a +listing device, such as a screen or teletype, and a keyboard through +which the user communicates with the operating system or +applications program. + +Console Command Processor: See CCP. + +CONST: BIOS entry point to a routine that returns the status of the +console device. + +control character: Nonprinting character combination. CP/M +interprets some control characters as simple commands such as line +editing functions. To enter a control character, hold down the +CONTROL key and strike the specified character key. + +Control Program for Microcomputers: See CP/M. + +CP/M: Control Program for Microcomputers. An operating system that +manages computer resources and provides a standard systems interface +to software written for a large variety of microprocessor-based +computer systems. + +CP/M 1.4l compatibility: For a CP/M 2 system to be able to read +correctly single-density disks produced under a CP/M 1.4 system, the +extent mask must be zero and the block size 1K. This is because +under CP/M 2 an FCB may contain more than one extent. The number of +extents that may be contained by an FCB is EXM+1. The issue of CP/M +1.4 compatibility also concerns random file I/O. To perform random +file I/O under CP/M 1.4, you must maintain an FCB for each extent of +the file. This scheme is upward compatible with CP/M 2 for files +not exceeding 512K bytes, the largest file size supported under CP/M +1.4. If you wish to implement random I/O for files larger than 512K +bytes under CP/M 2, you must use the random read and random write +functions, BDOS functions 33, 34, and 36. In this case, only one +FCB is used, and if CP/M 1.4 compatiblity is required, the program +must use the return version number function, BDOS Function 12, to +determine which method to employ. + +CP/M prompt: Characters that indicate that CP/M is ready to execute +your next command. The CP/M prompt consists of an upper-case +letter, A-P, followed by a > character; for example, A>. The letter +designates which drive is currently logged in as the default drive. +CP/M will search this drive for the command file specified, unless +the command is a built-in command or prefaced by a select drive +command: for example, B:STAT. + +CP/NET: Digital Research network operating system enabling +microcomputers to obtain access to common resources via a network. +CP/NET consists of MP/M masters and CP/M slaves with a network +interface between them. + +CSV: See checksum vector. + +cursor: One-character symbol that can appear anywhere on the +console screen. The cursor indicates the position where the next +keystroke at the console will have an effect. + + H-6 + + + + + +CP/M Operating System Manual H Glossary + + + +data file: File containing information that will be processed by a +program. + +deblocking: See blocking & deblocking algorithm. + +default: Currently selected disk drive and user number. Any +command that does not specify a disk drive or a user number +references the default disk drive and user number. When CP/M is +first invoked, the default disk drive is drive A, and the default +user number is 0. + +default buffer: Default 128-byte buffer maintained at 0080H in page +zero. When the CCP loads a COM file, this buffer is initialized to +the command tail; that is, any characters typed after the COM file +name are loaded into the buffer. The first byte at 0080H contains +the length of the command tail, while the command tail itself begins +at 0081H. The command tail is terminated by a byte containing a +binary zero value. The I command under DDT and SID initializes this +buffer in the same way as the CCP. + +default FCB: Two default FCBs are maintained by the CCP at 005CH +and 006CH in page zero. The first default FCB is initialized from +the first delimited field in the command tail. The second default +FCB is initialized from the next field in the command tail. + +delimiter: Special characters that separate different items in a +command line; for example, a colon separates the drive specification +from the filename. The CCP recognizes the following characters as +delimiters: . : = ; < > _, blank, and carriage return. Several +CP/M commands also treat the following as delimiter characters: , [ +] ( ) $. It is advisable to avoid the use of delimiter characters +and lower-case characters in CP/M filenames. + +DIR: Parameter in the diskdef macro library that specifies the +number of directory elements on the drive. + +DIR attribute: File attribute. A file with the DIR attribute can +be displayed by a DIR command. The file can be accessed from the +default user number and drive only. + +DIRBUF: 128-byte scratchpad area for directory operations, usually +located at the end of the BIOS. DIRBUF is used by the BDOS during +its directory operations. DIRBUF also refers to the two-byte +address of this scratchpad buffer in the disk parameter header at +DPbase + 8 bytes. + +directory: Portion of a disk that contains entries for each file on +the disk. In response to the DIR command, CP/M displays the +filenames stored in the directory. The directory also contains the +locations of the blocks allocated to the files. Each file directory +element is in the form of a 32-byte FCB, although one file can have +several elements, depending on its size. The maximum number of +directory elements supported is specified by the drive's disk +parameter block value for DRM. + + + H-7 + + + + + +CP/M Operating System Manual H Glossary + + +directory element: Data structure. Each file on a disk has one or +more 32-byte directory elements associated with it. There are four +directory elements per directory sector. Directory elements can +also be referred to as directory FCBs. + +directory entry: File entry displayed by the DIR command. +Sometimes this term refers to a physical directory element. + +disk, diskette: Magnetic media used for mass storage in a computer +system. Programs and data are recorded on the disk in the same way +music can be recorded on cassette tape. The CP/M operating system +must be initially loaded from disk when the computer is turned on. +Diskette refers to smaller capacity removable floppy diskettes, +while disk may refer to either a diskette, removable cartridge disk, +or fixed hard disk. Hard disk capacities range from five to several +hundred megabytes of storage. + +diskdef macro library: Library of code that when used with MAC, the +Digital Research macro assembler, creates disk definition tables +such as the DPB and DPH automatically. + +disk drive: Peripheral device that reads and writes information on +disk. CP/M assigns a letter to each drive under its control. For +example, CP/M may refer to the drives in a four-drive system as A, +B, C, and D. + +disk parameter block (DPB): Data structure referenced by one or +more disk parameter headers. The disk parameter block defines disk +characteristics in the fields listed below: + + SPT is the total number of sectors per track. + BSH is the data allocation block shift factor. + BLM is the data allocation block mask. + EXM is the extent mask determined by BLS and DSM. + DSM is the maximum data block number. + DRM is the maximum number of directory entries--1. + AL0 reserves directory blocks. + AL1 reserves directory blocks. + CKS is the number of directory sectors check summed. + OFF is the number of reserved system tracks. + +The address of the disk parameter block is located in the disk +parameter header at DPbase +0AH. CP/M Function 31 returns the DPB +address. Drives with the same characteristics can use the same disk +parameter header, and thus the same DPB. However, drives with +different characteristics must each have their own disk parameter +header and disk parameter blocks. When the BDOS calls the SELDSK +entry point in the BIOS, SELDSK must return the address of the +drive's disk parameter header in register HL. + +disk parameter header (DPH): Data structure that contains +information about the disk drive and provides a scratchpad area for +certain BDOS operations. The disk parameter header contains six +bytes of scratchpad area for the BDOS, and the following five 2-byte +parameters: + + + H-8 + + + + + +CP/M Operating System Manual H Glossary + + + + XLT is the sector translation table address. + DIRBUF is the directory buffer address. + DPB is the disk parameter block address. + CSV is the checksum vector address. + ALV is the allocation vector address. + +Given n disk drives, the disk parameter headers are arranged in a +table whose first row of 16 bytes corresponds to drive 0, with the +last row corresponding to drive n-1. + +DKS: Parameter in the diskdef macro library specifying the number +of data blocks on the drive. + +DMA: Direct Memory Access. DMA is a method of transferring data +from the disk into memory directly. In a CP/M system, the BDOS +calls the BIOS entry point READ to read a sector from the disk into +the currently selected DMA address. The DMA address must be the +address of a 128-byte buffer in memory, either the default buffer at +0080H in page zero, or a user-assigned buffer in the TPA. +Similarly, the BDOS calls the BIOS entry point WRITE to write the +record at the current DMA address to the disk. + +DN: Parameter in the diskdef macro library specifying the logical +drive number. + +DPB: See disk parameter block. + +DPH: See disk parameter header. + +DRM: 2-byte parameter in the disk parameter block at DPB + 7. DRM +is one less than the total number of directory entries allowed for +the drive. This value is related to DPB bytes AL0 and AL1, which +allocates up to 16 blocks for directory entries. + +DSM: 2-byte parameter of the disk parameter block at DPB + 5. DSM +is the maximum data block number supported by the drive. The +product BLS times (DSM+1) is the total number of bytes held by the +drive. This must not exceed the capacity of the physical disk less +the reserved system tracks. + +editor: Utility program that creates and modifies text files. An +editor can be used for creation of documents or creation of code for +computer programs. The CP/M editor is invoked by typing the command +ED next to the system prompt on the console. + +EX: Extent number field in an FCB. See extent. + +executable: Ready to be run by the computer. Executable code is a +series of instructions that can be carried out by the computer. For +example, the computer cannot execute names and addresses, but it can +execute a program that prints all those names and addresses on +mailing labels. + +execute a program: Start the processing of executable code. + + + H-9 + + + + + +CP/M Operating System Manual H Glossary + + + +EXM: See extent mask. + +extent: 16K consecutive bytes in a file. Extents are numbered from +0 to 31. One extent can contain 1, 2, 4, 8, or 16 blocks. EX is +the extent number field of an FCB and is a one-byte field at FCB + +12, where FCB labels the first byte in the FCB. Depending on the +block size (BLS) and the maximum data block number (DSM), an FCB can +contain 1, 2, 4, 8, or 16 extents. The EX field is normally set to +0 by the user but contains the current extent number during file +I/O. The term FCB folding describes FCBs containing more than one +extent. In CP/M version 1.4, each FCB contained only one extent. +Users attempting to perform random record I/O and maintain CP/M 1.4 +compatiblity should be aware of the implications of this difference. +See CP/M 1.4 compatibility. + +extent mask (EXM): A byte parameter in the disk parameter block +located at DPB + 3. The value of EXM is determined by the block +size (BLS) and whether the maximum data block number (DSM) exceeds +255. There are EXM + 1 extents per directory FCB. + +FCB: See File Control Block. + +file: Collection of characters, instructions, or data that can be +referenced by a unique identifier. Files are usually stored on +various types of media, such as disk, or magnetic tape. A CP/M file +is identified by a file specification and resides on disk as a +collection of from zero to 65,536 records. Each record is 128 bytes +and can contain either binary or ASCII data. Binary files contain +bytes of data that can vary in value from 0H to 0FFH. ASCII files +contain sequences of character codes delineated by a carriage return +and line-feed combination; normally byte values range from 0H to +7FH. The directory maps the file as a series of physical blocks. +Although files are defined as a sequence of consecutive logical +records, these records can not reside in consecutive sectors on the +disk. See also block, directory, extent, record, and sector. + +File Control Block (FCB): Structure used for accessing files on +disk. Contains the drive, filename, filetype, and other information +describing a file to be accessed or created on the disk. A file +control block consists of 36 consecutive bytes specified by the user +for file I/O functions. FCB can also refer to a directory element +in the directory portion of the allocated disk space. These contain +the same first 32 bytes of the FCB, but lack the current record and +random record number bytes. + +filename: Name assigned to a file. A filename can include a +primary filename of one to eight characters; a filetype of zero to +three characters. A period separates the primary filename from the +filetype. + +file specification: Unique file identifier. A complete CP/M file +specification includes a disk drive specification followed by a +colon, d:, a primary filename of one to eight characters, a period, +and a filetype of zero to three characters. For example, +b:example.tex is a complete CP/M file specification. + + H-10 + + + + + +CP/M Operating System Manual H Glossary + + + +filetype: Extension to a filename. A filetype can be from zero to +three characters and must be separated from the primary filename by +a period. A filetype can tell something about the file. Some +programs require that files to be processed have specific filetypes. + +floppy disk: Flexible magnetic disk used to store information. +Floppy disks come in 5 1/4- and 8-inch diameters. + +FSC: Parameter in the diskdef macro library specifying the first +physical sector number. This parameter is used to determine SPT and +build XLT. + +hard disk: Rigid, platter-like, magnetic disk sealed in a +container. A hard disk stores more information than a floppy disk. + +hardware: Physical components of a computer. + +hexadecimal notation: Notation for base 16 values using the decimal +digits and letters A, B, C, D, E, and F to represent the 16 digits. +Hexadecimal notation is often used to refer to binary numbers. A +binary number can be easily expressed as a hexadecimal value by +taking the bits in groups of 4, starting with the least significant +bit, and expressing each group as a hexadecimal digit, 0-F. Thus +the bit value 1011 becomes 0BH and 10110101 becomes 0B5H. + +hex file: ASCII-printable representation of a command, machine +language, file. + +hex file format: Absolute output of ASM and MAC for the Intel 8080 +is a hex format file, containing a sequence of absolute records that +give a load address and byte values to be stored, starting at the +load address. + +HOME: BIOS entry point which sets the disk head of the currently +selected drive to the track zero position. + +host: Physical characteristics of a hard disk drive in a system +using the blocking and deblocking algorithm. The term, host, helps +distinguish physical hardware characteristics from CP/M's logical +characteristics. For example, CP/M sectors are always 128 bytes, +although the host sector size can be a multiple of 128 bytes. + +input: Data going into the computer, usually from an operator +typing at the terminal or by a program reading from the disk. + +input/output: See I/O. + +interface: Object that allows two independent systems to +communicate with each other, as an interface between hardware and +software in a microcomputer. + +I/O: Abbreviation for input/output. Usually refers to input/output +operations or routines handling the input and output of data in the +computer system. + + + H-11 + + + + + +CP/M Operating System Manual H Glossary + + + +IOBYTE: A one-byte field in page zero, currently at location 0003H, +that can support a logical-to-physical device mapping for I/O. +However, its implementation in your BIOS is purely optional and +might or might not be supported in a given CP/M system. The IOBYTE +is easily set using the command: + + STAT = + +The CP/M logical devices are CON:, RDR:, PUN:, and LST:; each of +these can be assigned to one of four physical devices. The IOBYTE +can be initialized by the BOOT entry point of the BIOS and +interpreted by the BIOS I/O entry points CONST, CONIN, CONOUT, LIST, +PUNCH, and READER. Depending on the setting of the IOBYTE, +different I/O drivers can be selected by the BIOS. For example, +setting LST:=TTY: might cause LIST output to be directed to a serial +port, while setting LST:=LPT: causes LIST output to be directed to a +parallel port. + +K: Abbreviation for kilobyte. See kilobyte. + +keyword: See command keyword. + +kilobyte (K): 1024 bytes or 0400H bytes of memory. This is a +standard unit of memory. For example, the Intel 8080 supports up to +64K of memory address space or 65,536 bytes. 1024 kilobytes equal +one megabyte, or over one million bytes. + +linker: Utility program used to combine relocatable object modules +into an absolute file ready for execution. For example, LINK-80 +creates either a COM or PRL file from relocatable REL files, such as +those produced by PL/I-80 . + +LIST: A BIOS entry point to a routine that sends a character to the +list device, usually a printer. + +list device: Device such as a printer onto which data can be listed +or printed. + +LISTST: BIOS entry point to a routine that returns the ready status +of the list device. + +loader: Utility program that brings an absolute program image into +memory ready for execution under the operating system, or a utility +used to make such an image. For example, LOAD prepares an absolute +COM file from the assembler hex file output that is ready to be +executed under CP/M. + +logged in: Made known to the operating system, in reference to +drives. A drive is logged in when it is selected by the user or an +executing process. It remains selected or logged in until you +change disks in a floppy disk drive or enter CTRL-C at the command +level, or until a BDOS Function 0 is executed. + +logical: Representation of something that might or might not be the + + + H-12 + + + + + +CP/M Operating System Manual H Glossary + + +same in its actual physical form. For example, a hard disk can +occupy one physical drive, yet you can divide the available storage +on it to appear to the user as if it were in several different +drives. These apparent drives are the logical drives. + +logical sector: See sector. + +logical-to-physical sector translation table: See XLT. + +LSC: Diskdef macro library parameter specifying the last physical +sector number. + +LST: Logical CP/M list device, usually a printer. The CP/M list +device is an output-only device referenced through the LIST and +LISTST entry points of the BIOS. The STAT command allows assignment +of LST: to one of the physical devices: TTY:, CRT:, LPT:, or UL1:, +provided these devices and the IOBYTE are implemented in the LIST +and LISTST entry points of your CP/M BIOS module. The CP/NET +command NETWORK allows assignment of LST: to a list device on a +network master. For example, PIP LST:=TEST.SUB prints the file +TEST.SUB on the list device. + +macro assembler: Assembler code translator providing macro +processing facilities. Macro definitions allow groups of +instructions to be stored and substituted in the source program as +the macro names are encountered. Definitions and invocations can be +nested and macro parameters can be formed to pass arbitrary strings +of text to a specific macro for substitution during expansion. + +megabyte: Over one million bytes; 1024 kilobytes. See byte, and +kilobyte. + +microprocessor: Silicon chip that is the central processing unit +(CPU) of the microcomputer. The Intel 8080 and the Zilog Z80 are +microprocessors commonly used in CP/M systems. + +MOVCPM image: Memory image of the CP/M system created by MOVCPM. +This image can be saved as a disk file using the SAVE command or +placed on the system tracks using the SYSGEN command without +specifying a source drive. This image varies, depending on the +presence of a one-sector or two-sector boot. If the boot is less +than 128 bytes (one sector), the boot begins at 0900H, the CP/M +system at 0980H, and the BIOS at 1F80H. Otherwise, the boot is at +0900H, the CP/M system at 1000H, and the BIOS at 2000H. In a CP/M +1.4 system with a one-sector boot, the addresses are the same as for +the CP/M 2 system--except that the BIOS begins at 1E80H instead of +1F80H. + +MP/M: Multi-Programming Monitor control program. A microcomputer +operating system supporting multi-terminal access with multi- +programming at each terminal. + +multi-programming: The capability of initiating and executing more +than one program at a time. These programs, usually called +processes, are time-shared, each receiving a slice of CPU time on a +round-robin basis. See concurrency. + + + H-13 + + + + +CP/M Operating System Manual H Glossary + + +nibble: One half of a byte, usually the high-order or low-order 4 +bits in a byte. + +OFF: Two-byte parameter in the disk parameter block at DPB + 13 +bytes. This value specifies the number of reserved system tracks. +The disk directory begins in the first sector of track OFF. + +OFS: Diskdef macro library parameter specifying the number of +reserved system tracks. See OFF. + +operating system: Collection of programs that supervises the +execution of other programs and the management of computer +resources. An operating system provides an orderly input/output +environment between the computer and its peripheral devices. It +enables user-written programs to execute safely. An operating +system standardizes the use of computer resources for the programs +running under it. + +option: One of many parameters that can be part of a command tail. +Use options to specify additional conditions for a command's +execution. + +output: Data that is sent to the console, disk, or printer. + +page: 256 consecutive bytes in memory beginning on a page boundary, +whose base address is a multiple of 256 (100H) bytes. In hex +notation, pages always begin at an address with a least significant +byte of zero. + +page relocatable program: See PRL. + +page zero: Memory region between 0000H and 0100H used to hold +critical system parameters. Page zero functions primarily as an +interface region between user programs and the CP/M BDOS module. +Note that in non-standard systems this region is the base page of +the system and represents the first 256 bytes of memory used by the +CP/M system and user programs running under it. + +parameter: Value in the command tail that provides additional +information for the command. Technically, a parameter is a required +element of a command. + +peripheral devices: Devices external to the CPU. For example, +terminals, printers, and disk drives are common peripheral devices +that are not part of the processor but are used in conjunction with +it. + +physical: Characteristic of computer components, generally +hardware, that actually exist. In programs, physical components can +be represented by logical components. + +primary filename: First 8 characters of a filename. The primary +filename is a unique name that helps the user identify the file +contents. A primary filename contains one to eight characters and +can include any letter or number and some special characters. The + + + H-14 + + + + + +CP/M Operating System Manual H Glossary + + +primary filename follows the optional drive specification and +precedes the optional filetype. + +PRL: Page relocatable program. A page relocatable program is +stored on disk with a PRL filetype. Page relocatable programs are +easily relocated to any page boundary and thus are suitable for +execution in a nonbanked MP/M system. + +program: Series of coded instructions that performs specific tasks +when executed by a computer. A program can be written in a +processor-specific language or a high-level language that can be +implemented on a number of different processors. + +prompt: Any characters displayed on the video screen to help the +user decide what the next appropriate action is. A system prompt is +a special prompt displayed by the operating system. The alphabetic +character indicates the default drive. Some applications programs +have their own special prompts. See CP/M prompt. + +PUN: Logical CP/M punch device. The punch device is an output-only +device accessed through the PUNCH entry point of the BIOS. In +certain implementations, PUN: can be a serial device such as a +modem. + +PUNCH: BIOS entry point to a routine that sends a character to the +punch device. + +RDR: Logical CP/M reader device. The reader device is an input-only +device accessed through the READER entry point in the BIOS. See +PUN:. + +READ: Entry point in the BIOS to a routine that reads 128 bytes from +the currently selected drive, track, and sector into the current DMA +address. + +READER: Entry point to a routine in the BIOS that reads the next +character from the currently assigned reader device. + +Read-Only (R/O): Attribute that can be assigned to a disk file or a +disk drive. When assigned to a file, the Read-Only attribute allows +you to read from that file but not write to it. When assigned to a +drive, the Read-Only attribute allows you to read any file on the +disk, but prevents you from adding a new file, erasing or changing a +file, renaming a file, or writing on the disk. The STAT command can +set a file or a drive to Read-Only. Every file and drive is either +Read-Only or Read-Write. The default setting for drives and files +is Read-Write, but an error in resetting the disk or changing media +automatically sets the drive to Read-Only until the error is +corrected. See also ROM. + +Read-Write (R/W): Attribute that can be assigned to a disk file or +a disk drive. The Read-Write attribute allows you to read from and +write to a specific Read-Write file or to any file on a disk that is +in a drive set to Read-Write. A file or drive can be set to either +Read-Only or Read-Write. + + + H-15 + + + + + +CP/M Operating System Manual H Glossary + + +record: Group of bytes in a file. A physical record consists of +128 bytes and is the basic unit of data transfer between the +operating system and the application program. A logical record +might vary in length and is used to represent a unit of information. +Two 64-byte employee records can be stored in one 128-byte physical +record. Records are grouped together to form a file. + +recursive procedure: Code that can call itself during execution. + +reentrant procedure: Code that can be called by one process while +another is already executing it. Thus, reentrant code can be shared +between different users. Reentrant procedures must not be self- +modifying; that is, they must be pure code and not contain data. +The data for reentrant procedures can be kept in a separate data +area or placed on the stack. + +restart (RST): One-byte call instruction usually used during +interrupt sequences and for debugger break pointing. There are +eight restart locations, RST 0 through RST 7, whose addresses are +given by the product of 8 times the restart number. + +R/O: See Read-Only. + +ROM: Read-Only memory. This memory can be read but not written and +so is suitable for code and preinitialized data areas only. + +RST: See restart. + +R/W: See Read-Write. + +sector: In a CP/M system, a sector is always 128 consecutive bytes. +A sector is the basic unit of data read and written on the disk by +the BIOS. A sector can be one 128-byte record in a file or a sector +of the directory. The BDOS always requests a logical sector number +between 0 and (SPT-1). This is typically translated into a physical +sector by the BIOS entry point SECTRAN. In some disk subsystems, +the disk sector size is larger than 128 bytes, usually a power of +two, such as 256, 512, 1024, or 2048 bytes. These disk sectors are +always referred to as host sectors in CP/M documentation and should +not be confused with other references to sectors, in which cases the +CP/M 128-byte sectors should be assumed. When the host sector size +is larger than 128 bytes, host sectors must be buffered in memory +and the 128-byte CP/M sectors must be blocked and deblocked from +them. This can be done by adding an additional module, the blocking +and deblocking algorithm, between the BIOS disk I/O routines and the +actual disk I/O. + +sectors per track (SPT): A two-byte parameter in the disk parameter +block at DPB + 0. The BDOS makes calls to the BIOS entry point +SECTRAN with logical sector numbers ranging between 0 and (SPT - 1) +in register BC. + +SECTRAN: Entry point to a routine in the BIOS that performs +logical-to-physical sector translation for the BDOS. + + + + H-16 + + + + + +CP/M Operating System Manual H Glossary + + +SELDSK: Entry point to a routine in the BIOS that sets the +currently selected drive. + +SETDMA: Entry point to a routine in the BIOS that sets the +currently selected DMA address. The DMA address is the address of a +128-byte buffer region in memory that is used to transfer data to +and from the disk in subsequent reads and writes. + +SETSEC: Entry point to a routine in the BIOS that sets the +currently selected sector. + +SETTRK: Entry point to a routine in the BIOS that sets the +currently selected track. + +skew factor: Factor that defines the logical-to-physical sector +number translation in XLT. Logical sector numbers are used by the +BDOS and range between 0 and (SPT - 1). Data is written in +consecutive logical 128-byte sectors grouped in data blocks. The +number of sectors per block is given by BLS/128. Physical sectors +on the disk media are also numbered consecutively. If the physical +sector size is also 128 bytes, a one-to-one relationship exists +between logical and physical sectors. The logical-to-physical +translation table (XLT) maps this relationship, and a skew factor is +typically used in generating the table entries. For instance, if +the skew factor is 6, XLT will be: + + Logical: 0 1 2 3 4 5 6 ... 25 + Physical: 1 7 13 19 25 5 11 ... 22 + +The skew factor allows time for program processing without missing +the next sector. Otherwise, the system must wait for an entire disk +revolution before reading the next logical sector. The skew factor +can be varied, depending on hardware speed and application +processing overhead. Note that no sector translation is done when +the physical sectors are larger than 128 bytes, as sector deblocking +is done in this case. See also sector, SKF, and XLT. + +SKF: A diskdef macro library parameter specifying the skew factor +to be used in building XLT. If SKF is zero, no translation table is +generated and the XLT byte in the DPH will be 0000H. + +software: Programs that contain machine-readable instructions, as +opposed to hardware, which is the actual physical components of a +computer. + +source file: ASCII text file usually created with an editor that is +an input file to a system program, such as a language translator or +text formatter. + +SP: Stack pointer. See stack. + + + + + + + + H-17 + + + + + +CP/M Operating System Manual H Glossary + + +spooling: Process of accumulating printer output in a file while +the printer is busy. The file is printed when the printer becomes +free; a program does not have to wait for the slow printing process. + +SPT: See sectors per track. + +stack: Reserved area of memory where the processor saves the return +address when a call instruction is received. When a return +instruction is encountered, the processor restores the current +address on the stack to the program counter. Data such as the +contents of the registers can also be saved on the stack. The push +instruction places data on the stack and the pop instruction removes +it. An item is pushed onto the stack by decrementing the stack +pointer (SP) by 2 and writing the item at the SP address. In other +words, the stack grows downward in memory. + +syntax: Format for entering a given command. + +SYS: See system attribute. + +SYSGEN image: Memory image of the CP/M system created by SYSGEN +when a destination drive is not specified. This is the same as the +MOVCPM image that can be read by SYSGEN if a source drive is not +specified. See MOVCPM image. + +system attribute (SYS): File attribute. You can give a file the +system attribute by using the SYS option in the STAT command or by +using the set file attributes function, BDOS Function 12. A file +with the SYS attribute is not displayed in response to a DIR +command. If you give a file with user number 0 the SYS attribute, +you can read and execute that file from any user number on the same +drive. Use this feature to make your commonly used programs +available under any user number. + +system prompt: Symbol displayed by the operating system indicating +that the system is ready to receive input. See prompt and CP/M +prompt. + +system tracks: Tracks reserved on the disk for the CP/M system. +The number of system tracks is specified by the parameter OFF in the +disk parameter block (DPB). The system tracks for a drive always +precede its data tracks. The command SYSGEN copies the CP/M system +from the system tracks to memory, and vice versa. The standard +SYSGEN utility copies 26 sectors from track 0 and 26 sectors from +track 1. When the system tracks contain additional sectors or +tracks to be copied, a customized SYSGEN must be used. + +terminal: See console. + +TPA: Transient Program Area. Area in memory where user programs +run and store data. This area is a region of memory beginning at +0100H and extending to the base of the CP/M system in high memory. +The first module of the CP/M system is the CCP, which can be +overwritten by a user program. If so, the TPA is extended to the +base of the CP/M BDOS module. If the CCP is overwritten, the user + + + H-18 + + + + + +CP/M Operating System Manual H Glossary + + +program must terminate with either a system reset (Function 0) call +or a jump to location zero in page zero. The address of the base of +the CP/M BDOS is stored in location 0006H in page zero least +significant byte first. + +track: Data on the disk media is accessed by combination of track +and sector numbers. Tracks form concentric rings on the disk; the +standard IBM single-density disks have 77 tracks. Each track +consists of a fixed number of numbered sectors. Tracks are numbered +from zero to one less than the number of tracks on the disk. + +Transient Program Area: See TPA. + +upward compatible: Term meaning that a program created for the +previously released operating system, or compiler, runs under the +newly released version of the same operating system. + +USER: Term used in CP/M and MP/M systems to distinguish distinct +regions of the directory. + +user number: Number assigned to files in the disk directory so that +different users need only deal with their own files and have their +own directories, even though they are all working from the same +disk. In CP/M, files can be divided into 16 user groups. + +utility: Tool. Program that enables the user to perform certain +operations, such as copying files, erasing files, and editing files. +The utilities are created for the convenience of programmers and +users. + +vector: Location in memory. An entry point into the operating +system used for making system calls or interrupt handling. + +warm start: Program termination by a jump to the warm start vector +at location 0000H, a system reset (BDOS Function 0), or a CTRL-C +typed at the keyboard. A warm start reinitializes the disk +subsystem and returns control to the CP/M operating system at the +CCP level. The warm start vector is simply a jump to the WBOOT +entry point in the BIOS. + +WBOOT: Entry point to a routine in the BIOS used when a warm start +occurs. A warm start is performed when a user program branches to +location 0000H, when the CPU is reset from the front panel, or when +the user types CTRL-C. The CCP and BDOS are reloaded from the +system tracks of drive A. + +wildcard characters: Special characters that match certain +specified items. In CP/M there are two wildcard characters: ? and +*. The ? can be substituted for any single character in a filename, +and the * can be substituted for the primary filename, the filetype, +or both. By placing wildcard characters in filenames, the user +creates an ambiguous filename and can quickly reference one or more +files. + + + + + H-19 + + + + + +CP/M Operating System Manual H Glossary + + +word: 16-bit or two-byte value, such as an address value. Although +the Intel 8080 is an 8-bit CPU, addresses occupy two bytes and are +called word values. + +WRITE: Entry point to a routine in the BIOS that writes the record +at the currently selected DMA address to the currently selected +drive, track, and sector. + +XLT: Logical-to-physical sector translation table located in the +BIOS. SECTRAN uses XLT to perform logical-to-physical sector number +translation. XLT also refers to the two-byte address in the disk +parameter header at DPBASE + 0. If this parameter is zero, no +sector translation takes place. Otherwise this parameter is the +address of the translation table. + +ZERO PAGE: See page zero. + + +End of Appendix H + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + H-20 + + + + + + + + +Appendix I + +CP/M Error Messages + + + + Messages come from several different sources. CP/M displays +error messages when there are errors in calls to the Basic Disk +Operating System (BDOS). CP/M also displays messages when there are +errors in command lines. Each utility supplied with CP/M has its +own set of messages. The following lists CP/M messages and utility +messages. One might see messages other than those listed here if +one is running an application program. Check the application +program's documentation for explanations of those messages. + + + Table I-1. CP/M Error Messages + + F + Message Meaning + + ? + + DDT. This message has four possible + meanings: + + o DDT does not understand the assembly + language instruction. + o The file cannot be opened. + o A checksum error occurred in a HEX + file. + o The assembler/disassembler was + overlayed. + + + ABORTED + + PIP. You stopped a PIP operation by + pressing a key. + + + ASM Error Messages + + D Data error: data statement element + cannot be placed in specified data + area. + + E Expression error: expression cannot + be evaluated during assembly. + + L Label error: label cannot appear in + this context (might be duplicate + label). + + + + + + I-1 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + ASM Error Messages (continued) + + N Not implemented: unimplemented + features, such as macros, are + trapped. + + O Overflow: expression is too complex + to evaluate. + + P Phase error: label value changes on + two passes through assembly. + + R Register error: the value specified + as a register is incompatible with + the code. + + S Syntax error: improperly formed + expression. + + U Undefined label: label used does not + exist. + + V Value error: improperly formed + operand encountered in an expression. + + + BAD DELIMITER + + STAT. Check command line for typing + errors. + + + Bad Load + + CCP error message, or SAVE error message. + + + Bdos Err On d: + + Basic Disk Operating System error on the + designated drive: CP/M replaces d: with + the drive specification of the drive where + the error occurred. This message is + followed by one of the four phrases in the + situations described below. + + + + + + + + + I-2 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + Bdos Err On d: Bad Sector + + This message appears when CP/M finds no + disk in the drive, when the disk is + improperly formatted, when the drive latch + is open, or when power to the drive is + off. Check for one of these situations + and try again. This could also indicate a + hardware problem or a worn or improperly + formatted disk. Press ^C to terminate the + program and return to CP/M, or press + RETURN to ignore the error. + + + Bdos Err On d: File R/O + + You tried to erase, rename, or set file + attributes on a Read-Only file. The file + should first be set to Read-Write (R/W) + with the command: STAT filespec $R/W. + + + Bdos Err On d: R/O + + Drive has been assigned Read-Only status + with a STAT command, or the disk in the + drive has been changed without being + initialized with a ^C. CP/M terminates + the current program as soon as you press + any key. + + + Bdos Err on d: Select + + CP/M received a command line specifying a + nonexistent drive. CP/M terminates the + current program as soon as you press any + key. Press RETURN or CTRL-C to recover. + + + Break "x" at c + + ED. "x" is one of the symbols described + below and c is the command letter being + executed when the error occurred. + + # Search failure. ED cannot find the + string specified in an F, S, or N + command. + + + + + I-3 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + ? Unrecognized command letter c. ED + does not recognize the indicated + command letter, or an E, H, Q, or O + command is not alone on its command + line. + + O The file specified in an R command + cannot be found. + + > Buffer full. ED cannot put any more + characters in the memory buffer, or + the string specified in an F, N, or S + command is too long. + + E Command aborted. A keystroke at the + console aborted command execution. + + Break "x" at c (continued) + + F Disk or directory full. This error is + followed by either the disk or + directory full message. Refer to the + recovery procedures listed under + these messages. + + + CANNOT CLOSE DESTINATION FILE--\{filespec\} + + PIP. An output file cannot be closed. + You should take appropriate action after + checking to see if the correct disk is in + the drive and that the disk is not write- + protected. + + + Cannot close, R/O + CANNOT CLOSE FILES + + CP/M cannot write to the file. This + usually occurs because the disk is write- + protected. + + ASM. An output file cannot be closed. + This is a fatal error that terminates ASM + execution. Check to see that the disk is + in the drive, and that the disk is not + write-protected. + + + + + + + I-4 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + DDT. The disk file written by a W command + cannot be closed. This is a fatal error + that terminates DDT execution. Check if + the correct disk is in the drive and that + the disk is not write-protected. + + SUBMIT. This error can occur during + SUBMIT file processing. Check if the + correct system disk is in the A drive and + that the disk is not write-protected. The + SUBMIT job can be restarted after + rebooting CP/M. + + + CANNOT READ + + PIP. PIP cannot read the specified + source. Reader cannot be implemented. + + + CANNOT WRITE + + PIP. The destination specified in the PIP + command is illegal. You probably + specified an input device as a + destination. + + + Checksum error + + PIP. A HEX record checksum error was + encountered. The HEX record that produced + the error must be corrected, probably by + recreating the HEX file. + + + CHECKSUM ERROR + LOAD ADDRESS hhhh + ERROR ADDRESS hhhh + BYTES READ: + hhhh: + + LOAD. File contains incorrect data. + Regenerate HEX file from the source. + + + Command Buffer Overflow + + SUBMIT. The SUBMIT buffer allows up to + 2048 characters in the input file. + + + + I-5 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + Command too long + + SUBMIT. A command in the SUBMIT file + cannot exceed 125 characters. + + + CORRECT ERROR, TYPE RETURN OR CTRL-Z + + PIP. A HEX record checksum was + encountered during the transfer of a HEX + file. The HEX file with the checksum + error should be corrected, probably by + recreating the HEX file. + + + DESTINATION IS R/O, DELETE (Y/N)? + + PIP. The destination file specified in a + PIP command already exists and it is Read- + Only. If you type Y, the destination file + is deleted before the file copy is done. + + + Directory full + + ED. There is not enough directory space + for the file being written to the + destination disk. You can use the + OXfilespec command to erase any + unnecessary files on the disk without + leaving the editor. + + SUBMIT. There is not enough directory + space to write the $$$.SUB file used for + processing SUBMITs. Erase some files or + select a new disk and retry. + + + Disk full + + ED. There is not enough disk space for + the output file. This error can occur on + the W, E, H, or X commands. If it occurs + with X command, you can repeat the command + prefixing the filename with a different + drive. + + + + + + + + I-6 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + DISK READ ERROR--\{filespec\} + + PIP. The input disk file specified in a + PIP command cannot be read properly. This + is usually the result of an unexpected + end-of-file. Correct the problem in your + file. + + + DISK WRITE ERROR--\{filespec\} + + DDT. A disk write operation cannot be + successfully performed during a W command, + probably due to a full disk. You should + either erase some unnecessary files or get + another disk with more space. + + PIP. A disk write operation cannot be + successfully performed during a PIP + command, probably due to a full disk. You + should either erase some unnecessary files + or get another disk with more space and + execute PIP again. + + SUBMIT. The SUBMIT program cannot write + the $$$.SUB file to the disk. Erase some + files, or select a new disk and try again. + + + ERROR: BAD PARAMETER + + PIP. You entered an illegal parameter in + a PIP command. Retype the entry + correctly. + + + ERROR: CANNOT OPEN SOURCE, LOAD ADDRESS hhhh + + LOAD. Displayed if LOAD cannot find the + specified file or if no filename is + specified. + + + ERROR: CANNOT CLOSE FILE, LOAD ADDRESS hhhh + + LOAD. Caused by an error code returned by + a BDOS function call. Disk might be + write-protected. + + + + + + I-7 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + ERROR: CANNOT OPEN SOURCE, LOAD ADDRESS hhhh + + LOAD. Cannot find source file. Check + disk directory. + + + ERROR: DISK READ, LOAD ADDRESS hhhh + + LOAD. Caused by an error code returned by + a BDOS function call. + + + ERROR: DISK WRITE, LOAD ADDRESS hhhh + + LOAD. Destination disk is full. + + + ERROR: INVERTED LOAD ADDRESS, LOAD ADDRESS hhhh + + LOAD. The address of a record was too far + from the address of the previously- + processed record. This is an internal + limitation of LOAD, but it can be + circumvented. Use DDT to read the HEX + file into memory, then use a SAVE command + to store the memory image file on disk. + + + ERROR: NO MORE DIRECTORY SPACE, LOAD ADDRESS hhhh + + LOAD. Disk directory is full. + + + Error on line nnn message + + SUBMIT. The SUBMIT program displays its + messages in the format shown above, where + nnn represents the line number of the + SUBMIT file. Refer to the message + following the line number. + + + FILE ERROR + + ED. Disk or directory is full, and ED + cannot write anything more on the disk. + This is a fatal error, so make sure there + is enough space on the disk to hold a + second copy of the file before invoking + ED. + + + + I-8 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + FILE EXISTS + + You have asked CP/M to create or rename a + file using a file specification that is + already assigned to another file. Either + delete the existing file or use another + file specification. + + REN. The new name specified is the name + of a file that already exists. You cannot + rename a file with the name of an existing + file. If you want to replace an existing + file with a newer version of the same + file, either rename or erase the existing + file, or use the PIP utility. + + + File exists, erase it + + ED. The destination filename already + exists when you are placing the + destination file on a different disk than + the source. It should be erased or + another disk selected to receive the + output file. + + + ** FILE IS READ/ONLY ** + + ED. The file specified in the command to + invoke ED has the Read-Only attribute. Ed + can read the file so that the user can + examine it, but ED cannot change a Read- + Only file. + + + File Not Found + + CP/M cannot find the specified file. + Check that you have entered the correct + drive specification or that you have the + correct disk in the drive. + + ED. ED cannot find the specified file. + Check that you have entered the correct + drive specification or that you have the + correct disk in the drive. + + STAT. STAT cannot find the specified + file. The message might appear if you + omit the drive specification. Check to + see if the correct disk is in the drive. + + + I-9 + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + FILE NOT FOUND--\{filespec\} + + PIP. An input file that you have + specified does not exist. + + + Filename required + + ED. You typed the ED command without a + filename. Reenter the ED command followed + by the name of the file you want to edit + or create. + + + hhhh??=dd + + DDT. The ?? indicates DDT does not know + how to represent the hexadecimal value dd + encountered at address hhhh in 8080 + assembly language. dd is not an 8080 + machine instruction opcode. + + + Insufficient memory + + DDT. There is not enough memory to load + the file specified in an R or E command. + + + Invalid Assignment + + STAT. You specified an invalid drive or + file assignment, or misspelled a device + name. This error message might be + followed by a list of the valid file + assignments that can follow a filename. + If an invalid drive assignment was + attempted the message Use: d:=RO is + displayed, showing the proper syntax for + drive assignments. + + + + + + + + + + + + + + I-10 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + Invalid control character + + SUBMIT. The only valid control characters + in the SUBMIT files of the type SUB are ^ + A through ^ Z. Note that in a SUBMIT file + the control character is represented by + typing the circumflex, ^, not by pressing + the control key. + + + INVALID DIGIT--\{filespec\} + + PIP. An invalid HEX digit has been + encountered while reading a HEX file. The + HEX file with the invalid HEX digit should + be corrected, probably by recreating the + HEX file. + + + Invalid Disk Assignment + + STAT. Might appear if you follow the + drive specification with anything except + =R/O. + + + INVALID DISK SELECT + + CP/M received a command line specifying a + nonexistent drive, or the disk in the + drive is improperly formatted. CP/M + terminates the current program as soon as + you press any key. + + + INVALID DRIVE NAME (Use A, B, C, or D) + + SYSGEN. SYSGEN recognizes only drives A, + B, C, and D as valid destinations for + system generation. + + + Invalid File Indicator + + STAT. Appears if you do not specify RO, + RW, DIR, or SYS. + + + + + + + + I-11 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + INVALID FORMAT + + PIP. The format of your PIP command is + illegal. See the description of the PIP + command. + + + INVALID HEX DIGIT + LOAD ADDRESS hhhh + ERROR ADDRESS hhhh + BYTES READ: + hhhh + + LOAD. File contains incorrect HEX digit. + + + INVALID MEMORY SIZE + + MOVCPM. Specify a value less than 64K or + your computer's actual memory size. + + + INVALID SEPARATOR + + PIP. You have placed an invalid character + for a separator between two input + filenames. + + + INVALID USER NUMBER + + PIP. You have specified a user number + greater than 15. User numbers are in the + range 0 to 15. + + + n? + + USER. You specified a number greater than + fifteen for a user area number. For + example, if you type USER 18, the + screen displays 18?. + + + + + + + + + + + + I-12 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + NO DIRECTORY SPACE + + ASM. The disk directory is full. Erase + some files to make room for PRN and HEX + files. The directory can usually hold + only 64 filenames. + + + NO DIRECTORY SPACE--\{filespec\} + + PIP. There is not enough directory space + for the output file. You should either + erase some unnecessary files or get + another disk with more directory space and + execute PIP again. + + + NO FILE--\{filespec\} + + DIR, ERA, REN, PIP. CP/M cannot find the + specified file, or no files exist. + + ASM. The indicated source or include file + cannot be found on the indicated drive. + + DDT. The file specified in an R or E + command cannot be found on the disk. + + + NO INPUT FILE PRESENT ON DISK + + DUMP. The file you requested does not + exist. + + + No memory + + There is not enough (buffer?) memory + available for loading the program + specified. + + + NO SOURCE FILE ON DISK + + SYSGEN. SYSGEN cannot find CP/M either in + CPMxx.com form or on the system tracks of + the source disk. + + + + + + + I-13 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + NO SOURCE FILE PRESENT + + ASM. The assembler cannot find the file + you specified. Either you mistyped the + file specification in your command line, + or the filetype is not ASM. + + + NO SPACE + + SAVE. Too many files are already on the + disk, or no room is left on the disk to + save the information. + + + No SUB file present + + SUBMIT. For SUBMIT to operate properly, + you must create a file with filetype of + SUB. The SUB file contains usual CP/M + commands. Use one command per line. + + + NOT A CHARACTER SOURCE + + PIP. The source specified in your PIP + command is illegal. You have probably + specified an output device as a source. + + + ** NOT DELETED ** + + PIP. PIP did not delete the file, which + might have had the R/O attribute. + + + NOT FOUND + + PIP. PIP cannot find the specified file. + + + OUTPUT FILE WRITE ERROR + + ASM. You specified a write-protected disk + as the destination for the PRN and HEX + files, or the disk has no space left. + Correct the problem before assembling your + program. + + + + + + I-14 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + Parameter error + + SUBMIT. Within the SUBMIT file of type + sub, valid parameters are $0 through $9. + + + PARAMETER ERROR, TYPE RETURN TO IGNORE + + SYSGEN. If you press RETURN, SYSGEN + proceeds without processing the invalid + parameter. + + + QUIT NOT FOUND + + PIP. The string argument to a Q parameter + was not found in your input file. + + + Read error + + TYPE. An error occurred when reading the + file specified in the type command. Check + the disk and try again. The STAT filespec + command can diagnose trouble. + + + READER STOPPING + + PIP. Reader operation interrupted. + + + Record Too Long + + PIP. PIP cannot process a record longer + than 128 bytes. + + + Requires CP/M 2.0 or later + + XSUB. XSUB requires the facilities of + CP/M 2.0 or newer version. + + + + + + + + + + + + I-15 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + Requires CP/M 2.0 or new for operation + + PIP. This version of PIP requires the + facilities of CP/M 2.0 or newer version. + + + START NOT FOUND + + PIP. The string argument to an S + parameter cannot be found in the source + file. + + + SOURCE FILE INCOMPLETE + + SYSGEN. SYSGEN cannot use your CP/M + source file. + + + SOURCE FILE NAME ERROR + + ASM. When you assemble a file, you cannot + use the wildcard characters * and ? in the + filename. Only one file can be assembled + at a time. + + + SOURCE FILE READ ERROR + + ASM. The assembler cannot understand the + information in the file containing the + assembly-language program. Portions of + another file might have been written over + your assembly-language file, or + information was not properly saved on the + disk. Use the TYPE command to locate the + error. Assembly-language files contain + the letters, symbols, and numbers that + appear on your keyboard. If your screen + displays unrecognizable output or behaves + strangely, you have found where computer + instructions have crept into your file. + + + SYNCHRONIZATION ERROR + + MOVCPM. The MOVCPM utility is being used + with the wrong CP/M system. + + + + + + I-16 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + "SYSTEM" FILE NOT ACCESSIBLE + + You tried to access a file set to SYS with + the STAT command. + + + ** TOO MANY FILES ** + + STAT. There is not enough memory for STAT + to sort the files specified, or more than + 512 files were specified. + + + UNEXPECTED END OF HEX FILE--\{filespec\} + + PIP. An end-of-file was encountered prior + to a termination HEX record. The HEX file + without a termination record should be + corrected, probably by recreating the HEX + file. + + + Unrecognized Destination + + PIP. Check command line for valid + destination. + + + Use: STAT d:=RO + + STAT. An invalid STAT drive command was + given. The only valid drive assignment in + STAT is STAT d:=RO. + + + VERIFY ERROR:--\{filespec\} + + PIP. When copying with the V option, PIP + found a difference when rereading the data + just written and comparing it to the data + in its memory buffer. Usually this + indicates a failure of either the + destination disk or drive. + + + WRONG CP/M VERSION (REQUIRES 2.0) + + + XSUB ACTIVE + + SUBMIT. XSUB has been invoked. + + + I-17 + + + + + +CP/M Operating System Manual I CP/M Error Messages + + + Table I-1. (continued) + + Message Meaning + + XSUB ALREADY PRESENT + + SUBMIT. XSUB is already active in memory. + + Your input? + + If CP/M cannot find the command you + specified, it returns the command name you + entered followed by a question mark. + Check that you have typed the command line + correctly, or that the command you + requested exists as a .COM file on the + default or specified disk. + K + + +End of Appendix I + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + I-18 + + diff --git a/Source/Doc/CPM 22 Manual - Testing/sixa.tex b/Source/Doc/CPM 22 Manual - Testing/sixa.tex new file mode 100644 index 00000000..3b594928 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/sixa.tex @@ -0,0 +1,807 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 6-% +.pc 1 +.tc 6 CP/M 2 Alteration +.ce +.sh +Section 6 +.qs +.sp +.ce +.sh +CP/M 2 Alteration +.qs +.sp 3 +.tc 6.1 Introduction +.he CP/M Operating System Manual 6.1 Introduction +.sh +6.1 Introduction +.qs +.pp +The standard CP/M system assumes operation on an Intel Model +800 microcomputer development system , but is designed so you can alter a +specific set of subroutines that define the hardware operating +environment. +.pp +Although standard CP/M 2 is configured for single-density floppy +disks, field-alteration features allow adaptation to a wide +variety of disk subsystems from single-drive minidisks to +high-capacity, hard disk systems. To simplify the following +adaptation process, it is assumed that CP/M 2 is first +configured for single-density floppy disks where minimal editing +and debugging tools are available. If an earlier version of CP/M +is available, the customizing process is eased considerably. In +this latter case, you might want to review the system +generation process and skip to later sections that discuss system +alteration for nonstandard disk systems. +.pp +To achieve device independence, CP/M is separated into three +distinct modules: +.sp +.in 5 +.ti -2 +o BIOS is the Basic I/O System, which is environment dependent. +.sp +.ti -2 +o BDOS is the Basic Disk Operating System, which is not dependent upon the +hardware configuration. +.sp +.ti -2 +o CCP is the Console Command Processor, which uses the BDOS. +.fi +.in 0 +.pp +Of these modules, only the BIOS is dependent upon the particular +hardware. You can patch the distribution version +of CP/M to provide a new BIOS that provides a customized +interface between the remaining CP/M modules and the +hardware system. This document provides a step-by-step +procedure for patching a new BIOS into CP/M. +.mb 4 +.fm 1 +.pp +All disk-dependent portions of CP/M 2 are placed into a BIOS, a +resident disk parameter block, which is either hand coded or +produced automatically using the disk definition macro library +provided with CP/M 2. The end user need only specify the maximum +number of active disks, the starting and ending sector numbers, +the data allocation size, the maximum extent of the logical disk, +directory size information, and reserved track values. +The macros use this information to generate +the appropriate tables and table references for use during CP/M 2 +operation. Deblocking information is provided, which aids in +assembly or disassembly of sector sizes that are multiples of the +fundamental 128-byte data unit, and the system alteration manual +includes general purpose subroutines that use the deblocking +information to take advantage of larger sector sizes. Use of +these subroutines, together with the table-drive data access +algorithms, makes CP/M 2 a universal data management system. +.pp +File expansion is achieved by providing up to 512 logical file +extents, where each logical extent contains 16K bytes of data. +CP/M 2 is structured, however, so that as much as 128K bytes of +data are addressed by a single physical extent, corresponding to a +single directory entry, maintaining compatibility with previous +versions while taking advantage of directory space. +.pp +If CP/M is being tailored to a computer system for the first +time, the new BIOS requires some simple software development and +testing. The standard BIOS is listed in Appendix A and can be +used as a model for the customized package. A skeletal version +of the BIOS given in Appendix B can serve as the basis for a +modified BIOS. +.mb 6 +.fm 2 +.pp +In addition to the BIOS, you must write a simple memory +loader, called GETSYS, which brings the operating system into +memory. To patch the new BIOS into CP/M, you must write the +reverse of GETSYS, called PUTSYS, which places an altered version +of CP/M back onto the disk. PUTSYS can be derived from GETSYS by +changing the disk read commands into disk write commands. Sample +skeletal GETSYS and PUTSYS programs are described in Section 6.4 +and listed in Appendix C. +.pp +To make the CP/M system load automatically, you must also +supply a cold start loader, similar to the one provided with +CP/M, listed in Appendixes A and D. A skeletal form of a cold +start loader is given in Appendix E, which serves as a model for +the loader. +.mb 4 +.fm 1 +.sp 2 +.tc 6.2 First-level System Regeneration +.he CP/M Operating System Manual 6.2 First-level Regeneration +.sh +6.2 First-level System Regeneration +.qs +.pp +The procedure to patch the CP/M system is given below. Address +references in each step are shown with H denoting the +hexadecimal radix, and are given for a 20K CP/M system. For +larger CP/M systems, a bias is added to each address that is +shown with a +b following it, where b is equal to the memory +size-20K. Values for b in various standard memory sizes are listed in +Table 6-1. +.sp 2 +.sh + Table 6-1. Standard Memory Size Values + +.nf + Memory Size Value +.fi +.sp +.in 13 +24K: b = 24K - 20K = 4K = 1000H +.sp +32K: b = 32K - 20K = 12K = 3000H +.sp +40K: b = 40K - 20K = 20K = 5000H +.sp +48K: b = 48K - 20K = 28K = 7000H +.sp +56K: b = 56K - 20K = 36K = 9000H +.sp +62K: b = 62K - 20K = 42K = A800H +.sp +64K: b = 64K - 20K = 44K = B000H +.fi +.in 0 +.pp +Note that the standard distribution version of CP/M is set for +operation within a 20K CP/M system. Therefore, you must first bring up +the 20K CP/M system, then configure it for actual +memory size (see Section 6.3). +.pp +Follow these steps to patch your CP/M system: +.sp 2 +.in 8 +.ti -3 +1) Read Section 6.4 and write a GETSYS program that reads the +first two tracks of a disk into memory. The program from the +disk must be loaded starting at location 3380H. GETSYS is coded +to start at location 100H (base of the TPA) as shown in Appendix +C. +.mb 6 +.fm 2 +.sp +.ti -3 +2) Test the GETSYS program by reading a blank disk into memory, +and check to see that the data has been read properly and that +the disk has not been altered in any way by the GETSYS program. +.sp +.ti -3 +3) Run the GETSYS program using an initialized CP/M disk to see +if GETSYS loads CP/M starting at 3380H (the operating system +actually starts 128 bytes later at 3400H). +.sp +.ti -3 +4) Read Section 6.4 and write the PUTSYS program. This writes +memory starting at 3380H back onto the first two tracks of the +disk. The PUTSYS program should be located at 200H, as shown in +Appendix C. +.sp +.ti -3 +5) Test the PUTSYS program using a blank, uninitialized disk by +writing a portion of memory to the first two tracks; clear memory +and read it back using GETSYS. Test PUTSYS completely, because +this program will be used to alter CP/M on disk. +.sp +.ti -3 +6) Study Sections 6.5, 6.6, and 6.7 along with the distribution +version of the BIOS given in Appendix A and write a simple +version that performs a similar function for the customized +environment. Use the program given in Appendix B as a model. +Call this new BIOS by name CBIOS (customized BIOS). Implement +only the primitive disk operations on a single drive and simple +console input/output functions in this phase. +.sp +.ti -3 +7) Test CBIOS completely to ensure that it properly performs +console character I/O and disk reads and writes. Be careful to +ensure that no disk write operations occur during read operations +and check that the proper track and sectors are addressed on all +reads and writes. Failure to make these checks might cause +destruction of the initialized CP/M system after it is patched. +.mb 4 +.fm 1 +.sp +.ti -3 +8) Referring to Table 6-3 in Section 6.5, note that the BIOS is +placed between locations 4A00H and 4FFFH. Read the CP/M system +using GETSYS and replace the BIOS segment by the CBIOS developed +in step 6 and tested in step 7. This replacement is done in +memory. +.sp +.ti -3 +9) Use PUTSYS to place the patched memory image of CP/M onto the +first two tracks of a blank disk for testing. +.sp +.ti -4 +10) Use GETSYS to bring the copied memory image from the test +disk back into memory at 3380H and check to ensure that it has +loaded back properly (clear memory, if possible, before the +load). Upon successful load, branch to the cold start code at +location 4A00H. The cold start routine initializes page +zero, then jumps to the CCP at location 3400H, which calls the +BDOS, which calls the CBIOS. The CCP asks the CBIOS to read +sixteen sectors on track 2, and CP/M types A>, the system +prompt. +.mb 6 +.fm 2 +.sp +If difficulties are encountered, use whatever debug facilities +are available to trace and breakpoint the CBIOS. +.sp +.ti -4 +11) Upon completion of step 10, CP/M has prompted the console for +a command input. To test the disk write operation, type +.sp +SAVE 1 X.COM +.sp +All commands must be followed by a carriage return. CP/M +responds with another prompt after several disk accesses: +.sp +A> +.sp +If it does not, debug the disk write functions and retry. +.sp +.ti -4 +12) Test the directory command by typing +.sp +DIR +.sp +CP/M responds with +.sp +A:X COM +.sp +.ti -4 +13) Test the erase command by typing +.sp +ERA X.COM +.sp +CP/M responds with the A prompt. This is now an operational +system that only requires a bootstrap loader to function +completely. +.sp +.ti -4 +14) Write a bootstrap loader that is similar to GETSYS and place +it on track 0, sector 1, using PUTSYS (again using the test disk, +not the distribution disk). See Sections 6.5 and 6.8 for more +information on the bootstrap operation. +.sp +.ti -4 +15) Retest the new test disk with the bootstrap loader installed +by executing steps 11, 12, and 13. Upon completion of these +tests, type a CTRL-C. The system executes a warm start, which +reboots the system, and types the A prompt. +.sp +.ti -4 +16) At this point, there is probably a good version of the +customized CP/M system on the test disk. Use GETSYS to load CP/M +from the test disk. Remove the test disk, place the distribution +disk, or a legal copy, into the drive, and use PUTSYS to +replace the distribution version with the customized version. +Do not make this replacement if you are unsure of the patch +because this step destroys the system that was obtained from +Digital Research. +.sp +.ti -4 +17) Load the modified CP/M system and test it by typing +.sp +DIR +.sp +CP/M responds with a list of files that are provided on the +initialized disk. The file DDT.COM is the memory image for the +debugger. Note that from now on, you must always reboot the +CP/M system (CTRL-C is sufficient) when the disk is removed and +replaced by another disk, unless the new disk is to be Read-Only. +.sp +.ti -4 +18) Load and test the debugger by typing +.sp +DDT +.sp +See Chapter 4 for operating procedures. +.sp +.ti -4 +19) Before making further CBIOS modifications, practice using the +editor (see Chapter 2), and assembler (see Chapter 3). Recode +and test the GETSYS, PUTSYS, and CBIOS programs using ED, ASM, +and DDT. Code and test a COPY program that does a sector-to-sector +copy from one disk to another to obtain back-up copies of +the original disk. Read the CP/M Licensing Agreement specifying +legal responsibilities when copying the CP/M system. Place the +following copyright notice: +.sp +.nf +Copyright (c), 1983 + Digital Research +.fi +.sp +on each copy that is made with the COPY program. +.sp +.ti -4 +20) Modify the CBIOS to include the extra functions for punches, +readers, and sign-on messages, and add the facilities for +additional disk drives, if desired. These changes can be made +with the GETSYS and PUTSYS programs or by referring to the +regeneration process in Section 6.3. +.fi +.in 0 +.sp +.pp +You should now have a good copy of the customized CP/M +system. Although the CBIOS portion of CP/M belongs to the user, +the modified version cannot be legally copied. +.pp +It should be noted that the system remains file-compatible with +all other CP/M systems (assuming media compatibility) which +allows transfer of nonproprietary software between CP/M users. +.tc 6.3 Second-level System Generation +.bp +.he CP/M Operating System Manual 6.3 Second-level System Generation +.sh +6.3 Second-level System Generation +.qs +.pp +Once the system is running, the next step is to configure CP/M +for the desired memory size. Usually, a memory image is first +produced with the MOVCPM program (system relocator) and then +placed into a named disk file. The disk file can then be loaded, +examined, patched, and replaced using the debugger and the +system generation program (refer to Chapter 1). +.pp +The CBIOS and BOOT are modified using ED and assembled using ASM, +producing files called CBIOS.HEX and BOOT.HEX, which contain the +code for CBIOS and BOOT in Intel hex format. +.pp +To get the memory image of CP/M into the TPA configured for the +desired memory size, type the command: +.sp +.ti 8 +MOVCPM xx* +.sp +where xx is the memory size in decimal K bytes, for example, 32 +for 32K. The response is as follows: +.sp +.nf +.in 8 +CONSTRUCTING xxK CP/M VERS 2.0 +.sp +READY FOR "SYSGEN" OR +.sp +"SAVE 34 CPMxx.COM" +.fi +.in 0 +.pp +An image of CP/M in the TPA is configured for the requested +memory size. The memory image is at location 0900H through +227FH, that is, the BOOT is at 0900H, the CCP is at 980H, the +BDOS starts at 1180H, and the BIOS is at 1F80H. Note that the +memory image has the standard Model 800 BIOS and BOOT on it. It is now +necessary to save the memory image in a file so that you can +patch the CBIOS and CBOOT into it: +.sp +.ti 8 +SAVE 34 CPMxx.COM +.pp +The memory image created by the MOVCPM program is offset by a +negative bias so that it loads into the free area of the TPA, and +thus does not interfere with the operation of CP/M in higher +memory. This memory image can be subsequently loaded under DDT +and examined or changed in preparation for a new generation of +the system. DDT is loaded with the memory image by typing: +.sp +.ti 8 +DDT CPMxx.COM Loads DDT, then reads the CP/M image. +.sp +DDT should respond with the following: +.sp +.nf +.in 8 +NEXT PC +2300 0100 +- The DDT prompt +.fi +.in 0 +.sp +You can then give the display and disassembly commands to examine +portions of the memory image between 900H and 227FH. +Note, however, that to find any particular address +within the memory image, you must apply the negative bias to the +CP/M address to find the actual address. Track 00, sector 01, is +loaded to location 900H (the user should find the cold start +loader at 900H to 97FH); track 00, sector 02, is loaded into 980H +(this is the base of the CCP); and so on through the entire CP/M +system load. In a 20K system, for example, the CCP resides at +the CP/M address 3400H, but is placed into memory at 980H by the +SYSGEN program. Thus, the negative bias, denoted by n, satisfies +.sp +.ti 8 +3400H + n = 980H, or n =980H - 3400H +.sp +Assuming two's complement arithmetic, n = D580H, which can be +checked by +.sp +.ti 8 +.nf +3400H + D580H = 10980H = 0980H (ignoring high-order + overflow). +.fi +.pp +Note that for larger systems, n satisfies +.sp +.nf +.in 8 +(3400H+b) + n = 980H, or +n = 980H - (3400H + b), or +n = D580H - b +.fi +.in 0 +.sp +The value of n for common CP/M systems is given below. +.sp 2 +.sh + Table 6-2. Common Values for CP/M Systems +.sp +.nf + Memory Size BIAS b Negative Offset n +.sp +.in 13 +20K 0000H D580H - 0000H = D580H +24K 1000H D580H - 1000H = C580H +32K 3000H D580H - 3000H = A580H +40K 5000H D580H - 5000H = 8580H +48K 7000H D580H - 7000H = 6580H +56K 9000H D580H - 9000H = 4580H +62K A800H D580H - A800H = 2D80H +64K B000H D580H - B000H = 2580H +.fi +.in 0 +.sp +.pp +If you want to locate the address x within the memory image +loaded under DDT in a 20K system, first type +.sp +.ti 8 +Hx,n Hexadecimal sum and difference +.sp +and DDT responds with the value of x+n (sum) and x-n +(difference). The first number printed by DDT is the actual memory +address in the image where the data or code is located. For example, +the following DDT command: +.sp +.ti 8 +H3400,D580 +.sp +produces 980H as the sum, which is where the CCP +is located in the memory image under DDT. +.pp +Type the L command to disassemble portions of the +BIOS located at (4A00H+b)-n, which, when one uses the H command, +produces an actual address of 1F80H. The disassembly command +would thus be as follows: +.sp +.ti 8 +L1F80 +.sp +It is now necessary to patch in the CBOOT and CBIOS routines. The BOOT +resides at location 0900H in the memory image. If the actual +load address is n, then to calculate the bias (m), +type the command: +.sp +.ti 8 +H900,n Subtract load address from target address. +.pp +The second number typed by DDT in response to the command is the +desired bias (m). For example, if the BOOT executes at 0080H, +the command +.sp +.ti 8 +H900,80 +.sp +produces +.sp +.ti 8 +0980 0880 Sum and difference in hex. +.sp +Therefore, the bias m would be 0880H. To read-in the BOOT, give the command: +.sp +.ti 8 +ICBOOT.HEX Input file CBOOT.HEX +.sp +Then +.sp +.ti 8 +Rm Read CBOOT with a bias of m (=900H-n). +.sp +Examine the CBOOT with +.sp +.ti 8 +L900 +.sp +You are now ready to replace the CBIOS by examining the area at +1F80H, where the original version of the CBIOS resides, and then +typing +.sp +.ti 8 +ICBIOS.HEX Ready the hex file for loading. +.pp +Assume that the CBIOS is being integrated into a 20K +CP/M system and thus originates at location 4A00H. To locate the +CBIOS properly in the memory image under DDT, you must apply the +negative bias n for a 20K system when loading the hex file. This +is accomplished by typing +.sp +.ti 8 +RD580 Read the file with bias D580H. +.sp +Upon completion of the read, reexamine the area +where the CBIOS has been loaded (use an L1F80 command) to ensure +that it is properly loaded. When you are satisfied that the change has +been made, return from DDT using a CTRL-C or, G0 command. +.pp +SYSGEN is used to replace the patched memory image back onto a +disk (you use a test disk until sure of the +patch) as shown in the following interaction: +.sp 2 +.nf +.in 8 +SYSGEN Start the SYSGEN program. +.sp +SYSGEN VERSION 2.0 Sign-on message from SYSGEN. +.sp +SOURCE DRIVE NAME Respond with a carriage return +(OR RETURN TO SKIP) to skip the CP/M read operation + because the system is already + in memory. +.sp +DESTINATION DRIVE NAME Respond with B to write the new +(OR RETURN TO REBOOT) system to the disk in drive B. + +.sp +DESTINATION ON B, Place a scratch disk in drive +THEN TYPE RETURN B, then press RETURN. +.sp +FUNCTION COMPLETE +DESTINATION DRIVE NAME +(OR RETURN TO REBOOT) +.fi +.in 0 +.sp +.pp +Place the scratch disk in drive A, then +perform a cold start to bring up the newly-configured CP/M +system. +.pp +The new CP/M system is then tested and the Digital Research +copyright notice is placed on the disk, as specified in the +Licensing Agreement: +.sp +.nf +.in 8 +Copyright (c), 1979 + Digital Research +.fi +.in 0 +.sp 2 +.tc 6.4 Sample GETSYS and PUTSYS Programs +.he CP/M Operating System Manual 6.4 Sample GETSYS and PUTSYS +.sh +6.4 Sample GETSYS and PUTSYS Programs +.qs +.pp +The following program provides a framework for the GETSYS and +PUTSYS programs referenced in Sections 6.1 and 6.2. To read and +write the specific sectors, you must insert the READSEC and WRITESEC +subroutines. +.bp +.nf +; GETSYS PROGRAM -- READ TRACKS 0 AND 1 TO MEMORY AT 3380H +; REGISTER USE +.sp +; A (SCRATCH REGISTER) +.sp +; B TRACK COUNT (0, 1) +.sp +; C SECTOR COUNT (1,2,...,26) +.sp +; DE (SCRATCH REGISTER PAIR) +.sp +; HL LOAD ADDRESS +.sp +; SP SET TO STACK ADDRESS +.sp +; +START: LXI SP,3380H ;SET STACK POINTER TO SCRATCH + ;AREA + LXI H,3380H ;SET BASE LOAD ADDRESS + MVI B,0 ;START WITH TRACK 0 +RDTRK: ;READ NEXT TRACK (INITIALLY 0) + MVI C,1 ;READ STARTING WITH SECTOR 1 +.sp +RDSEC: ;READ NEXT SECTOR + CALL READSEC ;USER-SUPPLIED SUBROUTINE + LXI D,128 ;MOVE LOAD ADDRESS TO NEXT 1/2 + ;PAGE + DAD D ;HL = HL + 128 + INR C ;SECTOR = SECTOR + 1 + MOV A,C ;CHECK FOR END OF TRACK + CPI 27 + JC RDSEC ;CARRY GENERATED IF SECTOR <27 +.sp +; +; ARRIVE HERE AT END OF TRACK, MOVE TO NEXT TRACK + INR B + MOV A,B ;TEST FOR LAST TRACK + CPI 2 + JC RDTRK ;CARRY GENERATED IF TRACK <2 +.sp +; +; USER-SUPPLIED SUBROUTINE TO READ THE DISK +READSEC: +; ENTER WITH TRACK NUMBER IN REGISTER B, + SECTOR NUMBER IN REGISTER C, AND +.sp +; ADDRESS TO FILL IN HL +.sp +; + PUSH B ;SAVE B AND C REGISTERS + PUSH H ;SAVE HL REGISTERS +.sp 2 +.sh + Listing 6-1. GETSYS Program +.bp + ................................................. + perform disk read at this point, branch to + label START if an error occurs + ................................................. + POP H ;RECOVER HL + POP B ;RECOVER B AND C REGISTERS + RET ;BACK TO MAIN PROGRAM +.sp + END START +.fi +.in 0 +.sp 2 +.sh + Listing 6-1. (continued) +.sp 2 +.pp +This program is assembled and listed in Appendix B for reference +purposes, with an assumed origin of 100H. The hexadecimal +operation codes that are listed on the left might be useful if the +program has to be entered through the panel switches. +.pp +The PUTSYS program can be constructed from GETSYS by changing +only a few operations in the GETSYS program given above, as shown +in Appendix C. The register pair HL becomes the dump address, +next address to write, and operations on these registers do not +change within the program. The READSEC subroutine is replaced by +a WRITESEC subroutine, which performs the opposite function; data +from address HL is written to the track given by register B +and sector given by register C. It is often useful to combine +GETSYS and PUTSYS into a single program during the test and +development phase, as shown in Appendix C. +.sp 2 +.tc 6.5 Disk Organization +.he CP/M Operating System Manual 6.5 Disk Organization +.sh +6.5 Disk Organization +.qs +.pp +The sector allocation for the standard distribution version of +CP/M is given here for reference purposes. The first sector contains +an optional software boot section (see the table on the following +page. Disk controllers are often set up to bring track 0, +sector 1, into memory at a specific location, often location +0000H. The program in this sector, called BOOT, has the +responsibility of bringing the remaining sectors into memory +starting at location 3400H+b. If the controller does not +have a built-in sector load, the program in track 0, sector 1 can +be ignored. In this case, load the program from track 0, sector +2, to location 3400H+b. +.pp +As an example, the Intel Model 800 +hardware cold start loader brings track 0, sector 1, into +absolute address 3000H. Upon loading this sector, control +transfers to location 3000H, where the bootstrap operation +commences by loading the remainder of track 0 and all of track 1 +into memory, starting at 3400H+b. Note that this bootstrap +loader is of little use in a non-microcomputer development system +environment, although it is useful to examine it because some of +the boot actions will have to be duplicated in the user's cold +start loader. +.bp +.sh + Table 6-3. CP/M Disk Sector Allocation +.sp +.nf +Track # Sector Page# Memory Address CP/M Module name +.sp + 00 01 (boot address) Cold Start Loader + 00 02 00 3400H+b CCP + ' 03 ' 3480H+b ' + ' 04 01 3500H+b ' + ' 05 ' 3580H+b ' + ' 06 02 3600H+b ' + ' 07 ' 3680H+b ' + ' 08 03 3700H+b ' + ' 09 ' 3780H+b ' + ' 10 04 3800H+b ' + ' 11 ' 3880H+b ' + ' 12 05 3900H+b ' + ' 13 ' 3980H+b ' + ' 14 06 3A00H+b ' + ' 15 ' 3A80H+b ' + ' 16 07 3B00H+b ' + 00 17 ' 3B80H+b CCP + 00 18 08 3C00H+b BDOS + ' 19 ' 3C80H+b ' + ' 20 09 3D00H+b ' + ' 21 ' 3D80H+b ' + ' 22 10 3E00H+b ' + ' 23 ' 3E80H+b ' + ' 24 11 3F00H+b ' + ' 25 ' 3F80H+b ' + ' 26 12 4000H+b ' + 01 01 ' 4080H+b ' + ' 02 13 4100H+b ' + ' 03 ' 4180H+B ' + ' 04 14 4200H+b ' + ' 05 ' 4280H+b ' + ' 06 15 4300H+b ' + ' 07 ' 4380H+b ' + ' 08 16 4400H+b ' + ' 09 ' 4480H+b ' + ' 10 17 4500H+b ' + ' 11 ' 4580H+b ' + ' 12 18 4600H+b ' + ' 13 ' 4680H+b ' + ' 14 19 4700H+b ' + ' 15 ' 4780H+b ' + ' 16 20 4800H+b ' + ' 17 ' 4880H+b ' + ' 18 21 4900H+b ' +.mb 4 +.fm 1 + 01 19 ' 4900H+b BDOS + 07 20 22 4A00H+b BIOS + ' 21 ' 4A80H+b ' + ' 22 23 4B00H+b ' + ' 23 ' 4B80H+b ' + ' 24 24 4C00H+b ' + 01 25 ' 4C80H+b BIOS + 01 26 25 4D00H+b BIOS +02-76 01-26 (directory and data) +.fi +.nx sixb + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/sixb.tex b/Source/Doc/CPM 22 Manual - Testing/sixb.tex new file mode 100644 index 00000000..5ab5e7e7 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/sixb.tex @@ -0,0 +1,1311 @@ +.bp 13 +.tc 6.6 The BIOS Entry Points +.he CP/M Operating System Manual 6.6 BIOS Entry Points +.sh +6.6 The BIOS Entry Points +.qs +.pp 5 +The entry points into the BIOS from the cold start loader and +BDOS are detailed below. Entry to the BIOS is through a jump +vector located at 4A00H+b, as shown below. See Appendixes A and +B. The jump vector is a sequence of 17 jump +instructions that send program control to the individual BIOS +subroutines. The BIOS subroutines might be empty for certain +functions (they might contain a single RET operation) +during reconfiguration of CP/M, but the entries must be present +in the jump vector. +.pp +The jump vector at 4A00H+b takes the form shown below, where the +individual jump addresses are given to the left: +.mb 4 +.fm 1 +.mt 4 +.hm 1 +.sp 2 +.nf +.in 5 +4A00H+b JMP BOOT ;ARRIVE HERE FROM COLD + START LOAD +.sp +4A03H+b JMP WBOOT ;ARRIVE HERE FOR WARM START + +4A06H+b JMP CONST ;CHECK FOR CONSOLE CHAR + READY + +4A09H+b JMP CONIN ;READ CONSOLE CHARACTER IN + +4A0CH+b JMP CONOUT ;WRITE CONSOLE CHARACTER + OUT + +4A0FH+b JMP LIST ;WRITE LISTING CHARACTER OUT + +4A12H+b JMP PUNCH ;WRITE CHARACTER TO PUNCH + DEVICE + +4A15H+b JMP READER ;READ READER DEVICE + +4A18H+b JMP HOME ;MOVE TO TRACK 00 ON + SELECTED DISK + +4A1BH+b JMP SELDSK ;SELECT DISK DRIVE + +4A1EH+b JMP SETTRK ;SET TRACK NUMBER + +4A21H+b JMP SETSEC ;SET SECTOR NUMBER + +4A24H+b JMP SETDMA ;SET DMA ADDRESS + +4A27H+b JMP READ ;READ SELECTED SECTOR + +4A2AH+b JMP WRITE ;WRITE SELECTED SECTOR + +4A2DH+b JMP LISTST ;RETURN LIST STATUS + +4A30H+b JMP SECTRAN ;SECTOR TRANSLATE + SUBROUTINE +.fi +.in 0 +.sp 2 +.sh + Listing 6-2. BIOS Entry Points +.pp +Each jump address corresponds to a particular subroutine that performs the +specific function, as outlined below. There are three major +divisions in the jump table: the system reinitialization, +which results from calls on BOOT and WBOOT; simple character I/O, +performed by calls on CONST, CONIN, CONOUT, LIST, PUNCH, READER, +and LISTST; and disk I/O, performed by calls on HOME, SELDSK, +SETTRK, SETSEC, SETDMA, READ, WRITE, and SECTRAN. +.pp +All simple character I/O operations are assumed to be performed +in ASCII, upper- and lower-case, with high-order (parity bit) set +to zero. An end-of-file condition for an input device is given +by an ASCII CTRL-Z (1AH). Peripheral devices are seen by CP/M as +logical devices and are assigned to physical devices within the +BIOS. +.pp +To operate, the BDOS needs only the CONST, CONIN, and CONOUT +subroutines. LIST, PUNCH, and READER can be used by PIP, but not +the BDOS. Further, the LISTST entry is currently used only by +DESPOOL, the print spooling utility. Thus, the initial version +of CBIOS can have empty subroutines for the remaining ASCII +devices. +.pp +The following list describes the characteristics of each device. +.sp 2 +.in 5 +.ti -2 +o CONSOLE is the principal interactive console that communicates with the +operator and it is accessed through CONST, CONIN, and CONOUT. Typically, the +CONSOLE is a device such as a CRT or teletype. +.sp +.ti -2 +o LIST is the principal listing device. If it exists on the user's system, +it is usually a hard-copy device, such as a printer or teletype. +.sp +.ti -2 +o PUNCH is the principal tape punching device. If it exists, it is normally a +high-speed paper tape punch or teletype. +.sp +.ti -2 +o READER is the principal tape reading device, such as a simple optical +reader or teletype. +.fi +.in 0 +.sp +.pp +A single peripheral can be assigned as the LIST, PUNCH, and +READER device simultaneously. If no peripheral device is +assigned as the LIST, PUNCH, or READER device, the CBIOS +gives an appropriate error message so that the +system does not hang if the device is accessed by PIP or some +other user program. Alternately, the PUNCH and LIST routines can +just simply return, and the READER routine can return with a 1AH +(CTRL-Z) in register A to indicate immediate end-of-file. +.pp +For added flexibility, you can optionally implement the +IOBYTE function, which allows reassignment of physical devices. +The IOBYTE function creates a mapping of logical-to-physical +devices that can be altered during CP/M processing, +see the STAT command in Section 1.6.1. +.pp +The definition of the IOBYTE function corresponds to the Intel +standard as follows: a single location in memory, currently +location 0003H, is maintained, called IOBYTE, which defines the +logical-to-physical device mapping that is in effect at a +particular time. The mapping is performed by splitting the +IOBYTE into four distinct fields of two bits each, called the +CONSOLE, READER, PUNCH, and LIST fields, as shown in the +following figure. +.sp 2 +.nf + most significant least significant +.sp + IOBYTE AT 003H LIST PUNCH READER CONSOLE +.sp + bits 6,7 bits 4,5 bits 2,3 bits 0,1 +.fi +.sp 2 +.sh + Figure 6-1. IOBYTE Fields +.sp 2 +.pp +The value in each field can be in the range 0-3, defining the +assigned source or destination of each logical device. Table 6-4 +gives the values that can be assigned to each field. +.sp 2 +.sh +.nf + Table 6-4. IOBYTE Field Values +.sp + Value Meaning +.sp + CONSOLE field (bits 0,1) +.sp + 0 console is assigned to the console printer + device (TTY:) + 1 console is assigned to the CRT device (CRT:) + 2 batch mode: use the READER as the CONSOLE input, + and the LIST device as the CONSOLE output (BAT:) + 3 user-defined console device (UC1:) +.sp +.mb 4 +.fm 1 +.mt 4 +.hm 1 + READER field (bits 2,3) +.sp + 0 READER is the teletype device (TTY:) + 1 READER is the high speed reader device (PTR:) + 2 user-defined reader #1 (UR1:) + 3 user-defined reader #2 (UR2:) +.sp + PUNCH field (bits 4,5) +.sp + 0 PUNCH is the teletype device (TTY:) + 1 PUNCH is the high speed punch device (PTP:) + 2 user-defined punch #1 (UP1:) + 3 user-defined punch #2 (UP2:) +.sp + LIST field (bits 6,7) +.sp + 0 LIST is the teletype device (TTY:) + 1 LIST is the CRT device (CRT:) + 2 LIST is the line printer device (LPT:) + 3 user-defined list device (UL1:) +.fi +.bp +.pp +The implementation of the IOBYTE is optional and effects only the +organization of the CBIOS. No CP/M systems use the IOBYTE +(although they tolerate the existence of the IOBYTE at location +0003H) except for PIP, which allows access to the physical +devices, and STAT, which allows logical-physical assignments to +be make or displayed. For more information see Section 1. In +any case the IOBYTE implementation should be omitted until the +basic CBIOS is fully implemented and tested; then you should +add the IOBYTE to increase the facilities. +.mb 6 +.fm 2 +.mt 5 +.hm 2 +.pp +Disk I/O is always performed through a sequence of calls on the +various disk access subroutines that set up the disk number to +access, the track and sector on a particular disk, and the Direct +Memory Access (DMA) address involved in the I/O operation. After +all these parameters have been set up, a call is made to the READ +or WRITE function to perform the actual I/O operation. +.pp +There is often a single call to SELDSK to select a disk drive, +followed by a number of read or write operations to the selected +disk before selecting another drive for subsequent operations. +Similarly, there might be a single call to set the DMA address, +followed by several calls that read or write from the selected +DMA address before the DMA address is changed. The track and +sector subroutines are always called before the READ or WRITE +operations are performed. +.pp +The READ and WRITE routines should perform several retries (10 is +standard) before reporting the error condition to the BDOS. If +the error condition is returned to the BDOS, it reports the +error to the user. The HOME subroutine might or might not actually +perform the track 00 seek, depending upon controller +characteristics; the important point is that track 00 has been +selected for the next operation and is often treated in exactly +the same manner as SETTRK with a parameter of 00. +.pp +The following table describes the exact responsibilities of each +BIOS entry point subroutine. +.sp 2 +.sh + Table 6-5. BIOS Entry Points +.sp + Entry Point Function +.sp +.ll 60 +.in 15 +.ti -9 +BOOT The BOOT entry point gets control from the cold start loader and is +responsible for basic system initialization, including sending a sign-on +message, which can be omitted in the first version. If the IOBYTE function +is implemented, it must be set at this point. The various system parameters +that are set by the WBOOT entry point must be initialized, and control is +transferred to the CCP at 3400+b for further processing. Note that register +C must be set to zero to select drive A. +.in 0 +.bp +.sh + Table 6-5. (continued) +.sp + Entry Point Function +.sp +.in 15 +.ti -9 +WBOOT The WBOOT entry point gets control when a warm start occurs. A warm +start is performed whenever a user program branches to location 0000H, or +when the CPU is reset from the front panel. The CP/M system must be loaded +from the first two tracks of drive A up to, but not including, the BIOS, or +CBIOS, if the user has completed the patch. System parameters must be +initialized as follows: +.sp +.in 32 +.ti -17 +location 0,1,2 Set to JMP WBOOT for warm starts (000H: JMP 4A03H+b) +.sp +.ti -17 +location 3 Set initial value of IOBYTE, if implemented in the CBIOS +.sp +.ti -17 +location 4 High nibble = current user no; low nibble = current drive +.sp +.ti -17 +location 5,6,7 Set to JMP BDOS, which is the primary entry point to CP/M for +transient programs. (0005H: JMP 3C06H+b) +.sp +.in 15 +Refer to Section 6.9 for complete details of page zero use. +Upon completion of the initialization, the WBOOT program must branch to the +CCP at 3400H+b to restart the system. Upon entry to the CCP, register C is +set to the drive to select after system initialization. The WBOOT routine +should read location 4 in memory, verify that is a legal drive, and pass it +to the CCP in register C. +.sp +.ti -9 +CONST You should sample the status of the currently assigned console +device and return 0FFH in register A if a character is ready to read and 00H +in register A if no console characters are ready. +.sp +.ti -9 +CONIN The next console character is read into register A, and the parity +bit is set, high-order bit, to zero. If no console character is ready, +wait until a character is typed before returning. +.in 0 +.bp +.sh + Table 6-5. (continued) +.sp + Entry Point Function +.sp +.in 15 +.ti -9 +CONOUT The character is sent from register C to the console +output device. The character is in ASCII, with high-order parity +bit set to zero. You might want to include a time-out on a +line-feed or carriage return, if the console device requires some +time interval at the end of the line (such as a TI Silent 700 +terminal). You can filter out control characters that cause +the console device to react in a strange way (CTRL-Z causes the +Lear-Seigler terminal to clear the screen, for example). +.sp +.ti -9 +LIST The character is sent from register C to the currently +assigned listing device. The character is in ASCII with zero +parity bit. +.sp +.ti -9 +PUNCH The character is sent from register C to the currently +assigned punch device. The character is in ASCII with zero +parity. +.sp +.ti -9 +READER The next character is read from the currently assigned reader +device into register A with zero parity (high-order bit must be +zero); an end-of-file condition is reported by returning an ASCII +CTRL-Z(1AH). +.sp +.ti -9 +HOME The disk head of the currently selected disk +(initially disk A) is moved to the track 00 position. If the controller +allows access to the track 0 flag from the drive, the head is +stepped until the track 0 flag is detected. If the controller +does not support this feature, the HOME +call is translated into a call to SETTRK with a parameter of 0. +.sp +.ti -9 +SELDSK The disk drive given by register C is selected for further +operations, where register C contains 0 for drive A, 1 for drive B, and so +on up to 15 for drive P (the standard CP/M distribution version supports four +drives). On each disk select, SELDSK must return in HL the base address of a +16-byte area, called the Disk Parameter Header, described in Section 6.10. +For standard floppy disk drives, the contents of the header and associated +tables do not change; thus, the program segment included in the sample CBIOS +performs this operation automatically. +.in 0 +.bp +.sh + Table 6-5. (continued) +.sp + Entry Point Function +.sp +.in 15 +If there is an attempt to select a +nonexistent drive, SELDSK returns HL=0000H as an error indicator. +Although SELDSK must return the header address on each call, it is advisable +to postpone the physical disk select operation until an I/O function (seek, +read, or write) is actually performed, because disk selects often occur +without utimately performing any disk I/O, and many controllers unload +the head of the current disk before selecting the new drive. This +causes an excessive amount of noise and disk wear. The least significant bit +of register E is zero if this is the first occurrence of the drive select +since the last cold or warm start. +.sp +.ti -9 +SETTRK Register BC contains the track number for subsequent disk accesses +on the currently selected drive. The sector number in BC is the same as the +number returned from the SECTRAN entry point. You can choose to seek +the selected track at this time or delay the seek until the next read or +write actually occurs. Register BC can take on values in the range 0-76 +corresponding to valid track numbers for standard floppy disk drives and +0-65535 for nonstandard disk subsystems. +.sp +.ti -9 +SETSEC Register BC contains the sector number, 1 through 26, for subsequent +disk accesses on the currently selected drive. The sector number in BC is +the same as the number returned from the SECTRAN entry point. You can +choose to send this information to the controller at this point or delay +sector selection until a read or write operation occurs. +.mb 4 +.fm 1 +.sp +.ti -9 +SETDMA Register BC contains the DMA (Disk Memory Access) address for +subsequent read or write operations. For example, if B = 00H and C = 80H +when SETDMA is called, all subsequent read operations read their data into +80H through 0FFH and all subsequent write operations get their +data from 80H through 0FFH, until the next call +to SETDMA occurs. The initial DMA address is +assumed to be 80H. The controller need not +actually support Direct Memory Access. If, +for example, all data transfers are through I/O +ports, the CBIOS that is constructed uses +the 128-byte area starting at the selected DMA +address for the memory buffer during the +subsequent read or write operations. +.in 0 +.bp +.sh + Table 6-5. (continued) +.sp + Entry Point Function +.sp +.in 15 +.ti -9 +READ Assuming the drive has been selected, the track +has been set, and the DMA address has been +specified, the READ subroutine attempts to +read one sector based upon these parameters +and returns the following error codes in +register A: +.sp +0 no errors occurred +.sp +1 nonrecoverable error condition occurred +.sp +Currently, CP/M responds only to a zero or nonzero +value as the return code. That is, if the +value in register A is 0, CP/M assumes that the +disk operation was completed properly. IF an +error occurs the CBIOS should attempt +at least 10 retries to see if the error is +recoverable. When an error is reported the BDOS +prints the message BDOS ERR ONx: BAD +SECTOR. The operator then has the option of +pressing a carriage return to ignore the error, or +CTRL-C to abort. +.sp +.ti -9 +WRITE Data is written from the currently +selected DMA address to the currently selected +drive, track, and sector. For floppy disks, the +data should be marked as nondeleted data to +maintain compatibility with other CP/M systems. +The error codes given in the READ command are +returned in register A, with error recovery +attempts as described above. +.mb 6 +.fm 2 +.sp +.ti -9 +LISTST You return the ready status of the list +device used by the DESPOOL program to improve +console response during its operation. The +value 00 is returned in A if the list device is +not ready to accept a character and 0FFH if a +character can be sent to the printer. A 00 +value should be returned if LIST status is not +implemented. +.in 0 +.bp +.sh + Table 6-5. (continued) +.sp + Entry Point Function +.sp +.in 15 +.ti -9 +SECTRAN Logical-to-physical sector +translation is performed to improve the overall response of +CP/M. Standard CP/M systems are shipped with a +skew factor of 6, where six physical sectors are +skipped between each logical read operation. +This skew factor allows enough time between +sectors for most programs to load their buffers +without missing the next sector. In particular +computer systems that use fast processors, +memory, and disk subsystems, the skew factor might +be changed to improve overall response. +However, the user should maintain a single-density +IBM-compatible version of CP/M for +information transfer into and out of the +computer system, using a skew factor of 6. +.sp +In general, SECTRAN receives a logical sector +number relative to zero in BC and a translate +table address in DE. The sector number is used +as an index into the translate table, with the +resulting physical sector number +in HL. For standard systems, the table and +indexing code is provided in the CBIOS and +need not be changed. +.in 0 +.ll 65 +.sp 2 +.tc 6.7 A Sample BIOS +.he CP/M Operating System Manual 6.7 A Sample BIOS +.sh +6.7 A Sample BIOS +.qs +.pp +The program shown in Appendix B can serve as a basis for your +first BIOS. The simplest functions are assumed in this BIOS, so +that you can enter it through a front panel, if absolutely +necessary. You must alter and insert code into the +subroutines for CONST, CONIN, CONOUT, READ, WRITE, and WAITIO +subroutines. Storage is reserved for user-supplied code in these +regions. The scratch area reserved in page zero (see Section +6.9) for the BIOS is used in this program, so that it could be +implemented in ROM, if desired. +.pp +Once operational, this skeletal version can be enhanced to print +the initial sign-on message and perform better error recovery. +The subroutines for LIST, PUNCH, and READER can be filled out and +the IOBYTE function can be implemented. +.sp 2 +.tc 6.8 A Sample Cold Start Loader +.he CP/M Operating System Manual 6.8 A Sample Cold Start Loader +.sh +6.8 A Sample Cold Start Loader +.qs +.pp +The program shown in Appendix E can serve as a basis for a cold +start loader. The disk read function must be supplied by the +user, and the program must be loaded somehow starting at location +0000. Space is reserved for the patch code so that the total +amount of storage required for the cold start loader is 128 +bytes. +.pp +Eventually, you might want to get this +loader onto the first disk sector (track 0, sector 1) and cause +the controller to load it into memory automatically upon system +start up. Alternatively, the cold start loader can be placed +into ROM, and above the CP/M system. In this case, it is +necessary to originate the program at a higher address and key in +a jump instruction at system start up that branches to the +loader. Subsequent warm starts do not require this key-in +operation, because the entry point WBOOT gets control, thus bringing +the system in from disk automatically. The skeletal cold start +loader has minimal error recovery, which might be enhanced in later +versions. +.sp 2 +.tc 6.9 Reserved Locations in Page Zero +.he CP/M Operating System Manual 6.9 Reserved Locations in Page Zero +.sh +6.9 Reserved Locations in Page Zero +.qs +.pp +Main memory page zero, between locations 00H and 0FFH, contains +several segments of code and data that are used during CP/M +processing. The code and data areas are given in the following table. +.sp 2 +.sh + Table 6-6. Reserved Locations in Page Zero +.sp +.nf + Locations Contents +.fi +.sp +.ll 60 +.in 22 +.ti -17 +000H-0002H Contains a jump instruction to the warm start entry location +4A03H+b. This allows a simple programmed restart (JMP 0000H) or manual +restart from the front panel. +.sp +.ti -17 +0003H-0003H Contains the Intel standard IOBYTE is optionally +included in the user's CBIOS (refer to Section 6.6). +.sp +.ti -17 +0004H-0004H Current default drive number (0=A,...,15=P). +.sp +.ti -17 +0005H-0007H Contains a jump instruction to the BDOS and serves two +purposes: JMP 0005H provides the primary entry point to the BDOS, as +described in Chapter 5, and LHLD 0006H brings the address field of the +instruction to the HL register pair. This value is the lowest address in +memory used by CP/M, assuming the CCP is being overlaid. The DDT program +changes the address field to reflect the reduced memory size in debug mode. +.sp +.ti -17 +0008H-0027H Interrupt locations 1 through 5 not used. +.sp +.ti -17 +0030H-0037H Interrupt location 6 (not currently used) is reserved. +.in 0 +.bp +.sh + Table 6-6. (continued) +.sp +.nf + Locations Contents +.fi +.sp +.in 22 +.ti -17 +0038H-003AH Restart 7; contains a jump instruction into the DDT or SID +program when running in debug mode for programmed breakpoints, but is not +otherwise used by CP/M. +.sp +.ti -17 +003BH-003FH Not currently used; reserved. +.sp +.ti -17 +0040H-004FH A 16-byte area reserved for scratch by CBIOS, but is not +used for any purpose in the distribution version of CP/M. +.sp +.ti -17 +0050H-005BH Not currently used; reserved. +.sp +.ti -17 +005CH-007CH Default File Control Block produced for a transient +program by the CCP. +.sp +.ti -17 +007DH-007FH Optional default random record position. +.sp +.ti -17 +0080H-00FFH Default 128-byte disk buffer, also filled with the +command line when a transient is loaded under the CCP. +.in 0 +.ll 65 +.mb 4 +.fm 1 +.sp +.pp +This information is set up for normal operation under the CP/M +system, but can be overwritten by a transient program if the BDOS +facilities are not required by the transient. +.pp +If, for example, a particular program performs only simple I/O +and must begin execution at location 0, it can first be loaded +into the TPA, using normal CP/M facilities, with a small memory +move program that gets control when loaded. The memory move +program must get control from location 0100H, which is the +assumed beginning of all transient programs. The move program can +then proceed to the entire memory image down to location 0 and +pass control to the starting address of the memory load. +.pp +If the BIOS is overwritten or if location 0, containing the warm +start entry point, is overwritten, the operator must bring the +CP/M system back into memory with a cold start sequence. +.sp 2 +.tc 6.10 Disk Parameter Tables +.he CP/M Operating System Manual 6.10 Disk Parameter Tables +.sh +6.10 Disk Parameter Tables +.qs +.pp +Tables are included in the BIOS that describe the particular +characteristics of the disk subsystem used with CP/M. These +tables can be either hand-coded, as shown in the sample CBIOS in +Appendix B, or automatically generated using the DISKDEF macro +library, as shown in Appendix F. The purpose here is to describe +the elements of these tables. +.bp +.pp +In general, each disk drive has an associated (16-byte) disk +parameter header that contains information about the disk drive +and provides a scratch pad area for certain BDOS operations. The +format of the disk parameter header for each drive is shown +in Figure 6-2, where each element is a word (16-bit) value. +.mb 6 +.fm 2 +.sp 3 +.nf +XLT 0000 0000 0000 DIRBUF DPB CSV ALV +16b 16b 16b 16b 16b 16b 16b 16b +.fi +.sp 2 +.sh + Figure 6-2. Disk Parameter Header Format +.sp 2 +.pp +The meaning of each Disk Parameter Header (DPH) element is detailed in Table +6-7. +.sp 2 +.sh + Table 6-7. Disk Parameter Headers +.sp +.nf + Disk Parameter Meaning + Header +.fi +.ll 60 +.sp +.in 20 +.ti -14 +XLT Address of the logical-to-physical translation vector, if used +for this particular drive, or the value 0000H if no sector translation +takes place (that is, the physical and logical sector numbers are the same). +Disk drives with identical sector skew factors share the same translate tables. +.sp +.ti -14 +0000 Scratch pad values for use within the BDOS, initial value is +unimportant. +.sp +.ti -14 +DIRBUF Address of a 128-byte scratch pad area for directory operations +within BDOS. All DPHs address the same scratch pad area. +.sp +.ti -14 +DPB Address of a disk parameter block for this drive. Drives with +identical disk characteristics address the same disk parameter block. +.sp +.ti -14 +CSV Address of a scratch pad area used for software check for +changed disks. This address is different for each DPH. +.sp +.ti -14 +ALV Address of a scratch pad area used by the BDOS to keep disk +storage allocation information. This address is different for each DPH. +.fi +.in 0 +.ll 65 +.bp +.pp +Given n disk drives, the DPHs are arranged in a table whose first row of 16 +bytes corresponds to drive 0, with the last row corresponding to drive n-1. +In the following figure the lable DPBASE defines the base address of the DPH +table. +.sp 3 +.nf + DPBASE: +.sp + 00 XLT 00 0000 0000 0000 DIRBUF DBP 00 CSV 00 ALV 00 +.sp + 01 XLT 01 0000 0000 0000 DIRBUF DBP 01 CSV 01 ALV 01 + . + . + . + n-1 XLTn-1 0000 0000 0000 DIRBUF DBTn-1 CSVn-1 ALVn-1 +.fi +.sp 2 +.sh + Figure 6-3. Disk Parameter Header Table +.sp 2 +.pp +A responsibility of the SELDSK subroutine is to return the base address of +the DPH for the selected drive. The following sequence of operations returns +the table address, with a 0000H returned if the selected drive does not exist. +.sp 2 +.nf +.in 7 + NDISKS EQU 4 ;NUMBER OF DISK DRIVES + ..... + SELDSK: ;SELECT DISK GIVEN BY BC + LSI H,0000H ;ERROR CODE + MOV A,C ;DRIVE OK? + CPI NDISKS ;CY IF SO + RNC ;RET IF ERROR + ;NO ERROR, CONTINUE + MOV L,C ;LOW(DISK) + MOV H,B ;HIGH(DISK) + DAD H ;*2 + DAD H ;*4 + DAD H ;*8 + DAD H ;*16 + LXI D,DPBASE;FIRST DPH + DAD D ;DPH(DISK) + RET +.fi +.in 0 +.sp +.pp +The translation vectors, XLT 00 through XLTn-1, are located elsewhere in +the BIOS, and simply correspond one-for-one with the logical sector numbers +zero through the sector count 1. The Disk Parameter Block (DPB) for each +drive is more complex. As shown in Figure 6-4, particular DPB, that is +addressed by one or more DPHs, takes the general form: +.sp 3 +.nf + SPT BSH BLM EXM DSM DRM AL0 AL1 CKS 0FF + 16b 8b 8b 8b 16b 16b 8b 8b 16b 16b +.fi +.sp 2 +.sh + Figure 6-4. Disk Parameter Block Format +.sp 3 +where each is a byte or word value, as shown by the 8b or 16b indicator below +the field. +.pp +The following field abbreviations are used in Figure 6-4: +.sp 2 +.in 5 +.ti -2 +o SPT is the total number of sectors per track. +.sp +.ti -2 +o BSH is the data allocation block shift factor, determined by the data +block allocation size. +.sp +.ti -2 +o BLM is the data allocation block mask (2[BSH-1]). +.sp +.ti -2 +o EXM is the extent mask, determined by the data block allocation +size and the number of disk blocks. +.sp +.ti -2 +o DSM determines the total storage capacity of the disk drive. +.sp +.ti -2 +o DRM determines the total number of directory entries that can be +stored on this drive. AL0, AL1 determine reserved directory blocks. +.sp +.ti -2 +o CKS is the size of the directory check vector. +.sp +.ti -2 +o 0FF is the number of reserved tracks at the beginning of the +(logical) disk. +.fi +.in 0 +.sp +The values of BSH and BLM determine the data allocation size BLS, +which is not an entry in the DPB. Given that the designer has selected a +value for BLS, the values of BSH and BLM are shown Table 6-8. +.sp 2 +.sh + Table 6-8. BSH and BLM Values +.nf +.sp +.in 18 + BLS BSH BLM +.sp + 1024 3 7 + 2048 4 15 + 4096 5 31 + 8192 6 63 +16,384 7 127 +.fi +.in 0 +.sp 2 +where all values are in decimal. The value of EXM depends upon both the BLS +and whether the DSM value is less than 256 or greater than 255, as shown in +Table 6-9. +.bp +.sh + Table 6-9. EXM Values +.nf +.sp + BLS EXM values +.sp +.in 18 + DSM<256 DSM>255 +.sp + 1024 0 N/A + 2048 1 0 + 4096 3 1 + 8192 7 3 +16,384 15 7 +.fi +.in 0 +.sp +.pp +The value of DSM is the maximum data block number supported by this +particular drive, measured in BLS units. The product (DSM+1) is the +total number of bytes held by the drive and must be within the +capacity of the physical disk, not counting the reserved operating system +tracks. +.pp +The DRM entry is the one less than the total number of directory entries +that can take on a 16-bit value. The values of AL0 and AL1, however, are +determined by DRM. The values AL0 and AL1 can together be considered a +string of 16-bits, as shown in Figure 6-5. +.sp 3 +.nf + AL0 AL1 + + 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 +.fi +.sp 2 +.sh + Figure 6-5. AL0 and AL1 +.sp 2 +.pp +Position 00 corresponds to the high-order bit of the byte +labeled AL0 and 15 corresponds to the low-order bit of the byte +labeled AL1. Each bit position reserves a data block for number +of directory entries, thus allowing a total of 16 data blocks to +be assigned for directory entries (bits are assigned starting at +00 and filled to the right until position 15). Each directory +entry occupies 32 bytes, resulting in the following tabulation: +.sp 2 +.sh + Table 6-10. BLS Tabulation +.sp +.nf +.in 18 + BLS Directory Entries +.sp + 1024 32 times # bits + 2048 64 times # bits + 4096 128 times # bits + 8192 256 times # bits +16,384 512 times # bits +.fi +.in 0 +.bp +.pp +Thus, if DRM = 127 (128 directory entries) and BLS = 1024, there +are 32 directory entries per block, requiring 4 reserved blocks. +In this case, the 4 high-order bits of AL0 are set, resulting in +the values AL0 = 0F0H and AL1 = 00H. +.pp +The CKS value is determined as follows: if the disk drive media is +removable, then CKS = (DRM+1)/4, where DRM is the last directory +entry number. If the media are fixed, then set CKS = 0 (no +directory records are checked in this case). +.pp +Finally, the 0FF field determines the number of tracks that are +skipped at the beginning of the physical disk. This value is +automatically added whenever SETTRK is called and can be used as +a mechanism for skipping reserved operating system tracks or for +partitioning a large disk into smaller segmented sections. +.pp +To complete the discussion of the DPB, several DPHs can address +the same DPB if their drive characteristics are identical. +Further, the DPB can be dynamically changed when a new drive is +addressed by simply changing the pointer in the DPH; because the +BDOS copies the DPB values to a local area whenever the SELDSK +function is invoked. +.pp +Returning back to DPH for a particular drive, the two address +values CSV and ALV remain. Both addresses reference an area of +uninitialized memory following the BIOS. The areas must be +unique for each drive, and the size of each area is determined by +the values in the DPB. +.pp +The size of the area addressed by CSV is CKS bytes, which is +sufficient to hold the directory check information for this +particular drive, If CKS = (DRM+1)/4, you must reserve (DRM+1)/4 +bytes for directory check use. If CKS = 0, no storage is +reserved. +.pp +The size of the area addressed by ALV is determined by the +maximum number of data blocks allowed for this particular disk +and is computed as (DSM/8)+1. +.pp +The CBIOS shown in Appendix B demonstrates an instance of these +tables for standard 8-inch, single-density drives. It might be +useful to examine this program and compare the tabular values +with the definitions given above. +.sp 2 +.tc 6.11 The DISKDEF Macro Library +.he CP/M Operating System Manual 6.11 The DISKDEF Macro Library +.sh +6.11 The DISKDEF Macro Library +.qs +.pp +A macro library called DISKDEF (shown in Appendix F), greatly +simplifies the table construction process. You must have access +to the MAC macro assembler, of course, to use the DISKDEF +facility, while the macro library is included with all CP.M 2 +distribution disks. +.bp +.pp +A BIOS disk definition consists of the following sequence of +macro statements: +.sp +.nf +.in 7 + MACLIB DISKDEF + ..... + DISKS n + DISKDEF 0,... + DISKDEF 1,... + ..... + DISKDEF n-1 + ..... + ENDEF +.fi +.in 0 +.sp +where the MACLIB statement loads the DISKDEF.LIB file, on the +same disk as the BIOS, into MAC's internal tables. The DISKS +macro call follows, which specifies the number of drives to be +configured with the user's system, where n is an integer in the +range 1 to 16. A series of DISKDEF macro calls then follow that +define the characteristics of each logical disk, 0 through n-1, +corresponding to logical drives A through P. The DISKS and +DISKDEF macros generate the in-line fixed data tables described +in the previous section and thus must be placed in a +nonexecutable portion of the BIOS, typically directly following +the BIOS jump vector. +.pp +The remaining portion of the BIOS is defined following the +DISKDEF macros, with the ENDEF macro call immediately preceding +the END statement. The ENDEF (End of Diskdef) macro generates +the necessary uninitialized RAM areas that are located in +memory above the BIOS. +.pp +The DISKDEF macro call takes the form: +.sp +.ti 8 +DISKDEF dn,fsc,lsc,[skf],bls dks,dir,cks,ofs,[0] +.sp +where +.sp +.in 5 +.ti -2 +o dn is the logical disk number, 0 to n-1. +.ti -2 +o fsc is the first physical sector number (0 or 1). +.ti -2 +o lsc is the last sector number. +.ti -2 +o skf is the optional sector skew factor. +.ti -2 +o bls is the data allocation block size. +.ti -2 +o dks is the number of blocks on the disk. +.ti -2 +o dir is the number of directory entries. +.ti -2 +o cks is the number of checked directory entries. +.ti -2 +o ofs is the track offset to logical track 00. +.ti -2 +o [0] is an optional 1.4 compatibility flag. +.fi +.in 0 +.sp +.pp +The value dn is the drive number being defined with this DISKDEF +macro invocation. The fsc parameter accounts for differing +sector numbering systems and is usually 0 to 1. The lsc is the +last numbered sector on a track. When present, the skf parameter +defines the sector skew factor, which is used to create a sector +translation table according to the skew. +.pp +If the number of sectors is less than 256, a single-byte table is +created, otherwise each translation table element occupies two +bytes. No translation table is created if the skf parameter is +omitted, or equal to 0. +.pp +The bls parameter specifies the number of bytes allocated to each +data block, and takes on the values 1024, 2048, 4096, 8192, or +16384. Generally, performance increases with larger data block +sizes because there are fewer directory references, and logically +connected data records are physically close on the disk. +Further, each directory entry addresses more data and the BIOS-resident +RAM space is reduced. +.pp +The dks parameter specifies the total disk size in bls units. +That is, if the bls = 2048 and dks = 1000, the total disk +capacity is 2,048,000 bytes. If dks is greater than 255, the +block size parameter bls must be greater than 1024. The value of +dir is the total number of directory entries that might exceed +255, if desired. +.pp +The cks parameter determines the number of directory items to +check on each directory scan and is used internally to detect +changed disks during system operation, where an intervening cold +or warm start has not occurred. When this situation is detected, +CP/M automatically marks the disk Read-Only so that data is not +subsequently destroyed. +.pp +As stated in the previous section, the value of cks = dir when +the medium is easily changed, as is the case with a floppy disk +subsystem. If the disk is permanently mounted, the value of cks +is typically 0, because the probability of changing disks without a +restart is low. +.pp +The ofs value determines the number of tracks to skip when this +particular drive is addressed, which can be used to reserve +additional operating system space or to simulate several logical +drives on a single large capacity physical drive. +Finally, the [0] parameter is included when file compatibility is +required with versions of 1.4 that have been modified for higher +density disks. This parameter ensures that only 16K is allocated +for each directory record, as was the case for previous versions. +Normally, this parameter is not included. +.pp +For convenience and economy of table space, the special form: +.sp +.ti 8 +DISKDEF i,j +.sp +gives disk i the same characteristics as a previously defined +drive j. A standard four-drive, single-density system, which is +compatible with version 1.4, is defined using the following macro +invocations: +.sp +.nf +.in 7 + DISKS 4 + DISKDEF 0,1,26,6,1024,243,64,2 + DISKDEF 1,0 + DISKDEF 2,0 + DISKDEF 3,0 + .... + ENDEF +.fi +.in 0 +.sp +with all disks having the same parameter values of 26 sectors per +track, numbered 1 through 26, with 6 sectors skipped between each +access, 1024 bytes per data block, 243 data blocks for a total of +243K-byte disk capacity, 64 checked directory entries, and two +operating system tracks. +.pp +The DISKS macro generates n DPHs, starting at the DPH table +address DPBASE generated by the macro. Each disk header block +contains sixteen bytes, as described above, and correspond +one-for-one to each of the defined drives. In the four-drive +standard system, for example, the DISKS macro generates a table +of the form: +.sp +.nf +.in 5 +DPBASE EQU$ +DPE0: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV0,ALV0 +DPE1: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV1,ALV1 +DPE2: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV2,ALV2 +DPE3: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV3,ALV3 +.fi +.in 0 +.sp +where the DPH labels are included for reference purposes to show +the beginning table addresses for each drive 0 through 3. The +values contained within the DPH are described in detail in the +previous section. The check and allocation vector addresses are +generated by the ENDEF macro in the ram area following the BIOS +code and tables. +.pp +Note that if the skf (skew factor) parameter is +omitted, or equal to 0, the translation table is omitted and a +0000H value is inserted in the XLT position of the DPH for the +disk. In a subsequent call to perform the logical-to-physical +translation, SECTRAN receives a translation table address of DE = +0000H and simply returns the original logical sector from BC in +the HL register pair. +.pp +A translate table is constructed when the skf parameter is +present, and the (nonzero) table address is placed into the +corresponding DPHs. The following for example, is constructed +when the standard skew factor skf = 6 is specified in the DISKDEF +macro call: +.sp +.nf +.in 8 +XLT0: DB 1,7,13,19,25,5,11,17,23,3,9,15,21 + DB 2,8,14,20,26,6,12,18,24,4,10,16,22 +.fi +.in 0 +.pp +Following the ENDEF macro call, a number of uninitialized data +areas are defined. These data areas need not be a part of the BIOS +that is loaded upon cold start, but must be available between the +BIOS and the end of memory. The size of the uninitialized RAM +area is determined by EQU statements generated by the ENDEF macro. +For a standard four-drive system, the ENDEF macro might produce +the following EQU statement: +.bp +.nf +.in 8 +4C72 = BEGDAT EQU $ + (data areas) +.sp +4DB0 = ENDDAT EQU $ +.sp +013C = DATSIZ EQU $-BEGDAT +.fi +.in 0 +.sp +which indicates that uninitialized RAM begins at location 4C72H, +ends at 4DB0H-1, and occupies 013CH bytes. You must ensure +that these addresses are free for use after the system is loaded. +.pp +After modification, you can use the STAT program to +check drive characteristics, because STAT uses the disk parameter +block to decode the drive information. A STAT command of the form: +.sp +.ti 8 +STAT d:DSK: +.sp +decodes the disk parameter block for drive d (d=A,...,P) and +displays the following values: +.sp 2 +.nf +.in 8 +r: 128-byte record capacity +k: kilobyte drive capacity +d: 32-byte directory entries +c: checked directory entries +e: records/extent +b: records/block +s: sectors/track +t: reserved tracks +.fi +.in 0 +.sp +.pp +Three examples of DISKDEF macro invocations are shown below with +corresponding STAT parameter values. The last example produces a full +8-megabyte system. +.sp +.nf +.in 8 + DISKDEF 0,1,58,,2048,256,128,128,2 +r=4096, k=512, d=128, c=128, e=256, b=16, s=58, t=2 +.sp + DISKDEF 0,1,58,,2048,1024,300,0,2 +r=16348, k=2048, d=300, c=0, e=128, b=16, s=58, t=2 +.sp + DISKDEF 0,1,58,,16348,512,128,128,2 +r=65536, k=8192, d=128, c=128, e=1024, b=128, s=58, t=2 +.fi +.in 0 +.sp 2 +.tc 6.12 Sector Blocking and Deblocking +.he CP/M Operating System Manual 6.12 Blocking and Deblocking +.sh +6.12 Sector Blocking and Deblocking +.qs +.pp +Upon each call to BIOS WRITE entry point, the CP/M BDOS includes +information that allows effective sector blocking and deblocking +where the host disk subsystem has a sector size that is a +multiple of the basic 128-byte unit. The purpose here is to +present a general-purpose algorithm that can be included within +the BIOS and that uses the BDOS information to perform the +operations automatically. +.pp +On each call to WRITE, the BDOS provides the following +information in register C: +.sp +.nf +.in 8 +0 = (normal sector write) +1 = (write to directory sector) +2 = (write to the first sector + of a new data block) +.fi +.in 0 +.pp +Condition 0 occurs whenever the next write operation is into a +previously written area, such as a random mode record update; +when the write is to other than the first sector of an +unallocated block; or when the write is not into the directory +area. Condition 1 occurs when a write into the directory area is +performed. Condition 2 occurs when the first record (only) of a +newly allocated data block is written. In most cases, +application programs read or write multiple 128-byte sectors in +sequence; thus, there is little overhead involved in either +operation when blocking and deblocking records, because preread +operations can be avoided when writing records. +.pp +Appendix G lists the blocking and deblocking algorithms in +skeletal form; this file is included on your CP/M disk. +Generally, the algorithms map all CP/M sector read operations +onto the host disk through an intermediate buffer that is the +size of the host disk sector. Throughout the program, values and +variables that relate to the CP/M sector involved in a seek +operation are prefixed by sek, while those related to the host +disk system are prefixed by hst. The equate statements beginning +on line 29 of Appendix G define the mapping between CP/M and the +host system, and must be changed if other than the sample host +system is involved. +.pp +The entry points BOOT and WBOOT must contain the initialization +code starting on line 57, while the SELDSK entry point must be +augmented by the code starting on line 65. Note that although +the SELDSK entry point computes and returns the Disk Parameter +Header address, it does not physically select the host disk at +this point (it is selected later at READHST or WRITEHST). +Further, SETTRK, SETTRK, and SETMA simply store the values, but +do not take any other action at this point. SECTRAN performs a +trivial function of returning the physical sector number. +.pp +The principal entry points are READ and WRITE, starting on lines +110 and 125, respectively. These subroutines take the place of +your previous READ and WRITE operations. +.pp +The actual physical read or write takes place at either WRITEHST +or READHST, where all values have been prepared: hstdsk is the +host disk number, hsttrk is the host track number, and +hstsec is the host sector number, which +may require translation to physical sector number. You must +insert code at this point that performs the full sector read or write +into or out of the buffer at hstbuf of length hstsiz. All other mapping +functions are performed by the algorithms. +.pp +This particular algorithm was tested using an 80-megabyte hard +disk unit that was originally configured for 128-byte sectors, +producing approximately 35 megabytes of formatted storage. When +configured for 512-byte host sectors, usable storage increased to +57 megabytes, with a corresponding 400% improvement in overall +response. In this situation, there is no apparent overhead +involved in deblocking sectors, with the advantage that user +programs still maintain 128-byte sectors. This is primarily +because of the information provided by the BDOS, which eliminates +the necessity for preread operations. +.sp 2 +.ce +End of Section 6 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/test.tex b/Source/Doc/CPM 22 Manual - Testing/test.tex new file mode 100644 index 00000000..02ae661e --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/test.tex @@ -0,0 +1,447 @@ +.op +.sp 15 +.ce 100 +.bo 5 +CP/M +.sp +.sh +Operating System +.sp +.sh +Manual +.cs 5 +.sp 10 +Copyright (c) 1982 +.sp +Digital Research +P.O. Box 579 +160 Central Avenue +Pacific Grove, CA 93950 +(408) 649-3896 +TWX 910 360 5001 +.sp 4 +All Rights Reserved +.ce 0 +.bp +.po 17 +.ll 50 +.ce +COPYRIGHT +.sp +Copyright (c) 1976, 1977, 1978, 1979, 1982, 1983, and 1984 by +Digital Research Inc. All rights reserved. No part of this +publication may be reproduced, transmitted, transcribed, stored +in a retrieval system, or translated into any language or +computer language, in any form or by any means, electronic, mechanical, +magnetic, optical, chemical, manual or otherwise, without the prior +written permission of Digital Research Inc., Post Office Box 579, +Pacific Grove, California, 93950. +.sp +Thus, readers are granted permission to include the example +programs, either in whole or in part, in their own programs. +.sp 2 +.ce +DISCLAIMER +.sp +Digital Research Inc. makes no representations or warranties with +respect to the contents hereof and specifically disclaims +any implied warranties of merchantability or fitness for +any particular purpose. Further, Digital Research Inc. reserves the +right to revise this publication and to make changes from +time to time in the content hereof without obligation of +Digital Research Inc. to notify any person of such revision or +changes. +.sp 2 +.ce +TRADEMARKS +.sp +CP/M, CP/NET, and Digital Research and its logo are registered +trademarks of Digital Research. ASM, DESPOOL, DDT, LINK-80, MAC, +MP/M, PL/I-80 and SID are trademarks of Digital Research. IBM is +a registered trademark of International Business Machines. Intel +is a registered trademark of Intel Corporation. TI Silent 700 is +a trademark of Texas Instruments Incorporated. Zilog and Z80 are +registered trademarks of Zilog, Inc. +.mb 4 +.fm 1 +.sp 3 +The \c +.ul +CP/M Operating System Manual \c +.qu +was prepared using the Digital Research TEX Text Formatter and printed +in the United States of America. +.sp 2 +.ce 6 +********************************* +* First Edition: 1976 * +* Second Edition: July 1982 * +* Third Edition: March 1983 * +* Fourth Edition: March 1984 * +********************************* +.po 10 +.ll 65 +.in 0 +.bp +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft iii +.bp +.ce +.sh +Table of Contents +.sp 3 +.nf +.sh +1 CP/M Features and Facilities +.sp + 1.1 Introduction . . . . . . . . . . . . . . . . . . . 1-1 +.sp + 1.2 Functional Description . . . . . . . . . . . . . . 1-3 +.sp + 1.2.1 General Command Structure . . . . . . . . . 1-3 + 1.2.2 File References . . . . . . . . . . . . . . 1-3 +.sp + 1.3 Switching Disks . . . . . . . . . . . . . . . . . . 1-5 + 1.4 Built-in Commands . . . . . . . . . . . . . . . . . 1-6 +.sp + 1.4.1 ERA Command . . . . . . . . . . . . . . . . 1-6 + 1.4.2 DIR Command . . . . . . . . . . . . . . . . 1-7 + 1.4.3 REN Command . . . . . . . . . . . . . . . . 1-8 + 1.4.4 SAVE Command . . . . . . . . . . . . . . . . 1-8 + 1.4.5 TYPE Command . . . . . . . . . . . . . . . . 1-9 + 1.4.6 USER Command . . . . . . . . . . . . . . . . 1-9 +.sp + 1.5 Line Editing and Output Control . . . . . . . . . . 1-10 +.sp + 1.6 Transient Commands . . . . . . . . . . . . . . . . 1-11 +.sp + 1.6.1 STAT Command . . . . . . . . . . . . . . . . 1-12 + 1.6.2 ASM Command . . . . . . . . . . . . . . . . 1-18 + 1.6.3 LOAD Command . . . . . . . . . . . . . . . . 1-19 + 1.6.4 PIP . . . . . . . . . . . . . . . . . . . . 1-20 + 1.6.5 ED Command . . . . . . . . . . . . . . . . . 1-29 + 1.6.6 SYSGEN Command . . . . . . . . . . . . . . . 1-31 + 1.6.7 SUBMIT Command . . . . . . . . . . . . . . . 1-33 + 1.6.8 DUMP Command . . . . . . . . . . . . . . . . 1-35 + 1.6.9 MOVCPM Command . . . . . . . . . . . . . . . 1-35 +.sp + 1.7 BDOS Error Messages . . . . . . . . . . . . . . . . 1-37 +.sp + 1.8 CP/M Operation on the Model 800 . . . . . . . . . . 1-38 +.sp 2 +.sh +2 The CP/M Editor +.sp + 2.1 Introduction to ED . . . . . . . . . . . . . . . . 2-1 +.sp + 2.1.1 ED Operation . . . . . . . . . . . . . . . . 2-1 + 2.1.2 Text Transfer Functions . . . . . . . . . . 2-3 + 2.1.3 Memory Buffer Organization . . . . . . . . . 2-4 + 2.1.4 Line Numbers and ED Start-up . . . . . . . . 2-5 + 2.1.5 Memory Buffer Operation . . . . . . . . . . 2-6 + 2.1.6 Command Strings . . . . . . . . . . . . . . 2-7 + 2.1.7 Text Search and Alteration . . . . . . . . . 2-10 + 2.1.8 Source Libraries . . . . . . . . . . . . . . 2-13 + 2.1.9 Repetitive Command Execution . . . . . . . . 2-14 +.bp +.ft iv +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 + 2.2 ED Error Conditions . . . . . . . . . . . . . . . . 2-14 +.sp + 2.3 Control Characters and Commands . . . . . . . . . . 2-16 +.sp 2 +.sh +3 CP/M Assembler +.qs +.sp + 3.1 Introduction . . . . . . . . . . . . . . . . . . . 3-1 +.sp + 3.2 Program Format . . . . . . . . . . . . . . . . . . 3-3 +.sp + 3.3 Forming the Operand . . . . . . . . . . . . . . . . 3-4 +.sp + 3.3.1 Labels . . . . . . . . . . . . . . . . . . . 3-4 + 3.3.2 Numeric Constants . . . . . . . . . . . . . 3-5 + 3.3.3 Reserved Words . . . . . . . . . . . . . . . 3-5 + 3.3.4 String Constants . . . . . . . . . . . . . . 3-6 + 3.3.5 Arithmetic and Logical Operators . . . . . . 3-7 + 3.3.6 Precedence of Operators . . . . . . . . . . 3-8 +.sp + 3.4 Assembler Directives . . . . . . . . . . . . . . . 3-9 +.sp + 3.4.1 The ORG Directive . . . . . . . . . . . . . 3-10 + 3.4.2 The END Directive . . . . . . . . . . . . . 3-10 + 3.4.3 The EQU Directive . . . . . . . . . . . . . 3-11 + 3.4.4 The SET Directive . . . . . . . . . . . . . 3-11 + 3.4.5 The IF and ENDIF Directives . . . . . . . . 3-12 + 3.4.6 The DB Directive . . . . . . . . . . . . . . 3-13 + 3.4.7 The DW Directive . . . . . . . . . . . . . . 3-14 + 3.4.8 The DS Directive . . . . . . . . . . . . . . 3-14 +.sp + 3.5 Operation Codes . . . . . . . . . . . . . . . . . . 3-15 +.sp + 3.5.1 Jumps, Calls, and Returns . . . . . . . . . 3-15 + 3.5.2 Immediate Operand Instructions . . . . . . . 3-17 + 3.5.3 Increment and Decrement Instructions . . . . 3-17 + 3.5.4 Data Movement Instructions . . . . . . . . . 3-18 + 3.5.5 Arithmetic Logic Unit Operations . . . . . . 3-19 + 3.5.6 Control Instructions . . . . . . . . . . . . 3-21 +.sp + 3.6 Error Messages . . . . . . . . . . . . . . . . . . 3-21 +.sp + 3.7 A Sample Session . . . . . . . . . . . . . . . . . 3-23 +.bp +.ft v +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 +.sh +4 CP/M Dynamic Debugging Tool +.qs +.sp + 4.1 Introduction . . . . . . . . . . . . . . . . . . . 4-1 +.sp + 4.2 DDT Commands . . . . . . . . . . . . . . . . . . . 4-3 +.sp + 4.2.1 The A (Assembly) Command . . . . . . . . . . 4-3 + 4.2.2 The D (Display) Command . . . . . . . . . . 4-4 + 4.2.3 The F (Fill) Command . . . . . . . . . . . . 4-5 + 4.2.4 The G (Go) Command . . . . . . . . . . . . . 4-5 + 4.2.5 The I (Input) Command . . . . . . . . . . . 4-6 + 4.2.6 The L (List) Command . . . . . . . . . . . . 4-6 + 4.2.7 The M (Move) Command . . . . . . . . . . . . 4-7 + 4.2.8 The R (Read) Command . . . . . . . . . . . . 4-7 + 4.2.9 The S (Set) Command . . . . . . . . . . . . 4-8 + 4.2.1- The T (Trace) Command . . . . . . . . . . . 4-8 + 4.2.11 The U (Untrace) Command . . . . . . . . . . 4-9 + 4.2.12 The X (Examine) Command . . . . . . . . . . 4-9 +.sp + 4.3 Implementation Notes . . . . . . . . . . . . . . . 4-10 +.sp + 4.4 A Sample Program . . . . . . . . . . . . . . . . . 4-11 +.sp 2 +.sh +5 CP/M 2 System Interface +.qs +.sp + 5.1 Introduction . . . . . . . . . . . . . . . . . . . 5-1 +.sp + 5.2 Operating System Call Conventions . . . . . . . . . 5-3 +.sp + 5.3 A Sample File-to-File Copy Program . . . . . . . . 5-35 +.sp + 5.4 A Sample File Dump Utility . . . . . . . . . . . . 5-38 +.sp + 5.5 A Sample Random Access Program . . . . . . . . . . 5-42 +.sp + 5.6 System Function Summary . . . . . . . . . . . . . . 5-50 +.sp 2 +.sh +6 CP/M 2 Alteration +.qs +.sp + 6.1 Introduction . . . . . . . . . . . . . . . . . . . 6-1 +.sp + 6.2 First-level System Regeneration . . . . . . . . . . 6-2 +.sp + 6.3 Second-level System Generation . . . . . . . . . . 6-5 +.sp + 6.4 Sample GETSYS and PUTSYS Programs . . . . . . . . . 6-9 +.bp +.ft vi +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 + 6.5 Disk Organization . . . . . . . . . . . . . . . . . 6-11 +.sp + 6.6 The BIOS Entry Points . . . . . . . . . . . . . . . 6-13 +.sp + 6.7 A Sample BIOS . . . . . . . . . . . . . . . . . . . 6-21 +.sp + 6.8 A Sample Cold Start Loader . . . . . . . . . . . . 6-21 +.sp + 6.9 Reserved Locations in Page Zero . . . . . . . . . . 6-22 +.sp + 6.10 Disk Parameter Tables . . . . . . . . . . . . . . 6-23 +.sp + 6.11 The DISKDEF Macro Library . . . . . . . . . . . . 6-28 +.sp + 6.12 Sector Blocking and Deblocking . . . . . . . . . . 6-32 +.bp +.ft vii +.ce +.sh +Appendixes +.qs +.sp 3 +.sh +A \c +.qs +Basic Input/Output System (BIOS) . . . . . . . . . . . A-1 +.sp 2 +.sh +B \c +.qs +A Skeletal CBIOS . . . . . . . . . . . . . . . . . . . B-1 +.sp 2 +.sh +C \c +.qs +A Skeletal GETSYS/PUTSYS Program . . . . . . . . . . . C-1 +.sp 2 +.sh +D \c +.qs +The Model 800 Cold Start Loader for CP/M 2 . . . . . . D-1 +.sp 2 +.sh +E \c +.qs +A Skeletal Cold Start Loader . . . . . . . . . . . . . E-1 +.sp 2 +.sh +F \c +.qs +CP/M Disk Definition Library . . . . . . . . . . . . . F-1 +.sp 2 +.sh +G \c +.qs +Blocking and Deblocking Algorithms . . . . . . . . . . G-1 +.sp 2 +.sh +H \c +.qs +Glossary . . . . . . . . . . . . . . . . . . . . . . . H-1 +.sp 2 +.sh +I \c +.qs +CP/M Error Messages . . . . . . . . . . . . . . . . . . I-1 +.bp +.ft viii +.ce +.sh +Tables, Figures, and Listings +.qs +.sp 3 +.sh +Tables +.qs +.sp + 1-1. Line-editing Control Characters . . . . . . . . 1-10 + 1-2. CP/M Transient Commands . . . . . . . . . . . . 1-11 + 1-3. Physical Devices . . . . . . . . . . . . . . . 1-14 + 1-4. PIP Parameters . . . . . . . . . . . . . . . . 1-24 +.sp + 2-1. ED Text Transfer Commands . . . . . . . . . . . 2-3 + 2-2. Editing Commands . . . . . . . . . . . . . . . 2-6 + 2-3. Line-editing Controls . . . . . . . . . . . . . 2-7 + 2-4. Error Message Symbols . . . . . . . . . . . . . 2-13 + 2-5. ED Control Characters . . . . . . . . . . . . . 2-14 + 2-6. ED Commands . . . . . . . . . . . . . . . . . . 2-15 +.sp + 3-1. Reserved Characters . . . . . . . . . . . . . . 3-6 + 3-2. Arithmetic and Logical Operators . . . . . . . 3-7 + 3-3. Assembler Directives . . . . . . . . . . . . . 3-9 + 3-4. Jumps, Calls, and Returns . . . . . . . . . . . 3-15 + 3-5. Immediate Operand Instructions . . . . . . . . 3-16 + 3-6. Increment and Decrement Instructions . . . . . 3-17 + 3-7. Data Movement Instructions . . . . . . . . . . 3-17 + 3-8. Arithmetic Logic Unit Operations . . . . . . . 3-18 + 3-9. Error Codes . . . . . . . . . . . . . . . . . . 3-20 + 3-10. Error Messages . . . . . . . . . . . . . . . . 3-21 +.sp + 4-1. Line-editing Controls . . . . . . . . . . . . . 4-2 + 4-2. DDT Commands . . . . . . . . . . . . . . . . . 4-2 + 4-3. CPU Registers . . . . . . . . . . . . . . . . . 4-9 +.sp + 5-1. CP/M Filetypes . . . . . . . . . . . . . . . . 5-6 + 5-2. File Control Block Fields . . . . . . . . . . . 5-7 + 5-3. Edit Control Characters . . . . . . . . . . . . 5-20 +.sp + 6-1. Standard Memory Size Values . . . . . . . . . . 6-2 + 6-2. Common Values for CP/M Systems . . . . . . . . 6-7 + 6-3. CP/M Disk Sector Allocation . . . . . . . . . . 6-11 + 6-4. IOBYTE Field Values . . . . . . . . . . . . . . 6-15 + 6-5. BIOS Entry Points . . . . . . . . . . . . . . . 6-16 + 6-6. Reserved Locations in Page Zero . . . . . . . . 6-21 + 6-7. Disk Parameter Headers . . . . . . . . . . . . 6-23 + 6-8. BSH and BLM Values . . . . . . . . . . . . . . 6-25 + 6-9. EXM Values . . . . . . . . . . . . . . . . . . 6-25 + 6-10. BLS Tabluation . . . . . . . . . . . . . . . . 6-26 +.sp + I-1. CP/M Error Messages . . . . . . . . . . . . . . I-1 +.sp 2 +.sh +Figures +.qs +.sp + 2-1. Overall ED Operation . . . . . . . . . . . . . 2-2 + 2-2. Memory Buffer Organization . . . . . . . . . . 2-2 +.bp +.ft ix +.ce +.sh +Tables, Figures, and Listings +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 +.sh +Figures +.qs +.sp + 2-3. Logical Organization of Memory Buffer . . . . . 2-4 +.sp + 5-1. CP/M Memory Organization . . . . . . . . . . . 5-1 + 5-2. File Control Block Format . . . . . . . . . . . 5-7 +.sp + 6-1. IOBYTE Fields . . . . . . . . . . . . . . . . . 6-15 + 6-2. Disk Parameter Header Format . . . . . . . . . 6-22 + 6-3. Disk Parameter Header Table . . . . . . . . . . 6-23 + 6-4. Disk Parameter Block Format . . . . . . . . . . 6-24 + 6-5. AL0 and AL1 . . . . . . . . . . . . . . . . . . 6-25 +.sp 2 +.sh +Listings +.qs +.sp + 6-1. GETSYS Program . . . . . . . . . . . . . . . . 6-9 + 6-2. BIOS Entry Points . . . . . . . . . . . . . . . 6-13 +.nx onea + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/threea.tex b/Source/Doc/CPM 22 Manual - Testing/threea.tex new file mode 100644 index 00000000..1a5c666c --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/threea.tex @@ -0,0 +1,938 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 3-% +.pc 1 +.tc 3 CP/M Assembler +.ce 2 +.sh +Section 3 +.sp +.sh +CP/M Assembler +.qs +.sp 3 +.tc 3.1 Introduction +.he CP/M Operating System Manual 3.1 Introduction +.sh +3.1 Introduction +.qs +.pp 5 +The CP/M assembler reads assembly-language source files from the +disk and produces 8080 machine language in Intel hex format. +To start the CP/M assembler, type a command in one of the +following forms: +.sp +.nf +.in 8 +ASM filename +ASM filename.parms +.fi +.in 0 +.sp +In both cases, the assembler assumes there is a file on the +disk with the name: +.sp +.ti 8 +filename.ASM +.sp +which contains an 8080 assembly-language source file. The first +and second forms shown above differ only in that the second form +allows parameters to be passed to the assembler to control source +file access and hex and print file destinations. +.pp +In either case, the CP/M assembler loads and prints the message: +.sp +.ti 8 +CP/M ASSEMBLER VER n.n +.sp +where n.n is the current version number. In the case of the +first command, the assembler reads the source file with assumed +filetype ASM and creates two output files +.sp +.in 8 +.nf +filename.HEX +filename.PRN +.fi +.in 0 +.pp +The HEX file contains the machine code corresponding to the +original program in Intel hex format, and the PRN file contains +an annotated listing showing generated machine code, error flags, +and source lines. If errors occur during translation, they are +listed in the PRN file and at the console. +.pp +The form ASM filename parms is used to redirect input and +output files from their defaults. In this case, the parms +portion of the command is a three-letter group that specifies the +origin of the source file, the destination of the hex file, and +the destination of the print file. The form is +.bp +.ti 8 +filename.p1p2p3 +.sp +where p1, p2, and p3 are single letters. P1 can be +.sp +.ti 8 +A,B, ...,P +.sp +which designates the disk name that contains the source file. P2 +can be +.sp +.ti 8 +A,B, ...,P +.sp +which designates the disk name that will receive the hex file; or, P2 +can be +.sp +.ti 8 +Z +.sp +which skips the generation of the hex file. +.pp +P3 can be +.sp +.ti 8 +A,B, ...,P +.sp +which designates the disk name that will receive the +print file. P3 can also be specified as +.sp +.ti 8 +X +.sp +which places the listing at the console; or +.sp +.ti 8 +Z +.sp +which skips generation of the print file. Thus, the command +.sp +.ti 8 +ASM X.AAA +.sp +indicates that the source, X.HEX, and print, X.PRN, files +are also to be created on disk A. This form of the command is +implied if the assembler is run from disk A. Given that you are +currently addressing disk A, the above command is the same as +.sp +.ti 8 +ASM X +.sp +The command +.sp +.ti 8 +ASM X.ABX +.sp +indicates that the source file is to be taken from disk A, the +hex file is to be placed on disk B, and the listing file is to be +sent to the console. The command +.sp +.ti 8 +ASM X.BZZ +.sp +takes the source file from disk B and skips the generation of the +hex and print files. This command is useful for fast execution of +the assembler to check program syntax. +.bp +.pp +The source program format is compatible with the Intel 8080 +assembler. Macros are not implemented in ASM; see the optional +MAC macro assembler. There are certain extensions in the CP/M +assembler that make it somewhat easier to use. These extensions +are described below. +.sp 2 +.tc 3.2 Program Format +.he CP/M Operating System Manual 3.2 Program Format +.sh +3.2 Program Format +.qs +.pp +An assembly-language program acceptable as input to the assembler +consists of a sequence of statements of the form +.sp +.ti 8 +line# label operation operand ;comment +.sp +where any or all of the fields may be present in a particular +instance. Each assembly-language statement is terminated with a +carriage return and line-feed (the line-feed is inserted +automatically by the ED program), or with the character !, which +is treated as an end-of-line by the assembler. Thus, multiple +assembly-language statements can be written on the same physical +line if separated by exclamation point symbols. +.pp +The line# is an optional decimal integer value representing the +source program line number, and ASM ignores this field if +present. +.pp +The label field takes either of the following forms: +.sp +.in 8 +.nf +identifier +identifier: +.fi +.in 0 +.sp +The label field is optional, except where noted in particular statement +types. The identifier is a sequence of alphanumeric characters +where the first character is alphabetic. Identifiers can be +freely used by the programmer to label elements such as program +steps and assembler directives, but cannot exceed 16 characters +in length. All characters are significant in an identifier, +except for the embedded dollar symbol $, which can be used to +improve readability of the name. Further, all lower-case +alphabetics are treated as upper-case. The +following are all valid instances of labels: +.sp 2 +.nf +.in 8 +x xy long$name + +x: yxl: longer$named$data: + +X1Y2 X1x2 x234$5678$9012$3456: +.fi +.in 0 +.sp +.pp +The operation field contains either an assembler directive or +pseudo operation, or an 8080 machine operation code. The pseudo +operations and machine operation codes are described in Section +3.3. +.pp +Generally, the operand field of the statement contains an +expression formed out of constants and labels, along with +arithmetic and logical operations on these elements. Again, the +complete details of properly formed expressions are given in +Section 3.3. +.pp +The comment field contains arbitrary characters following the +semicolon +symbol until the next real or logical end-of-line. These +characters are read, listed, and otherwise ignored by the +assembler. The CP/M assembler also treats statements that begin +with an * in column one as comment statements that are listed +and ignored in the assembly process. +.pp +The assembly-language program is formulated as a sequence of +statements of the above form, terminated by an optional END +statement. All statements following the END are ignored by the +assembler. +.sp 2 +.tc 3.3 Forming the Operand +.he CP/M Operating System Manual 3.3 Forming the Operand +.sh +3.3 Forming the Operand +.qs +.pp +To describe the operation codes and pseudo operations completely, +it is necessary first to present the form of the operand field, +since it is used in nearly all statements. Expressions in the +operand field consist of simple operands, labels, constants, and +reserved words, combined in properly formed subexpressions by +arithmetic and logical operators. The expression computation is +carried out by the assembler as the assembly proceeds. Each +expression must produce a 16-bit value during the assembly. +Further, the number of significant digits in the result must not +exceed the intended use. If an expression is to be used +in a byte move immediate instruction, the most significant 8 bits +of the expression must be zero. The restriction on the +expression significance is given with the individual +instructions. +.sp 2 +.tc 3.3.1 Labels +.sh +3.3.1 Labels +.qs +.pp +As discussed above, a label is an identifier that occurs on a +particular statement. In general, the label is given a value +determined by the type of statement that it precedes. If the +label occurs on a statement that generates machine code or +reserves memory space (for example, a MOV instruction or a +DS pseudo operation), the label is given the value of the program address +that it labels. If the label precedes an EQU or SET, the label +is given the value that results from evaluating the operand +field. Except for the SET statement, an identifier can label +only one statement. +.pp +When a label appears in the operand field, its value is +substituted by the assembler. This value can then be combined +with other operands and operators to form the operand field for a +particular instruction. +.bp +.tc 3.3.2 Numeric Constants +.sh +3.3.2 Numeric Constants +.qs +.pp +A numeric constant is a 16-bit value in one of several bases. +The base, called the radix of the constant, is denoted by a +trailing radix indicator. The following are radix indicators: +.sp +.in 3 +.nf +o B is a binary constant (base 2). +o O is a octal constant (base 8). +o Q is a octal constant (base 8). +o D is a decimal constant (base 10). +o H is a hexadecimal constant (base 16). +.fi +.in 0 +.pp +Q is an alternate radix indicator for octal numbers because the +letter O is easily confused with the digit 0. Any numeric +constant that does not terminate with a radix indicator is +a decimal constant. +.pp +A constant is composed as a sequence of digits, followed by +an optional radix indicator, where the digits are in the +appropriate range for the radix. Binary constants must +be composed of 0 and 1 digits, octal constants can contain digits +in the range 0-7, while decimal constants contain decimal digits. +Hexadecimal constants contain decimal digits as well as +hexadecimal digits A(10D), B(11D), C(12D), D(13D), E(14D), and +F(15D). Note that the leading digit of a +hexadecimal constant must be a decimal digit to avoid confusing a +hexadecimal constant with an identifier. A leading 0 will always +suffice. A constant composed in this manner must evaluate to a +binary number that can be contained within a 16-bit counter, +otherwise it is truncated on the right by the assembler. +.pp +Similar +to identifiers, embedded $ signs are allowed within constants to +improve their readability. Finally, the radix indicator is +translated to upper-case if a lower-case letter is encountered. +The following are all valid instances of numeric constants: +.sp 2 +.nf +.in 8 +1234 1234D 1100B 1111$0000$1111$0000B +.sp +1234H OFFEH 3377O 33$77$22Q +.sp +3377o Ofe3h 1234d Offffh +.fi +.in 0 +.sp 2 +.tc 3.3.3 Reserved Words +.sh +3.3.3 Reserved Words +.qs +.pp +There are several reserved character sequences that have +predefined meanings in the operand field of a statement. The +names of 8080 registers are given below. When they are +encountered, they produce the values shown to the right. +.bp +.nf +.sh + Table 3-1. Reserved Characters +.sp + Character Value + + A 7 + B 0 + C 1 + D 2 + E 3 + H 4 + L 5 + M 6 + SP 6 + PSW 6 +.fi +.in 0 +.sp +.pp +Again, lower-case names have the same values as their upper-case +equivalents. Machine instructions can also be used in the +operand field; they evaluate to their internal codes. In the case +of instructions that require operands, where the specific operand +becomes a part of the binary bit pattern of the instruction, +for example, MOV A,B, the value of the instruction, in this case MOV, +is the bit pattern of the instruction with zeros in the optional +fields, for example, MOV produces 40H. +.pp +When the symbol $ occurs in the operand field, not embedded +within identifiers and numeric constants, its value becomes the +address of the next instruction to generate, not including the +instruction contained within the current logical line. +.sp 2 +.tc 3.3.4 String Constants +.sh +3.3.4 String Constants +.qs +.pp +String constants represent sequences of ASCII characters and are +represented by enclosing the characters within apostrophe symbols. +All strings must be fully contained within the current +physical line (thus allowing exclamation point symbols within +strings) and must +not exceed 64 characters in length. The apostrophe character +itself can be included within a string by representing it as a +double apostrophe (the two keystrokes ''), which becomes a single +apostrophe when read by the assembler. In most cases, the string +length is restricted to either one or two characters (the DB +pseudo operation is an exception), in which case the string +becomes an 8- or 16-bit value, respectively. Two-character +strings become a 16-bit constant, with the second character as +the low-order byte, and the first character as the high-order +byte. +.pp +The value of a character is its corresponding ASCII code. There +is no case translation within strings; both upper- and +lower-case characters can be represented. You should note +that only graphic printing ASCII characters are +allowed within strings. +.bp +.nf + Valid strings: How assembler reads strings: + + 'A' 'AB' 'ab' 'c' A AB ab c + '' 'a''' '''' '''' a' ' ' + 'Walla Walla Wash.' Walla Walla Wash. + 'She said ''Hello'' to me.' She said ''Hello'' to me + 'I said ''Hello'' to her.' I said ''Hello'' to her +.fi +.sp 2 +.tc 3.3.5 Arithmetic and Logical Operators +.sh +3.3.5 Arithmetic and Logical Operators +.qs +.pp +The operands described in Section 3.3 can be combined in normal algebraic +notation using any combination of properly formed operands, +operators, and parenthesized expressions. The operators +recognized in the operand field are described in Table 3-2. +.sp 2 +.ce +.sh +Table 3-2. Arithmetic and Logical Operators +.ll 60 +.in 5 +.sp +.nf +Operators Meaning +.sp +.fi +.in 19 +.ti -13 +a + b unsigned arithmetic sum of a and b +.sp +.ti -13 +a - b unsigned arithmetic difference between a and b +.sp +.ti -13 + + b unary plus (produces b) +.sp +.ti -13 + - b unary minus (identical to 0 - b) +.sp +.ti -13 +a * b unsigned magnitude multiplication of a and b +.sp +.ti -13 +a / b unsigned magnitude division of a by b +.sp +.ti -13 +a MOD b remainder after a / b. +.sp +.ti -13 +NOT b logical inverse of b (all 0s become 1s, 1s become +0s), where b is considered a 16-bit value +.sp +.ti -13 +a AND b bit-by-bit logical and of a and b +.sp +.ti -13 +a OR b bit-by-bit logical or of a and b +.sp +.ti -13 +a XOR b bit-by-bit logical exclusive or of a and b +.sp +.ti -13 +a SHL b the value that results from shifting a to the left +by an amount b, with zero fill +.sp +.ti -13 +a SHR b the value that results from shifting a to the +right by an amount b, with zero fill +.in 0 +.ll 65 +.sp +.pp +In each case, a and b represent simple operands (labels, numeric +constants, reserved words, and one- or two-character strings) or +fully enclosed parenthesized subexpressions, like those shown in +the following examples: +.sp 2 +.nf +.in 8 +10+20 10h+37Q LI/3 (L2+4) SHR 3 + +('a' and 5fh) + '0' ('B'+B) OR (PSW+M) + +(1+(2+c)) shr (A-(B+1)) +.fi +.in 0 +.sp +.pp +Note that all computations are performed at assembly time as 16-bit +unsigned operations. Thus, -1 is computed as 0-1, which +results in the value 0ffffh (that is, all 1s). The resulting +expression must fit the operation code in which it is used. For +example, if the expression is used in an ADI (add immediate) +instruction, the high-order 8 bits of the expression must be +zero. As a result, the operation ADI-1 produces an error message +(-1 becomes 0ffffh, which cannot be represented as an 8-bit +value), while ADI(-1) AND 0FFH is accepted by the assembler +because the AND operation zeros the high-order bits of the +expression. +.sp 2 +.tc 3.3.6 Precedence of Operators +.sh +3.3.6 Precedence of Operators +.qs +.pp +As a convenience to the programmer, ASM assumes that operators +have a relative precedence of application that allows the +programmer to write expressions without nested levels of +parentheses. The resulting expression has assumed parentheses +that are defined by the relative precedence. The order of +application of operators in unparenthesized expressions is listed +below. Operators listed first have highest precedence (they are +applied first in an unparenthesized expression), while operators +listed last have lowest precedence. Operators listed on the same +line have equal precedence, and are applied from left to right as +they are encountered in an expression. +.sp 2 +.in 8 +.mb 5 +.fm 1 +.nf +* / MOD SHL SHR + +- + + +NOT + +AND + +OR XOR +.fi +.in 0 +.sp +.pp +Thus, the expressions shown to the left below are interpreted by +the assembler as the fully parenthesized expressions shown to the +right. +.bp +.nf +.in 5 +a*b+c (a*b)+c + +a+b*c a+(b*c) + +a MOD b*c SHL d ((a MOD b)*c) SHL d + +a OR b AND NOT c+d SHL e a OR (b AND (NOT (c+(d SHL e)))) +.fi +.in 0 +.sp +.pp +Balanced, parenthesized subexpressions can always be used to +override the assumed parentheses; thus, the last expression above +could be rewritten to force application of operators in a +different order, as shown: +.sp +.ti 8 +(a OR b) AND (NOT c)+ d SHL e +.sp +This results in these assumed parentheses: +.sp +.ti 8 +(a OR b) AND ((NOT c) + (d SHL e)) +.pp +An unparenthesized expression is well-formed only if the +expression that results from inserting the assumed parentheses is +well-formed. +.sp 2 +.tc 3.4 Assembler Directives +.he CP/M Operating System Guide 3.4 Assembler Directives +.sh +3.4 Assembler Directives +.qs +.pp +Assembler directives are used to set labels to specific values +during the assembly, perform conditional assembly, define storage +areas, and specify starting addresses in the program. Each +assembler directive is denoted by a pseudo operation that appears +in the operation field of the line. The acceptable pseudo operations +are shown in Table 3-3. +.sp 2 +.nf +.sh + Table 3-3. Assembler Directives +.sp + Directive Meaning +.fi +.sp + ORG set the program or data origin +.sp + END end program, optional start address +.sp + EQU numeric equate +.sp + SET numeric set +.sp + IF begin conditional assembly +.sp + ENDIF end of conditional assembly +.sp + DB define data bytes +.sp + DW define data words +.sp + DS define data storage area +.in 0 +.bp +.tc 3.4.1 The ORG Directive +.sh +3.4.1 The ORG Directive +.qs +.pp +The ORG statement takes the form: +.sp +.ti 8 +label ORG expression +.sp +where label is an optional program identifier and expression is +a 16-bit expression, consisting of operands that are defined +before the ORG statement. The assembler begins machine code +generation at the location specified in the expression. There +can be any number of ORG statements within a particular program, +and there are no checks to ensure that the programmer is not +defining overlapping memory areas. Note that +most programs written for the CP/M system begin with an ORG +statement of the form: +.sp +.ti 8 +ORG 100H +.sp +which causes machine code generation to begin at the base of the +CP/M transient program area. If a label is specified in the ORG +statement, the label is given the value of the expression. This +label can then be used in the operand field of other statements +to represent this expression. +.sp 2 +.tc 3.4.2 The END Directive +.sh +3.4.2 The END Directive +.qs +.pp +The END statement is optional in an assembly-language program, +but if it is present it must be the last statement. All +subsequent statements are ignored in the assembly. The END +statement takes the following two forms: +.sp +.in 8 +.nf +label END + +label END expression +.fi +.in 0 +.sp +where the label is again optional. If the first form is used, +the assembly process stops, and the default starting address of +the program is taken as 0000. Otherwise, the expression is +evaluated, and becomes the program starting address. This +starting address is included in the last record of the Intel-formatted +machine code hex file that results from the +assembly. Thus, most CP/M assembly-language programs end with +the statement: +.sp +.ti 8 +END 100H +.sp +resulting in the default starting address of 100H (beginning of +the transient program area). +.bp +.tc 3.4.3 The EQU Directive +.sh +3.4.3 The EQU Directive +.qs +.pp +The EQU (equate) statement is used to set up synonyms for +particular numeric values. The EQU statement takes the form: +.sp +.ti 8 +.nf +label EQU expression +.fi +.sp +where the label must be present and must not label any other +statement. The assembler evaluates the expression and assigns +this value to the identifier given in the label field. The +identifier is usually a name that describes the value in a more +human-oriented manner. Further, this name is used throughout the +program to place parameters on certain functions. Suppose data +received from a teletype appears on a particular input port, and +data is sent to the teletype through the next output port in +sequence. For example, you can use this series of equate statements +to define these ports for a particular hardware environment: +.sp 2 +.in 8 +.nf +TTYBASE EQU 10H ;BASE PORT NUMBER FOR TTY + +TTYIN EQU TTYBASE ;TTY DATA IN + +TTYOUT EQU TTYBASE+1 ;TTY DATA OUT +.fi +.in 0 +.sp +.pp +At a later point in the program, the statements that access the +teletype can appear as follows: +.sp 2 +.in 7 +.nf + IN TTYIN ;READ TTY DATA TO REG-A + + ... + + OUT TTYOUT ;WRITE DATA TO TTY FROM REG-A +.fi +.in 0 +.sp 2 +making the program more readable than if the absolute I/O ports +are used. Further, if the hardware environment is redefined +to start the teletype communications ports at 7FH instead of 10H, +the first statement need only be changed to +.sp +.ti 8 +.nf +TTYBASE EQU 7FH ;BASE PORT NUMBER FOR TTY +.fi +.sp +and the program can be reassembled without changing any other +statements. +.sp 2 +.tc 3.4.4 The SET Directive +.sh +3.4.4 The SET Directive +.qs +.pp +The SET statement is similar to the EQU, taking the form: +.sp +.ti 8 +label SET expression +.sp +except that the label can occur on other SET statements within +the program. The expression is evaluated and becomes the current +value associated with the label. Thus, the EQU statement defines +a label with a single value, while the SET statement defines a +value that is valid from the current SET statement to the point +where the label occurs on the next SET statement. The use of the +SET is similar to the EQU statement, but is used most often in +controlling conditional assembly. +.sp 2 +.tc 3.4.5 The IF and ENDIF Directives +.sh +3.4.5 The IF and ENDIF Directives +.qs +.pp +The IF and ENDIF statements define a range of assembly-language +statements that are to be included or excluded during the +assembly process. These statements take on the form: +.sp 2 +.in 8 +.nf +IF expression + +statement#1 + +statement#2 + + ... + +statement#n + +ENDIF +.fi +.in 0 +.sp +.pp +When encountering the IF statement, the assembler evaluates the +expression following the IF. All operands in the expression must +be defined ahead of the IF statement. If the expression +evaluates to a nonzero value, then statement#1 through +statement#n are assembled. If the expression evaluates to zero, +the statements are listed but not assembled. Conditional +assembly is often used to write a single generic program that +includes a number of possible run-time environments, with only a +few specific portions of the program selected for any particular +assembly. The following program segments, for example, might be +part of a program that communicates with either a teletype or a +CRT console (but not both) by selecting a particular value for +TTY before the assembly begins. +.bp +.nf +.in 8 +TRUE EQU OFFFFH ;DEFINE VALUE OF TRUE +FALSE EQU NOT TRUE ;DEFINE VALUE OF FALSE +; +TTY EQU TRUE ;TRUE IF TTY, FALSE IF CRT +; +TTYBASE EQU 10H ;BASE OF TTY I/O PORTS +CRTBASE EQU 20H ;BASE OF CRT I/O PORTS + IF TTY ;ASSEMBLE RELATIVE TO + ;TTYBASE +CONIN EQU TTYBASE ;CONSOLE INPUT +CONOUT EQU TTYBASE+1 ;CONSOLE OUTPUT + ENDIF + +; IF NOT TTY ;ASSEMBLE RELATIVE TO + ;CRTBASE +CONIN EQU CRTBASE ;CONSOLE INPUT +CONOUT EQU CRTBASE+1 ;CONSOLE OUTPUT + + ENDIF + ... + IN CONIN ;READ CONSOLE DATA + ... + OUT CONTOUT ;WRITE CONSOLE DATA +.fi +.in 0 +.sp 2 +In this case, the program assembles for an environment where +a teletype is connected, based at port 10H. The statement +defining TTY can be changed to +.sp +.nf +.ti 8 +TTY EQU FALSE +.fi +.sp +and, in this case, the program assembles for a CRT based at +port 20H. +.sp 2 +.tc 3.4.6 The DB Directive +.sh +3.4.6 The DB Directive +.qs +.pp +The DB directive allows the programmer to define initialized +storage areas in single-precision byte format. The DB statement +takes the form: +.sp +.nf +.ti 8 +label DB e#1, e#2, ..., e#n +.fi +.sp +where e#1 through e#n are either expressions that evaluate to 8-bit +values (the high-order bit must be zero) or are ASCII strings +of length no greater than 64 characters. There is no practical +restriction on the number of expressions included on a single +source line. The expressions are evaluated and placed +sequentially into the machine code file following the last +program address generated by the assembler. String characters +are similarly placed into memory starting with the first +character and ending with the last character. Strings of length +greater than two characters cannot be used as operands in more +complicated expressions. +.bp +.sh +Note: \c +.qs +ASCII +characters are always placed in memory with the parity bit reset +(0). Also, there is no translation from lower- to upper-case +within strings. The optional label can be used to reference the +data area throughout the remainder of the program. The following +are examples of valid DB statements: +.sp 2 +.nf +.in 8 +data: DB 0,1,2,3,4,5 + DB data and 0ffh,5,377Q,1+2+3+4 + +sign-on: DB 'please type your name',cr,lf,0 + DB 'AB' SHR 8, 'C', 'DE' AND 7FH +.fi +.in 0 +.sp 3 +.tc 3.4.7 The DW Directive +.sh +3.4.7 The DW Directive +.qs +.pp +The DW statement is similar to the DB statement except double-precision +two-byte words of storage are initialized. The DW statement +takes the form: +.sp +.nf +.ti 8 +label DW e#1, e#2, ..., e#n +.fi +.sp +where e#1 through e#n are expressions that evaluate to 16-bit +results. Note that ASCII strings of one or two +characters are allowed, but strings longer than two characters +are disallowed. In all cases, the data storage is consistent +with the 8080 processor; the least significant byte of the +expression is stored first in memory, followed by the most +significant byte. The following are examples of DW statements: +.sp 2 +.in 8 +.nf +doub: DW 0ffefh,doub+4,signon-$,255+255 + DW 'a', 5, 'ab', 'CD', 6 shl 8 or llb. +.fi +.in 0 +.sp 3 +.tc 3.4.8 The DS Directive +.sh +3.4.8 The DS Directive +.qs +.pp +The DS statement is used to reserve an area of uninitialized +memory, and takes the form: +.sp +.ti 8 +.nf +label DS expression +.fi +.sp +where the label is optional. The assembler begins subsequent +code generation after the area reserved by the DS. Thus, the DS +statement given above has exactly the same effect as the following +statement: +.sp +.nf +.in 7 +label: EQU $ ;LABEL VALUE IS CURRENT CODE LOCATION + ORG $+expression ;MOVE PAST RESERVED AREA +.fi +.in 0 +.nx threeb + + + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/threeb.tex b/Source/Doc/CPM 22 Manual - Testing/threeb.tex new file mode 100644 index 00000000..616e190f --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/threeb.tex @@ -0,0 +1,954 @@ +.bp +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.ft 3-% +.he CP/M Operating System Manual 3.5 Operation Codes +.tc 3.5 Operation Codes +.sh +3.5 Operation Codes +.qs +.pp 5 +Assembly-language operation codes form the principal part of +assembly-language programs and form the operation field of the +instruction. In general, ASM accepts all the standard mnemonics +for the Intel 8080 microcomputer, which are given in detail in the \c +.ul +Intel 8080 Assembly Language Programming Manual. \c +.qu +Labels are optional on each input line. The individual operators +are listed briefly in the following sections for completeness, +although the Intel manuals should be +referenced for exact operator details. In Tables 3-4 through 3-8, +bit values have the following meaning: +.sp 2 +.in 5 +.ti -2 +o e3 represents a 3-bit value in the range 0-7 that can be +one of the predefined registers A, B, C, D, E, H, L, M, SP, or +PSW. +.sp +.ti -2 +o e8 represents an 8-bit value in the range 0-255. +.sp +.ti -2 +o e16 represents a 16-bit value in the range 0-65535. +.in 0 +.sp +.pp +These expressions can be formed from an arbitrary combination of +operands and operators. In some cases, the operands are +restricted to particular values within the allowable range, such +as the PUSH instruction. These cases are noted as they are +encountered. +.pp +In the sections that follow, each operation code is listed in its +most general form, along with a specific example, a short +explanation, and special restrictions. +.sp 2 +.tc 3.5.1 Jumps, Calls, and Returns +.sh +3.5.1 Jumps, Calls, and Returns +.qs +.pp +The Jump, Call, and Return instructions allow several different +forms that test the condition flags set in the 8080 microcomputer +CPU. The forms are shown in Table 3-4. +.sp 2 +.ce +.sh +Table 3-4. Jumps, Calls, and Returns +.ll 63 +.sp +.nf + Form Bit Example Meaning + Value + + JMP e16 JMP L1 Jump unconditionally to label + + JNZ e16 JNZ L2 Jump on nonzero condition to label + + JZ e16 JZ 100H Jump on zero condition to label + + JNC e16 JNC L1+4 Jump no carry to label + + JC e16 JC L3 Jump on carry to label + + JPO e16 JPO $+8 Jump on parity odd to label +.bp +.ll 65 +.fi +.ce +.sh +Table 3-4. (continued) +.ll 63 +.sp +.nf + Form Bit Example Meaning + Value + + JPE e16 JPE L4 Jump on even parity to label + + JP e16 JP GAMMA Jump on positive result to label + + JM e16 JM al Jump on minus to label + + + CALL e16 CALL S1 Call subroutine unconditionally + + CNZ e16 CNZ S2 Call subroutine on nonzero + condition + + CZ e16 CZ 100H Call subroutine on zero condition + + CNC e16 CNC S1+4 Call subroutine if no carry set + + CC e16 CC S3 Call subroutine if carry set + + CPO e16 CPO $+8 Call subroutine if parity odd + + CPE e16 CPE $4 Call subroutine if parity even + + CP e16 CP GAMMA Call subroutine if positive result + + CM e16 CM b1$c2 Call subroutine if minus flag + + + RST e3 RST 0 Programmed restart, equivalent to + CALL 8*e3, except one byte call + + RET Return from subroutine + + RNZ Return if nonzero flag set + + RZ Return if zero flag set + + RNC Return if no carry + + RC Return if carry flag set + + RPO Return if parity is odd + + RPE Return if parity is even + + RP Return if positive result + + RM Return if minus flag is set +.fi +.in 0 +.ll 65 +.sp 3 +.tc 3.5.2 Immediate Operand Instructions +.sh +3.5.2 Immediate Operand Instructions +.qs +.pp 5 +Several instructions are available that load single- or double- +precision registers or single-precision memory cells with +constant values, along with instructions that perform immediate +arithmetic or logical operations on the accumulator (register A). +Table 3-5 describes the immediate operand instructions. +.sp 2 +.ce +.sh +Table 3-5. Immediate Operand Instructions +.sp +.ll 60 +.in 5 +.nf +Form with Example Meaning +Bit Values +.fi +.sp +.in 35 +.ti -30 +MVI e3,e8 MVI B,255 Move immediate data to register A, B, C, D, +E, H, L, or M (memory) +.sp +.ti -30 +ADI e8 ADI 1 Add immediate operand to A without carry +.sp +.ti -30 +ACI e8 ACI 0FFH Add immediate operand to A with carry +.sp +.ti -30 +SUI e8 SUI L + 3 Subtract from A without borrow (carry) +.sp +.ti -30 +SBI e8 SBI L AND 11B Subtract from A with borrow (carry) +.sp +.ti -30 +ANI e8 ANI $ AND 7FH Logical and A with immediate data +.sp +.ti -30 +XRI e8 XRI 1111$0000B Exclusive or A with immediate data +.sp +.ti -30 +ORI e8 ORI L AND 1+1 Logical or A with immediate data +.sp +.ti -30 +CPI e8 CPI 'a' Compare A with immediate data, same +as SUI except register A not changed. +.sp +.ti -30 +LXI e3,e16 LXI B,100H Load extended immediate to register +pair. e3 must be equivalent to B, D, H, or SP. +.in 0 +.ll 65 +.sp 2 +.tc 3.5.3 Increment and Decrement Instructions +.sh +3.5.3 Increment and Decrement Instructions +.qs +.pp +The 8080 provides instructions for incrementing or decrementing +single- and double-precision registers. The instructions are +described in Table 3-6. +.sp 2 +.ce +.sh +Table 3-6. Increment and Decrement Instructions +.ll 60 +.sp +.in 5 +.nf +Form with Example Meaning +Bit Value +.fi +.sp +.in 35 +.ti -28 +INR e3 INR E Single-precision increment +register. e3 produces one of A, B, C, D, E, H, L, M. +.sp +.ti -28 +DCR e3 DCR A Single-precision decrement +register. e3 produces one of A, B, C, D, E, H, L, M. +.sp +.ti -28 +INX e3 INX SP Double-precision increment register +pair. e3 must be equivalent to B, D, H, or SP. +.sp +.ti -28 +DCX e3 DCX B Double-precision decrement register +pair. e3 must be equivalent to B, D, H, or SP. +.in 0 +.ll 65 +.sp 3 +.tc 3.5.4 Data Movement Instructions +.sh +3.5.4 Data Movement Instructions +.qs +.pp +Instructions that move data from memory to the CPU and from CPU to memory are +given in the following table. +.sp 2 +.ce +.sh +Table 3-7. Data Movement Instructions +.ll 60 +.in 5 +.sp +.nf +Form with Example Meaning +Bit Value +.fi +.sp +.in 35 +.ti -30 +MOV e3,e3 MOV A,B Move data to leftmost element from rightmost +element. e3 produces on of A, B, C, D, E, H, L, or M. MOV M,M is +disallowed. +.sp +.ti -30 +LDAX e3 LDAX B Load register A from computed address. e3 must +produce either B or D. +.sp +.ti -30 +STAX e3 STAX D Store register A to computed +address. e3 must produce either B or D. +.sp +.ti -30 +LHLD e16 LHLD L1 Load HL direct from location +e16. Double-precision load to H and L. +.fi +.bp +.ll 65 +.in 0 +.ce +.sh +Table 3-7. (continued) +.ll 60 +.in 5 +.sp +.nf +Form with Example Meaning +Bit Value +.fi +.sp +.in 35 +.ti -30 +SHLD e16 SHLD L5+x Store HL direct to location e16. +Double-precision store from H and L to memory. +.sp +.ti -30 +LDA e16 LDA Gamma Load register A from address e16. +.sp +.ti -30 +STA e16 STA X3-5 Store register A into memory +at e16. +.sp +.ti -30 +POP e3 POP PSW Load register pair from stack, set SP. +e3 must produce one of B, D, H, or PSW. +.sp +.ti -30 +PUSH e3 PUSH B Store register pair into stack, set SP. e3 +must produce on of B, D, H, or PSW. +.sp +.ti -30 +IN e8 IN 0 Load register A with data from port +e8. +.sp +.ti -30 +OUT e8 OUT 255 Send data from register A to port +e8. +.sp +.ti -30 +XTHL Exchange data from top of stack +with HL. +.sp +.ti -30 +PCHL Fill program counter with data from +HL. +.sp +.ti -30 +SPHL Fill stack pointer with data from +HL. +.sp +.ti -30 +XCHG Exchange DE pair with HL pair. +.in 0 +.ll 65 +.sp 3 +.tc 3.5.5 Arithmetic Logic Unit Operations +.sh +3.5.5 Arithmetic Logic Unit Operations +.qs +.pp +Instructions that act upon the single-precision accumulator to +perform arithmetic and logic operations are given in the +following table. +.bp +.ce +.sh +Table 3-8. Arithmetic Logic Unit Operations +.ll 60 +.sp +.in 5 +.nf +Form with Example Meaning +Bit Value +.fi +.sp +.in 35 +.ti -29 +ADD e3 ADD B Add register given by e3 to +accumulator without carry. e3 must produce one of A, B, C, D, E, +H, or L. +.sp +.ti -29 +ADC e3 ADC L Add register to A with carry, e3 as +above. +.sp +.ti -29 +SUB e3 SUB H Subtract reg e3 from A without +carry, e3 is defined as above. +.sp +.ti -29 +SBB e3 SBB 2 Subtract register e3 from A with +carry, e3 defined as above. +.sp +.ti -29 +ANA e3 ANA 1+1 Logical and reg with A, e3 as +above. +.sp +.ti -29 +XRA e3 XRA A Exclusive or with A, e3 as above. +.sp +.ti -29 +ORA e3 ORA B Logical or with A, e3 defined as +above. +.sp +.ti -29 +CMP e3 CMP H Compare register with A, e3 as +above. +.sp +.ti -29 +DAA Decimal adjust register A based +upon last arithmetic logic unit operation. +.sp +.ti -29 +CMA Complement the bits in register A. +.sp +.ti -29 +STC Set the carry flag to 1. +.sp +.ti -29 +CMC Complement the carry flag. +.sp +.ti -29 +RLC Rotate bits left, (re)set carry as a +side effect. High-order A bit becomes carry. +.sp +.ti -29 +RRC Rotate bits right, (re)set carry as +side effect. Low-order A bit becomes carry. +.bp +.in 0 +.ll 65 +.ce +.sh +Table 3-8. (continued) +.ll 60 +.sp +.in 5 +.nf +Form with Example Meaning +Bit Value +.fi +.sp +.in 35 +.ti -29 +RAL Rotate carry/A register to left. +Carry is involved in the rotate. +.sp +.ti -29 +RAR Rotate carry/A register to right. +Carry is involved in the rotate. +.sp +.ti -29 +DAD e3 DAD B Double-precision add register pair +e3 to HL. e3 must produce B, D, H, or SP. +.in 0 +.ll 65 +.sp 2 +.tc 3.5.6 Control Instructions +.sh +3.5.6 Control Instructions +.qs +.pp +The four remaining instructions, categorized as control instructions, are +the following: +.sp +.nf +.in 3 +o HLT halts the 8080 processor. +o DI disables the interrupt system. +o EI enables the interrupt system. +o NOP means no operation. +.in 0 +.fi +.sp 2 +.tc 3.6 Error Messages +.he CP/M Operating System Manual 3.6 Error Messages +.sh +3.6 Error Messages +.qs +.pp +When errors occur within the assembly-language program, they are +listed as single-character flags in the leftmost position of the +source listing. The line in error is also echoed at the console +so that the source listing need not be examined to determine if +errors are present. The error codes are listed in the following +table. +.sp 2 +.ce +.sh +Table 3-9. Error Codes +.sp +.ll 60 +.in 3 +.nf +Error Code Meaning +.fi +.sp +.in 16 +.ti -13 +D Data error: element in data statement cannot be placed in +the specified data area. +.sp +.ti -13 +E Expression error: expression is ill-formed and cannot be +computed at assembly time. +.sp +.ti -13 +L Label error: label cannot appear in this context; might be +duplicate label. +.sp +.ti -13 +N Not implemented: features that will appear in future ASM +versions. For example, macros are recognized, but flagged in this +version. +.bp +.in 0 +.ll 65 +.ce +.sh +Table 3-9. (continued) +.sp +.ll 60 +.in 3 +.nf +Error Code Meaning +.fi +.sp +.in 16 +.ti -13 +O Overflow: expression is too complicated (too many +pending operators) to be computed and should be simplified. +.sp +.ti -13 +P Phase error: label does not have the same value on two +subsequent passes through the program. +.sp +.ti -13 +R Register error: the value specified as a register is not +compatible with the operation code. +.sp +.ti -13 +S Syntax error: statement is not properly formed. +.sp +.ti -13 +V Value error: operand encountered in expression is +improperly formed. +.in 0 +.ll 65 +.sp +.pp +Table 3-10 lists the error messages that are due to terminal error +conditions. +.sp 2 +.ce +.sh +Table 3-10. Error Messages +.sp +.ll 60 +.in 5 +.nf +Message Meaning +.fi +.sp +NO SOURCE FILE PRESENT +.sp +.in 19 +The file specified in the ASM command does not exist on disk. +.sp 2 +.in 5 +NO DIRECTORY SPACE +.sp +.in 19 +The disk directory is full; erase files that are not needed and retry. +.sp 2 +.in 5 +SOURCE FILE NAME ERROR +.sp +.in 19 +Improperly formed ASM filename, for example, it is specified with ? fields. +.sp 2 +.in 5 +SOURCE FILE READ ERROR +.sp +.in 19 +Source file cannot be read properly by the assembler; execute a +TYPE to determine the point of error. +.bp +.in 0 +.ll 65 +.ce +.sh +Table 3-10. (continued) +.sp +.ll 60 +.in 5 +.nf +Message Meaning +.fi +.sp +OUTPUT FILE WRITE ERROR +.sp +.in 19 +Output files cannot be written properly; most likely cause is a full +disk, erase and retry. +.sp 2 +.in 5 +CANNOT CLOSE FILE +.sp +.in 19 +Output file cannot be closed; check to see if disk is write protected. +.in 0 +.ll 65 +.sp 3 +.tc 3.7 A Sample Session +.he CP/M Operating System Manual 3.7 A Sample Session +.sh +3.7 A Sample Session +.qs +.pp +The following sample session shows interaction with the assembler and +debugger in the development of a simple assembly-language +program. The arrow represents a carriage return keystroke. +.sp 2 +.ll 90 +.nf +A>\c +.sh +ASM SORT \c +.qs +Assemble SORT.ASM +.sp +CP/M ASSEMBLER - VER 1.0 +.sp +0015C Next free address +003H USE FACTOR Percent of table used 00 to ff (hexadecimal) +END OF ASSEMBLY +.sp +A>\c +.sh +DIR SORT.* +.qs +.sp +SORT ASM Source file +SORT BAK Back-up from last edit +SORT PRN Print file (contains tab characters) +SORT HEX Machine code file +.sp +A>\c +.sh +TYPE SORT.PRN +.qs + Source line +.sp + ; SORT PROGRAM IN CP/M ASSEMBLY LANGUAGE + ; START AT THE BEGINNING OF THE TRANSIENT + PROGRAM AREA +.sp +Machine code location +0100 ORG 100H +.sp +Generated machine code +0100 214601 SORT: LXI H,SW ;ADDRESS SWITCH TOGGLE +0103 3601 MVI M,1 ;SET TO 1 FOR FIRST ITERATION +0105 214701 LXI H,I ;ADDRESS INDEX +0108 3600 MVI M,0 ;I=0 + ; + ; COMPARE I WITH ARRAY SIZE +010A 7E COMPL: MOV A,M ;A REGISTER = I +010B FE09 CPI N-1 ;CY SET IF I<(N-1) +010D D21901 JNC CONT ;CONTINUE IF I<=(N-2) + ; + ; END OF ONE PASS THROUGH DATA +0110 214601 LXI H,SW ;CHECK FOR ZERO SWITCHES +0113 7EB7C200001 MOV A, M! ORA A! JNZ SORT ;END OF SORT IF SW=0 + ; +0118 FF RST 7 ;GO TO THE DEBUGGER INSTEAD OF REB + ; + ; CONTINUE THIS PASS +Truncated ; ADDRESSING I, SO LOAD AV(I) INTO REGISTERS +0119 + 5F16002148CONT: MOV E, A! MVI D, 0! LXI H, AV! DAD D! DAD D +0121 4E792346 MOV C, M! MOV A, C! INX H! MOV B, M + ; LOW ORDER BYTE IN A AND C, HIGH ORDER BYTE IN B + ; + ; MOV H AND L TO ADDRESS AV(I+1) +0125 23 INX H + ; + ; COMPARE VALUE WITH REGS CONTAINING AV (I) +0126 965778239E SUB M! MOV D, A! MOV A, B! INX H! SBB M ;SUBTRACT + ; + ; BORROW SET IF AV(I+1)>AV(I) +012B DA3F01 JC INCI ;SKIP IF IN PROPER ORDER + ; + ; CHECK FOR EQUAL VALUES +012E B2CA3F01 ORA D! JZ INCI ;SKIP IF AV(I) = AV(I+1) +0132 56702B5E MOV D, M! MOV M, B! DCX H! MOV E, M +0136 712B722B73 MOV M, C! DCX H! MOV M, D! DCX H! MOV M, E + ; + ; INCREMENT SWITCH COUNT +013B 21460134 LXI H,SW! INR M + ; + ; INCREMENT I +013F 21470134C3INCI:LXI H,I! INR M! JMP COMP + ; + ; DATA DEFINITION SECTION +0146 00 SW: DB 0 ;RESERVE SPACE FOR SWITCH COUNT +0147 I: DS 1 ;SPACE FOR INDEX +0148 050064001EAV: DW 5, 100, 30, 50, 20, 7, 1000, 300, 100, -32767 +000A = N EQU($-AV)/2 ;COMPUTE N INSTEAD OF PRE +015C END +A>\c +.sh +TYPE SORT.HEX \c +.qs +Equate value + +:10010000214601360121470136007EFE09D2190140 +:100110002146017EB7C20001FF5F16002148011988 Machine code in +:10012000194E79234623965778239EDA3F01B2CAA7 HEX format +.mb 5 +.fm 1 + +:100130003F0156702B5E712B722B732146013421C7 +:07014000470134C30A01006E Machine code in +:10014800050064001E00320014000700E8032C01BB HEX format +:0401580064000180BE +:0000000000 +A>\c +.sh +DDT SORT.HEX \c +.qs +Start debug run +.mb 6 +.fm 2 + +16K DDT VER 1.0 +NEXT PC +015C 0000 Default address (no address on END statement) +-XP + +P=0000 100 Change PC to 100 + +-UFFFF Untrace for 65535 steps + Abort with rubout +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 LXI H,0146*0100 +-T10 Trace 10\d16\u steps + +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0100 LXI H, 0146 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M, 01 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H, 0147 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M, 00 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=010A MOV A, M +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010B CPI 09 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010D JNC 0119 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0110 LXI H, 0146 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0113 MOV A, M +C1Z0M1E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0114 ORA A +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0115 JNZ 0100 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0100 LXI H, 0146 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M, 01 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H, 0147 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M, 00 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=010A MOV A, M*010B +-A10D Stopped at 10BH + +010D JC 119 Change to a jump on carry +0110 + +-XP + +P=010B 100 Reset program counter back to beginning of program + +-T10 Trace execution for 10H steps + + Altered instruction +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0100 LXI H,0146 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M,01 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H,0147 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M,00 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010A MOV A,M +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010B CPI 09 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010D JC 0119 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0119 MOV E,A +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=011A MVI D,00 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=011C LXI H,0148 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=011F DAD D +C0Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=0120 DAD D +C0Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=0121 MOV C,M +C0Z0M1E0I0 A=00 B=0005 D=0000 H=0148 S=0100 P=0122 MOV A,C +C0Z0M1E0I0 A=05 B=0005 D=0000 H=0148 S=0100 P=0123 INX H +C0Z0M1E0I0 A=05 B=0005 D=0000 H=0149 S=0100 P=0124 MOV B,M*0125 +-L100 Automatic breakpoint + + 0100 LXI H,0146 + 0103 MVI M,01 + 0105 LXI H,0147 + 0108 MVI M,00 + 010A MOV A,M List some code + 010B CPI 09 from 100H + 010D JC 0119 + 0110 LXI H,0146 + 0113 MOV A,M + 0114 ORA A + 0115 JNZ 0100 + -L + + 0118 RST 07 + 0119 MOV E,A List more + 011A MVI D,00 + 011C LXI H,0148 +-Abort list with rubout +-G,11B Start program from current PC (0125H) + and run in real time to 11BH + + + +*0127 Stopped with an external interrupt 7 from front panel +-T4 (program was looping indefinitely) + Look at looping program in trace mode + +C0Z0M0E0I0 A=38 B=0064 D=0006 H=0156 S=0100 P=0127 MOV D,A +C0Z0M0E0I0 A=38 B=0064 D=3806 H=0156 S=0100 P=0128 MOV A,B +C0Z0M0E0I0 A=00 B=0064 D=3806 H=0156 S=0100 P=0129 INX H +C0Z0M0E0I0 A=00 B=0064 D=3806 H=0157 S=0100 P=012A SBB M*012B +-D148 + Data are sorted, but program does not stop. +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D.,........ + +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-G0 Return to CP/M + +A>\c +.sh +DDT SORT.HEX \c +.qs +Reload the memory image + +16K DDT VER 1.0 +NEXT PC +015C 0000 +-XP + +P=0000 100 Set PC to beginning of program + +-L10D List bad OPCODE + + 010D JNC 0119 + 0110 LXI H,0146 +-Abort list with rubout +-A10D Assemble new OPCODE + +010D JC 119 + +0110 + +-L100 List starting section of program + + 0100 LXI H,0146 + 0103 MVI M,01 + 0105 LXI H,0147 + 0108 MVI M,00 +-Abort list with rubout +-A103 Change switch initialization to 00 + +0103 MVI M,0 + +0105 + +-^C Return to CP/M with CTRL-C (G0 works as well) + +SAVE 1 SORT.COM Save 1 page (256 bytes, from 100H to 1ffH) on + disk in case there is need to reload later +A>\c +.sh +DDT SORT.COM \c +.qs +Restart DDT with saved memory image + +16K DDT VER 1.0 +NEXT PC +0200 0100 COM file always starts with address 100H +-G Run the program from PC=100H + +*0118 Programmed stop (RST 7) encountered +-D148 + + Data properly sorted +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D......... + +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ +0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-G0 Return to CP/M + +A>\c +.sh +ED SORT.ASM \c +.qs +Make changes to original program + +*N,0^Z0TT Find next ,0 + MVI M,0 ;I = 0 + +*- Up one line in text + LXI H,I ;ADDRESS INDEX +.bp +*- Up another line + MVI M,1 ;SET TO 1 FOR FIRST ITERATION + +*KT Kill line and type next line + LXI H,I ;ADDRESS INDEX + +*I Insert new line + MVI M,0 ;ZERO SW + +*T + LXI H,I ;ADDRESS INDEX + +*NJNC^Z0T + JNC*T + CONT ;CONTINUE IF I<=(N-2) + +*-2DIC^Z0LT + JC CONT ;CONTINUE IF I<=(N-2) + +*E Source from disk A + HEX to disk A +A>\c +.sh +ASM SORT.AAZ \c +.qs +Skip PRN file + +CP/M ASSEMBLER - VER 1.0 + +015C Next address to assemble +003H USE FACTOR +END OF ASSEMBLY + +A>\c +.sh +DDT SORT.HEX \c +.qs +Test program changes + +16K DDT VER 1.0 +NEXT PC +015C 0000 +-G100 + +*0118 +-D148 + Data sorted +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D.......... +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-Abort with rubout + +-G0 Return to CP/M--program checks OK. +.in 0 +.ll 65 +.sp 2 +.ce +End of Section 3 +.nx foura + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual - Testing/two.tex b/Source/Doc/CPM 22 Manual - Testing/two.tex new file mode 100644 index 00000000..e534f9d3 --- /dev/null +++ b/Source/Doc/CPM 22 Manual - Testing/two.tex @@ -0,0 +1,1124 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 2-% +.pc 1 +.tc 2 The CP/M Editor +.ce 2 +.sh +Section 2 +.sp +.sh +The CP/M Editor +.sp 3 +.tc 2.1 Introduction to ED +.he CP/M Operating System Manual 2.1 Introduction to ED +.sh +2.1 Introduction to Ed +.qs +.pp 5 +Ed is the context editor for CP/M, and is used to create and alter CP/M source +files. To start ED, type a command of the following form: +.sp +.nf +.ti 8 +ED filename +or +.ti 8 +ED filename.typ +.fi +.sp +Generally, ED reads segments of the source file given by filename or +filename.typ into the central memory, where you edit the file +and it is subsequently written back to disk after alterations. If the +source file does not exist before editing, it is created by ED and +initialized to empty. The overall operation of Ed is shown in +Figure 2-1. +.sp 2 +.tc 2.1.1 ED Operation +.sh +2.1.1 ED Operation +.qs +.pp +Ed operates upon the source file, shown in Figure 2-1 by x.y, and passes +all text through a memory buffer where the text can be viewed or altered. +The number of lines that can be maintained in the memory buffer varies with +the line length, but has a total capacity of about 5000 characters in a 20K +CP/M system. +.pp +Edited text material is written into a temporary +work file under your command. Upon termination of the edit, the +memory buffer is written to the temporary file, followed by any remaining +(unread) text in the source file. The name of the original file is changed +from x.y to x.BAK so that the most recent edited source file can +be reclaimed if necessary. See the CP/M commands ERASE and RENAME. The +temporary file is then changed from x.$$$ to x.y, which becomes the resulting +edited file. +.pp +The memory buffer is logically between the source file and working file, as +shown in Figure 2-2. +.bp +.sp 27 +.ce +.sh +Figure 2-1. Overall ED Operation +.sp 3 +.nf + Source File Memory Buffer Temporary File + + 1 First Line 1 First Line 1 First Line + 2 Appended 2 Buffered 2 Processed + 3 Lines 3 Text 3 Text + + + + SP MP TP + + + + Unprocessed Next Free Next Free File + Source Append Memory Write Space + Lines Space + + + + SP = Source Pointer + MP = Memory Pointer + TP = Temporary Pointer +.sp 2 +.fi +.ce +.sh +Figure 2-2. Memory Buffer Organization +.bp +.tc 2.1.2 Text Transfer Functions +.sh +2.1.2 Text Transfer Functions +.qs +.pp +Given that n is an integer value in the range 0 through 65535, several +single-letter ED commands transfer lines of text from the source file through +the memory buffer to the temporary (and eventually final) file. Single letter +commands are shown in upper-case, but can be typed in either upper- or +lower-case. +.sp 2 +.ce +.sh +Table 2-1. ED Text Transfer Commands +.sp + Command Result +.sp +.ll 60 +.in 15 +.ti -10 +nA Appends the next n unprocessed source lines from the source file at +SP to the end of the memory buffer at MP. Increment SP and MP by n. If +upper-case translation is set (see the U command) and the A command is typed +in upper-case, all input lines will automatically be translated to upper-case. +.sp +.ti -10 +nW Writes the first n lines of the memory buffer to the temporary +file free space. Shift the remaining lines n+1 through MP to the top of the +memory buffer. Increment TP by n. +.sp +.ti -10 +E Ends the edit. Copy all buffered text to temporary file and copy +all unprocessed source lines to temporary file. Rename files. +.sp +.ti -10 +H Moves to head of new file by performing automatic E command. The +temporary file becomes the new source file, the memory buffer is emptied, and +a new temporary file is created. The effect is equivalent to issuing an E +command, followed by a reinvocation of ED, using x.y as the file to edit. +.sp +.ti -10 +O Returns to original file. The memory buffer is emptied, the +temporary file is deleted, and the SP is returned to position 1 of the +source file. The effects of the previous editing commands are thus nullified. +.sp +.ti -10 +Q Quits edit with no file alterations, returns to CP/M. +.in 0 +.ll 65 +.sp +.pp +There are a number of special cases to consider. If the integer n is omitted +in any ED command where an integer is allowed, then 1 is assumed. Thus, the +commands A and W append one line and write one line, respectively. In +addition, if a pound sign # is given in the place of n, then the integer +65535 is assumed (the largest value for n that is allowed). Because most +source files can be contained entirely in the memory buffer, +the command #A is often issued at the beginning of the edit to read the +entire source file to memory. Similarly, the command #W writes the entire +buffer to the temporary file. +.pp +Two special forms of the A and W commands +are provided as a convenience. The command 0A fills the current memory +buffer at least half full, while 0W writes lines until the buffer is at least +half empty. An error is issued if the memory buffer size is exceeded. +You can then enter any command, such as W, that does not increase +memory requirements. The remainder of any partial line read during the +overflow will be brought into memory on the next successful append. +.sp 2 +.tc 2.1.3 Memory Buffer Organization +.sh +2.1.3 Memory Buffer Organization +.qs +.pp +The memory buffer can be considered a sequence of source lines brought +in with the A command from a source file. The memory buffer has an imaginary +character pointer (CP) that moves throughout the memory buffer +under command of the operator. +.pp +The memory buffer appears logically as shown +in Figure 2-3, where the dashes represent characters of the source line of +indefinite length, terminated by carriage return () and line-feed () +characters, and CP represents the imaginary character pointer. +Note that the CP is always located ahead of the first character of the +first line, behind the last character of the last line, or between two +characters. The current line CL is the source line that contains the CP. +.sp 3 +.nf + Memory Buffer + + + first line ----------------------- + + + ----------------------- + + + current line CL --------------------------- + + + CP + + last line ----------------------- +.sp 2 +.sh + Figure 2-3. Logical Organization of Memory Buffer +.qs +.fi +.sp 5 +.tc 2.1.4 Line Numbers and ED Start-up +.sh +2.1.4 Line Numbers and ED Start-up +.qs +.pp +ED produces absolute line number prefixes that are used to reference a +line or range of lines. The absolute line number is displayed at the +beginning of each line when ED is in insert mode (see the I command in +Section 2.1.5). Each line number takes the form +.sp +.ti 8 +nnnnn: +.sp +where nnnnn is an absolute line number in the range of 1 to 65535. If the +memory buffer is empty or if the current line is at the end of the memory +buffer, nnnnn appears as 5 blanks. +.pp +You can reference an absolute line number by preceding any command by +a number followed by a colon, in the same format as the line number display. +In this case, the ED program moves the current line reference to the absolute +line number, if the line exists in the current memory buffer. The line +denoted by the absolute line number must be in the memory buffer (see the +A command). Thus, the command +.sp +.ti 8 +345:T +.sp +is interpreted as move to absolute 345, and type the line. Absolute line +numbers are produced only during the editing process and are not recorded +with the file. In particular, the line numbers will change following a +deleted or expanded section of text. +.pp +You can also reference an absolute line number as a backward or forward +distance from the current line by preceding the absolute number by a colon. +Thus, the command +.sp +.ti 8 +:400T +.sp +is interpreted as type from the current line number through the line whose +absolute number is 400. Combining the two line reference forms, the +command +.sp +.ti 8 +345::400T +.sp +is interpreted as move to absolute line 345, then type through +absolute line 400. Absolute line references of this sort can precede any +of the standard ED commands. +.pp +Line numbering is controlled by the V (Verify Line Numbers) command. Line +numbering can be turned off by typing the -V command. +.bp +If the file to edit does not exist, ED displays the following message: +.sp +.ti 8 +NEW FILE +.sp +To move text into the memory buffer, you must enter an i command before typing +input lines and terminate each line with a carriage return. A single +CTRL-Z character returns ED to command mode. +.sp 2 +.tc 2.1.5 Memory Buffer Operation +.sh +2.1.5 Memory Buffer Operation +.qs +.pp +When ED begins, the memory buffer is empty. You can either append +lines from the source file with the A command, or enter the lines directly +from the console with the insert command. The insert command takes the +following form: +.sp +.ti 8 +I +.sp +ED then accepts any number of input lines. You must terminate each line with +a (the is supplied automatically). A single CTRL-Z, denoted +by a caret (^)Z, returns ED to command mode. The CP is positioned after the +last character entered. The following sequence: +.sp +.in 8 +.nf +I +NOW IS THE +TIME FOR +ALL GOOD MEN +^Z +.fi +.in 0 +.sp +leaves the memory buffer as +.sp +.in 8 +.nf +NOW IS THE +TIME FOR +ALL GOOD MEN +.fi +.in 0 +.pp +Generally, ED accepts command letters in upper- or lower-case. If the +command is upper-case, all input values associated with the command are +translated to upper-case. If the I command is typed, all +input lines are automatically translated internally to upper-case. The +lower-case form of the i command is most often used to allow both upper- and +lower-case letters to be entered. +.pp +Various commands can be issued that control the CP or display source text +in the vicinity of the CP. The commands shown below with a preceding n +indicate that an optional unsigned value can be specified. When preceded +by +\b_, the command can be unsigned, or have an optional preceding plus or +minus sign. As before, the pound sign # is replaced by 65535. If an +integer n is optional, but not supplied, then n=1 is assumed. Finally, if a +plus sign is optional, but none is specified, then + is assumed. +.bp +.ce +.sh +Table 2-2. Editing Commands +.sp + Command Action +.sp +.ll 60 +.in 15 +.ti -10 ++\b_B Move CP to beginning of memory buffer if + and to bottom if -. +.sp +.ti -10 ++\b_nC Move CP by +\b_n characters (moving ahead if +), counting the + as two characters. +.sp +.ti -10 ++\b_nD Delete n characters ahead of CP if plus and behind CP if minus. +.sp +.ti -10 ++\b_nK Kill (remove) +\b_n lines of source text using CP as the +current reference. If CP is not at the beginning of the current line when K +is issued, the characters before CP remain if + is specified, while the +characters after CP remain if - is given in the command. +.sp +.ti -10 ++\b_nL If n = 0, move CP to the beginning of the current +line, if it is +not already there. If n =\b/ 0, first move the CP to the beginning of the +current line and then move it to the beginning of the line that is n lines +down (if +) or up (if -). The CP will stop at the top or bottom of the +memory buffer if too large a value of n is specified. +.sp +.ti -10 ++\b_nT If n = 0, type the contents of the current line up to CP. If +n = 1, type the contents of the current line from CP to the end of the line. +If n>1, type the current line along with n - 1 lines that follow, if + is +specified. Similarly, if n>1 and - is given, type the previous n lines up to +the CP. Any key can be depressed to abort long type-outs. +.sp +.ti -10 ++\b_n Equivalent to +\b_nLT, which moves up or down and types a +single line. +.in 0 +.ll 65 +.sp 3 +.tc 2.1.6 Command Strings +.sh +2.1.6 Command Strings +.qs +.pp +Any number of commands can be typed contiguously (up to the capacity of +the console buffer) and are executed only after you press the . Table 2-3 +summarizes the CP/M console line-editing commands used to control the input +command line. +.bp +.ce +.sh +Table 2-3. Line-editing Controls +.sp + Command Result +.sp +.ll 60 +.in 16 +.ti -11 +CTRL-C Reboots the CP/M system when typed at the start of a line. +.sp +.ti -11 +CTRL-E Physical end of line: carriage is returned, but line is not sent +until the carriage return key is depressed. +.sp +.ti -11 +CTRL-H Backspaces one character position. +.sp +.ti -11 +CTRL-J Terminates current input (line-feed). +.sp +.ti -11 +CTRL-M Terminates current input (carriage return). +.sp +.ti -11 +CTRL-R Retypes current command line: types a clean line character +deletion with rubouts. +.sp +.ti -11 +CTRL-U Deletes the entire line typed at the console. +.sp +.ti -11 +CTRL-X Same as CTRL-U. +.sp +.ti -11 +CTRL-Z Ends input from the console (used in PIP and ED). +.sp +.ti -11 +rub/del Deletes and echos the last character typed at the +console. +.in 0 +.ll 65 +.sp +.pp +Suppose the memory buffer contains the characters shown in the +previous section, with the CP following the last character of the +buffer. In the following example, the command strings on the left produce +the results shown to the right. Use lower-case command letters to avoid +automatic translation of strings to upper-case. +.sp 2 + Command String Effect +.sp +.fi +.in 20 +.ll 60 +.ti -15 +B2T Move to beginning of the buffer and type two lines: +.nf +.sp +NOW IS THE +TIME FOR +.fi +The result in the memory buffer is +.sp +.nf +NOW IS THE +TIME FOR +ALL GOOD MEN +.fi +.in 0 +.bp + Command String Effect +.in 20 +.sp +.ti -15 +5C0T Move CP five characters and type the beginning of the line NOW +I. The result in the memory buffer is +.sp +NOW I S THE +.sp 2 +.ti -15 +2L-T Move two lines down and type the previous line TIME FOR. +The result in the memory buffer is +.sp +.nf +NOW IS THE +TIME FOR +ALL GOOD MEN +.fi +.sp 2 +.ti -15 +-L#K Move up one line, delete 65535 lines that follow. The result +in the memory buffer is +.sp +NOW IS THE +.sp 2 +.ti -15 +I Insert two lines of text with automatic +.ti -15 +TIME TO translation to upper-case. The result in +.ti -15 +INSERT the memory buffer is +.ti -15 +^Z +.sp +.nf +NOW IS THE +TIME TO +INSERT +.fi +.sp 2 +.ti -15 +-2L#T Move up two lines and type 65535 lines ahead of CP NOW IS THE. +The result in the memory buffer is +.sp +.nf +NOW IS THE +TIME TO +INSERT +.fi +.sp 2 +.ti -15 + Move down one line and type one line INSERT. The result in +the memory buffer is +.sp +.nf +NOW IS THE +TIME TO +INSERT +.fi +.in 0 +.ll 65 +.bp +.tc 2.1.7 Text Search and Alteration +.sh +2.1.7 Text Search and Alteration +.qs +.pp +ED has a command that locates strings within the memory +buffer. The command takes the form +.sp +.nf +.ti 8 +nF s +or +.ti 8 +nF s ^Z +.fi +.sp +where s represents the string to match, followed by either a +or CTRL-Z, denoted by ^Z. ED starts at the current position +of CP and attempts to match the string. The match is attempted n +times and, if successful, the CP is moved directly after the +string. If the n matches are not successful, the CP is not moved +from its initial position. Search strings can include CTRL-L, +which is replaced by the pair of symbols . +.pp +The following commands illustrate the use of the F command: +.sp 2 + Command String Effect +.in 20 +.sp +.ll 60 +.ti -15 +B#T Move to the beginning and type the entire buffer. The result +in the memory buffer is +.sp +.nf +NOW IS THE +TIME FOR +ALL GOOD MEN +.fi +.sp 2 +.ti -15 +FS T Find the end of the string S T. The result in the memory +buffer is +.nf +.sp +NOW IS T HE +.fi +.sp 2 +.ti -15 +FIs^Z0TT Find the next I and type to the CP; then type the remainder +of the current line ME FOR. The result in the memory buffer is +.nf +.sp +NOW IS THE +TI ME FOR + +ALL GOOD MEN +.fi +.in 0 +.ll 65 +.sp +.pp +An abbreviated form of the insert command is also allowed, which +is often used in conjunction with the F command to make simple +textual changes. The form is +.sp +.ti 8 +.nf +| s ^Z +or +.ti 8 +| s +.fi +.sp +where s is the string to insert. If the insertion string is +terminated by a CTRL-Z, the string is inserted directly following +the CP, and the CP is positioned directly after the string. The +action is the same if the command is followed by a except +that a is automatically inserted into the text following +the string. The following command sequences are examples +of the F and I commands: +.sp 2 + Command String Effect +.in 20 +.ll 60 +.sp +.ti -15 +BITHIS IS ^Z +.sp +Insert THIS IS at the beginning of the text. The result in the +memory buffer is +.sp +THIS IS NOW THE +.nf + +TIME FOR +ALL GOOD MEN +.sp 2 +.fi +.ti -15 +FTIME^Z-4DIPLACE^Z +.sp +Find TIME and delete it; then insert PLACE. The result in the memory +buffer is +.nf +.sp +THIS IS NOW THE +PLACE FOR + +ALL GOOD MEN +.sp 2 +.ti -15 +3FO^Z-3D5D1 +.fi +.ti -15 +CHANGES^Z Find third occurrence of O (that is, the +second O in GOOD), +delete previous 3 characters and the subsequent 5 characters; then insert +CHANGES. The result in the memory buffer is +.nf +.sp +THIS IS NOW THE +PLACE FOR +ALL CHANGES +.fi +.sp 2 +.ti -15 +-8CISOURCE +.sp +Move back 8 characters and insert the line SOURCE. The result in the +memory buffer is +.nf +.sp +THIS IS NOW THE +PLACE FOR +ALL SOURCE + CHANGES +.fi +.ll 65 +.in 0 +.sp +.pp +ED also provides a single command that combines the F and I +commands to perform simple string substitutions. The command +takes the following form: +.sp +.nf +.ti 8 +nS s\d1\u^Zs\d2\u +or +.ti 8 +nS s\d1\u^Zs\d2\u ^Z +.fi +.sp +and has exactly the same effect as applying the following command +string a total of n times: +.sp +.nf +.ti 8 +F s\d1\u^Z-kDIs\d2 +or +.ti 8 +F s\d1\u^Z-kDIs\d2\u ^Z +.fi +.sp +where k is the length of the string. ED searches the +memory buffer starting at the current position of CP and +successively substitutes the second string for the first string +until the end of buffer, or until the substitution has been +performed n times. +.pp +As a convenience, a command similar to F is provided by ED that +automatically appends and writes lines as the search proceeds. +The form is +.sp +.nf +.ti 8 +n N s +or +.ti 8 +n N s ^Z +.fi +.sp +which searches the entire source file for the nth occurrence of +the strings (you should recall that F fails if the string +cannot be found in the current buffer). The operation of the N +command is precisely the same as F except in the case that the +string cannot be found within the current memory buffer. In this +case, the entire memory content is written (that is, an automatic #W +is issued). Input lines are then read until the buffer is at +least half full, or the entire source file is exhausted. The +search continues in this manner until the string has been found n +times, or until the source file has been completely transferred to +the temporary file. +.pp +A final line editing function, called the juxtaposition command, +takes the form +.sp +.nf +.ti 8 +n J s\d1\u^Zs\d2\u^Zs\d3\u +or +.ti 8 +n J s\d1\u^Zs\d2\u^Zs\d3\u ^Z +.fi +.sp +with the following action applied n times to the memory buffer: search from +the current CP for the next occurrence of the string s1. If found, +insert the string s2, and move CP to follow s2. Then delete all +characters following CP up to, but not including, the string s\d3\u, leaving +CP directly after s\d2\u. If s\d3\u cannot be found, then no deletion is +made. If the current line is +.sp 4 +.ti 8 +.nf +NOW IS THE TIME +.sp +the command +.sp +.ti 8 +JW ^ZWHAT^Z^1 +.sp +results in +.sp +.ti 8 +NOW WHAT +.fi +.sp +You should recall that ^1 (CTRL-L) represents the pair + in search and substitute strings. +.pp +The number of characters ED allows in the F, S, N, and J +commands is limited to 100 symbols. +.sp 2 +.tc 2.1.8 Source Libraries +.sh +2.1.8 Source Libraries +.qs +.pp +ED also allows the inclusion of source libraries during the +editing process with the R command. The form of this command is +.sp +.nf +.ti 8 +R filename ^Z +or +.ti 8 +R filename +.fi +.sp +where filename is the primary filename of a source file on the +disk with an assumed filetype of LIB. ED reads the specified +file, and places the characters into the memory buffer after CP, +in a manner similar to the I command. Thus, if the command +.sp +.ti 8 +RMACRO +.sp +is issued by the operator, ED reads from the file MACRO.LIB until +the end-of-file and automatically inserts the characters into the +memory buffer. +.pp +ED also includes a block move facility implemented through the +X (Transfer) command. The form +.sp +.ti 8 +nX +.sp +transfers the next n lines from the current line to a temporary +file called +.sp +.ti 8 +X$$$$$$.LIB +.sp +which is active only during the editing process. You can +reposition the current line reference to any portion of +the source file and transfer lines to the temporary file. The +transferred lines accumulate one after another in this file and +can be retrieved by simply typing +.sp +.ti 8 +R +.sp +which is the trivial case of the library read command. In this +case, the entire transferred set of lines is read into the memory +buffer. Note that the X command does not remove +the transferred lines from the memory buffer, although a K +command can be used directly after the X, and the R command does +not empty the transferred LIB file. That is, given that a set of +lines has been transferred with the X command, they can be +reread any number of times back into the source file. The +command +.sp +.ti 8 +0X +.sp +is provided to empty the transferred line file. +.pp +Note that upon normal completion of the ED +program through Q or E, the temporary LIB file is removed. If ED +is aborted with a CTRL-C, the LIB file will exist if lines have +been transferred, but will generally be empty (a subsequent ED +invocation will erase the temporary file). +.sp 2 +.tc 2.1.9 Repetitive Command Execution +.sh +2.1.9 Repetitive Command Execution +.qs +.pp +The macro command M allows you to group ED commands +together for repeated evaluation. The M command takes the following form: +.sp +.nf +.ti 8 +n M CS +or +.ti 8 +n M CS ^Z +.sp +.fi +where CS represents a string of ED commands, not including +another M command. ED executes the command string n times if +n>1. If n=0 or 1, the command string is executed repetitively +until an error condition is encountered (for example, the end of the +memory buffer is reached with an F command). +.pp +As an example, the following macro changes all occurrences of +GAMMA to DELTA within the current buffer, and types each line +that is changed: +.sp +.ti 8 +MFGAMMA^Z-5DIDELTA^Z0TT +.sp +or equivalently +.sp +.ti 8 +MSGAMMA^ZDELTA^Z0TT +.sp 2 +.tc 2.2 ED Error Conditions +.he CP/M Operating System Manual 2.2 ED Error Conditions +.sh +2.2 ED Error Conditions +.qs +.pp +On error conditions, ED prints the message BREAK X AT C where X +is one of the error indicators shown in Table 2-4. +.bp +.ce +.sh +Table 2-4. Error Message Symbols +.sp + Symbol Meaning +.sp +.ll 62 +.in 15 +.ti -10 +? Unrecognized command. +.sp +.ti -10 +> Memory buffer full (use one of the commands D, K, N, S, +or W to remove characters); F, N, or S strings too long. +.sp +.ti -10 +# Cannot apply command the number of times specified +(for example, in F command). +.sp +.ti -10 +O Cannot open LIB file in R command. +.in 0 +.ll 65 +.sp 2 +If there is a disk error, CP/M displays the following message: +.sp +.ti 8 +BDOS ERR on d: BAD SECTOR +.sp +You can choose to ignore the error by pressing RETURN +at the console (in this case, the memory buffer data +should be examined to see if they were incorrectly read), or you +can reset the system with a CTRL-C and reclaim the back-up file +if it exists. The file can be reclaimed by first typing the +contents of the BAK file to ensure that it contains the proper +information. For example, type the following: +.sp +.ti 8 +TYPE x.BAK +.sp +where x is the file being edited. Then remove the primary file +.sp +.ti 8 +ERA x.y +.sp +and rename the BAK file +.sp +.ti 8 +REN x.y=x.BAK +.sp +The file can then be reedited, starting with the previous +version. +.pp +ED also takes file attributes into account. If you +attempt to edit a Read-Only file, the message +.sp +.ti 8 +** FILE IS READ/ONLY ** +.sp +appears at the console. The file can be loaded and examined, but +cannot be altered. You must end the edit +session and use STAT to change the file attribute to R/W. If +the edited file has the system attribute set, the following message: +.sp +.ti 8 +'SYSTEM' FILE NOT ACCESSIBLE +.sp +is displayed and the edit session is aborted. Again, the STAT +program can be used to change the system attribute, if desired. +.sp 2 +.tc 2.3 Control Characters and Commands +.he CP/M Operating System Manual 2.3 Control Characters and Commands +.sh +2.3 Control Characters and Commands +.qs +.pp +Table 2-5 summarizes the control characters and +commands available in ED. +.sp 2 +.ce +.sh +Table 2-5. ED Control Characters +.sp +.ll 60 +.nf + Control Function + Character +.sp +.fi +.in 20 +.ti -16 +CTRL-C System reboot +.sp +.ti -16 +CTRL-E Physical (not actually entered +in command) +.sp +.ti -16 +CTRL-H Backspace +.sp +.ti -16 +CTRL-J Logical tab (cols 1, 9, 16, ...) +.sp +.ti -16 +CTRL-L Logical in search and +substitute strings +.sp +.ti -16 +CTRL-R Repeat line +.sp +.ti -16 +CTRL-U Line delete +.sp +.ti -16 +CTRL-X Line delete +.sp +.ti -16 +CTRL-Z String terminator +.sp +.ti -16 +rub/del Character delete +.sp +.in 0 +.ll 65 +.pp +Table 2-6 summarizes the commands used in ED. +.sp 2 +.ce +.sh +Table 2-6. ED Commands +.sp +.nf + Command Function +.ll 60 +.fi +.sp +.in 20 +.ti -16 + nA Append lines +.sp +.ti -16 + +\b_B Begin or bottom of buffer +.sp +.ti -16 + +\b_nC Move character positions +.sp +.ti -16 + +\b_nD Delete characters +.sp +.ti -16 + E End edit and close files (normal end) +.sp +.ti -16 + nF Find string +.bp +.in 0 +.ll 65 +.ce +.sh +Table 2-6. (continued) +.sp + Command Function +.ll 60 +.in 20 +.sp +.ti -16 + H End edit, close and reopen files +.sp +.ti -16 + I Insert characters, use i if both upper +and lower-case characters are to be entered. +.sp +.ti -16 + nJ Place strings in juxtaposition +.sp +.ti -16 + +\b_nK Kill lines +.sp +.ti -16 + +\b_nL Move down/up lines +.sp +.ti -16 + nM Macro definition +.sp +.ti -16 + nN Find next occurrence with autoscan +.sp +.ti -16 + O Return to original file +.sp +.ti -16 + +\b_nP Move and print pages +.sp +.ti -16 + Q Quit with no file changes +.sp +.ti -16 + R Read library file +.sp +.ti -16 + nS Substitute strings +.sp +.ti -16 + +\b_nT Type lines +.sp +.ti -16 + +\b_U Translate lower- to upper-case if U, +no translation if -U +.sp +.ti -16 + +\b_V Verify line numbers, or show +remaining free character space +.sp +.ti -16 + 0V A special case of the V command, OV, +prints the memory buffer statistics in the form +.sp +free/total +.sp +where free is the number of free bytes in the memory buffer (in +decimal) and total is the size of the memory buffer +.sp +.ti -16 + nW Write lines +.sp +.ti -16 + nZ Wait (sleep) for approximately n +seconds +.sp +.ti -16 + +\b_n Move and type (+\b_nLT). +.in 0 +.ll 65 +.sp +.pp +Because of common typographical errors, ED requires several +potentially disastrous commands to be typed as single letters, +rather than in composite commands. The following commands: +.sp +.nf +.in 3 +o E(end) +o H(head) +o O(original) +o Q(quit) +.fi +.in 0 +.sp +must be typed as single letter commands. +.pp +The commands I, J, M, N, R, and S should be typed as i, j, m, n, +r, and s if both upper- and lower-case characters are used in the +operation, otherwise all characters are converted to upper-case. +When a command is entered in upper-case, ED automatically +converts the associated string to upper-case, and vice versa. +.sp 2 +.ce +End of Section 2 +.nx threea + + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/Build.cmd b/Source/Doc/CPM 22 Manual/Build.cmd new file mode 100644 index 00000000..76b09046 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/Build.cmd @@ -0,0 +1,27 @@ +@echo off +setlocal + +set TOOLS=..\..\..\Tools + +set PATH=%TOOLS%\zx;%PATH% + +set ZXBINDIR=%TOOLS%/cpm/bin/ +set ZXLIBDIR=%TOOLS%/cpm/lib/ +set ZXINCDIR=%TOOLS%/cpm/include/ + +rem set TEXOPT=-$D + +zx TEX21A PART1 %TEXOPT% +zx TEX21A PART2 %TEXOPT% +zx TEX21A PART3 %TEXOPT% + +echo Remove extraneous control codes and escape sequences +rem pause + +PowerShell .\Strip.ps1 + +call texify -p --clean "Main.ltx" + +if errorlevel 1 goto :eof + +move /Y Main.pdf "..\..\..\Doc\CPM 22 Manual.pdf" \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/Clean.cmd b/Source/Doc/CPM 22 Manual/Clean.cmd new file mode 100644 index 00000000..333e8f7a --- /dev/null +++ b/Source/Doc/CPM 22 Manual/Clean.cmd @@ -0,0 +1,7 @@ +@echo off +if exist *.pdf del *.pdf +if exist *.prn del *.prn +if exist *.ix del *.ix +if exist *.log del *.log +if exist part?.txt del part?.txt +if exist *.synctex.gz del *.synctex.gz diff --git a/Source/Doc/CPM 22 Manual/Main.ltx b/Source/Doc/CPM 22 Manual/Main.ltx new file mode 100644 index 00000000..09593aeb --- /dev/null +++ b/Source/Doc/CPM 22 Manual/Main.ltx @@ -0,0 +1,40 @@ +\documentclass[letterpaper,10pt,oneside]{book} +\usepackage[T1]{fontenc} +%\usepackage[defaultmono]{droidmono} +\usepackage[scaled]{beramono} +\usepackage{fancyvrb} +\usepackage{geometry} +\usepackage{pdflscape} +%\usepackage{showframe} % Diagnostic + +% Suppress headers and footers completely +\pagestyle{empty} + +% portrait @ 66 lines per page +\geometry{top=0.0in, bottom=0.0in, left=1.0in, right=1.0in} + +%\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}% +%{ +% commandchars=\\\{\} +%} + +\begin{document} + +% Part 1 (main document sections) +\VerbatimInput{part1.txt} + +% landscape @ 51 lines per page +\newgeometry{top=1.0in, bottom=1.0in, left=0.0in, right=0.0in} +\begin{landscape} + +% Part 2 (appendices A-G, source listings) +\VerbatimInput{part2.txt} + +% restore portrait @ 66 lines per page +\end{landscape} +\restoregeometry + +% Part 3 (appendices H-I, index) +\VerbatimInput{part3.txt} + +\end{document} \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/Main.ltx.bak b/Source/Doc/CPM 22 Manual/Main.ltx.bak new file mode 100644 index 00000000..9cd1d4e7 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/Main.ltx.bak @@ -0,0 +1,35 @@ +\documentclass[letterpaper,10pt,oneside]{book} +\usepackage[defaultmono]{droidmono} +\usepackage{verbatim} +\usepackage{geometry} +\usepackage{pdflscape} +%\usepackage{showframe} % Diagnostic + +% Suppress headers and footers completely +\pagestyle{empty} + +% 66 lines per page, portrait +%\geometry{top=0.0in, bottom=0.0in, left=1.0in, right=0.5in} +\geometry{top=0.0in, bottom=0.0in, left=0.5in, right=0.5in} + +\begin{document} + +% Part 1 (main document sections) +\hspace{1pt} \verbatiminput{part1.txt} + +% 51 lines per page, landscape +%\newgeometry{top=1.0in, bottom=0.5in, left=0.0in, right=0.0in} +\newgeometry{top=0.5in, bottom=0.5in, left=0.0in, right=0.0in} +\begin{landscape} + +% Part 2 (appendices A-G, source listings) +\hspace{1pt} \verbatiminput{part2.txt} + +% back to standard geometry +\end{landscape} +\restoregeometry + +% Part 3 (appendices H-I, index) +\hspace{1pt} \verbatiminput{part3.txt} + +\end{document} \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/Strip.ps1 b/Source/Doc/CPM 22 Manual/Strip.ps1 new file mode 100644 index 00000000..d10584bb --- /dev/null +++ b/Source/Doc/CPM 22 Manual/Strip.ps1 @@ -0,0 +1,14 @@ +function StripFile($Filename) +{ + $Content = Get-Content "${Filename}.prn" +# $Content = $Content -replace "\0", "" +# $Content = $Content -replace "\e.", "" + $Content = $Content -replace "\x1A", "" + Set-Content "${Filename}.txt" $Content[0..($Content.count - 3)] +} + +StripFile("part1") +StripFile("part2") +StripFile("part3") + +return diff --git a/Source/Doc/CPM 22 Manual/appa.tex b/Source/Doc/CPM 22 Manual/appa.tex new file mode 100644 index 00000000..e6542646 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/appa.tex @@ -0,0 +1,716 @@ +.pl 51 +.nf +.bp 1 +.ft A-% + Appendix A + + The Microcomputer Development System Basic Input/Output System (BIOS) + + + + 1 ; mds-800 i/o drivers for cp/m 2.2 + 2 ; (four drive single density version) + 3 ; + 4 ; version 2.2 february, 1980 + 5 ; + 6 0016 = vers equ 22 ;version 2.2 + 7 ; + 8 ; copyright (c) 1980 + 9 ; digital research + 10 ; box 579, pacific grove + 11 ; california, 93950 + 12 ; + 13 ; + 14 ffff = true equ 0fffh ;value of "true" + 15 0000 = false equ not true ;"false" + 16 0000 = test equ false ;true if test bios + 17 ; + 18 if test + 19 bias equ 03400h ;base of ccp in test system + 20 endif + 21 if not test + 22 0000 = bias equ 0000h ;generate relocatable cp/m system + 23 endif + 24 ; + 25 1600 = patch equ 1600h + 26 ; + 27 1600 org patch + 28 0000 = cpmb equ $-patch ;base of cpm console processor + 29 0806 = bdos equ 806h+cpmb ;basic dos (resident portion) + 30 1600 = cpml equ $-cpmb ;length (in bytes) of cpm system + 31 002c = nsects equ cpml/128 ;number of sectors to load + 32 0002 = offset equ 2 ;number of disk tracks used by cp/m + 33 0004 = cdisk equ 0004h ;address of last logged disk on warm start + 34 0080 = buff equ 0080h ;default buffer address + 35 000a = retry equ 10 ;max retries on disk i/o before error + 36 ; + 37 ; perform following functions + 38 ; boot cold start + 39 ; wboot warm start (save i/o byte) + 40 ; (boot and wboot are the same for mds) + 41 ; const console status + 42 ; reg-a = 00 if no character ready + 43 ; reg-a = ff if character ready + 44 ; conin console character in (result in reg-a) + 45 ; conout console character out (char in reg-c) + 46 ; list list out (char in reg-c) + 47 ; punch punch out (char in reg-c) + 48 ; reader paper tape reader in (result to reg-a) + 49 ; home move to track 00 + 50 ; + 51 ; (the following calls set-up the io parameter block for the + 52 ; mds, which is used to perform subsequent reads and writes) + 53 ; seldsk select disk given by reg-c (0, 1, 2...) + 54 ; settrk set track address (0,...76) for subsequent read-write + 55 ; setsec set sector address (1,...,26) for subsequent read-write + 56 ; setdma set subsequent dma address (initially 80h) + 57 ; + 58 ; (read and write assume previous calls to set up the io parameters) + 59 ; read read track/sector to preset dma address + 60 ; write track/sector from preset dma address + 61 ; + 62 ; jump vector for individual routines + 63 1600 c3b316 jmp boot + 64 1603 c3c316 wboote: jmp wboot + 65 1606 c36117 jmp const + 66 1609 c36417 jmp conin + 67 160c c36a17 jmp conout + 68 160f c36d17 jmp list + 69 1612 c37217 jmp punch + 70 1615 c37517 jmp reader + 71 1618 c37817 jmp home + 72 161b c37d17 jmp seldsk + 73 161e c3a717 jmp settrk + 74 1621 c3ac17 jmp setsec + 75 1624 c3bb17 jmp setdma + 76 1627 c3c117 jmp read + 77 162a c3ca17 jmp write + 78 162d c37017 jmp listst ;list status + 79 1630 c3b117 jmp sectran + 80 ; + 81 maclib diskdef ;load the disk definition library + 82 disks 4 ;four disks + 83 1633+= dpbase equ $ ;base of disk parameter blocks + 84 1633+82160000 dpe0: dw xlt0, 0000h ;translate table + 85 1637+00000000 dw 0000h, 0000h ;scratch area + 86 163b+6e187316 dw dirbuf, dpb0 ;dir buff, parm block + 87 163f+0d19ee18 dw csv0, alv0 ;check, alloc vectors + 88 1643+82160000 dpe1: dw xlt1, 0000h ;translate table + 89 1647+00000000 dw 0000h, 0000h ;scratch area + 90 164b+6e187316 dw dirbuf, dpb1 ;dir buff, parm block + 91 164f+3c191d19 dw csv1, alv1 ;check, alloc vectors + 92 1653+82160000 dpe2: dw xlt2, 0000h ;translate table + 93 1657+00000000 dw 0000h, 0000h ;scratch area + 94 165b+6e187316 dw dirbuf, dpb2 ;dir buff, parm block + 95 165f+6b194c19 dw csv2, alv2 ;check, alloc vectors + 96 1663+82160000 dpe3: dw xlt3, 0000h ;translate table + 97 1667+00000000 dw 0000h, 0000h ;scratch area + 98 166b+6e187316 dw dirbuf, dpb3 ;check, alloc block + 99 166f+9a197b19 dw csv3, alv3 ;dir buff, parm vectors +100 diskdef 0, 1, 26, 6, 1024, 243, 64, 64, offset +101 1673+= dpb0 equ $ ;disk parm block +102 1673+1a00 dw 26 ;sec per track +103 1675+03 db 3 ;block shift +104 1676+07 db 7 ;block mask +105 1677+00 db 0 ;extnt mask +106 1678+f200 dw 242 ;disk size-1 +107 167a+3f00 dw 63 ;directory max +108 167c+c0 db 192 ;alloc0 +109 167d+00 db 0 ;alloc1 +110 167e+1000 dw 16 ;check size +111 1680+0200 dw 2 ;offset +112 1682+= xlt0 equ $ ;translate table +113 1682+01 db 1 +114 1683+07 db 7 +115 1684+0d db 13 +116 1685+13 db 19 +117 1686+19 db 25 +118 1687+05 db 5 +119 1688+0b db 11 +120 1689+11 db 17 +121 168a+17 db 23 +122 168b+03 db 3 +123 168c+09 db 9 +124 168d+0f db 15 +125 168e+15 db 21 +126 168f+02 db 2 +127 1690+08 db 8 +128 1691+0e db 14 +129 1692+14 db 20 +130 1693+1a db 26 +131 1694+06 db 6 +132 1695+0c db 12 +133 1696+12 db 18 +134 1697+18 db 24 +135 1698+04 db 4 +136 1699+0a db 10 +137 169a+10 db 16 +138 169b+16 db 22 +139 diskdef 1,0 +140 1673+ = dpb1 equ dpb0 ;equivalent parameters +141 001f+ = als1 equ als0 ;same allocation vector size +142 0010+ = css1 equ css0 ;same checksum vector size +143 1682+ = xlt1 equ xlt0 ;same translate table +144 diskdef 2, 0 +145 1673+ = dpb2 equ dpb0 ;equivalent parameters +146 001f+ = als2 equ als0 ;same allocation vector size +147 0010+ = css2 equ css0 ;same checksum vector size +148 1682+ = xlt2 equ xlt0 ;same translate table +149 diskdef 3, 0 +150 1673+ = dpb3 equ dpb0 ;equivalent parameters +151 001f+ = als3 equ als0 ;same allocation vector size +152 0010+ = css3 equ css0 ;same checksum vector size +153 1682+ = xlt3 equ xlt0 ;same translate table +154 ; endef occurs at end of assembly +155 ; +156 ; end of controller--independent code, the remaining subroutines +157 ; are tailored to the particular operating environment, and must +158 ; be altered for any system which differs from the intel mds. +159 ; +160 ; the following code assumes the mds monitor exists at 0f800h +161 ; and uses the i/o subroutines within the monitor +162 ; +163 ; we also assume the mds system has four disk drives +164 00fd = revrt equ 0fdh ;interrupt revert port +165 00fc = intc equ 0fch ;interrupt mask port +166 00f3 = icon equ 0f3h ;interrupt control port +167 007E = inte equ 0111$1110b ;enable rst 0 (warm boot), rst 7 (monitor) +168 ; +169 ; mds monitor equates +170 f800 = mon80 equ 0f800h ;mds monitor +171 ff0f = rmon80 equ 0ff0fh ;restart mon80 (boot error) +172 f803 = ci equ 0f803h ;console character to reg-a +173 f806 = ri equ 0f806h ;reader in to reg-a +174 f809 = co equ 0f809h ;console char from c to console out +175 f80c = po equ 0f80ch ;punch char from c to punch device +176 f80f = lo equ 0f80fh ;list from c to list device +177 f812 = csts equ 0f812h ;console status 00/ff to register a +178 ; +179 ; disk ports and commands +180 0078 = base equ 78h ;base of disk command io ports +181 0078 = dstat equ base ;disk status (input) +182 0079 = rtype equ base+1 ;result type (input) +183 007b = rbyte equ base+3 ;result byte (input) +184 ; +185 0079 = ilow equ base+1 ;iopb low address (output) +186 007a = ihigh equ base+2 ;iopb high address (output) +187 ; +188 0004 = readf equ 4h ;read function +189 0006 = writf equ 6h ;write function +190 0003 = recal equ 3h ;recalibrate drive +191 0004 = iordy equ 4h ;i/o finished mask +192 000d = cr equ 0dh ;carriage return +193 000a = lf equ 0ah ;line-feed +194 ; +195 signon: ;signon message: xxk cp/m vers y.y +196 169c 0d0a0a db cr, lf, lf +197 if test +198 db '32' ;32k example bios +199 endif +200 if not test +201 169f 3030 db '00' ;memory size filled by relocator +202 endif +203 16a1 6b2043502f db 'k cp/m vers ' +204 16ad 322e32 db ver/10+'0', ',' vers mod 10+'0' +205 16b0 0d0a00 db cr, lf, 0 +206 ; +207 boot: ;print signon message and go to ccp +208 ; (note: mds boot initialized iobyte at 0003h) +209 16b3 310001 lxi sp, buff+80h +210 16b6 219c16 lxi h, signon +211 16b9 cdd317 call prmsg ;print message +212 16bc af xra a ;clear accumulator +213 16bd 320400 sta cdisk ;set initially to disk a +214 16c0 c30f17 jmp gocpm ;go to cp/m +215 ; +216 ; +217 wboot:; loader on track 0, sector 1, which will be skipped for warm +218 ; read cp/m from disk--assuming there is a 128 byte cold start +219 ; start +220 ; +221 16c3 318000 lxi sp, buff ;using dma--thus 80 thru ff available for stack +222 ; +223 16c6 0e0a mvi c, retry ;max retries +224 16c8 c5 push b +225 wboot0: ;enter here on error retries +226 16c9 010000 lxi b, cpmb ;set dma address to start of disk system +227 16cc cdbb17 call setdma +228 16cf 0e00 mvi c, 0 ;boot from drive 0 +229 16d1 cd7d17 call seldsk +230 16d4 0e00 mvi c, 0 +231 16d6 cda717 call settrk ;start with track 0 +232 16d9 0e02 mvi c, 2 ;start reading sector 2 +233 16db cdac17 call setsec +234 ; +235 ; read sectors, count nsects to zero +236 16de c1 pop b ;10-error count +237 16df 062c mvi b, nsects +238 rdsec: ;read next sector +239 16e1 c5 push b ;save sector count +240 16e2 cdc117 call read +241 16e5 c24917 jnz booterr ;retry if errors occur +242 16e8 2a6c18 lhld iod ;increment dma address +243 16eb 118000 lxi d, 128 ;sector size +244 16ee 19 dad d ;incremented dma address in hl +245 16ef 44 mov b, h +246 16f0 4d mov c, l ;ready for call to set dma +247 16f1 cdbb17 call setdma +248 16f4 3a6b18 lda ios ;sector number just read +249 16f7 fe1a cpi 26 ;read last sector? +250 16f9 da0517 jc rd1 +251 ; must be sector 26, zero and go to next track +252 16fc 3a6a18 lda iot ;get track to register a +253 16ff 3c inr a +254 1700 4f mov c, a ;read for call +255 1701 cda717 call settrk +256 1704 af xra a ;clear sector number +257 1705 3c rd1: inr a ;to next sector +258 1706 4f mov c, a ;ready for call +259 1707 cdac17 call setsec +260 170a c1 pop b ;recall sector count +261 170b 05 dcr b ;done? +262 170c c2e116 jnz rdsec +263 ; +264 ; done with the load, reset default buffer address +265 gocpm: ;(enter here from cold start boot) +266 ; enable rst0 and rst7 +267 170f f3 di +268 1710 3e12 mvi a, 12h ;initialize command +269 1712 d3fd out revrt +270 1714 af xra a +271 1715 d3fc out intc ;cleared +272 1717 3e7e mvi a, inte ;rst0 and rst7 bits on +273 1719 d3fc out intc +274 171b af xra a +275 171c d3f3 out icon ;interrupt control +276 ; +277 ; set default buffer address to 80h +278 171e 018000 lxi b, buff +279 1721 cdbb17 call setdma +280 ; +281 ; reset monitor entry points +282 1724 3ec3 mvi a, jmp +283 1726 320000 sta 0 +284 1729 210316 lxi h, wboote +285 172c 220100 shld 1 ;jump wboot at location 00 +286 172f 320500 sta 5 +287 1732 210608 lxi h, bdos +288 1735 220600 shld 6 ;jmp bdos at location 5 +289 if not test +290 1738 323800 sta 7*8 ;jmp to mon80 (may have changed by ddt) +291 173b 2100f8 lxi h, mon80 +292 173e 223900 shld 7*8+1 +293 endif +294 ; leave iobyte set +295 ; previously selected disk was b, send parameter to cpm +296 1741 3a0400 lda cdisk ;last logged disk number +297 1744 4f mov c, a ;send to ccp to log it in +298 1745 fb ei +299 1746 c30000 jmp cpmb +300 ; +301 ; error condition occurred, print message and retry +302 booterr: +303 1749 c1 pop b ;recall counts +304 174a 0d dcr c +305 174b ca5217 jz booter0 +306 ; try again +307 174e c5 push b +308 174f c3c916 jmp wboot0 +309 ; +310 booter0: +311 ; otherwise too many retries +312 1752 215b17 lxi h, bootmsg +313 1755 cdd317 call prmsg +314 1758 c30fff jmp rmon80 ;mds hardware monitor +315 ; +316 bootmsg: +317 175b 3f626f6f74 db '?boot', 0 +318 ; +319 ; +320 const: console status to reg-a +321 ; (exactly the same as mds call) +322 1761 c312f8 jmp csts +323 ; +324 conin: ;console character to reg-a +325 1764 cd03f8 call ci +326 1767 e67f ani 7fh ;remove parity bit +327 1769 c9 ret +328 ; +329 conout: ;console character from c to console out +330 176a c309f8 jmp co +331 ; +332 list: ;list device out +333 ; (exactly the same as mds call) +334 176d c30ff8 jmp lo +335 ; +336 listst: +337 ;return list status +338 1770 af xra a +339 1771 c9 ret ;always not ready +340 ; +341 punch: ;punch device out +342 ; (exactly the same as mds call) +343 1772 c30cf8 jmp po +344 ; +345 reader: ;reader character in to reg-a +346 ; (exactly the same as mds call) +347 1775 c306f8 jmp ri +348 ; +349 home: ;move to home position +350 ; treat as track 00 seek +351 1778 0e00 mvi c, 0 +352 177a c3a717 jmp settrk +353 ; +354 seldsk: ;select disk given by register c +355 177d 210000 lxi h, 0000h ;return 0000 if error +356 1780 79 mov a, c +357 1781 fe04 cpi ndisks ;too large? +358 1783 d0 rnc ;leave hl = 0000 +359 ; +360 1784 e602 ani 10b ;00 00 for drive 0, 1 and 10 10 for drive 2, 3 +361 1786 326618 sta dbank ;to select drive bank +362 1789 79 mov a, c ;00, 01, 10, 11 +363 178a e601 ani 1b ;mds has 0, 1 at 78, 2, 3 at 88 +364 178c b7 ora a ;result 00? +365 178d ca9217 jz setdrive +366 1790 3e30 mvi a, 00110000b ;selects drive 1 in bank +367 setdrive: +368 1792 47 mov b, a ;save the function +369 1793 216818 lxi h, iof ;io function +370 1796 7e mov a, m +371 1797 e6cf ani 11001111b ;mask out disk number +372 1799 b0 ora b ;mask in new disk number +373 179a 77 mov m, a ;save it in iopb +374 179b 69 mov l, c +375 179c 2600 mvi h, 0 ;hl=disk number +376 179e 29 dad h ;*2 +377 179f 29 dad h ;*4 +378 17a0 29 dad h ;*8 +379 17a1 29 dad h ;*16 +380 17a2 113316 lxi d, dpbase +381 17a5 19 dad d ;hl=disk header table address +382 17a6 c9 ret +383 ; +384 ; +385 settrk: ;set track address given by c +386 17a7 216a18 lxi h, iot +387 17aa 71 mov m, c +388 17ab c9 ret +389 ; +390 setsec: ;set sector number given by c +391 17ac 216b18 lxi h, ios +392 17af 71 mov m, c +393 17b0 c9 ret +394 sectran: +395 ;translate sector bc using table at de +396 17b1 0600 mvi b, 0 ;double-precision sector number in bc +397 17b3 eb xchg ;translate table address to hl +398 17b4 09 dad b ;translate (sector) address +399 17b5 7e mov a, m ;translated sector number to a +400 17b6 326b18 sta ios +401 17b9 6f mov l, a ;return sector number in l +402 17ba c9 ret +403 ; +404 setdma: ;set dma address given by regs b, c +405 17bb 69 mov l, c +406 17bc 60 mov h, b +407 17bd 226c18 shld iod +408 17c0 c9 ret +409 ; +410 read: ;read next disk record (assuming disk/trk/sec/dma set) +411 17c1 0e04 mvi c, readf ;set to read function +412 17c3 cde017 call setfunc +413 17c6 cdf017 call waitio ;perform read function +414 17c9 c9 ret ;may have error set in reg-a +415 ; +416 ; +417 write: ;disk write function +418 17ca 0e06 mvi c, writf +419 17cc cde017 call setfunc ;set to write function +420 17cf cdf017 call waitio +421 17d2 c9 ret ;may have error set +422 ; +423 ; +424 ; utility subroutines +425 prmsg: ;print message at h, l to 0 +426 17d3 7e mov a, m +427 17d4 b7 ora a zero? +428 17d5 c8 rz +429 ; more to print +430 17d6 e5 push h +431 17d7 4f mov c,a +432 17d8 cd6a17 call conout +433 17db e1 pop h +434 17dc 23 inx h +435 17dd c3d317 jmp prmsg +436 ; +437 setfunc: +438 ; set function for next i/o (command in reg-c) +439 17e0 216818 lxi h, iof ;io function address +440 17e3 7e mov a, m ;get it to accumulator for masking +441 17e4 e6f8 ani 11111000b ;remove previous command +442 17e6 b1 ora c ;set to new command +443 17e7 77 mov m, a ;replaced in iopb +444 ; the mds-800 controller requires disk bank bit in sector byte +445 ; mask the bit from the current i/o function +446 17e8 e620 ani 00100000b ;mask the disk select bit +447 17ea 216b18 lxi h, ios ;address the sector select byte +448 17ed b6 ora m ;select proper disk bank +449 17ee 77 mov m, a ;set disk select bit on/off +450 17ef c9 ret +451 ; +452 waitio: +453 17f0 0e0a mvi c, retry ;max retries before perm error +454 rewait: +455 ; start the i/o function and wait for completion +456 17f2 cd3f18 call intype ;in rtype +457 17f5 cd4c18 call inbyte ;clears the controller +458 ; +459 17f8 3a6618 lda dbank ;set bank flags +460 17fb b7 ora a ;zero if drive 0, 1 and nz if 2, 3 +461 17fc 3e67 mvi a, iopb and offh ;low address for iopb +462 17fe 0618 mvi b, iopb shr 8 ;high address for iopb +463 1800 c20b18 jnz iodr1 ;drive bank 1? +464 1803 d379 out ilow ;low address to controller +465 1805 78 mov a, b +466 1806 d37a out ihigh ;high address +467 1808 c31018 jmp waito ;to wait for complete +468 ; +469 iodr1: ;drive bank 1 +470 180b d389 out ilow+10h ;88 for drive bank 10 +471 180d 78 mov a, b +472 180e d38a out ihigh+10h +473 ; +474 1810 cd5918 waito: call instat ;wait for completion +475 1813 e604 ani iordy ;ready? +476 1815 ca1018 jz waito +477 ; +478 ; check io completion ok +479 1818 cd3f18 call intype ;must be io complete (00) unlinked +480 ; 00 unlinked i/o complete, 01 linked i/o complete (not used) +481 ; io disk status changed 11 (not used) +482 181b fe02 cpi 10b ;ready status change? +483 181d ca3218 jz wready +484 ; +485 ; must be 00 in the accumulator +486 1820 b7 ora a +487 1821 c23818 jnz werror ;some other condition, retry +488 ; +489 ; check i/o error bits +490 1824 cd4c18 call inbyte +491 1827 17 ral +492 1828 da3218 jc wready ;unit not ready +493 182b 1f rar +494 182c e6fe ani 11111110b ;any other errors? (deleted data ok) +495 182e c23818 jnz werror +496 ; +497 ; read or write is ok, accumulator contains zero +498 1831 c9 ret +499 ; +500 wready: ;not ready, treat as error for now +501 1832 cd4c18 call inbyte ;clear result byte +502 1835 c33818 jmp trycount +503 ; +504 werror: ;return hardware malfunction (crc, track, seek, etc.) +505 ; the mds controller has returned a bit in each position +506 ; of the accumulator, corresponding to the conditions: +507 ; 0 -deleted data (accepted as ok above) +508 ; 1 -crc error +509 ; 2 -seek error +510 ; 3 -address error (hardware malfunction) +511 ; 4 -data over/under flow (hardware malfunction) +512 ; 5 -write protect (treated as not ready) +513 ; 6 -write error (hardware malfunction) +514 ; j -not ready +515 ; (accumulator bits are numbered 7 6 5 4 3 2 1 0) +516 ; +517 ; it may be useful to filter out the various conditions, +518 ; but we will get a permanent error message if it is not +519 ; recoverable. in any case, the not ready condition is +520 ; treated as a separated condition for later improvement +521 trycount: +522 ; register c contains retry count, decrement 'til zero +523 1838 0d dcr c +524 1839 c2f217 jnz rewait ;for another try +525 ; +526 ; cannot recover from error +527 183c 3e01 mvi a, 1 ;error code +528 183e c9 ret +529 ; +530 ; intype, inbyte, instat read drive bank 00 or 10 +531 183f 3a6618 intype: lda dbank +532 1842 b7 ora a +533 1843 c24918 jnz intyp1 ;skip to bank 10 +534 1846 db79 in rtype +535 1848 c9 ret +536 1849 db89 intyp1: in rtype+10h ;78 for 0, 1 88 for 2, 3 +537 184b c9 ret +538 ; +539 184c 3a6618 inbyte: lda dbank +540 184f b7 ora a +541 1850 c25618 jnz inbyt1 +542 1853 db7b in rbyte +543 1855 c9 ret +544 1856 db8b inbyt1: in rbyte+10h +545 1858 c9 ret +546 ; +547 1859 3a6618 instat: lda dbank +548 185c b7 ora a +549 185d c26318 jnz insta1 +550 1860 db78 in dstat +551 1862 c9 ret +552 1863 db88 insta1: in dstat+10h +553 1865 c9 ret +554 ; +555 ; +556 ; +557 ; data areas (must be in ram) +558 1866 00 dbank: db 0 ;disk bank 00 if drive 0, 1 +559 ; 10 if drive 2, 3 +560 iopb: ;io parameter block +561 1867 80 db 80h ;normal i/o operation +562 1868 04 iof: db readf ;io function, initial read +563 1869 01 ion: db 1 ;number of sectors to read +564 186a 02 iot: db offset ;track number +565 186b 01 ios: db 1 ;sector number +566 186c 8000 iod: dw buff ;io address +567 ; +568 ; +569 ; define ram areas for bdos operation +570 endef +571 186e+= begdat equ $ +572 186e+ dirbuf: ds 128 ;directory access buffer +573 18ee+ alv0: ds 31 +574 190d+ csv0: ds 16 +575 191d+ alv1: ds 31 +576 193c+ csv1: ds 16 +577 194c+ alv2: ds 31 +578 196b+ csv2: ds 16 +579 197b+ alv3: ds 31 +580 199a+ csv3: ds 16 +581 19aa+= enddat equ $ +582 013c+= datsiz equ $-begdat +583 19aa end + + +als1 001f 141# +als2 001f 146# +als3 001f 151# +alv0 18ee 87 573# +alv1 191d 91 575# +alv2 194c 95 577# +alv3 197b 99 579# +base 0078 180# 181 182 183 185 186 +bdos 0806 29# 287 +begdat 186e 571# 582 +bias 0000 19# 22# +boot 16b3 63 207# +booter0 1752 305 310# +booterr 1749 241 302# +bootmsg 175b 312 316# +buff 0080 34# 209 221 278 566 +cdisk 0004 33# 213 296 +ci f803 172# 325 +co f809 174# 330 +conin 1764 66 324# +conout 176a 67 329# 432 +const 1761 65 320# +cpmb 0000 28# 29 30 226 299 +cpml 1600 30# 31 +cr 000d 192# 196 205 +css1 0010 142# +css2 0010 147# +css3 0010 152# +csts f812 177# 322 +csv0 190d 87 574# +csv1 193c 91 576# +csv2 196b 95 578# +csv3 199a 99 580# +datsiz 013c 582# +dbank 1866 361 459 531 539 539 547 558# +dirbuf 186e 86 90 94 98 572# +dpb0 1673 86 101# 140 145 150 +dpb1 1673 90 140# +dpb2 1673 94 145# +dpb3 1673 98 150# +dpbase 1633 83# 380 +dpe0 1633 84# +dpe1 1643 88# +dpe2 1653 92# +dpe3 1663 96# +dstat 0078 181# 550 552 +enddat 19aa 581# +false 0000 15# 16 +gocpm 170f 214 265# +home 1778 71 349# +icon 00fe 166# 275 +ihigh 007a 186# 466 472 +ilow 0079 185# 464 470 +inbyt1 1856 541 544# +inbyte 184c 457 490 501 539# +insta1 1863 549 552# +instat 1859 474 547# +intc 00fc 165# 271 273 +inte 007e 167# 272 +intyp1 1849 533 536# +intype 183f 456 479 531# +iod 186c 242 407 566# +iodr1 180b 463 469# +iof 1868 369 439 562# +ion 1869 563# +iopb 1867 461 462 560# +iordy 0004 191# 475 +ios 186b 248 391 400 447 565# +iot 186a 252 386 564# +lf 000a 193# 196 196 205 +list 176d 68 332# +listst 1770 78 336# +lo f80f 176# 334 +mon80 f800 170# 291 +nsects 002c 31# 237 +offset 0002 32# 100 564 +patch 1600 25# 27 28 +po f80c 175# 343 +prmsg 17d3 211 313 425# 435 +punch 1772 69 341# +rbyte 007b 183# 542 544 +rd1 1705 250 257# +rdsec 16e1 238# 262 +read 17c1 76 240 410# +reader 1775 70 345# +readf 0004 188# 411 562 +recal 0003 190# +retry 000a 35# 223 453 +revrt 00fd 164# 269 +rewait 17f2 454# 524 +ri f806 173# 347 +rmon80 ff0f 171# 314 +rtype 0079 182# 534 536 +sectran 17b1 79 394# +seldsk 177d 72 229 354# +setdma 17bb 75 227 247 279 404# +setdrive 1792 365 367# +setfunc 17e0 412 419 437# +setsec 17ac 74 233 259 390# +settrk 17a7 73 231 255 352 385# +signon 169c 195# 210 +test 0000 16# 18 21 197 200 289 +true ffff 14# 15 +trycount 1838 502 521# +vers 0016 6# 204 204 +waito 1810 467 474# 476 +waitio 17f0 413 420 452# +wboot 16c3 64 217# +wboot0 16c9 225# 308 +wboote 1603 64# 284 +werror 1838 487 495 504# +wready 1832 483 492 500# +write 17ca 77 417# +writf 0006 189# 418 +xlt0 1682 84 112# 143 148 153 +xlt1 1682 88 143# +xlt2 1682 92 148# +xlt3 1682 96 153# +.nx appb + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/appb.tex b/Source/Doc/CPM 22 Manual/appb.tex new file mode 100644 index 00000000..f8105690 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/appb.tex @@ -0,0 +1,371 @@ +.pl 51 +.nf +.bp 1 +.ft B-% + Appendix B + + A Skeletal CBIOS + + + + + 1 ; skeletal cbios for first level of cp/m 2.0 alteration + 2 ; + 3 0014 = msize equ 20 ;cp/m version memory size in kilobytes + 4 ; + 5 ; "bias" is address offset from 3400h for memory systems + 6 ; than 16k (referred to as "b" throughout the text) + 7 ; + 8 0000 = bias equ (msize-20)*1024 + 9 3400 = ccp equ 3400h+bias ;base of ccp + 10 3c06 = bdos equ ccp+806h ;base of bdos + 11 4a00 = bios equ ccp+1600h ;base of bios + 12 0004 = cdisk equ 0004h ;current disk number 0=a,..., 15=p + 13 0003 = iobyte equ 0003h ;intel i/o byte + 14 ; + 15 4a00 org bios ;origin of this program + 16 002c = nsects equ ($-ccp)/128 ;warm start sector count + 17 ; + 18 ; jump vector for individual subroutines + 19 4a00 c39c4a jmp boot ;cold start + 20 4a03 c3a64a wboote: jmp wboot ;warm start + 21 4a06 c3114b jmp const ;console status + 22 4a09 c3244b jmp conin ;console character in + 23 4a0c c3374b jmp conout ;console character out + 24 4a0f c3494b jmp list ;list character out + 25 4a12 c34d4b jmp punch ;punch character out + 26 4a15 c34f4b jmp reader ;reader character out + 27 4a18 c3544b jmp home ;move head to home position + 28 4a1b c35a4b jmp seldsk ;select disk + 29 4a1e c37d4b jmp settrk ;set track number + 30 4a21 c3924b jmp setsec ;set sector number + 31 4a24 c3ad4b jmp setdma ;set dma address + 32 4a27 c3c34b jmp read ;read disk + 33 4a2a c3d64b jmp write ;write disk + 34 4a2d c34b4b jmp listst ;return list status + 35 4a30 c3a74b jmp sectran ;sector translate + 36 ; + 37 ; fixed data tables for four-drive standard + 38 ; ibm-compatible 8" disks + 39 ; disk parameter header for disk 00 + 40 4a33 734a0000 dpbase: dw trans, 0000h + 41 4a37 00000000 dw 0000h, 0000h + 42 4a3b f04c8d4a dw dirbf, dpblk + 43 4a3f ec4d704d dw chk00, all00 + 44 ; disk parameter header for disk 01 + 45 4a43 734a0000 dw trans, 0000h + 46 4a47 00000000 dw 0000h, 0000h + 47 4a4b f04c8d4a dw dirbf, dpblk + 48 4a4f fc4d8f4d dw chk01, all01 + 49 ; disk parameter header for disk 02 + 50 4a53 734a0000 dw trans, 0000h + 51 4a57 00000000 dw 0000h, 0000h + 52 4a5b f04c8d4a dw dirbf, dpblk + 53 4a5f 0c4eae4d dw chk02, all02 + 54 ; disk parameter header for disk 03 + 55 4a63 734a0000 dw trans, 0000h + 56 4a67 00000000 dw 0000h, 0000h + 57 4a6b f04c8d4a dw dirbf, dpblk + 58 4a6f 1c4ecd4d dw chk03, all03 + 59 ; + 60 ; sector translate vector + 61 4a73 01070d13 trans: db 1, 7, 13, 19 ;sectors 1, 2, 3, 4 + 62 4a77 19050b11 db 25, 5, 11, 17 ;sectors 5, 6, 7, 8 + 63 4a7b 1703090f db 23, 3, 9, 15 ;sectors 9, 10, 11, 12 + 64 4a7f 1502080e db 21, 2, 8, 14 ;sectors 13, 14, 15, 16 + 65 4a83 141a060c db 20, 26, 6, 12 ;sectors 17, 18, 19, 20 + 66 4a87 1218040a db 18, 24, 4, 10 ;sectors 21, 22, 23, 24 + 67 4a8b 1016 db 16, 22 ;sectors 25, 26 + 68 ; + 69 dpblk: ;disk parameter block, common to all disks + 70 4a8d 1a00 dw 26 ;sectors per track + 71 4a8f 03 db 3 ;block shift factor + 72 4a90 07 db 7 ;block mask + 73 4a91 00 db 0 ;null mask + 74 4a92 f200 dw 242 ;disk size-1 + 75 4a94 3f00 dw 63 ;directory max + 76 4a96 c0 db 192 ;alloc 0 + 77 4a97 00 db 0 ;alloc 1 + 78 4a98 1000 dw 16 ;check size + 79 4a9a 0200 dw 2 ;track offset + 80 ; + 81 ; end of fixed tables + 82 ; + 83 ; individual subroutines to perform each function + 84 boot: ;simplest case is to just perform parameter initialization + 85 4a9c af xra a ;zero in the accum + 86 4a9d 320300 sta iobyte ;clear the iobyte + 87 4aa0 320400 sta cdisk ;select disk zero + 88 4aa3 c3ef4a jmp gocpm ;initialize and go to cp/m + 89 ; + 90 wboot: ;simplest case is to read the disk until all sectors loaded + 91 4aa6 318000 lxi sp, 80h ;use space below buffer for stack + 92 4aa9 0e00 mvi c, 0 ;select disk 0 + 93 4aab cd5a4b call seldsk + 94 4aae cd544b call home ;go to track 00 + 95 ; + 96 4ab1 062c mvi b, nsects ;b counts # of sectors to load + 97 4ab3 0e00 mvi c, 0 ;c has the current track number + 98 4ab5 1602 mvi d, 2 ;d has the next sector to read + 99 ; note that we begin by reading track 0, sector 2 since sector 1 +100 ; contains the cold start loader, which is skipped in a warm start +101 4ab7 210034 lxi h, ccp ;base of cp/m (initial load point) +102 load1: ;load one more sector +103 4aba c5 push b ;save sector count, current track +104 4abb d5 push d ;save next sector to read +105 4abc e5 push h ;save dma address +106 4abd 4a mov c, d ;get sector address to register c +107 4abe cd924b call setsec ;set sector address from register c +108 4ac1 c1 pop b ;recall dma address to b, c +109 4ac2 c5 push b ;replace on stack for later recall +110 4ac3 cdad4b call setdma ;set dma address from b, c +111 ; +112 ; drive set to 0, track set, sector set, dma address set +113 4ac6 cdc34b call read +114 4ac9 fe00 cpi 00h ;any errors? +115 4acb c2a64a jnz wboot ;retry the entire boot if an error occurs +116 ; +117 ; no error, move to next sector +118 4ace e1 pop h ;recall dma address +119 4acf 118000 lxi d, 128 ;dma=dma+128 +120 4ad2 19 dad d ;new dma address is in h, l +121 4ad3 d1 pop d ;recall sector address +122 4ad4 c1 pop b ;recall number of sectors remaining, and current trk +123 4ad5 05 dcr b ;sectors=sectors-1 +124 4ad6 caef4a jz gocpm ;transfer to cp/m if all have been loaded +125 ; +126 ; more sectors remain to load, check for track change +127 4ad9 14 inr d +128 4ada 7a mov a,d ;sector=27?, if so, change tracks +129 4adb fe1b cpi 27 +130 4add daba4a jc load1 ;carry generated if sector<27 +131 ; +132 ; end of current track, go to next track +133 4ae0 1601 mvi d, 1 ;begin with first sector of next track +134 4ae2 0c inr c ;track=track+1 +135 ; +136 ; save register state, and change tracks +137 4ae3 c5 push b +138 4ae4 d5 push d +139 4ae5 e5 push h +140 4ae6 cd7d4b call settrk ;track address set from register c +141 4ae9 e1 pop h +142 4aea d1 pop d +143 4aeb c1 pop b +144 4aec c3ba4a jmp load1 ;for another sector +145 ; +146 ; end of load operation, set parameters and go to cp/m +147 gocpm: +148 4aef 3ec3 mvi a, 0c3h ;c3 is a jmp instruction +149 4af1 320000 sta 0 ;for jmp to wboot +150 4af4 21034a lxi h, wboote ;wboot entry point +151 4af7 220100 shld 1 ;set address field for jmp at 0 +152 ; +153 4afa 320500 sta 5 ;for jmp to bdos +154 4afd 21063c lxi h, bdos ;bdos entry point +155 4b00 220600 shld 6 ;address field of jump at 5 to bdos +156 ; +157 4b03 018000 lxi b, 80h ;default dma address is 80h +158 4b06 cdad4b call setdma +159 ; +160 4b09 fb ei ;enable the interrupt system +161 4b0a 3a0400 lda cdisk ;get current disk number +162 4b0d 4f mov c, a ;send to the ccp +163 4b0e c30034 jmp ccp ;go to cp/m for further processing +164 ; +165 ; +166 ; simple i/o handlers (must be filled in by user) +167 ; in each case, the entry point is provided, with space reserved +168 ; to insert your own code +169 ; +170 const: ;console status, return 0ffh if character ready, 00h if not +171 4b11 ds 10h ;space for status subroutine +172 4b21 3e00 mvi a, 00h +173 4b23 c9 ret +174 ; +175 conin: ;console character into register a +176 4b24 ds 10h ;space for input routine +177 4b34 e67f ani 7fh ;strip parity bit +178 4b36 c9 ret +179 ; +180 conout: ;console character output from register c +181 4b37 79 mov a, c ;get to accumulator +182 4b38 ds 10h ;space for output routine +183 4b48 c9 ret +184 ; +185 list: ;list character from register c +186 4b49 79 mov a, c ;character to register a +187 4b4a c9 ret ;null subroutine +188 ; +189 listst: ;return list status (0 if not ready, 1 if ready) +190 4b4b af xra a ;0 is always ok to return +191 4b4c c9 ret +192 ; +193 punch: ;punch character from register c +194 4b4d 79 mov a, c ;character to register a +195 4b4e c9 ret ;null subroutine +196 ; +197 ; +198 reader: ;reader character into register a from reader device +199 4b4f 3e1a mvi a, 1ah ;enter end of file for now (replace later) +200 4b51 e67f ani 7fh ;remember to strip parity bit +201 4b53 c9 ret +202 ; +203 ; +204 ; i/o drivers for the disk follow +205 ; for now, we will simply store the parameters away for use +206 ; in the read and write subroutines +207 ; +208 home: ;move to the track 00 position of current drive +209 ; translate this call into a settrk call with parameter 00 +210 4b54 0e00 mvi c, 0 ;select track 0 +211 4b56 cd7d4b call settrk +212 4b59 c9 ret ;we will move to 00 on first read/write +213 ; +214 seldsk: ;select disk given by register c +215 4b51 210000 lxi h, 0000h ;error return code +216 4b5d 79 mov a, c +217 4b5e 32ef4c sta diskno +218 4b61 fe04 cpi 4 ;must be between 0 and 3 +219 4b63 d0 rnc ;no carry if 4, 5,... +220 ; disk number is in the proper range +221 4b64 ds 10 ;space for disk select +222 ; compute proper disk parameter header address +223 4b6e 3aef4c lda diskno +224 4b71 6f mov l, a ;l=disk number 0, 1, 2, 3 +225 4b72 2600 mvi h, 0 ;high order zero +226 4b74 29 dad h ;*2 +227 4b75 29 dad h ;*4 +228 4b76 29 dad h ;*8 +229 4b77 29 dad h ;*16 (size of each header) +230 4b78 11334a lxi d, dpbase +231 4b7b 19 dad 0 ;hl=.dpbase (diskno*16) +232 4b7c c9 ret +233 ; +234 settrk: ;set track given by register c +235 4b7d 79 mov a, c +236 4b7e 32e94c sta track +237 4b81 ds 10h ;space for track select +238 4b91 c9 ret +239 ; +240 setsec: ;set sector given by register c +241 4b92 79 mov a, c +242 4b93 32eb4c sta sector +243 4b96 ds 10h ;space for sector select +244 4ba6 c9 ret +245 ; +246 sectran: +247 ;translate the sector given by bc using the +248 ;translate table given by de +249 4ba7 eb xchg ;hl=.trans +250 4ba8 09 dad b ;hl=.trans (sector) +251 4ba9 6e mov l, m ;l=trans (sector) +252 4baa 2600 mvi h, 0 ;hl=trans (sector) +253 4bac c9 ret ;with value in hl +254 ; +255 setdma: ;set dma address given by registers b and c +256 4bad 69 mov l, c ;low order address +257 4bae 60 mov h, b ;high order address +258 4baf 22ed4c shld dmaad ;save the address +259 4bb2 ds 10h ;space for setting the dma address +260 4bc2 c9 ret +261 ; +262 read: ;perform read operation (usually this is similar to write +263 ; so we will allow space to set up read command, then use +264 ; common code in write) +265 4bc3 ds 10h ;set up read command +266 4bd3 c3e64b jmp waitio ;to perform the actual i/o +267 ; +268 write: ;perform a write operation +269 4bd6 ds 10h ;set up write command +270 ; +271 waitio: ;enter here from read and write to perform the actual i/o +272 ; operation. return a 00h in register a if the operation completes +273 ; properly, and 01h if an error occurs during the read or write +274 ; +275 ; in this case, we have saved the disk number in 'diskno' (0, 1) +276 ; the track number in 'track' (0-76) +277 ; the sector number in 'sector' (1-26) +278 ; the dma address in 'dmaad' (0-65535) +279 4be6 ds 256 ;space reserved for i/o drivers +280 4ce6 3e01 mvi a, 1 ;error condition +281 4ce8 c9 ret ;replaced when filled-in +282 ; +283 ; the remainder of the cbios is reserved uninitialized +284 ; data area, and does not need to be a part of the +285 ; system memory image (the space must be available, +286 ; however, between "begdat" and "enddat"). +287 ; +288 4ce9 track: ds 2 ;two bytes for expansion +289 4ceb sector: ds 2 ;two bytes for expansion +290 4ced dmaad: ds 2 ;direct memory address +291 4cef diskno: ds 1 ;disk number 0-15 +292 ; +293 ; scratch ram area for bdos use +294 4cf0= begdat equ $ ;beginning of data area +295 4cf0 dirfb: ds 128 ;scratch directory area +296 4d70 all00: ds 31 ;allocation vector 0 +297 4d8f all01: ds 31 ;allocation vector 1 +298 4dae all02: ds 31 ;allocation vector 2 +299 4dcd all03: ds 31 ;allocation vector 3 +300 4dec chk00: ds 16 ;check vector 0 +301 4dfc chk01: ds 16 ;check vector 1 +302 4e0c chk02: ds 16 ;check vector 2 +303 4e1c chk03: ds 16 ;check vector 3 +304 ; +305 4e2c enddat equ $ ;end of data area +306 013c= datsiz equ $-begdat; ;size of data area +307 4e2c end + +all00 4d70 43 296# +all01 4d8f 48 297# +all02 4dae 53 298# +all03 4dcd 58 299# +bdos 3c06 10# 154 +begdat 4cf0 294# 306 +bias 0000 8# 9 +bios 4a00 11# 15 +boot 4a9c 19 84# +ccp 3400 9# 10 11 16 101 163 +cdisk 0004 12# 87 161 +chk00 4dec 43 300# +chk01 4dfc 48 301# +chk02 4e0c 53 302# +chk03 4e1c 58 303# +conin 4b24 22 175# +conout 4b37 23 180# +const 4b11 21 170# +datsiz 013c 306# +dirbf 4cf0 42 47 52 57 295# +diskno 4cef 217 223 291# +dmaad 4ced 258 290# +dpbase 4a33 40# 230 +dpblk 4a8d 42 47 52 57 69# +enddat 4e2c 305# +gocpm 4aef 88 124 147# +home 4b54 27 94 208# +iobyte 0003 13# 86 +list 4b49 24 185# +listst 4b4b 34 189# +load1 4aba 102# 130 144 +msize 0014 3# 8 +nsects 002c 16# 96 +punch 4b4d 25 193# +read 4bc3 32 113 262# +reader 4b4f 26 198# +sector 4ceb 242 289# +sectran 4ba7 35 246# +seldsk 4b5a 28 93 214# +setdma 4bad 31 110 158 255# +setsec 4b92 30 107 240# +settrk 4b7d 29 140 211 234# +track 4ce9 236 288# +trans 4a73 40 45 50 55 61# +waitio 4be6 266 271# +wboot 4aa6 20 90# 115 +wboote 4a03 20# 150 +write 4bd6 33 268# + + +.nx appc + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/appc.tex b/Source/Doc/CPM 22 Manual/appc.tex new file mode 100644 index 00000000..b45311ad --- /dev/null +++ b/Source/Doc/CPM 22 Manual/appc.tex @@ -0,0 +1,143 @@ +.pl 51 +.nf +.bp 1 +.ft C-% + Appendix C + + A Skeletal GETSYS/PUTSYS Program + + + + ; combined getsys and putsys programs from + ; Sec 6.4 + ; Start the programs at the base of the TPA + +0100 org 0100h + +0014 = msize equ 20 ;size of cp/m in Kbytes + + ;"bias" is the amount to add to addresses for > 20k + ; (referred to as "b" throughout the text) + +0000 = bias equ (msize-20)*1024 +3400 = ccp equ 3400h+bias +3c00 = bdos equ ccp+0800h +4a00 = bios equ ccp+1600h + + ; getsys programs tracks 0 and 1 to memory at + ; 3880h + bias + + ; register usage + ; a (scratch register) + ; b track count (0...76) + ; c sector count (1...26) + ; d,e (scratch register pair) + ; h,l load address + ; sp set to track address + + gstart: ;start of getsys +0100 318033 lxi sp,ccp-0080h ;convenient place +0103 218033 lxi h,ccp-0080h ;set initial load +0106 0600 mvi b 0 ;start with track + rd$trk: ;read next track +0108 0e01 mvi c,1 ;each track start + rd$sec: +010a cd0003 call read$sec ;get the next sector +010d 118000 lxi d,128 ;offset by one sector +0110 19 dad d ; (hl=hl+128) +0111 0c inr c ;next sector +0112 79 mov a,c ;fetch sector number +0113 felb cpi 27 ;and see if last +0115 da0a01 jc rdsec ;<, do one more + + ;arrive here at end of track, move to next track + +0118 04 inr b ;track = track+1 +0119 78 mov a,b ;check for last +011a fe02 cpi 2 ;track = 2 ? +011c da0801 jc rd$trk ;<, do another + + ;arrive here at end of load, halt for lack of anything + ;better + +011f fb ei +0120 76 hlt + ; putsys program, places memory image + ; starting at + ; 3880h + bias back to tracks 0 and 1 + ; start this program at the next page boundary +0200 org ($+0100h) and 0ff00h + + put$sys: +0200 318033 lxi sp,ccp-0080h ;convenient place +0203 218033 lxi h,ccp-0080h ;start of dump +0206 0600 mvi b,0 ;start with track + wr$trk: +0208 0e01 mvi b,1 ;start with sector + wr$sec: +020a cd0004 call write$sec ;write one sector +020d 118000 lxi d,128 ;length of each +0210 19 dad d ;= + 128 +0211 0c inr c ; = + 1 +0212 79 mov a,c ;see if +0213 felb cpi 27 ;past end of track +0215 da0a02 jc wr$sec ;no, do another + + ;arrive here at end of track, move to next track + +0218 04 inr b ;track = track+1 +0219 78 mov a,b ;see if +021a fe02 cpi 2 ;last track +021c da0802 jc wr$trk ;no, do another + + ; done with putsys, halt for lack of anything + ; better + +02lf fb ei +0220 76 hit + + ;user supplied subroutines for sector read and write + + ; move to next page boundary + +0300 org ($+0100h) and 0ff00h + + read$sec: + ;read the next sector + ;track in , + ;sector in + ;dmaaddr in + +0300 c5 push b +0301 e5 push h + + ;user defined read operation goes here +0302 ds 64 + +0342 el pop h +0343 cl pop b +0344 c9 ret + +0400 org ($+0100h) and 0ff00h ;another page + ;boundary + + write$sec: + + ;same parameters as read$sec + +0400 c5 push b +0401 e5 push h + + ;user defined write operation goes here +0402 ds 64 + +0442 el pop h +0443 cl pop b +0444 c9 ret + + ;end of getsys/putsys program + +0445 end + +.nx appd + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/appd.tex b/Source/Doc/CPM 22 Manual/appd.tex new file mode 100644 index 00000000..30424b39 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/appd.tex @@ -0,0 +1,175 @@ +.pl 51 +.nf +.bp 1 +.ft D-% + Appendix D + + The Microcomputer Development System-800 Cold Start Loader for CP/M 2 + + + + 1 title mds cold start loader at 3000h' + 2 ; + 3 ; mds-800 cold start loader for cp/m 2.0 + 4 ; + 5 ; version 2.0 august, 1979 + 6 ; + 7 0000 = false equ 0 + 8 ffff true equ not false + 9 0000 = testing equ false if true, then go to mon80 on errors + 10 ; + 11 if testing + 12 bias equ 03400h + 13 endif + 14 if not testing + 15 0000 = bias equ 0000h + 16 endif + 17 0000 = cpmb equ bias ;base of dos load + 18 0806 = bdos equ 806h+bias ;entry to dos for calls + 19 1880 = bdose equ 1880h+bias ;end of dos load + 20 1600 = boot equ 1600h+bias ;cold start entry point + 21 1603 = rboot equ boot+3 ;warm start entry point + 22 ; + 23 3000 org 03000h ;loaded down from hardware boot at 3000H + 24 ; + 25 1880 = bdosl equ bdose-cpmb + 26 0002 = ntrks equ 2 ;number of tracks to read + 27 0031 = bdoss equ bdosl/128 ;number of sectors in dos + 28 0019 = bdoso equ 25 ;number of bdos sectors on track 0 + 29 0018 = bdos1 equ bdoss-bdoso ;number of sectors on track 1 + 30 ; + 31 f800 = mon80 equ 0f800h ;intel monitor base + 32 ff0f = rmon80 equ 0ff0fh ;restart location for mon80 + 33 0078 = base equ 078h ;'base' used by controller + 34 0079 = rtype equ base+1 ;result type + 35 007b = rbyte equ base+3 ;result byte + 36 007f = reset equ base+7 ;reset controller + 37 ; + 38 0078 = dstat equ base ;disk status port + 39 0079 = ilow equ base+1 ;low iopb address + 40 007a = ihigh equ base+2 ;high iopb address + 41 00ff = bsw equ 0ffh ;boot switch + 42 0003 = recal equ 3h ;recalibrate selected drive + 43 0004 = readf equ 4h ;disk read function + 44 0100 = stack equ 100h ;use end of boot for stack + 45 ; + 46 rstart: + 47 3000 310001 lxi sp,stack; ;in case of call to mon80 + 48 ; clear disk status + 49 3003 db79 in rtype + 50 3005 db7b in rbyte + 51 ; check if boot switch if off + 52 coldstart: + 53 3007 dbff in bsw + 54 3009 e602 ani 02h ;switch on? + 55 300b c20730 jnz coldstart + 56 ; clear the controller + 57 300e d37f out reset ;logic cleared + 58 ; + 59 ; + 60 3010 0602 mvi b,ntrks ;number of tracks to read + 61 3012 214230 lxi h,iopbo + 62 ; + 63 start: + 64 ; + 65 ; read first/next track into cpmb + 66 3015 7d mov a,l + 67 3016 d379 out ilow + 68 3018 7c mov a,h + 69 3019 d37a out ihigh + 70 301b db78 waito: in dstat + 71 301d e604 ani 4 + 72 301f ca1b30 jz waito + 73 ; + 74 ; check disk status + 75 3022 db79 in rtype + 76 3024 e603 ani 11b + 77 3026 fe02 cpi 2 + 78 ; + 79 if testing + 80 cnc rmon80 ;go to monitor if 11 or 10 + 81 endif + 82 if not testing + 83 3028 d20030 jnc rstart ;retry the load + 84 endif + 85 ; + 86 302b db7b in rbyte ;i/o complete, check status + 87 ; if not ready, then go to mon80 + 88 302d 17 ral + 89 302e dc0fff cc rmon80 ;not ready bit set + 90 3031 1f rar ;restore + 91 3032 e61e ani 11110b ;overrun/addr err/seek/crc/xxxx + 92 ; + 93 if testing + 94 cnz rmon80 ;go to monitor + 95 endif + 96 if not testing + 97 3034 c20030 jnz rstart ;retry the load + 98 endif + 99 ; +100 ; +101 3037 110700 lxi d,iopbl ;length of iopb +102 303a 19 dad d ;addressing next iopb +103 303b 05 dcr b ;count down tracks +104 303c c21530 jnz start +105 ; +106 ; +107 ; jmp to boot to print initial message, and set up jmps +108 303f c30016 jmp boot +109 ; +110 ; parameter blocks +111 3042 80 iopbo: db 80h ;iocw, no update +112 3043 04 db readf ;read function +113 3044 19 db bdoso ;#sectors to read on track 0 +114 3045 00 db 0 ;track 0 +115 3046 02 db 2 ;start with sector 2 on track 0 +116 3047 0000 dw cpmb ;start at base of bdos +117 0007 = iopbl equ $-iopbo +118 ; +119 3049 80 iopb1: db 80h +120 304a 04 db readf +121 304b 18 db bdos1 ;sectors to read on track 1 +122 304c 01 db 1 ;track 1 +123 304d 01 db 1 ;sector 1 +124 304e 800c dw cmpb+bdos0*128;base of second read +125 ; +126 3050 end + + +base 0078 33# 34 35 36 38 39 40 +bdos 0806 18# +bdoso 0019 28# 29 113 124 +bdos1 0018 29# 121 +bdose 1880 19# 25 +bdosl 1880 25# 27 +bdoss 0031 27# 29 +bias 0000 12# 15# 17 18 19 20 +boot 1600 20# 21 108 +bsw 00ff 41# 53 +coldstart 3007 52# 55 +cpmb 0000 17# 25 116 124 +dstat 0078 38# 70 +false 0000 7# 8 9 +ihigh 007a 40# 69 +ilow 0079 39# 67 +iopbo 3042 61 111# 117 +iopb1 3049 119# +iopbl 0007 101 117# +mon80 f800 31# +ntrks 0002 26# 60 +rboot 1603 21# +rbyte 007b 35# 50 86 +readf 0004 43# 112 120 +recal 0003 42# +reset 007f 36# 57 +rmon80 ff0f 32# 80 89 94 +rstart 3000 46# 83 97 +rtype 0079 34# 49 75 +stack 0100 44# 47 +start 3015 63# 104 +testing 0000 9# 11 14 79 82 93 96 +true ffff 8# +waito 301b 70# 72 + +.nx appe + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/appe.tex b/Source/Doc/CPM 22 Manual/appe.tex new file mode 100644 index 00000000..36a53fbc --- /dev/null +++ b/Source/Doc/CPM 22 Manual/appe.tex @@ -0,0 +1,109 @@ +.pl 51 +.nf +.bp 1 +.ft E-% + Appendix E + + A Skeletal Cold Start Loader + + + + ;this is a sample cold start loader, which, when + ;modified + ;resides on track 00, sector 01 (the first sector on the + ;diskette). we assume that the controller has loaded + ;this sector into memory upon system start-up (this + ;program can be keyed-in, or can exist in read-only + ;memory + ;beyond the address space of the cp/m version you are + ;running). the cold start loader brings the cp/m system + ;into memory at "loadp" (3400h + "bias"). in a 20k + ;memory system, the value of "bias" is 000h, with + ;large + ;values for increased memory sizes (see section 2). + ;after + ;loading the cp/m system, the cold start loader + ;branches + ;to the "boot" entry point of the bios, which beings at + ;"bios" + "bias". the cold start loader is not used un- + ;til the system is powered up again, as long as the bios + ;is not overwritten. the origin is assumed at 0000h, and + ;must be changed if the controller brings the cold start + ;loader into another area, or if a read-only memory + ;area + ;is used. + +0000 org 0 ;base of ram in + ;cp/m + +0014 = msize equ 20 ;min mem size in + ;kbytes +0000 = bias equ (msize-20)*1024 ;offset from 20k + ;system +3400 = ccp equ 3400h+bias ;base of the ccp +4a00 = bios equ ccp+1600h ;base of the bios +0300 = biosl equ 0300h ;length of the bios +4a00 = boot equ bios +1900 = size equ bios+biosl-ccp ;size of cp/m + ;system +0032 = sects equ size/128 ;# of sectors to load + + ; begin the load operation + + cold: +0000 010200 lxi b,2 ;b=0, c=sector 2 +0003 1632 mvi d,sects ;d=# sectors to + ;load +0005 210034 lxi h,ccp ;base transfer + ;address + lsect: ;load the next sector + + ; insert inline code at this point to + ; read one 128 byte sector from the + ; track given in register b, sector + ; given in register c, + ; into the address given by + ;branch to location "cold" if a read error occurs + ; + ; + ; user supplied read operation goes + ; here... + ; + ; + +0008 c36b00 jmp past$patch ;remove this + ;when patched +000b ds 60h + + past$patch: + ;go to next sector if load is incomplete +006b 15 dcr d ;sects=sects-1 +006c ca004a jz boot ;head for the bios + + ; more sectors to load + ; + ;we aren't using a stack, so use as scratch + ;register + ; to hold the load address increment + +006f 318000 lxi sp,128 ;128 bytes per + ;sector +0072 39 dad sp ; = + + 128 +0073 0c inr c ;sector=sector + 1 +0074 79 mov a,c +0075 felb cpi 27 ;last sector of + ;track? +0077 da0800 jc lsect ;no, go read + ;another + + ;end of track, increment to next track + +007a 0e01 mvi c,l ;sector = 1 +007c 04 inr b ;track = track + 1 +007d c30800 jmp lsect ;for another group +0080 end ;of boot loader + + +.nx appf + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/appf.tex b/Source/Doc/CPM 22 Manual/appf.tex new file mode 100644 index 00000000..f34da4f2 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/appf.tex @@ -0,0 +1,263 @@ +.pl 51 +.nf +.bp 1 +.ft F-% + Appendix F + + CP/M Disk Definition Library + + + 1:; CP/M 2.0 disk re-definition library + 2:; + 3:; Copyright (c) 1979 + 4:; Digital Research + 5:; Box 579 + 6:; Pacific Grove, CA + 7:; 93950 + 8:; + 9:; CP/M logical disk drives are defined using the + 10:; macros given below, where the sequence of calls + 11:; is: + 12:; + 13:; disks n + 14:; diskdef parameter-list-0 + 15:; diskdef parameter-list-1 + 16:; ... + 17:; diskdef parameter-list-n + 18:; endef + 19:; + 20:; where n is the number of logical disk drives attached + 21:; to the CP/M system, and parameter-list-i defines the + 22:; characteristics of the ith drive (i=0,1,...,n-1) + 23:; + 24:; each parameter-list-i takes the form + 25:; dn,fsc,lsc,[skf],bls,dks,dir,cks,ofs,[0] + 26:; where + 27:; dn is the disk number 0,1,...,n-1 + 28:; fsc is the first sector number (usually 0 or 1) + 29:; lsc is the last sector number on a track + 30:; skf is optional "skew factor" for sector translate + 31:; bls is the data block size (1024,2048,...,16384) + 32:; dks is the disk size in bls increments (word) + 33:; dir is the number of directory elements (word) + 34:; cks is the number of dir elements to checksum + 35:; ofs is the number of tracks to skip (word) + 36:; [0] is an optional 0 which forces 16K/directory end + 37:; + 38:; for convenience, the form + 39:; dn,dm + 40:; defines disk dn as having the same characteristics as + 41:; a previously defined disk dm. + 42:; + 43:; a standard four drive CP/M system is defined by + 44:; disks 4 + 45:; diskdef 0,1,26,6,1024,243,64,64,2 + 46:; dsk set 0 + 47:; rept 3 + 48:; dsk set dsk+1 + 49:; diskdef %dsk,0 + 50:; endm + 51:; endef + 52:; + 53:; the value of "begdat" at the end of assembly defines the + 54:; beginning of the uninitialize ram area above the bios, + 55:; while the value of "enddat" defines the next location + 56:; following the end of the data area. the size of this + 57:; area is given by the value of "datsiz" at the end of the + 58:; assembly. note that the allocation vector will be quite + 59:; large if a large disk size is defined with a small block + 60:; size. + 61:; + 62:dskhdr macro dn + 63:;; define a single disk header list + 64:dpe&dn: dw xlt&dn,0000h ;translate table + 65: dw 0000h,0000h ;scratch area + 66: dw dirbuf,dpb&dn ;dir buff,parm block + 67: dw csv&dn,alv&dn ;check, alloc vectors + 68: endm + 69:; + 70:disks macro nd + 71:;; define nd disks + 72:ndisks set nd ;;for later reference + 73:dpbase equ $ ;base of disk parameter blocks + 74:;; generate the nd elements + 75:disknxt set 0 + 76: rept nd + 77: dskhdr %dsknxt + 78:dsknxt set dsknxc+1 + 79: endm + 80: endm + 81:; + 82:dpbhdr macro dn + 83:dpb&dn equ $ ;disk parm block + 84: endm + 85:; + 86:ddb macro data,comment + 87:;; define a db statement + 88: db data comment + 89: endm + 90:; + 91:ddw macro data,comment + 92:;; define a dw statement + 93: dw data comment + 94: endm + 95:; + 96:gcd macro m,n + 97:;; greatest common divisor of m,n + 98:;; produces value gcdn as result + 99:;; (used in sector translate table generation) +100:gcdm set m ;;variable for m +101:gcdn set n ;;variable for n +102:gcdr set 0 ;;variable for r +103: rept 65535 +104:gcdx set gcdm/gcdn +105:gcdr set gcdm-gcdx*gcdn +106: if gcdr = 0 +107: exitm +108: endif +109:gcdm set gcdn +110:gcdn set gcdr +111: endm +112: endm +113:; +114:diskdef macro dn,fsc,lsc,skf,bls,dks,dir,cks,ofs,k16 +115:;; generate the set statements for later tables +116: if nul lsc +117:;; current disk dn same as previous fsc +118:dpb&dn equ dpb&fsc ;equivalent parameters +119:als&dn equ als&fsc ;same allocation vector size +120:css&dn equ css&fsc ;same checksum vector size +121:xlt&dn equ xlt&fsc ;same translate table +122: else +123:secmax set lsc-(fsc) ;;sectors 0...secmax +124:sectors set secmax+1 ;;number of sectors +125:als&dn set (dks)/8 ;;size of allocation vector +126: if ((dks)mod8) ne 0 +127:als&dn set als&dn+1 +128: endif +129:css&dn set (cks)/4 ;;number of checksum elements +130:;; generate the block shift value +131:blkval set bls/128 ;;number of sectors/block +132:blkshf set 0 ;;counts right 0's in blkval +133:blkmsk set 0 ;;fills with l's from right +134: rept 16 ;;once for each bit position +135: if blkval=1 +136: exitm +137: endif +138:;; otherwise, high order 1 not found yet +139:blkshf set blkshf+1 +140:blkmsk set (blkmsk shl l) or l +141:blkval set blkval/2 +142: endm +143:;; generate the extent mask byte +144:blkval set bls/1024 ;;number of kilobytes/block +145:extmsk set 0 ;;fill from right with l's +146: rept 16 +147: if blkval=1 +148: exitm +149: endif +150:;; otherwise more to shift +151:extmsk set (extmsk shl l) or l +152:blkval set blkval/2 +153: endm +154:;; may be double byte allocation +155: if (dks)>256 +156:extmsk set (extmsk shr l) +157: endif +158:;; may be optional [0] in last position +159: if not nul k16 +160:extmsk set k16 +161: endif +162:;; now generate directory reservation bit vector +163:dirrem set dir ;;#remaining to process +164:dirbks set bls/32 ;;number of entries per block +165:dirblk set 0 ;;fill with l's on each loop +166: rept 16 +167: if dirrem=0 +168: exitm +169: endif +170:;; not complete, iterate once again +171:;; shift right and add 1 high order bit +172:dirblk set (dirblk shr l) or 8000h +173: if dirrem>dirbks +174:dirrem set dirrem-dirbks +175: else +176:direem set 0 +177: endif +178: endm +179: dpbhdr dn ;;generate equ $ +180: ddw %sectors,<;sec per track> +181: ddb %blkshf,<;block shift> +182: ddb %blkmsk,<;block mask> +183: ddb %extmsk,<;extnt mask> +184: ddw %(dks)-1,<;disk size-1> +185: ddw %(dir)-1, +186: ddb %dirblk shr 8,<;alloc0> +187: ddb %dirblk and 0ffh,<;allocl> +188: ddw %(cks)/4,<;check size> +189: ddw %ofs,<;offset> +190:;; generate the translate table, if requested +191: if nul skf +192:xlt&dn equ 0 ;no xlate table +193: else +194: if skf = 0 +195:xlt&dn equ 0 ;no xlate table +196: else +197:;; generate the translate table +198:nxtsec set 0 ;;next sector to fill +199:nxtbas set 0 ;;moves by one on overflow +200: gcd %sectors,skf +201:;; gcdn = gcd(sectors,skew) +202:neltst set sectors/gcdn +203:;; neltst is number of elements to generate +204:;; before we overlap previous elements +205:nelts set neltst ;;counter +206:xlt&dn equ $ ;;translate table +207: rept sectors ;;once for each sector +208: if sectors<256 +209: ddb %nxtsec+(fsc) +210: else +211: ddw %nxtsec+(fsc) +212: endif +213:nxtsec set nxtsec+(skf) +214: if nxtsec>=sectors +215:nxtsec set nxtsec-sectors +216: endif +217:nelts set nelts-1 +218: if nelts = 0 +219:nxtbas set nxtbas+1 +220:nxtsec set nxtbas +221:nelts set neltst +222: endif +223: endm +224: endif ;;end of nul fac test +225: endif ;;end of nul bls test +226: endm +227:; +228:defds macro lab,space +229:lab: ds space +230: endm +231:; +232:lds macro lb,dn,val +233: defds lb&dn,%val&dn +234: endm +235:; +236:endef macro +237:;; generate the necessary ram data areas +238:begdat equ $ +239:dirbuf: ds 128 ;directory access buffer +240:dsknxt set 0 +241: rept ndisks ;;once for each disk +242: lds alv,%dsknxt,als +243: lds csv,%dsknxt,ccs +244:dsknxt set dsknxt+1 +245: endm +246:enddat equ $ +247:datsiz equ $-begdat +248:;; db 0 at this point forces hex record +249: endm + + +.nx appg + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/appg.tex b/Source/Doc/CPM 22 Manual/appg.tex new file mode 100644 index 00000000..6848b31f --- /dev/null +++ b/Source/Doc/CPM 22 Manual/appg.tex @@ -0,0 +1,475 @@ +.pl 51 +.nf +.bp 1 +.ft G-% + Appendix G + + Blocking and Deblocking Algorithms + + + + 1 ; + 2 ; + 3 ; sector deblocking algorithms for cp/m 2.0 + 4 ; + 5 ; + 6 ; + 7 ; utility macro to compute sector mask + 8 smask macro hblk + 9 ;; compute log2(hblk), return @x as result + 10 ;; (2 ** @x = hblk on return) + 11 @y set hblk + 12 @x set 0 + 13 ;; count right shifts of @y until = 1 + 14 rept 8 + 15 if @y = 1 + 16 exitm + 17 endif + 18 ;; @y is not 1, shift right one position + 19 @y set @y shr 1 + 20 @x set @x + 1 + 21 endm + 22 endm + 23 ; + 24 ; + 25 ; + 26 ; cp/m to host disk constants + 27 ; + 28 ; + 29 0800 = blksiz equ 2048 ;cp/m allocation size + 30 0200 = hstsiz equ 512 ;host disk sector size + 31 0014 = hstspt equ 20 ;host disk sectors/trk + 32 0004 = hstblk equ hstsiz/128 ;cp/m sects/host buff + 33 0050 = cpmspt equ hstblk * hstspt ;cp/m sectors/track + 34 0003 = secmsk equ hstblk-1 ;sector mask + 35 smask hstblk ;compute sector mask + 36 0002 = secshf equ @x ;log2(hstblk) + 37 ; + 38 ; + 39 ; + 40 ; bdos constants on entry to write + 41 ; + 42 ; + 43 0000 = wrall equ 0 ;write to allocated + 44 0001 = wrdir equ 1 ;write to directory + 45 0002 = wrual equ 2 ;write to unallocated + 46 ; + 47 ; + 48 ; + 49 ; the bdos entry points given below show the + 50 ; code which is relevant to deblocking only. + 51 ; + 52 ; + 53 ; + 54 ; diskdef macro, or hand coded tables go here + 55 0000 = dpbase equ $ ;disk param block base + 56 ; + 57 boot: + 58 wboot: + 59 ;enter here on system boot to initialize + 60 0000 af xra a ;0 to accumulator + 61 0001 326a01 sta hstact ;host buffer inactive + 62 0004 326c01 sta unacnt ;clear unalloc count + 63 0007 c9 ret + 64 ; + 65 home: + 66 ;home the selected disk + 67 home: + 68 0008 3a6b01 lda hstwrt ;check for pending write + 69 000b b7 ora a + 70 000c c21200 jnz homed + 71 000f 326a01 sta hstact ;clear host active flag + 72 homed: + 73 0012 c9 ret + 74 ; + 75 seldsk: + 76 ;select disk + 77 0013 79 mov a,c ;selected disk number + 78 0014 326101 sta sekdsk ;seek disk number + 79 0017 6f mov l,a ;disk number to hl + 80 0018 2600 mvi h,0 + 81 rept 4 ;multiply by 16 + 82 dad h + 83 endm + 84 001a+29 dad h + 85 001b+29 dad h + 86 001c+29 dad h + 87 001d+29 dad h + 88 001e 110000 lxi d,dpbase ;base of parm block + 89 0021 19 dad d ;hl=.dpb(curdsk) + 90 0022 c9 ret + 91 ; + 92 settrk: + 93 ;set track given by registers bc + 94 0023 60 mov h,b + 95 0024 69 mov l,c + 96 0025 226201 shld sektrk ;track to seek + 97 0028 c9 ret + 98 ; + 99 setsec: +100 ;set sector given by register c +101 0029 79 mov a,c +102 002a 326401 sta seksec ;sector to seek +103 002d c9 ret +104 ; +105 setdma: +106 ;set dma address given by bc +107 002e 60 mov h,b +108 002f 69 mov l,c +109 0030 227501 shld dmaadr +110 0033 c9 ret +111 ; +112 sectran: +113 ;translate sector number bc +114 0034 60 mov h,b +115 0035 69 mov l,c +116 0036 c9 ret +117 ; +118 ; +119 ; +120 ; the read entry point takes the place of +121 ; the previous bios definition for read. +122 ; +123 ; +124 read: +125 ;read the selected cp/m sector +126 0037 af xra a +127 0038 326c01 sta unacnt +128 003b 3e01 mvi a,1 +129 003d 327301 sta readop ;read operation +130 0040 327201 sta rsflag ;must read data +131 0043 3e02 mvi a,wrual +132 0045 327401 sta wrtype ;treat as unalloc +133 0048 c3b600 jmp rwoper ;to perform the read +134 ; +135 ; +136 ; +137 ; the write entry point takes the place of +138 ; the previous bios definition for write. +139 ; +140 ; +141 write: +142 ;write the selected cp/m sector +143 004b af xra a ;0 to accumulator +144 004c 327301 sta readop ;not a read operation +145 004f 79 mov a,c ;write type in c +146 0050 327401 sta wrtype +147 0053 fe02 cpi wrual ;write unallocated? +148 0050 c26f00 jnz chkuna ;check for unalloc +149 ; +150 ; write to unallocated, set parameters +151 0058 3e10 mvi a,blksiz/128 ;next unalloc recs +152 005a 326c01 sta unacnt +153 005d 3a6101 lda sekdsk ;disk to seek +154 0060 326d01 sta unadsk ;unadsk = sekdsk +155 0063 2a6201 lhld settrk +156 0066 226e01 shld unatrk ;unatrk = sectrk +157 0069 3a6401 lda seksec +158 006c 327001 sta unasec ;unasec = seksec +159 ; +160 chkuna: +161 ;check for write to unallocated sector +162 006f 3a6c01 lda unacnt ;any unalloc remain? +163 0072 b7 ora a +164 0073 caae00 jz alloc ;skip if not +165 ; +166 ; more unallocated records remain +167 0076 3d dcr a ;unacnt = unacnt-1 +168 0077 326c01 sta unacnt +169 007a 3a6101 lda sekdsk ;same disk? +170 007d 216d01 lxi h,unadsk +171 0080 be cmp m ;sekdsk = unadsk? +172 0081 c2ae00 jnz alloc ;skip if not +173 ; +174 ; disks are the same +175 0084 216e01 lxi h,unatrk +176 0087 cd5301 call sektrkcmp ;saektrk = unatrk? +177 008a c2ae00 jnz alloc ;skip if not +178 ; +179 ; tracks are the same +180 008d 3a6401 lda seksec ;same sector? +181 0090 217001 lxi h,unasec +182 0093 be cmp m ;seksec = unasec? +183 0094 c2ae00 jnz alloc ;skip if not +184 ; +185 ; match, move to next sector for future ref +186 0097 34 inr m ;unasec = unasec+1 +187 0098 7e mov a,m ;end of track? +188 0099 fe50 cpi cpmspt ;count cp/m sectors +189 009b daa700 jc noovf ;skip if no overflow +190 ; +191 ; overflow to next track +192 009e 3600 mvi m,o ;unasec = 0 +193 00a0 2a6e01 lhld unatrk +194 00a3 23 inx h +195 00a4 226e01 shld unatrk ;unatrk = unatrk+1 +196 ; +197 noovf: +198 ;match found, mark as unnecessary read +199 00a7 af xra a ;0 to accumulator +200 00ab 327201 sta rsflag ;rsflag = 0 +201 00ab c3b600 jmp rwoper ;to perform the write +202 ; +203 alloc: +204 ;not an unallocated record, requires pre-read +205 00ae af xra a ;0 to accum +206 00af 326c01 sta unacnt ;unacnt = 0 +207 00b2 3c inr a ;1 to accum +208 00b3 327201 sta rsflag = 1 ;rsflag = 1 +209 ; +210 ; +211 ; +212 ; common code for read and write follows +213 ; +214 ; +215 rwoper: +216 ;enter here to perform the read-write +217 00b6 af xra a ;zero to accum +218 00b7 327101 sta erflag ;no errors (yet) +219 00ba 3a6401 lda seksec ;compute host sector +220 rept secshf +221 ora a ;carry = 0 +222 rar ;shift right +223 endm +224 00bd+b7 ora a ;carry = 0 +225 00be+1f rar ;shift right +226 00bf+b7 ora a ;carry = 0 +227 00c0+1f rar ;shift right +228 00c1 326901 sta sekhst ;host sector to seek +229 ; +230 ; active host sector? +231 00c4 216a01 lxi h,hstact ;host active flag +232 00c7 7e mov a,m +233 00c8 3601 mvi m,1 ;always becomes 1 +234 00ca b7 ora a ;was it already? +235 00cb caf200 jz filhst ;fill host if not +236 ; +237 ; host buffer active, same as seek buffer? +238 00ce 3a6101 lda sekdsk +239 00d1 216501 lxi h,hstdsk ;same disk? +240 00d4 be cmp m ;sekdsk = hstdsk? +241 00d5 c2eb00 jnz nomatch +242 ; +243 ; same disk, same track? +244 00d8 216601 lxi h,hsttrk +245 00db cd5301 call sektrkcmp ;sektrk = hsttrk? +246 00de c2eb00 jnz nomatch +247 ; +248 ; same disk, same track, same buffer? +249 00e1 3a6901 lda sekhst +250 00e4 216801 lxi h,hstsec ;sekhst = hstsec? +251 00e7 be cmp m +252 00e8 ca0f01 jz match ;skip if match +253 ; +254 nomatch: +255 ;proper disk, but not correct sector +256 00eb 3a6b01 lda hstwrt ;host written? +257 00ee b7 ora a +258 00ef c45f01 cnz writehst ;clear host buff +259 ; +260 filhst: +261 ;may have to fill the host buffer +262 00f2 3a6101 lda sekdsk +263 00f5 326501 sta hstdsk +264 00f8 2a6201 lhld sektrk +265 00fb 226601 shld hsttrk +266 00fe 3a6901 lda sekhst +267 0101 326801 sta hstsec +268 0104 3a7201 lda rsflag ;need to read? +269 0107 b7 ora a +270 0108 c46001 cnz readhst ;yes, if 1 +271 010b af xra a ;0 to accum +272 010c 326b01 sta hstwrt ;no pending write +273 ; +274 match: +275 ;copy data to or from buffer +276 010f 3a6401 lda seksec ;mask buffer number +277 0112 e603 ani secmsk ;least signif bits +278 0114 6f mov l,a ;ready to shift +279 0115 2600 mvi h,0 ;double count +280 rept 7 ;shift left 7 +281 dad h +282 endm +283 0117+29 dad h +284 0118+29 dad h +285 0119+29 dad h +286 011a+29 dad h +287 011b+29 dad h +288 011c+29 dad h +289 011d+29 dad h +290 ; hl has relative host buffer address +291 011e 117701 lxi d,hstbuf +292 0121 19 dad d ;hl = host address +293 0122 eb xchg ;now in de +294 0123 2a7501 lhld dmaadr ;get/put cp/m data +295 0126 0e80 mvi c,128 ;length of move +296 0128 3a7301 lda readop ;which way? +297 012b b7 ora a +298 012c c23501 jnz rwmove ;skip if read +299 ; +300 ; write operation, mark and switch direction +301 012f 3e01 mvi a,1 +302 0131 326b01 sta hstwrt ;hstwrt = 1 +303 0134 eb xchg ;source/dest swap +304 ; +305 rwmove: +306 ;c initially 128, de is source, hl is dest +307 0135 1a ldax d ;source character +308 0136 13 inx d +309 0137 77 mov m,a ;to dest +310 0138 23 inx h +311 0139 od dcr c ;loop 128 times +312 013a c23501 jnz rwmove +313 ; +314 ; data has been moved to/from host buffer +315 013d 3a7401 lda wrtype ;write type +316 0140 fe01 cpi wrdir ;to directory? +317 0142 3a7101 lda erflag ;in case of errors +318 0145 c0 rnz ;no further processing +319 ; +320 ; clear host buffer for directory write +321 0146 b7 ora a ;errors? +322 0147 c0 rnz ;skip if so +323 0148 af xra a ;0 to accum +324 0149 326b01 sta hstwrt ;buffer written +325 014c cd5f01 call writehst +326 014f 3a7101 lda erflag +327 0152 c9 +328 ; +329 ; +330 ; +331 ; utility subroutine for 16-bit compare +332 ; +333 ; +334 sektrkcmp: +335 ;hl = .unatrk or .hsttrk, compare with sektrk +336 0153 eb xchg +337 0154 216201 lxi h,sektrk +338 0157 1a ldax d ;low byte compare +339 0158 be cmp m ;same? +340 0159 c0 rnz ;return if not +341 ; low bytes equal, test high 1s +342 015a 13 inx d +343 015b 23 inx h +344 015c 1a ldax d +345 015d be cmp m ;sets flags +346 015e c9 ret +347 ; +348 ; +349 ; +350 ; writehst performs the physical write to +351 ; the host disk, readhst reads the physical +352 ; disk. +353 ; +354 ; +355 writehst: +356 ;hstdsk = host disk #, hsttrk = host track #, +357 ;hstsec = host sect #. write "hstsiz" bytes +358 ;from hstbuf and return error flag in erflag. +359 ;return erflag non-zero if error +360 015f c9 ret +361 ; +362 readhst: +363 ;hstdsk = host disk #, hsttrk = host track #, +364 ;hstsec = host sect #. read "hstsiz" bytes +365 ;into hstbuf and return error flag in erflag. +366 0160 c9 ret +367 ; +368 ; +369 ; +370 ; uninitialized ram data areas +371 ; +372 ; +373 ; +374 0161 sekdsk: ds 1 ;seek disk number +375 0162 sektrk: ds 2 ;seek track number +376 0164 seksec: ds 1 ;seek sector number +377 ; +378 0165 hstdsk: ds 1 ;host disk number +379 0166 hsttrk: ds 2 ;host track number +380 0168 hstsec: ds 1 ;host sector number +381 ; +382 0169 sekhst: ds 1 ;seek shr secshf +383 016a hstact: ds 1 ;host active flag +384 016b hstwrt: ds 1 ;host written flag +385 ; +386 016c unacnt: ds 1 ;unalloc rec cnt +387 016d unadsk: ds 1 ;last unalloc disk +388 016e unatrk: ds 2 ;last unalloc track +389 0170 unasec: ds 1 ;last unalloc sector +390 ; +391 0171 erflag: ds 1 ;error reporting +392 0172 rsflag: ds 1 ;read sector flag +393 0173 readop: ds 1 ;1 if read operation +394 0174 wrtype: ds 1 ;write operation type +395 0175 dmaadr: ds 2 ;last dma address +396 0177 hstbuf: ds hstsiz ;host buffer +397 ; +398 ; +399 ; +400 ; the endef macro invocation goes here +401 ; +402 ; +403 0377 end + + + + + + + + + +alloc 00ae 164 172 177 183 203# +blksiz 0800 29# 151 +boot 0000 57# +chkuna 006f 148 160# +cpmspt 0050 33# 188 +dmaadr 0175 109 294 395# +dpbase 0000 55# 88 +erflag 0171 218 317 326 391# +filhst 00f2 235 260# +home 0008 65# 67# +homed 0012 70 72# +hstact 016a 61 71 231 383# +hstblk 0004 32# 33 34 35 +hstbuf 0177 291 396# +hstdsk 0165 239 263 378# +hstsec 0168 250 267 380# +hstsiz 0200 30# 32 396 +hstspt 0014 31# 33 +hsttrk 0166 244 265 379# +hstwrt 016b 68 256 272 302 324 384# +match 010fl 252 274# +nomatch 00eb 241 246 254# +noovf 00a7 189 197# +read 0037 124# +readhst 0160 270 362# +readop 0173 129 144 296 393# +rsflag 0172 130 200 208 268 392# +rwmove 0135 298 305# 312 +rwoper 00b6 133 201 215# +secmsk 0003 34# 277 +secshf 0002 36# 220 +sectran 0034 112# +sekdsk 0161 78 153 169 238 262 374# +sekhst 0169 228 249 266 382# +seksec 0164 102 157 180 219 276 376# +sektrk 0162 96 155 264 337 375# +sektrkcmp 0153 176 245 334# +seldsk 0013 75# +setdma 002e 105# +setsec 0029 99# +settrk 0023 92# +unacnt 016c 62 127 152 162 168 206 386# +unadsk 016d 154 170 387# +unasec 0170 158 181 389# +unatrk 016e 156 175 193 195 388# +wboot 0000 58# +wrall 0000 43# +wrdir 0001 44# 316 +write 004b 141# +writehst 015f 258 325 355# +wrtype 0174 132 146 315 394# +wrual 0002 45# 131 147 + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/apph.tex b/Source/Doc/CPM 22 Manual/apph.tex new file mode 100644 index 00000000..90d673d2 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/apph.tex @@ -0,0 +1,904 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft H-% +.pc 1 +.tc H Glossary +.ce 2 +.sh +Appendix H +.sp +.sh +Glossary +.qs +.he CP/M Operating System Manual H Glossary +.sp 3 +.sh +address: \c +.qs +Number representing the location of a byte in memory. Within +CP/M there are two kinds of addresses: logical and physical. A +physical address refers to an absolute and unique location within +the computer's memory space. A logical address refers to the +offset or displacement of a byte in relation to a base location. +A standard CP/M program is loaded at address 0100H, the base +value; the first instruction of a program has a physical address +of 0100H and a relative address or offset of OH. +.sp +.sh +allocation vector (ALV): \c +.qs +An allocation vector is maintained in the BIOS for each logged-in +disk drive. A vector consists of a string of bits, one for each +block on the drive. The bit corresponding to a particular block +is set to one when the block has been allocated and to zero +otherwise. The first two bytes of this vector are initialized +with the bytes AL0 and AL1 on, thus allocating the directory +blocks. CP/M Function 27 returns the allocation vector address. +.sp +.sh +AL0, AL1: \c +.qs +Two bytes in the disk parameter block that reserve data blocks +for the directory. These two bytes are copied into the first two +bytes of the allocation vector when a drive is logged in. See \c +.sh +allocation vector. +.sp +.sh +ALV: \c +.qs +See \c +.sh +allocation vector. +.sp +.sh +ambiguous filename: \c +.qs +Filename that contains either of the CP/M wildcard characters, ? +or *, in the primary filename, filetype, or both. When you +replace characters in a filename with these wildcard characters, +you create an ambiguous filename and can easily reference more +than one CP/M file in a single command line. +.sp +.sh +American Standard Code for Information Interchange: \c +.qs +See \c +.sh +ASCII. +.sp +.sh +applications program: \c +.qs +Program designed to solve a specific problem. Typical +applications programs are business accounting packages, word +processing (editing) programs and mailing list programs. +.sp +.sh +archive attribute: \c +.qs +File attribute controlled by the high-order bit of the t3 byte +(FCB+11) in a directory element. This attribute is set if the +file has been archived. +.sp +.sh +argument: \c +.qs +Symbol, usually a letter, indicating a place into which you can +substitute a number, letter, or name to give an appropriate +meaning to the formula in question. +.sp +.sh +ASCII: \c +.qs +American Standard Code for Information Interchange. ASCII is a +standard set of seven-bit numeric character codes used to +represent characters in memory. Each character requires one byte +of memory with the high-order bit usually set to zero. +Characters can be numbers, letters, and symbols. An ASCII file can be +intelligibly displayed on the video screen or printed on paper. +.sp +.sh +assembler: \c +.qs +Program that translates assembly language into the binary machine +code. Assembly language is simply a set of mnemonics used to +designate the instruction set of the CPU. See \c +.sh +ASM \c +.qs +in Section 3 of this manual. +.sp +.sh +back-up: \c +.qs +Copy of a disk or file made for safekeeping, or the creation of +the duplicate disk or file. +.sp +.sh +Basic Disk Operating System: \c +.qs +See \c +.sh +BDOS. +.sp +.sh +BDOS: \c +.qs +Basic Disk Operating System. The BDOS module of the CP/M +operating system provides an interface for a user program to the +operating system. This interface is in the form of a set of +function calls which may be made to the BDOS through calls to +location 0005H in page zero. The user program specifies the +number of the desired function in register C. User programs +running under CP/M should use BDOS functions for all I/O +operations to remain compatible with other CP/M systems and +future releases. The BDOS normally resides in high memory +directly below the BIOS. +.sp +.sh +bias: \c +.qs +Address value which when added to the origin address of your BIOS +module produces 1F80H, the address of the BIOS module in the +MOVCPM image. There is also a bias value that when added to the +BOOT module origin produces 0900H, the address of the BOOT module +in the MOVCPM image. You must use these bias values with the R +command under DDT or SID \ \ when you patch a CP/M system. If you do +not, the patched system may fail to function. +.sp +.sh +binary: \c +.qs +Base 2 numbering system. A binary digit can have one of two +values: 0 or 1. Binary numbers are used in computers because +the hardware can most easily exhibit two states: off and on. +Generally, a bit in memory represents one binary digit. +.sp +.sh +Basic Input/Output System: \c +.qs +See \c +.sh +BIOS. +.sp +.sh +BIOS: \c +.qs +Basic Input/Output System. The BIOS is the only hardware- +dependent module of the CP/M system. It provides the BDOS with a +set of primitive I/O operations. The BIOS is an assembly +language module usually written by the user, hardware +manufacturer, or independent software vendor, and is the key to +CP/M's portability. The BIOS interfaces the CP/M system to its +hardware environment through a standardized jump table at the +front of the BIOS routine and through a set of disk parameter +tables which define the disk environment. Thus, the BIOS +provides CP/M with a completely table-driven I/O system. +.sp +.sh +BIOS base: \c +.qs +Lowest address of the BIOS module in memory, that by definition +must be the first entry point in the BIOS jump table. +.bp +.sh +bit: \c +.qs +Switch in memory that can be set to on (1) or off (0). Bits are +grouped into bytes, eight bits to a byte, which is the smallest +directly addressable unit in an Intel 8080 or Zilog Z80. By +common convention, the bits in a byte are numbered from right, 0 +for the low-order bit, to left, 7 for the high-order bit. Bit +values are often represented in hexadecimal notation by grouping +the bits from the low-order bit in groups of four. Each group of +four bits can have a value from 0 to 15 and thus can easily be +represented by one hexadecimal digit. +.sp +.sh +BLM: \c +.qs +See \c +.sh +block mask. +.sp +.sh +block: \c +.qs +Basic unit of disk space allocation. Each disk drive has a fixed +block size (BLS) defined in its disk parameter block in the BIOS. +A block can consist of 1K, 2K, 4K, 8K, or 16K consecutive bytes. +Blocks are numbered relative to zero so that each block is unique +and has a byte displacement in a file equal to the block number +times the block size. +.sp +.sh +block mask (BLM): \c +.qs +Byte value in the disk parameter block at DPB + 3. The block +mask is always one less than the number of 128 byte sectors that +are in one block. Note that BLM = (2 ** BSH) - 1. +.sp +.sh +block shift (BSH): \c +.qs +Byte parameter in the disk parameter block at DPB + 2. +Block shift and block mask (BLM) values are determined by the +block size (BLS). Note that BLM = (2 ** BSH) - 1. +.sp +.sp 0 +.sh +blocking & deblocking algorithm: \c +.qs +In some disk subsystems the disk sector size is larger than 128 +bytes, usually 256, 512, 1024, or 2048 bytes. When the host +sector size is larger than 128 bytes, host sectors must be +buffered in memory and the 128-byte CP/M sectors must be blocked +and deblocked by adding an additional module, the blocking and +deblocking algorithm, between the BIOS disk I/O routines and the +actual disk I/O. The host sector size must be an even multiple +of 128 bytes for the algorithm to work correctly. The blocking +and deblocking algorithm allows the BDOS and BIOS to function +exactly as if the entire disk consisted only of 128-byte sectors, +as in the standard CP/M installation. +.sp +.sh +BLS: \c +.qs +Block size in bytes. See \c +.sh +block. +.sp +.sh +boot: \c +.qs +Process of loading an operating system into memory. A boot +program is a small piece of code that is automatically executed +when you power-up or reset your computer. The boot program loads +the rest of the operating system into memory in a manner similar +to a person pulling himself up by his own bootstraps. This +process is sometimes called a cold boot or cold start. Bootstrap +pocedures vary from system to system. The boot program must be +customized for the memory size and hardware environment that the +operating system manages. Typically, the boot resides on the +first sector of the system tracks on your system disk. When +executed, the boot loads the remaining sectors of the system +tracks into high memory at the location for which the CP/M system +has been configured. Finally, the boot transfers execution to +the boot entry point in the BIOS jump table so that the system +can initialize itself. In this case, the boot program should be +placed at 900H in the SYSGEN image. Alternatively, the boot +program may be located in ROM. +.sp +.sh +bootstrap: \c +.qs +See \c +.sh +boot. +.sp +.sh +BSH: \c +.qs +See \c +.sh +block shift. +.sp +.sh +BTREE: \c +.qs +General purpose file access method that has become the standard +organization for indexes in large data base systems. BTREE +provides near optimum performance over the full range of file +operations, such as insertion, deletion, search, and search next. +.sp +.sh +buffer: \c +.qs +Area of memory that temporarily stores data during the transfer +of information. +.sp +.sh +built-in commands: \c +.qs +Commands that permanently reside in memory. They respond quickly +because they are not accessed from a disk. +.sp +.sh +byte: \c +.qs +Unit of memory or disk storage containing eight bits. A byte can +represent a binary number between 0 and 255, and is the smallest +unit of memory that can be addressed directly in 8-bit CPUs such +as the Intel 8080 or Zilog Z80. +.sp +.sh +CCP: \c +.qs +Console Command Processor. The CCP is a module of the CP/M +operating system. It is loaded directly below the BDOS module +and interprets and executes commands typed by the console user. +Usually these commands are programs that the CCP loads and calls. +Upon completion, a command program may return control to the CCP +if it has not overwritten it. If it has, the program can reload +the CCP into memory by a warm boot operation initiated by either +a jump to zero, BDOS system reset (Function 0), or a cold boot. +Except for its location in high memory, the CCP works like any +other standard CP/M program; that is, it makes only BDOS function +calls for its I/O operations. +.sp +.sh +CCP base: \c +.qs +Lowest address of the CCP module in memory. This term sometimes +refers to the base of the CP/M system in memory, as the CCP is +normally the lowest CP/M module in high memory. +.sp +.sh +checksum vector (CSV): \c +.qs +Contiguous data area in the BIOS, with one byte for each +directory sector to be checked, that is, CKS bytes. See \c +.sh +CKS. \c +.qs +A checksum vector is initialized and maintained for each logged-in +drive. Each directory access by the system results in a checksum +calculation that is compared with the one in the checksum vector. +If there is a discrepancy, the drive is set to Read-Only status. +This feature prevents the user from inadvertently switching disks +without logging in the new disk. If the new disk is not logged-in, +it is treated the same as the old one, and data on it might be +destroyed if writing is done. +.sp +.mb 5 +.fm 1 +.sh +CKS: \c +.qs +Number of directory records to be checked summed on directory +accesses. This is a parameter in the disk parameter block +located in the BIOS. If the value of CKS is zero, then no +directory records are checked. CKS is also a parameter in the +diskdef macro library, where it is the actual number of directory +elements to be checked rather than the number of directory +records. +.sp +.sh +cold boot: \c +.qs +See \c +.sh +boot. \c +.qs +Cold boot also refers to a jump to the boot entry point in the +BIOS jump table. +.sp +.mb 6 +.fm 2 +.sh +COM: \c +.qs +Filetype for a CP/M command file. See \c +.sh +command file. +.sp +.sh +command: \c +.qs +CP/M command line. In general, a CP/M command line has three +parts: the command keyword, command tail, and a carriage return. +To execute a command, enter a CP/M command line directly after +the CP/M prompt at the console and press the carriage return or +enter key. +.sp +.sh +command file: \c +.qs +Executable program file of filetype COM. A command file is a +machine language object module ready to be loaded and executed at +the absolute address of 0100H. To execute a command file, enter +its primary filename as the command keyword in a CP/M command +line. +.sp +.sh +command keyword: \c +.qs +Name that identifies a CP/M command, usually the primary filename +of a file of type COM, or a built-in command. The command +keyword precedes the command tail and the carriage return in the +command line. +.sp +.sh +command syntax: \c +.qs +Statement that defines the correct way to enter a command. The +correct structure generally includes the command keyword, the +command tail, and a carriage return. A syntax line usually +contains symbols that you should replace with actual values when +you enter the command. +.sp +.sh +command tail: \c +.qs +Part of a command that follows the command keyword in the command +line. The command tail can include a drive specification, a +filename and filetype, and options or parameters. Some +commands do not require a command tail. +.sp +.sh +CON: \c +.qs +Mnemonic that represents the CP/M console device. +For example, the CP/M command PIP CON:=TEST.SUB displays the +file TEST.SUB on the console device. The explanation of the STAT +command tells how to assign the logical device CON: to various +physical devices. \c +See \c +.sh +console. +.sp +.sh +concatenate: \c +.qs +Name of the PIP operation that copies two or more separate files +into one new file in the the specified sequence. +.sp +.sh +concurrency: \c +.qs +Execution of two processes or operations simultaneously. +.sp +.sh +CONIN: \c +.qs +BIOS entry point to a routine that reads a character from the +console device. +.sp +.sh +CONOUT: \c +.qs +BIOS entry point to a routine that sends a character to the +console device. +.bp +.sh +console: \c +.qs +Primary input/output device. The console consists of a listing +device, such as a screen or teletype, and a keyboard through +which the user communicates with the operating system or +applications program. +.sp +.sh +Console Command Processor: \c +.qs +See \c +.sh +CCP. +.sp +.sh +CONST: \c +.qs +BIOS entry point to a routine that returns the status of the +console device. +.sp +.sh +control character: \c +.qs +Nonprinting character combination. CP/M interprets some control +characters as simple commands such as line editing functions. To +enter a control character, hold down the CONTROL key and strike +the specified character key. +.sp +.sh +Control Program for Microcomputers: \c +.qs +See \c +.sh +CP/M. +.sp +.sh +CP/M: \c +.qs +Control Program for Microcomputers. An operating system that +manages computer resources and provides a standard systems +interface to software written for a large variety of +microprocessor-based computer systems. +.sp +.sh +CP/M 1.4l compatibility: \c +.qs +For a CP/M 2 system to be able to read correctly single-density +disks produced under a CP/M 1.4 system, the extent mask must be +zero and the block size 1K. This is because under CP/M 2 an FCB +may contain more than one extent. The number of extents that may +be contained by an FCB is EXM+1. The issue of CP/M 1.4 +compatibility also concerns random file I/O. To perform random +file I/O under CP/M 1.4, you must maintain an FCB for each extent +of the file. This scheme is upward compatible with CP/M 2 for +files not exceeding 512K bytes, the largest file size supported +under CP/M 1.4. If you wish to implement random I/O for files +larger than 512K bytes under CP/M 2, you must use the random read +and random write functions, BDOS functions 33, 34, and 36. In +this case, only one FCB is used, and if CP/M 1.4 compatiblity is +required, the program must use the return version number +function, BDOS Function 12, to determine which method to employ. +.sp +.sh +CP/M prompt: \c +.qs +Characters that indicate that CP/M is ready to execute your next +command. The CP/M prompt consists of an upper-case letter, A-P, +followed by a > character; for example, A>. The letter +designates which drive is currently logged in as the default +drive. CP/M will search this drive for the command file +specified, unless the command is a built-in command or prefaced +by a select drive command: for example, B:STAT. +.sp +.sh +CP/NET: \c +.qs +Digital Research network operating system enabling microcomputers +to obtain access to common resources via a network. CP/NET +consists of MP/M masters and CP/M slaves with a network interface +between them. +.sp +.sh +CSV: \c +.qs +See \c +.sh +checksum vector. +.sp +.mb 5 +.fm 1 +.sh +cursor: \c +.qs +One-character symbol that can appear anywhere on the console +screen. The cursor indicates the position where the next +keystroke at the console will have an effect. +.sp +.sh +data file: \c +.qs +File containing information that will be processed by a program. +.sp +.mb 6 +.fm 2 +.sh +deblocking: \c +.qs +See \c +.sh +blocking & deblocking algorithm. +.sp +.sh +default: \c +.qs +Currently selected disk drive and user number. Any command that +does not specify a disk drive or a user number references the +default disk drive and user number. When CP/M is first invoked, +the default disk drive is drive A, and the default user number is +0. +.sp +.sh +default buffer: \c +.qs +Default 128-byte buffer maintained at 0080H in page zero. When +the CCP loads a COM file, this buffer is initialized to the +command tail; that is, any characters typed after the COM file +name are loaded into the buffer. The first byte at 0080H +contains the length of the command tail, while the command tail +itself begins at 0081H. The command tail is terminated by a byte +containing a binary zero value. The I command under DDT and SID +initializes this buffer in the same way as the CCP. +.sp +.sh +default FCB: \c +.qs +Two default FCBs are maintained by the CCP at 005CH and 006CH in +page zero. The first default FCB is initialized from the first +delimited field in the command tail. The second default FCB +is initialized from the next field in the command tail. +.sp +.sp 0 +.sh +delimiter: \c +.qs +Special characters that separate different items in a command +line; for example, a colon separates the drive specification from +the filename. The CCP recognizes the following characters as +delimiters: . : = ; < > _, blank, and carriage return. Several +CP/M commands also treat the following as delimiter characters: +, [ ] ( ) $. It is advisable to avoid the use of delimiter +characters and lower-case characters in CP/M filenames. +.sp +.sh +DIR: \c +.qs +Parameter in the diskdef macro library that specifies the number +of directory elements on the drive. +.sp +.sh +DIR attribute: \c +.qs +File attribute. A file with the DIR attribute can be displayed +by a DIR command. The file can be accessed from the default user +number and drive only. +.sp +.sh +DIRBUF: \c +.qs +128-byte scratchpad area for directory operations, +usually located at the end of the BIOS. DIRBUF is used by the +BDOS during its directory operations. DIRBUF also refers to the +two-byte address of this scratchpad buffer in the disk parameter +header at DPbase + 8 bytes. +.sp +.sh +directory: \c +.qs +Portion of a disk that contains entries for each file on the +disk. In response to the DIR command, CP/M displays the +filenames stored in the directory. The directory also contains +the locations of the blocks allocated to the files. Each file +directory element is in the form of a 32-byte FCB, although one +file can have several elements, depending on its size. The +maximum number of directory elements supported is specified by +the drive's disk parameter block value for DRM. +.bp +.sh +directory element: \c +.qs +Data structure. Each file on a disk has one or more 32-byte +directory elements associated with it. There are four directory +elements per directory sector. Directory elements can also be +referred to as directory FCBs. +.sp +.sh +directory entry: \c +.qs +File entry displayed by the DIR command. Sometimes this term +refers to a physical directory element. +.sp +.sp 0 +.sh +disk, diskette: \c +.qs +Magnetic media used for mass storage in a computer system. +Programs and data are recorded on the disk in the same way music +can be recorded on cassette tape. The CP/M operating system must +be initially loaded from disk when the computer is turned on. +Diskette refers to smaller capacity removable floppy diskettes, +while disk may refer to either a diskette, removable cartridge +disk, or fixed hard disk. Hard disk capacities range from five +to several hundred megabytes of storage. +.sp +.sh +diskdef macro library: \c +.qs +Library of code that when used with MAC, the Digital Research +macro assembler, creates disk definition tables such as the DPB +and DPH automatically. +.sp +.sh +disk drive: \c +.qs +Peripheral device that reads and writes information on disk. +CP/M assigns a letter to each drive under its +control. For example, CP/M may refer to the drives in a +four-drive system as A, B, C, and D. +.sp +.sh +disk parameter block (DPB): \c +.qs +Data structure referenced by one or more disk parameter headers. +The disk parameter block defines disk characteristics in the +fields listed below: +.sp +.in 5 +.nf +SPT is the total number of sectors per track. +BSH is the data allocation block shift factor. +BLM is the data allocation block mask. +EXM is the extent mask determined by BLS and DSM. +DSM is the maximum data block number. +DRM is the maximum number of directory entries--1. +AL0 reserves directory blocks. +AL1 reserves directory blocks. +CKS is the number of directory sectors check summed. +OFF is the number of reserved system tracks. +.fi +.in 0 +.sp +The address of the disk parameter block is located in the disk +parameter header at DPbase +0AH. CP/M Function 31 returns the +DPB address. Drives with the same characteristics can use the +same disk parameter header, and thus the same DPB. However, +drives with different characteristics must each have their own +disk parameter header and disk parameter blocks. When the BDOS +calls the SELDSK entry point in the BIOS, SELDSK must return the +address of the drive's disk parameter header in register HL. +.sp +.sh +disk parameter header (DPH): \c +.qs +Data structure that contains information about the disk drive and +provides a scratchpad area for certain BDOS operations. The disk +parameter header contains six bytes of scratchpad area for the +BDOS, and the following five 2-byte parameters: +.sp +.in 5 +.nf +XLT is the sector translation table address. +DIRBUF is the directory buffer address. +DPB is the disk parameter block address. +CSV is the checksum vector address. +ALV is the allocation vector address. +.fi +.in 0 +.sp +Given n disk drives, the disk parameter headers are arranged in a +table whose first row of 16 bytes corresponds to drive 0, with +the last row corresponding to drive n-1. +.sp +.sh +DKS: \c +.qs +Parameter in the diskdef macro library specifying the number of +data blocks on the drive. +.sp +.sh +DMA: \c +.qs +Direct Memory Access. DMA is a method of transferring data from +the disk into memory directly. In a CP/M system, the BDOS calls +the BIOS entry point READ to read a sector from the disk into the +currently selected DMA address. The DMA address must be the +address of a 128-byte buffer in memory, either the default buffer +at 0080H in page zero, or a user-assigned buffer in the TPA. +Similarly, the BDOS calls the BIOS entry point WRITE to write the +record at the current DMA address to the disk. +.sp +.sh +DN: \c +.qs +Parameter in the diskdef macro library specifying the logical +drive number. +.sp +.sh +DPB: \c +.qs +See \c +.sh +disk parameter block. +.sp +.sh +DPH: \c +.qs +See \c +.sh +disk parameter header. +.sp +.sh +DRM: \c +.qs +2-byte parameter in the disk parameter block at DPB + 7. DRM is +one less than the total number of directory entries allowed for +the drive. This value is related to DPB bytes AL0 and AL1, which +allocates up to 16 blocks for directory entries. +.sp +.sh +DSM: \c +.qs +2-byte parameter of the disk parameter block at DPB + 5. DSM is +the maximum data block number supported by the drive. The +product BLS times (DSM+1) is the total number of bytes held by +the drive. This must not exceed the capacity of the physical +disk less the reserved system tracks. +.sp +.sh +editor: \c +.qs +Utility program that creates and modifies text files. An editor +can be used for creation of documents or creation of code for +computer programs. The CP/M editor is invoked by typing the +command ED next to the system prompt on the console. +.sp +.sh +EX: \c +.qs +Extent number field in an FCB. See \c +.sh +extent. +.sp +.sh +executable: \c +.qs +Ready to be run by the computer. Executable code is a series of +instructions that can be carried out by the computer. For +example, the computer cannot execute names and addresses, but it +can execute a program that prints all those names and addresses +on mailing labels. +.sp +.sh +execute a program: \c +.qs +Start the processing of executable code. +.sp +.sh +EXM: \c +.qs +See \c +.sh +extent mask. +.sp +.sh +extent: \c +.qs +16K consecutive bytes in a file. Extents are numbered from 0 to +31. One extent can contain 1, 2, 4, 8, or 16 blocks. EX is the +extent number field of an FCB and is a one-byte field at FCB + +12, where FCB labels the first byte in the FCB. Depending on the +block size (BLS) and the maximum data block number (DSM), an FCB +can contain 1, 2, 4, 8, or 16 extents. The EX field is normally +set to 0 by the user but contains the current extent number +during file I/O. The term FCB folding describes FCBs containing +more than one extent. In CP/M version 1.4, each FCB contained +only one extent. Users attempting to perform random record I/O +and maintain CP/M 1.4 compatiblity should be aware of the +implications of this difference. See \c +.sh +CP/M 1.4 compatibility. +.sp +.sh +extent mask (EXM): \c +.qs +A byte parameter in the disk parameter block located at DPB + 3. +The value of EXM is determined by the block size (BLS) and +whether the maximum data block number (DSM) exceeds 255. There +are EXM + 1 extents per directory FCB. +.sp +.sh +FCB: \c +.qs +See \c +.sh +File Control Block. +.sp +.sh +file: \c +.qs +Collection of characters, instructions, or data that can be +referenced by a unique identifier. Files are usually stored on +various types of media, such as disk, or magnetic +tape. A CP/M file is identified by a file specification and +resides on disk as a collection of from zero to 65,536 records. +Each record is 128 bytes and can contain either binary or ASCII +data. Binary files contain bytes of data that can vary in value +from 0H to 0FFH. ASCII files contain sequences of character +codes delineated by a carriage return and line-feed combination; +normally byte values range from 0H to 7FH. The directory maps +the file as a series of physical blocks. Although files are +defined as a sequence of consecutive logical records, these +records can not reside in consecutive sectors on the disk. See +also \c +.sh +block, directory, extent, record, \c +.qs +and \c +.sh +sector. +.qs +.nx apph2.tex + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/apph2.tex b/Source/Doc/CPM 22 Manual/apph2.tex new file mode 100644 index 00000000..89387031 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/apph2.tex @@ -0,0 +1,912 @@ +.he CP/M Operating System Manual H Glossary +.sp +File Control Block (FCB): +Structure used for accessing files on disk. Contains the drive, +filename, filetype, and other information describing a file to be +accessed or created on the disk. A file control block consists +of 36 consecutive bytes specified by the user for file I/O +functions. FCB can also refer to a directory element in the +directory portion of the allocated disk space. These contain the +same first 32 bytes of the FCB, but lack the current record and +random record number bytes. +.sp +.sh +filename: \c +.qs +Name assigned to a file. A filename can include a primary +filename of one to eight characters; a filetype of zero to three characters. +A period separates the primary filename from the filetype. +.sp +.mb 5 +.fm 1 +.sh +file specification: \c +.qs +Unique file identifier. A complete CP/M file specification +includes a disk drive specification followed by a colon, d:, a +primary filename of one to eight characters, a period, and a filetype of +zero to three characters. For example, b:example.tex is a complete CP/M +file specification. +.sp +.sh +filetype: \c +.qs +Extension to a filename. A filetype can be from zero to three +characters and must be separated from the primary filename by a +period. A filetype can tell something about the file. Some +programs require that files to be processed have specific +filetypes. +.sp +.mb 6 +.fm 2 +.sp 0 +.sh +floppy disk: \c +.qs +Flexible magnetic disk used to store information. Floppy disks +come in 5 1/4- and 8-inch diameters. +.sp +.sh +FSC: \c +.qs +Parameter in the diskdef macro library specifying the first +physical sector number. This parameter is used to determine SPT +and build XLT. +.sp +.sh +hard disk: \c +.qs +Rigid, platter-like, magnetic disk sealed in a container. A hard +disk stores more information than a floppy disk. +.sp +.sh +hardware: \c +.qs +Physical components of a computer. +.sp +.sh +hexadecimal notation: \c +.qs +Notation for base 16 values using the decimal digits and letters +A, B, C, D, E, and F to represent the 16 digits. Hexadecimal +notation is often used to refer to binary numbers. A binary +number can be easily expressed as a hexadecimal value by taking +the bits in groups of 4, starting with the least significant bit, +and expressing each group as a hexadecimal digit, 0-F. Thus the +bit value 1011 becomes 0BH and 10110101 becomes 0B5H. +.sp +.sh +hex file: \c +.qs +ASCII-printable representation of a command, machine language, +file. +.sp +.sh +hex file format: \c +.qs +Absolute output of ASM and MAC for the Intel 8080 is a hex format +file, containing a sequence of absolute records that give a load +address and byte values to be stored, starting at the load +address. +.sp +.sh +HOME: \c +.qs +BIOS entry point which sets the disk head of the currently +selected drive to the track zero position. +.sp +.sh +host: \c +.qs +Physical characteristics of a hard disk drive in a system using +the blocking and deblocking algorithm. The term, host, helps +distinguish physical hardware characteristics from CP/M's logical +characteristics. For example, CP/M sectors are always 128 bytes, +although the host sector size can be a multiple of 128 bytes. +.sp +.sh +input: \c +.qs +Data going into the computer, usually from an operator typing at +the terminal or by a program reading from the disk. +.sp +.sh +input/output: \c +.qs +See \c +.sh +I/O. +.sp +.sh +interface: \c +.qs +Object that allows two independent systems to communicate with +each other, as an interface between hardware and software in a +microcomputer. +.sp +.sh +I/O: \c +.qs +Abbreviation for input/output. Usually refers to input/output +operations or routines handling the input and output of data in +the computer system. +.sp +.sh +IOBYTE: \c +.qs +A one-byte field in page zero, currently at location 0003H, that +can support a logical-to-physical device mapping for I/O. +However, its implementation in your BIOS is purely optional and +might or might not be supported in a given CP/M system. The IOBYTE +is easily set using the command: +.sp +.ti 8 +.nf +STAT = +.fi +.sp +The CP/M logical devices are CON:, RDR:, PUN:, and LST:; each of +these can be assigned to one of four physical devices. The IOBYTE +can be initialized by the BOOT entry point of the BIOS and +interpreted by the BIOS I/O entry points CONST, CONIN, CONOUT, +LIST, PUNCH, and READER. Depending on the setting of the IOBYTE, +different I/O drivers can be selected by the BIOS. For example, +setting LST:=TTY: might cause LIST output to be directed to a +serial port, while setting LST:=LPT: causes LIST output to be +directed to a parallel port. +.sp +.sh +K: \c +.qs +Abbreviation for kilobyte. See \c +.sh +kilobyte. +.sp +.sh +keyword: \c +.qs +See \c +.sh +command keyword. +.sp +.sh +kilobyte (K): \c +.qs +1024 bytes or 0400H bytes of memory. This is a standard unit of +memory. For example, the Intel 8080 supports up to 64K of memory +address space or 65,536 bytes. 1024 kilobytes equal one megabyte, +or over one million bytes. +.sp +.sh +linker: \c +.qs +Utility program used to combine relocatable object modules into +an absolute file ready for execution. For example, LINK-80 \ \ +creates either a COM or PRL file from relocatable REL files, such +as those produced by PL/I-80 \ \ . +.sp +.sh +LIST: \c +.qs +A BIOS entry point to a routine that sends a character to the +list device, usually a printer. +.sp +.sh +list device: \c +.qs +Device such as a printer onto which data can be listed or +printed. +.sp +.sh +LISTST: \c +.qs +BIOS entry point to a routine that returns the ready status of +the list device. +.sp +.sh +loader: \c +.qs +Utility program that brings an absolute program image into memory +ready for execution under the operating system, or a utility used +to make such an image. For example, LOAD prepares an absolute +COM file from the assembler hex file output that is ready to be +executed under CP/M. +.sp +.sh +logged in: \c +.qs +Made known to the operating system, in reference to drives. A +drive is logged in when it is selected by the user or an +executing process. It remains selected or logged in until you +change disks in a floppy disk drive or enter CTRL-C at the +command level, or until a BDOS Function 0 is executed. +.sp +.sh +logical: \c +.qs +Representation of something that might or might not be the same +in its actual physical form. For example, a hard disk can occupy +one physical drive, yet you can divide the available storage on +it to appear to the user as if it were in several different +drives. These apparent drives are the logical drives. +.sp +.sh +logical sector: \c +.qs +See \c +.sh +sector. +.sp +.sh +logical-to-physical sector translation table: \c +.qs +See \c +.sh +XLT. +.sp +.sh +LSC: \c +.qs +Diskdef macro library parameter specifying the last physical +sector number. +.sp +.sh +LST: \c +.qs +Logical CP/M list device, usually a printer. The CP/M list +device is an output-only device referenced through the LIST and +LISTST entry points of the BIOS. The STAT command allows +assignment of LST: to one of the physical devices: TTY:, CRT:, +LPT:, or UL1:, provided these devices and the IOBYTE are +implemented in the LIST and LISTST entry points of your CP/M BIOS +module. The CP/NET command NETWORK allows assignment of LST: to +a list device on a network master. For example, PIP LST:=TEST.SUB +prints the file TEST.SUB on the list device. +.sp +.sh +macro assembler: \c +.qs +Assembler code translator providing macro processing facilities. +Macro definitions allow groups of instructions to be stored and +substituted in the source program as the macro names are +encountered. Definitions and invocations can be nested and macro +parameters can be formed to pass arbitrary strings of text to a +specific macro for substitution during expansion. +.sp +.sh +megabyte: \c +.qs +Over one million bytes; 1024 kilobytes. See \c +.sh +byte, \c +.qs +and \c +.sh +kilobyte. +.sp +.sh +microprocessor: \c +.qs +Silicon chip that is the central processing unit (CPU) of the +microcomputer. The Intel 8080 and the Zilog Z80 are +microprocessors commonly used in CP/M systems. +.sp +.sh +MOVCPM image: \c +.qs +Memory image of the CP/M system created by MOVCPM. This image +can be saved as a disk file using the SAVE command or placed on +the system tracks using the SYSGEN command without specifying a +source drive. This image varies, depending on the presence of a +one-sector or two-sector boot. If the boot is less than 128 +bytes (one sector), the boot begins at 0900H, the CP/M system at +0980H, and the BIOS at 1F80H. Otherwise, the boot is at 0900H, +the CP/M system at 1000H, and the BIOS at 2000H. In a CP/M 1.4 +system with a one-sector boot, the addresses are the same as for +the CP/M 2 system--except that the BIOS begins at 1E80H instead +of 1F80H. +.mb 4 +.fm 1 +.sp +.sh +MP/M: \c +.qs +Multi-Programming Monitor control program. A microcomputer +operating system supporting multi-terminal access with multi- +programming at each terminal. +.sp +.sh +multi-programming: \c +.qs +The capability of initiating and executing more than one program +at a time. These programs, usually called processes, are time-shared, +each receiving a slice of CPU time on a round-robin +basis. See \c +.sh +concurrency. +.sp +.sh +nibble: \c +.qs +One half of a byte, usually the high-order or low-order 4 bits in +a byte. +.sp +.sh +OFF: \c +.qs +Two-byte parameter in the disk parameter block at DPB + 13 bytes. +This value specifies the number of reserved system tracks. The +disk directory begins in the first sector of track OFF. +.sp +.sh +OFS: \c +.qs +Diskdef macro library parameter specifying the number of reserved +system tracks. See \c +.sh +OFF. +.sp +.sh +operating system: \c +.qs +Collection of programs that supervises the execution of other +programs and the management of computer resources. An operating +system provides an orderly input/output environment between the +computer and its peripheral devices. It enables user-written +programs to execute safely. An operating system standardizes the +use of computer resources for the programs running under it. +.mb 6 +.fm 2 +.sp +.sh +option: \c +.qs +One of many parameters that can be part of a command tail. Use +options to specify additional conditions for a command's +execution. +.sp +.sh +output: \c +.qs +Data that is sent to the console, disk, or printer. +.sp +.sh +page: \c +.qs +256 consecutive bytes in memory beginning on a page boundary, +whose base address is a multiple of 256 (100H) bytes. In hex +notation, pages always begin at an address with a least +significant byte of zero. +.sp +.sh +page relocatable program: \c +.qs +See \c +.sh +PRL. +.sp +.sh +page zero: \c +.qs +Memory region between 0000H and 0100H used to hold critical +system parameters. Page zero functions primarily as an interface +region between user programs and the CP/M BDOS module. Note that +in non-standard systems this region is the base page of the +system and represents the first 256 bytes of memory used by the +CP/M system and user programs running under it. +.sp +.sh +parameter: \c +.qs +Value in the command tail that provides additional information +for the command. Technically, a parameter is a required element +of a command. +.sp +.sh +peripheral devices: \c +.qs +Devices external to the CPU. For example, terminals, printers, +and disk drives are common peripheral devices that are not part +of the processor but are used in conjunction with it. +.sp +.sh +physical: \c +.qs +Characteristic of computer components, generally hardware, that +actually exist. In programs, physical components can be +represented by logical components. +.sp +.sh +primary filename: \c +.qs +First 8 characters of a filename. The primary filename is a +unique name that helps the user identify the file contents. A +primary filename contains one to eight characters and can include any +letter or number and some special characters. The primary +filename follows the optional drive specification and precedes +the optional filetype. +.sp +.sh +PRL: \c +.qs +Page relocatable program. A page relocatable program is stored +on disk with a PRL filetype. Page relocatable programs are +easily relocated to any page boundary and thus are suitable for +execution in a nonbanked MP/M system. +.sp +.sh +program: \c +.qs +Series of coded instructions that performs specific tasks when +executed by a computer. A program can be written in a +processor-specific language or a high-level language that can be +implemented on a number of different processors. +.sp +.sh +prompt: \c +.qs +Any characters displayed on the video screen to help the user +decide what the next appropriate action is. A system prompt is a +special prompt displayed by the operating +system. The alphabetic character indicates the default drive. Some +applications programs have their own special prompts. See \c +.sh +CP/M prompt. +.qs +.sp +.mb 5 +.fm 1 +PUN: +Logical CP/M punch device. The punch device is an output-only +device accessed through the PUNCH entry point of the BIOS. In +certain implementations, PUN: can be a serial device such as a +modem. +.sp +PUNCH: +BIOS entry point to a routine that sends a character to the punch +device. +.sp +RDR: +Logical CP/M reader device. The reader device is an input-only +device accessed through the READER entry point in the BIOS. +See +PUN:. +.sp +READ: +Entry point in the BIOS to a routine that reads 128 bytes from +the currently selected drive, track, and sector into the current +DMA address. +.sp +READER: +Entry point to a routine in the BIOS that reads the next +character from the currently assigned reader device. +.sp +Read-Only (R/O): +Attribute that can be assigned to a disk file or a disk drive. +When assigned to a file, the Read-Only attribute allows you to +read from that file but not write to it. When assigned to a +drive, the Read-Only attribute allows you to read any file on the +disk, but prevents you from adding a new file, erasing or changing +a file, renaming a file, or writing on the disk. The STAT +command can set a file or a drive to Read-Only. Every file and +drive is either Read-Only or Read-Write. The default setting for +drives and files is Read-Write, but an error in resetting the +disk or changing media automatically sets the drive to Read-Only +until the error is corrected. See also \c +.sh +ROM. +.sp +.sh +Read-Write (R/W): \c +.qs +Attribute that can be assigned to a disk file or a disk drive. +The Read-Write attribute allows you to read from and write to a +specific Read-Write file or to any file on a disk that is in a +drive set to Read-Write. A file or drive can be set to either +Read-Only or Read-Write. +.sp +.sh +record: \c +.qs +Group of bytes in a file. A physical record consists of 128 +bytes and is the basic unit of data transfer between the +operating system and the application program. A logical record +might vary in length and is used to represent a unit of +information. Two 64-byte employee records can be stored in one +128-byte physical record. Records are grouped together to form a +file. +.sp +.sh +recursive procedure: \c +.qs +Code that can call itself during execution. +.sp +.mb 6 +.fm 2 +.sh +reentrant procedure: \c +.qs +Code that can be called by one process while another is already +executing it. Thus, reentrant code can be shared between +different users. Reentrant procedures must not be self- +modifying; that is, they must be pure code and not contain data. +The data for reentrant procedures can be kept in a separate data +area or placed on the stack. +.sp +.sh +restart (RST): \c +.qs +One-byte call instruction usually used during interrupt sequences +and for debugger break pointing. There are eight restart +locations, RST 0 through RST 7, whose addresses are given by the +product of 8 times the restart number. +.sp +.sh +R/O: \c +.qs +See \c +.sh +Read-Only. +.sp +.sh +ROM: \c +.qs +Read-Only memory. This memory can be read but not written and so +is suitable for code and preinitialized data areas only. +.sp +.sh +RST: \c +.qs +See \c +.sh +restart. +.sp +.sh +R/W: \c +.qs +See \c +.sh +Read-Write. +.sp +.sh +sector: \c +.qs +In a CP/M system, a sector is always 128 consecutive bytes. A +sector is the basic unit of data read and written on the disk by +the BIOS. A sector can be one 128-byte record in a file or a +sector of the directory. The BDOS always requests a logical +sector number between 0 and (SPT-1). This is typically +translated into a physical sector by the BIOS entry point +SECTRAN. In some disk subsystems, the disk sector size is larger +than 128 bytes, usually a power of two, such as 256, 512, 1024, or +2048 bytes. These disk sectors are always referred to as host +sectors in CP/M documentation and should not be confused with +other references to sectors, in which cases the CP/M 128-byte +sectors should be assumed. When the host sector size is larger +than 128 bytes, host sectors must be buffered in memory and the +128-byte CP/M sectors must be blocked and deblocked from them. +This can be done by adding an additional module, the blocking and +deblocking algorithm, between the BIOS disk I/O routines and the +actual disk I/O. +.sp +.sh +sectors per track (SPT): \c +.qs +A two-byte parameter in the disk parameter block at DPB + 0. The +BDOS makes calls to the BIOS entry point SECTRAN with logical +sector numbers ranging between 0 and (SPT - 1) in register BC. +.sp +.sh +SECTRAN: \c +.qs +Entry point to a routine in the BIOS that performs +logical-to-physical sector translation for the BDOS. +.sp +.sh +SELDSK: \c +.qs +Entry point to a routine in the BIOS that sets the currently +selected drive. +.sp +.sh +SETDMA: \c +.qs +Entry point to a routine in the BIOS that sets the currently +selected DMA address. The DMA address is the address of a +128-byte buffer region in memory that is used to transfer data to +and from the disk in subsequent reads and writes. +.sp +.sh +SETSEC: \c +.qs +Entry point to a routine in the BIOS that sets the currently +selected sector. +.sp +.sh +SETTRK: \c +.qs +Entry point to a routine in the BIOS that sets the currently +selected track. +.sp +.sh +skew factor: \c +.qs +Factor that defines the logical-to-physical sector number +translation in XLT. Logical sector numbers are used by the BDOS +and range between 0 and (SPT - 1). Data is written in +consecutive logical 128-byte sectors grouped in data blocks. The +number of sectors per block is given by BLS/128. Physical +sectors on the disk media are also numbered consecutively. If +the physical sector size is also 128 bytes, a one-to-one +relationship exists between logical and physical sectors. The +logical-to-physical translation table (XLT) maps this +relationship, and a skew factor is typically used in generating +the table entries. For instance, if the skew factor is 6, XLT +will be: +.sp +.nf +.in 8 +Logical: 0 1 2 3 4 5 6 ... 25 +Physical: 1 7 13 19 25 5 11 ... 22 +.fi +.in 0 +.sp +The skew factor allows time for program processing without +missing the next sector. Otherwise, the system must wait for an +entire disk revolution before reading the next logical sector. +The skew factor can be varied, depending on hardware speed and +application processing overhead. Note that no sector translation +is done when the physical sectors are larger than 128 bytes, as +sector deblocking is done in this case. See also \c +.sh +sector, SKF, \c +.qs +and \c +.sh +XLT. +.sp +.sh +SKF: \c +.qs +A diskdef macro library parameter specifying the skew factor to +be used in building XLT. If SKF is zero, no translation table is +generated and the XLT byte in the DPH will be 0000H. +.sp +.sh +software: \c +.qs +Programs that contain machine-readable instructions, as opposed +to hardware, which is the actual physical components of a +computer. +.sp +.sh +source file: \c +.qs +ASCII text file usually created with an editor that is an input +file to a system program, such as a language translator or text +formatter. +.sp +.sh +SP: \c +.qs +Stack pointer. See \c +.sh +stack. +.bp +.sh +spooling: \c +.qs +Process of accumulating printer output in a file while the +printer is busy. The file is printed when the printer becomes +free; a program does not have to wait for the slow printing +process. +.sp +.sh +SPT: \c +.qs +See \c +.sh +sectors per track. +.sp +.sh +stack: \c +.qs +Reserved area of memory where the processor saves the return +address when a call instruction is received. When a return +instruction is encountered, the processor restores the current +address on the stack to the program counter. Data such as the +contents of the registers can also be saved on the stack. The +push instruction places data on the stack and the pop instruction +removes it. An item is pushed onto the stack by decrementing the +stack pointer (SP) by 2 and writing the item at the SP address. +In other words, the stack grows downward in memory. +.sp +.sh +syntax: \c +.qs +Format for entering a given command. +.sp +.sh +SYS: \c +.qs +See \c +.sh +system attribute. +.sp +.sh +SYSGEN image: \c +.qs +Memory image of the CP/M system created by SYSGEN when a +destination drive is not specified. This is the same as the +MOVCPM image that can be read by SYSGEN if a source drive is +not specified. See \c +.sh +MOVCPM image. +.sp +.sh +system attribute (SYS): \c +.qs +File attribute. You can give a file the system attribute by +using the SYS option in the STAT command or by using the set file +attributes function, BDOS Function 12. A file with the SYS +attribute is not displayed in response to a DIR command. If you +give a file with user number 0 the SYS attribute, you can read +and execute that file from any user number on the same drive. +Use this feature to make your commonly used programs available +under any user number. +.sp +system prompt: +Symbol displayed by the operating system indicating that the +system is ready to receive input. +See prompt and CP/M prompt. +.sp +.sh +system tracks: \c +.qs +Tracks reserved on the disk for the CP/M system. The number of +system tracks is specified by the parameter OFF in the disk +parameter block (DPB). The system tracks for a drive always +precede its data tracks. The command SYSGEN copies the CP/M +system from the system tracks to memory, and vice versa. The +standard SYSGEN utility copies 26 sectors from track 0 and 26 +sectors from track 1. When the system tracks contain additional +sectors or tracks to be copied, a customized SYSGEN must be used. +.sp +.sh +terminal: \c +.qs +See \c +.sh +console. +.sp +.sh +TPA: \c +.qs +Transient Program Area. Area in memory where user programs run +and store data. This area is a region of memory beginning at +0100H and extending to the base of the CP/M system in high +memory. The first module of the CP/M system is the CCP, which +can be overwritten by a user program. If so, the TPA is extended +to the base of the CP/M BDOS module. If the CCP is overwritten, +the user program must terminate with either a system reset +(Function 0) call or a jump to location zero in page zero. The +address of the base of the CP/M BDOS is stored in location 0006H +in page zero least significant byte first. +.sp +.sh +track: \c +.qs +Data on the disk media is accessed by combination of track and +sector numbers. Tracks form concentric rings on the disk; the +standard IBM single-density disks have 77 tracks. Each track +consists of a fixed number of numbered sectors. Tracks are +numbered from zero to one less than the number of tracks on the +disk. +.sp +.sh +Transient Program Area: \c +.qs +See \c +.sh +TPA. +.sp +.sh +upward compatible: \c +.qs +Term meaning that a program created for the previously released +operating system, or compiler, runs under the newly released +version of the same operating system. +.sp +.sh +USER: \c +.qs +Term used in CP/M and MP/M systems to distinguish distinct +regions of the directory. +.sp +.sh +user number: \c +.qs +Number assigned to files in the disk directory so that different +users need only deal with their own files and have their own +directories, even though they are all working from the same disk. +In CP/M, files can be divided into 16 user groups. +.sp +.sh +utility: \c +.qs +Tool. Program that enables the user to perform certain +operations, such as copying files, erasing files, and editing +files. The utilities are created for the convenience of +programmers and users. +.sp +.sh +vector: \c +.qs +Location in memory. An entry point into the operating system +used for making system calls or interrupt handling. +.sp +.sh +warm start: \c +.qs +Program termination by a jump to the warm start vector at +location 0000H, a system reset (BDOS Function 0), or a CTRL-C +typed at the keyboard. A warm start reinitializes the disk +subsystem and returns control to the CP/M operating system at the +CCP level. The warm start vector is simply a jump to the WBOOT +entry point in the BIOS. +.sp +.sh +WBOOT: \c +.qs +Entry point to a routine in the BIOS used when a warm start +occurs. A warm start is performed when a user program branches +to location 0000H, when the CPU is reset from the front panel, or +when the user types CTRL-C. The CCP and BDOS are reloaded from +the system tracks of drive A. +.sp +.sh +wildcard characters: \c +.qs +Special characters that match certain specified items. In CP/M +there are two wildcard characters: ? and *. The ? can be +substituted for any single character in a filename, and the * can +be substituted for the primary filename, the filetype, or both. +By placing wildcard characters in filenames, the user creates an +ambiguous filename and can quickly reference one or more files. +.bp +.sh +word: \c +.qs +16-bit or two-byte value, such as an address value. Although the +Intel 8080 is an 8-bit CPU, addresses occupy two bytes and are +called word values. +.sp +.sh +WRITE: \c +.qs +Entry point to a routine in the BIOS that writes the record at +the currently selected DMA address to the currently selected +drive, track, and sector. +.sp +.sh +XLT: \c +.qs +Logical-to-physical sector translation table located in the BIOS. +SECTRAN uses XLT to perform logical-to-physical sector number +translation. XLT also refers to the two-byte address in the disk +parameter header at DPBASE + 0. If this parameter is zero, no +sector translation takes place. Otherwise this parameter is the +address of the translation table. +.sp +.sh +ZERO PAGE: \c +.qs +See \c +.sh +page zero. +.qs +.sp 2 +.ce +End of Appendix H +.nx appi + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/appi.tex b/Source/Doc/CPM 22 Manual/appi.tex new file mode 100644 index 00000000..745b5b2e --- /dev/null +++ b/Source/Doc/CPM 22 Manual/appi.tex @@ -0,0 +1,939 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft I-% +.pc 1 +.tc I CP/M Error Messages +.ce 2 +.sh +Appendix I +.sp +.sh +CP/M Error Messages +.qs +.he CP/M Operating System Manual I CP/M Error Messages +.sp 2 +.pp +Messages come from several different sources. CP/M displays +error messages when there are errors in calls to the Basic Disk +Operating System (BDOS). CP/M also displays messages when there +are errors in command lines. Each utility supplied with CP/M has +its own set of messages. The following lists CP/M messages and +utility messages. One might see messages other than those listed +here if one is running an application program. Check the +application program's documentation for explanations of those +messages. +.sp 2 +.sh + Table I-1. CP/M Error Messages +.sp +.ll 60 +.nf + Message Meaning +.sp +.fi +.in 20 +.ti -15 +? +.sp +DDT. This message has four possible meanings: +.sp +.in 23 +.ti -2 +o DDT does not understand the assembly language instruction. +.ti -2 +o The file cannot be opened. +.ti -2 +o A checksum error occurred in a HEX file. +.ti -2 +o The assembler/disassembler was overlayed. +.sp 2 +.in 20 +.ti -15 +ABORTED +.sp +PIP. You stopped a PIP operation by pressing a key. +.sp 2 +.ti -15 +ASM Error Messages +.sp +.in 24 +.ti -4 +D Data error: data statement element cannot be placed in +specified data area. +.sp +.ti -4 +E Expression error: expression cannot be evaluated during +assembly. +.sp +.ti -4 +L Label error: label cannot appear in this context (might be +duplicate label). +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.sp + ASM Error Messages (continued) +.fi +.sp +.in 24 +.ti -4 +N Not implemented: unimplemented features, such as macros, are +trapped. +.sp +.ti -4 +O Overflow: expression is too complex to evaluate. +.sp +.ti -4 +P Phase error: label value changes on two passes through +assembly. +.sp +.ti -4 +R Register error: the value specified as a register is +incompatible with the code. +.sp +.ti -4 +S Syntax error: improperly formed expression. +.sp +.ti -4 +U Undefined label: label used does not exist. +.sp +.ti -4 +V Value error: improperly formed operand encountered in an +expression. +.sp 2 +.in 20 +.ti -15 +BAD DELIMITER +.sp +STAT. Check command line for typing errors. +.sp 2 +.ti -15 +Bad Load +.sp +CCP error message, or SAVE error message. +.sp 2 +.ti -15 +Bdos Err On d: +.sp +Basic Disk Operating System error on the designated drive: CP/M +replaces d: with the drive specification of the drive where the +error occurred. This message is followed by one of the four +phrases in the situations described below. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +Bdos Err On d: Bad Sector +.sp +This message appears when CP/M finds no disk in the drive, when +the disk is improperly formatted, when the drive latch is open, +or when power to the drive is off. Check for one of these +situations and try again. This could also indicate a hardware +problem or a worn or improperly formatted disk. Press ^C to +terminate the program and return to CP/M, or press RETURN +to ignore the error. +.sp 2 +.ti -15 +Bdos Err On d: File R/O +.sp +You tried to erase, rename, or set file attributes on a Read-Only +file. The file should first be set to Read-Write (R/W) with the +command: STAT filespec $R/W. +.sp 2 +.ti -15 +Bdos Err On d: R/O +.sp +Drive has been assigned Read-Only status with a STAT command, or +the disk in the drive has been changed without being initialized +with a ^C. CP/M terminates the current program as soon as you +press any key. +.sp 2 +.ti -15 +Bdos Err on d: Select +.sp +CP/M received a command line specifying a nonexistent drive. +CP/M terminates the current program as soon as you press any key. +Press RETURN or CTRL-C to recover. +.sp 2 +.ti -15 +Break "x" at c +.sp +ED. "x" is one of the symbols described below and c is the +command letter being executed when the error occurred. +.sp +.in 24 +.ti -4 +# Search failure. ED cannot find the string specified in an F, +S, or N command. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 24 +.ti -4 +? Unrecognized command letter c. ED does not recognize the +indicated command letter, or an E, H, Q, or O command is not +alone on its command line. +.sp +.ti -4 +O The file specified in an R command cannot be found. +.sp +.ti -4 +> Buffer full. ED cannot put any more characters in the memory +buffer, or the string specified in an F, N, or S command is too +long. +.sp +.ti -4 +E Command aborted. A keystroke at the console aborted command +execution. +.sp +Break "x" at c (continued) +.sp +.ti -4 +F Disk or directory full. This error is followed by either the +disk or directory full message. Refer to the recovery procedures +listed under these messages. +.sp 2 +.in 20 +.ti -15 +CANNOT CLOSE DESTINATION FILE--{filespec} +.sp +PIP. An output file cannot be closed. You should take +appropriate action after checking to see if the correct disk is +in the drive and that the disk is not write-protected. +.sp 2 +.nf +.in 5 +Cannot close, R/O +CANNOT CLOSE FILES +.fi +.in 20 +.sp +CP/M cannot write to the file. This usually occurs because the +disk is write-protected. +.sp +ASM. An output file cannot be closed. This is a fatal error +that terminates ASM execution. Check to see that the disk is in +the drive, and that the disk is not write-protected. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +DDT. The disk file written by a W command cannot be closed. +This is a fatal error that terminates DDT execution. Check if +the correct disk is in the drive and that the disk is not write-protected. +.sp +SUBMIT. This error can occur during SUBMIT file processing. +Check if the correct system disk is in the A drive and that the +disk is not write-protected. The SUBMIT job can be restarted +after rebooting CP/M. +.sp 2 +.ti -15 +CANNOT READ +.sp +PIP. PIP cannot read the specified source. Reader cannot be +implemented. +.sp 2 +.ti -15 +CANNOT WRITE +.sp +PIP. The destination specified in the PIP command is illegal. +You probably specified an input device as a destination. +.sp 2 +.ti -15 +Checksum error +.sp +PIP. A HEX record checksum error was encountered. The HEX +record that produced the error must be corrected, probably by +recreating the HEX file. +.sp 2 +.nf +.in 5 +CHECKSUM ERROR +LOAD ADDRESS hhhh +ERROR ADDRESS hhhh +BYTES READ: +hhhh: +.fi +.in 20 +.sp +LOAD. File contains incorrect data. Regenerate HEX file from +the source. +.sp 2 +.ti -15 +Command Buffer Overflow +.sp +SUBMIT. The SUBMIT buffer allows up to 2048 characters in the +input file. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +Command too long +.sp +SUBMIT. A command in the SUBMIT file cannot exceed 125 +characters. +.sp 2 +.ti -15 +CORRECT ERROR, TYPE RETURN OR CTRL-Z +.sp +PIP. A HEX record checksum was encountered during the transfer +of a HEX file. The HEX file with the checksum error should be +corrected, probably by recreating the HEX file. +.sp 2 +.ti -15 +DESTINATION IS R/O, DELETE (Y/N)? +.sp +PIP. The destination file specified in a PIP command already +exists and it is Read-Only. If you type Y, the destination file +is deleted before the file copy is done. +.sp 2 +.ti -15 +Directory full +.sp +ED. There is not enough directory space for the file being +written to the destination disk. You can use the OXfilespec +command to erase any unnecessary files on the disk without +leaving the editor. +.sp +SUBMIT. There is not enough directory space to write the $$$.SUB +file used for processing SUBMITs. Erase some files or select a +new disk and retry. +.sp 2 +.ti -15 +Disk full +.sp +ED. There is not enough disk space for the output file. This +error can occur on the W, E, H, or X commands. If it occurs with +X command, you can repeat the command prefixing the filename with +a different drive. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +DISK READ ERROR--{filespec} +.sp +PIP. The input disk file specified in a PIP command cannot be +read properly. This is usually the result of an unexpected end-of-file. +Correct the problem in your file. +.sp 2 +.ti -15 +DISK WRITE ERROR--{filespec} +.sp +DDT. A disk write operation cannot be successfully performed +during a W command, probably due to a full disk. You should +either erase some unnecessary files or get another disk with more +space. +.sp +PIP. A disk write operation cannot be successfully performed +during a PIP command, probably due to a full disk. You should +either erase some unnecessary files or get another disk with more +space and execute PIP again. +.sp +SUBMIT. The SUBMIT program cannot write the $$$.SUB file to the +disk. Erase some files, or select a new disk and try again. +.sp 2 +.ti -15 +ERROR: BAD PARAMETER +.sp +PIP. You entered an illegal parameter in a PIP command. Retype +the entry correctly. +.sp 2 +.ti -15 +ERROR: CANNOT OPEN SOURCE, LOAD ADDRESS hhhh +.sp +LOAD. Displayed if LOAD cannot find the specified file or if no +filename is specified. +.sp 2 +.ti -15 +ERROR: CANNOT CLOSE FILE, LOAD ADDRESS hhhh +.sp +LOAD. Caused by an error code returned by a BDOS function call. +Disk might be write-protected. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +ERROR: CANNOT OPEN SOURCE, LOAD ADDRESS hhhh +.sp +LOAD. Cannot find source file. Check disk directory. +.sp 2 +.ti -15 +ERROR: DISK READ, LOAD ADDRESS hhhh +.sp +LOAD. Caused by an error code returned by a BDOS function call. +.sp 2 +.ti -15 +ERROR: DISK WRITE, LOAD ADDRESS hhhh +.sp +LOAD. Destination disk is full. +.sp 2 +.ti -15 +ERROR: INVERTED LOAD ADDRESS, LOAD ADDRESS hhhh +.sp +LOAD. The address of a record was too far from the address of +the previously-processed record. This is an internal limitation +of LOAD, but it can be circumvented. Use DDT to read the HEX +file into memory, then use a SAVE command to store the memory +image file on disk. +.sp 2 +.ti -15 +ERROR: NO MORE DIRECTORY SPACE, LOAD ADDRESS hhhh +.sp +LOAD. Disk directory is full. +.sp 2 +.ti -15 +Error on line nnn message +.sp +SUBMIT. The SUBMIT program displays its messages in the format +shown above, where nnn represents the line number of the SUBMIT +file. Refer to the message following the line number. +.sp 2 +.ti -15 +FILE ERROR +.sp +ED. Disk or directory is full, and ED cannot write anything more +on the disk. This is a fatal error, so make sure there is enough +space on the disk to hold a second copy of the file before +invoking ED. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +FILE EXISTS +.sp +You have asked CP/M to create or rename a file using a file +specification that is already assigned to another file. Either +delete the existing file or use another file specification. +.sp +REN. The new name specified is the name of a file that already +exists. You cannot rename a file with the name of an existing +file. If you want to replace an existing file with a newer +version of the same file, either rename or erase the existing +file, or use the PIP utility. +.sp 2 +.ti -15 +File exists, erase it +.sp +ED. The destination filename already exists when you are placing +the destination file on a different disk than the source. It +should be erased or another disk selected to receive the output +file. +.sp 2 +.ti -15 +** FILE IS READ/ONLY ** +.sp +ED. The file specified in the command to invoke ED has the +Read-Only attribute. Ed can read the file so that the user can +examine it, but ED cannot change a Read-Only file. +.sp 2 +.mb 4 +.fm 1 +.ti -15 +File Not Found +.sp +CP/M cannot find the specified file. Check that you have entered +the correct drive specification or that you have the correct disk +in the drive. +.sp +ED. ED cannot find the specified file. Check that you have +entered the correct drive specification or that you have the +correct disk in the drive. +.sp +STAT. STAT cannot find the specified file. The message might +appear if you omit the drive specification. Check to see if the +correct disk is in the drive. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +FILE NOT FOUND--{filespec} +.sp +.mb 6 +.fm 2 +PIP. An input file that you have specified does not exist. +.sp 2 +.ti -15 +Filename required +.sp +ED. You typed the ED command without a filename. Reenter the ED +command followed by the name of the file you want to edit or +create. +.sp 2 +.ti -15 +hhhh??=dd +.sp +DDT. The ?? indicates DDT does not know how to represent the +hexadecimal value dd encountered at address hhhh in 8080 assembly +language. dd is not an 8080 machine instruction opcode. +.sp 2 +.ti -15 +Insufficient memory +.sp +DDT. There is not enough memory to load the file specified in an +R or E command. +.sp 2 +.ti -15 +Invalid Assignment +.sp +STAT. You specified an invalid drive or file assignment, or +misspelled a device name. This error message might be followed +by a list of the valid file assignments that can follow a +filename. If an invalid drive assignment was attempted the +message Use: d:=RO is displayed, showing the proper syntax for +drive assignments. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +Invalid control character +.sp +SUBMIT. The only valid control characters in the SUBMIT files of +the type SUB are ^ A through ^ Z. Note that in a SUBMIT file the +control character is represented by typing the circumflex, ^, not +by pressing the control key. +.sp 2 +.ti -15 +INVALID DIGIT--{filespec} +.sp +PIP. An invalid HEX digit has been encountered while reading a +HEX file. The HEX file with the invalid HEX digit should be +corrected, probably by recreating the HEX file. +.sp 2 +.ti -15 +Invalid Disk Assignment +.sp +STAT. Might appear if you follow the drive specification with +anything except =R/O. +.sp 2 +.ti -15 +INVALID DISK SELECT +.sp +CP/M received a command line specifying a nonexistent drive, or +the disk in the drive is improperly formatted. CP/M terminates +the current program as soon as you press any key. +.sp 2 +.ti -15 +INVALID DRIVE NAME (Use A, B, C, or D) +.sp +SYSGEN. SYSGEN recognizes only drives A, B, C, and D as valid +destinations for system generation. +.sp 2 +.ti -15 +Invalid File Indicator +.sp +STAT. Appears if you do not specify RO, RW, DIR, or SYS. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +INVALID FORMAT +.sp +PIP. The format of your PIP command is illegal. See the +description of the PIP command. +.sp 2 +.nf +.in 5 +INVALID HEX DIGIT +LOAD ADDRESS hhhh +ERROR ADDRESS hhhh +BYTES READ: +hhhh +.fi +.in 20 +.sp +LOAD. File contains incorrect HEX digit. +.sp 2 +.ti -15 +INVALID MEMORY SIZE +.sp +MOVCPM. Specify a value less than 64K or your computer's actual +memory size. +.sp 2 +.ti -15 +INVALID SEPARATOR +.sp +PIP. You have placed an invalid character for a separator +between two input filenames. +.sp 2 +.ti -15 +INVALID USER NUMBER +.sp +PIP. You have specified a user number greater than 15. User +numbers are in the range 0 to 15. +.sp 2 +.ti -15 +n? +.sp +USER. You specified a number greater than fifteen for a user +area number. For example, if you type USER 18, the screen +displays 18?. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +NO DIRECTORY SPACE +.sp +ASM. The disk directory is full. Erase some files to make room +for PRN and HEX files. The directory can usually hold only 64 +filenames. +.sp 2 +.ti -15 +NO DIRECTORY SPACE--{filespec} +.sp +PIP. There is not enough directory space for the output file. +You should either erase some unnecessary files or get another +disk with more directory space and execute PIP again. +.sp 2 +.ti -15 +NO FILE--{filespec} +.sp +DIR, ERA, REN, PIP. CP/M cannot find the specified file, or no +files exist. +.sp +ASM. The indicated source or include file cannot be found on the +indicated drive. +.sp +DDT. The file specified in an R or E command cannot be found on +the disk. +.sp 2 +.ti -15 +NO INPUT FILE PRESENT ON DISK +.sp +DUMP. The file you requested does not exist. +.sp 2 +.ti -15 +No memory +.sp +There is not enough (buffer?) memory available for loading the +program specified. +.sp 2 +.ti -15 +NO SOURCE FILE ON DISK +.sp +SYSGEN. SYSGEN cannot find CP/M either in CPMxx.com form or on +the system tracks of the source disk. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +NO SOURCE FILE PRESENT +.sp +ASM. The assembler cannot find the file you specified. Either +you mistyped the file specification in your command line, or the +filetype is not ASM. +.sp 2 +.ti -15 +NO SPACE +.sp +SAVE. Too many files are already on the disk, or no room is left +on the disk to save the information. +.sp 2 +.ti -15 +No SUB file present +.sp +SUBMIT. For SUBMIT to operate properly, you must create a file +with filetype of SUB. The SUB file contains usual CP/M commands. +Use one command per line. +.sp 2 +.ti -15 +NOT A CHARACTER SOURCE +.sp +PIP. The source specified in your PIP command is illegal. You +have probably specified an output device as a source. +.sp 2 +.ti -15 +** NOT DELETED ** +.sp +PIP. PIP did not delete the file, which might have had the R/O +attribute. +.sp 2 +.ti -15 +NOT FOUND +.sp +PIP. PIP cannot find the specified file. +.sp 2 +.ti -15 +OUTPUT FILE WRITE ERROR +.sp +ASM. You specified a write-protected disk as the destination for +the PRN and HEX files, or the disk has no space left. Correct +the problem before assembling your program. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +Parameter error +.sp +SUBMIT. Within the SUBMIT file of type sub, valid parameters are +$0 through $9. +.sp 2 +.ti -15 +PARAMETER ERROR, TYPE RETURN TO IGNORE +.sp +SYSGEN. If you press RETURN, SYSGEN proceeds without processing +the invalid parameter. +.sp 2 +.ti -15 +QUIT NOT FOUND +.sp +PIP. The string argument to a Q parameter was not found in your +input file. +.sp 2 +.ti -15 +Read error +.sp +TYPE. An error occurred when reading the file specified in the +type command. Check the disk and try again. The STAT filespec +command can diagnose trouble. +.sp 2 +.ti -15 +READER STOPPING +.sp +PIP. Reader operation interrupted. +.sp 2 +.ti -15 +Record Too Long +.sp +PIP. PIP cannot process a record longer than 128 bytes. +.sp 2 +.ti -15 +Requires CP/M 2.0 or later +.sp +XSUB. XSUB requires the facilities of CP/M 2.0 or newer version. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +Requires CP/M 2.0 or new for operation +.sp +PIP. This version of PIP requires the facilities of CP/M 2.0 or +newer version. +.sp 2 +.ti -15 +START NOT FOUND +.sp +PIP. The string argument to an S parameter cannot be found in +the source file. +.sp 2 +.ti -15 +SOURCE FILE INCOMPLETE +.sp +SYSGEN. SYSGEN cannot use your CP/M source file. +.sp 2 +.ti -15 +SOURCE FILE NAME ERROR +.sp +ASM. When you assemble a file, you cannot use the wildcard +characters * and ? in the filename. Only one file can be +assembled at a time. +.sp 2 +.ti -15 +SOURCE FILE READ ERROR +.sp +ASM. The assembler cannot understand the information in the file +containing the assembly-language program. Portions of another +file might have been written over your assembly-language file, or +information was not properly saved on the disk. Use the TYPE +command to locate the error. Assembly-language files contain the +letters, symbols, and numbers that appear on your keyboard. If +your screen displays unrecognizable output or behaves strangely, +you have found where computer instructions have crept into your +file. +.sp 2 +.ti -15 +SYNCHRONIZATION ERROR +.sp +MOVCPM. The MOVCPM utility is being used with the wrong CP/M +system. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +"SYSTEM" FILE NOT ACCESSIBLE +.sp +You tried to access a file set to SYS with the STAT command. +.sp 2 +.ti -15 +** TOO MANY FILES ** +.sp +STAT. There is not enough memory for STAT to sort the files +specified, or more than 512 files were specified. +.sp 2 +.ti -15 +UNEXPECTED END OF HEX FILE--{filespec} +.sp +PIP. An end-of-file was encountered prior to a termination HEX +record. The HEX file without a termination record should be +corrected, probably by recreating the HEX file. +.sp 2 +.ti -15 +Unrecognized Destination +.sp +PIP. Check command line for valid destination. +.sp 2 +.ti -15 +Use: STAT d:=RO +.sp +STAT. An invalid STAT drive command was given. The only valid +drive assignment in STAT is STAT d:=RO. +.sp 2 +.ti -15 +VERIFY ERROR:--{filespec} +.sp +PIP. When copying with the V option, PIP found a difference when +rereading the data just written and comparing it to the data in +its memory buffer. Usually this indicates a failure of either +the destination disk or drive. +.sp 2 +.ti -15 +WRONG CP/M VERSION (REQUIRES 2.0) +.sp 2 +.ti -15 +XSUB ACTIVE +.sp +SUBMIT. XSUB has been invoked. +.in 0 +.bp +.sh + Table I-1. (continued) +.sp +.nf + Message Meaning +.fi +.sp +.in 20 +.ti -15 +XSUB ALREADY PRESENT +.sp +SUBMIT. XSUB is already active in memory. +.sp +.ti -15 +Your input? +.sp +If CP/M cannot find the command you specified, it returns the +command name you entered followed by a question mark. Check that +you have typed the command line correctly, or that the command +you requested exists as a .COM file on the default or specified +disk. +.in 0 +.ll 65 +.sp 2 +.ce +End of Appendix I + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/cpm22tex.zip b/Source/Doc/CPM 22 Manual/cpm22tex.zip new file mode 100644 index 00000000..6248e534 Binary files /dev/null and b/Source/Doc/CPM 22 Manual/cpm22tex.zip differ diff --git a/Source/Doc/CPM 22 Manual/fivea.tex b/Source/Doc/CPM 22 Manual/fivea.tex new file mode 100644 index 00000000..cbd6b8f5 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/fivea.tex @@ -0,0 +1,671 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 5-% +.pc 1 +.ce +.sh +Section 5 +.qs +.sp +.ce +.sh +CP/M 2 System Interface +.qs +.tc 5 CP/M 2 System Interface +.sp 2 +.he CP/M Operating System Manual 5.1 Introduction +.tc 5.1 Introduction +5.1 Introduction +.fi +.pp 5 +This chapter describes CP/M (release 2) system organization including the +structure of memory and system entry points. This section provides +the information you need to write programs that operate under CP/M and +that use the peripheral and disk I/O facilities of the system. +.pp +CP/M is logically divided into four parts, called the Basic Input/Output +System (BIOS), the Basic Disk Operating System (BDOS), the Console Command +Processor (CCP), and the Transient Program Area (TPA). The BIOS is a +hardware-dependent module that defines the exact low level interface with a +particular computer system that is necessary for peripheral device I/O. +Although a standard BIOS is supplied by Digital Research, explicit +instructions are provided for field reconfiguration of the BIOS to match +nearly any hardware environment, see Section 6. +.pp +The BIOS and BDOS are +logically combined into a single module with a common entry point and +referred to as the FDOS. The CCP is a distinct program that uses the FDOS to +provide a human-oriented interface with the information that is cataloged on +the back-up storage device. The TPA is an area of memory, +not used by the FDOS and CCP, where various nonresident operating +system commands and user programs are executed. The lower portion of memory +is reserved for system information and is detailed in later sections. Memory +organization of the CP/M system is shown in Figure 5-1. +.sp 3 +.nf + High + Memory FDOS (BDOS+BIOS) + FBASE: + + CCP + CBASE: + + TPA + TBASE: + + System Parameters + BOOT: +.sp 2 +.ce +.sh +Figure 5-1. CP/M Memory Organization +.qs +.fi +.sp 2 +.pp +The exact memory addresses corresponding to BOOT, TBASE, CBASE, and FBASE +vary from version to version and are described fully in Section 6. All +standard CP/M versions assume BOOT=0000H, which is the base of +random access memory. The machine code found at location BOOT performs a +system warm start, which loads and initializes the programs and variables +necessary to return control to the CCP. Thus, transient programs need only +jump to location BOOT to return control to CP/M at the command level. +Further, the standard versions assume TBASE=BOOT+0100H, which is normally +location 0100H. The principal entry point to the FDOS is at location +BOOT+0005H (normally 0005H) where a jump to FBASE is found. The address +field at BOOT+0006H (normally 0006H) contains the value of FBASE and can be +used to determine the size of available memory, assuming that the CCP is +being overlaid by a transient program. +.pp +Transient programs are loaded into the TPA and executed as follows. The +operator communicates with the CCP by typing command lines following each +prompt. Each command line takes one of the following forms: +.sp +.nf +.in 8 +command +command file1 +command file1 file2 +.fi +.in 0 +.sp +where command is either a built-in function, such as DIR or TYPE, or the name +of a transient command or program. If the command is a built-in function of +CP/M, it is executed immediately. Otherwise, the CCP searches the currently +addressed disk for a file by the name +.sp +.ti 8 +command.COM +.pp +If the file is found, it is assumed to be a memory image of a program that +executes in the TPA and thus implicity originates at TBASE in memory. The +CCP loads the COM file from the disk into memory starting at TBASE and can +extend up to CBASE. +.pp +If the command is followed by one or two file specifications, the CCP prepares +one or two File Control Block (FCB) names in the system +parameter area. These optional FCBs are in the form necessary to +access files through the FDOS and are described in Section 5.2. +.pp +The transient program receives control from the CCP and begins +execution, using the I/O facilities of the FDOS. The transient +program is called from the CCP. Thus, it can simply return to the CCP upon +completion of its processing, or can jump to BOOT to pass control back to +CP/M. In the first case, the transient program must not use memory above +CBASE, while in the latter case, memory up through FBASE-1 can be used. +.pp +The transient program can use the CP/M I/O facilities to communicate with the +operator's console and peripheral devices, including the disk subsystem. The +I/O system is accessed by passing a function number and an information address +to CP/M through the FDOS entry point at BOOT+0005H. In the case of a disk +read, for example, the transient program sends the number corresponding to a +disk read, along with the address of an FCB to the CP/M FDOS. The FDOS, in +turn, performs the operation and returns with either a disk read completion +indication or an error number indicating that the disk read was unsuccessful. +.sp 2 +.tc 5.2 Operating System Call Conventions +.he CP/M Operating System Manual 5.2 Call Conventions +.sh +5.2 Operating System Call Conventions +.qs +.pp +This section provides detailed information for performing direct operating +system calls from user programs. Many of the functions listed below, however, +are accessed more simply through the I/O macro library provided with the +MAC macro assembler and listed in the Digital Research manual +entitled, \c +.ul +Programmer's Utilities Guide for the CP/M Family of Operating Systems. +.qu +.pp +CP/M facilities that are available for access by transient programs fall into +two general categories: simple device I/O and disk file I/O. The simple +device operations are +.sp +.nf +.in 5 +.ti -2 +o read a console character +.ti -2 +o write a console character +.ti -2 +o read a sequential character +.ti -2 +o write a sequential character +.ti -2 +o get or set I/O status +.ti -2 +o print console buffer +.ti -2 +o interrogate console ready +.sp +The following FDOS operations perform disk I/O: +.sp +.ti -2 +o disk system reset +.ti -2 +o drive selection +.ti -2 +o file creation +.ti -2 +o file close +.ti -2 +o directory search +.ti -2 +o file delete +.ti -2 +o file rename +.ti -2 +o random or sequential read +.ti -2 +o random or sequential write +.ti -2 +o interrogate available disks +.ti -2 +o interrogate selected disk +.ti -2 +o set DMA address +.ti -2 +o set/reset file indicators. +.fi +.in 0 +.pp +As mentioned above, access to the FDOS functions is accomplished by passing +a function number and information address through the primary point at +location BOOT+0005H. In general, the function number is passed in register C +with the information address in the double byte pair DE. Single byte values +are returned in register A, with double byte values returned in HL, a zero +value is returned when the function number is out of range. For reasons of +compatibility, register A = L and register B = H upon return in all cases. +Note that the register passing conventions of CP/M agree with +those of the Intel PL/M systems programming language. CP/M functions and +their numbers are listed below. +.bp +.nf +.in 5 + O System Reset 19 Delete File + 1 Console Input 20 Read Sequential + 2 Console Output 21 Write Sequential + 3 Reader Input 22 Make File + 4 Punch Output 23 Rename File + 5 List Output 24 Return Login Vector + 6 Direct Console I/O 25 Return Current Disk + 7 Get I/O Byte 26 Set DMA Address + 8 Set I/O Byte 27 Get Addr(Alloc) + 9 Print String 28 Write Protect Disk +10 Read Console Buffer 29 Get R/0 Vector +11 Get Console Status 30 Set File Attributes +12 Return Version Number 31 Get Addr(Disk Parms) +13 Reset Disk System 32 Set/Get User Code +14 Select Disk 33 Read Random +15 Open File 34 Write Random +16 Close File 35 Compute File Size +17 Search for First 36 Set Random Record +18 Search for Next 37 Reset Drive + 40 Write Random with Zero Fill +.fi +.in 0 +.sp +.pp +Functions 28 and 32 should be avoided in application programs to +maintain upward compatibility with CP/M. +.pp +Upon entry to a transient program, the CCP leaves the stack +pointer set to an eight-level stack area with the CCP return +address pushed onto the stack, leaving seven levels before +overflow occurs. Although this stack is usually not used by a +transient program (most transients return to the CCP +through a jump to location 0000H) it is large enough to +make CP/M system calls because the FDOS switches to a local stack +at system entry. For example, the assembly-language program segment below +reads characters continuously until an asterisk is +encountered, at which time control returns to the CCP, assuming a +standard CP/M system with BOOT = 0000H. +.sp 2 +.nf +.in 8 +BDOS EQU 0005H ;STANDARD CP/M ENTRY +CONIN EQU 1 ;CONSOLE INPUT FUNCTION +; + ORG 0100H ;BASE OF TPA +NEXTC: MVI C,CONIN ;READ NEXT CHARACTER + CALL BDOS ;RETURN CHARACTER IN + CPI '*' ;END OF PROCESSING? + JNZ NEXTC ;LOOP IF NOT + RET ;RETURN TO CCP + END +.fi +.in 0 +.sp +.pp +CP/M implements a named file structure on each disk, providing a +logical organization that allows any particular file to contain +any number of records from completely empty to the full capacity +of the drive. Each drive is logically distinct with a disk +directory and file data area. The disk filenames are in three +parts: the drive select code, the filename (consisting of one to +eight nonblank characters), and the filetype (consisting of zero +to three nonblank characters). The filetype names the generic +category of a particular file, while the filename distinguishes +individual files in each category. The filetypes listed in Table 5-1 +name a few generic categories that have been established, +although they are somewhat arbitrary. +.sp 2 +.sh + Table 5-1. CP/M Filetypes +.qs +.sp +.nf + Filetype Meaning +.sp +.in 30 +.ti -11 +ASM Assembler Source +.ti -11 +PRN Printer Listing +.ti -11 +HEX Hex Machine Code +.ti -11 +BAS Basic Source File +.ti -11 +INT Intermediate Code +.ti -11 +COM Command File +.ti -11 +PLI PL/I Source File +.ti -11 +REL Relocatable Module +.ti -11 +TEX TEX Formatter Source +.ti -11 +BAK ED Source Backup +.ti -11 +SYM SID Symbol File +.ti -11 +$$$ Temporary File +.fi +.in 0 +.sp +.pp +Source files are treated as a sequence of ASCII characters, where +each line of the source file is followed by a carriage return, and +line-feed sequence (0DH followed by 0AH). Thus, one 128-byte CP/M +record can contain several lines of source text. The end of an +ASCII file is denoted by a CTRL-Z character (1AH) or a real +end-of-file returned by the CP/M read operation. CTRL-Z characters embedded +within machine code files (for example, COM files) are ignored and +the end-of-file condition returned by CP/M is used to terminate +read operations. +.pp +Files in CP/M can be thought of as a sequence of up to 65536 +records of 128 bytes each, numbered from 0 through 65535, thus +allowing a maximum of 8 megabytes per file. Note, however, +that although the records may be considered logically +contiguous, they may not be physically contiguous in the disk +data area. Internally, all files are divided into 16K byte +segments called logical extents, so that counters are easily +maintained as 8-bit values. The division into extents is +discussed in the paragraphs that follow: however, they are not +particularly significant for the programmer, because each extent is +automatically accessed in both sequential and random access +modes. +.pp +In the file operations starting with Function 15, DE +usually addresses a FCB. Transient programs +often use the default FCB area reserved by CP/M at +location BOOT+005CH (normally 005CH) for simple file operations. +The basic unit of file information is a 128-byte record used for +all file operations. Thus, a default location for disk I/O is +provided by CP/M at location BOOT+0080H (normally 0080H) which +is the initial default DMA address. See Function 26. +.pp +All directory operations take place in a reserved area that does not +affect write buffers as was the case in release 1, with the +exception of Search First and Search Next, where compatibility is +required. +.pp +The FCB data area consists of a sequence of 33 bytes for +sequential access and a series of 36 bytes in the case when the +file is accessed randomly. The default FCB, normally located at +005CH, can be used for random access files, because the three bytes +starting at BOOT+007DH are available for this purpose. Figure 5-2 shows +the FCB format with the following fields. +.sp 3 +.nf + dr f1 f2 / / f8 t1 t2 t3 ex s1 s2 rc d0 / / dn cr r0 r1 r2 + 00 01 02 ... 08 09 10 11 12 13 14 15 16 ... 31 32 33 34 35 +.fi +.sp 2 +.sh + Figure 5-2. File Control Block Format +.sp 3 +The following table lists and describes each of the fields in the File Control +Block figure. +.sp 2 +.sh + Table 5-2. File Control Block Fields +.nf +.sp + Field Definition +.sp + dr drive code (0-16) + 0 = use default drive for file + 1 = auto disk select drive A, + 2 = auto disk select drive B, + . + . + . + 16= auto disk select drive P. +.sp + f1...f8 contain the filename in ASCII + upper-case, with high bit = 0 +.sp + t1, t2, t3 contain the filetype in ASCII + upper-case, with high bit = 0 + t1', t2', and t3' denote the + bit of these positions, + t1' = 1 =>Read-Only file, + t2' = 1 =>SYS file, no DIR list +.sp + ex contains the current extent + number, normally set to 00 by + the user, but in range 0-31 + during file I/O +.bp +.sh + Table 5-2. (continued) +.qs +.sp + Field Definition +.sp + s1 reserved for internal system use +.sp + s2 reserved for internal system use, + set to zero on call to OPEN, MAKE, + SEARCH +.sp + rc record count for extent ex; + takes on values from 0-127 +.sp + d0...dn filled in by CP/M; reserved for + system use +.sp + cr current record to read or write in + a sequential file operation; + normally set to zero by user +.sp + r0, r1, r2 optional random record number in + the range 0-65535, with overflow + to r2, r0, r1 constitute a 16-bit + value with low byte r0, and high + byte r1 +.fi +.sp +.pp +Each file being accessed through CP/M must have a corresponding +FCB, which provides the name and allocation information for all +subsequent file operations. When accessing files, it is the +programmer's responsibility to fill the lower 16 bytes of the FCB +and initialize the cr field. Normally, bytes 1 through 11 are +set to the ASCII character values for the filename and filetype, +while all other fields are zero. +.pp +FCBs are stored in a directory area of the disk, and are brought +into central memory before the programmer proceeds with file +operations (see the OPEN and MAKE functions). The memory copy of +the FCB is updated as file operations take place and later +recorded permanently on disk at the termination of the file +operation, (see the CLOSE command). +.pp +The CCP constructs the first 16 bytes of two optional FCBs for a +transient by scanning the remainder of the line following the +transient name, denoted by file1 and file2 in the prototype +command line described above, with unspecified fields set to +ASCII blanks. The first FCB is constructed at location +BOOT+005CH and can be used as is for subsequent file operations. +The second FCB occupies the d0...dn portion of the first FCB and +must be moved to another area of memory before use. If, for +example, the following command line is typed: +.sp +.ti 8 +PROGNAME B:X.ZOT Y.ZAP +.bp +the file PROGNAME.COM is loaded into the TPA, and the default FCB +at BOOT+005CH is initialized to drive code 2, filename X, and +filetype ZOT. The second drive code takes the default value 0, +which is placed at BOOT-006CH, with the filename Y placed into +location BOOT+006DH and filetype ZAP located 8 bytes later at +BOOT+0075H. All remaining fields through cr are set to zero. +Note again that it is the programmer's +responsibility to move this second filename and filetype to another +area, usually a separate file control block, before opening the +file that begins at BOOT+005CH, because the open operation +overwrites the second name and type. +.pp +If no filenames are specified in the original command, the +fields beginning at BOOT+005DH and BOOT+006DH contain blanks. In +all cases, the CCP translates lower-case alphabetics to upper-case +to be consistent with the CP/M file naming conventions. +.pp +As an added convenience, the default buffer area at location +BOOT+0080H is initialized to the command line tail typed by the +operator following the program name. The first position contains +the number of characters, with the characters themselves +following the character count. Given the above command line, the +area beginning at BOOT+0080H is initialized as follows: +.sp 2 +.nf +.in 5 +BOOT+0080H: +.sp ++00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +A +B +C +D +E +E '' 'B' ':' 'X' '.' 'Z' 'O' 'T' '' 'Y' '.' 'Z' 'A' 'P' +.fi +.in 0 +.sp 2 +where the characters are translated to upper-case ASCII with +uninitialized memory following the last valid character. Again, +it is the responsibility of the programmer to extract the +information from this buffer before any file operations are +performed, unless the default DMA address is explicitly changed. +.pp +Individual functions are described in detail in the pages that +follow. +.bp +.sp 4 +.nf + FUNCTION 0: SYSTEM RESET +.sp + Entry Parameters: + Register C: 00H +.fi +.sp 2 +.pp +The System Reset function returns control to the CP/M operating +system at the CCP level. The CCP reinitializes the disk +subsystem by selecting and logging-in disk drive A. This +function has exactly the same effect as a jump to location BOOT. +.sp 6 +.nf + FUNCTION 1: CONSOLE INPUT +.sp + Entry Parameters: + Register C: 01H +.sp + Returned Value: + Register A: ASCII Character +.fi +.sp 2 +.pp +The Console Input function reads the next console character to +register A. Graphic characters, along with carriage return, line-feed, +and back space (CTRL-H) are echoed to the console. Tab +characters, CTRL-I, move the cursor to the next tab stop. A check +is made for start/stop scroll, CTRL-S, and start/stop printer echo, +CTRL-P. The FDOS does not return to the calling program until a +character has been typed, thus suspending execution if a +character is not ready. +.bp +.sp 4 +.nf + FUNCTION 2: CONSOLE OUTPUT +.sp + Entry Parameters + Register C: 02H + Register E: ASCII Character +.fi +.sp 2 +.pp +The ASCII character from register E is sent to the console +device. As in Function 1, tabs are expanded and checks are made +for start/stop scroll and printer echo. +.sp 6 +.nf + FUNCTION 3: READER INPUT +.sp + Entry Parameters: + Register C: 03H +.sp + Returned Value: + Register A: ASCII Character +.fi +.sp 2 +.pp +The Reader Input function reads the next character from the +logical reader into register A. See the IOBYTE definition in +Chapter 6. Control does not return until the character has been +read. +.bp +.sp 4 +.nf + FUNCTION 4: PUNCH OUTPUT +.sp + Entry Parameters: + Register C: 04H + register E: ASCII Character +.fi +.sp 2 +.pp +The Punch Output function sends the character from register E to +the logical punch device. +.sp 6 +.nf + FUNCTION 5: LIST OUTPUT +.sp + Entry Parameters: + Register C: 05H + Register E: ASCII Character +.fi +.sp 2 +.pp +The List Output function sends the ASCII character in register E +to the logical listing device. +.bp +.sp 4 +.nf + FUNCTION 6: DIRECT CONSOLE I/O +.sp + Entry Parameters: + Register C: 06H + Register E: 0FFH (input) or + char (output) +.sp + Returned Value: + Register A: char or status +.fi +.sp 2 +.pp +Direct Console I/O is supported under CP/M for those specialized +applications where basic console input and output are required. +Use of this function should, in general, be avoided since it +bypasses all of the CP/M normal control character functions (for example, +CTRL-S and CTRL-P). Programs that perform direct I/O +through the BIOS under previous releases of CP/M, however, should +be changed to use direct I/O under BDOS so that they can be fully +supported under future releases of MP/M \ and CP/M. +.pp +Upon entry to Function 6, register E either contains hexadecimal +FF, denoting a console input request, or an ASCII character. If +the input value is FF, Function 6 returns A = 00 if no character +is ready, otherwise A contains the next console input character. +.pp +If the input value in E is not FF, Function 6 assumes that E +contains a valid ASCII character that is sent to the console. +.pp +Function 6 must not be used in conjunction with other console I/O +functions. +.sp 6 +.nf + FUNCTION 7: GET I/O BYTE +.sp + Entry Parameters: + Register C: 07H +.sp + Returned Value: + Register A: I/O Byte Value +.fi +.sp 2 +.pp +The Get I/O Byte function returns the current value of IOBYTE in +register A. See Chapter 6 for IOBYTE definition. +.bp +.sp 4 +.nf + FUNCTION 8: SET I/O BYTE +.sp + Entry Parameters: + Register C: 08H + Register E: I/O Byte Value +.fi +.sp 2 +.pp +The SET I/O Byte function changes the IOBYTE value to that given +in register E. +.sp 6 +.nf + FUNCTION 9: PRINT STRING +.sp + Entry Parameters: + Register C: 09H + Registers DE: String Address +.fi +.sp 2 +.pp +The Print String function sends the character string stored in +memory at the location given by DE to the console device, until a +$ is encountered in the string. Tabs are expanded as in Function +2, and checks are made for start/stop scroll and printer echo. +.nx fiveb.tex + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/fiveb.tex b/Source/Doc/CPM 22 Manual/fiveb.tex new file mode 100644 index 00000000..ad1ec089 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/fiveb.tex @@ -0,0 +1,806 @@ +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.bp +.sp 4 +.nf + FUNCTION 10: READ CONSOLE BUFFER +.sp + Entry Parameters: + Register C: 0AH + Registers DE: Buffer Address +.sp + Returned Value: + Console Characters in Buffer +.fi +.sp 2 +.pp +The Read Buffer functions reads a line of edited console input +into a buffer addressed by registers DE. Console input is +terminated when either input buffer overflows or a carriage return +or line-feed is typed. The Read Buffer takes the form: +.sp +.nf +.in 8 +DE:+0 +1 +2 +3 +4 +5 +6 +7 +8 . . .+n +.sp +mx nc c1 c2 c3 c4 c5 c6 c7 ... ?? +.fi +.in 0 +.sp +where mx is the maximum number of characters that the buffer will +hold, 1 to 255, and nc is the number of characters read (set by +FDOS upon return) followed by the characters read from the +console. If nc < mx, then uninitialized positions follow the +last character, denoted by ?? in the above figure. A number of +control functions, summarized in Table 5-3, are recognized during +line editing. +.sp 2 +.sh + Table 5-3. Edit Control Characters +.sp +.nf + Character Edit Control Function +.sp +.fi +.in 8 +rub/del removes and echoes the last character +.sp +CTRL-C reboots when at the beginning of line +.sp +CTRL-E causes physical end of line +.sp +CTRL-H backspaces one character position +.sp +CTRL-J (line feed) terminates input line +.sp +CTRL-M (return) terminates input line +.sp +CTRL-R retypes the current line after new line +.sp +CTRL-U removes current line +.sp +CTRL-X same as CTRL-U +.in 0 +.sp 2 +The user should also note that certain functions that return the +carriage to the leftmost position (for example, CTRL-X) do so only to the +column position where the prompt ended. In earlier releases, the +carriage returned to the extreme left margin. This convention +makes operator data input and line correction more legible. +.bp +.sp 4 +.nf + FUNCTION 11: GET CONSOLE STATUS +.sp + Entry Parameters: + Register C: 0BH +.sp + Returned Value: + Register A: Console Status +.fi +.sp 2 +.pp +The Console Status function checks to see if a character has been +typed at the console. If a character is ready, the value 0FFH is +returned in register A. Otherwise a 00H value is returned. +.sp 6 +.nf + FUNCTION 12: RETURN VERSION NUMBER +.sp + Entry Parameters: + Register C: 0CH +.sp + Returned Value: + Registers HL: Version Number +.fi +.sp 2 +.pp +Function 12 provides information that allows version independent +programming. A two-byte value is returned, with H = 00 +designating the CP/M release (H = 01 for MP/M) and L = 00 for +all releases previous to 2.0. CP/M 2.0 returns a hexadecimal 20 +in register L, with subsequent version 2 releases in the +hexadecimal range 21,22, through 2F. Using Function 12, for +example, the user can write application programs that provide +both sequential and random access functions. +.bp +.sp 4 +.nf + FUNCTION 13: RESET DISK SYSTEM +.sp + Entry Parameters: + Register C: 0DH +.fi +.sp 2 +.pp +The Reset Disk function is used to programmatically restore the +file system to a reset state where all disks are set to +Read-Write. See functions 28 and 29, only disk drive A is +selected, and the default DMA address is reset to BOOT+0080H. +This function can be used, for example, by an application program +that requires a disk change without a system reboot. +.sp 6 +.nf + FUNCTION 14: SELECT DISK +.sp + Entry Parameters: + Register C: 0EH + Register E: Selected Disk +.fi +.sp 2 +.pp +The Select Disk function designates the disk drive named in register +E as the default disk for subsequent file operations, with E = O +for drive A, 1 for drive B, and so on through 15, corresponding to drive +P in a full 16 drive system. The drive is placed in an on-line +status, which activates its directory until the next cold start, +warm start, or disk system reset operation. If the disk medium +is changed while it is on-line, the drive automatically goes to +a Read-Only status in a standard CP/M environment, see Function +28. FCBs that specify drive code zero (dr = 00H) automatically +reference the currently selected default drive. Drive code +values between 1 and 16 ignore the selected default +drive and directly reference drives A through P. +.bp +.sp 4 +.nf + FUNCTION 15: OPEN FILE +.sp + Entry Parameters: + Register C: 0FH + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Open File operation is used to activate a file that currently +exists in the disk directory for the currently active user +number. The FDOS scans the referenced disk directory for a match +in positions 1 through 14 of the FCB referenced by DE (byte s1 is +automatically zeroed) where an ASCII question mark (3FH) matches +any directory character in any of these positions. Normally, no +question marks are included, and bytes ex and s2 of the FCB are +zero. +.pp +If a directory element is matched, the relevant directory +information is copied into bytes d0 through dn of FCB, thus +allowing access to the files through subsequent read and write +operations. The user should note that an existing file must not +be accessed until a successful open operation is completed. Upon +return, the open function returns a directory code with the value +0 through 3 if the open was successful or 0FFH (255 decimal) if +the file cannot be found. If question marks occur in the FCB, +the first matching FCB is activated. Note that the current +record, (cr) must be zeroed by the program if the file is to be +accessed sequentially from the first record. +.bp +.sp 4 +.nf + FUNCTION 16: CLOSE FILE +.sp + Entry Parameters: + Register C: 10H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Close File function performs the inverse of the Open File +function. Given that the FCB addressed by DE has been previously +activated through an open or make function, the close function +permanently records the new FCB in the reference disk directory +see functions 15 and 22. The FCB matching process for the close +is identical to the open function. The directory code returned +for a successful close operation is 0, 1, 2, or 3, while a 0FFH +(255 decimal) is returned if the filename cannot be found in the +directory. A file need not be closed if only read operations +have taken place. If write operations have occurred, the close +operation is necessary to record the new directory information +permanently. +.bp +.sp 4 +.nf + FUNCTION 17: SEARCH FOR FIRST +.sp + Entry Parameters: + Register C: 11H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +Search First scans the directory for a match with the file given +by the FCB addressed by DE. The value 255 (hexadecimal FF) is +returned if the file is not found; otherwise, 0, 1, 2, or 3 is +returned indicating the file is present. When the file is found, +the current DMA address is filled with the record containing the +directory entry, and the relative starting position is A *32 +(that is, rotate the A register left 5 bits, or ADD A five times). +Although not normally required for application programs, the +directory information can be extracted from the buffer at this +position. +.pp +An ASCII question mark (63 decimal, 3F hexadecimal) in any +position from f1 through ex matches the corresponding field of +any directory entry on the default or auto-selected disk drive. +If the dr field contains an ASCII question mark, the auto disk +select function is disabled and the default disk is searched, +with the search function returning any matched entry, allocated +or free, belonging to any user number. This latter function is +not normally used by application programs, but it allows complete +flexibility to scan all current directory values. If the dr +field is not a question mark, the s2 byte is automatically +zeroed. +.bp +.sp 4 +.nf + FUNCTION 18: SEARCH FOR NEXT +.sp + Entry Parameters: + Register C: 12H +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Search Next function is similar to the Search First function, except +that the directory scan continues from the last matched entry. +Similar to Function 17, Function 18 returns the decimal value 255 +in A when no more directory items match. +.sp 6 +.nf + FUNCTION 19: DELETE FILE +.sp + Entry Parameters: + Register C: 13H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Delete File function removes files that match the FCB +addressed by DE. The filename and type may contain ambiguous +references (that is, question marks in various positions), but the +drive select code cannot be ambiguous, as in the Search and +Search Next functions. +.pp +Function 19 returns a decimal 255 if the referenced file or files +cannot be found; otherwise, a value in the range 0 to 3 returned. +.bp +.sp 4 +.nf + FUNCTION 20: READ SEQUENTIAL +.sp + Entry Parameters: + Register C: 14H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +Given that the FCB addressed by DE has been activated through an +Open or Make function, the Read Sequential function reads the +next 128-byte record from the file into memory at the current DMA +address. The record is read from position cr of the extent, and +the cr field is automatically incremented to the next record +position. If the cr field overflows, the next logical extent is +automatically opened and the cr field is reset to zero in +preparation for the next read operation. The value 00H is +returned in the A register if the read operation was successful, +while a nonzero value is returned if no data exist at the next +record position (for example, end-of-file occurs). +.sp 6 +.nf + FUNCTION 21: WRITE SEQUENTAIL +.sp + Entry Parameters: + Register C: 15H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +Given that the FCB addressed by DE has been activated through an +Open or Make function, the Write Sequential +function writes the 128-byte data record at the current DMA +address to the file named by the FCB. The record is placed at +position cr of the file, and the cr field is automatically +incremented to the next record position. If the cr field +overflows, the next logical extent is automatically opened and +the cr field is reset to zero in preparation for the next write +operation. Write operations can take place into an existing +file, in which case, newly written records overlay those that +already exist in the file. Register A = 00H upon return from a +successful write operation, while a nonzero value indicates an +unsuccessful write caused by a full disk. +.bp +.sp 4 +.nf + FUNCTION 22: MAKE FILE +.sp + Entry Parameters: + Register C: 16H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Make File operation is similar to the Open File operation +except that the FCB must name a file that does not exist in the +currently referenced disk directory (that is, the one named +explicitly by a nonzero dr code or the default disk if dr is +zero). The FDOS creates the file and initializes both the +directory and main memory value to an empty file. The programmer +must ensure that no duplicate filenames occur, and a preceding +delete operation is sufficient if there is any possibility of +duplication. Upon return, register A = 0, 1, 2, or 3 if the +operation was successful and 0FFH (255 decimal) if no more +directory space is available. The Make function has the side +effect of activating the FCB and thus a subsequent open is not +necessary. +.sp 6 +.nf + FUNCTION 23: RENAME FILE +.sp + Entry Parameters: + Register C: 17H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Rename function uses the FCB addressed by DE to change all +occurrences of the file named in the first 16 bytes to the file +named in the second 16 bytes. The drive code dr at postion 0 is +used to select the drive, while the drive code for the new +filename at position 16 of the FCB is assumed to be zero. Upon +return, register A is set to a value between 0 and 3 if the +rename was successful and 0FFH (255 decimal) if the first +filename could not be found in the directory scan. +.bp +.sp 4 +.nf + FUNCTION 24: RETURN LOG-IN VECTOR +.sp + Entry Parameters: + Register C: 18H +.sp + Returned Value: + Registers HL: Log-in Vector +.fi +.sp 2 +.pp +The log-in vector value returned by CP/M is a 16-bit value in HL, where the +least significant bit of L corresponds to the first drive A and +the high-order bit of H corresponds to the sixteenth drive, +labeled P. A 0 bit indicates that the drive is not on-line, +while a 1 bit marks a drive that is actively on-line as a result +of an explicit disk drive selection or an implicit drive select +caused by a file operation that specified a nonzero dr field. +The user should note that compatibility is maintained with +earlier releases, because registers A and L contain the same values +upon return. +.sp 6 +.nf + FUNCTION 25: RETURN CURRENT DISK +.sp + Entry Parameters: + Register C: 19H +.sp + Returned Value: + Register A: Current Disk +.fi +.sp 2 +.pp +Function 25 returns the currently selected default disk number in +register A. The disk numbers range from 0 through 15 +corresponding to drives A through P. +.bp +.sp 4 +.nf + FUNCTION 26: SET DMA ADDRESS +.sp + Entry Parameters: + Register C: 1AH + Registers DE: DMA Address +.fi +.sp 2 +.pp +DMA is an acronym for Direct Memory Address, which is often used +in connection with disk controllers that directly access the +memory of the mainframe computer to transfer data to and from the +disk subsystem. Although many computer systems use non-DMA +access (that is, the data is transferred through programmed I/O +operations), the DMA address has, in CP/M, come to mean the +address at which the 128-byte data record resides before a disk +write and after a disk read. Upon cold start, warm start, or +disk system reset, the DMA address is automatically set to +BOOT+0080H. The Set DMA function can be used to change +this default value to address another area of memory where the +data records reside. Thus, the DMA address becomes the value +specified by DE until it is changed by a subsequent Set DMA +function, cold start, warm start, or disk system reset. +.sp 6 +.nf + FUNCTION 27: GET ADDR (ALLOC) +.sp + Entry Parameters: + Register C: 1BH +.sp + Returned Value: + Registers HL: ALLOC Address +.fi +.sp 2 +.pp +An allocation vector is maintained in main memory for each on- +line disk drive. Various system programs use the information +provided by the allocation vector to determine the amount of +remaining storage (see the STAT program). Function 27 returns +the base address of the allocation vector for the currently +selected disk drive. However, the allocation information might be +invalid if the selected disk has been marked Read-Only. Although +this function is not normally used by application programs, +additional details of the allocation vector are found in Chapter +6. +.bp +.sp 4 +.nf + FUNCTION 28: WRITE PROTECT DISK +.sp + Entry Parameters: + Register C: 1CH +.fi +.sp 2 +.pp +The Write Protect Disk function provides temporary write +protection for the currently selected disk. Any attempt to write +to the disk before the next cold or warm start operation produces +the message: +.sp +.ti 8 +BDOS ERR on d:R/O +.sp 6 +.nf + FUNCTION 29: GET READ-ONLY VECTOR +.sp + Entry Parameters: + Register C: 1DH +.sp + Returned Value: + Registers HL: R/O Vector Value +.fi +.sp 2 +.pp +Function 29 returns a bit vector in register pair HL, which +indicates drives that have the temporary Read-Only bit set. As +in Function 24, the least significant bit corresponds to drive A, +while the most significant bit corresponds to drive P. The R/O +bit is set either by an explicit call to Function 28 or by the +automatic software mechanisms within CP/M that detect changed +disks. +.bp +.sp 4 +.nf + FUNCTION 30: SET FILE ATTRIBUTES +.sp + Entry Parameters: + Register C: 1EH + Registers DE: FCB Address +.sp + Returned Value: + Register A: Directory Code +.fi +.sp 2 +.pp +The Set File Attributes function allows programmatic manipulation +of permanent indicators attached to files. In particular, the R/O +and System attributes (t1' and t2') can be set or reset. The DE +pair addresses an unambiguous filename with the appropriate +attributes set or reset. Function 30 searches for a match and +changes the matched directory entry to contain the selected +indicators. Indicators f1' through f4' are not currently used, +but may be useful for applications programs, since they are not +involved in the matching process during file open and close +operations. Indicators f5' through f8' and t3' are reserved for +future system expansion. +.sp 6 +.nf + FUNCTION 31: GET ADDR (DISK PARMS) +.sp + Entry Parameters: + Register C: 1FH +.sp + Returned Value: + Registers HL: DPB Address +.fi +.sp 2 +.pp +The address of the BIOS resident disk parameter block is returned +in HL as a result of this function call. This address can be +used for either of two purposes. First, the disk parameter +values can be extracted for display and space computation +purposes, or transient programs can dynamically change the values +of current disk parameters when the disk environment changes, if +required. Normally, application programs will not require this +facility. +.bp +.sp 4 +.nf + FUNCTION 32: SET/GET USER CODE +.sp + Entry Parameters: + Register C: 20H + Register E: OFFH (get) or + User Code (set) +.sp + Returned Value: + Register A: Current Code or + (no value) +.fi +.sp 2 +.pp +An application program can change or interrogate the currently +active user number by calling Function 32. If register E = 0FFH, +the value of the current user number is returned in register A, +where the value is in the range of 0 to 15. If register E is not +0FFH, the current user number is changed to the value of E, +modulo 16. +.bp +.sp 4 +.nf + FUNCTION 33: READ RANDOM +.sp + Entry Parameters: + Register C: 21H +.sp + Returned Value: + Register A: Return Code +.fi +.sp 2 +.pp +The Read Random function is similar to the sequential file read +operation of previous releases, except that the read operation +takes place at a particular record number, selected by the 24-bit +value constructed from the 3-byte field following the FCB (byte +positions r0 at 33, r1 at 34, and r2 at 35). The user should +note that the sequence of 24 bits is stored with least +significant byte first (r0), middle byte next (r1), and high byte +last (r2). CP/M does not reference byte r2, except in computing +the size of a file (Function 35). Byte r2 must be zero, however, +since a nonzero value indicates overflow past the end of file. +.pp +Thus, the r0, r1 byte pair is treated as a double-byte, or word +value, that contains the record to read. This value ranges from +0 to 65535, providing access to any particular record of the 8- +megabyte file. To process a file using random access, the base +extent (extent 0) must first be opened. Although the base extent +might or might not contain any allocated data, this ensures that the +file is properly recorded in the directory and is visible in DIR +requests. The selected record number is then stored in the +random record field (r0, r1), and the BDOS is called to read the +record. +.pp +Upon return from the call, register A either contains an error +code, as listed below, or the value 00, indicating the operation +was successful. In the latter case, the current DMA address +contains the randomly accessed record. Note that +contrary to the sequential read operation, the record number is +not advanced. Thus, subsequent random read operations continue +to read the same record. +.pp +Upon each random read operation, the logical extent and current +record values are automatically set. Thus, the file can be +sequentially read or written, starting from the current randomly +accessed position. However, note that, in this +case, the last randomly read record will be reread as one +switches from random mode to sequential read and the last record +will be rewritten as one switches to a sequential write operation. +The user can simply advance the random record +position following each random read or write to obtain the effect +of sequential I/O operation. +.bp +.pp +Error codes returned in register A following a random read are +listed below. +.sp 2 +.nf +.in 8 +01 reading unwritten data +.sp +02 (not returned in random mode) +.sp +03 cannot close current extent +.sp +04 seek to unwritten extent +.sp +05 (not returned in read mode) +.sp +06 seek past physical end of disk +.fi +.in 0 +.sp +.pp +Error codes 01 and 04 occur when a random read operation accesses +a data block that has not been previously written or an extent +that has not been created, which are equivalent conditions. +Error code 03 does not normally occur under proper system +operation. If it does, it can be cleared by simply rereading or +reopening extent zero as long as the disk is not physically write +protected. Error code 06 occurs whenever byte r2 is nonzero +under the current 2.0 release. Normally, nonzero return codes +can be treated as missing data, with zero return codes indicating +operation complete. +.bp +.sp 4 +.nf + FUNCTION 34: WRITE RANDOM +.sp + Entry Parameters: + Register C: 22H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Return Code +.fi +.sp 2 +.pp +The Write Random operation is initiated similarly to the Read +Random call, except that data is written to the disk from the +current DMA address. Further, if the disk extent or data block +that is the target of the write has not yet been allocated, the +allocation is performed before the write operation continues. As +in the Read Random operation, the random record number is not +changed as a result of the write. The logical extent number and +current record positions of the FCB are set to correspond to the +random record that is being written. Again, sequential read or +write operations can begin following a random write, with the +notation that the currently addressed record is either read or +rewritten again as the sequential operation begins. You can +also simply advance the random record position following each +write to get the effect of a sequential write operation. +Note that reading or writing the last record of an extent in +random mode does not cause an automatic extent switch as it does +in sequential mode. +.pp +The error codes returned by a random write are identical to the +random read operation with the addition of error code 05, which +indicates that a new extent cannot be created as a result of +directory overflow. +.bp +.sp 4 +.nf + FUNCTION 35: COMPUTE FILE SIZE +.sp + Entry Parameters: + Register C: 23H + Registers DE: FCB Address +.sp + Returned Value: + Random Record Field Set +.fi +.sp 2 +.pp +When computing the size of a file, the DE register pair addresses +an FCB in random mode format (bytes r0, r1, and r2 are present). +The FCB contains an unambiguous filename that is used in the +directory scan. Upon return, the random record bytes contain the +virtual file size, which is, in effect, the record address of +the record following the end of the file. Following a call to +Function 35, if the high record byte r2 is 01, the file contains +the maximum record count 65536. Otherwise, bytes r0 and r1 +constitute a 16-bit value as before (r0 is the least significant byte), +which is the file size. +.pp +Data can be appended to the end of an existing file by simply +calling Function 35 to set the random record position to the end +of file and then performing a sequence of random writes starting +at the preset record address. +.pp +The virtual size of a file corresponds to the physical size when +the file is written sequentially. If the file was created in +random mode and holes exist in the allocation, the file might +contain fewer records than the size indicates. For example, +if only the last record of an 8-megabyte file is written in +random mode (that is, record number 65535), the virtual size is +65536 records, although only one block of data is actually +allocated. +.bp +.sp 4 +.nf + FUNCTION 36: SET RANDOM RECORD +.sp + Entry Parameters: + Register C: 24H + Registers DE: FCB Address +.sp + Returned Value: + Random Record Field Set +.fi +.sp 2 +.pp +The Set Random Record function causes the BDOS automatically +to produce the random record position from a file that has been +read or written sequentially to a particular point. The function +can be useful in two ways. +.pp +First, it is often necessary initially to read and scan a +sequential file to extract the positions of various key fields. +As each key is encountered, Function 36 is called to compute the +random record position for the data corresponding to this key. If +the data unit size is 128 bytes, the resulting record position is +placed into a table with the key for later retrieval. After +scanning the entire file and tabulating the keys and their record +numbers, the user can move instantly to a particular keyed record +by performing a random read, using the corresponding random +record number that was saved earlier. The scheme is easily +generalized for variable record lengths, because the program need +only store the buffer-relative byte position along with the key +and record number to find the exact starting position of the +keyed data at a later time. +.pp +A second use of Function 36 occurs when switching from a +sequential read or write over to random read or write. A file is +sequentially accessed to a particular point in the file, Function +36 is called, which sets the record number, and subsequent random +read and write operations continue from the selected point in the +file. +.bp +.sp 4 +.nf + FUNCTION 37: RESET DRIVE +.sp + Entry Parameters: + Register C: 25H + Registers DE: Drive Vector +.sp + Returned Value: + Register A: 00H +.fi +.sp 2 +.pp +The Reset Drive function allows resetting of specified drives. +The passed parameter is a 16-bit vector of drives to be reset; +the least significant bit is drive A:. +.pp +To maintain compatibility with MP/M, CP/M returns a zero value. +.sp 6 +.nf + FUNCTION 40: WRITE RANDOM WITH ZERO FILL +.sp + Entry Parameters: + Register C: 28H + Registers DE: FCB Address +.sp + Returned Value: + Register A: Return Code +.fi +.sp 2 +.pp +The Write With Zero Fill operation is similar to Function 34, +with the exception that a previously unallocated block is filled +with zeros before the data is written. +.nx fivec + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/fivec.tex b/Source/Doc/CPM 22 Manual/fivec.tex new file mode 100644 index 00000000..e0cfc002 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/fivec.tex @@ -0,0 +1,444 @@ + +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.bp +.tc 5.3 A Sample File-to-File Copy Program +.he CP/M Operating System Manual 5.3 A Sample Copy Program +.sh +5.3 A Sample File-to-File Copy Program +.qs +.pp +The following program provides a relatively simple example of file +operations. The program source file is created as COPY.ASM using +the CP/M ED program and then assembled using ASM or MAC, resulting +in a HEX file. The LOAD program is used to produce a COPY.COM +file that executes directly under the CCP. The program begins +by setting the stack pointer to a local area and proceeds to move +the second name from the default area at 006CH to a 33-byte File +Control Block called DFCB. The DFCB is then prepared for file +operations by clearing the current record field. At this point, +the source and destination FCBs are ready for processing, because +the SFCB at 005CH is properly set up by the CCP upon entry to the +COPY program. That is, the first name is placed into the default +FCB, with the proper fields zeroed, including the current record +field at 007CH. The program continues by opening the source +file, deleting any existing destination file, and creating the destination +file. If all this is successful, the program loops at the label +COPY until each record is read from the source file and placed into the +destination file. Upon completion of the data transfer, the +destination file is closed and the program returns to the +CCP command level by jumping to BOOT. +.ll 75 +.sp 3 +.nf + ; sample file-to-file copy program + ; + ; at the ccp level, the command + ; + ; copy a:x.y b:u.v + ; + ; copies the file named x.y from drive + ; a to a file named u.v. on drive b. + ; +0000 = boot equ 0000h ;system reboot +0005 = bdos equ 0005h ;bdos entry point +005c = fcbl equ 005ch ;first file name +005c = sfcb equ fcbl ;source fcb +006c = fcb2 equ 006ch ;second file name +0080 = dbuff equ 0080h ;default buffer +0100 = tpa equ 0100h ;beginning of tpa + ; +0009 = printf equ 9 ;print buffer func# +000f = openf equ 15 ;open file func# +0010 = closef equ 16 ;close file func# +0013 = deletef equ 19 ;delete file func# +0014 = readf equ 20 ;sequential read +0015 = writef equ 21 ;sequential write +0016 = makef equ 22 ;make file func# + ; +0100 org tpa ;beginning of tpa +0100 311b02 lxi sp,stack ;local stack + ; + ; move second file name to dfcb +0103 0e10 mvi c,16 ;half an fcb +0105 116c00 lxi d,fcb2 ;source of move +0108 21da01 lxi h,dfcb ;destination fcb +010b 1a mfcb: Idax d ;source fcb +010c 13 inx d ;ready next +010d 77 mov m,a ;dest fcb +010e 23 inx h ;ready next +010f 0d dcr c ;count 16...0 +0110 c10b01 jnz mfcb ;loop 16 times + ; + ; name has been removed, zero cr +0113 af xra a ;a = 00h +0114 32fa01 sta dfcbcr ;current rec = 0 + ; + ; source and destination fcb's ready + ; +0117 115c00 lxi d,sfcb ;source file +011a cd6901 call open ;error if 255 +011d 118701 lxi d,nofile ;ready message +0120 3c inr a ;255 becomes 0 +0121 cc6101 cz finis ;done if no file + ; + ; source file open, prep destination +0124 11da01 lxi d,dfcb ;destination +0127 cd7301 call delete ;remove if present + ; +012a 11da01 lxi d,dfcb ;destination +012d cd8201 call make ;create the file +0130 119601 lxi d,nodir ;ready message +0133 3c inr a ;255 becomes 0 +0134 cc6101 cz finis ;done if no dir space + ; + ; source file open, dest file open + ; copy until end of file on source + ; +0137 115c00 copy: lxi d,sfcb ;source +013a cd7801 call read ;read next record +013d b7 ora a ;end of file? +013e c25101 jnz eofile ;skip write if so + ; + ; not end of file, write the record +0141 11da01 lix d,dfcb ;destination +0144 cd7d01 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 11da01 lxi d,dfcb ;destination +0154 cd6e01 call close ;255 if error +0157 21bb01 lxi h,wrprot ;ready message +015a 3c inr a ;255 becomes 00 +015b cc6101 cz finis ;shouldn't happen + ; + ; copy operation complete, end +015e 11cc01 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 system + ; + ; system interface subroutines + ; (all return directly from bdos) + ; +0169 0e0f open: mvi c,openf +016b c30500 jmp bdos + ; +016e 0e10 close: mvi c,closef +0170 c30500 jmp bdos + ; +0173 0e13 delete mvi c,deletef +0175 c30500 jmp bdos + ; +0178 0e14 read: mvi c,readf +017a c30500 jmp bdos + ; +017d 0e15 write: mvi c,writef +017f c30500 jmp bdos + ; +0182 0e16 make: mvi c,makef +0184 c30500 jmp bdos + ; + ; console messages +0187 6e6f20f nofile: db 'no source file$' +0196 6e6f209 nodir: db 'no directory space$' +01a9 6f7574f space: db 'out of dat space$' +01bb 7772695 wrprot: db 'write protected?$' +01cc 636f700 normal: db 'copy complete$' + ; + ; data areas +01da dfcb: ds 33 ;destination fcb +01fa dfcbcr equ dfcb+32 ;current record + ; +01fb ds 32 ;16 level stack + stack: +021b end +.ll 65 +.fi +.in 0 +.sp 2 +.pp +Note that there are several simplifications in this +particular program. First, there are no checks for invalid filenames +that could contain ambiguous references. This +situation could be detected by scanning the 32-byte default area +starting at location 005CH for ASCII question marks. A check +should also be make to ensure that the filenames have +been included (check locations 005DH and 006DH for nonblank ASCII +characters). Finally, a check should be made to ensure that the +source and destination filenames are different. An improvement +in speed could be obtained by buffering more data on each read +operation. One could, for example, determine the size of memory +by fetching FBASE from location 0006H and using the entire +remaining portion of memory for a data buffer. In this case, the +programmer simply resets the DMA address to the next successive +128-byte area before each read. Upon writing to the destination +file, the DMA address is reset to the beginning of the buffer and +incremented by 128 bytes to the end as each record is +transferred to the destination file. +.sp 2 +.he CP/M Operating System Manual 5.4 A Sample File Dump Utility +.tc 5.4 A Sample File Dump Utility +.sh +5.4 A Sample File Dump Utility +.qs +.pp +The following file dump program is slightly more complex than +the simple copy program given in the previous section. The dump +program reads an input file, specified in the CCP command line, +and displays the content of each record in hexadecimal format at +the console. Note that the dump program saves the CCP's stack +upon entry, resets the stack to a local area, and restores the +CCP's stack before returning directly to the CCP. Thus, the +dump program does not perform and warm start at the end of +processing. +.ll 75 +.sp 3 +.nf +x.in 5 + ;DUMP program reads input file and displays + hex data + ; +0100 org 100h +0005 = bdos equ 0005h = ;bdos entry point +0001 = cons equ 1 ;read console +0002 = typef equ 2 ;type function +0009 = printf equ 9 ;buffer print entry +000b = brkf equ 11 ;break key function + ;(true if char +000f = openf equ 15 ;file open +0014 = readf equ 20 ;read function + ; +005c = fcb equ 5ch ;file control block + ;address +0080 = buff equ 80h ;input disk buffer + ;address + ; + ; non graphic characters +000d = cr equ 0dh ;carriage return +000a = If equ 0ah ;line feed + ; + ; file control block definitions +005c = fcbdn equ fcb+0 ;disk name +005d = fcbfn equ fcb+1 ;file name +0065 = fcbft equ fcb+9 ;disk file type (3 + ;characters) +0068 = fcbrl equ fcb+12 ;file's current reel + ;number +006b = fcbrc equ fcb+15 ;file's record count (0 to + ;128)128) +007c = fcbcr' equ fcb+32 ;current (next) record + ;number (0 +007d = fcbin equ fcb+33 ;fcb length + ; + ; set up stack +0100 210000 lxi h,0 +0103 39 dad sp + ; entry stack pointer in hl from the ccp +0104 221502 shld oldsp + ; set sp to local stack area (restored at + ; finis) +0107 315702 lxi sp,stktop + ; read and print successive buffers +010a cdc101 call setup ;set up input file +010d feff cpi 255 ;255 if file not present +010f c21b01 jnz openok ;skip if open is ok + ; + ; file not there, give error message and + ; return +0112 11f301 lxi d,opnmsg +0115 cd9c01 call err +0118 c35101 jmp finis ;to return + ; + openok: ;open operation ok, set buffer index to + ;end +011b 3e80 mvi a,80h +011d 321302 sta ibp ;set buffer pointer to 80h + ; hl contains next address to print +0120 210000 lxi h,0 ;start with 0000 + ; + gloop: +0123 e5 push h ;save line position +0124 cda201 call gnb +0127 e1 pop h ;recall line position +0138 da5101 jc finis ;carry set by gnb if end + ;file +012b 47 mov b,a + ; print hex values + ; check for line fold +012c 7d + mov a,l +012d e60f ani 0fh ;check low 4 bits +012f c24401 jnz nonum + ; print line number +0132 cd7201 call crlf + ; + ; check for break key +0135 cd5901 call break + ; accum lsb = 1 if character ready +0138 0f rrc ;into carry +0139 da5101 jc finis ;don't print any more + ; +013c 7c mov a,h +013d cd8f01 call phex +0140 7d mov a,l +0141 cd8f01 call phex + nonum +0144 23 inx h ;to next line number +0145 3e20 mvi a,'' +0147 cd6501 call pchar +014a 78 mov a,b +014b cd8f01 call phex +014e c32301 jmp gloop + ; + finis + ; end of dump, return to cco + ; (note that a jmp to 0000h reboots) +0151 cd7201 call crif +0154 2a1502 lhld oldsp +0157 f9 sphl + ; stack pointer contains ccp's stack + ; location +0158 c9 ret ;to the ccp + ; + ; + ; subroutines + ; + break: ;check break key (actually any key will + ;do) +0159 e5d5c5 push h! push d! push b; environment + ;saved +015c 0e0b mvi c,brkf +015e cd0500 call bdos +0161 c1d1e1 pop b! pop d! pop h; environment + restored +0164 c9 ret + ; + pchar: ;print a character +0165 e5d5c5 push h! push d! push b; saved +0168 0e02 mvi c, typef +016a 5f mov e,a +016b cd0500 call bdos +016e c1d1e1 pop b! pop d! pop h; restored +0171 c9 ret + ; + crlf +0172 3e0d mvi a,cr +0174 cd6501 call pchar +0177 3e0a mvi a,lf +0179 cd6501 call pchar +017c c9 ret + ; + ; + pnib: ;print nibble in reg a +017d e60f ani ofh ;low 4 bits +017f fe0a cpi 10 +0181 d28901 jnc p10 + ; less than or equal to 9 +0184 c630 adi '0' +0186 c38b01 jmp prn + ; + ; greater or equal to 10 +0189 c637 p10: adi 'a' - 10 +018b cd6501 prn: call pchar +018e c9 ret + ; + phex ;print hex char in reg a +018f f5 pushpsw +0190 0f rrc +0191 0f rrc +0192 0f rrc +0193 0f rrc +0194 cd7d01 call pnib ;print nibble +0197 f1 pop psw +0198 cd7d01 call pnip +019b c9 ret + ; + err: ;print error message + ; d,e addresses message ending with "$" +019c 0e09 mvi c,printf ;print buffer + ;function +019e cd0500 call bdos +01a1 c9 ret + ; + ; + gnb: ;get next byte +01a2 3a1302 lda ibp +01a5 fe80 cpi 80h +01a7 c2b301 jnz g0 + ; read another buffer + ; + ; + 01aa cdce01 call diskr +01ad b7 ora a ;zero value if read ok +01ae cab301 jz g0 ;for another byte + ; end of data, return with carry set for eof +01b1 37 stc +01b2 c9 ret + ; + g0: ;read the byte at buff+reg a +01b3 5f mov e,a ;Is byte of buffer index +01b4 1600 mvi d,0 ;double precision + ;index to de +01b6 3c inr a ;index=index+1 +01b7 321302 sta ibp ;back to memory + ; pointer is incremented + ; save the current file address +01ba 218000 lxi h,buff +01bd 19 dad d + ; absolute character address is in hl +01be 7e mov a,m + ; byte is in the accumulator +01bf b7 ora a ;reset carry bit +01c0 c9 ret + ; + setup: ;set up file + ; open the file for input +01c1 af xra a ;zero to accum +01c2 327c00 sta fcbcr ;clear current record + ; +01c5 115c00 lxi d,fcb +01c8 0e0f mvi c,openf +01ca cd0500 call bdos + ; 255 in accum if open error +01cd c9 ret + ; + diskr: ;read disk file record +01ce e5d5c5 push h! push d! push b +01d1 115c00 lxi d,fcb +01d4 0e14 mvi c,readf +01d6 cd0500 call bdos +01d9 c1d1e1 pop b! pop d! pop h +01dc c9 ret + ; + ; fixed message area +01dd 46494c0 signon: db 'file dump version 2.0$' +01f3 0d0a4e0 opnmsg: db cr,lf,'no input file present on + disk$' + + ; variable area +0213 ibp: ds 2 ;input buffer pointer +0215 oldsp: ds 2 ;entry sp value from ccp + ; + ; stack area +0217 ; ds 64 ;reserve 32 level stack + stktop: + ; +0257 end +.ll 65 +.fi +.in 0 +.nx fived + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/fived.tex b/Source/Doc/CPM 22 Manual/fived.tex new file mode 100644 index 00000000..49bf9f2b --- /dev/null +++ b/Source/Doc/CPM 22 Manual/fived.tex @@ -0,0 +1,497 @@ +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.sp 3 +.he CP/M Operating System Manual 5.5 Sample Random Access Program +.sh +5.5 A Sample Random Access Program +.qs +.tc 5.5 A Sample Random Access Program +.pp +This chapter concludes with an extensive example of random access operation. +The program listed below performs the simple function of reading or writing +random records upon command from the terminal. When a +program has been created, assembled, and placed into a file +labeled RANDOM.COM, the CCP level command +.sp +.ti 8 +RANDOM X.DAT +.sp +starts the test program. The program looks for a file by the +name X.DAT and, if found, proceeds to prompt the console for +input. If not found, the file is created before the prompt is +given. Each prompt takes the form +.sp +.ti 8 +next command? +.sp +and is followed by operator input, followed by a carriage +return. The input commands take the form +.sp +.ti 8 +nW nR Q +.sp +where n is an integer value in the range 0 to 65535, and W, R, +and Q are simple command characters corresponding to random +write, random read, and quit processing, respectively. If the W +command is issued, the RANDOM program issues the prompt +.sp +.ti 8 +type data: +.sp +The operator then responds by typing up to 127 characters, +followed by a carriage return. RANDOM then writes the character +string into the X.DAT file at record n. If the R command is +issued, RANDOM reads record number n and displays the string +value at the console, If the Q command is issued, the X.DAT file +is closed, and the program returns to the CCP. In the interest +of brevity, the only error message is +.sp +.ti 8 +error, try again. +.pp +The program begins with an initialization section where the input +file is opened or created, followed by a continuous loop at the +label ready where the individual commands are interpreted. The +DFBC at 005CH and the default buffer at 0080H are used in all +disk operations. The utility subroutines then follow, which +contain the principal input line processor, called readc. This +particular program shows the elements of random access +processing, and can be used as the basis for further program +development. +.ll 75 +.sp 3 +.nf +.sh + Sample Random Access Program for CP/M 2.0 +.qs + +0100 org 100h ;base of tpa + ; +0000 = reboot equ 0000h ;system reboot +0005 = bdos equ 0005h ;bdos entry point + ; +0001 = coninp equ 1 ;console input function +0002 = conout equ 2 ;console output function +0009 = pstring equ 9 ;print string until '$' +000a = rstring equ 10 ;read console buffer +000c = version equ 12 ;return version number +000f = openf equ 15 ;file open function +0010 = closef equ 16 ;close function +0016 = makef equ 22 ;make file function +0021 = readr equ 33 ;read random +0022 = writer equ 34 ;write random + ; +005c = fcb equ 005ch ;default file control + ;block +007d = ranrec equ fcb+33 ;random record position +007f = ranovf equ fcb+35 ;high order (overflow) + ;byte +0080 = buff equ 0080h ;buffer address + ; +000d = cr equ 0dh ;carriage return +000a = lf equ 0ah ;line feed + ; + + +.sh + Load SP, Set-Up File for Random Access +.qs + +0100 31bc00 lxi sp,stack + ; + ; version 2.0 +0103 0e0c mvi c,version +0105 cd0500 call bdos +0108 fe20 cpi 20h ;version 2.0 or better? +010a d21600 jnc versok + ; bad version, message and go back +010d 111b00 lxi d,badver +0110 cdda00 call print +0113 c30000 jmp reboot + ; + versok: + ; correct versionm for random access +0116 0e0f mvi c,openf ;open default fcb +0118 115c00 lxi d,fcb +011b cd 0500 call bdos +011e 3c inr a ;err 255 becomes zero +011f c23700 jnz ready + ; + ; connot open file, so create it +0122 0e16 mvi c,makef +0124 115c00 lxi d,fcb +0127 cd0500 call bdos +012a 3c inr a ;err 255 becomes zero +012b c23700 jnz ready + ; + ; cannot create file, directory full +012e 113a00 lxi d,nospace +0131 cdda00 call print +0134 c30000 jmp reboot ;back to ccp +.sp 2 +.sh + Loop Back to Ready After Each Command +.qs +.sp + ; + ready: + ; file is ready for processing + ; +0137 cde500 call readcom ;read next command +013a 227d00 shld ranrec ;store input record# +013d 217f00 lxi h,ranovf +0140 3600 mvi m,0 ;clear high byte if set +0142 fe51 cpi 'Q' ;quit? +0144 c25600 jnz notq + ; + ; quit processing, close file +0147 0e10 mvi c,closef +0149 115c00 lxi d,fcb +014c cd0500 call bdos +014f 3c inr a ;err 255 becomes 0 +0150 cab900 jz error ;error message, retry +0153 c30000 jmp reboot ;back to ccp + ; +.sp 2 +.sh + End of Quit Command, Process Write +.qs +.sp + notq: + ; not the quit command, random write? +0156 fe57 cpi 'W' +0158 c28900 jnz notw + ; + ; this is a random write, fill buffer untill cr +015b 114d00 lxi d,datmsg +015e cdda00 call print ;data prompt +0161 0e7f mvi c,127 ;up to 127 characters +0163 218000 lxi h,buff ;destination + rloop: ;read next character to buff +0166 c5 push b ;save counter +0167 e5 push h ;next destination +0168 cdc200 call getchr ;character to a +016b e1 pop h ;restore counter +016c c1 pop b ;restore next to fill +016d fe0d cpi cr ;end of line? +016f ca7800 jz erloop + ; not end, store character +0172 77 mov m,a +0173 23 inx h ;next to fill +0174 0d dcr c ;counter goes down +0175 c26600 jnz rloop ;end of buffer? + erloop: + ; end of read loop, store 00 +0178 3600 mvi m,0 + ; + ; write the record to selected record number +017a 0e22 mvi c,writer +017c 115c00 lxi d,fcb +017c cd0500 call bdos +0182 b7 ora a ;erro code zero? +0183 c2b900 jnz error ;message if not +0186 c33700 jmp ready ;for another record + ; +.sp 2 +.sh + End of Write Command, Process Read +.qs +.sp + notw: + ; not a write command, read record? +0189 fe52 cpi 'R' +018b c2b900 jnz error ;skip if not + ; + ; read random record +018e 0e21 mvi c,readr +0190 115c00 lxi d,fcb +0193 cd0500 call bdos +0196 b7 ora a ;return code 00? +0197 c2b900 jnz error + ; + ; read was successful, write to console +019a cdcf00 call crlf ;new line +019d 0e80 mvi c,128 ;max 128 characters +019f 218000 lxi h,buff ;next to get + wloop: +01a2 7e mov a,m ;next character +01a3 23 inx h ;next to get +01a4 e67f ani 7fh ;mask parity +01a6 ca3700 jz ready ;for another command + ;if 00 +01a9 c5 push b ;save counter +01aa e5 push h ;save next to get +01ab fe20 cpi '' ;graphic? +01ad d4c800 cnc putchr ;skip output if not +01b0 e1 pop h +01b1 c1 pop b +01b2 0d dcr c ;count=count-1 +01b3 c2a200 jnz wloop +01b6 c33700 jmp ready +.bp +.sh + End of Read Command, All Errors End Up Here +.qs +.sp + ; + error: +01b9 115900 lxi d,errmsg +01bc cdda00 call print +01bf c33700 jmp ready + ; +.sp 2 +.sh + Utility Subroutines for Console I/O +.qs +.sp + getchr: + ;read next console character to a +01c2 0e01 mvi c,coninp +01c4 cd0500 call bdos +01c7 c9 ret + ; + putchr: + ;write character from a to console +01c8 0e02 mvi c,conout +01ca 5f mov e,a ;character to send +01cb cd0500 call bdos ;send character +01ce c9 ret + ; + crlf: + ;send carriage return line feed +01cf 3e0d mvi a,cr ;carriage return +01d1 cdc800 call putchr +01d4 3e0a mvi a,lf ;line feed +01d6 cdc800 call putchr +01d9 c9 ret + ; + print: + ;print the buffer addressed by de untill $ +01da d5 push d +01db cdcf00 call crlf +01de d1 pop d ;new line +01df 0e09 mvi c,pstring +01e0 cd0500 call bdos ;print the string +01e4 c9 ret + ; + readcom: + ;read the next command line to the conbuf +01e5 116b00 lxi d,prompt +01e8 cdda00 call print ;command? +01eb 0e0a mvi c,rstring +01ed 117a00 lxi d,conbuf +01f0 cd0500 call bdos ;read command line + ; command line is present, scan it +01f3 210000 lxi h,0 ;start with 0000 +01f6 117c00 lxi d,conlin ;command line +01f9 1a readc: ldax d ;next command + ;character +01fa 13 inx d ;to next command + ;position +01fb b7 ora a ;cannot be end of + ;command +01fc c8 rz + ; not zero, numeric? +01fd d630 sui '0' +01ff fe0a cpi 10 ;carry if numeric +0201 d21300 jnc endrd + ; add-in next digit +0204 29 dad h ;*2 +0205 4d mov c,l +0206 44 mov b,h ;bc = value * 2 +0207 29 dad h ;*4 +0208 29 dad h ;*8 +0209 09 dad b ;*2 + *8 = *10 +020a 85 add l ;*digit +020b 6f mov l,a +020c d2f900 jnc readc ;for another char +020f24 inr h ;overflow +0210 c3f900 jmp readc ;for another char + endrd: + ; end of read, restore value in a +0213 c630 adi '0' ;command +0215 fe61 cpi 'a' ;translate case? +0217 d8 rc + ; lower case, mask lower case bits +0218 e65f ani 101$1111b +021a c9 ret + ; +.sp 2 +.sh + String Data Area for Console Messages +.qs +.sp + badver: +021b 536f79 db 'sorry, you need cp/m version 2$' + nospace: +023a 4e6f29 db 'no directory space$' + datmsg: +024d 547970 db 'type data: $' + errmsg: +0259 457272 db 'error, try again.$' + prompt: +026b 4e6570 db 'next command? $' + ; +.sp 2 +.mb 5 +.fm 1 +.sh + Fixed and Variable Data Area +.qs +.sp +027a 21 conbuf: db conlen ;length of console buffer +027b consiz: ds 1 ;resulting size after read +027c conlin: ds 32 ;length 32 buffer +0021 = conlen equ $-consiz + ; +029c ds 32 ;16 level stack + stack: +02bc end +.ll 65 +.fi +.pp +Major improvements could be made to this particular program to enhance +its operation. In fact, with some work, this program could +evolve into a simple data base management system. One could, for +example, assume a standard record size of 128 bytes, consisting +to arbitrary fields within the record. A program, called GETKEY, +could be developed that first reads a sequential file and +extracts a specific field defined by the operator. For example, +the command +.mb 6 +.fm 2 +.sp +.ti 8 +GETKEY NAMES.DAT LASTNAME 10 20 +.sp +would cause GETKEY to read the data base file NAMES.DAT and +extract the LAST-NAME field from each record, starting in +position 10 and ending at character 20. GETKEY builds a table in +memory consisting of each particular LASTNAME field, along with +its 16-bit record number location within the file. The GETKEY +program then sorts this list and writes a new file, called +LASTNAME.KEY, which is an alphabetical list of LASTNAME fields +with their corresponding record numbers. This list is called an +inverted index in information retrieval parlance. +.pp +If the programmer were to rename the program shown above as QUERY +and modify it so that it reads a sorted key file into memory, +the command line might appear as +.sp +.ti 8 +QUERY NAMES.DAT LASTNAME.KEY +.sp +Instead of reading a number, the QUERY program reads an +alphanumeric string that is a particular key to find in the +NAMES.DAT data base. Because the LASTNAME.KEY list is sorted, one +can find a particular entry rapidly by performing a binary +search, similar to looking up a name in the telephone book. +Starting at both ends of the list, one examines the +entry halfway in between and, if not matched, splits either the +upper half or the lower half for the next search. You will +quickly reach the item you are looking for and find the +corresponding record number. You should fetch and display +this record at the console, just as was done in the program shown +above. +.pp +With some more work, you can allow a fixed grouping size +that differs from the 128-byte record shown above. This is +accomplished by keeping track of the record number and the +byte offset within the record. Knowing the group size, you +randomly access the record containing the proper group, offset +to the beginning of the group within the record read sequentially +until the group size has been exhausted. +.pp +Finally, you can improve QUERY considerably by allowing boolean +expressions, which compute the set of records that satisfy +several relationships, such as a LASTNAME between HARDY and +LAUREL and an AGE lower than 45. Display all the records that +fit this description. Finally, if your lists are getting +too big to fit into memory, randomly access key +files from the disk as well. +.bp +.tc 5.6 System Function Summary +.he CP/M Operating System Manual 5.6 System Function Summary +.sh +5.6 System Function Summary +.qs +.sp +.nf +Function Function Input Output +Number Name +.sp +Decimal Hex +.sp + 0 0 System Reset C = 00H none + 1 1 Console Input C = 01H A = ASCII char + 2 2 Console Output E = char none + 3 3 Reader Input A = ASCII char + 4 4 Punch Output E = char none + 5 5 List Output E = char none + 6 6 Direct Console I/O C = 06H A = char or status + + E = 0FFH (input) or (no value) + 0FEH (status) or + char (output) + 7 7 Get I/O Byte none A = I/O byte + Value + 8 8 Set I/O Byte E = I/O Byte none + 9 9 Print String DE = Buffer Address none +10 A Read Console Buffer DE = Buffer Console + Characters + in Buffer +11 B Get Console Status none A = 00/non zero +12 C Return Version Number none HL: Version + Number +13 D Reset Disk System none none +14 E Select Disk E = Disk Number none +15 F Open File DE = FCB Address FF if not found +16 10 Close File DE = FCB Address FF if not found +17 11 Search For First DE = FCB Address A = Directory + Code +18 12 Search For Next none A = Directory + Code +19 13 Delete File DE = FCB Address A = none +20 14 Read Sequential DE = FCB Address A = Error Code +21 15 Write Sequential DE = FCB Address A = Error Code +22 16 Make File DE = FCB Address A = FF if no DIR + Space +23 17 Rename File DE = FCB Address A = FF in not + found +24 18 Return Login Vector none HL = Login + Vector* +25 19 Return Current Disk none A = Current Disk + Number +26 1A Set DMA Address DE = DMA Address none +27 1B Get ADDR (ALLOC) none HL = ALLOC + Address* +28 1C Write Protect Disk none none +29 1D Get Read/only Vector none HL = R/O + Vector Value* +30 1E Set File Attributes DE = FCB Address A = none +31 1F Get ADDR (Disk Parms) none HL = DPB + Address +32 20 Set/Get User Code E = 0FFH for Get User Number + E = 00 to 0FH for Set +33 21 Read Random DE = FCB Address A = Error Code +34 22 Write Random DE = FCB Address A = Error Code +35 23 Compute File Size DE = FCB Address r0, r1, r2 +36 24 Set Random Record DE = FCB Address r0, r1, r2 +37 25 Reset Drive DE = Drive Vector A = 0 +38 26 Access Drive not supported +39 27 Free Drive not supported +40 28 Write Random with Fill DE = FCB A = Error Code +.fi +.sp 4 +*Note that A = L, and B = H upon return. +.sp 2 +.ce +End of Section 5 +.nx sixa + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/foura.tex b/Source/Doc/CPM 22 Manual/foura.tex new file mode 100644 index 00000000..9f90f979 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/foura.tex @@ -0,0 +1,693 @@ + +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 4-% +.pc 1 +.tc 4 CP/M Dynamic Debugging Tool +.nf +.sh + Section 4 +.sp +.sh + CP/M Dynamic Debugging Tool +.qs +.fi +.sp 3 +.tc 4.1 Introduction +.he CP/M Operating System Manual 4.1 Introduction +.sh +4.1 Introduction +.pp 5 +The DDT program allows dynamic interactive testing and debugging of +programs generated in the CP/M environment. Invoke the debugger with +a command of one of the following forms: +.sp +.in 8 +.nf +DDT +DDT filename.HEX +DDT filename.COM +.fi +.in 0 +.sp +where filename is the name of the program to be loaded and +tested. In both cases, the DDT program is brought into main +memory in place of the Console Command Processor (CCP) and resides +directly below the Basic Disk Operating System (BDOS) +portion of CP/M. Refer to Section 5 for standard memory +organization. The BDOS +starting address, located in the address field of the +JMP instruction at location 5H, is altered to reflect the +reduced Transient Program Area (TPA) size. +.pp +The second and third forms of the DDT command perform the same +actions as the first, except there is a subsequent automatic load +of the specified HEX or COM file. The action is identical to the +following sequence of commands: +.sp +.in 8 +.nf +DDT +Ifilename.HEX or Ifilename.COM +R +.fi +.in 0 +.sp +where the I and R commands set up and read the specified program +to test. See the explanation of the I and R +commands below for exact details. +.pp +Upon initiation, DDT prints a sign-on message in the form: +.sp +.ti 8 +DDT VER m.m +.sp +where m.m is the revision number. +.pp +Following the sign-on message, DDT prompts you with the +hyphen character, -, and waits for input commands from the +console. You can type any of several single-character commands, +followed by a carriage return to execute the command. Each +line of input can be line-edited using the following standard +CP/M controls: +.bp +.ce +.sh +Table 4-1. Line-editing Controls +.ll 60 +.sp +.in 5 +.nf +Control Result +.sp +rubout removes the last character typed + +CTRL-U removes the entire line, ready for retyping + +CTRL-C reboots system +.fi +.in 0 +.ll 65 +.sp +.pp +Any command can be up to 32 characters in length. An automatic +carriage return is inserted as character 33, where the +first character determines the command type. Table 4-2 describes DDT +commands. +.sp 2 +.sh + Table 4-2. DDT Commands +.sp +.nf + Command Result + Character +.fi +.sp +.ll 57 +.in 16 +.ti -9 +A enters assembly-language mnemonics with operands. +.sp +.ti -9 +D displays memory in hexadecimal and ASCII. +.sp +.ti -9 +F fills memory with constant data. +.sp +.ti -9 +G begins execution with optional breakpoints. +.sp +.ti -9 +I sets up a standard input File Control Block. +.sp +.ti -9 +L lists memory using assembler mnemonics. +.sp +.ti -9 +M moves a memory segment from source to destination. +.sp +.ti -9 +R reads a program for subsequent testing. +.sp +.ti -9 +S substitutes memory values. +.sp +.ti -9 +T traces program execution. +.sp +.ti -9 +U untraced program monitoring. +.sp +.ti -9 +X examines and optionally alters the CPU state. +.in 0 +.ll 65 +.mb 4 +.fm 1 +.sp 2 +The command character, in some cases, is followed by zero, one, +two, or three hexadecimal values, which are separated by commas +or single blank characters. All DDT numeric output is in +hexadecimal form. The commands are not execution until the +carriage return is typed at the end of the command. +.pp +At any point in the debug run, you can stop execution of +DDT by using either a CTRL-C or G0 (jump to location 0000H) and +save the current memory image by using a SAVE command of the form: +.sp +.ti 8 +SAVE n filename. COM +.sp +where n is the number of pages (256 byte blocks) to be saved on +disk. The number of blocks is determined by taking the high-order +byte of the address in the TPA and converting this number to +decimal. For example, if the highest address in the TPA is 134H, +the number of pages is 12H or 18 in decimal. You could type a +CTRL-C during the debug run, returning to the CCP level, followed +by +.mb 6 +.fm 2 +.sp +.ti 8 +SAVE 18 X.COM +.sp +The memory image is saved as X.COM on the disk and can be +directly executed by typing the name X. If further testing is +required, the memory image can be recalled by typing +.sp +.ti 8 +DDT X.COM +.sp +which reloads the previously saved program from location 100H +through page 18, 23FFH. The CPU state is not a part of the COM +file; thus, the program must be restarted from the beginning to +test it properly. +.sp 2 +.tc 4.2 DDT Commands +.he CP/M Operating System Manual 4.2 DDT Commands +.sh +4.2 DDT Commands +.pp +The individual commands are detailed below. In each case, the +operator must wait for the hyphen prompt character before entering +the command. If control is passed to a program under test, and +the program has not reached a breakpoint, control can be returned +to DDT by executing a RST 7 from the front panel. In the +explanation of each command, the command letter is shown in some +cases with numbers separated by commas, the the numbers are +represented by lower-case letters. These numbers are always +assumed to be in a hexadecimal radix and from one to four digits +in length. Longer numbers are automatically truncated on the +right. +.pp +Many of the commands operate upon a CPU state that corresponds +to the program under test. The CPU state holds the registers of +the program being debugged and initially contains zeros for all +registers and flags except for the program counter, P, and stack +pointer, S, which default to 100H. The program counter is +subsequently set to the starting address given in the last record +of a HEX file if a file of this form is loaded, see the I and R +commands. +.sp 2 +.tc 4.2.1 The A (Assembly) Command +.sh +4.2.1 The A (Assembly) Command +.pp +DDT allows in-line assembly language to be inserted into the +current memory image using the A command, which takes the form: +.sp +.ti 8 +As +.sp +where s is the hexadecimal starting address for the in-line +assembly. DDT prompts the console with the address of the next +instruction to fill and reads the console, looking for assembly-language +mnemonics followed by register references and operands in +absolute hexadecimal form. See the \c +.ul +Intel 8080 Assembly Language Reference Card \c +.qu +for a list of mnemonics. Each +successive load address is printed before reading the console. +The A command terminates when the first empty line is input from +the console. +.pp +Upon completion of assembly language input, you can +review the memory segment using the DDT disassembler (see the L +command). +.pp +Note that the assembler/disassembler portion of +DDT can be overlaid by the transient program being tested, in +which case the DDT program responds with an error condition when +the A and L commands are used. +.sp 2 +.tc 4.2.2 The D (Display) Command +.sh +4.2.2 The D (Display) Command +.pp +The D command allows you to view the contents of memory +in hexadecimal and ASCII formats. The D command takes the forms: +.sp +.in 8 +.nf +D +Ds +Ds,f +.fi +.in 0 +.pp +In the first form, memory is displayed from the current display +address, initially 100H, and continues for 16 display lines. +Each display line takes the followng form: +.sp +.nf +aaaa bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb cccccccccccccccc +.fi +.sp +where aaaa is the display address in hexadecimal and bb +represents data present in memory starting at aaaa. The ASCII +characters starting at aaaa are to the right (represented by the +sequence of character c) where nongraphic characters are printed as a +period. You should note that both upper- and lower-case +alphabetics are displayed, and will appear as upper-case symbols +on a console device that supports only upper-case. Each display +line gives the values of 16 bytes of data, with the first line +truncated so that the next line begins at an address that is a +multiple of 16. +.pp +The second form of the D command is similar to the first, except +that the display address is first set to address s. +.pp +The third form causes the display to continue from address s +through address f. In all cases, the display address is set to +the first address not displayed in this command, so that a +continuing display can be accomplished by issuing successive D +commands with no explicit addresses. +.pp +Excessively long displays can be aborted by pressing the return key. +.sp 2 +.tc 4.2.3 The F (Fill) Command +.sh +4.2.3 The F (Fill) Command +.pp +The F command takes the form: +.sp +.ti 8 +Fs,f,c, +.sp +where s is the starting address, f is the final address, and c is +a hexadecimal byte constant. DDT stores the constant c at +address s, increments the value of s and test against f. If s +exceeds f, the operation terminates, otherwise the operation is +repeated. Thus, the fill command can be used to set a memory +block to a specific constant value. +.sp 2 +.tc 4.2.4 The G (Go) Command +.sh +4.2.4 The G (Go) Command +.pp +A program is executed using the G command, with up to two +optional breakpoint addresses. The G command takes the forms: +.sp 2 +.in 8 +.nf +G +Gs +Gs,b +Gs,b,c +G,b +G,b,c +.fi +.in 0 +.sp +.pp +The first form executes the program at the current value of the +program counter in the current machine state, with no breakpoints +set. The only way to regain control in DDT is through a RST 7 +execution. The current program counter can be viewed by typing +an X or XP command. +.pp +The second form is similar to the first, except that the program +counter in the current machine state is set to address s before +execution begins. +.pp +The third form is the same as the second, except that program +execution stops when address b is encountered (b must be in the +area of the program under test). The instruction at location b is +not executed when the breakpoint is encountered. +.pp +The fourth form is identical to the third, except that two +breakpoints are specified, one at b and the other at c. +Encountering either breakpoint causes execution to stop, and both +breakpoints are cleared. The last two forms take the program +counter from the current machine state and set one and two +breakpoints, respectively. +.pp +Execution continues from the starting address in real-time to the +next breakpoint. There is no intervention between the starting +address and the break address by DDT. If the program under test +does not reach a breakpoint, control cannot return to DDT without +executing a RST 7 instruction. Upon encountering a breakpoint, +DDT stops execution and types +.sp +.ti 8 +*d +.sp +where d is the stop address. The machine state can be examined +at this point using the X (Examine) command. You must +specify breakpoints that differ from the program counter address +at the beginning of the G command. Thus, if the current program +counter is 1234H, then the following commands: +.sp +.nf +.in 8 +G,1234 +G400,400 +.fi +.in 0 +.sp +both produce an immediate breakpoint without executing any +instructions. +.sp 2 +.tc 4.2.5 The I (Input) Command +.sh +4.2.5 The I (Input) Command +.pp +The I command allows you to insert a filename into the default +File Control Block (FCB) at 5CH. The FCB created by CP/M for +transient programs is placed at this location (see Section 5). +The default FCB can be used by the program under test as if it +had been passed by the CP/M Console Processor. Note that this +filename is also used by DDT for reading additional HEX and COM +files. The I command takes the forms: +.sp +.nf +.in 8 +Ifilename +Ifilename.typ +.fi +.in 0 +.pp +If the second form is used and the filetype is either HEX or COM, +subsequent R commands can be used to read the pure binary or hex +format machine code. Section 4.2.8 gives further details. +.sp 2 +.tc 4.2.6 The L (List) Command +.sh +4.2.6 The L (List) Command +.pp +The L command is used to list assembly-language mnemonics in a +particular program region. The L command takes the forms: +.sp +.in 8 +.nf +L +Ls +Ls,f +.fi +.in 0 +.pp +The first form lists twelve lines of disassembled machine code +from the current list address. The second form sets the list +address to s and then lists twelve lines of code. The last form +lists disassembled code from s through address f. In all three +cases, the list address is set to the next unlisted location in +preparation for a subsequent L command. Upon encountering an +execution breakpoint, the list address is set to the current +value of the program counter (G and T commands). Again, long +typeouts can be aborted by pressing RETURN during the list +process. +.sp 2 +.tc 4.2.7 The M (Move) Command +.sh +4.2.7 The M (Move) Command +.pp +The M command allows block movement of program or data areas from +one location to another in memory. The M command takes the form: +.sp +.ti 8 +Ms,f,d +.sp +where s is the start address of the move, f is the final address, +and d is the destination address. Data is first removed from s +to d, and both addresses are incremented. If s exceeds f, the +move operation stops; otherwise, the move operation is repeated. +.sp 2 +.tc 4.2.8 The R (Read) Command +.sh +4.2.8 The R (Read) Command +.pp +The R command is used in conjunction with the I command to read +COM and HEX files from the disk into the transient program +area in preparation for the debug run. The R command takes the forms: +.sp +.in 8 +.nf +R +RB +.fi +.in 0 +.sp +where b is an optional bias address that is added to each program +or data address as it is loaded. The load operation must not +overwrite any of the system parameters from 000H through 0FFH +(that is, the first page of memory). If b is omitted, then +b=0000 is assumed. The R command requires a previous I command, +specifying the name of a HEX or COM file. The load address for +each record is obtained from each individual HEX record, while an +assumed load address of 100H is used for COM files. Note that +any number of R commands can be issued following the I command to +reread the program under test, assuming the tested program does +not destroy the default area at 5CH. Any file specified with the +filetype COM is assumed to contain machine code in pure binary +form (created with the LOAD or SAVE command), and all others are +assumed to contain machine code in Intel hex format (produced, +for example, with the ASM command). +.pp +Recall that the command, +.sp +.ti 8 +DDT filename.filetype +.sp +which initiates the DDT program, equals to the following commands: +.sp +.in 8 +.nf +DDT +-Ifilename.filetype +-R +.fi +.in 0 +.bp +.pp +Whenever the R command is issued, DDT responds with either the +error indicator ? (file cannot be opened, or a checksum error +occurred in a HEX file) or with a load message. The load message +takes the form: +.sp +.in 8 +.nf +NEXT PC +nnnn pppp +.fi +.in 0 +.sp +where nnnn is the next address following the loaded program and +pppp is the assumed program counter (100H for COM files, or +taken from the last record if a HEX file is specified). +.sp 2 +.tc 4.2.9 The S (Set) Command +.sh +4.2.9 The S (Set) Command +.pp +The S command allows memory locations to be examined and +optionally altered. The S command takes the form: +.sp +.ti 8 +Ss +.sp +where s is the hexadecimal starting address for examination and +alteration of memory. DDT responds with a numeric prompt, giving +the memory location, along with the data currently held in +memory. If you type a carriage return, the data is +not altered. If a byte value is typed, the value is stored at +the prompted address. In either case, DDT continues to prompt +with successive addresses and values until you type either a period +or an invalid input value is detected. +.sp 2 +.tc 4.2.10 The T (Trace) Command +.sh +4.2.10 The T (Trace) Command +.pp +The T command allows selective tracing of program execution for 1 +to 65535 program steps. The T command takes the forms: +.sp +.in 8 +.nf +T +Tn +.fi +.in 0 +.mb 4 +.fm 1 +.pp +In the first form, the CPU state is displayed and the next +program step is executed. The program terminates immediately, +with the termination address displayed as +.sp +.ti 8 +*hhhh +.sp +where hhhh is the next address to execute. The display address +(used in the D command) is set to the value of H and L, and the +list address (used in the L command) is set to hhhh. The CPU +state at program termination can then be examined using the X +command. +.pp +The second form of the T command is similar to the first, except +that execution is traced for n steps (n is a hexadecimal value) +before a program breakpoint occurs. A breakpoint can be forced +in the trace mode by typing a rubout character. The CPU state is +displayed before each program step is taken in trace mode. The +format of the display is the same as described in the X command. +.mb 6 +.fm 2 +.pp +You should note that program tracing is discontinued at the +CP/M interface and resumes after return from CP/M to the program +under test. Thus, CP/M functions that access I/O devices, such +as the disk drive, run in real-time, avoiding I/O timing +problems. Programs running in trace mode execute approximately +500 times slower than real-time because DDT gets control after each +user instruction is executed. Interrupt processing routines can +be traced, but commands that use the breakpoint facility (G, T, +and U) accomplish the break using an RST 7 instruction, which +means that the tested program cannot use this interrupt location. +Further, the trace mode always runs the tested program with +interrupts enabled, which may cause problems if asynchronous +interrupts are received during tracing. +.pp +To get control back to DDT during trace, press RETURN rather than +executing an RST 7. This ensures that the trace for current +instruction is completed before interruption. +.sp 2 +.tc 4.2.11 The U (Untrace) Command +.sh +4.2.11 The U (Untrace) Command +.pp +The U command is identical to the T command, except that +intermediate program steps are not displayed. The untrace mode +allows from 1 to 65535, (0FFFFH) steps to be executed in monitored +mode and is used principally to retain control of an executing +program while it reaches steady state conditions. All conditions +of the T command apply to the U command. +.sp 2 +.tc 4.2.12 The X (Examine) Command +.sh +4.2.12 The X (Examine) Command +.pp +The X command allows selective display and alteration of the +current CPU state for the program under test. The X command +takes the forms: +.sp +.in 8 +.nf +X +Xr +.fi +.in 0 +.sp +where r is one of the 8080 CPU registers listed in the following table. +.sp 2 +.sh + Table 4-3. CPU Registers +.sp +.nf + Register Meaning Value +.sp + C Carry flag (0/1) + Z Zero flag (0/1) + M Minus flag (0/1) + E Even parity flag (0/1) + I Interdigit carry (0/1) + A Accumulator (0-FF) + B BC register pair (0-FFFF) + D DE register pair (0-FFFF) +.bp +.sh + Table 4-3. (continued) +.sp +.nf + Register Meaning Value +.sp + H HL register pair (0-FFFF) + S Stack pointer (0-FFFF) + P Program counter (0-FFFF) +.fi +.sp 2 +In the first case, the CPU register state is displayed in the +format: +.sp +.ti 8 +CfZfMfEflf A=bb B=dddd D=dddd H=dddd S=dddd P=dddd inst +.sp +where f is a 0 or 1 flag value, bb is a byte value, and dddd is a +double-byte quantity corresponding to the register pair. The +inst field contains the disassembled instruction, that occurs at +the location addressed by the CPU state's program counter. +.pp +The second form allows display and optional alteration of +register values, where r is one of the registers given above (C, +Z, M, E, I, A, B, D, H, S, or P). In each case, the flag or +register value is first displayed at the console. The DDT +program then accepts input from the console. If a carriage +return is typed, the flag or register value is not altered. If +a value in the proper range is typed, the flag or register value +is altered. You should note that BC, DE, and HL are +displayed as register pairs. Thus, you must type the entire +register pair when B, C, or the BC pair is altered. +.sp 2 +.tc 4.3 Implementation Notes +.he CP/M Operating System Manual 4.3 Implementation Notes +.sh +4.3 Implementation Notes +.pp +The organization of DDT allows certain nonessential portions to +be overlaid to gain a larger transient program area for debugging +large programs. The DDT program consists of two parts: the DDT +nucleus and the assembler/disassembler module. The DDT nucleus +is loaded over the CCP and, although loaded with the DDT nucleus, +the assembler/disassembler is overlayable unless used to assemble +or disassemble. +.pp +In particular, the BDOS address at location 6H (address field of +the JMP instruction at location 5H) is modified by DDT to address +the base location of the DDT nucleus, which, in turn, contains a +JMP instruction to the BDOS. Thus, programs that use this +address field to size memory see the logical end of memory at the +base of the DDT nucleus rather than the base of the BDOS. +.pp +The assembler/disassembler module resides directly below the DDT +nucleus in the transient program area. If the A, L, T, or X +commands are used during the debugging process, the DDT program +again alters the address field at 6H to include this module, +further reducing the logical end of memory. If a program loads +beyond the beginning of the assembler/disassembler module, the A +and L commands are lost (their use produces a ? in response) +and the trace and display (T and X) commands list the inst field +of the display in hexadecimal, rather than as a decoded +instruction. +.nx fourb + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/fourb.tex b/Source/Doc/CPM 22 Manual/fourb.tex new file mode 100644 index 00000000..84f1ac1f --- /dev/null +++ b/Source/Doc/CPM 22 Manual/fourb.tex @@ -0,0 +1,583 @@ +.sp 2 +.tc 4.4 A Sample Program +.he CP/M Operating System Manual 4.4 A Sample Program +.sh +4.4 A Sample Program +.pp +The following example shows an edit, assemble, and debug for a +simple program that reads a set of data values and determines the +largest value in the set. The largest value is taken from the +vector and stored into LARGE at the termination of the program. +.ll 75 +.sp 2 +.nf +A>\c +.sh +ED SCAN.ASM \c +.qs +Create source program; + " " represents carriage return. +*I + ORG 1-00H ;START OF TRANSIENT + ;AREA + MVI B, LEN ;LENGTH OF VECTOR TO SCAN + MVI C, 0 ;LARGER_RST VALUE SO FAR +LOOP LXI H, VECT ;BASE OF VECTOR +LOOP: MOV A, M ;GET VALUE + SUB C ;LARGER VALUE IN C? + JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND +; NEW LARGEST VALUE, STORE IT TO C + MOV C, A +NFOUND INX H ;TO NEXT ELEMENT + DCR B ;MORE TO SCAN? + JNZ LOOP ;FOR ANOTHER +; +; END OF SCAN, STORE C + MOV A, C ;GET LARGEST VALUE + STA LARGE + JMP 0 ;REBOOT +; +; TEST DATA +VECT: DB 2,0,4,3,5,6,1,5 +LEN EQU $-VECT ;LENGTH +LARGE: DS 1 ;LARGEST VALUE ON EXIT + END + +.bp +^-Z +*B0P + ORG 100H ;START OF TRANSIENT AREA + MVI B,LEN ;LENGTH OF VECTOR TO SCAN + MVI C,0 ;LARGEST VALUE SO FAR + LXI H,VECT ;BASE OF VECTOR +LOOP: MOV A,M ;GET VALUE + SUB C ;LARGER VALUE IN C? + JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND +; NEW LARGEST VALUE, STORE IT TO C + MOV C,A +NFOUND: INX H ;TO NEXT ELEMENT + DCR B ;MORE TO SCAN? + JNZ LOOP ;FOR ANOTHER +; END OF SCAN, STORE C + MOV A,C ;GET LARGEST VALUE + STA LARGE + JMP 0 ;REBOOT +; +; TEST DATA + +VECT: DB 2,0,4,3,5,6,1,5 +LEN EQU $-VECT ;LENGTH +LARGE: DS 1 ;LARGEST VALUE ON EXIT + END +*E <--End of edit + +A>\c +.sh +ASM SCAN \c +.qs +Start Assembler + +CP/M ASSEMBLER - VER 1.0 + +0122 +002H USE FACTOR +END OF ASSEMBLY Assembly complete; lock at program listing + +A>\c +.sh +TYPE SCAN.PRN +.qs + Code address Source program + 0100 ORG 100H ;START OF TRANSIENT AREA + 0100 0608 MVI B,LEN ;LENGTH OF VECTOR TO SCAN + 0102 0E00 Machine code MVI C,0 ;LARGEST VALUE SO FAR + 0104 211901 LXI H,VECT. ;BASE OF VECTOR + 0107 7E LOOP: MOV A,M ;GET VALUE + 0108 91 SUB C ;LARGER VALUE IN C? + 0109 D20D01 JNC NFOUND ;JUMP IF LARGER VALUE NOT + ;FOUND + ; NEW LARGEST VALUE, STORE IT TO C + 010C 4F MOV C,A +.bp + 010D 23 NFOUND: INX H ;TO NEXT ELEMENT + 010E 05 DCR B ;MORE TO SCAN? + 010F C20701 JNZ LOOP ;FOR ANOTHER + ; + ; END OF SCAN, STORE C + 0112 79 MOV A,C ;GET LARGEST VALUE + 0113 322101 STA LARGE + + 0116 C30000 JMP 0 ;REBOOT + Code--data listing; + truncated ; TEST DATA + 0119 0200040305 VECT: DB 2,0,4,3,5,6,1,5 + 0008 = Value of LEN EQU $-VECT ;LENGTH + 0121 equate LARGE: DS 1 ;LARGEST VALUE ON EXIT + 0122 END + + +A>\c +.sh +DDT SCAN.HEX \c +.qs +Start debugger using hex format machine code + +DDT VER 1.0 +NEXT PC Next instruction +0121 0000 to execute at +-X Last load address + 1 PC=0 + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0000 OUT 7F +-XP Examine registers before debug run + +P=0000 100 Change PC to 100 + +-X Look at registers again + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +-L100 + PC changed Next instruction + to execute at PC=100 + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C Disassembled machine + 0109 JNC 010D code at 100H + 010C MOV C,A (see source listing + 010D INX H for comparison) + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C +-L +.bp + 0113 STA 0121 + 0116 JMP 0000 + 0119 STAX B + 011A NOP A little more machine + 011B INR B code. Note that pro- + 011C INX B gram ends at location + 011D DCR B 116 with a JMP to + 011E MVI B,01 0000. Remainder of + 0120 DCR B listing is assembly of + 0121 LXI D,2200 data. + 0124 LXI H,0200 +-A116 Enter in-line assembly mode to change the JMP to 0000 into a RST 7, + which will cause the program under test to return to DDT if 116H is + ever executed. +0116 RST 7 + +0117 (Single carriage return stops assemble mode) + +-L113 List code at 113H to check that RST 7 was properly inserted + + 0113 STA 0121 + 0116 RST 07 in place of JMP + 0117 NOP + 0118 NOP + 0119 STAX B + 011A NOP + 011B INR B + 011C INX B +- + +-X Look at registers + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +-T + Execute Program for one stop. Initial CPU state, before is executed + +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08*0102 + Automatic breakpoint + + Trace one step again (note O8H in B) +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0102 MVI C,00*0104 +-T + Trace again (Register C is cleared) +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0104 LXI H,0119*0107 +-T3 Trace three steps +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z0M0E0I0 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JNC 010D*010D +-D119 + Display memory starting at 119H. Automatic breakpoint at 10DH + +0119 02 00 04 03 05 06 01.Program data Lower-case x +0120 05 11 00 22 21 00 02 7E EB 77 13 23 EB 0B 78 B1 ..."!.. . W .#..X. +0130 C2 27 01 C3 03 29 00 00 00 00 00 00 00 00 00 00 ...' ...)......... +0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Data are displayed +0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 in ASCI with a "." +0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 in the position of +0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 nongraphic........ +01A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 characters........ +01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +01C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. +-X + Current CPU state +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +-T5 + Trace 5 steps from current CPU state +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0800 D=0000 H=011A S=0100 P=010E DCR B +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=010F JNZ 0107 +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0700 D=0000 H=011A S=0100 P=0108 SUB C*0109 + +U5 + Automatic breakpoint + Trace without listing intermediate states +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=0109 JNC 010D*0108 +-X + CPU state at end of U5 +C0Z0M0E1I1 A=04 B=0600 D=0000 H=011B S=0100 P=0108 SUB C +-G Run program from current PC until completion (in real-time) + +*0116 breakpoint at 116H, caused by executing RST 7 in machine code. + +-X + CPU state at end of program +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0116 RST 07 +-XP + Examine and change program counter + +P=0116 100 + +-X + +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0100 MVI B,08 +-T10 + + First data element + Current largest value + Subtract for comparison C + Trace 10 (hexadecimal) steps +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0121 S=0100 P=0100 MVI B,08 +C0Z1M0E1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0102 MVI C,00 +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0121 S=0100 P=0104 LXI H,0119 +C0Z1M0E1I1 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z1M0E1I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JNC 010D +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0800 D=0000 H=011A S=0100 P=010E DCR B +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=010F JNZ 0107 +C0Z0M0E0I1 A=02 B=0700 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0700 D=0000 H=011A S=0100 P=0108 SUB C +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=0109 JNC 010D +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011A S=0100 P=010D INX H +C0Z1M0E1I1 A=00 B=0700 D=0000 H=011B S=0100 P=010E DCR B +C0Z0M0E1I1 A=00 B=0600 D=0000 H=011B S=0100 P=010F JNZ 0107 +C0Z0M0E1I1 A=00 B=0600 D=0000 H=011B S=0100 P=0107 MOV A,M*0108 +-A109 + Insert a "hot patch" into Program should have moved the + the machine code value from A into C since A>C. +0109 JC 10D to change the Since this code was not executed, + JNC to JC it appears that the JNC should +010C have been a JC instruction + + Stop DDT so that a version of +-G0 the patched program can be saved + +A>\c +.sh +SAVE 1 SCAN.COM \c +.qs +Program resides on first + page, so save 1 page. +A>\c +.sh +DDT SCAN.COM +.qs + Restart DDT with the save memory +DDT VER 1.0 image to continue testing +NEXT PC +0200 0100 + +-L100 List some code + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C + 0109 JC 010D Previous patch is present in X.COM + 010C MOV C,A + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C + -XP + +P=0100 + +-T10 + Trace to see how patched version operates Data is moved from A to C +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 MVI B,08 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0102 MVI C,00 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0000 S=0100 P=0104 LXI H,0119 +C0Z0M0E0I0 A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M +C0Z0M0E0I0 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JC 010D +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010C MOV C,A +C0Z0M0E0I1 A=02 B=0802 D=0000 H=0119 S=0100 P=010D INX H +C0Z0M0E0I1 A=02 B=0802 D=0000 H=011A S=0100 P=010E DCR B +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=010F JNZ 0107 +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=0107 MOV A,M +C0Z0M0E0I1 A=00 B=0702 D=0000 H=011A S=0100 P=0108 SUB C +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=0109 JC 010D +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=010D INX H +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011B S=0100 P=010E DCR B +C1Z0M0E1I1 A=FE B=0602 D=0000 H=011B S=0100 P=010F JNZ 0107*0107 +-X Breakpoint after 16 steps + +C1Z0M0E1I1 A=FE B=0602 D=0000 H=011B S=0100 P=0107 MOV A,M +-G,108 Run from current PC and breakpoint at 108H + +*0108 +-X + Next data item +C1Z0M0E1I1 A=04 B=0602 D=0000 H=011B S=0100 P=0108 SUB C +-T + Single step for a few cycles +C1Z0M0E1I1 A=04 B=0602 D=0000 H=011B S=0100 P=0108 SUB C*0109 +-T + +C0Z0M0E0I1 A=02 B=0602 D=0000 H=011B S=0100 P=0109 JC 010D*010C +-X + +C0Z0M0E0I1 A=02 B=0602 D=0000 H=011B S=0100 P=010C MOV C,A +-G Run to completion + +*0116 +-X + +C0Z1M0E1I1 A=03 B=0003 D=0000 H=0121 S=0100 P=0116 RST 07 +-S121 Look at the value of "LARGE" + + 0121 03 Wrong value! + + 0122 00 + + 0123 22 + + 0124 21 + + 0125 00 + + 0126 02 + + 0127 7E _\b. End of the S command + +-L100 + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C + 0109 JC 010D + 010C MOV C,A + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C +-L Review the code + + 0113 STA 0121 + 0116 RST 07 + 0117 NOP + 0118 NOP + 0119 STAX B + 011A NOP + 011B INR B + 011C INX B + 011D DCR B + 011E MVI B,01 + 0120 DCR B +-XP + +P=0116 100 Reset the PC + +-T + Single step, and watch data values +C0Z1M0E1I1 A=03 B=0003 D=0000 H=0121 S=0100 P=0100 MVI B,08*0102 +-T + +C0Z1M0E1I1 A=03 B=0803 D=0000 H=0121 S=0100 P=0102 MVI C,00*0104 +-T + Count set Largest set +C0Z1M0E1I1 A=03 B=0800 D=0000 H=0121 S=0100 P=0104 LXI H,0119*0107 +-T + Base address of data set +C0Z1M0E1I1 A=03 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M*0108 +-T + First data item brought to A +C0Z1M0E1I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0108 SUB C*0109 +-T + +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JC 010D*010C +-T + +C0Z0M0E0I1 A=02 B=0800 D=0000 H=0119 S=0100 P=010C MOV C,A*010D +-T + First data item moved to C correctly +C0Z0M0E0I1 A=02 B=0802 D=0000 H=0119 S=0100 P=010D INX H*010E +-T + +C0Z0M0E0I1 A=02 B=0802 D=0000 H=011A S=0100 P=010E DCR B*010F +-T + +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=010F JNZ 0107*0107 +-T + +C0Z0M0E0I1 A=02 B=0702 D=0000 H=011A S=0100 P=0107 MOV A,M*0108 +-T + Second data item brought to A +C0Z0M0E0I1 A=00 B=0702 D=0000 H=011A S=0100 P=0108 SUB C*0109 +-T + Subtract destroys data value that was loaded! +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=0109 JC 010D*010D +-T + +C1Z0M1E0I0 A=FE B=0702 D=0000 H=011A S=0100 P=010D INX H*010E +-L100 + + 0100 MVI B,08 + 0102 MVI C,00 + 0104 LXI H,0119 + 0107 MOV A,M + 0108 SUB C This should have been a CMP so that register A + 0109 JC 010D would not be destroyed. + 010C MOV C,A + 010D INX H + 010E DCR B + 010F JNZ 0107 + 0112 MOV A,C + -A108 + +0108 CMP C Hot patch at 108H changes SUB to CMP + +0109 + +-G0 Stop DDT for SAVE + +A>\c +.sh +SAVE 1 SCAN.COM \c +.qs +Save memory image + +A>\c +.sh +DDT SCAN.COM \c +.qs +Restart DDT + +DDT VER 1.0 +NEXT PC +0200 0100 +-XP + +P=0100 + +-L116 +.mb 5 +.fm 1 + + 0116 RST 07 + 0117 NOP + 0118 NOP Look at code to see if it was properly loaded + 0119 STAX B (long typeout aborted with rubout) + 011A NOP + - + +-G,116 Run from 100H to completion + +*0116 +-XC Look at carry (accidental typo) +C1 +-X Look at CPU state +.mb 6 +.fm 2 + +C1Z1M0E1I1 A=06 B=0006 D=0000 H=0121 S=0100 P=0116 RST 07 +-S121 Look at "large"--it appears to be correct. + +0121 06 + +0122 00 + +0123 22 + +-G0 Stop DDT + +A>\c +.sh +ED SCAN.ASM \c +.qs +Re-edit the source program, and make both changes + +*NSUB +*0LT + CTRL-Z SUB C ;LARGER VALUE IN C? +*SSUB^\b|ZCMP^\b|Z0LT + CMP D ;LARGER VALUE IN C? +* + JNC NFOUND ;JUMP IF LARGER VALUE NOT FOUND +*SNC^\b|ZC^\b|Z0LT + JC NFOUND ;JUMP IF LARGER VALUE NOT FOUND +*E + Reassemble, selecting source from disk A +A>\c +.sh +ASM SCAN.AAZ \c +.qs +<--- Hex to disk A + Print to Z (selects no print file) +CP/M ASSEMBLER VER 1.0 + +0122 +002H USE FACTOR +END OF ASSEMBLY + +A>\c +.sh +DDT SCAN.HEX \c +.qs +Rerun debugger to check changes + +DDT VER 1.0 +NEXT PC +0121 0000 +-L116 + + 0116 JMP 0000 Check to ensure end is still at 116H + + 0119 STAX B + + 011A NOP + 011B INR B + + -(rubout) + +-G100,116 Go from beginning with breakpoint at end + +*0116 Breakpoint reached +-D121 Look at "LARGE" + Correct value computed +0121 06 00 22 21 00 02 7E EB 77 13 23 EB 0B 78 B1 .. '!... W .#..X. +0130 C2 27 01 C3 03 29 00 00 00 00 00 00 00 00 00 00 .'...)........ +0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .............. + +-(rubout) Aborts long typeout + +G0 Stop DDT, debug session complete. +.ll 65 +.sp 2 +.ce +End of Section 4 +.nx fivea + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/front.tex b/Source/Doc/CPM 22 Manual/front.tex new file mode 100644 index 00000000..6c6df942 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/front.tex @@ -0,0 +1,447 @@ +.op +.sp 15 +.ce 100 +.sh +CP/M +.sp +.sh +Operating System +.sp +.sh +Manual +.cs 5 +.sp 10 +Copyright (c) 1982 +.sp +Digital Research +P.O. Box 579 +160 Central Avenue +Pacific Grove, CA 93950 +(408) 649-3896 +TWX 910 360 5001 +.sp 4 +All Rights Reserved +.ce 0 +.bp +.po 17 +.ll 50 +.ce +COPYRIGHT +.sp +Copyright (c) 1976, 1977, 1978, 1979, 1982, 1983, and 1984 by +Digital Research Inc. All rights reserved. No part of this +publication may be reproduced, transmitted, transcribed, stored +in a retrieval system, or translated into any language or +computer language, in any form or by any means, electronic, mechanical, +magnetic, optical, chemical, manual or otherwise, without the prior +written permission of Digital Research Inc., Post Office Box 579, +Pacific Grove, California, 93950. +.sp +Thus, readers are granted permission to include the example +programs, either in whole or in part, in their own programs. +.sp 2 +.ce +DISCLAIMER +.sp +Digital Research Inc. makes no representations or warranties with +respect to the contents hereof and specifically disclaims +any implied warranties of merchantability or fitness for +any particular purpose. Further, Digital Research Inc. reserves the +right to revise this publication and to make changes from +time to time in the content hereof without obligation of +Digital Research Inc. to notify any person of such revision or +changes. +.sp 2 +.ce +TRADEMARKS +.sp +CP/M, CP/NET, and Digital Research and its logo are registered +trademarks of Digital Research. ASM, DESPOOL, DDT, LINK-80, MAC, +MP/M, PL/I-80 and SID are trademarks of Digital Research. IBM is +a registered trademark of International Business Machines. Intel +is a registered trademark of Intel Corporation. TI Silent 700 is +a trademark of Texas Instruments Incorporated. Zilog and Z80 are +registered trademarks of Zilog, Inc. +.mb 4 +.fm 1 +.sp 3 +The \c +.ul +CP/M Operating System Manual \c +.qu +was prepared using the Digital Research TEX Text Formatter and printed +in the United States of America. +.sp 2 +.ce 6 +********************************* +* First Edition: 1976 * +* Second Edition: July 1982 * +* Third Edition: March 1983 * +* Fourth Edition: March 1984 * +********************************* +.po 10 +.ll 65 +.in 0 +.bp +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft iii +.bp +.ce +.sh +Table of Contents +.sp 3 +.nf +.sh +1 CP/M Features and Facilities +.sp + 1.1 Introduction . . . . . . . . . . . . . . . . . . . 1-1 +.sp + 1.2 Functional Description . . . . . . . . . . . . . . 1-3 +.sp + 1.2.1 General Command Structure . . . . . . . . . 1-3 + 1.2.2 File References . . . . . . . . . . . . . . 1-3 +.sp + 1.3 Switching Disks . . . . . . . . . . . . . . . . . . 1-5 + 1.4 Built-in Commands . . . . . . . . . . . . . . . . . 1-6 +.sp + 1.4.1 ERA Command . . . . . . . . . . . . . . . . 1-6 + 1.4.2 DIR Command . . . . . . . . . . . . . . . . 1-7 + 1.4.3 REN Command . . . . . . . . . . . . . . . . 1-8 + 1.4.4 SAVE Command . . . . . . . . . . . . . . . . 1-8 + 1.4.5 TYPE Command . . . . . . . . . . . . . . . . 1-9 + 1.4.6 USER Command . . . . . . . . . . . . . . . . 1-9 +.sp + 1.5 Line Editing and Output Control . . . . . . . . . . 1-10 +.sp + 1.6 Transient Commands . . . . . . . . . . . . . . . . 1-11 +.sp + 1.6.1 STAT Command . . . . . . . . . . . . . . . . 1-12 + 1.6.2 ASM Command . . . . . . . . . . . . . . . . 1-18 + 1.6.3 LOAD Command . . . . . . . . . . . . . . . . 1-19 + 1.6.4 PIP . . . . . . . . . . . . . . . . . . . . 1-20 + 1.6.5 ED Command . . . . . . . . . . . . . . . . . 1-29 + 1.6.6 SYSGEN Command . . . . . . . . . . . . . . . 1-31 + 1.6.7 SUBMIT Command . . . . . . . . . . . . . . . 1-33 + 1.6.8 DUMP Command . . . . . . . . . . . . . . . . 1-35 + 1.6.9 MOVCPM Command . . . . . . . . . . . . . . . 1-35 +.sp + 1.7 BDOS Error Messages . . . . . . . . . . . . . . . . 1-37 +.sp + 1.8 CP/M Operation on the Model 800 . . . . . . . . . . 1-38 +.sp 2 +.sh +2 The CP/M Editor +.sp + 2.1 Introduction to ED . . . . . . . . . . . . . . . . 2-1 +.sp + 2.1.1 ED Operation . . . . . . . . . . . . . . . . 2-1 + 2.1.2 Text Transfer Functions . . . . . . . . . . 2-3 + 2.1.3 Memory Buffer Organization . . . . . . . . . 2-4 + 2.1.4 Line Numbers and ED Start-up . . . . . . . . 2-5 + 2.1.5 Memory Buffer Operation . . . . . . . . . . 2-6 + 2.1.6 Command Strings . . . . . . . . . . . . . . 2-7 + 2.1.7 Text Search and Alteration . . . . . . . . . 2-10 + 2.1.8 Source Libraries . . . . . . . . . . . . . . 2-13 + 2.1.9 Repetitive Command Execution . . . . . . . . 2-14 +.bp +.ft iv +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 + 2.2 ED Error Conditions . . . . . . . . . . . . . . . . 2-14 +.sp + 2.3 Control Characters and Commands . . . . . . . . . . 2-16 +.sp 2 +.sh +3 CP/M Assembler +.qs +.sp + 3.1 Introduction . . . . . . . . . . . . . . . . . . . 3-1 +.sp + 3.2 Program Format . . . . . . . . . . . . . . . . . . 3-3 +.sp + 3.3 Forming the Operand . . . . . . . . . . . . . . . . 3-4 +.sp + 3.3.1 Labels . . . . . . . . . . . . . . . . . . . 3-4 + 3.3.2 Numeric Constants . . . . . . . . . . . . . 3-5 + 3.3.3 Reserved Words . . . . . . . . . . . . . . . 3-5 + 3.3.4 String Constants . . . . . . . . . . . . . . 3-6 + 3.3.5 Arithmetic and Logical Operators . . . . . . 3-7 + 3.3.6 Precedence of Operators . . . . . . . . . . 3-8 +.sp + 3.4 Assembler Directives . . . . . . . . . . . . . . . 3-9 +.sp + 3.4.1 The ORG Directive . . . . . . . . . . . . . 3-10 + 3.4.2 The END Directive . . . . . . . . . . . . . 3-10 + 3.4.3 The EQU Directive . . . . . . . . . . . . . 3-11 + 3.4.4 The SET Directive . . . . . . . . . . . . . 3-11 + 3.4.5 The IF and ENDIF Directives . . . . . . . . 3-12 + 3.4.6 The DB Directive . . . . . . . . . . . . . . 3-13 + 3.4.7 The DW Directive . . . . . . . . . . . . . . 3-14 + 3.4.8 The DS Directive . . . . . . . . . . . . . . 3-14 +.sp + 3.5 Operation Codes . . . . . . . . . . . . . . . . . . 3-15 +.sp + 3.5.1 Jumps, Calls, and Returns . . . . . . . . . 3-15 + 3.5.2 Immediate Operand Instructions . . . . . . . 3-17 + 3.5.3 Increment and Decrement Instructions . . . . 3-17 + 3.5.4 Data Movement Instructions . . . . . . . . . 3-18 + 3.5.5 Arithmetic Logic Unit Operations . . . . . . 3-19 + 3.5.6 Control Instructions . . . . . . . . . . . . 3-21 +.sp + 3.6 Error Messages . . . . . . . . . . . . . . . . . . 3-21 +.sp + 3.7 A Sample Session . . . . . . . . . . . . . . . . . 3-23 +.bp +.ft v +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 +.sh +4 CP/M Dynamic Debugging Tool +.qs +.sp + 4.1 Introduction . . . . . . . . . . . . . . . . . . . 4-1 +.sp + 4.2 DDT Commands . . . . . . . . . . . . . . . . . . . 4-3 +.sp + 4.2.1 The A (Assembly) Command . . . . . . . . . . 4-3 + 4.2.2 The D (Display) Command . . . . . . . . . . 4-4 + 4.2.3 The F (Fill) Command . . . . . . . . . . . . 4-5 + 4.2.4 The G (Go) Command . . . . . . . . . . . . . 4-5 + 4.2.5 The I (Input) Command . . . . . . . . . . . 4-6 + 4.2.6 The L (List) Command . . . . . . . . . . . . 4-6 + 4.2.7 The M (Move) Command . . . . . . . . . . . . 4-7 + 4.2.8 The R (Read) Command . . . . . . . . . . . . 4-7 + 4.2.9 The S (Set) Command . . . . . . . . . . . . 4-8 + 4.2.1- The T (Trace) Command . . . . . . . . . . . 4-8 + 4.2.11 The U (Untrace) Command . . . . . . . . . . 4-9 + 4.2.12 The X (Examine) Command . . . . . . . . . . 4-9 +.sp + 4.3 Implementation Notes . . . . . . . . . . . . . . . 4-10 +.sp + 4.4 A Sample Program . . . . . . . . . . . . . . . . . 4-11 +.sp 2 +.sh +5 CP/M 2 System Interface +.qs +.sp + 5.1 Introduction . . . . . . . . . . . . . . . . . . . 5-1 +.sp + 5.2 Operating System Call Conventions . . . . . . . . . 5-3 +.sp + 5.3 A Sample File-to-File Copy Program . . . . . . . . 5-35 +.sp + 5.4 A Sample File Dump Utility . . . . . . . . . . . . 5-38 +.sp + 5.5 A Sample Random Access Program . . . . . . . . . . 5-42 +.sp + 5.6 System Function Summary . . . . . . . . . . . . . . 5-50 +.sp 2 +.sh +6 CP/M 2 Alteration +.qs +.sp + 6.1 Introduction . . . . . . . . . . . . . . . . . . . 6-1 +.sp + 6.2 First-level System Regeneration . . . . . . . . . . 6-2 +.sp + 6.3 Second-level System Generation . . . . . . . . . . 6-5 +.sp + 6.4 Sample GETSYS and PUTSYS Programs . . . . . . . . . 6-9 +.bp +.ft vi +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 + 6.5 Disk Organization . . . . . . . . . . . . . . . . . 6-11 +.sp + 6.6 The BIOS Entry Points . . . . . . . . . . . . . . . 6-13 +.sp + 6.7 A Sample BIOS . . . . . . . . . . . . . . . . . . . 6-21 +.sp + 6.8 A Sample Cold Start Loader . . . . . . . . . . . . 6-21 +.sp + 6.9 Reserved Locations in Page Zero . . . . . . . . . . 6-22 +.sp + 6.10 Disk Parameter Tables . . . . . . . . . . . . . . 6-23 +.sp + 6.11 The DISKDEF Macro Library . . . . . . . . . . . . 6-28 +.sp + 6.12 Sector Blocking and Deblocking . . . . . . . . . . 6-32 +.bp +.ft vii +.ce +.sh +Appendixes +.qs +.sp 3 +.sh +A \c +.qs +Basic Input/Output System (BIOS) . . . . . . . . . . . A-1 +.sp 2 +.sh +B \c +.qs +A Skeletal CBIOS . . . . . . . . . . . . . . . . . . . B-1 +.sp 2 +.sh +C \c +.qs +A Skeletal GETSYS/PUTSYS Program . . . . . . . . . . . C-1 +.sp 2 +.sh +D \c +.qs +The Model 800 Cold Start Loader for CP/M 2 . . . . . . D-1 +.sp 2 +.sh +E \c +.qs +A Skeletal Cold Start Loader . . . . . . . . . . . . . E-1 +.sp 2 +.sh +F \c +.qs +CP/M Disk Definition Library . . . . . . . . . . . . . F-1 +.sp 2 +.sh +G \c +.qs +Blocking and Deblocking Algorithms . . . . . . . . . . G-1 +.sp 2 +.sh +H \c +.qs +Glossary . . . . . . . . . . . . . . . . . . . . . . . H-1 +.sp 2 +.sh +I \c +.qs +CP/M Error Messages . . . . . . . . . . . . . . . . . . I-1 +.bp +.ft viii +.ce +.sh +Tables, Figures, and Listings +.qs +.sp 3 +.sh +Tables +.qs +.sp + 1-1. Line-editing Control Characters . . . . . . . . 1-10 + 1-2. CP/M Transient Commands . . . . . . . . . . . . 1-11 + 1-3. Physical Devices . . . . . . . . . . . . . . . 1-14 + 1-4. PIP Parameters . . . . . . . . . . . . . . . . 1-24 +.sp + 2-1. ED Text Transfer Commands . . . . . . . . . . . 2-3 + 2-2. Editing Commands . . . . . . . . . . . . . . . 2-6 + 2-3. Line-editing Controls . . . . . . . . . . . . . 2-7 + 2-4. Error Message Symbols . . . . . . . . . . . . . 2-13 + 2-5. ED Control Characters . . . . . . . . . . . . . 2-14 + 2-6. ED Commands . . . . . . . . . . . . . . . . . . 2-15 +.sp + 3-1. Reserved Characters . . . . . . . . . . . . . . 3-6 + 3-2. Arithmetic and Logical Operators . . . . . . . 3-7 + 3-3. Assembler Directives . . . . . . . . . . . . . 3-9 + 3-4. Jumps, Calls, and Returns . . . . . . . . . . . 3-15 + 3-5. Immediate Operand Instructions . . . . . . . . 3-16 + 3-6. Increment and Decrement Instructions . . . . . 3-17 + 3-7. Data Movement Instructions . . . . . . . . . . 3-17 + 3-8. Arithmetic Logic Unit Operations . . . . . . . 3-18 + 3-9. Error Codes . . . . . . . . . . . . . . . . . . 3-20 + 3-10. Error Messages . . . . . . . . . . . . . . . . 3-21 +.sp + 4-1. Line-editing Controls . . . . . . . . . . . . . 4-2 + 4-2. DDT Commands . . . . . . . . . . . . . . . . . 4-2 + 4-3. CPU Registers . . . . . . . . . . . . . . . . . 4-9 +.sp + 5-1. CP/M Filetypes . . . . . . . . . . . . . . . . 5-6 + 5-2. File Control Block Fields . . . . . . . . . . . 5-7 + 5-3. Edit Control Characters . . . . . . . . . . . . 5-20 +.sp + 6-1. Standard Memory Size Values . . . . . . . . . . 6-2 + 6-2. Common Values for CP/M Systems . . . . . . . . 6-7 + 6-3. CP/M Disk Sector Allocation . . . . . . . . . . 6-11 + 6-4. IOBYTE Field Values . . . . . . . . . . . . . . 6-15 + 6-5. BIOS Entry Points . . . . . . . . . . . . . . . 6-16 + 6-6. Reserved Locations in Page Zero . . . . . . . . 6-21 + 6-7. Disk Parameter Headers . . . . . . . . . . . . 6-23 + 6-8. BSH and BLM Values . . . . . . . . . . . . . . 6-25 + 6-9. EXM Values . . . . . . . . . . . . . . . . . . 6-25 + 6-10. BLS Tabluation . . . . . . . . . . . . . . . . 6-26 +.sp + I-1. CP/M Error Messages . . . . . . . . . . . . . . I-1 +.sp 2 +.sh +Figures +.qs +.sp + 2-1. Overall ED Operation . . . . . . . . . . . . . 2-2 + 2-2. Memory Buffer Organization . . . . . . . . . . 2-2 +.bp +.ft ix +.ce +.sh +Tables, Figures, and Listings +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 +.sh +Figures +.qs +.sp + 2-3. Logical Organization of Memory Buffer . . . . . 2-4 +.sp + 5-1. CP/M Memory Organization . . . . . . . . . . . 5-1 + 5-2. File Control Block Format . . . . . . . . . . . 5-7 +.sp + 6-1. IOBYTE Fields . . . . . . . . . . . . . . . . . 6-15 + 6-2. Disk Parameter Header Format . . . . . . . . . 6-22 + 6-3. Disk Parameter Header Table . . . . . . . . . . 6-23 + 6-4. Disk Parameter Block Format . . . . . . . . . . 6-24 + 6-5. AL0 and AL1 . . . . . . . . . . . . . . . . . . 6-25 +.sp 2 +.sh +Listings +.qs +.sp + 6-1. GETSYS Program . . . . . . . . . . . . . . . . 6-9 + 6-2. BIOS Entry Points . . . . . . . . . . . . . . . 6-13 +.nx onea + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/index.tex b/Source/Doc/CPM 22 Manual/index.tex new file mode 100644 index 00000000..e7f353ec --- /dev/null +++ b/Source/Doc/CPM 22 Manual/index.tex @@ -0,0 +1,468 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft Index-% +.nf +.ce +.sh +Index +.qs +.sp 3 +.sh +A +.qs +Absolute line number, 36 +Access mode, 13 +afn (ambiguous file + reference), 3, 4, 6 +Allocation vector, 105 +Ambiguous file reference + (afn), 3, 4, 6 +ASM, 15, 47 +Assembler, 15, 47 +Assembler/disassembler module + (DDT), 77 +Assembler errors, 62 +Assembly language mnemonics + in DDT, 71, 74 +Assembly language program, 49 +Assembly language statement, 49 +Automatic command + processing, 25 +.sp +.sh +B +.qs +.sp +Base, 50 +Basic Disk Operating System + (BDOS), 2, 89, 127 +Basic I/O System (BIOS), + 2, 89, 127 +BDOS (Basic Disk Operating + System), 2, 89, 127 +Binary constants, 50 +BIOS (Basic I/O System), + 2, 89, 127 +BIOS disk definition, 137, 148 + subroutines +Block move command, 74 +bls parameter, 149 +BOOT, 90, 136, 140 + entry point +Break point, 71, 73 +Built-in commands, 3 +.sp +.sh +C +.qs +.sp +Case translation, 5, 6, 20, + 37, 39, 44, 45, 51, 95 +CCP (Console Command + Processor), 2, 69, 89, 127 +CCP Stack, 92 +Character pointer, 35 +CKS parameter, 149 +Close File function, 101 +Code and data areas, 144 +Cold start loader, 136, + 140, 143 +Combine files, 17 +Command, 3 +Command line, 90 +Comment field, 49 +Compute File Size + function, 108 +Condition flags, 58, 77 +Conditional assembly, 56 +CONIN, 140 +CONOUT, 141 +CONSOLE, 138 +Console Command Processor + (CCP), 2, 69, 89, 127 +Console Input function, 95 +Console Output function, 96 +CONST, 140 +Constant, 50 +Control characters, 9, +Control functions, 9 +CTRL-Z character, 93 +Copy files, 17 +CPU state, 71 +cr (carriage return), 39 +Create files, 23 +Create system disk, 24 +Creating COM files, 16 +Currently logged disk, + 3, 5, 10, 17, 25 +.sp +.sh +D +.qs +.sp +Data allocation size, 147 +Data block number, 147 +DB statement, 57 +DDT commands, 70, 133 +DDT nucleus, 77 +DDT prompt, 70 +DDT sign-on message, 69 +Decimal constant, 50 +Default FCB, 73 +Delete File function, 102 +DESPOOL, 138 +Device assignment, 11 +DIR, 6 +DIR attribute, 14 +dir parameter, 149 +Direct console I/O + function, 97 +Direct Memory Address, 104 +Directory, 6 +Directory code, 100, 101, + 102, 103 +Disassembler, 71, 77 +Disk attributes, 11 +Disk drive name, 5 +Disk I/O functions, 99-110 +Disk parameter block, 146 +Disk parameter header, 145 +Disk parameter table, 145 +Disk statistics, 10 +Disk-to-disk copy, 18 +DISKDEF macro, 149 +Diskette format, 31 +DISKS macro, 150, 186 +Display file contents, 8 +dks parameter, 149 +DMA, 104 +DMA address, 93 +dn parameter, 149 +DPBASE, 146 +Drive characteristics, 14 +Drive select code, 94 +Drive specification, 5 +DS statement, 57 +DUMP, 27, 113 +DW statement, 57 +.sp +.sh +E +.qs +.sp +ED, 23, 33-45, 131 +ED commands, 38, 44 +ED errors, 43 +Edit command line, 9 +8080 CPU registers, 76 +8080 registers, 51 +end-of-file, 19, 93 +END statement, 49, 54 +EMDEF macro, 150 +ENDIF statement, 56 +EQU statement, 55 +ERA, 6 +Erase files, 6 +Error messages, 29, 43, + 62, 153 +Expression, 49 +Extents, 13 +.sp +.sh +F +.qs +.sp +FBASE, 89 +FCB, 93, 94 +FCB format, 93, 94 +FDOS (operations), 89, 91 +File attributes, 14 +File compatibility, 23 +File control block (FCB), + 93, 94 +File expansion, 128 +File extent, 93 +File indicators, 14 +File names, 3 +File reference, 3 +File statistics, 10, 13 +Filetype, 93 +Find command, 39 +fsc parameter, 149 +.sp +.sh +G +.qs +.sp +Get ADDR (Alloc) function, + 105 +Get ADDR (Disk Parms) + function, 106 +Get Console Status, 99 +Get I/O Byte function, 97 +Get Read/Only Vector + function, 105 +GETSYS, 128, 134 +.sp +.sh +H +.qs +.sp +Hexadecimal, 49, 50 +Hex files, 16, 19, 20, 47 +HOME subroutine, 139, 141 +.sp +.sh +I +.qs +.sp +Identifier, 49, 50 +IF statement, 56 +Initialized storage areas, 57 +In-line assembly language, 71 +Insert mode, 37 +Insert String, 40 +IOBYTE function, 138, 139 +.sp +.sh +J +.qs +.sp +Jump vector, 137 +Juxtaposition command,41 +.sp +.sh +K +.qs +.sp +Key fields, 109 +.sp +.sh +L +.qs +.sp +Label field, 49 +Labels, 48, 49, 58 +Library read command, 42 +Line-editing control + characters, 38, 70, 98 +Line-editing functions, 9 +Line numbers, 36 +LIST, 138, 141 +List Output function, 96 +LISTST, 142 +LOAD, 16 +Logged in, 3 +Logical devices, 11, 18, 138 +Logical extents, 93 +Logical-physical assignments, + 12, 139 +Logical to physical device + mapping, 138 +Logical to physical sector + translation, 143, 149 +Isc parameter, 149 +.sp +.sh +M +.qs +.sp +Machine executable code, 16 +Macro command, 42 +Make File function, 103 +Memory buffer, 33, 34, 35, 37 +Memory image, 71, 131, 132 +Memory image file, 16 +Memory size, 27, 128, 132 +MOVCPM, 27, 131, 132 +Multiple command + processing, 25 +.sp +.sh +N +.qs +.sp +{o} parameter, 149 +Octal constant, 50 +ofs parameter, 150 +On-line status, 100 +Open File function, 100 +Operand field, 49-51 +Operation field, 49-58 +Operators, 52, 53, 58 +ORG directive, 54 +.sp +.sh +P +.qs +.sp +Page zero, 144 +Patching the CP/M system, 128 +Peripheral devices, 138 +Physical devices, 12, 18, 139 +Physical file size, 109 +Physical to logical device + assignment, 12, 139 +PIP, 17 +PIP devices, 19 +PIP parameters, 20 +Print String function, 98 +PRN file, 47 +Program counter, 71, 73, 76 +Program tracing, 75 +Prompt, 3 +Pseudo-operation, 53 +PUNCH, 138, 141 +Punch Output function, 96 +PUTSYS, 129, 135 +.sp +.sh +R +.qs +.sp +Radix indicators, 50 +Random access, 107, 108, 117 +Random record number, 108 +READ, 142 +Read Console Buffer + function, 98 +Read only, 14 +Read/only status, 14 +Read random error codes, 107 +Read Random function, 107 +READ routine, 139 +Read Sequential function, 102 +Read/write, 14 +READER, 138, 141 +Reader Input function, 96 +REN, 7 +Rename file function, 104 +Reset Disk function, 99 +Reset Drive function, 109 +Reset state, 99 +Return Current Disk + function, 104 +Return Log-in Vector + function, 104 +Return Version Number + function, 99 +R/O, 14 +R/O, attribute, 106 +R/O bit, 105 +R/W, 14 +.sp +.sh +S +.qs +.sp +SAVE, 7 +SAVE command, 70 +Search for First function, 101 +Search for Next function, 102 +Search strings, 39 +Sector allocation, 136 +SECTRAN, 143 +SELDSK, 139, 141, 146 +Select Disk function, 100 +Sequential access, 93 +Set DMA address function, 104 +Set File Attributes + function, 106 +Set/GET User Code + function, 106 +Set I/O Byte function, 97 +Set Random Record + function, 109 +SET statement, 55 +SETDMA, 142 +SETSEC, 142 +SETTRK, 141 +Simple character I/O, 138 +Size in records, 13 +skf parameter, 149, 150 +Source files, 93 +Stack pointer, 92 +STAT, 10, 139, 151 +Stop console output, 9 +String substitutions, 40 +SUBMIT, 25 +SYS attribute, 14 +SYSGEN, 24, 134 +System attribute, 44, 106 +System parameters, 140 +System (re)initialization, 138 +System Reset function, 95 +.sp +.sh +T +.qs +.sp +Testing and debugging of + programs, 69 +Text transfer commands, 35 +TPA (Transient Program Area), + 2, 89 +Trace mode, 76 +Transient commands, 3, 9 +Transient Program Area + (TPA), 2, 89 +Translate table, 150 +Translation vectors, 146 +TYPE, 8 +.sp +.sh +U +.qs +.sp +ufn, 3, 6 +Unambiguous file reference, + 3, 6 +Uninitialized memory, 57 +Untrace mode, 76 +USER, 8 +USER numbers, 8, 15, 106 +.sp +.sh +V +.qs +.sp +Verify line numbers command, + 37, 45 +Version independent + programming, 99 +Virtual file size, 108 +.sp +.sh +W +.qs +.sp +Warm start, 90, 140 +WBOOT entry point, 140 +WRITE, 142 +Write Protect Disk + function, 105 +Write random error codes, 108 +Write Random function, 108 +Write Random with Zero Fill + function, 110 +Write routine, 142 +Write Sequential function, 103 +.sp +.sh +X +.qs +.sp +XSOB, 26 +.fi + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/onea.tex b/Source/Doc/CPM 22 Manual/onea.tex new file mode 100644 index 00000000..51969d60 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/onea.tex @@ -0,0 +1,990 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 1-% +.pc 1 +.tc 1 CP/M Features and Facilities +.ce 2 +.sh +Section 1 +.sp +.sh +CP/M Features and Facilities +.qs +.sp 3 +.he CP/M Operating System Manual 1.1 Introduction +.tc 1.1 Introduction +.sh +1.1 Introduction +.qs +.fi +.pp 5 +CP/M \ is a monitor control program for microcomputer system development that +uses floppy disks or Winchester hard disks for backup storage. Using a +computer system based on the Intel \ 8080 microcomputer, CP/M provides an +environment for program construction, storage, and editing, along +with assembly and program check-out facilities. CP/M can be easily +altered to execute with any computer +configuration that uses a Zilog \ Z80 \ or an Intel 8080 Central Processing +Unit (CPU) and has at least 20K bytes of main memory with up to 16 disk +drives. A detailed discussion of the modifications required for any +particular hardware environment is given in Section 6. Although the +standard Digital Research version operates on a single-density +Intel Model 800, microcomputer development system several different +hardware manufacturers support their own input-output (I/O) drivers for CP/M. +.pp +The CP/M monitor provides rapid access to programs through a comprehensive +file management package. The file subsystem supports a named file structure, +allowing dynamic allocation of file space as well as sequential and random +file access. Using this file system, a large number of programs can be +stored in both source and machine-executable form. +.pp +CP/M 2 is a high-performance, single console operating system that uses +table-driven techniques to allow field reconfiguration to match a wide +variety of disk capacities. All fundamental file restrictions are removed, +maintaining upward compatibility from previous versions of release 1. +.pp +Features of CP/M 2 include field specification of one to sixteen logical +drives, each containing up to eight megabytes. Any particular file can +reach the full drive size with the capability of expanding to thirty-two +megabytes in future releases. The directory size can be field-configured to +contain any reasonable number of entries, and each file is optionally tagged +with Read-Only and system attributes. Users of CP/M 2 are physically +separated by user numbers, with facilities for file copy operations from one +user area to another. Powerful relative-record random access functions are +present in CP/M 2 that provide direct access to any of the 65536 records of +an eight-megabyte file. +.pp +CP/M also supports ED, a powerful context editor, ASM , an Intel-compatible +assembler, and DDT , debugger subsystems. Optional software includes a +powerful +Intel-compatible macro assembler, symbolic debugger, along with various +high-level languages. When coupled with CP/M's Console Command +Processor (CCP), +the resulting facilities equal or exceed similar large computer facilities. +.pp +CP/M is logically divided into several distinct parts: +.sp +.in 3 +.nf +o BIOS (Basic I/O System), hardware-dependent +o BDOS (Basic Disk Operating System) +o CCP (Console Command Processor) +o TPA (Transient Program Area) +.fi +.in 0 +.pp +The BIOS provides the primitive operations necessary to access the disk +drives and to interface standard peripherals: teletype, CRT, paper tape +reader/punch, and user-defined peripherals. You can tailor +peripherals for any particular hardware environment by patching this +portion of +CP/M. The BDOS provides disk management by controlling one or more disk +drives containing independent file directories. The BDOS implements disk +allocation strategies that provide fully dynamic file construction while +minimizing head movement across the disk during access. The BDOS has entry +points that include the following primitive operations, which the +program accesses: +.sp +.in 5 +.ti -2 +o SEARCH looks for a particular disk file by name. +.ti -2 +o OPEN opens a file for further operations. +.ti -2 +o CLOSE closes a file after processing. +.ti -2 +o RENAME changes the name of a particular file. +.ti -2 +o READ reads a record from a particular file. +.ti -2 +o WRITE writes a record to a particular file. +.ti -2 +o SELECT selects a particular disk drive for further operations. +.in 0 +.pp +The CCP provides a symbolic interface between your console and the +remainder of the CP/M system. The CCP reads the console device and +processes commands, which include listing the file directory, printing the +contents of files, and controlling the operation of transient programs, such +as assemblers, editors, and debuggers. The standard commands that are +available in the CCP are listed in Section 1.2.1. +.pp +The last segment of CP/M is the area called the Transient Program +Area (TPA). The TPA holds programs that are loaded from the disk under +command of the CCP. During program editing, for example, the TPA holds +the CP/M text editor machine code and data areas. Similarly, programs +created under CP/M can be checked out by loading and executing these +programs in the TPA. +.pp +Any or all of the CP/M component subsystems can be overlaid by an +executing program. That is, once a user's program is loaded into the TPA, +the CCP, BDOS, and BIOS areas can be used as the program's data area. +A bootstrap loader is programmatically accessible whenever the BIOS portion +is not overlaid; thus, the user program need only branch to the bootstrap +loader at the end of execution and the complete CP/M monitor is reloaded +from disk. +.pp +The CP/M operating system is partitioned into distinct modules, including +the BIOS portion that defines the hardware environment in which CP/M is +executing. Thus, the standard system is easily modified to any nonstandard +environment by changing the peripheral drivers to handle the custom system. +.bp +.tc 1.2 Functional Description +.he CP/M Operating System Manual 1.2 Functional Description +.sh +1.2 Functional Description +.qs +.pp +You interact with CP/M primarily through the CCP, which reads and +interprets commands entered through the console. In general, the CCP +addresses one of several disks that are on-line. The standard system +addresses up to sixteen different disk drives. These disk drives are +labeled A through P. A disk is logged-in if the CCP is currently +addressing the disk. To clearly indicate which disk is the currently logged +disk, the CCP always prompts the operator with the disk name followed by the +symbol >, indicating that the CCP is ready for another command. Upon +initial start-up, the CP/M system is loaded from disk A, and the CCP +displays the following message: +.sp +.ti 8 +CP/M VER x.x +.sp +where x.x is the CP/M version number. All CP/M systems are initially set +to operate in a 20K memory space, but can be easily reconfigured to fit any +memory size on the host system (see Section 1.6.9). Following system +sign-on, CP/M automatically logs in disk A, prompts you with the +symbol A>, indicating that CP/M is currently addressing disk A, and +waits for a command. The commands are implemented at two levels: built-in +commands and transient commands. +.sp 2 +.tc 1.2.1 General Command Structure +.sh +1.2.1 General Command Structure +.qs +.pp +Built-in commands are a part of the CCP program, while transient +commands are loaded into the TPA from disk and executed. The +following are built-in commands: +.sp +.in 3 +.nf +o ERA erases specified files. +o DIR lists filenames in the directory. +o REN renames the specified file. +o SAVE saves memory contents in a file. +o TYPE types the contents of a file on the logged disk. +.in 0 +.fi +.sp +Most of the commands reference a particular file or group of files. The +form of a file reference is specified in Section 1.2.2. +.sp 2 +.tc 1.2.2 File References +.sh +1.2.2 File References +.qs +.pp +A file reference identifies a particular file or group of files on a +particular disk attached to CP/M. These file references are +either unambiguous (ufn) or ambiguous (afn). An unambiguous file +reference uniquely identifies a single file, while an ambiguous file +reference is satisfied by a number of different files. +.mb 5 +.fm 1 +.pp +File references consist of two parts: the primary filename and the +filetype. Although the filetype is optional, it usually is +generic. For example, the filetype ASM is used to denote that the file is an +assembly language source file, while the primary filename distinguishes each +particular source file. The two names are separated by a period, as shown +in the following example: +.bp +.ti 8 +filename.typ +.sp +.mb 6 +.fm 2 +In this example, filename is the primary filename of eight characters or +less, and typ +is the filetype of no more than three characters. As mentioned above, the +name +.sp +.ti 8 +filename +.sp +is also allowed and is equivalent to a filetype consisting of +three blanks. The characters used in specifying an unambiguous +file reference cannot contain any of the following special +characters: +.sp +.ti 8 +< > . , ; : = ? * [ ] _ % | ( ) / \\ +.sp +while all alphanumerics and remaining special characters are allowed. +.pp +An ambiguous file reference is used for directory search and pattern +matching. The form of an ambiguous file reference is similar to an +unambiguous reference, except the symbol ? can be interspersed throughout +the primary and secondary names. In various commands throughout CP/M, +the ? symbol matches any character of a filename in the ? position. +Thus, the ambiguous reference +.sp +.ti 8 +X?Z.C?M +.sp +matches the following unambiguous filenames +.sp +.ti 8 +XYZ.COM +.sp +and +.sp +.ti 8 +X3Z.CAM +.sp +The * wildcard character can also be used in an ambiguous file +reference. The * character replaces all or part of a filename or +filetype. Note that +.sp +.ti 8 +*.* +.sp +equals the ambiguous file reference +.sp +.ti 8 +????????.??? +.sp +while +.sp +.ti 8 +filename.* +.sp +and +.sp +.ti 8 +*.typ +.sp +are abbreviations for +.sp +.ti 8 +filename.??? +.sp +and +.sp +.ti 8 +????????.typ +.sp +respectively. As an example, +.sp +.ti 8 +A>\c +.sh +DIR *.* +.qs +.sp +is interpreted by the CCP as a command to list the names of all disk files +in the directory. The following example searches only for a file +by the name X.Y: +.sp +.ti 8 +A>\c +.sh +DIR X,Y +.qs +.sp +Similarly, the command +.sp +.ti 8 +A>\c +.sh +DIR X?Y.C?M +.qs +.sp +causes a search for all unambiguous filenames on the disk that satisfy +this ambiguous reference. +.pp +The following file references are valid unambiguous file references: +.sp +.nf +.in 8 +X +X.Y +XYZ +XYZ.COM +GAMMA +GAMMA.1 +.fi +.in 0 +.pp +As an added convenience, the programmer can generally specify the disk drive +name along with the filename. In this case, the drive name is given as a +letter A through P followed by a colon (:). The specified drive is +then logged-in before the file operation occurs. Thus, the following are +valid file references with disk name prefixes: +.sp +.nf +.in 8 +A:X.Y +P:XYZ.COM +B:XYZ +B:X.A?M +C:GAMMA +C:*.ASM +.fi +.in 0 +.sp +All alphabetic lower-case letters in file and drive names are translated to +upper-case when they are processed by the CCP. +.sp 2 +.tc 1.3 Switching Disks +.he CP/M Operating System Manual 1.3 Switching Disks +.sh +1.3 Switching Disks +.qs +.mb 5 +.fm 1 +.pp +The operator can switch the currently logged disk by typing the disk drive +name, A through P, followed by a colon when the CCP is waiting for +console input. The following sequence of prompts and commands +can occur after the CP/M system is loaded from disk A: +.sp +.nf +.in 8 +CP/M VER 2.2 +A>\c +.sh +DIR \c +.qs +List all files on disk A. +A:SAMPLE ASM SAMPLE PRN +A>\c +.sh +B: \c +.qs +Switch to disk B. +B>\c +.sh +DIR *.ASM \c +.qs +List all ASM files on B. +B:DUMP ASM FILES ASM +b>\c +.sh +A: \c +.qs +Switch back to A. +.in 0 +.fi +.mb 6 +.fm 2 +.sp 2 +.tc 1.4 Built-in Commands +.he CP/M Operating System Manual 1.4 Built-in Commands +.sh +1.4 Built-in Commands +.qs +.pp +The file and device reference forms described can now be used to fully +specify the structure of the built-in commands. Assume the following +abbreviations in the description below: +.sp +.in 8 +.nf +ufn unambiguous file reference +afn ambiguous file reference +.fi +.in 0 +.sp +Recall that the CCP always translates lower-case characters to upper-case +characters internally. Thus, lower-case alphabetics are treated as if they +are upper-case in command names and file references. +.sp 2 +.tc 1.4.1 ERA Command +.sh +1.4.1 ERA Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +ERA afn +.pp +The ERA (erase) command removes files from the currently logged-in +disk, for example, the disk name currently prompted by CP/M preceding the >. +The files that are erased are those that satisfy the ambiguous file +reference afn. The following examples illustrate the use of ERA: +.sp 2 +.in 24 +.ti -16 +ERA X.Y The file named X.Y on the currently logged disk is removed +from the disk directory and the space is returned. +.sp +.ti -16 +ERA X.* All files with primary name X are removed from the current +disk. +.sp +.ti -16 +ERA *.ASM All files with secondary name ASM are removed from the +current disk. +.sp +.ti -16 +ERA X?Y.C?M All files on the current disk that satisfy the ambiguous +reference X?Y.C?M are deleted. +.bp +.ti -16 +ERA *.* Erase all files on the current disk. In this +case, the CCP prompts the console with the message +.sp +.nf +ALL FILES (Y/N)? +.fi +.sp +which requires a Y response before files are actually removed. +.sp +.ti -16 +ERA b:*.PRN All files on drive B that satisfy the ambiguous +reference ????????.PRN are deleted, independently of the currently +logged disk. +.in 0 +.sp 3 +.tc 1.4.2 DIR Command +.sh +1.4.2 DIR Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +DIR afn +.pp +The DIR (directory) command causes the names of all files that satisfy the +ambiguous filename afn to be listed at the console device. As a special +case, the command +.sp +.ti 8 +DIR +.sp +lists the files on the currently logged disk (the command DIR is +equivalent to the command DIR *.*). The following are valid DIR +commands: +.sp +.nf +.in 8 +DIR X.Y +DIR X?Z.C?M +DIR ??.Y +.in 0 +.fi +.pp +Similar to other CCP commands, the afn can be preceded by a drive name. +The following DIR commands cause the selected drive to be addressed before +the directory search takes place: +.sp +.in 8 +.nf +DIR B: +DIR B:X.Y +DIR B:*.A?M +.fi +.in 0 +.pp +If no files on the selected disk satisfy the directory request, the +message NO FILE appears at the console. +.bp +.tc 1.4.3 REN Command +.sh +1.4.3 REN Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +REN ufn1=ufn2 +.pp +The REN (rename) command allows you to change the names of files on +disk. The file satisfying ufn2 is changed to ufn1. The currently logged +disk is assumed to contain the file to rename (ufn2). You can also +type a left-directed arrow instead of the equal sign if the console supports +this graphic character. The following are examples of the REN +command: +.sp 2 +.in 31 +.ti -23 +REN X.Y=Q.R The file Q.R is changed to X.Y. +.ti -23 +.sp +REN XYZ.COM=XYZ.XXX The file XYZ.XXX is changed to XYZ.COM. +.in 0 +.fi +.sp +.pp +The operator precedes either ufn1 or ufn2 (or both) by an optional drive +address. If ufn1 is preceded by a drive name, then ufn2 is assumed to exist +on the same drive. Similarly, if ufn2 is preceded by a drive name, then +ufn1 is assumed to exist on the drive as well. The same drive must be +specified in both cases if both ufn1 and ufn2 are preceded by drive names. +The following REN commands illustrate this format: +.sp 2 +.in 31 +.ti -23 +REN A:X.ASM=Y.ASM The file Y.ASM is changed to X.ASM on drive A. +.sp +.ti -23 +REN B:ZAP.BAS=ZOT.BAS The file ZOT.BAS is changed to ZAP.BAS on drive B. +.sp +.ti -23 +REN B:A.ASM=B:A.BAK The file A.BAK is renamed to A.ASM on drive B. +.in 0 +.sp +.pp +If ufn1 is already present, the REN command responds with the +error FILE EXISTS and not perform the change. If ufn2 does not exist on +the specified disk, the message NO FILE is printed at the console. +.sp 2 +.tc 1.4.4 SAVE Command +.sh +1.4.4 SAVE Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +SAVE n ufn +.pp +The SAVE command places n pages (256-byte blocks) onto disk from the TPA +and names this file ufn. In the CP/M distribution system, the TPA starts +at 100H (hexadecimal) which is the second page of memory. The SAVE command +must specify 2 pages of memory if the user's program occupies the area +from 100H through 2FFH. The machine code file can be subsequently loaded +and executed. The following are examples of the SAVE command: +.sp 2 +.in 31 +.ti -23 +SAVE 3X.COM Copies 100H through 3FFH to X.COM. +.sp +.ti -23 +SAVE 40 Q Copies 100H through 28FFH to Q. Note that 28 is the +page count in 28FFH, and that 28H = 2*16+8=40 decimal. +.sp +.ti -23 +SAVE 4 X.Y Copies 100H through 4FFH to X.Y. +.in 0 +.sp 2 +The SAVE command can also specify a disk drive in the ufn portion of the +command, as shown in the following example: +.sp +.in 31 +.ti -23 +SAVE 10 B:ZOT.COM Copies 10 pages, 100H through 0AFFH, to the +file ZOT.COM on drive B. +.in 0 +.sp 3 +.tc 1.4.5 TYPE Command +.sh +1.4.5 TYPE Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +TYPE ufn +.pp +The TYPE command displays the content of the ASCII source file ufn on the +currently logged disk at the console device. The following are valid +TYPE commands: +.sp +.in 8 +.nf +TYPE X.Y +TYPE X.PLM +TYPE XXX +.in 0 +.fi +.pp +The TYPE command expands tabs, CTRL-I characters, assuming tab positions are +set at every eighth column. The ufn can also reference a drive name. +.sp +.in 24 +.ti -16 +TYPE B:X.PRN The file X.PRN from drive B is displayed. +.in 0 +.sp 2 +.tc 1.4.6 USER Command +.sh +1.4.6 USER Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +USER n +.pp +The USER command allows maintenance of separate files in the same +directory. In the syntax line, n is an integer value in the range 0 to +15. On cold start, the operator is automatically logged into user +area number 0, which is +compatible with standard CP/M 1 directories. You can issue the +USER command at any time to move to another logical area within the same +directory. Drives that are logged-in while addressing one user number are +automatically active when the operator moves to another. A user number is +simply a prefix that accesses particular directory entries on the active +disks. +.pp +The active user number is maintained until changed by a subsequent USER +command, or until a cold start when user 0 is again assumed. +.sp 2 +.tc 1.5 Line Editing and Output Control +.he CP/M Operating System Manual 1.5 Line Editing and Output Control +.sh +1.5 Line Editing and Output Control +.pp +The CCP allows certain line-editing functions while typing command lines. +The CTRL-key sequences are obtained by pressing the control and letter keys +simultaneously. Further, CCP command lines are generally up to 255 +characters in length; they are not acted upon until the carriage return key +is pressed. +.sp 2 +.ce +.sh +Table 1-1. Line-editing Control Characters +.qs +.sp +.ll 60 +.in 5 +.nf +Character Meaning +.fi +.sp +.in 18 +.ti -12 +CTRL-C Reboots CP/M system when pressed at start of line. +.sp +.ti -12 +CTRL-E Physical end of line; carriage is returned, but line is not sent +until the carriage return key is pressed. +.sp +.ti -12 +CTRL-H Backspaces one character position. +.sp +.ti -12 +CTRL-J Terminates current input (line feed). +.sp +.ti -12 +CTRL-M Terminates current input (carriage return). +.sp +.ti -12 +CTRL-P Copies all subsequent console output to the currently +assigned list device (see Section 1.6.1). Output is sent to the list device +and the console device until the next CTRL-P is pressed. +.sp +.ti -12 +CTRL-R Retypes current command line; types a clean line following +character deletion with rubouts. +.sp +.ti -12 +CTRL-S Stops the console output temporarily. Program execution and +output continue when you press any character at the console, for +example another CTRL-S. This feature stops output on high speed consoles, +such as CRTs, in order to view a segment of output before continuing. +.bp +.ll 65 +.in 0 +.ce +.sh +Table 1-1. (continued) +.qs +.sp +.ll 60 +.in 5 +.nf +Character Meaning +.fi +.sp +.in 18 +.ti-12 +CTRL-U Deletes the entire line typed at the console. +.sp +.ti -12 +CTRL-X Same as CTRL-U. +.sp +.ti -12 +CTRL-Z Ends input from the console (used in PIP and ED). +.sp +.ti -12 +RUB/DEL Deletes and echoes the last character typed at the console. +.in 0 +.ll 65 +.sp 2 +.tc 1.6 Transient Commands +.he CP/M Operating System Manual 1.6 Transient Commands +.sh +1.6 Transient Commands +.qs +.pp +Transient commands are loaded from the currently logged disk and executed in +the TPA. The transient commands for execution under the CCP are below. +Additional functions are easily defined by the user (see Section 1.6.3). +.sp 2 +.ce +.sh +Table 1-2. CP/M Transient Commands +.qs +.sp +.ll 60 +.in 5 +.nf +Command Function +.fi +.sp +.in 16 +.ti -11 +STAT Lists the number of bytes of storage remaining on the currently +logged disk, provides statistical information about particular files, and +displays or alters device assignment. +.sp +.ti -11 +ASM Loads the CP/M assembler and assembles the specified program from +disk. +.sp +.ti -11 +LOAD Loads the file in Intel HEX machine code format and produces a +file in machine executable form which can be loaded into the TPA. This loaded +program becomes a new command under the CCP. +.sp +.ti -11 +DDT Loads the CP/M debugger into TPA and starts execution. +.sp +.ti -11 +PIP Loads the Peripheral Interchange Program for subsequent disk file +and peripheral transfer operations. +.sp +.ti-11 +ED Loads and executes the CP/M text editor program. +.sp +.ti -11 +SYSGEN Creates a new CP/M system disk. +.bp +.ll 65 +.in 0 +.ce +.sh +Table 1-2. (continued) +.qs +.sp +.ll 60 +.in 5 +.nf +Command Function +.fi +.sp +.in 16 +.ti -11 +SUBMIT Submits a file of commands for batch processing. +.sp +.ti -11 +DUMP Dumps the contents of a file in hex. +.sp +.ti -11 +MOVCPM Regenerates the CP/M system for a particular memory size. +.sp +.ll 65 +.in 0 +.pp +Transient commands are specified in the same manner as built-in commands, and +additional commands are easily defined by the user. For convenience, the +transient command can be preceded by a drive name which causes the transient +to be loaded from the specified drive into the TPA for execution. Thus, the +command +.sp +.ti 8 +B:STAT +.sp +causes CP/M to temporarily log in drive B for the source of the STAT +transient, and then return to the original logged disk for subsequent +processing. +.sp 2 +.tc 1.6.1 STAT Command +.sh +1.6.1 STAT Command +.qs +.sp +.ul +Syntax: +.qu +.sp +.in 8 +.nf +STAT +STAT "command line" +.fi +.in 0 +.pp +The STAT command provides general statistical information about file storage +and device assignment. Special forms of the command line allow the current +device assignment to be +examined and altered. The various command lines that can be specified are +shown with an explanation of each form to the right. +.sp 2 +.in 24 +.ti -16 +STAT If you type an empty command line, the STAT transient +calculates the storage remaining on all active drives, and prints +one of the following messages: +.sp +.nf +d: R/W, SPACE: nnnK +.sp +d: R/O, SPACE: nnnK +.fi +.sp +for each active drive d:, where R/W indicates the drive can be read or +written, and R/O indicates the drive is Read-Only (a drive becomes R/O by +explicitly setting it to Read-Only, as shown below, or by inadvertently +changing disks without performing a warm start). The space remaining on +the disk in drive d: is given in kilobytes by nnn. +.sp +.ti -16 +STAT d: If a drive name is given, then the drive is selected before +the storage is computed. Thus, the command STAT B: could be issued while +logged into drive A, resulting in the message +.sp +BYTES REMAINING ON B: nnnK +.sp +.ti -16 +STAT afn The command line can also specify a set of files to be +scanned by STAT. The files that satisfy afn are listed in alphabetical +order, with storage requirements for each file under the heading: +.sp +.nf +RECS BYTES EXT D:FILENAME.TYP +rrrr bbbK ee d:filename.typ +.fi +.sp +where rrrr is the number of 128-byte records allocated to the file, bbb is +the number of kilobytes allocated to the file (bbb=rrrr*128/1024), ee is the +number of 16K extensions (ee=bbb/16), d is the drive name containing the +file (A...P), filename is the eight-character primary filename, and +typ is the three-character filetype. After listing the individual +files, the storage usage is summarized. +.sp +.ti -16 +STAT d:afn The drive name can be given ahead of the afn. The specified +drive is first selected, and the form STAT afn is executed. +.sp +.ti -16 +STAT d:=R/O This form sets the drive given by d to Read-Only, remaining +in effect until the next warm or cold start takes place. When a disk is +Read-Only, the message +.sp +BDOS ERR ON d: Read-Only +.sp +appears if there is an attempt to write to the Read-Only disk. CP/M +waits until a key is pressed before performing an automatic +warm start, at +which time the disk becomes R/W. +.in 0 +.bp +.pp +The STAT command allows you to control the physical-to-logical device +assignment. See the IOBYTE function described in Sections 5 and 6. There +are four logical peripheral devices that are, at any particular instant, each +assigned one of several physical peripheral devices. The +following is a list of the four logical devices: +.sp 2 +.in 5 +.ti -2 +o CON: is the system console device, used by CCP for communication with the +operator. +.sp +.ti -2 +o RDR: is the paper tape reader device. +.sp +.ti -2 +o PUN: is the paper tape punch device. +.sp +.ti -2 +o LST: is the output list device. +.in 0 +.sp +.pp +The actual devices attached to any particular computer system are driven by +subroutines in the BIOS portion of CP/M. Thus, the logical RDR: device, for +example, could actually be a high speed reader, teletype reader, or cassette +tape. To allow some flexibility in device naming and assignment, several +physical devices are defined in Table 1-3. +.sp 2 +.ce +.sh +Table 1-3. Physical Devices +.ll 60 +.in 5 +.sp +.nf +Device Meaning +.fi +.sp +.in 14 +.ti -8 +TTY: Teletype device (slow speed console) +.sp +.ti -8 +CRT: Cathode ray tube device (high speed console) +.sp +.ti -8 +BAT: Batch processing (console is current RDR:, output goes to current +LST: device) +.sp +.ti -8 +UC1: User-defined console +.sp +.ti -8 +PTR: Paper tape reader (high speed reader) +.sp +.ti -8 +UR1: User-defined reader #1 +.sp +.ti -8 +UR2: User-defined reader #2 +.sp +.ti -8 +PTP: Paper tape punch (high speed punch) +.sp +.ti -8 +UP1: User-defined punch #1 +.sp +.ti -8 +UP2: User-defined punch #2 +.sp +.ti -8 +LPT: Line printer +.sp +.ti -8 +UL1: User-defined list device #1 +.in 0 +.ll 65 +.nx oneb + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/oneb.tex b/Source/Doc/CPM 22 Manual/oneb.tex new file mode 100644 index 00000000..67ae6beb --- /dev/null +++ b/Source/Doc/CPM 22 Manual/oneb.tex @@ -0,0 +1,915 @@ +.bp +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he CP/M Operating System Manual 1.6 Transient Commands +.ft 1-% +.pc 1 +.pp 5 +It is emphasized that the physical device names might not actually +correspond to devices that the names imply. That is, you can +implement the PTP: device as a cassette write operation. The exact +correspondence and driving subroutine is defined in the BIOS portion of +CP/M. In the standard distribution version of CP/M, these devices correspond +to their names on the Model 800 development system. +.pp +The command, +.sp +.ti 8 +STAT VAL: +.sp +produces a summary of the available status commands, resulting in +the output: +.sp +.in 8 +.nf +Temp R/O Disk d:$R/O +Set Indicator: filename.typ $R/O $R/W $SYS $DIR +Disk Status: DSK: d:DSK +Iobyte Assign: +.sp +.in 0 +.fi +which gives an instant summary of the possible STAT commands and shows the +permissible logical-to-physical device assignments: +.sp +.in 8 +.nf +CON: = TTY: CRT: BAT: UC1: +RDR: = TTY: PTR: UR1: UR2: +PUN: = TTY: PTP: UP1: UP2: +LST: = TTY: CRT: LPT: UL1: +.fi +.in 0 +.sp +The logical device to the left takes any of the four physical assignments +shown to the right. The current logical-to-physical mapping is displayed by +typing the command: +.sp +.ti 8 +STAT DEV: +.sp +This command produces a list of each logical device to the left and +the current +corresponding physical device to the right. For example, the list might +appear as follows: +.sp +.in 8 +.nf +CON: = CRT: +RDR: = UR1: +PUN: = PTP: +LST: = TTY: +.fi +.in 0 +.sp +The current logical-to-physical device assignment is changed by typing a STAT +command of the form: +.sp +.ti 8 +STAT ld1 = pd1, ld2 = pd2, ... , ldn = pdn +.sp +where ld1 through ldn are logical device names and pd1 through pdn are +compatible physical device names. For example, ldi and pdi appear on the +same line +in the VAL: command shown above. The following example shows valid STAT +commands that change the +current logical-to-physical device assignments: +.sp +.in 8 +.nf +STAT CON:=CRT: +STAT PUN:=TTY:, LST:=LPT:, RDR:=TTY: +.in 0 +.fi +.pp +The command form, +.sp +.ti 8 +STAT d:filename.typ $S +.sp +where d: is an optional drive name and filename.typ is an unambiguous or +ambiguous filename, produces the following output display format: +.sp 2 +.in 8 +.nf +Size Recs Bytes Ext Acc +.sp + 48 48 6K 1 R/O A:ED.COM + 55 55 12K 1 R/O (A:PIP.COM) +65536 128 16K 2 R/W A:X.DAT +.in 0 +.fi +.sp 2 +where the $S parameter causes the Size field to be displayed. Without the +$S, the Size field is skipped, but the remaining fields are displayed. The +Size field lists the virtual file size in records, while the Recs field +sums the number of virtual records in each extent. For files constructed +sequentially, the Size and Recs fields are identical. The Bytes field +lists the actual number of bytes allocated to the corresponding file. The +minimum allocation unit is determined at configuration time; thus, the number +of bytes corresponds to the record count plus the remaining unused space in +the last allocated block for sequential files. Random access files are given +data areas only when written, so the Bytes field contains the only accurate +allocation figure. In the case of random access, the Size field gives the +logical end-of-file record position and the Recs field counts the logical +records of each extent. Each of these extents, however, can contain +unallocated holes even though they are added into the record count. +.pp +The Ext field counts the number of physical extents allocated to the file. +The Ext count corresponds to the number of directory entries given to the +file. Depending on allocation size, there can be up to 128K +bytes (8 logical extents) directly addressed by a single directory entry. In a special case, +there are actually 256K bytes that can be directly addressed by a physical +extent. +.pp +The Acc field gives the R/O or R/W file indicator, which you can +change using the commands shown. The four command forms, +.sp +.nf +.in 8 +STAT d:filename.typ $R/O +STAT d:filename.typ $R/W +STAT d:filename.typ $SYS +STAT d:filename.typ $DIR +.in 0 +.fi +.sp +set or reset various permanent file indicators. The R/O indicator places the +file, or set of files, in a Read-Only status until changed by a subsequent +STAT command. The R/O status is recorded in the directory with the file so +that it remains R/O through intervening cold start operations. The R/W +indicator places the file in a permanent Read-Write status. The SYS +indicator attaches the system indicator to the file, while the DIR command +removes the system indicator. The filename.typ may be ambiguous or +unambiguous, but files whose attributes are changed are listed at the console +when the change occurs. The drive name denoted by d: is optional. +.pp +When a file is marked R/O, subsequent attempts to erase or write into the +file produce the following BDOS message at your screen: +.sp +.ti 8 +BDOS Err on d: File R/O +.sp +lists the drive characteristics of the disk named by d: that is in the range +A:, B:,...,P:. The drive characteristics are listed in the +following format: +.sp +.nf + d: Drive Characteristics + 65536: 128 Byte Record Capacity + 8192: Kilobyte Drive Capacity + 128: 32 Byte Directory Entries + 0: Checked Directory Entries + 1024: Records/Extent + 128: Records/Block + 58: Sectors/Track + 2: Reserved Tracks +.fi +.sp +where d: is the selected drive, followed by the total record capacity +(65536 is an eight-megabyte drive), followed by the total capacity listed in +kilobytes. The directory size is listed next, followed by the checked +entries. The number of checked entries is usually identical to the directory +size for removable media, because this mechanism is used to detect changed +media during CP/M operation without an intervening warm start. For fixed +media, the number is usually zero, because the media are not changed without +at least a cold or warm start. +.pp +The number of records per extent determines +the addressing capacity of each directory entry (1024 times 128 bytes, or +128K in the previous example). The number of records per block shows the +basic allocation size (in the example, 128 records/block times 128 bytes per +record, or 16K bytes per block). The listing is then followed by the number +of physical sectors per track and the number of reserved tracks. +.pp +For logical +drives that share the same physical disk, the number of reserved tracks can +be quite large because this mechanism is used to skip lower-numbered disk +areas allocated to other logical disks. The command form +.sp +.ti 8 +STAT DSK: +.sp +produces a drive characteristics table for all currently active drives. The +final STAT command form is +.sp +.ti 8 +STAT USR: +.sp +which produces a list of the user numbers that have files on the currently +addressed disk. The display format is +.sp +.nf +.in 8 +Active User: 0 +Active Files: 0 1 3 +.in 0 +.fi +.sp +where the first line lists the currently addressed user number, as set by the +last CCP USER command, followed by a list of user numbers scanned from the +current directory. In this case, the active user number is 0 (default at cold +start) with three user numbers that have active files on the current disk. +The operator can subsequently examine the directories of the other user +numbers by logging in with USER 1 or USER 3 commands, followed by a DIR +command at the CCP level. +.sp 2 +.tc 1.6.2 ASM Command +.sh +1.6.2 ASM Command +.qs +.sp +Syntax: +.sp +.ti 8 +ASM ufn +.pp +The ASM command loads and executes the CP/M 8080 assembler. The ufn +specifies a source file containing assembly language statements, where the +filetype is assumed to be ASM and is not specified. The following ASM +commands are valid: +.sp +.nf +.in 8 +ASM X +ASM GAMMA +.in 0 +.fi +.sp +The two-pass assembler is automatically executed. Assembly errors that occur +during the second pass are printed at the console. +.pp +The assembler produces a file: +.sp +.ti 8 +X.PRN +.sp +where X is the primary name specified in the ASM command. The PRN file +contains a listing of the source program with embedded tab characters if +present in the source program, along with the machine code generated for +each statement and diagnostic error messages, if any. The PRN file is listed +at the console using the TYPE command, or sent to a peripheral device +using PIP (see Section 1.6.4). Note that the PRN file +contains the original source program, augmented by miscellaneous assembly +information in the leftmost 16 columns; for example, program addresses and +hexadecimal +machine code. The PRN file serves as a backup for the original +source file. If the source file is accidentally removed or destroyed, the +PRN file can be edited by removing the leftmost 16 characters +of each line (see Section 2). This is done by issuing a single editor macro +command. +The resulting file is identical to the original source file and can be +renamed from PRN to ASM for subsequent editing and assembly. The file +.sp +.ti 8 +X.HEX +.sp +is also produced, which contains 8080 machine language in Intel HEX format +suitable for subsequent loading and execution (see Section 1.6.3). For +complete details of CP/M's assembly language program, see Section 3. +.pp +The source file for assembly is taken from an alternate disk by prefixing the +assembly language filename by a disk drive name. The command +.sp +.ti 8 +ASM B:ALPHA +.sp +loads the assembler from the currently logged drive and processes the source +program ALPHA.ASM on drive B. The HEX and PRN files are also placed on +drive B in this case. +.he CP/M Operating System Manual 1.6 Transient Commands +.sp 2 +.tc 1.6.3 LOAD Command +.sh +1.6.3 LOAD Command +.qs +.sp +Syntax: +.sp +.ti 8 +LOAD ufn +.pp 5 +The LOAD command reads the file ufn, which is assumed to contain HEX format +machine code, and produces a memory image file that can subsequently be +executed. The filename ufn is assumed to be of the form: +.sp +.ti 8 +X.HEX +.sp +and only the filename X need be specified in the command. The LOAD command +creates a file named +.sp +.ti 8 +X.COM +.sp +that marks it as containing machine executable code. The file is actually +loaded into memory and executed when the user types the filename X +immediately after the prompting character > printed by the CCP. +.pp +Generally, the CCP reads the filename X following the prompting character and +looks for a built-in function name. If no function name is found, the CCP +searches the system disk directory for a file by the name +.sp +.ti 8 +X.COM +.mb 5 +.fm 1 +.sp +If found, the machine code is loaded into the TPA, and the program executes. +Thus, the user need only LOAD a hex file once; it can be subsequently +executed any number of times by typing the primary name. This +way, you can invent new commands in the CCP. Initialized disks contain +the transient commands as COM files, which are optionally deleted. The +operation takes place on an alternate drive if the filename is prefixed +by a drive name. Thus, +.bp +.mb 6 +.fm 2 +.sp +.ti 8 +LOAD B:BETA +.sp +brings the LOAD program into the TPA from the currently logged disk and +operates on drive B after execution begins. +.sp +.sh +Note: \c +.qs +the BETA.HEX file must contain valid Intel format +hexadecimal machine code records (as produced by the ASM program, for +example) that begin at 100H of the TPA. The addresses in the hex records +must be in ascending order; gaps in unfilled memory regions are filled with +zeroes by the LOAD command as the hex records are read. Thus, LOAD must be +used only for creating CP/M standard COM files that operate in the TPA. +Programs that occupy regions of memory other than the TPA are loaded under +DDT. +.sp 2 +.tc 1.6.4 PIP +.sh +1.6.4 PIP +.qs +.sp +.ul +Syntax: +.qu +.sp +.in 8 +.nf +PIP +PIP destination=source#1, source#2, ..., source #n +.fi +.in 0 +.pp +PIP is the CP/M Peripheral Interchange Program that implements the basic +media conversion operations necessary to load, print, punch, copy, and +combine disk files. The PIP program is initiated by typing one of the +following forms: +.sp +.nf +.in 8 +PIP +PIP command line +.fi +.in 0 +.sp +In both cases PIP is loaded into the TPA and executed. In the +first form, PIP reads command lines directly from the console, prompted with +the * character, until an empty command line is typed (for example, a single +carriage return is issued by +the operator). Each successive command line causes some media conversion +to take place according to the rules shown below. +.pp +In the second form, the PIP +command is equivalent to the first, except that the single command line +given with the PIP command is automatically executed, and PIP terminates +immediately with no further prompting of the console for input command +lines. The form of each command line is +.sp +.ti 8 +destination = source#1, source#2, ..., source#n +.sp +where destination is the file or peripheral device to receive the +data, +and source#1, ..., source#n is a series of one or more files or devices +that are copied from left to right to the destination. +.pp +When multiple files are given in the command line (for example, +n>1), the individual +files are assumed to contain ASCII characters, with an assumed CP/M +end-of-file character (CTRL-Z) at the end of each file (see the O parameter +to override this assumption). Lower-case ASCII alphabetics are internally +translated to upper-case to be consistent with CP/M file and device name +conventions. Finally, the total command line length cannot exceed 255 +characters. CTRL-E can be used to force a physical carriage return for lines +that exceed the console width. +.pp +The destination and source elements are unambiguous references to CP/M source +files with or without a preceding disk drive name. That is, any file can be +referenced with a preceding drive name (A: through P:) that defines the +particular drive where the file can be obtained or stored. When the drive +name is not included, the currently logged disk is assumed. The +destination file can also appear as one or more of the source files, in +which case the source file is not altered until the entire concatenation is +complete. If it already exists, the destination file is removed if the +command line is properly formed. It is not removed if an error condition +arises. The following command lines, with explanations to the +right, are +valid as input to PIP: +.sp 2 +.in 31 +.ti -23 +X=Y Copies to file X from file Y, where X and Y are +unambiguous filenames; Y remains unchanged. +.sp +.ti -23 +X=Y,Z Concatenates files Y and z and copies to file X, +with Y and Z unchanged. +.sp +.ti -23 +X.ASM=Y.ASM,Z.ASM Creates the file X.ASM from the concatenation of the +Y and Z.ASM files. +.sp +.ti -23 +NEW.ZOT=B:OLD.ZAP Moves a copy of OLD.ZAPP from drive B to the currently +logged disk; names the file NEW.ZOT. +.sp +.ti -23 +B:A.U=B:B.V,A:C.W,D.X Concatenates file B.V from drive B with C.W from drive +a and D.X from the logged disk; creates the file A.U on drive b. +.in 0 +.sp +.pp +For convenience, PIP allows abbreviated commands for transferring files +between disk drives. The abbreviated PIP forms are +.sp +.in 8 +.nf +PIP d:=afn +PIP d\d1\u=d\d2\u:afn +PIP ufn = d\d2\u: +PIP d\d1\u:ufn = d\d2\u: +.fi +.in 0 +.sp +The first form copies all files from the currently logged disk that satisfy +the afn to the same files on drive d, where d = A...P. The second form is +equivalent to the first, where the source for the copy is drive +d\d2\u, where d\d2\u = A...P. The third form is equivalent to the command PIP +d\d1\u:ufn=d\d2\u:ufn which copies the file given by ufn from drive +d\d2\u to the file ufn on drive d\d1\u:. The fourth form is equivalent to +the third, where the source disk is explicitly given by d\d2\u:. +.pp +The source and destination disks must be different in all of these cases. +If an afn is specified, PIP lists each ufn that satisfies the afn as it +is being copied. If a file exists by the same name as the destination file, +it is removed after successful completion of the copy and replaced by the +copied file. +.pp +The following PIP commands give examples of valid disk-to-disk copy operations: +.sp 2 +.in 24 +.ti -16 +B:=*.COM Copies all files that have the secondary name COM to +drive B from the current drive. +.sp +.ti -16 +A:=B:ZAP.* Copies all files that have the primary name ZAP to +drive A from drive B. +.sp +.ti -16 +ZAP.ASM=B: Same as ZAP.ASM=B:ZAP.ASM +.sp +.ti -16 +B:ZOT.COM=A: Same as B:ZOT.COM=A:ZOT.COM +.sp +.ti -16 +B:=GAMMA.BAS Same as B:GAMMA.BAS=GAMMA.BAS +.sp +.ti -16 +B:=A:GAMMA.BAS Same as B:GAMMA.BAS=A:GAMMA.BAS +.in 0 +.sp +.pp +PIP allows reference to physical and logical devices that are attached to the +CP/M system. The device names are the same as given under the STAT command, +along with a number of specially named devices. The following is +a list of logical devices given in the STAT command +.sp +.in 8 +.nf +CON: (console) +RDR: (reader) +PUN: (punch) +LST: (list) +.fi +.in 0 +.sp +while the physical devices are +.sp +.in 8 +.nf +TTY: (console), reader, punch, or list) +CRT: (console, or list), UC1: (console) +PTR: (reader), UR1: (reader), UR2: (reader) +PTP: (punch), UP1: (punch), UP2: (punch) +LPT: (list), UL1: (list) +.fi +.in 0 +.sp +The BAT: physical device is not included, because this assignment is used +only to indicate that the RDR: and LST: devices are used for console +input/output. +.pp +The RDR, LST, PUN, and CON devices are all defined within the BIOS portion of +CP/M, and are easily altered for any particular I/O system. The current +physical device mapping is defined by IOBYTE; see Section 6 for a discussion +of this function. The destination device must be capable of +receiving data, for example, data cannot be sent to the punch, and the +source devices must be +capable of generating data, for example, the LST: device cannot be read. +.pp +The following list describes additional device names that can be used in +PIP commands. +.sp 2 +.in 5 +.ti -2 +o NUL: sends 40 nulls (ASCII 0s) to the device. This can be issued +at the end of punched output. +.sp +.ti -2 +o EOF: sends a CP/M end-of-file (ASCII CTRL-Z) to the destination +device (sent automatically at the end of all ASCII data transfers through PIP). +.sp +.ti -2 +o INP: is a special PIP input source that can be patched into the PIP +program. PIP gets the input data character-by-character, by CALLing location +103H, with data returned in location 109H (parity bit must be zero). +.sp +.ti -2 +o OUT: is a special PIP output destination that can be patched into the +PIP program. PIP CALLs location 106H with data in register C for each +character to transmit. Note that locations 109H through +1FFH of the PIP memory image are not used and can be replaced by special +purpose drivers using DDT (see Section 4). +.sp +.ti -2 +o PRN: is the same as LST:, except that tabs are expanded at every eighth +character position, lines are numbered, and page ejects are inserted every +60 lines with an initial eject (same as using PIP options [t8np]). +.in 0 +.sp +.pp +File and device names can be interspersed in the PIP commands. In each case, +the specific device is read until end-of-file (CTRL-Z for ASCII files, and +end-of-data for non-ASCII disk files). Data from each device or file are +concatenated from left to right until the last data source has been read. +.pp +The destination device or file is written using the data from the source +files, and an end-of-file character, CTRL-Z, is appended to the result +for ASCII files. If the destination is a disk file, a temporary file is +created ($$$ secondary name) that is changed to the actual filename only +on successful completion of the copy. Files with the extension COM are +always assumed to be non-ASCII. +.pp +The copy operation can be aborted at any time by pressing any key on the +keyboard. PIP responds with the message ABORTED to +indicate that the operation has not been completed. If any operation is +aborted, or if an error occurs during processing, PIP removes any pending +commands that were set up while using the SUBMIT command. +.pp +PIP performs a special function if the destination is a disk file with type +HEX (an Intel hex-formatted machine code file), and the source is an +external peripheral device, such as a paper tape reader. In this case, the +PIP program checks to ensure that the source file contains a properly formed +hex file, with legal hexadecimal values and checksum records. +.pp +When an +invalid input record is found, PIP reports an error message at the console +and waits for corrective action. Usually, you can open the reader +and rerun a section of the tape (pull the tape back about 20 inches). When +the tape is ready for the reread, a single carriage return is typed at the +console, and PIP attempts another read. If the tape position cannot be +properly read, continue the read by typing a return following the +error message, and enter the record manually with the ED program after +the disk file is constructed. +.pp +PIP allows the end-of-file to +be entered from the console if the source file is an RDR: device. In +this case, the PIP program reads the device and monitors the keyboard. If +CTRL-Z is typed at the keyboard, the read operation is terminated normally. +.pp +The following are valid PIP commands: +.sp 2 +.in 24 +.ti 8 +PIP LST: = X.PRN +.sp +Copies X.PRN to the LST device and +terminates the PIP program. +.sp +.ti 8 +PIP +.sp +Starts PIP for a sequence of +commands. PIP prompts with *. +.sp +.ti 8 +*CON:=X.ASM,Y.ASM,Z.ASM +.sp +Concatenates three ASM files and copies to +the CON device. +.sp +.ti 8 +*X.HEX=CON:,Y.HEX,PTR: +.sp +Creates a HEX file by reading the CON +until a CTRL-Z is typed, followed by data from Y.HEX and PTR until +a CTRL-Z is encountered. +.sp +.ti 8 +PIP PUN:=NUL:,X.ASM,EOF:,NUL: +.mb 4 +.fm 1 +.sp +Sends 40 nulls to the punch device; copies the X.ASM file to the punch, +followed by an end-of-file, CTRL-Z, and 40 more null characters. +.sp +.ti 8 +(carriage return) +.sp +A single carriage return stops PIP. +.in 0 +.bp +.pp +You can also specify one or more PIP parameters, enclosed in left and +right square brackets, separated by zero or more blanks. Each parameter +affects the copy operation, and the enclosed list of parameters must +immediately follow the affected file or device. Generally, each parameter +can be followed by an optional decimal integer value (the S and Q parameters +are exceptions). Table 1-4 describes valid PIP parameters. +.sp 2 +.ce +.sh +Table 1-4. PIP Parameters +.ll 60 +.in 5 +.nf +.sp +Parameter Meaning +.fi +.mb 6 +.fm 2 +.sp +.in 17 +.ti -10 +B Blocks mode transfer. Data are buffered by PIP until an ASCII x-off +character, CTRL-S, is received from the source device. This allows transfer +of data to a disk file from a continuous reading device, such as a cassette +reader. Upon receipt of the x-off, PIP clears the disk buffers and returns +for more input data. The amount of data that can be buffered depends on the +memory size of the host system. PIP issues an error message if the +buffers overflow. +.sp +.ti -10 +Dn Deletes characters that extend past column n in the transfer of data +to the destination from the character source. This parameter is generally +used to truncate long lines that are sent to a narrow printer or +console device. +.sp +.ti -10 +E Echoes all transfer operations to the console as they are being +performed. +.sp +.ti -10 +F Filters form-feeds from the file. All embedded form-feeds are +removed. The P parameter can be used simultaneously to insert new form-feeds. +.sp +.ti -10 +Gn Gets file from user number n (n in the range 0-15). +.sp +.ti -10 +H Transfers HEX data. All data are checked for proper Intel hex file +format. Nonessential characters between hex records are removed during the +copy operation. The console is prompted for corrective action in case +errors occur. +.sp +.ti -10 +I Ignores :00 records in the transfer of Intel hex format +file. The I parameter automatically sets the H parameter. +.bp +.ll 65 +.in 0 +.ce +.sh +Table 1-4. (continued) +.ll 60 +.in 5 +.nf +.sp +Parameter Meaning +.fi +.sp +.in 17 +.ti -10 +L Translates upper-case alphabetics to lower-case. +.sp +.ti -10 +N Adds line numbers to each line transferred to the destination, +starting at one and incrementing by 1. Leading zeroes are suppressed, and +the number is followed by a colon. If N2 is specified, leading zeroes are +included and a tab is inserted following the number. The tab is expanded if +T is set. +.sp +.ti -10 +O Transfers non-ASCII object files. The normal CP/M end-of-file is +ignored. +.sp +.ti -10 +Pn Includes page ejects at every n lines with an initial page eject. +If n = 1 or is excluded altogether, page ejects occur every 60 lines. If +the F parameter is used, form-feed suppression takes place before the new +page ejects are inserted. +.sp +.ti -10 +Qs^Z Quits copying from the source device or file when the +string s, terminated by CTRL-Z, is encountered. +.sp +.ti -10 +R Reads system files. +.sp +.ti -10 +Ss^Z Start copying from the source device when the string +s, terminated by CTRL-Z, is encountered. The S and Q parameters can be used +to abstract a particular section of a file, such as a subroutine. The +start and quit strings are always included in the copy operation. +.sp +If you specify a command line after the PIP command keyword, the CCP +translates strings +following the S and Q parameters to upper-case. If you do not +specify a command line, PIP does not perform the automatic upper-case +translation. +.sp +.ti -10 +Tn Expands tabs, CTRL-I characters, to every nth column during the +transfer of characters to the destination from the source. +.sp +.ti -10 +U Translates lower-case alphabetics to upper-case during the copy +operation. +.bp +.ll 65 +.in 0 +.ce +.sh +Table 1-4. (continued) +.ll 60 +.in 5 +.nf +.sp +Parameter Meaning +.fi +.sp +.in 17 +.ti -10 +V Verifies that data have been copied correctly by rereading after the +write operation (the destination must be a disk file). +.sp +.ti -10 +W Writes over R/O files without console interrogation. +.sp +.ti -10 +Z Zeros the parity bit on input for each ASCII character. +.in 0 +.ll 65 +.sp +.pp +The following examples show valid PIP commands that specify parameters in +the file transfer. +.sp 2 +.in 24 +.ti 8 +PIP X.ASM=B:[v] +.sp +Copies X.ASM from drive B to the current drive and verifies that the data were +properly copied. +.sp 2 +.ti 8 +PIP LPT:=X.ASM[nt8u] +.sp +Copies X.ASM to the LPT: device; numbers each line, expands tabs to every +eighth column, and translates lower-case alphabetics to upper-case. +.sp 2 +.ti 8 +PIP PUN:=X.HEX[i],Y.ZOT[h] +.sp +First copies X.HEX to the PUN: device +and ignores the trailing :00 record in X.HEX; continues the transfer of data +by reading Y.ZOT, which contains HEX records, including any :00 records +it contains. +.sp 2 +.ti 8 +PIP X.LIB=Y.ASM[sSUBRI:^z qJMP L3^z] +.sp +Copies from the file Y.ASM into the +file X.LIB. The command starts the copy when the string SUBR1: has been +found, and quits copying after the string JMP L3 is encountered. +.bp +.ti 8 +PIP PRN:=X.ASM[p50] +.sp +Sends X.ASM to the LST: device with +line numbers, expands tabs to every eighth column, and ejects +pages at every +50th line. The assumed parameter list for a PRN file is nt8p60; p50 +overrides the default value. +.in 0 +.sp +.pp +Under normal operation, PIP does not overwrite a file that is set to a +permanent R/O status. If an attempt is made to overwrite an R/O file, the +following prompt appears: +.sp +.ti 8 +DESTINATION FILE IS R/O, DELETE (Y/N)? +.sp +If you type Y, the file is overwritten. Otherwise, the following response +appears: +.sp +.ti 8 +** NOT DELETED ** +.sp +The file transfer is skipped, and PIP continues with the next +operation in sequence. To avoid the prompt and response in the case of R/O +file overwrite, the command line can include the W parameter, as +shown in this example: +.sp +.ti 8 +PIP A:=B:*.COM[W] +.sp +The W parameter copies all nonsystem files to the A drive from the B drive and +overwrites any R/O files in the process. If the operation involves several +concatenated files, the W parameter need only be included with the last file +in the list, as in this example: +.sp +.ti 8 +PIP A.DAT=B.DAT,F:NEW.DAT,G:OLD.DAT[W] +.pp +Files with the system attribute can be included in PIP transfers if the R +parameter is included; otherwise, system files are not +recognized. For example, the command line: +.sp +.ti 8 +PIP ED.COM=B:ED.COM[R] +.sp +reads the ED.COM file from the B drive, even if it has been +marked as an R/O and system file. The system file attributes are copied, if +present. +.pp +Downward compatibility with previous versions of CP/M is only maintained if +the file does not exceed one megabyte, no file attributes are set, and the +file is created by user 0. If compatibility is required with +nonstandard, for example, double-density versions of 1.4, it +might be +necessary to select 1.4 +compatibility mode when constructing the internal disk parameter block. See +Section 6 and refer to Section 6.10, which describes BIOS differences. +.bp +.sh +Note: \c +.qs +to copy files into another user area, PIP.COM must be located in that user +area. Use the following procedure to make a copy of PIP.COM in another +user area. +.sp 2 +.in 8 +.nf +USER 0 Log in user 0. + +DDT PIP.COM (note PIP size s) Load PIP to memory. + +GO Return to CCP. + +USER 3 Log in user 3. + +SAVEs PIP.COM +.fi +.in 0 +.sp 2 +In this procedure, s is the integral number of memory pages, 256-byte +segments, occupied +by PIP. The number s can be determined when PIP.COM is loaded under DDT, +by referring to the value under the NEXT display. If, for example, the next +available address is 1D00, then PIP.COM requires 1C hexadecimal +pages, or +1 times 16 + 12 = 28 pages, and the value of s is 28 in the subsequent +save. Once PIP is copied in this manner, it can be copied to another disk +belonging to the same user number through normal PIP transfers. +.nx onec + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/onec.tex b/Source/Doc/CPM 22 Manual/onec.tex new file mode 100644 index 00000000..6ab06cf0 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/onec.tex @@ -0,0 +1,683 @@ +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he CP/M Operating System Manual 1.6 Transient Commands +.ft 1-% +.pc 1 +.sp 2 +.tc 1.6.5 ED Command +.sh +1.6.5 ED Command +.qs +.sp +.ul +Syntax: +.qu +.sp 0 +.sp +.ti 8 +ED ufn +.pp 5 +The ED program is the CP/M system context editor that allows creation and +alteration of ASCII files in the CP/M environment. Complete details of +operation are given in Section 2. ED allows the operator to create and +operate upon source files that are organized as a sequence of ASCII +characters, separated by end-of-line characters (a carriage +return/line-feed +sequence). There is no practical restriction on line length (no single +line can exceed the size of the working memory) that is defined by the +number of characters typed between carriage returns. +.pp +The ED program has +a number of commands for character string searching, replacement, and +insertion that are useful for creating and correcting programs or text +files under CP/M. Although the CP/M has a limited memory work +space area (approximately 5000 characters in a 20K CP/M system), the file +size that +can be edited is not limited, since data are easily paged through this +work area. +.pp +If it does not exist, ED creates the specified source file and opens the +file for access. If the source file does exist, the +programmer appends data for editing (see the A command). The appended data +can then be +displayed, altered, and written from the work area back to the +disk (see the W command). Particular points in the program can be +automatically paged and +located by context, allowing easy access to particular +portions of a large file (see the N command). +.pp +If you type the following command line: +.sp +.ti 8 +ED X.ASM +.sp +the ED program creates an intermediate work file with the name +.sp +.ti 8 +X.$$$ +.sp +to hold the edited data during the ED run. Upon completion of ED, the +X.ASM file (original file) is renamed to X.BAK, and the edited work file is +renamed to X.ASM. Thus, the X.BAK file contains the original unedited +file, and the X.ASM file contains the newly edited file. The operator can +always return to the previous version of a file by removing the most recent +version and renaming the previous version. If the current X.ASM file has +been improperly edited, the following sequence of commands reclaim the +back-up file. +.sp 2 +.nf +.in 8 +DIR X.* Checks to see that BAK file is + available. + +ERA X.ASM Erases most recent version. + +REN X.ASM=X.BAK Renames the BAK file to ASM. +.fi +.in 0 +.sp 2 +You can abort the edit at any point (reboot, power failure, CTRL-C, +or CTRL-Q command) without destroying the original file. In this case, the +BAK file is not created and the original file is always intact. +.pp +The ED program allows the user to edit the source on one disk and create the +back-up file on another disk. This form of the ED command is +.sp +.ti 8 +ED ufn d: +.sp +where ufn is the name of the file to edit on the currently logged disk and d +is the name of an alternate drive. The ED program reads and processes the +source file and writes the new file to drive d using the name ufn. After +processing, the original file becomes the back-up file. If the operator is +addressing disk A, the following command is valid. +.sp +.ti 8 +ED X.ASM b: +.sp +This edits the file X.ASM on drive A, creating the new file X.$$$ on +drive B. After a successful edit, A:X.ASM is renamed to A:X.BAK, and +B:X.$$$ is renamed to B:X.ASM. For convenience, the currently logged disk +becomes drive B at the end of the edit. Note that if a file +named B:X.ASM exists before the editing begins, the following +message appears on the screen: +.bp +.sp +.ti 8 +FILE EXISTS +.sp +This message is a precaution against accidentally destroying +a source file. You should first erase the existing file and then restart +the edit operation. +.pp +Similar to other transient commands, editing can take place on a drive +different from the currently logged disk by preceding the source filename +by a drive name. The following are examples of valid edit +requests: +.sp 2 +.in 25 +.ti -17 +ED A:X.ASM Edits the file X.ASM on drive A, with new file and back-up +on drive A. +.sp +.ti -17 +ED B:X.ASM A: Edits the file X.ASM on drive B to the temporary file X.$$$ +on drive A. After editing, this command changes X.ASM on drive B to X.BAK +and changes X.$$$ on drive A to X.ASM. +.in 0 +.ll 65 +.sp 2 +.tc 1.6.6 SYSGEN Command +.sh +1.6.6 SYSGEN Command +.qs +.sp +Syntax: +.sp +.ti 8 +SYSGEN +.pp +The SYSGEN transient command allows generation of an initialized disk +containing the CP/M operating system. The SYSGEN program prompts the +console for commands by interacting as shown. +.sp 2 +.in 24 +.ti 8 +SYSGEN +.sp +Initiates the SYSGEN program. +.sp 2 +.ti 8 +SYSGEN VERSION x.x +.sp +SYSGEN sign-on message. +.sp 2 +.in 8 +.nf +SOURCE DRIVE NAME +(OR RETURN TO SKIP) +.in 24 +.sp +.fi +Respond with the drive name (one of the letters A, B, C, or D) of the +disk containing a CP/M system, usually A. If a copy of CP/M already exists +in memory due to a MOVCPM command, press only a carriage return. Typing a +drive name d causes the response: +.sp 2 +.ti 8 +SOURCE ON d THEN TYPE RETURN +.sp +Place a disk containing the CP/M operating +system on drive d (d is one of A, B, C, or D). Answer by pressing a carriage +return when ready. +.sp 2 +.ti 8 +FUNCTION COMPLETE +.sp +System is copied to memory. SYSGEN then prompts with the following: +.sp 2 +.nf +.in 8 +DESTINATION DRIVE NAME +(OR RETURN TO REBOOT) +.fi +.sp +.in 24 +If a disk is being initialized, place the new disk into a drive +and answer with the drive name. Otherwise, press a carriage return +and the system reboots from drive A. Typing drive name d causes +SYSGEN to prompt with the following message: +.sp 2 +.nf +.in 8 +DESTINATION ON d +THEN TYPE RETURN +.fi +.in 24 +.sp +Place new disk into drive d; press return when ready. +.sp 2 +.ti 8 +FUNCTION COMPLETE +.sp +New disk is initialized in drive d. +.in 0 +.sp 2 +The DESTINATION prompt is repeated until a single carriage return is +pressed at the console, so that more than one disk can be initialized. +.pp +Upon completion of a successful system generation, the new disk contains +the operating system, and only the built-in commands are available. An +IBM-compatible disk appears to CP/M as a disk with an +empty directory; therefore, the operator must copy the appropriate COM files +from an existing CP/M disk to the newly constructed disk using the +PIP transient. +.pp +You can copy all files from an existing disk by typing the following +PIP command: +.sp +.ti 8 +PIP B: = A:*.*[v] +.bp +This command copies all files from disk drive A to disk drive B and verifies +that +each file has been copied correctly. The name of each file is displayed at +the console as the copy operation proceeds. +.pp +Note that a SYSGEN does not destroy the files that already +exist on a disk; it only constructs a new operating system. If a +disk is being used only on drives B through P and will never be the +source of a bootstrap operation on drive A, the SYSGEN need not take place. +.sp 2 +.tc 1.6.7 SUBMIT Command +.sh +1.6.7 SUBMIT Command +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +SUBMIT ufn parm#1 ... parm#n +.pp +The SUBMIT command allows CP/M commands to be batched for automatic +processing. The ufn given in the SUBMIT command must be the filename of a +file that exists on the currently logged disk, with an assumed file type of +SUB. The SUB file contains CP/M prototype commands with possible parameter +substitution. The actual parameters parm#1 ... parm#n are substituted into +the prototype commands, and, if no errors occur, the file of substituted +commands are processed sequentially by CP/M. +.pp +The prototype command file is created using the ED program, with +interspersed $ parameters of the form: +.sp +.ti 8 +$1 $2 $3 ...$n +.sp +corresponding to the number of actual parameters that will be included when +the file is submitted for execution. When the SUBMIT transient is executed, +the actual parameters parm#1 ... parm#n are paired with the formal parameters +$1 ... $n in the prototype commands. If the numbers of formal and actual +parameters do not correspond, the SUBMIT function is aborted with an error +message at the console. The SUBMIT function creates a file of substituted +commands with the name +.mt 5 +.hm 2 +.sp +.ti 8 +$$$.SUB +.sp +on the logged disk. When the system reboots, at the termination of the +SUBMIT, this command file is read by the CCP as a source of input rather +than the console. If the SUBMIT function is performed on any disk other +than drive A, the commands are not processed until the disk is inserted into +drive A and the system reboots. You can abort command processing at +any time by pressing the rubout key when the command is read and echoed. In +this case, the $$$.SUB file is removed and the subsequent commands come +from the console. Command processing is also aborted if the CCP detects an +error in any of the commands. Programs that execute under CP/M can abort +processing of command files when error conditions occur by erasing any +existing $$$.SUB file. +.pp +To introduce dollar signs into a SUBMIT file, you can type a $$ +which reduces to a single $ within the command file. A caret, +^, precedes an alphabetic character s, which produces a single CTRL-X +character within the file. +.pp +The last command in a SUB file can initiate another SUB file, allowing +chained batch commands: +.pp +Suppose the file ASMBL.SUB exists on disk and contains the prototype commands +.sp +.in 8 +.nf +ASM $1 +DIR $1.* +ERA *.BAK +PIP $2:=$1.PRN +ERA $1.PRN +.fi +.in 0 +.sp +then, you issue the following command: +.sp +.ti 8 +SUBMIT ASMBL X PRN +.sp +The SUBMIT program reads the ASMBL.SUB file, +substituting X: for all occurrences of $1 and PRN for all occurrences of +$2. This results in a $$$.SUB file containing the commands: +.sp +.in 8 +.nf +ASM X +DIR X.* +ERA *.BAK +PIP PRN:=X.PRN +ERA X.PRN +.fi +.in 0 +.sp +which are executed in sequence by the CCP. +.pp +The SUBMIT function can access a SUB file on an alternate drive by preceding +the filename by a drive name. Submitted files are only acted upon when +they appear on drive A. Thus, it is possible to create a submitted file +on drive B that is executed at a later time when inserted in drive A. +.pp +An additional utility program called XSUB extends the power of the SUBMIT +facility to include line input to programs as well as the CCP. The XSUB +command is included as the first line of the SUBMIT +file. When it is executed, XSUB self-relocates directly below the CCP. All +subsequent SUBMIT command lines are processed by XSUB so that programs that +read buffered console input, BDOS Function 10, receive their input directly +from the SUBMIT file. For example, the file SAVER.SUB can contain the +following SUBMIT lines: +.sp +.in 8 +.nf +XSUB +DDT +|$1.COM +R +GO +SAVE 1 $2.COM +.fi +.in 0 +.sp +a subsequent SUBMIT command, such as +.sp +.ti 8 +A>\c +.sh +SUBMIT SAVER PIP Y +.qs +.sp +substitutes X for $1 and Y for $2 in the command stream. The XSUB +program loads, followed by DDT, which is sent to the command lines PIP.COM, +R, and G0, thus returning to the CCP. The final command SAVE 1 Y.COM is +processed by the CCP. +.pp +The XSUB program remains in memory and prints the message +.sp +.ti 8 +(xsub active) +.sp +on each warm start operation to indicate its presence. Subsequent SUBMIT +command streams do not require the XSUB, unless an intervening cold start +occurs. Note that XSUB must be loaded after the optional +CP/M DESPOOL utility, if both are to run simultaneously. +.sp 2 +.tc 1.6.8 DUMP Command +.sh +1.6.8 DUMP Command +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +DUMP ufn +.pp +The DUMP program types the contents of the disk file (ufn) at the console in +hexadecimal form. The file contents are listed sixteen bytes at a time, +with the absolute byte address listed to the left of each line in +hexadecimal. Long typeouts can be aborted by pressing the rubout key during +printout. The source listing of the DUMP program is given in Section 5 as +an example of a program written for the CP/M environment. +.sp 2 +.tc 1.6.9 MOVCPM Command +.sh +1.6.9 MOVCPM Command +.sp +.ul +Syntax: +.qu +.sp +.ti 8 +MOVCPM +.pp +The MOVCPM program allows you to reconfigure the CP/M system for any +particular memory size. Two optional parameters can be used to indicate the +desired size of the new system and the disposition of the new system at +program termination. If the first parameter is omitted or an * is given, +the MOVCPM program reconfigures the system to its maximum size, based +upon the kilobytes of contiguous RAM in the host system (starting at 0000H). +If the second parameter is omitted, the system is executed, but not +permanently recorded; if * is given, the system is left in memory, ready +for a SYSGEN operation. The MOVCPM program relocates a memory image of CP/M +and places this image in memory in preparation for a system generation +operation. The following is a list of MOVCPM command forms: +.sp 2 +.in 23 +.ti -15 +MOVCPM Relocates and executes CP/M for management of the current +memory +configuration (memory is examined for contiguous RAM, starting at 100H). +On completion of the relocation, the new system is executed but not +permanently recorded on the disk. The system that is constructed +contains a BIOS for the Intel microcomputer development system 800. +.sp +.ti -15 +MOVCPM n Creates a relocated CP/M system for management of an n kilobyte +system (n must be in the range of 20 to 64), and executes the system as +described. +.sp +.ti -15 +MOVCPM * * Constructs a relocated memory image for the current memory +configuration, but leaves the memory image in memory in preparation for a +SYSGEN operation. +.sp +.ti -15 +MOVCPM n * Constructs a relocated memory image for an n kilobyte memory +system, and leaves the memory image in preparation for a SYSGEN operation. +.in 0 +.sp +.pp +For example, the command, +.sp +.ti 8 +MOVCPM * * +.sp +constructs a new version of the CP/M system and leaves it in +memory, ready for a SYSGEN operation. The message +.sp +.in 8 +.nf +READY FOR 'SYSGEN' OR +'SAVE 34 CPMxx.COM' +.fi +.in 0 +.sp +appears at the console upon completion, where xx is the current memory +size in kilobytes. You can then type the following sequence: +.sp 2 +.in 35 +.ti -27 +SYSGEN This starts the system generation. +.sp +.nf +.ti -27 +SOURCE DRIVE NAME Respond with a carriage return +.sp 0 +.fi +.ti -27 +(OR RETURN TO SKIP) to skip the CP/M read operation, because the +system is already in memory as a result of the previous MOVCPM operation. +.sp +.nf +.ti -27 +DESTINATION DRIVE NAME Respond with B to write new +.sp 0 +.fi +.ti -27 +(OR RETURN TO REBOOT) system to the disk in drive B. SYSGEN +prompts with the following message: +.sp +.mb 5 +.fm 1 +.nf +.ti -27 +DESTINATION ON B, Place the new disk on drive B +.sp 0 +.fi +.ti -27 +THEN TYPE RETURN and press the RETURN key when ready. +.in 0 +.bp +.mb 6 +.fm 2 +.pp +If you respond with A rather than B above, the system is +written to drive A rather than B. SYSGEN continues to print this +prompt: +.sp +.ti 8 +DESTINATION DRIVE NAME (OR RETURN TO REBOOT) +.sp +until you respond with a single carriage return, which stops the +SYSGEN program with a system reboot. +.pp +You can then go through the reboot process with the old or new +disk. Instead of performing the SYSGEN operation, you can +type a command of the form: +.sp +.ti 8 +SAVE 34 CPMxx.COM +.sp +at the completion of the MOVCPM function, where xx is the value indicated +in the SYSGEN message. The CP/M memory image on the currently logged disk is +in a form that can be patched. This is necessary when operating in a +nonstandard environment where the BIOS must be altered for a particular +peripheral device configuration, as described in Section 6. +.pp +The following are valid MOVCPM commands: +.sp 2 +.in 23 +.ti -15 +MOVCPM 48 Constructs a 48K version of CP/M and starts execution. +.sp +.mb 5 +.fm 1 +.ti -15 +MOVCPM 48 * Constructs a 48K version of CP/M in preparation for permanent +recording; the response is +.sp +.nf +READY FOR 'SYSGEN' OR + 'SAVE 34 CPM48.COM' +.fi +.sp +.ti -15 +MOVCPM * * Constructs a maximum memory version of CP/M and +starts execution. +.in 0 +.pp +The newly created system is serialized with the number attached to the +original disk and is subject to the conditions of the Digital Research +Software Licensing Agreement. +.sp 2 +.he CP/M Operating System Manual 1.7 BDOS Error Messages +.tc 1.7 BDOS Error Messages +.sh +1.7 BDOS Error Messages +.qs +.mb 6 +.fm 2 +.pp +There are three error situations that the Basic Disk Operating System +intercepts during file processing. When one of these conditions is detected, +the BDOS prints the message: +.sp +.ti 8 +BDOS ERR ON d: error +.bp +where d is the drive name and error is one of the three error messages: +.sp +.in 8 +.nf +BAD SECTOR +SELECT +READ ONLY +.fi +.in 0 +.pp +The BAD SECTOR message indicates that the disk controller electronics has +detected an error condition in reading or writing the disk. This +condition is generally caused by a malfunctioning disk controller or an +extremely worn disk. If you find that CP/M reports this +error more than once a month, the state of the controller electronics and the +condition of the media should be checked. +.pp +You can also encounter this condition in reading files generated +by a controller produced by a different manufacturer. Even +though controllers claim to be IBM..-compatible, one +often finds small differences in recording formats. The Model 800 controller, +for example, requires two bytes of one's following the data CRC byte, which +is not required in the IBM format. As a result, disks generated by the +Intel microcomputer development system can be read by almost all +other IBM-compatible system, while disk files generated on other +manufacturers' equipment produce the BAD SECTOR message when read +by the microcomputer development system. To recover from this +condition, press a CTRL-C to reboot (the safest course), or a +return, which ignores the bad sector in the file operation. +.sp +.sh +Note: \c +.qs +pressing a return might destroy disk integrity if the +operation is a directory write. Be sure you have adequate +back-ups in this case. +.pp +The SELECT error occurs when there is an attempt to address a drive beyond +the range supported by the BIOS. In this case, the value of d in the error +message gives the selected drive. The system reboots following any input +from the console. +.pp +The READ ONLY message occurs when there is an attempt to write to a +disk or file that has been designated as Read-Only in a STAT command or +has been set to Read-Only by the BDOS. Reboot CP/M by +using the warm start procedure, CTRL-C, or by performing a cold start +whenever the disks are changed. If a changed disk is to be read but +not written, BDOS allows the disk to be changed without the warm or +cold start, but internally marks the drive as Read-Only. The status of the +drive is subsequently changed to Read-Write if a warm or cold start occurs. +On issuing this message, CP/M waits for input from the console. An automatic +warm start takes place following any input. +.sp 2 +.he CP/M Operating System Manual 1.8 Operation of CP/M on the Model 800 +.tc 1.8 CP/M Operation on the Model 800 +.sh +1.8 CP/M Operation on the Model 800 +.pp +This section gives operating procedures for using CP/M on the +Intel Model 800 microcomputer development system microcomputer development +system. Basic knowledge of the microcomputer development system +hardware and software systems is assumed. +.pp +CP/M is initiated in essentially the same manner as the Intel ISIS operating +system. The disk drives are labeled 0 through 3 on the +microcomputer development system, corresponding +to CP/M drives A through D, respectively. The CP/M system disk is +inserted into drive 0, and the BOOT and RESET switches are pressed in +sequence. The interrupt 2 light should go on at this point. The space bar +is then pressed on the system console, and the light should go +out. If it does not, the user should check connections and baud rates. The +BOOT +switch is turned off, and the CP/M sign-on message should appear at the +selected console device, followed by the A> system prompt. You +can then issue the various resident and transient commands. +.pp +The CP/M system can be restarted (warm start) at any time by pushing the +INT 0 switch on the front panel. The built-in Intel ROM monitor can be +initiated by pushing the INT 7 switch, which generates an RST 7, except when +operating under DDT, in which case the DDT program gets control instead. +.pp +Diskettes can be removed from the drives at any time, and the system can be +shut down during operation without affecting data integrity. Do +not remove a disk and replace it with another without rebooting the +system (cold or warm start) unless the inserted disk is Read-Only. +.pp +As a result of hardware hang-ups or malfunctions, CP/M might +print the following message: +.sp +.ti 8 +BDOS ERR ON d: BAD SECTOR +.sp +where d is the drive that has a permanent error. This error can occur when +drive doors are opened and closed randomly, followed by disk operations, or +can be caused by a disk, drive, or controller failure. You can +optionally elect to ignore the error by pressing a single return at the +console. The error might produce a bad data record, requiring +reinitialization +of up to 128 bytes of data. You can reboot the CP/M system and try +the operation again. +.pp +Termination of a CP/M session requires no special action, except that it is +necessary to remove the disks before turning the power off to avoid +random transients that often make their way to the drive electronics. +.pp +You should use IBM-compatible disks rather than disks +that have previously been used with any ISIS version. In particular, the +ISIS FORMAT operation produces nonstandard sector numbering throughout the +disk. This nonstandard numbering seriously degrades the performance of +CP/M, and causes CP/M to operate noticeably slower than the distribution +version. If it becomes necessary to reformat a disk, which +should not be the case for standard disks, a program can be +written under CP/M that causes the Model 800 controller to +reformat with sequential sector numbering (1-26) on each track. +.pp +Generally, IBM-compatible 8-inch disks do not need to be formatted. +However, 5 1/4-inch disks need to be formatted. +.sp 2 +.ce +End of Section 1 +.nx two + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/part1.tex b/Source/Doc/CPM 22 Manual/part1.tex new file mode 100644 index 00000000..7e98c4ef --- /dev/null +++ b/Source/Doc/CPM 22 Manual/part1.tex @@ -0,0 +1,2 @@ +.nx front + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/part2.tex b/Source/Doc/CPM 22 Manual/part2.tex new file mode 100644 index 00000000..75330cc4 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/part2.tex @@ -0,0 +1,2 @@ +.nx appa.tex + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/part3.tex b/Source/Doc/CPM 22 Manual/part3.tex new file mode 100644 index 00000000..e8e80d7e --- /dev/null +++ b/Source/Doc/CPM 22 Manual/part3.tex @@ -0,0 +1,2 @@ +.nx apph.tex + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/sixa.tex b/Source/Doc/CPM 22 Manual/sixa.tex new file mode 100644 index 00000000..3b594928 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/sixa.tex @@ -0,0 +1,807 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 6-% +.pc 1 +.tc 6 CP/M 2 Alteration +.ce +.sh +Section 6 +.qs +.sp +.ce +.sh +CP/M 2 Alteration +.qs +.sp 3 +.tc 6.1 Introduction +.he CP/M Operating System Manual 6.1 Introduction +.sh +6.1 Introduction +.qs +.pp +The standard CP/M system assumes operation on an Intel Model +800 microcomputer development system , but is designed so you can alter a +specific set of subroutines that define the hardware operating +environment. +.pp +Although standard CP/M 2 is configured for single-density floppy +disks, field-alteration features allow adaptation to a wide +variety of disk subsystems from single-drive minidisks to +high-capacity, hard disk systems. To simplify the following +adaptation process, it is assumed that CP/M 2 is first +configured for single-density floppy disks where minimal editing +and debugging tools are available. If an earlier version of CP/M +is available, the customizing process is eased considerably. In +this latter case, you might want to review the system +generation process and skip to later sections that discuss system +alteration for nonstandard disk systems. +.pp +To achieve device independence, CP/M is separated into three +distinct modules: +.sp +.in 5 +.ti -2 +o BIOS is the Basic I/O System, which is environment dependent. +.sp +.ti -2 +o BDOS is the Basic Disk Operating System, which is not dependent upon the +hardware configuration. +.sp +.ti -2 +o CCP is the Console Command Processor, which uses the BDOS. +.fi +.in 0 +.pp +Of these modules, only the BIOS is dependent upon the particular +hardware. You can patch the distribution version +of CP/M to provide a new BIOS that provides a customized +interface between the remaining CP/M modules and the +hardware system. This document provides a step-by-step +procedure for patching a new BIOS into CP/M. +.mb 4 +.fm 1 +.pp +All disk-dependent portions of CP/M 2 are placed into a BIOS, a +resident disk parameter block, which is either hand coded or +produced automatically using the disk definition macro library +provided with CP/M 2. The end user need only specify the maximum +number of active disks, the starting and ending sector numbers, +the data allocation size, the maximum extent of the logical disk, +directory size information, and reserved track values. +The macros use this information to generate +the appropriate tables and table references for use during CP/M 2 +operation. Deblocking information is provided, which aids in +assembly or disassembly of sector sizes that are multiples of the +fundamental 128-byte data unit, and the system alteration manual +includes general purpose subroutines that use the deblocking +information to take advantage of larger sector sizes. Use of +these subroutines, together with the table-drive data access +algorithms, makes CP/M 2 a universal data management system. +.pp +File expansion is achieved by providing up to 512 logical file +extents, where each logical extent contains 16K bytes of data. +CP/M 2 is structured, however, so that as much as 128K bytes of +data are addressed by a single physical extent, corresponding to a +single directory entry, maintaining compatibility with previous +versions while taking advantage of directory space. +.pp +If CP/M is being tailored to a computer system for the first +time, the new BIOS requires some simple software development and +testing. The standard BIOS is listed in Appendix A and can be +used as a model for the customized package. A skeletal version +of the BIOS given in Appendix B can serve as the basis for a +modified BIOS. +.mb 6 +.fm 2 +.pp +In addition to the BIOS, you must write a simple memory +loader, called GETSYS, which brings the operating system into +memory. To patch the new BIOS into CP/M, you must write the +reverse of GETSYS, called PUTSYS, which places an altered version +of CP/M back onto the disk. PUTSYS can be derived from GETSYS by +changing the disk read commands into disk write commands. Sample +skeletal GETSYS and PUTSYS programs are described in Section 6.4 +and listed in Appendix C. +.pp +To make the CP/M system load automatically, you must also +supply a cold start loader, similar to the one provided with +CP/M, listed in Appendixes A and D. A skeletal form of a cold +start loader is given in Appendix E, which serves as a model for +the loader. +.mb 4 +.fm 1 +.sp 2 +.tc 6.2 First-level System Regeneration +.he CP/M Operating System Manual 6.2 First-level Regeneration +.sh +6.2 First-level System Regeneration +.qs +.pp +The procedure to patch the CP/M system is given below. Address +references in each step are shown with H denoting the +hexadecimal radix, and are given for a 20K CP/M system. For +larger CP/M systems, a bias is added to each address that is +shown with a +b following it, where b is equal to the memory +size-20K. Values for b in various standard memory sizes are listed in +Table 6-1. +.sp 2 +.sh + Table 6-1. Standard Memory Size Values + +.nf + Memory Size Value +.fi +.sp +.in 13 +24K: b = 24K - 20K = 4K = 1000H +.sp +32K: b = 32K - 20K = 12K = 3000H +.sp +40K: b = 40K - 20K = 20K = 5000H +.sp +48K: b = 48K - 20K = 28K = 7000H +.sp +56K: b = 56K - 20K = 36K = 9000H +.sp +62K: b = 62K - 20K = 42K = A800H +.sp +64K: b = 64K - 20K = 44K = B000H +.fi +.in 0 +.pp +Note that the standard distribution version of CP/M is set for +operation within a 20K CP/M system. Therefore, you must first bring up +the 20K CP/M system, then configure it for actual +memory size (see Section 6.3). +.pp +Follow these steps to patch your CP/M system: +.sp 2 +.in 8 +.ti -3 +1) Read Section 6.4 and write a GETSYS program that reads the +first two tracks of a disk into memory. The program from the +disk must be loaded starting at location 3380H. GETSYS is coded +to start at location 100H (base of the TPA) as shown in Appendix +C. +.mb 6 +.fm 2 +.sp +.ti -3 +2) Test the GETSYS program by reading a blank disk into memory, +and check to see that the data has been read properly and that +the disk has not been altered in any way by the GETSYS program. +.sp +.ti -3 +3) Run the GETSYS program using an initialized CP/M disk to see +if GETSYS loads CP/M starting at 3380H (the operating system +actually starts 128 bytes later at 3400H). +.sp +.ti -3 +4) Read Section 6.4 and write the PUTSYS program. This writes +memory starting at 3380H back onto the first two tracks of the +disk. The PUTSYS program should be located at 200H, as shown in +Appendix C. +.sp +.ti -3 +5) Test the PUTSYS program using a blank, uninitialized disk by +writing a portion of memory to the first two tracks; clear memory +and read it back using GETSYS. Test PUTSYS completely, because +this program will be used to alter CP/M on disk. +.sp +.ti -3 +6) Study Sections 6.5, 6.6, and 6.7 along with the distribution +version of the BIOS given in Appendix A and write a simple +version that performs a similar function for the customized +environment. Use the program given in Appendix B as a model. +Call this new BIOS by name CBIOS (customized BIOS). Implement +only the primitive disk operations on a single drive and simple +console input/output functions in this phase. +.sp +.ti -3 +7) Test CBIOS completely to ensure that it properly performs +console character I/O and disk reads and writes. Be careful to +ensure that no disk write operations occur during read operations +and check that the proper track and sectors are addressed on all +reads and writes. Failure to make these checks might cause +destruction of the initialized CP/M system after it is patched. +.mb 4 +.fm 1 +.sp +.ti -3 +8) Referring to Table 6-3 in Section 6.5, note that the BIOS is +placed between locations 4A00H and 4FFFH. Read the CP/M system +using GETSYS and replace the BIOS segment by the CBIOS developed +in step 6 and tested in step 7. This replacement is done in +memory. +.sp +.ti -3 +9) Use PUTSYS to place the patched memory image of CP/M onto the +first two tracks of a blank disk for testing. +.sp +.ti -4 +10) Use GETSYS to bring the copied memory image from the test +disk back into memory at 3380H and check to ensure that it has +loaded back properly (clear memory, if possible, before the +load). Upon successful load, branch to the cold start code at +location 4A00H. The cold start routine initializes page +zero, then jumps to the CCP at location 3400H, which calls the +BDOS, which calls the CBIOS. The CCP asks the CBIOS to read +sixteen sectors on track 2, and CP/M types A>, the system +prompt. +.mb 6 +.fm 2 +.sp +If difficulties are encountered, use whatever debug facilities +are available to trace and breakpoint the CBIOS. +.sp +.ti -4 +11) Upon completion of step 10, CP/M has prompted the console for +a command input. To test the disk write operation, type +.sp +SAVE 1 X.COM +.sp +All commands must be followed by a carriage return. CP/M +responds with another prompt after several disk accesses: +.sp +A> +.sp +If it does not, debug the disk write functions and retry. +.sp +.ti -4 +12) Test the directory command by typing +.sp +DIR +.sp +CP/M responds with +.sp +A:X COM +.sp +.ti -4 +13) Test the erase command by typing +.sp +ERA X.COM +.sp +CP/M responds with the A prompt. This is now an operational +system that only requires a bootstrap loader to function +completely. +.sp +.ti -4 +14) Write a bootstrap loader that is similar to GETSYS and place +it on track 0, sector 1, using PUTSYS (again using the test disk, +not the distribution disk). See Sections 6.5 and 6.8 for more +information on the bootstrap operation. +.sp +.ti -4 +15) Retest the new test disk with the bootstrap loader installed +by executing steps 11, 12, and 13. Upon completion of these +tests, type a CTRL-C. The system executes a warm start, which +reboots the system, and types the A prompt. +.sp +.ti -4 +16) At this point, there is probably a good version of the +customized CP/M system on the test disk. Use GETSYS to load CP/M +from the test disk. Remove the test disk, place the distribution +disk, or a legal copy, into the drive, and use PUTSYS to +replace the distribution version with the customized version. +Do not make this replacement if you are unsure of the patch +because this step destroys the system that was obtained from +Digital Research. +.sp +.ti -4 +17) Load the modified CP/M system and test it by typing +.sp +DIR +.sp +CP/M responds with a list of files that are provided on the +initialized disk. The file DDT.COM is the memory image for the +debugger. Note that from now on, you must always reboot the +CP/M system (CTRL-C is sufficient) when the disk is removed and +replaced by another disk, unless the new disk is to be Read-Only. +.sp +.ti -4 +18) Load and test the debugger by typing +.sp +DDT +.sp +See Chapter 4 for operating procedures. +.sp +.ti -4 +19) Before making further CBIOS modifications, practice using the +editor (see Chapter 2), and assembler (see Chapter 3). Recode +and test the GETSYS, PUTSYS, and CBIOS programs using ED, ASM, +and DDT. Code and test a COPY program that does a sector-to-sector +copy from one disk to another to obtain back-up copies of +the original disk. Read the CP/M Licensing Agreement specifying +legal responsibilities when copying the CP/M system. Place the +following copyright notice: +.sp +.nf +Copyright (c), 1983 + Digital Research +.fi +.sp +on each copy that is made with the COPY program. +.sp +.ti -4 +20) Modify the CBIOS to include the extra functions for punches, +readers, and sign-on messages, and add the facilities for +additional disk drives, if desired. These changes can be made +with the GETSYS and PUTSYS programs or by referring to the +regeneration process in Section 6.3. +.fi +.in 0 +.sp +.pp +You should now have a good copy of the customized CP/M +system. Although the CBIOS portion of CP/M belongs to the user, +the modified version cannot be legally copied. +.pp +It should be noted that the system remains file-compatible with +all other CP/M systems (assuming media compatibility) which +allows transfer of nonproprietary software between CP/M users. +.tc 6.3 Second-level System Generation +.bp +.he CP/M Operating System Manual 6.3 Second-level System Generation +.sh +6.3 Second-level System Generation +.qs +.pp +Once the system is running, the next step is to configure CP/M +for the desired memory size. Usually, a memory image is first +produced with the MOVCPM program (system relocator) and then +placed into a named disk file. The disk file can then be loaded, +examined, patched, and replaced using the debugger and the +system generation program (refer to Chapter 1). +.pp +The CBIOS and BOOT are modified using ED and assembled using ASM, +producing files called CBIOS.HEX and BOOT.HEX, which contain the +code for CBIOS and BOOT in Intel hex format. +.pp +To get the memory image of CP/M into the TPA configured for the +desired memory size, type the command: +.sp +.ti 8 +MOVCPM xx* +.sp +where xx is the memory size in decimal K bytes, for example, 32 +for 32K. The response is as follows: +.sp +.nf +.in 8 +CONSTRUCTING xxK CP/M VERS 2.0 +.sp +READY FOR "SYSGEN" OR +.sp +"SAVE 34 CPMxx.COM" +.fi +.in 0 +.pp +An image of CP/M in the TPA is configured for the requested +memory size. The memory image is at location 0900H through +227FH, that is, the BOOT is at 0900H, the CCP is at 980H, the +BDOS starts at 1180H, and the BIOS is at 1F80H. Note that the +memory image has the standard Model 800 BIOS and BOOT on it. It is now +necessary to save the memory image in a file so that you can +patch the CBIOS and CBOOT into it: +.sp +.ti 8 +SAVE 34 CPMxx.COM +.pp +The memory image created by the MOVCPM program is offset by a +negative bias so that it loads into the free area of the TPA, and +thus does not interfere with the operation of CP/M in higher +memory. This memory image can be subsequently loaded under DDT +and examined or changed in preparation for a new generation of +the system. DDT is loaded with the memory image by typing: +.sp +.ti 8 +DDT CPMxx.COM Loads DDT, then reads the CP/M image. +.sp +DDT should respond with the following: +.sp +.nf +.in 8 +NEXT PC +2300 0100 +- The DDT prompt +.fi +.in 0 +.sp +You can then give the display and disassembly commands to examine +portions of the memory image between 900H and 227FH. +Note, however, that to find any particular address +within the memory image, you must apply the negative bias to the +CP/M address to find the actual address. Track 00, sector 01, is +loaded to location 900H (the user should find the cold start +loader at 900H to 97FH); track 00, sector 02, is loaded into 980H +(this is the base of the CCP); and so on through the entire CP/M +system load. In a 20K system, for example, the CCP resides at +the CP/M address 3400H, but is placed into memory at 980H by the +SYSGEN program. Thus, the negative bias, denoted by n, satisfies +.sp +.ti 8 +3400H + n = 980H, or n =980H - 3400H +.sp +Assuming two's complement arithmetic, n = D580H, which can be +checked by +.sp +.ti 8 +.nf +3400H + D580H = 10980H = 0980H (ignoring high-order + overflow). +.fi +.pp +Note that for larger systems, n satisfies +.sp +.nf +.in 8 +(3400H+b) + n = 980H, or +n = 980H - (3400H + b), or +n = D580H - b +.fi +.in 0 +.sp +The value of n for common CP/M systems is given below. +.sp 2 +.sh + Table 6-2. Common Values for CP/M Systems +.sp +.nf + Memory Size BIAS b Negative Offset n +.sp +.in 13 +20K 0000H D580H - 0000H = D580H +24K 1000H D580H - 1000H = C580H +32K 3000H D580H - 3000H = A580H +40K 5000H D580H - 5000H = 8580H +48K 7000H D580H - 7000H = 6580H +56K 9000H D580H - 9000H = 4580H +62K A800H D580H - A800H = 2D80H +64K B000H D580H - B000H = 2580H +.fi +.in 0 +.sp +.pp +If you want to locate the address x within the memory image +loaded under DDT in a 20K system, first type +.sp +.ti 8 +Hx,n Hexadecimal sum and difference +.sp +and DDT responds with the value of x+n (sum) and x-n +(difference). The first number printed by DDT is the actual memory +address in the image where the data or code is located. For example, +the following DDT command: +.sp +.ti 8 +H3400,D580 +.sp +produces 980H as the sum, which is where the CCP +is located in the memory image under DDT. +.pp +Type the L command to disassemble portions of the +BIOS located at (4A00H+b)-n, which, when one uses the H command, +produces an actual address of 1F80H. The disassembly command +would thus be as follows: +.sp +.ti 8 +L1F80 +.sp +It is now necessary to patch in the CBOOT and CBIOS routines. The BOOT +resides at location 0900H in the memory image. If the actual +load address is n, then to calculate the bias (m), +type the command: +.sp +.ti 8 +H900,n Subtract load address from target address. +.pp +The second number typed by DDT in response to the command is the +desired bias (m). For example, if the BOOT executes at 0080H, +the command +.sp +.ti 8 +H900,80 +.sp +produces +.sp +.ti 8 +0980 0880 Sum and difference in hex. +.sp +Therefore, the bias m would be 0880H. To read-in the BOOT, give the command: +.sp +.ti 8 +ICBOOT.HEX Input file CBOOT.HEX +.sp +Then +.sp +.ti 8 +Rm Read CBOOT with a bias of m (=900H-n). +.sp +Examine the CBOOT with +.sp +.ti 8 +L900 +.sp +You are now ready to replace the CBIOS by examining the area at +1F80H, where the original version of the CBIOS resides, and then +typing +.sp +.ti 8 +ICBIOS.HEX Ready the hex file for loading. +.pp +Assume that the CBIOS is being integrated into a 20K +CP/M system and thus originates at location 4A00H. To locate the +CBIOS properly in the memory image under DDT, you must apply the +negative bias n for a 20K system when loading the hex file. This +is accomplished by typing +.sp +.ti 8 +RD580 Read the file with bias D580H. +.sp +Upon completion of the read, reexamine the area +where the CBIOS has been loaded (use an L1F80 command) to ensure +that it is properly loaded. When you are satisfied that the change has +been made, return from DDT using a CTRL-C or, G0 command. +.pp +SYSGEN is used to replace the patched memory image back onto a +disk (you use a test disk until sure of the +patch) as shown in the following interaction: +.sp 2 +.nf +.in 8 +SYSGEN Start the SYSGEN program. +.sp +SYSGEN VERSION 2.0 Sign-on message from SYSGEN. +.sp +SOURCE DRIVE NAME Respond with a carriage return +(OR RETURN TO SKIP) to skip the CP/M read operation + because the system is already + in memory. +.sp +DESTINATION DRIVE NAME Respond with B to write the new +(OR RETURN TO REBOOT) system to the disk in drive B. + +.sp +DESTINATION ON B, Place a scratch disk in drive +THEN TYPE RETURN B, then press RETURN. +.sp +FUNCTION COMPLETE +DESTINATION DRIVE NAME +(OR RETURN TO REBOOT) +.fi +.in 0 +.sp +.pp +Place the scratch disk in drive A, then +perform a cold start to bring up the newly-configured CP/M +system. +.pp +The new CP/M system is then tested and the Digital Research +copyright notice is placed on the disk, as specified in the +Licensing Agreement: +.sp +.nf +.in 8 +Copyright (c), 1979 + Digital Research +.fi +.in 0 +.sp 2 +.tc 6.4 Sample GETSYS and PUTSYS Programs +.he CP/M Operating System Manual 6.4 Sample GETSYS and PUTSYS +.sh +6.4 Sample GETSYS and PUTSYS Programs +.qs +.pp +The following program provides a framework for the GETSYS and +PUTSYS programs referenced in Sections 6.1 and 6.2. To read and +write the specific sectors, you must insert the READSEC and WRITESEC +subroutines. +.bp +.nf +; GETSYS PROGRAM -- READ TRACKS 0 AND 1 TO MEMORY AT 3380H +; REGISTER USE +.sp +; A (SCRATCH REGISTER) +.sp +; B TRACK COUNT (0, 1) +.sp +; C SECTOR COUNT (1,2,...,26) +.sp +; DE (SCRATCH REGISTER PAIR) +.sp +; HL LOAD ADDRESS +.sp +; SP SET TO STACK ADDRESS +.sp +; +START: LXI SP,3380H ;SET STACK POINTER TO SCRATCH + ;AREA + LXI H,3380H ;SET BASE LOAD ADDRESS + MVI B,0 ;START WITH TRACK 0 +RDTRK: ;READ NEXT TRACK (INITIALLY 0) + MVI C,1 ;READ STARTING WITH SECTOR 1 +.sp +RDSEC: ;READ NEXT SECTOR + CALL READSEC ;USER-SUPPLIED SUBROUTINE + LXI D,128 ;MOVE LOAD ADDRESS TO NEXT 1/2 + ;PAGE + DAD D ;HL = HL + 128 + INR C ;SECTOR = SECTOR + 1 + MOV A,C ;CHECK FOR END OF TRACK + CPI 27 + JC RDSEC ;CARRY GENERATED IF SECTOR <27 +.sp +; +; ARRIVE HERE AT END OF TRACK, MOVE TO NEXT TRACK + INR B + MOV A,B ;TEST FOR LAST TRACK + CPI 2 + JC RDTRK ;CARRY GENERATED IF TRACK <2 +.sp +; +; USER-SUPPLIED SUBROUTINE TO READ THE DISK +READSEC: +; ENTER WITH TRACK NUMBER IN REGISTER B, + SECTOR NUMBER IN REGISTER C, AND +.sp +; ADDRESS TO FILL IN HL +.sp +; + PUSH B ;SAVE B AND C REGISTERS + PUSH H ;SAVE HL REGISTERS +.sp 2 +.sh + Listing 6-1. GETSYS Program +.bp + ................................................. + perform disk read at this point, branch to + label START if an error occurs + ................................................. + POP H ;RECOVER HL + POP B ;RECOVER B AND C REGISTERS + RET ;BACK TO MAIN PROGRAM +.sp + END START +.fi +.in 0 +.sp 2 +.sh + Listing 6-1. (continued) +.sp 2 +.pp +This program is assembled and listed in Appendix B for reference +purposes, with an assumed origin of 100H. The hexadecimal +operation codes that are listed on the left might be useful if the +program has to be entered through the panel switches. +.pp +The PUTSYS program can be constructed from GETSYS by changing +only a few operations in the GETSYS program given above, as shown +in Appendix C. The register pair HL becomes the dump address, +next address to write, and operations on these registers do not +change within the program. The READSEC subroutine is replaced by +a WRITESEC subroutine, which performs the opposite function; data +from address HL is written to the track given by register B +and sector given by register C. It is often useful to combine +GETSYS and PUTSYS into a single program during the test and +development phase, as shown in Appendix C. +.sp 2 +.tc 6.5 Disk Organization +.he CP/M Operating System Manual 6.5 Disk Organization +.sh +6.5 Disk Organization +.qs +.pp +The sector allocation for the standard distribution version of +CP/M is given here for reference purposes. The first sector contains +an optional software boot section (see the table on the following +page. Disk controllers are often set up to bring track 0, +sector 1, into memory at a specific location, often location +0000H. The program in this sector, called BOOT, has the +responsibility of bringing the remaining sectors into memory +starting at location 3400H+b. If the controller does not +have a built-in sector load, the program in track 0, sector 1 can +be ignored. In this case, load the program from track 0, sector +2, to location 3400H+b. +.pp +As an example, the Intel Model 800 +hardware cold start loader brings track 0, sector 1, into +absolute address 3000H. Upon loading this sector, control +transfers to location 3000H, where the bootstrap operation +commences by loading the remainder of track 0 and all of track 1 +into memory, starting at 3400H+b. Note that this bootstrap +loader is of little use in a non-microcomputer development system +environment, although it is useful to examine it because some of +the boot actions will have to be duplicated in the user's cold +start loader. +.bp +.sh + Table 6-3. CP/M Disk Sector Allocation +.sp +.nf +Track # Sector Page# Memory Address CP/M Module name +.sp + 00 01 (boot address) Cold Start Loader + 00 02 00 3400H+b CCP + ' 03 ' 3480H+b ' + ' 04 01 3500H+b ' + ' 05 ' 3580H+b ' + ' 06 02 3600H+b ' + ' 07 ' 3680H+b ' + ' 08 03 3700H+b ' + ' 09 ' 3780H+b ' + ' 10 04 3800H+b ' + ' 11 ' 3880H+b ' + ' 12 05 3900H+b ' + ' 13 ' 3980H+b ' + ' 14 06 3A00H+b ' + ' 15 ' 3A80H+b ' + ' 16 07 3B00H+b ' + 00 17 ' 3B80H+b CCP + 00 18 08 3C00H+b BDOS + ' 19 ' 3C80H+b ' + ' 20 09 3D00H+b ' + ' 21 ' 3D80H+b ' + ' 22 10 3E00H+b ' + ' 23 ' 3E80H+b ' + ' 24 11 3F00H+b ' + ' 25 ' 3F80H+b ' + ' 26 12 4000H+b ' + 01 01 ' 4080H+b ' + ' 02 13 4100H+b ' + ' 03 ' 4180H+B ' + ' 04 14 4200H+b ' + ' 05 ' 4280H+b ' + ' 06 15 4300H+b ' + ' 07 ' 4380H+b ' + ' 08 16 4400H+b ' + ' 09 ' 4480H+b ' + ' 10 17 4500H+b ' + ' 11 ' 4580H+b ' + ' 12 18 4600H+b ' + ' 13 ' 4680H+b ' + ' 14 19 4700H+b ' + ' 15 ' 4780H+b ' + ' 16 20 4800H+b ' + ' 17 ' 4880H+b ' + ' 18 21 4900H+b ' +.mb 4 +.fm 1 + 01 19 ' 4900H+b BDOS + 07 20 22 4A00H+b BIOS + ' 21 ' 4A80H+b ' + ' 22 23 4B00H+b ' + ' 23 ' 4B80H+b ' + ' 24 24 4C00H+b ' + 01 25 ' 4C80H+b BIOS + 01 26 25 4D00H+b BIOS +02-76 01-26 (directory and data) +.fi +.nx sixb + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/sixb.tex b/Source/Doc/CPM 22 Manual/sixb.tex new file mode 100644 index 00000000..5ab5e7e7 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/sixb.tex @@ -0,0 +1,1311 @@ +.bp 13 +.tc 6.6 The BIOS Entry Points +.he CP/M Operating System Manual 6.6 BIOS Entry Points +.sh +6.6 The BIOS Entry Points +.qs +.pp 5 +The entry points into the BIOS from the cold start loader and +BDOS are detailed below. Entry to the BIOS is through a jump +vector located at 4A00H+b, as shown below. See Appendixes A and +B. The jump vector is a sequence of 17 jump +instructions that send program control to the individual BIOS +subroutines. The BIOS subroutines might be empty for certain +functions (they might contain a single RET operation) +during reconfiguration of CP/M, but the entries must be present +in the jump vector. +.pp +The jump vector at 4A00H+b takes the form shown below, where the +individual jump addresses are given to the left: +.mb 4 +.fm 1 +.mt 4 +.hm 1 +.sp 2 +.nf +.in 5 +4A00H+b JMP BOOT ;ARRIVE HERE FROM COLD + START LOAD +.sp +4A03H+b JMP WBOOT ;ARRIVE HERE FOR WARM START + +4A06H+b JMP CONST ;CHECK FOR CONSOLE CHAR + READY + +4A09H+b JMP CONIN ;READ CONSOLE CHARACTER IN + +4A0CH+b JMP CONOUT ;WRITE CONSOLE CHARACTER + OUT + +4A0FH+b JMP LIST ;WRITE LISTING CHARACTER OUT + +4A12H+b JMP PUNCH ;WRITE CHARACTER TO PUNCH + DEVICE + +4A15H+b JMP READER ;READ READER DEVICE + +4A18H+b JMP HOME ;MOVE TO TRACK 00 ON + SELECTED DISK + +4A1BH+b JMP SELDSK ;SELECT DISK DRIVE + +4A1EH+b JMP SETTRK ;SET TRACK NUMBER + +4A21H+b JMP SETSEC ;SET SECTOR NUMBER + +4A24H+b JMP SETDMA ;SET DMA ADDRESS + +4A27H+b JMP READ ;READ SELECTED SECTOR + +4A2AH+b JMP WRITE ;WRITE SELECTED SECTOR + +4A2DH+b JMP LISTST ;RETURN LIST STATUS + +4A30H+b JMP SECTRAN ;SECTOR TRANSLATE + SUBROUTINE +.fi +.in 0 +.sp 2 +.sh + Listing 6-2. BIOS Entry Points +.pp +Each jump address corresponds to a particular subroutine that performs the +specific function, as outlined below. There are three major +divisions in the jump table: the system reinitialization, +which results from calls on BOOT and WBOOT; simple character I/O, +performed by calls on CONST, CONIN, CONOUT, LIST, PUNCH, READER, +and LISTST; and disk I/O, performed by calls on HOME, SELDSK, +SETTRK, SETSEC, SETDMA, READ, WRITE, and SECTRAN. +.pp +All simple character I/O operations are assumed to be performed +in ASCII, upper- and lower-case, with high-order (parity bit) set +to zero. An end-of-file condition for an input device is given +by an ASCII CTRL-Z (1AH). Peripheral devices are seen by CP/M as +logical devices and are assigned to physical devices within the +BIOS. +.pp +To operate, the BDOS needs only the CONST, CONIN, and CONOUT +subroutines. LIST, PUNCH, and READER can be used by PIP, but not +the BDOS. Further, the LISTST entry is currently used only by +DESPOOL, the print spooling utility. Thus, the initial version +of CBIOS can have empty subroutines for the remaining ASCII +devices. +.pp +The following list describes the characteristics of each device. +.sp 2 +.in 5 +.ti -2 +o CONSOLE is the principal interactive console that communicates with the +operator and it is accessed through CONST, CONIN, and CONOUT. Typically, the +CONSOLE is a device such as a CRT or teletype. +.sp +.ti -2 +o LIST is the principal listing device. If it exists on the user's system, +it is usually a hard-copy device, such as a printer or teletype. +.sp +.ti -2 +o PUNCH is the principal tape punching device. If it exists, it is normally a +high-speed paper tape punch or teletype. +.sp +.ti -2 +o READER is the principal tape reading device, such as a simple optical +reader or teletype. +.fi +.in 0 +.sp +.pp +A single peripheral can be assigned as the LIST, PUNCH, and +READER device simultaneously. If no peripheral device is +assigned as the LIST, PUNCH, or READER device, the CBIOS +gives an appropriate error message so that the +system does not hang if the device is accessed by PIP or some +other user program. Alternately, the PUNCH and LIST routines can +just simply return, and the READER routine can return with a 1AH +(CTRL-Z) in register A to indicate immediate end-of-file. +.pp +For added flexibility, you can optionally implement the +IOBYTE function, which allows reassignment of physical devices. +The IOBYTE function creates a mapping of logical-to-physical +devices that can be altered during CP/M processing, +see the STAT command in Section 1.6.1. +.pp +The definition of the IOBYTE function corresponds to the Intel +standard as follows: a single location in memory, currently +location 0003H, is maintained, called IOBYTE, which defines the +logical-to-physical device mapping that is in effect at a +particular time. The mapping is performed by splitting the +IOBYTE into four distinct fields of two bits each, called the +CONSOLE, READER, PUNCH, and LIST fields, as shown in the +following figure. +.sp 2 +.nf + most significant least significant +.sp + IOBYTE AT 003H LIST PUNCH READER CONSOLE +.sp + bits 6,7 bits 4,5 bits 2,3 bits 0,1 +.fi +.sp 2 +.sh + Figure 6-1. IOBYTE Fields +.sp 2 +.pp +The value in each field can be in the range 0-3, defining the +assigned source or destination of each logical device. Table 6-4 +gives the values that can be assigned to each field. +.sp 2 +.sh +.nf + Table 6-4. IOBYTE Field Values +.sp + Value Meaning +.sp + CONSOLE field (bits 0,1) +.sp + 0 console is assigned to the console printer + device (TTY:) + 1 console is assigned to the CRT device (CRT:) + 2 batch mode: use the READER as the CONSOLE input, + and the LIST device as the CONSOLE output (BAT:) + 3 user-defined console device (UC1:) +.sp +.mb 4 +.fm 1 +.mt 4 +.hm 1 + READER field (bits 2,3) +.sp + 0 READER is the teletype device (TTY:) + 1 READER is the high speed reader device (PTR:) + 2 user-defined reader #1 (UR1:) + 3 user-defined reader #2 (UR2:) +.sp + PUNCH field (bits 4,5) +.sp + 0 PUNCH is the teletype device (TTY:) + 1 PUNCH is the high speed punch device (PTP:) + 2 user-defined punch #1 (UP1:) + 3 user-defined punch #2 (UP2:) +.sp + LIST field (bits 6,7) +.sp + 0 LIST is the teletype device (TTY:) + 1 LIST is the CRT device (CRT:) + 2 LIST is the line printer device (LPT:) + 3 user-defined list device (UL1:) +.fi +.bp +.pp +The implementation of the IOBYTE is optional and effects only the +organization of the CBIOS. No CP/M systems use the IOBYTE +(although they tolerate the existence of the IOBYTE at location +0003H) except for PIP, which allows access to the physical +devices, and STAT, which allows logical-physical assignments to +be make or displayed. For more information see Section 1. In +any case the IOBYTE implementation should be omitted until the +basic CBIOS is fully implemented and tested; then you should +add the IOBYTE to increase the facilities. +.mb 6 +.fm 2 +.mt 5 +.hm 2 +.pp +Disk I/O is always performed through a sequence of calls on the +various disk access subroutines that set up the disk number to +access, the track and sector on a particular disk, and the Direct +Memory Access (DMA) address involved in the I/O operation. After +all these parameters have been set up, a call is made to the READ +or WRITE function to perform the actual I/O operation. +.pp +There is often a single call to SELDSK to select a disk drive, +followed by a number of read or write operations to the selected +disk before selecting another drive for subsequent operations. +Similarly, there might be a single call to set the DMA address, +followed by several calls that read or write from the selected +DMA address before the DMA address is changed. The track and +sector subroutines are always called before the READ or WRITE +operations are performed. +.pp +The READ and WRITE routines should perform several retries (10 is +standard) before reporting the error condition to the BDOS. If +the error condition is returned to the BDOS, it reports the +error to the user. The HOME subroutine might or might not actually +perform the track 00 seek, depending upon controller +characteristics; the important point is that track 00 has been +selected for the next operation and is often treated in exactly +the same manner as SETTRK with a parameter of 00. +.pp +The following table describes the exact responsibilities of each +BIOS entry point subroutine. +.sp 2 +.sh + Table 6-5. BIOS Entry Points +.sp + Entry Point Function +.sp +.ll 60 +.in 15 +.ti -9 +BOOT The BOOT entry point gets control from the cold start loader and is +responsible for basic system initialization, including sending a sign-on +message, which can be omitted in the first version. If the IOBYTE function +is implemented, it must be set at this point. The various system parameters +that are set by the WBOOT entry point must be initialized, and control is +transferred to the CCP at 3400+b for further processing. Note that register +C must be set to zero to select drive A. +.in 0 +.bp +.sh + Table 6-5. (continued) +.sp + Entry Point Function +.sp +.in 15 +.ti -9 +WBOOT The WBOOT entry point gets control when a warm start occurs. A warm +start is performed whenever a user program branches to location 0000H, or +when the CPU is reset from the front panel. The CP/M system must be loaded +from the first two tracks of drive A up to, but not including, the BIOS, or +CBIOS, if the user has completed the patch. System parameters must be +initialized as follows: +.sp +.in 32 +.ti -17 +location 0,1,2 Set to JMP WBOOT for warm starts (000H: JMP 4A03H+b) +.sp +.ti -17 +location 3 Set initial value of IOBYTE, if implemented in the CBIOS +.sp +.ti -17 +location 4 High nibble = current user no; low nibble = current drive +.sp +.ti -17 +location 5,6,7 Set to JMP BDOS, which is the primary entry point to CP/M for +transient programs. (0005H: JMP 3C06H+b) +.sp +.in 15 +Refer to Section 6.9 for complete details of page zero use. +Upon completion of the initialization, the WBOOT program must branch to the +CCP at 3400H+b to restart the system. Upon entry to the CCP, register C is +set to the drive to select after system initialization. The WBOOT routine +should read location 4 in memory, verify that is a legal drive, and pass it +to the CCP in register C. +.sp +.ti -9 +CONST You should sample the status of the currently assigned console +device and return 0FFH in register A if a character is ready to read and 00H +in register A if no console characters are ready. +.sp +.ti -9 +CONIN The next console character is read into register A, and the parity +bit is set, high-order bit, to zero. If no console character is ready, +wait until a character is typed before returning. +.in 0 +.bp +.sh + Table 6-5. (continued) +.sp + Entry Point Function +.sp +.in 15 +.ti -9 +CONOUT The character is sent from register C to the console +output device. The character is in ASCII, with high-order parity +bit set to zero. You might want to include a time-out on a +line-feed or carriage return, if the console device requires some +time interval at the end of the line (such as a TI Silent 700 +terminal). You can filter out control characters that cause +the console device to react in a strange way (CTRL-Z causes the +Lear-Seigler terminal to clear the screen, for example). +.sp +.ti -9 +LIST The character is sent from register C to the currently +assigned listing device. The character is in ASCII with zero +parity bit. +.sp +.ti -9 +PUNCH The character is sent from register C to the currently +assigned punch device. The character is in ASCII with zero +parity. +.sp +.ti -9 +READER The next character is read from the currently assigned reader +device into register A with zero parity (high-order bit must be +zero); an end-of-file condition is reported by returning an ASCII +CTRL-Z(1AH). +.sp +.ti -9 +HOME The disk head of the currently selected disk +(initially disk A) is moved to the track 00 position. If the controller +allows access to the track 0 flag from the drive, the head is +stepped until the track 0 flag is detected. If the controller +does not support this feature, the HOME +call is translated into a call to SETTRK with a parameter of 0. +.sp +.ti -9 +SELDSK The disk drive given by register C is selected for further +operations, where register C contains 0 for drive A, 1 for drive B, and so +on up to 15 for drive P (the standard CP/M distribution version supports four +drives). On each disk select, SELDSK must return in HL the base address of a +16-byte area, called the Disk Parameter Header, described in Section 6.10. +For standard floppy disk drives, the contents of the header and associated +tables do not change; thus, the program segment included in the sample CBIOS +performs this operation automatically. +.in 0 +.bp +.sh + Table 6-5. (continued) +.sp + Entry Point Function +.sp +.in 15 +If there is an attempt to select a +nonexistent drive, SELDSK returns HL=0000H as an error indicator. +Although SELDSK must return the header address on each call, it is advisable +to postpone the physical disk select operation until an I/O function (seek, +read, or write) is actually performed, because disk selects often occur +without utimately performing any disk I/O, and many controllers unload +the head of the current disk before selecting the new drive. This +causes an excessive amount of noise and disk wear. The least significant bit +of register E is zero if this is the first occurrence of the drive select +since the last cold or warm start. +.sp +.ti -9 +SETTRK Register BC contains the track number for subsequent disk accesses +on the currently selected drive. The sector number in BC is the same as the +number returned from the SECTRAN entry point. You can choose to seek +the selected track at this time or delay the seek until the next read or +write actually occurs. Register BC can take on values in the range 0-76 +corresponding to valid track numbers for standard floppy disk drives and +0-65535 for nonstandard disk subsystems. +.sp +.ti -9 +SETSEC Register BC contains the sector number, 1 through 26, for subsequent +disk accesses on the currently selected drive. The sector number in BC is +the same as the number returned from the SECTRAN entry point. You can +choose to send this information to the controller at this point or delay +sector selection until a read or write operation occurs. +.mb 4 +.fm 1 +.sp +.ti -9 +SETDMA Register BC contains the DMA (Disk Memory Access) address for +subsequent read or write operations. For example, if B = 00H and C = 80H +when SETDMA is called, all subsequent read operations read their data into +80H through 0FFH and all subsequent write operations get their +data from 80H through 0FFH, until the next call +to SETDMA occurs. The initial DMA address is +assumed to be 80H. The controller need not +actually support Direct Memory Access. If, +for example, all data transfers are through I/O +ports, the CBIOS that is constructed uses +the 128-byte area starting at the selected DMA +address for the memory buffer during the +subsequent read or write operations. +.in 0 +.bp +.sh + Table 6-5. (continued) +.sp + Entry Point Function +.sp +.in 15 +.ti -9 +READ Assuming the drive has been selected, the track +has been set, and the DMA address has been +specified, the READ subroutine attempts to +read one sector based upon these parameters +and returns the following error codes in +register A: +.sp +0 no errors occurred +.sp +1 nonrecoverable error condition occurred +.sp +Currently, CP/M responds only to a zero or nonzero +value as the return code. That is, if the +value in register A is 0, CP/M assumes that the +disk operation was completed properly. IF an +error occurs the CBIOS should attempt +at least 10 retries to see if the error is +recoverable. When an error is reported the BDOS +prints the message BDOS ERR ONx: BAD +SECTOR. The operator then has the option of +pressing a carriage return to ignore the error, or +CTRL-C to abort. +.sp +.ti -9 +WRITE Data is written from the currently +selected DMA address to the currently selected +drive, track, and sector. For floppy disks, the +data should be marked as nondeleted data to +maintain compatibility with other CP/M systems. +The error codes given in the READ command are +returned in register A, with error recovery +attempts as described above. +.mb 6 +.fm 2 +.sp +.ti -9 +LISTST You return the ready status of the list +device used by the DESPOOL program to improve +console response during its operation. The +value 00 is returned in A if the list device is +not ready to accept a character and 0FFH if a +character can be sent to the printer. A 00 +value should be returned if LIST status is not +implemented. +.in 0 +.bp +.sh + Table 6-5. (continued) +.sp + Entry Point Function +.sp +.in 15 +.ti -9 +SECTRAN Logical-to-physical sector +translation is performed to improve the overall response of +CP/M. Standard CP/M systems are shipped with a +skew factor of 6, where six physical sectors are +skipped between each logical read operation. +This skew factor allows enough time between +sectors for most programs to load their buffers +without missing the next sector. In particular +computer systems that use fast processors, +memory, and disk subsystems, the skew factor might +be changed to improve overall response. +However, the user should maintain a single-density +IBM-compatible version of CP/M for +information transfer into and out of the +computer system, using a skew factor of 6. +.sp +In general, SECTRAN receives a logical sector +number relative to zero in BC and a translate +table address in DE. The sector number is used +as an index into the translate table, with the +resulting physical sector number +in HL. For standard systems, the table and +indexing code is provided in the CBIOS and +need not be changed. +.in 0 +.ll 65 +.sp 2 +.tc 6.7 A Sample BIOS +.he CP/M Operating System Manual 6.7 A Sample BIOS +.sh +6.7 A Sample BIOS +.qs +.pp +The program shown in Appendix B can serve as a basis for your +first BIOS. The simplest functions are assumed in this BIOS, so +that you can enter it through a front panel, if absolutely +necessary. You must alter and insert code into the +subroutines for CONST, CONIN, CONOUT, READ, WRITE, and WAITIO +subroutines. Storage is reserved for user-supplied code in these +regions. The scratch area reserved in page zero (see Section +6.9) for the BIOS is used in this program, so that it could be +implemented in ROM, if desired. +.pp +Once operational, this skeletal version can be enhanced to print +the initial sign-on message and perform better error recovery. +The subroutines for LIST, PUNCH, and READER can be filled out and +the IOBYTE function can be implemented. +.sp 2 +.tc 6.8 A Sample Cold Start Loader +.he CP/M Operating System Manual 6.8 A Sample Cold Start Loader +.sh +6.8 A Sample Cold Start Loader +.qs +.pp +The program shown in Appendix E can serve as a basis for a cold +start loader. The disk read function must be supplied by the +user, and the program must be loaded somehow starting at location +0000. Space is reserved for the patch code so that the total +amount of storage required for the cold start loader is 128 +bytes. +.pp +Eventually, you might want to get this +loader onto the first disk sector (track 0, sector 1) and cause +the controller to load it into memory automatically upon system +start up. Alternatively, the cold start loader can be placed +into ROM, and above the CP/M system. In this case, it is +necessary to originate the program at a higher address and key in +a jump instruction at system start up that branches to the +loader. Subsequent warm starts do not require this key-in +operation, because the entry point WBOOT gets control, thus bringing +the system in from disk automatically. The skeletal cold start +loader has minimal error recovery, which might be enhanced in later +versions. +.sp 2 +.tc 6.9 Reserved Locations in Page Zero +.he CP/M Operating System Manual 6.9 Reserved Locations in Page Zero +.sh +6.9 Reserved Locations in Page Zero +.qs +.pp +Main memory page zero, between locations 00H and 0FFH, contains +several segments of code and data that are used during CP/M +processing. The code and data areas are given in the following table. +.sp 2 +.sh + Table 6-6. Reserved Locations in Page Zero +.sp +.nf + Locations Contents +.fi +.sp +.ll 60 +.in 22 +.ti -17 +000H-0002H Contains a jump instruction to the warm start entry location +4A03H+b. This allows a simple programmed restart (JMP 0000H) or manual +restart from the front panel. +.sp +.ti -17 +0003H-0003H Contains the Intel standard IOBYTE is optionally +included in the user's CBIOS (refer to Section 6.6). +.sp +.ti -17 +0004H-0004H Current default drive number (0=A,...,15=P). +.sp +.ti -17 +0005H-0007H Contains a jump instruction to the BDOS and serves two +purposes: JMP 0005H provides the primary entry point to the BDOS, as +described in Chapter 5, and LHLD 0006H brings the address field of the +instruction to the HL register pair. This value is the lowest address in +memory used by CP/M, assuming the CCP is being overlaid. The DDT program +changes the address field to reflect the reduced memory size in debug mode. +.sp +.ti -17 +0008H-0027H Interrupt locations 1 through 5 not used. +.sp +.ti -17 +0030H-0037H Interrupt location 6 (not currently used) is reserved. +.in 0 +.bp +.sh + Table 6-6. (continued) +.sp +.nf + Locations Contents +.fi +.sp +.in 22 +.ti -17 +0038H-003AH Restart 7; contains a jump instruction into the DDT or SID +program when running in debug mode for programmed breakpoints, but is not +otherwise used by CP/M. +.sp +.ti -17 +003BH-003FH Not currently used; reserved. +.sp +.ti -17 +0040H-004FH A 16-byte area reserved for scratch by CBIOS, but is not +used for any purpose in the distribution version of CP/M. +.sp +.ti -17 +0050H-005BH Not currently used; reserved. +.sp +.ti -17 +005CH-007CH Default File Control Block produced for a transient +program by the CCP. +.sp +.ti -17 +007DH-007FH Optional default random record position. +.sp +.ti -17 +0080H-00FFH Default 128-byte disk buffer, also filled with the +command line when a transient is loaded under the CCP. +.in 0 +.ll 65 +.mb 4 +.fm 1 +.sp +.pp +This information is set up for normal operation under the CP/M +system, but can be overwritten by a transient program if the BDOS +facilities are not required by the transient. +.pp +If, for example, a particular program performs only simple I/O +and must begin execution at location 0, it can first be loaded +into the TPA, using normal CP/M facilities, with a small memory +move program that gets control when loaded. The memory move +program must get control from location 0100H, which is the +assumed beginning of all transient programs. The move program can +then proceed to the entire memory image down to location 0 and +pass control to the starting address of the memory load. +.pp +If the BIOS is overwritten or if location 0, containing the warm +start entry point, is overwritten, the operator must bring the +CP/M system back into memory with a cold start sequence. +.sp 2 +.tc 6.10 Disk Parameter Tables +.he CP/M Operating System Manual 6.10 Disk Parameter Tables +.sh +6.10 Disk Parameter Tables +.qs +.pp +Tables are included in the BIOS that describe the particular +characteristics of the disk subsystem used with CP/M. These +tables can be either hand-coded, as shown in the sample CBIOS in +Appendix B, or automatically generated using the DISKDEF macro +library, as shown in Appendix F. The purpose here is to describe +the elements of these tables. +.bp +.pp +In general, each disk drive has an associated (16-byte) disk +parameter header that contains information about the disk drive +and provides a scratch pad area for certain BDOS operations. The +format of the disk parameter header for each drive is shown +in Figure 6-2, where each element is a word (16-bit) value. +.mb 6 +.fm 2 +.sp 3 +.nf +XLT 0000 0000 0000 DIRBUF DPB CSV ALV +16b 16b 16b 16b 16b 16b 16b 16b +.fi +.sp 2 +.sh + Figure 6-2. Disk Parameter Header Format +.sp 2 +.pp +The meaning of each Disk Parameter Header (DPH) element is detailed in Table +6-7. +.sp 2 +.sh + Table 6-7. Disk Parameter Headers +.sp +.nf + Disk Parameter Meaning + Header +.fi +.ll 60 +.sp +.in 20 +.ti -14 +XLT Address of the logical-to-physical translation vector, if used +for this particular drive, or the value 0000H if no sector translation +takes place (that is, the physical and logical sector numbers are the same). +Disk drives with identical sector skew factors share the same translate tables. +.sp +.ti -14 +0000 Scratch pad values for use within the BDOS, initial value is +unimportant. +.sp +.ti -14 +DIRBUF Address of a 128-byte scratch pad area for directory operations +within BDOS. All DPHs address the same scratch pad area. +.sp +.ti -14 +DPB Address of a disk parameter block for this drive. Drives with +identical disk characteristics address the same disk parameter block. +.sp +.ti -14 +CSV Address of a scratch pad area used for software check for +changed disks. This address is different for each DPH. +.sp +.ti -14 +ALV Address of a scratch pad area used by the BDOS to keep disk +storage allocation information. This address is different for each DPH. +.fi +.in 0 +.ll 65 +.bp +.pp +Given n disk drives, the DPHs are arranged in a table whose first row of 16 +bytes corresponds to drive 0, with the last row corresponding to drive n-1. +In the following figure the lable DPBASE defines the base address of the DPH +table. +.sp 3 +.nf + DPBASE: +.sp + 00 XLT 00 0000 0000 0000 DIRBUF DBP 00 CSV 00 ALV 00 +.sp + 01 XLT 01 0000 0000 0000 DIRBUF DBP 01 CSV 01 ALV 01 + . + . + . + n-1 XLTn-1 0000 0000 0000 DIRBUF DBTn-1 CSVn-1 ALVn-1 +.fi +.sp 2 +.sh + Figure 6-3. Disk Parameter Header Table +.sp 2 +.pp +A responsibility of the SELDSK subroutine is to return the base address of +the DPH for the selected drive. The following sequence of operations returns +the table address, with a 0000H returned if the selected drive does not exist. +.sp 2 +.nf +.in 7 + NDISKS EQU 4 ;NUMBER OF DISK DRIVES + ..... + SELDSK: ;SELECT DISK GIVEN BY BC + LSI H,0000H ;ERROR CODE + MOV A,C ;DRIVE OK? + CPI NDISKS ;CY IF SO + RNC ;RET IF ERROR + ;NO ERROR, CONTINUE + MOV L,C ;LOW(DISK) + MOV H,B ;HIGH(DISK) + DAD H ;*2 + DAD H ;*4 + DAD H ;*8 + DAD H ;*16 + LXI D,DPBASE;FIRST DPH + DAD D ;DPH(DISK) + RET +.fi +.in 0 +.sp +.pp +The translation vectors, XLT 00 through XLTn-1, are located elsewhere in +the BIOS, and simply correspond one-for-one with the logical sector numbers +zero through the sector count 1. The Disk Parameter Block (DPB) for each +drive is more complex. As shown in Figure 6-4, particular DPB, that is +addressed by one or more DPHs, takes the general form: +.sp 3 +.nf + SPT BSH BLM EXM DSM DRM AL0 AL1 CKS 0FF + 16b 8b 8b 8b 16b 16b 8b 8b 16b 16b +.fi +.sp 2 +.sh + Figure 6-4. Disk Parameter Block Format +.sp 3 +where each is a byte or word value, as shown by the 8b or 16b indicator below +the field. +.pp +The following field abbreviations are used in Figure 6-4: +.sp 2 +.in 5 +.ti -2 +o SPT is the total number of sectors per track. +.sp +.ti -2 +o BSH is the data allocation block shift factor, determined by the data +block allocation size. +.sp +.ti -2 +o BLM is the data allocation block mask (2[BSH-1]). +.sp +.ti -2 +o EXM is the extent mask, determined by the data block allocation +size and the number of disk blocks. +.sp +.ti -2 +o DSM determines the total storage capacity of the disk drive. +.sp +.ti -2 +o DRM determines the total number of directory entries that can be +stored on this drive. AL0, AL1 determine reserved directory blocks. +.sp +.ti -2 +o CKS is the size of the directory check vector. +.sp +.ti -2 +o 0FF is the number of reserved tracks at the beginning of the +(logical) disk. +.fi +.in 0 +.sp +The values of BSH and BLM determine the data allocation size BLS, +which is not an entry in the DPB. Given that the designer has selected a +value for BLS, the values of BSH and BLM are shown Table 6-8. +.sp 2 +.sh + Table 6-8. BSH and BLM Values +.nf +.sp +.in 18 + BLS BSH BLM +.sp + 1024 3 7 + 2048 4 15 + 4096 5 31 + 8192 6 63 +16,384 7 127 +.fi +.in 0 +.sp 2 +where all values are in decimal. The value of EXM depends upon both the BLS +and whether the DSM value is less than 256 or greater than 255, as shown in +Table 6-9. +.bp +.sh + Table 6-9. EXM Values +.nf +.sp + BLS EXM values +.sp +.in 18 + DSM<256 DSM>255 +.sp + 1024 0 N/A + 2048 1 0 + 4096 3 1 + 8192 7 3 +16,384 15 7 +.fi +.in 0 +.sp +.pp +The value of DSM is the maximum data block number supported by this +particular drive, measured in BLS units. The product (DSM+1) is the +total number of bytes held by the drive and must be within the +capacity of the physical disk, not counting the reserved operating system +tracks. +.pp +The DRM entry is the one less than the total number of directory entries +that can take on a 16-bit value. The values of AL0 and AL1, however, are +determined by DRM. The values AL0 and AL1 can together be considered a +string of 16-bits, as shown in Figure 6-5. +.sp 3 +.nf + AL0 AL1 + + 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 +.fi +.sp 2 +.sh + Figure 6-5. AL0 and AL1 +.sp 2 +.pp +Position 00 corresponds to the high-order bit of the byte +labeled AL0 and 15 corresponds to the low-order bit of the byte +labeled AL1. Each bit position reserves a data block for number +of directory entries, thus allowing a total of 16 data blocks to +be assigned for directory entries (bits are assigned starting at +00 and filled to the right until position 15). Each directory +entry occupies 32 bytes, resulting in the following tabulation: +.sp 2 +.sh + Table 6-10. BLS Tabulation +.sp +.nf +.in 18 + BLS Directory Entries +.sp + 1024 32 times # bits + 2048 64 times # bits + 4096 128 times # bits + 8192 256 times # bits +16,384 512 times # bits +.fi +.in 0 +.bp +.pp +Thus, if DRM = 127 (128 directory entries) and BLS = 1024, there +are 32 directory entries per block, requiring 4 reserved blocks. +In this case, the 4 high-order bits of AL0 are set, resulting in +the values AL0 = 0F0H and AL1 = 00H. +.pp +The CKS value is determined as follows: if the disk drive media is +removable, then CKS = (DRM+1)/4, where DRM is the last directory +entry number. If the media are fixed, then set CKS = 0 (no +directory records are checked in this case). +.pp +Finally, the 0FF field determines the number of tracks that are +skipped at the beginning of the physical disk. This value is +automatically added whenever SETTRK is called and can be used as +a mechanism for skipping reserved operating system tracks or for +partitioning a large disk into smaller segmented sections. +.pp +To complete the discussion of the DPB, several DPHs can address +the same DPB if their drive characteristics are identical. +Further, the DPB can be dynamically changed when a new drive is +addressed by simply changing the pointer in the DPH; because the +BDOS copies the DPB values to a local area whenever the SELDSK +function is invoked. +.pp +Returning back to DPH for a particular drive, the two address +values CSV and ALV remain. Both addresses reference an area of +uninitialized memory following the BIOS. The areas must be +unique for each drive, and the size of each area is determined by +the values in the DPB. +.pp +The size of the area addressed by CSV is CKS bytes, which is +sufficient to hold the directory check information for this +particular drive, If CKS = (DRM+1)/4, you must reserve (DRM+1)/4 +bytes for directory check use. If CKS = 0, no storage is +reserved. +.pp +The size of the area addressed by ALV is determined by the +maximum number of data blocks allowed for this particular disk +and is computed as (DSM/8)+1. +.pp +The CBIOS shown in Appendix B demonstrates an instance of these +tables for standard 8-inch, single-density drives. It might be +useful to examine this program and compare the tabular values +with the definitions given above. +.sp 2 +.tc 6.11 The DISKDEF Macro Library +.he CP/M Operating System Manual 6.11 The DISKDEF Macro Library +.sh +6.11 The DISKDEF Macro Library +.qs +.pp +A macro library called DISKDEF (shown in Appendix F), greatly +simplifies the table construction process. You must have access +to the MAC macro assembler, of course, to use the DISKDEF +facility, while the macro library is included with all CP.M 2 +distribution disks. +.bp +.pp +A BIOS disk definition consists of the following sequence of +macro statements: +.sp +.nf +.in 7 + MACLIB DISKDEF + ..... + DISKS n + DISKDEF 0,... + DISKDEF 1,... + ..... + DISKDEF n-1 + ..... + ENDEF +.fi +.in 0 +.sp +where the MACLIB statement loads the DISKDEF.LIB file, on the +same disk as the BIOS, into MAC's internal tables. The DISKS +macro call follows, which specifies the number of drives to be +configured with the user's system, where n is an integer in the +range 1 to 16. A series of DISKDEF macro calls then follow that +define the characteristics of each logical disk, 0 through n-1, +corresponding to logical drives A through P. The DISKS and +DISKDEF macros generate the in-line fixed data tables described +in the previous section and thus must be placed in a +nonexecutable portion of the BIOS, typically directly following +the BIOS jump vector. +.pp +The remaining portion of the BIOS is defined following the +DISKDEF macros, with the ENDEF macro call immediately preceding +the END statement. The ENDEF (End of Diskdef) macro generates +the necessary uninitialized RAM areas that are located in +memory above the BIOS. +.pp +The DISKDEF macro call takes the form: +.sp +.ti 8 +DISKDEF dn,fsc,lsc,[skf],bls dks,dir,cks,ofs,[0] +.sp +where +.sp +.in 5 +.ti -2 +o dn is the logical disk number, 0 to n-1. +.ti -2 +o fsc is the first physical sector number (0 or 1). +.ti -2 +o lsc is the last sector number. +.ti -2 +o skf is the optional sector skew factor. +.ti -2 +o bls is the data allocation block size. +.ti -2 +o dks is the number of blocks on the disk. +.ti -2 +o dir is the number of directory entries. +.ti -2 +o cks is the number of checked directory entries. +.ti -2 +o ofs is the track offset to logical track 00. +.ti -2 +o [0] is an optional 1.4 compatibility flag. +.fi +.in 0 +.sp +.pp +The value dn is the drive number being defined with this DISKDEF +macro invocation. The fsc parameter accounts for differing +sector numbering systems and is usually 0 to 1. The lsc is the +last numbered sector on a track. When present, the skf parameter +defines the sector skew factor, which is used to create a sector +translation table according to the skew. +.pp +If the number of sectors is less than 256, a single-byte table is +created, otherwise each translation table element occupies two +bytes. No translation table is created if the skf parameter is +omitted, or equal to 0. +.pp +The bls parameter specifies the number of bytes allocated to each +data block, and takes on the values 1024, 2048, 4096, 8192, or +16384. Generally, performance increases with larger data block +sizes because there are fewer directory references, and logically +connected data records are physically close on the disk. +Further, each directory entry addresses more data and the BIOS-resident +RAM space is reduced. +.pp +The dks parameter specifies the total disk size in bls units. +That is, if the bls = 2048 and dks = 1000, the total disk +capacity is 2,048,000 bytes. If dks is greater than 255, the +block size parameter bls must be greater than 1024. The value of +dir is the total number of directory entries that might exceed +255, if desired. +.pp +The cks parameter determines the number of directory items to +check on each directory scan and is used internally to detect +changed disks during system operation, where an intervening cold +or warm start has not occurred. When this situation is detected, +CP/M automatically marks the disk Read-Only so that data is not +subsequently destroyed. +.pp +As stated in the previous section, the value of cks = dir when +the medium is easily changed, as is the case with a floppy disk +subsystem. If the disk is permanently mounted, the value of cks +is typically 0, because the probability of changing disks without a +restart is low. +.pp +The ofs value determines the number of tracks to skip when this +particular drive is addressed, which can be used to reserve +additional operating system space or to simulate several logical +drives on a single large capacity physical drive. +Finally, the [0] parameter is included when file compatibility is +required with versions of 1.4 that have been modified for higher +density disks. This parameter ensures that only 16K is allocated +for each directory record, as was the case for previous versions. +Normally, this parameter is not included. +.pp +For convenience and economy of table space, the special form: +.sp +.ti 8 +DISKDEF i,j +.sp +gives disk i the same characteristics as a previously defined +drive j. A standard four-drive, single-density system, which is +compatible with version 1.4, is defined using the following macro +invocations: +.sp +.nf +.in 7 + DISKS 4 + DISKDEF 0,1,26,6,1024,243,64,2 + DISKDEF 1,0 + DISKDEF 2,0 + DISKDEF 3,0 + .... + ENDEF +.fi +.in 0 +.sp +with all disks having the same parameter values of 26 sectors per +track, numbered 1 through 26, with 6 sectors skipped between each +access, 1024 bytes per data block, 243 data blocks for a total of +243K-byte disk capacity, 64 checked directory entries, and two +operating system tracks. +.pp +The DISKS macro generates n DPHs, starting at the DPH table +address DPBASE generated by the macro. Each disk header block +contains sixteen bytes, as described above, and correspond +one-for-one to each of the defined drives. In the four-drive +standard system, for example, the DISKS macro generates a table +of the form: +.sp +.nf +.in 5 +DPBASE EQU$ +DPE0: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV0,ALV0 +DPE1: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV1,ALV1 +DPE2: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV2,ALV2 +DPE3: DW XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV3,ALV3 +.fi +.in 0 +.sp +where the DPH labels are included for reference purposes to show +the beginning table addresses for each drive 0 through 3. The +values contained within the DPH are described in detail in the +previous section. The check and allocation vector addresses are +generated by the ENDEF macro in the ram area following the BIOS +code and tables. +.pp +Note that if the skf (skew factor) parameter is +omitted, or equal to 0, the translation table is omitted and a +0000H value is inserted in the XLT position of the DPH for the +disk. In a subsequent call to perform the logical-to-physical +translation, SECTRAN receives a translation table address of DE = +0000H and simply returns the original logical sector from BC in +the HL register pair. +.pp +A translate table is constructed when the skf parameter is +present, and the (nonzero) table address is placed into the +corresponding DPHs. The following for example, is constructed +when the standard skew factor skf = 6 is specified in the DISKDEF +macro call: +.sp +.nf +.in 8 +XLT0: DB 1,7,13,19,25,5,11,17,23,3,9,15,21 + DB 2,8,14,20,26,6,12,18,24,4,10,16,22 +.fi +.in 0 +.pp +Following the ENDEF macro call, a number of uninitialized data +areas are defined. These data areas need not be a part of the BIOS +that is loaded upon cold start, but must be available between the +BIOS and the end of memory. The size of the uninitialized RAM +area is determined by EQU statements generated by the ENDEF macro. +For a standard four-drive system, the ENDEF macro might produce +the following EQU statement: +.bp +.nf +.in 8 +4C72 = BEGDAT EQU $ + (data areas) +.sp +4DB0 = ENDDAT EQU $ +.sp +013C = DATSIZ EQU $-BEGDAT +.fi +.in 0 +.sp +which indicates that uninitialized RAM begins at location 4C72H, +ends at 4DB0H-1, and occupies 013CH bytes. You must ensure +that these addresses are free for use after the system is loaded. +.pp +After modification, you can use the STAT program to +check drive characteristics, because STAT uses the disk parameter +block to decode the drive information. A STAT command of the form: +.sp +.ti 8 +STAT d:DSK: +.sp +decodes the disk parameter block for drive d (d=A,...,P) and +displays the following values: +.sp 2 +.nf +.in 8 +r: 128-byte record capacity +k: kilobyte drive capacity +d: 32-byte directory entries +c: checked directory entries +e: records/extent +b: records/block +s: sectors/track +t: reserved tracks +.fi +.in 0 +.sp +.pp +Three examples of DISKDEF macro invocations are shown below with +corresponding STAT parameter values. The last example produces a full +8-megabyte system. +.sp +.nf +.in 8 + DISKDEF 0,1,58,,2048,256,128,128,2 +r=4096, k=512, d=128, c=128, e=256, b=16, s=58, t=2 +.sp + DISKDEF 0,1,58,,2048,1024,300,0,2 +r=16348, k=2048, d=300, c=0, e=128, b=16, s=58, t=2 +.sp + DISKDEF 0,1,58,,16348,512,128,128,2 +r=65536, k=8192, d=128, c=128, e=1024, b=128, s=58, t=2 +.fi +.in 0 +.sp 2 +.tc 6.12 Sector Blocking and Deblocking +.he CP/M Operating System Manual 6.12 Blocking and Deblocking +.sh +6.12 Sector Blocking and Deblocking +.qs +.pp +Upon each call to BIOS WRITE entry point, the CP/M BDOS includes +information that allows effective sector blocking and deblocking +where the host disk subsystem has a sector size that is a +multiple of the basic 128-byte unit. The purpose here is to +present a general-purpose algorithm that can be included within +the BIOS and that uses the BDOS information to perform the +operations automatically. +.pp +On each call to WRITE, the BDOS provides the following +information in register C: +.sp +.nf +.in 8 +0 = (normal sector write) +1 = (write to directory sector) +2 = (write to the first sector + of a new data block) +.fi +.in 0 +.pp +Condition 0 occurs whenever the next write operation is into a +previously written area, such as a random mode record update; +when the write is to other than the first sector of an +unallocated block; or when the write is not into the directory +area. Condition 1 occurs when a write into the directory area is +performed. Condition 2 occurs when the first record (only) of a +newly allocated data block is written. In most cases, +application programs read or write multiple 128-byte sectors in +sequence; thus, there is little overhead involved in either +operation when blocking and deblocking records, because preread +operations can be avoided when writing records. +.pp +Appendix G lists the blocking and deblocking algorithms in +skeletal form; this file is included on your CP/M disk. +Generally, the algorithms map all CP/M sector read operations +onto the host disk through an intermediate buffer that is the +size of the host disk sector. Throughout the program, values and +variables that relate to the CP/M sector involved in a seek +operation are prefixed by sek, while those related to the host +disk system are prefixed by hst. The equate statements beginning +on line 29 of Appendix G define the mapping between CP/M and the +host system, and must be changed if other than the sample host +system is involved. +.pp +The entry points BOOT and WBOOT must contain the initialization +code starting on line 57, while the SELDSK entry point must be +augmented by the code starting on line 65. Note that although +the SELDSK entry point computes and returns the Disk Parameter +Header address, it does not physically select the host disk at +this point (it is selected later at READHST or WRITEHST). +Further, SETTRK, SETTRK, and SETMA simply store the values, but +do not take any other action at this point. SECTRAN performs a +trivial function of returning the physical sector number. +.pp +The principal entry points are READ and WRITE, starting on lines +110 and 125, respectively. These subroutines take the place of +your previous READ and WRITE operations. +.pp +The actual physical read or write takes place at either WRITEHST +or READHST, where all values have been prepared: hstdsk is the +host disk number, hsttrk is the host track number, and +hstsec is the host sector number, which +may require translation to physical sector number. You must +insert code at this point that performs the full sector read or write +into or out of the buffer at hstbuf of length hstsiz. All other mapping +functions are performed by the algorithms. +.pp +This particular algorithm was tested using an 80-megabyte hard +disk unit that was originally configured for 128-byte sectors, +producing approximately 35 megabytes of formatted storage. When +configured for 512-byte host sectors, usable storage increased to +57 megabytes, with a corresponding 400% improvement in overall +response. In this situation, there is no apparent overhead +involved in deblocking sectors, with the advantage that user +programs still maintain 128-byte sectors. This is primarily +because of the information provided by the BDOS, which eliminates +the necessity for preread operations. +.sp 2 +.ce +End of Section 6 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/test.tex b/Source/Doc/CPM 22 Manual/test.tex new file mode 100644 index 00000000..02ae661e --- /dev/null +++ b/Source/Doc/CPM 22 Manual/test.tex @@ -0,0 +1,447 @@ +.op +.sp 15 +.ce 100 +.bo 5 +CP/M +.sp +.sh +Operating System +.sp +.sh +Manual +.cs 5 +.sp 10 +Copyright (c) 1982 +.sp +Digital Research +P.O. Box 579 +160 Central Avenue +Pacific Grove, CA 93950 +(408) 649-3896 +TWX 910 360 5001 +.sp 4 +All Rights Reserved +.ce 0 +.bp +.po 17 +.ll 50 +.ce +COPYRIGHT +.sp +Copyright (c) 1976, 1977, 1978, 1979, 1982, 1983, and 1984 by +Digital Research Inc. All rights reserved. No part of this +publication may be reproduced, transmitted, transcribed, stored +in a retrieval system, or translated into any language or +computer language, in any form or by any means, electronic, mechanical, +magnetic, optical, chemical, manual or otherwise, without the prior +written permission of Digital Research Inc., Post Office Box 579, +Pacific Grove, California, 93950. +.sp +Thus, readers are granted permission to include the example +programs, either in whole or in part, in their own programs. +.sp 2 +.ce +DISCLAIMER +.sp +Digital Research Inc. makes no representations or warranties with +respect to the contents hereof and specifically disclaims +any implied warranties of merchantability or fitness for +any particular purpose. Further, Digital Research Inc. reserves the +right to revise this publication and to make changes from +time to time in the content hereof without obligation of +Digital Research Inc. to notify any person of such revision or +changes. +.sp 2 +.ce +TRADEMARKS +.sp +CP/M, CP/NET, and Digital Research and its logo are registered +trademarks of Digital Research. ASM, DESPOOL, DDT, LINK-80, MAC, +MP/M, PL/I-80 and SID are trademarks of Digital Research. IBM is +a registered trademark of International Business Machines. Intel +is a registered trademark of Intel Corporation. TI Silent 700 is +a trademark of Texas Instruments Incorporated. Zilog and Z80 are +registered trademarks of Zilog, Inc. +.mb 4 +.fm 1 +.sp 3 +The \c +.ul +CP/M Operating System Manual \c +.qu +was prepared using the Digital Research TEX Text Formatter and printed +in the United States of America. +.sp 2 +.ce 6 +********************************* +* First Edition: 1976 * +* Second Edition: July 1982 * +* Third Edition: March 1983 * +* Fourth Edition: March 1984 * +********************************* +.po 10 +.ll 65 +.in 0 +.bp +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft iii +.bp +.ce +.sh +Table of Contents +.sp 3 +.nf +.sh +1 CP/M Features and Facilities +.sp + 1.1 Introduction . . . . . . . . . . . . . . . . . . . 1-1 +.sp + 1.2 Functional Description . . . . . . . . . . . . . . 1-3 +.sp + 1.2.1 General Command Structure . . . . . . . . . 1-3 + 1.2.2 File References . . . . . . . . . . . . . . 1-3 +.sp + 1.3 Switching Disks . . . . . . . . . . . . . . . . . . 1-5 + 1.4 Built-in Commands . . . . . . . . . . . . . . . . . 1-6 +.sp + 1.4.1 ERA Command . . . . . . . . . . . . . . . . 1-6 + 1.4.2 DIR Command . . . . . . . . . . . . . . . . 1-7 + 1.4.3 REN Command . . . . . . . . . . . . . . . . 1-8 + 1.4.4 SAVE Command . . . . . . . . . . . . . . . . 1-8 + 1.4.5 TYPE Command . . . . . . . . . . . . . . . . 1-9 + 1.4.6 USER Command . . . . . . . . . . . . . . . . 1-9 +.sp + 1.5 Line Editing and Output Control . . . . . . . . . . 1-10 +.sp + 1.6 Transient Commands . . . . . . . . . . . . . . . . 1-11 +.sp + 1.6.1 STAT Command . . . . . . . . . . . . . . . . 1-12 + 1.6.2 ASM Command . . . . . . . . . . . . . . . . 1-18 + 1.6.3 LOAD Command . . . . . . . . . . . . . . . . 1-19 + 1.6.4 PIP . . . . . . . . . . . . . . . . . . . . 1-20 + 1.6.5 ED Command . . . . . . . . . . . . . . . . . 1-29 + 1.6.6 SYSGEN Command . . . . . . . . . . . . . . . 1-31 + 1.6.7 SUBMIT Command . . . . . . . . . . . . . . . 1-33 + 1.6.8 DUMP Command . . . . . . . . . . . . . . . . 1-35 + 1.6.9 MOVCPM Command . . . . . . . . . . . . . . . 1-35 +.sp + 1.7 BDOS Error Messages . . . . . . . . . . . . . . . . 1-37 +.sp + 1.8 CP/M Operation on the Model 800 . . . . . . . . . . 1-38 +.sp 2 +.sh +2 The CP/M Editor +.sp + 2.1 Introduction to ED . . . . . . . . . . . . . . . . 2-1 +.sp + 2.1.1 ED Operation . . . . . . . . . . . . . . . . 2-1 + 2.1.2 Text Transfer Functions . . . . . . . . . . 2-3 + 2.1.3 Memory Buffer Organization . . . . . . . . . 2-4 + 2.1.4 Line Numbers and ED Start-up . . . . . . . . 2-5 + 2.1.5 Memory Buffer Operation . . . . . . . . . . 2-6 + 2.1.6 Command Strings . . . . . . . . . . . . . . 2-7 + 2.1.7 Text Search and Alteration . . . . . . . . . 2-10 + 2.1.8 Source Libraries . . . . . . . . . . . . . . 2-13 + 2.1.9 Repetitive Command Execution . . . . . . . . 2-14 +.bp +.ft iv +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 + 2.2 ED Error Conditions . . . . . . . . . . . . . . . . 2-14 +.sp + 2.3 Control Characters and Commands . . . . . . . . . . 2-16 +.sp 2 +.sh +3 CP/M Assembler +.qs +.sp + 3.1 Introduction . . . . . . . . . . . . . . . . . . . 3-1 +.sp + 3.2 Program Format . . . . . . . . . . . . . . . . . . 3-3 +.sp + 3.3 Forming the Operand . . . . . . . . . . . . . . . . 3-4 +.sp + 3.3.1 Labels . . . . . . . . . . . . . . . . . . . 3-4 + 3.3.2 Numeric Constants . . . . . . . . . . . . . 3-5 + 3.3.3 Reserved Words . . . . . . . . . . . . . . . 3-5 + 3.3.4 String Constants . . . . . . . . . . . . . . 3-6 + 3.3.5 Arithmetic and Logical Operators . . . . . . 3-7 + 3.3.6 Precedence of Operators . . . . . . . . . . 3-8 +.sp + 3.4 Assembler Directives . . . . . . . . . . . . . . . 3-9 +.sp + 3.4.1 The ORG Directive . . . . . . . . . . . . . 3-10 + 3.4.2 The END Directive . . . . . . . . . . . . . 3-10 + 3.4.3 The EQU Directive . . . . . . . . . . . . . 3-11 + 3.4.4 The SET Directive . . . . . . . . . . . . . 3-11 + 3.4.5 The IF and ENDIF Directives . . . . . . . . 3-12 + 3.4.6 The DB Directive . . . . . . . . . . . . . . 3-13 + 3.4.7 The DW Directive . . . . . . . . . . . . . . 3-14 + 3.4.8 The DS Directive . . . . . . . . . . . . . . 3-14 +.sp + 3.5 Operation Codes . . . . . . . . . . . . . . . . . . 3-15 +.sp + 3.5.1 Jumps, Calls, and Returns . . . . . . . . . 3-15 + 3.5.2 Immediate Operand Instructions . . . . . . . 3-17 + 3.5.3 Increment and Decrement Instructions . . . . 3-17 + 3.5.4 Data Movement Instructions . . . . . . . . . 3-18 + 3.5.5 Arithmetic Logic Unit Operations . . . . . . 3-19 + 3.5.6 Control Instructions . . . . . . . . . . . . 3-21 +.sp + 3.6 Error Messages . . . . . . . . . . . . . . . . . . 3-21 +.sp + 3.7 A Sample Session . . . . . . . . . . . . . . . . . 3-23 +.bp +.ft v +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 +.sh +4 CP/M Dynamic Debugging Tool +.qs +.sp + 4.1 Introduction . . . . . . . . . . . . . . . . . . . 4-1 +.sp + 4.2 DDT Commands . . . . . . . . . . . . . . . . . . . 4-3 +.sp + 4.2.1 The A (Assembly) Command . . . . . . . . . . 4-3 + 4.2.2 The D (Display) Command . . . . . . . . . . 4-4 + 4.2.3 The F (Fill) Command . . . . . . . . . . . . 4-5 + 4.2.4 The G (Go) Command . . . . . . . . . . . . . 4-5 + 4.2.5 The I (Input) Command . . . . . . . . . . . 4-6 + 4.2.6 The L (List) Command . . . . . . . . . . . . 4-6 + 4.2.7 The M (Move) Command . . . . . . . . . . . . 4-7 + 4.2.8 The R (Read) Command . . . . . . . . . . . . 4-7 + 4.2.9 The S (Set) Command . . . . . . . . . . . . 4-8 + 4.2.1- The T (Trace) Command . . . . . . . . . . . 4-8 + 4.2.11 The U (Untrace) Command . . . . . . . . . . 4-9 + 4.2.12 The X (Examine) Command . . . . . . . . . . 4-9 +.sp + 4.3 Implementation Notes . . . . . . . . . . . . . . . 4-10 +.sp + 4.4 A Sample Program . . . . . . . . . . . . . . . . . 4-11 +.sp 2 +.sh +5 CP/M 2 System Interface +.qs +.sp + 5.1 Introduction . . . . . . . . . . . . . . . . . . . 5-1 +.sp + 5.2 Operating System Call Conventions . . . . . . . . . 5-3 +.sp + 5.3 A Sample File-to-File Copy Program . . . . . . . . 5-35 +.sp + 5.4 A Sample File Dump Utility . . . . . . . . . . . . 5-38 +.sp + 5.5 A Sample Random Access Program . . . . . . . . . . 5-42 +.sp + 5.6 System Function Summary . . . . . . . . . . . . . . 5-50 +.sp 2 +.sh +6 CP/M 2 Alteration +.qs +.sp + 6.1 Introduction . . . . . . . . . . . . . . . . . . . 6-1 +.sp + 6.2 First-level System Regeneration . . . . . . . . . . 6-2 +.sp + 6.3 Second-level System Generation . . . . . . . . . . 6-5 +.sp + 6.4 Sample GETSYS and PUTSYS Programs . . . . . . . . . 6-9 +.bp +.ft vi +.ce +.sh +Table of Contents +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 + 6.5 Disk Organization . . . . . . . . . . . . . . . . . 6-11 +.sp + 6.6 The BIOS Entry Points . . . . . . . . . . . . . . . 6-13 +.sp + 6.7 A Sample BIOS . . . . . . . . . . . . . . . . . . . 6-21 +.sp + 6.8 A Sample Cold Start Loader . . . . . . . . . . . . 6-21 +.sp + 6.9 Reserved Locations in Page Zero . . . . . . . . . . 6-22 +.sp + 6.10 Disk Parameter Tables . . . . . . . . . . . . . . 6-23 +.sp + 6.11 The DISKDEF Macro Library . . . . . . . . . . . . 6-28 +.sp + 6.12 Sector Blocking and Deblocking . . . . . . . . . . 6-32 +.bp +.ft vii +.ce +.sh +Appendixes +.qs +.sp 3 +.sh +A \c +.qs +Basic Input/Output System (BIOS) . . . . . . . . . . . A-1 +.sp 2 +.sh +B \c +.qs +A Skeletal CBIOS . . . . . . . . . . . . . . . . . . . B-1 +.sp 2 +.sh +C \c +.qs +A Skeletal GETSYS/PUTSYS Program . . . . . . . . . . . C-1 +.sp 2 +.sh +D \c +.qs +The Model 800 Cold Start Loader for CP/M 2 . . . . . . D-1 +.sp 2 +.sh +E \c +.qs +A Skeletal Cold Start Loader . . . . . . . . . . . . . E-1 +.sp 2 +.sh +F \c +.qs +CP/M Disk Definition Library . . . . . . . . . . . . . F-1 +.sp 2 +.sh +G \c +.qs +Blocking and Deblocking Algorithms . . . . . . . . . . G-1 +.sp 2 +.sh +H \c +.qs +Glossary . . . . . . . . . . . . . . . . . . . . . . . H-1 +.sp 2 +.sh +I \c +.qs +CP/M Error Messages . . . . . . . . . . . . . . . . . . I-1 +.bp +.ft viii +.ce +.sh +Tables, Figures, and Listings +.qs +.sp 3 +.sh +Tables +.qs +.sp + 1-1. Line-editing Control Characters . . . . . . . . 1-10 + 1-2. CP/M Transient Commands . . . . . . . . . . . . 1-11 + 1-3. Physical Devices . . . . . . . . . . . . . . . 1-14 + 1-4. PIP Parameters . . . . . . . . . . . . . . . . 1-24 +.sp + 2-1. ED Text Transfer Commands . . . . . . . . . . . 2-3 + 2-2. Editing Commands . . . . . . . . . . . . . . . 2-6 + 2-3. Line-editing Controls . . . . . . . . . . . . . 2-7 + 2-4. Error Message Symbols . . . . . . . . . . . . . 2-13 + 2-5. ED Control Characters . . . . . . . . . . . . . 2-14 + 2-6. ED Commands . . . . . . . . . . . . . . . . . . 2-15 +.sp + 3-1. Reserved Characters . . . . . . . . . . . . . . 3-6 + 3-2. Arithmetic and Logical Operators . . . . . . . 3-7 + 3-3. Assembler Directives . . . . . . . . . . . . . 3-9 + 3-4. Jumps, Calls, and Returns . . . . . . . . . . . 3-15 + 3-5. Immediate Operand Instructions . . . . . . . . 3-16 + 3-6. Increment and Decrement Instructions . . . . . 3-17 + 3-7. Data Movement Instructions . . . . . . . . . . 3-17 + 3-8. Arithmetic Logic Unit Operations . . . . . . . 3-18 + 3-9. Error Codes . . . . . . . . . . . . . . . . . . 3-20 + 3-10. Error Messages . . . . . . . . . . . . . . . . 3-21 +.sp + 4-1. Line-editing Controls . . . . . . . . . . . . . 4-2 + 4-2. DDT Commands . . . . . . . . . . . . . . . . . 4-2 + 4-3. CPU Registers . . . . . . . . . . . . . . . . . 4-9 +.sp + 5-1. CP/M Filetypes . . . . . . . . . . . . . . . . 5-6 + 5-2. File Control Block Fields . . . . . . . . . . . 5-7 + 5-3. Edit Control Characters . . . . . . . . . . . . 5-20 +.sp + 6-1. Standard Memory Size Values . . . . . . . . . . 6-2 + 6-2. Common Values for CP/M Systems . . . . . . . . 6-7 + 6-3. CP/M Disk Sector Allocation . . . . . . . . . . 6-11 + 6-4. IOBYTE Field Values . . . . . . . . . . . . . . 6-15 + 6-5. BIOS Entry Points . . . . . . . . . . . . . . . 6-16 + 6-6. Reserved Locations in Page Zero . . . . . . . . 6-21 + 6-7. Disk Parameter Headers . . . . . . . . . . . . 6-23 + 6-8. BSH and BLM Values . . . . . . . . . . . . . . 6-25 + 6-9. EXM Values . . . . . . . . . . . . . . . . . . 6-25 + 6-10. BLS Tabluation . . . . . . . . . . . . . . . . 6-26 +.sp + I-1. CP/M Error Messages . . . . . . . . . . . . . . I-1 +.sp 2 +.sh +Figures +.qs +.sp + 2-1. Overall ED Operation . . . . . . . . . . . . . 2-2 + 2-2. Memory Buffer Organization . . . . . . . . . . 2-2 +.bp +.ft ix +.ce +.sh +Tables, Figures, and Listings +.qs +.sp +.ce +.sh +(continued) +.qs +.sp 3 +.sh +Figures +.qs +.sp + 2-3. Logical Organization of Memory Buffer . . . . . 2-4 +.sp + 5-1. CP/M Memory Organization . . . . . . . . . . . 5-1 + 5-2. File Control Block Format . . . . . . . . . . . 5-7 +.sp + 6-1. IOBYTE Fields . . . . . . . . . . . . . . . . . 6-15 + 6-2. Disk Parameter Header Format . . . . . . . . . 6-22 + 6-3. Disk Parameter Header Table . . . . . . . . . . 6-23 + 6-4. Disk Parameter Block Format . . . . . . . . . . 6-24 + 6-5. AL0 and AL1 . . . . . . . . . . . . . . . . . . 6-25 +.sp 2 +.sh +Listings +.qs +.sp + 6-1. GETSYS Program . . . . . . . . . . . . . . . . 6-9 + 6-2. BIOS Entry Points . . . . . . . . . . . . . . . 6-13 +.nx onea + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/threea.tex b/Source/Doc/CPM 22 Manual/threea.tex new file mode 100644 index 00000000..1a5c666c --- /dev/null +++ b/Source/Doc/CPM 22 Manual/threea.tex @@ -0,0 +1,938 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 3-% +.pc 1 +.tc 3 CP/M Assembler +.ce 2 +.sh +Section 3 +.sp +.sh +CP/M Assembler +.qs +.sp 3 +.tc 3.1 Introduction +.he CP/M Operating System Manual 3.1 Introduction +.sh +3.1 Introduction +.qs +.pp 5 +The CP/M assembler reads assembly-language source files from the +disk and produces 8080 machine language in Intel hex format. +To start the CP/M assembler, type a command in one of the +following forms: +.sp +.nf +.in 8 +ASM filename +ASM filename.parms +.fi +.in 0 +.sp +In both cases, the assembler assumes there is a file on the +disk with the name: +.sp +.ti 8 +filename.ASM +.sp +which contains an 8080 assembly-language source file. The first +and second forms shown above differ only in that the second form +allows parameters to be passed to the assembler to control source +file access and hex and print file destinations. +.pp +In either case, the CP/M assembler loads and prints the message: +.sp +.ti 8 +CP/M ASSEMBLER VER n.n +.sp +where n.n is the current version number. In the case of the +first command, the assembler reads the source file with assumed +filetype ASM and creates two output files +.sp +.in 8 +.nf +filename.HEX +filename.PRN +.fi +.in 0 +.pp +The HEX file contains the machine code corresponding to the +original program in Intel hex format, and the PRN file contains +an annotated listing showing generated machine code, error flags, +and source lines. If errors occur during translation, they are +listed in the PRN file and at the console. +.pp +The form ASM filename parms is used to redirect input and +output files from their defaults. In this case, the parms +portion of the command is a three-letter group that specifies the +origin of the source file, the destination of the hex file, and +the destination of the print file. The form is +.bp +.ti 8 +filename.p1p2p3 +.sp +where p1, p2, and p3 are single letters. P1 can be +.sp +.ti 8 +A,B, ...,P +.sp +which designates the disk name that contains the source file. P2 +can be +.sp +.ti 8 +A,B, ...,P +.sp +which designates the disk name that will receive the hex file; or, P2 +can be +.sp +.ti 8 +Z +.sp +which skips the generation of the hex file. +.pp +P3 can be +.sp +.ti 8 +A,B, ...,P +.sp +which designates the disk name that will receive the +print file. P3 can also be specified as +.sp +.ti 8 +X +.sp +which places the listing at the console; or +.sp +.ti 8 +Z +.sp +which skips generation of the print file. Thus, the command +.sp +.ti 8 +ASM X.AAA +.sp +indicates that the source, X.HEX, and print, X.PRN, files +are also to be created on disk A. This form of the command is +implied if the assembler is run from disk A. Given that you are +currently addressing disk A, the above command is the same as +.sp +.ti 8 +ASM X +.sp +The command +.sp +.ti 8 +ASM X.ABX +.sp +indicates that the source file is to be taken from disk A, the +hex file is to be placed on disk B, and the listing file is to be +sent to the console. The command +.sp +.ti 8 +ASM X.BZZ +.sp +takes the source file from disk B and skips the generation of the +hex and print files. This command is useful for fast execution of +the assembler to check program syntax. +.bp +.pp +The source program format is compatible with the Intel 8080 +assembler. Macros are not implemented in ASM; see the optional +MAC macro assembler. There are certain extensions in the CP/M +assembler that make it somewhat easier to use. These extensions +are described below. +.sp 2 +.tc 3.2 Program Format +.he CP/M Operating System Manual 3.2 Program Format +.sh +3.2 Program Format +.qs +.pp +An assembly-language program acceptable as input to the assembler +consists of a sequence of statements of the form +.sp +.ti 8 +line# label operation operand ;comment +.sp +where any or all of the fields may be present in a particular +instance. Each assembly-language statement is terminated with a +carriage return and line-feed (the line-feed is inserted +automatically by the ED program), or with the character !, which +is treated as an end-of-line by the assembler. Thus, multiple +assembly-language statements can be written on the same physical +line if separated by exclamation point symbols. +.pp +The line# is an optional decimal integer value representing the +source program line number, and ASM ignores this field if +present. +.pp +The label field takes either of the following forms: +.sp +.in 8 +.nf +identifier +identifier: +.fi +.in 0 +.sp +The label field is optional, except where noted in particular statement +types. The identifier is a sequence of alphanumeric characters +where the first character is alphabetic. Identifiers can be +freely used by the programmer to label elements such as program +steps and assembler directives, but cannot exceed 16 characters +in length. All characters are significant in an identifier, +except for the embedded dollar symbol $, which can be used to +improve readability of the name. Further, all lower-case +alphabetics are treated as upper-case. The +following are all valid instances of labels: +.sp 2 +.nf +.in 8 +x xy long$name + +x: yxl: longer$named$data: + +X1Y2 X1x2 x234$5678$9012$3456: +.fi +.in 0 +.sp +.pp +The operation field contains either an assembler directive or +pseudo operation, or an 8080 machine operation code. The pseudo +operations and machine operation codes are described in Section +3.3. +.pp +Generally, the operand field of the statement contains an +expression formed out of constants and labels, along with +arithmetic and logical operations on these elements. Again, the +complete details of properly formed expressions are given in +Section 3.3. +.pp +The comment field contains arbitrary characters following the +semicolon +symbol until the next real or logical end-of-line. These +characters are read, listed, and otherwise ignored by the +assembler. The CP/M assembler also treats statements that begin +with an * in column one as comment statements that are listed +and ignored in the assembly process. +.pp +The assembly-language program is formulated as a sequence of +statements of the above form, terminated by an optional END +statement. All statements following the END are ignored by the +assembler. +.sp 2 +.tc 3.3 Forming the Operand +.he CP/M Operating System Manual 3.3 Forming the Operand +.sh +3.3 Forming the Operand +.qs +.pp +To describe the operation codes and pseudo operations completely, +it is necessary first to present the form of the operand field, +since it is used in nearly all statements. Expressions in the +operand field consist of simple operands, labels, constants, and +reserved words, combined in properly formed subexpressions by +arithmetic and logical operators. The expression computation is +carried out by the assembler as the assembly proceeds. Each +expression must produce a 16-bit value during the assembly. +Further, the number of significant digits in the result must not +exceed the intended use. If an expression is to be used +in a byte move immediate instruction, the most significant 8 bits +of the expression must be zero. The restriction on the +expression significance is given with the individual +instructions. +.sp 2 +.tc 3.3.1 Labels +.sh +3.3.1 Labels +.qs +.pp +As discussed above, a label is an identifier that occurs on a +particular statement. In general, the label is given a value +determined by the type of statement that it precedes. If the +label occurs on a statement that generates machine code or +reserves memory space (for example, a MOV instruction or a +DS pseudo operation), the label is given the value of the program address +that it labels. If the label precedes an EQU or SET, the label +is given the value that results from evaluating the operand +field. Except for the SET statement, an identifier can label +only one statement. +.pp +When a label appears in the operand field, its value is +substituted by the assembler. This value can then be combined +with other operands and operators to form the operand field for a +particular instruction. +.bp +.tc 3.3.2 Numeric Constants +.sh +3.3.2 Numeric Constants +.qs +.pp +A numeric constant is a 16-bit value in one of several bases. +The base, called the radix of the constant, is denoted by a +trailing radix indicator. The following are radix indicators: +.sp +.in 3 +.nf +o B is a binary constant (base 2). +o O is a octal constant (base 8). +o Q is a octal constant (base 8). +o D is a decimal constant (base 10). +o H is a hexadecimal constant (base 16). +.fi +.in 0 +.pp +Q is an alternate radix indicator for octal numbers because the +letter O is easily confused with the digit 0. Any numeric +constant that does not terminate with a radix indicator is +a decimal constant. +.pp +A constant is composed as a sequence of digits, followed by +an optional radix indicator, where the digits are in the +appropriate range for the radix. Binary constants must +be composed of 0 and 1 digits, octal constants can contain digits +in the range 0-7, while decimal constants contain decimal digits. +Hexadecimal constants contain decimal digits as well as +hexadecimal digits A(10D), B(11D), C(12D), D(13D), E(14D), and +F(15D). Note that the leading digit of a +hexadecimal constant must be a decimal digit to avoid confusing a +hexadecimal constant with an identifier. A leading 0 will always +suffice. A constant composed in this manner must evaluate to a +binary number that can be contained within a 16-bit counter, +otherwise it is truncated on the right by the assembler. +.pp +Similar +to identifiers, embedded $ signs are allowed within constants to +improve their readability. Finally, the radix indicator is +translated to upper-case if a lower-case letter is encountered. +The following are all valid instances of numeric constants: +.sp 2 +.nf +.in 8 +1234 1234D 1100B 1111$0000$1111$0000B +.sp +1234H OFFEH 3377O 33$77$22Q +.sp +3377o Ofe3h 1234d Offffh +.fi +.in 0 +.sp 2 +.tc 3.3.3 Reserved Words +.sh +3.3.3 Reserved Words +.qs +.pp +There are several reserved character sequences that have +predefined meanings in the operand field of a statement. The +names of 8080 registers are given below. When they are +encountered, they produce the values shown to the right. +.bp +.nf +.sh + Table 3-1. Reserved Characters +.sp + Character Value + + A 7 + B 0 + C 1 + D 2 + E 3 + H 4 + L 5 + M 6 + SP 6 + PSW 6 +.fi +.in 0 +.sp +.pp +Again, lower-case names have the same values as their upper-case +equivalents. Machine instructions can also be used in the +operand field; they evaluate to their internal codes. In the case +of instructions that require operands, where the specific operand +becomes a part of the binary bit pattern of the instruction, +for example, MOV A,B, the value of the instruction, in this case MOV, +is the bit pattern of the instruction with zeros in the optional +fields, for example, MOV produces 40H. +.pp +When the symbol $ occurs in the operand field, not embedded +within identifiers and numeric constants, its value becomes the +address of the next instruction to generate, not including the +instruction contained within the current logical line. +.sp 2 +.tc 3.3.4 String Constants +.sh +3.3.4 String Constants +.qs +.pp +String constants represent sequences of ASCII characters and are +represented by enclosing the characters within apostrophe symbols. +All strings must be fully contained within the current +physical line (thus allowing exclamation point symbols within +strings) and must +not exceed 64 characters in length. The apostrophe character +itself can be included within a string by representing it as a +double apostrophe (the two keystrokes ''), which becomes a single +apostrophe when read by the assembler. In most cases, the string +length is restricted to either one or two characters (the DB +pseudo operation is an exception), in which case the string +becomes an 8- or 16-bit value, respectively. Two-character +strings become a 16-bit constant, with the second character as +the low-order byte, and the first character as the high-order +byte. +.pp +The value of a character is its corresponding ASCII code. There +is no case translation within strings; both upper- and +lower-case characters can be represented. You should note +that only graphic printing ASCII characters are +allowed within strings. +.bp +.nf + Valid strings: How assembler reads strings: + + 'A' 'AB' 'ab' 'c' A AB ab c + '' 'a''' '''' '''' a' ' ' + 'Walla Walla Wash.' Walla Walla Wash. + 'She said ''Hello'' to me.' She said ''Hello'' to me + 'I said ''Hello'' to her.' I said ''Hello'' to her +.fi +.sp 2 +.tc 3.3.5 Arithmetic and Logical Operators +.sh +3.3.5 Arithmetic and Logical Operators +.qs +.pp +The operands described in Section 3.3 can be combined in normal algebraic +notation using any combination of properly formed operands, +operators, and parenthesized expressions. The operators +recognized in the operand field are described in Table 3-2. +.sp 2 +.ce +.sh +Table 3-2. Arithmetic and Logical Operators +.ll 60 +.in 5 +.sp +.nf +Operators Meaning +.sp +.fi +.in 19 +.ti -13 +a + b unsigned arithmetic sum of a and b +.sp +.ti -13 +a - b unsigned arithmetic difference between a and b +.sp +.ti -13 + + b unary plus (produces b) +.sp +.ti -13 + - b unary minus (identical to 0 - b) +.sp +.ti -13 +a * b unsigned magnitude multiplication of a and b +.sp +.ti -13 +a / b unsigned magnitude division of a by b +.sp +.ti -13 +a MOD b remainder after a / b. +.sp +.ti -13 +NOT b logical inverse of b (all 0s become 1s, 1s become +0s), where b is considered a 16-bit value +.sp +.ti -13 +a AND b bit-by-bit logical and of a and b +.sp +.ti -13 +a OR b bit-by-bit logical or of a and b +.sp +.ti -13 +a XOR b bit-by-bit logical exclusive or of a and b +.sp +.ti -13 +a SHL b the value that results from shifting a to the left +by an amount b, with zero fill +.sp +.ti -13 +a SHR b the value that results from shifting a to the +right by an amount b, with zero fill +.in 0 +.ll 65 +.sp +.pp +In each case, a and b represent simple operands (labels, numeric +constants, reserved words, and one- or two-character strings) or +fully enclosed parenthesized subexpressions, like those shown in +the following examples: +.sp 2 +.nf +.in 8 +10+20 10h+37Q LI/3 (L2+4) SHR 3 + +('a' and 5fh) + '0' ('B'+B) OR (PSW+M) + +(1+(2+c)) shr (A-(B+1)) +.fi +.in 0 +.sp +.pp +Note that all computations are performed at assembly time as 16-bit +unsigned operations. Thus, -1 is computed as 0-1, which +results in the value 0ffffh (that is, all 1s). The resulting +expression must fit the operation code in which it is used. For +example, if the expression is used in an ADI (add immediate) +instruction, the high-order 8 bits of the expression must be +zero. As a result, the operation ADI-1 produces an error message +(-1 becomes 0ffffh, which cannot be represented as an 8-bit +value), while ADI(-1) AND 0FFH is accepted by the assembler +because the AND operation zeros the high-order bits of the +expression. +.sp 2 +.tc 3.3.6 Precedence of Operators +.sh +3.3.6 Precedence of Operators +.qs +.pp +As a convenience to the programmer, ASM assumes that operators +have a relative precedence of application that allows the +programmer to write expressions without nested levels of +parentheses. The resulting expression has assumed parentheses +that are defined by the relative precedence. The order of +application of operators in unparenthesized expressions is listed +below. Operators listed first have highest precedence (they are +applied first in an unparenthesized expression), while operators +listed last have lowest precedence. Operators listed on the same +line have equal precedence, and are applied from left to right as +they are encountered in an expression. +.sp 2 +.in 8 +.mb 5 +.fm 1 +.nf +* / MOD SHL SHR + +- + + +NOT + +AND + +OR XOR +.fi +.in 0 +.sp +.pp +Thus, the expressions shown to the left below are interpreted by +the assembler as the fully parenthesized expressions shown to the +right. +.bp +.nf +.in 5 +a*b+c (a*b)+c + +a+b*c a+(b*c) + +a MOD b*c SHL d ((a MOD b)*c) SHL d + +a OR b AND NOT c+d SHL e a OR (b AND (NOT (c+(d SHL e)))) +.fi +.in 0 +.sp +.pp +Balanced, parenthesized subexpressions can always be used to +override the assumed parentheses; thus, the last expression above +could be rewritten to force application of operators in a +different order, as shown: +.sp +.ti 8 +(a OR b) AND (NOT c)+ d SHL e +.sp +This results in these assumed parentheses: +.sp +.ti 8 +(a OR b) AND ((NOT c) + (d SHL e)) +.pp +An unparenthesized expression is well-formed only if the +expression that results from inserting the assumed parentheses is +well-formed. +.sp 2 +.tc 3.4 Assembler Directives +.he CP/M Operating System Guide 3.4 Assembler Directives +.sh +3.4 Assembler Directives +.qs +.pp +Assembler directives are used to set labels to specific values +during the assembly, perform conditional assembly, define storage +areas, and specify starting addresses in the program. Each +assembler directive is denoted by a pseudo operation that appears +in the operation field of the line. The acceptable pseudo operations +are shown in Table 3-3. +.sp 2 +.nf +.sh + Table 3-3. Assembler Directives +.sp + Directive Meaning +.fi +.sp + ORG set the program or data origin +.sp + END end program, optional start address +.sp + EQU numeric equate +.sp + SET numeric set +.sp + IF begin conditional assembly +.sp + ENDIF end of conditional assembly +.sp + DB define data bytes +.sp + DW define data words +.sp + DS define data storage area +.in 0 +.bp +.tc 3.4.1 The ORG Directive +.sh +3.4.1 The ORG Directive +.qs +.pp +The ORG statement takes the form: +.sp +.ti 8 +label ORG expression +.sp +where label is an optional program identifier and expression is +a 16-bit expression, consisting of operands that are defined +before the ORG statement. The assembler begins machine code +generation at the location specified in the expression. There +can be any number of ORG statements within a particular program, +and there are no checks to ensure that the programmer is not +defining overlapping memory areas. Note that +most programs written for the CP/M system begin with an ORG +statement of the form: +.sp +.ti 8 +ORG 100H +.sp +which causes machine code generation to begin at the base of the +CP/M transient program area. If a label is specified in the ORG +statement, the label is given the value of the expression. This +label can then be used in the operand field of other statements +to represent this expression. +.sp 2 +.tc 3.4.2 The END Directive +.sh +3.4.2 The END Directive +.qs +.pp +The END statement is optional in an assembly-language program, +but if it is present it must be the last statement. All +subsequent statements are ignored in the assembly. The END +statement takes the following two forms: +.sp +.in 8 +.nf +label END + +label END expression +.fi +.in 0 +.sp +where the label is again optional. If the first form is used, +the assembly process stops, and the default starting address of +the program is taken as 0000. Otherwise, the expression is +evaluated, and becomes the program starting address. This +starting address is included in the last record of the Intel-formatted +machine code hex file that results from the +assembly. Thus, most CP/M assembly-language programs end with +the statement: +.sp +.ti 8 +END 100H +.sp +resulting in the default starting address of 100H (beginning of +the transient program area). +.bp +.tc 3.4.3 The EQU Directive +.sh +3.4.3 The EQU Directive +.qs +.pp +The EQU (equate) statement is used to set up synonyms for +particular numeric values. The EQU statement takes the form: +.sp +.ti 8 +.nf +label EQU expression +.fi +.sp +where the label must be present and must not label any other +statement. The assembler evaluates the expression and assigns +this value to the identifier given in the label field. The +identifier is usually a name that describes the value in a more +human-oriented manner. Further, this name is used throughout the +program to place parameters on certain functions. Suppose data +received from a teletype appears on a particular input port, and +data is sent to the teletype through the next output port in +sequence. For example, you can use this series of equate statements +to define these ports for a particular hardware environment: +.sp 2 +.in 8 +.nf +TTYBASE EQU 10H ;BASE PORT NUMBER FOR TTY + +TTYIN EQU TTYBASE ;TTY DATA IN + +TTYOUT EQU TTYBASE+1 ;TTY DATA OUT +.fi +.in 0 +.sp +.pp +At a later point in the program, the statements that access the +teletype can appear as follows: +.sp 2 +.in 7 +.nf + IN TTYIN ;READ TTY DATA TO REG-A + + ... + + OUT TTYOUT ;WRITE DATA TO TTY FROM REG-A +.fi +.in 0 +.sp 2 +making the program more readable than if the absolute I/O ports +are used. Further, if the hardware environment is redefined +to start the teletype communications ports at 7FH instead of 10H, +the first statement need only be changed to +.sp +.ti 8 +.nf +TTYBASE EQU 7FH ;BASE PORT NUMBER FOR TTY +.fi +.sp +and the program can be reassembled without changing any other +statements. +.sp 2 +.tc 3.4.4 The SET Directive +.sh +3.4.4 The SET Directive +.qs +.pp +The SET statement is similar to the EQU, taking the form: +.sp +.ti 8 +label SET expression +.sp +except that the label can occur on other SET statements within +the program. The expression is evaluated and becomes the current +value associated with the label. Thus, the EQU statement defines +a label with a single value, while the SET statement defines a +value that is valid from the current SET statement to the point +where the label occurs on the next SET statement. The use of the +SET is similar to the EQU statement, but is used most often in +controlling conditional assembly. +.sp 2 +.tc 3.4.5 The IF and ENDIF Directives +.sh +3.4.5 The IF and ENDIF Directives +.qs +.pp +The IF and ENDIF statements define a range of assembly-language +statements that are to be included or excluded during the +assembly process. These statements take on the form: +.sp 2 +.in 8 +.nf +IF expression + +statement#1 + +statement#2 + + ... + +statement#n + +ENDIF +.fi +.in 0 +.sp +.pp +When encountering the IF statement, the assembler evaluates the +expression following the IF. All operands in the expression must +be defined ahead of the IF statement. If the expression +evaluates to a nonzero value, then statement#1 through +statement#n are assembled. If the expression evaluates to zero, +the statements are listed but not assembled. Conditional +assembly is often used to write a single generic program that +includes a number of possible run-time environments, with only a +few specific portions of the program selected for any particular +assembly. The following program segments, for example, might be +part of a program that communicates with either a teletype or a +CRT console (but not both) by selecting a particular value for +TTY before the assembly begins. +.bp +.nf +.in 8 +TRUE EQU OFFFFH ;DEFINE VALUE OF TRUE +FALSE EQU NOT TRUE ;DEFINE VALUE OF FALSE +; +TTY EQU TRUE ;TRUE IF TTY, FALSE IF CRT +; +TTYBASE EQU 10H ;BASE OF TTY I/O PORTS +CRTBASE EQU 20H ;BASE OF CRT I/O PORTS + IF TTY ;ASSEMBLE RELATIVE TO + ;TTYBASE +CONIN EQU TTYBASE ;CONSOLE INPUT +CONOUT EQU TTYBASE+1 ;CONSOLE OUTPUT + ENDIF + +; IF NOT TTY ;ASSEMBLE RELATIVE TO + ;CRTBASE +CONIN EQU CRTBASE ;CONSOLE INPUT +CONOUT EQU CRTBASE+1 ;CONSOLE OUTPUT + + ENDIF + ... + IN CONIN ;READ CONSOLE DATA + ... + OUT CONTOUT ;WRITE CONSOLE DATA +.fi +.in 0 +.sp 2 +In this case, the program assembles for an environment where +a teletype is connected, based at port 10H. The statement +defining TTY can be changed to +.sp +.nf +.ti 8 +TTY EQU FALSE +.fi +.sp +and, in this case, the program assembles for a CRT based at +port 20H. +.sp 2 +.tc 3.4.6 The DB Directive +.sh +3.4.6 The DB Directive +.qs +.pp +The DB directive allows the programmer to define initialized +storage areas in single-precision byte format. The DB statement +takes the form: +.sp +.nf +.ti 8 +label DB e#1, e#2, ..., e#n +.fi +.sp +where e#1 through e#n are either expressions that evaluate to 8-bit +values (the high-order bit must be zero) or are ASCII strings +of length no greater than 64 characters. There is no practical +restriction on the number of expressions included on a single +source line. The expressions are evaluated and placed +sequentially into the machine code file following the last +program address generated by the assembler. String characters +are similarly placed into memory starting with the first +character and ending with the last character. Strings of length +greater than two characters cannot be used as operands in more +complicated expressions. +.bp +.sh +Note: \c +.qs +ASCII +characters are always placed in memory with the parity bit reset +(0). Also, there is no translation from lower- to upper-case +within strings. The optional label can be used to reference the +data area throughout the remainder of the program. The following +are examples of valid DB statements: +.sp 2 +.nf +.in 8 +data: DB 0,1,2,3,4,5 + DB data and 0ffh,5,377Q,1+2+3+4 + +sign-on: DB 'please type your name',cr,lf,0 + DB 'AB' SHR 8, 'C', 'DE' AND 7FH +.fi +.in 0 +.sp 3 +.tc 3.4.7 The DW Directive +.sh +3.4.7 The DW Directive +.qs +.pp +The DW statement is similar to the DB statement except double-precision +two-byte words of storage are initialized. The DW statement +takes the form: +.sp +.nf +.ti 8 +label DW e#1, e#2, ..., e#n +.fi +.sp +where e#1 through e#n are expressions that evaluate to 16-bit +results. Note that ASCII strings of one or two +characters are allowed, but strings longer than two characters +are disallowed. In all cases, the data storage is consistent +with the 8080 processor; the least significant byte of the +expression is stored first in memory, followed by the most +significant byte. The following are examples of DW statements: +.sp 2 +.in 8 +.nf +doub: DW 0ffefh,doub+4,signon-$,255+255 + DW 'a', 5, 'ab', 'CD', 6 shl 8 or llb. +.fi +.in 0 +.sp 3 +.tc 3.4.8 The DS Directive +.sh +3.4.8 The DS Directive +.qs +.pp +The DS statement is used to reserve an area of uninitialized +memory, and takes the form: +.sp +.ti 8 +.nf +label DS expression +.fi +.sp +where the label is optional. The assembler begins subsequent +code generation after the area reserved by the DS. Thus, the DS +statement given above has exactly the same effect as the following +statement: +.sp +.nf +.in 7 +label: EQU $ ;LABEL VALUE IS CURRENT CODE LOCATION + ORG $+expression ;MOVE PAST RESERVED AREA +.fi +.in 0 +.nx threeb + + + + + + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/threeb.tex b/Source/Doc/CPM 22 Manual/threeb.tex new file mode 100644 index 00000000..616e190f --- /dev/null +++ b/Source/Doc/CPM 22 Manual/threeb.tex @@ -0,0 +1,954 @@ +.bp +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.ft 3-% +.he CP/M Operating System Manual 3.5 Operation Codes +.tc 3.5 Operation Codes +.sh +3.5 Operation Codes +.qs +.pp 5 +Assembly-language operation codes form the principal part of +assembly-language programs and form the operation field of the +instruction. In general, ASM accepts all the standard mnemonics +for the Intel 8080 microcomputer, which are given in detail in the \c +.ul +Intel 8080 Assembly Language Programming Manual. \c +.qu +Labels are optional on each input line. The individual operators +are listed briefly in the following sections for completeness, +although the Intel manuals should be +referenced for exact operator details. In Tables 3-4 through 3-8, +bit values have the following meaning: +.sp 2 +.in 5 +.ti -2 +o e3 represents a 3-bit value in the range 0-7 that can be +one of the predefined registers A, B, C, D, E, H, L, M, SP, or +PSW. +.sp +.ti -2 +o e8 represents an 8-bit value in the range 0-255. +.sp +.ti -2 +o e16 represents a 16-bit value in the range 0-65535. +.in 0 +.sp +.pp +These expressions can be formed from an arbitrary combination of +operands and operators. In some cases, the operands are +restricted to particular values within the allowable range, such +as the PUSH instruction. These cases are noted as they are +encountered. +.pp +In the sections that follow, each operation code is listed in its +most general form, along with a specific example, a short +explanation, and special restrictions. +.sp 2 +.tc 3.5.1 Jumps, Calls, and Returns +.sh +3.5.1 Jumps, Calls, and Returns +.qs +.pp +The Jump, Call, and Return instructions allow several different +forms that test the condition flags set in the 8080 microcomputer +CPU. The forms are shown in Table 3-4. +.sp 2 +.ce +.sh +Table 3-4. Jumps, Calls, and Returns +.ll 63 +.sp +.nf + Form Bit Example Meaning + Value + + JMP e16 JMP L1 Jump unconditionally to label + + JNZ e16 JNZ L2 Jump on nonzero condition to label + + JZ e16 JZ 100H Jump on zero condition to label + + JNC e16 JNC L1+4 Jump no carry to label + + JC e16 JC L3 Jump on carry to label + + JPO e16 JPO $+8 Jump on parity odd to label +.bp +.ll 65 +.fi +.ce +.sh +Table 3-4. (continued) +.ll 63 +.sp +.nf + Form Bit Example Meaning + Value + + JPE e16 JPE L4 Jump on even parity to label + + JP e16 JP GAMMA Jump on positive result to label + + JM e16 JM al Jump on minus to label + + + CALL e16 CALL S1 Call subroutine unconditionally + + CNZ e16 CNZ S2 Call subroutine on nonzero + condition + + CZ e16 CZ 100H Call subroutine on zero condition + + CNC e16 CNC S1+4 Call subroutine if no carry set + + CC e16 CC S3 Call subroutine if carry set + + CPO e16 CPO $+8 Call subroutine if parity odd + + CPE e16 CPE $4 Call subroutine if parity even + + CP e16 CP GAMMA Call subroutine if positive result + + CM e16 CM b1$c2 Call subroutine if minus flag + + + RST e3 RST 0 Programmed restart, equivalent to + CALL 8*e3, except one byte call + + RET Return from subroutine + + RNZ Return if nonzero flag set + + RZ Return if zero flag set + + RNC Return if no carry + + RC Return if carry flag set + + RPO Return if parity is odd + + RPE Return if parity is even + + RP Return if positive result + + RM Return if minus flag is set +.fi +.in 0 +.ll 65 +.sp 3 +.tc 3.5.2 Immediate Operand Instructions +.sh +3.5.2 Immediate Operand Instructions +.qs +.pp 5 +Several instructions are available that load single- or double- +precision registers or single-precision memory cells with +constant values, along with instructions that perform immediate +arithmetic or logical operations on the accumulator (register A). +Table 3-5 describes the immediate operand instructions. +.sp 2 +.ce +.sh +Table 3-5. Immediate Operand Instructions +.sp +.ll 60 +.in 5 +.nf +Form with Example Meaning +Bit Values +.fi +.sp +.in 35 +.ti -30 +MVI e3,e8 MVI B,255 Move immediate data to register A, B, C, D, +E, H, L, or M (memory) +.sp +.ti -30 +ADI e8 ADI 1 Add immediate operand to A without carry +.sp +.ti -30 +ACI e8 ACI 0FFH Add immediate operand to A with carry +.sp +.ti -30 +SUI e8 SUI L + 3 Subtract from A without borrow (carry) +.sp +.ti -30 +SBI e8 SBI L AND 11B Subtract from A with borrow (carry) +.sp +.ti -30 +ANI e8 ANI $ AND 7FH Logical and A with immediate data +.sp +.ti -30 +XRI e8 XRI 1111$0000B Exclusive or A with immediate data +.sp +.ti -30 +ORI e8 ORI L AND 1+1 Logical or A with immediate data +.sp +.ti -30 +CPI e8 CPI 'a' Compare A with immediate data, same +as SUI except register A not changed. +.sp +.ti -30 +LXI e3,e16 LXI B,100H Load extended immediate to register +pair. e3 must be equivalent to B, D, H, or SP. +.in 0 +.ll 65 +.sp 2 +.tc 3.5.3 Increment and Decrement Instructions +.sh +3.5.3 Increment and Decrement Instructions +.qs +.pp +The 8080 provides instructions for incrementing or decrementing +single- and double-precision registers. The instructions are +described in Table 3-6. +.sp 2 +.ce +.sh +Table 3-6. Increment and Decrement Instructions +.ll 60 +.sp +.in 5 +.nf +Form with Example Meaning +Bit Value +.fi +.sp +.in 35 +.ti -28 +INR e3 INR E Single-precision increment +register. e3 produces one of A, B, C, D, E, H, L, M. +.sp +.ti -28 +DCR e3 DCR A Single-precision decrement +register. e3 produces one of A, B, C, D, E, H, L, M. +.sp +.ti -28 +INX e3 INX SP Double-precision increment register +pair. e3 must be equivalent to B, D, H, or SP. +.sp +.ti -28 +DCX e3 DCX B Double-precision decrement register +pair. e3 must be equivalent to B, D, H, or SP. +.in 0 +.ll 65 +.sp 3 +.tc 3.5.4 Data Movement Instructions +.sh +3.5.4 Data Movement Instructions +.qs +.pp +Instructions that move data from memory to the CPU and from CPU to memory are +given in the following table. +.sp 2 +.ce +.sh +Table 3-7. Data Movement Instructions +.ll 60 +.in 5 +.sp +.nf +Form with Example Meaning +Bit Value +.fi +.sp +.in 35 +.ti -30 +MOV e3,e3 MOV A,B Move data to leftmost element from rightmost +element. e3 produces on of A, B, C, D, E, H, L, or M. MOV M,M is +disallowed. +.sp +.ti -30 +LDAX e3 LDAX B Load register A from computed address. e3 must +produce either B or D. +.sp +.ti -30 +STAX e3 STAX D Store register A to computed +address. e3 must produce either B or D. +.sp +.ti -30 +LHLD e16 LHLD L1 Load HL direct from location +e16. Double-precision load to H and L. +.fi +.bp +.ll 65 +.in 0 +.ce +.sh +Table 3-7. (continued) +.ll 60 +.in 5 +.sp +.nf +Form with Example Meaning +Bit Value +.fi +.sp +.in 35 +.ti -30 +SHLD e16 SHLD L5+x Store HL direct to location e16. +Double-precision store from H and L to memory. +.sp +.ti -30 +LDA e16 LDA Gamma Load register A from address e16. +.sp +.ti -30 +STA e16 STA X3-5 Store register A into memory +at e16. +.sp +.ti -30 +POP e3 POP PSW Load register pair from stack, set SP. +e3 must produce one of B, D, H, or PSW. +.sp +.ti -30 +PUSH e3 PUSH B Store register pair into stack, set SP. e3 +must produce on of B, D, H, or PSW. +.sp +.ti -30 +IN e8 IN 0 Load register A with data from port +e8. +.sp +.ti -30 +OUT e8 OUT 255 Send data from register A to port +e8. +.sp +.ti -30 +XTHL Exchange data from top of stack +with HL. +.sp +.ti -30 +PCHL Fill program counter with data from +HL. +.sp +.ti -30 +SPHL Fill stack pointer with data from +HL. +.sp +.ti -30 +XCHG Exchange DE pair with HL pair. +.in 0 +.ll 65 +.sp 3 +.tc 3.5.5 Arithmetic Logic Unit Operations +.sh +3.5.5 Arithmetic Logic Unit Operations +.qs +.pp +Instructions that act upon the single-precision accumulator to +perform arithmetic and logic operations are given in the +following table. +.bp +.ce +.sh +Table 3-8. Arithmetic Logic Unit Operations +.ll 60 +.sp +.in 5 +.nf +Form with Example Meaning +Bit Value +.fi +.sp +.in 35 +.ti -29 +ADD e3 ADD B Add register given by e3 to +accumulator without carry. e3 must produce one of A, B, C, D, E, +H, or L. +.sp +.ti -29 +ADC e3 ADC L Add register to A with carry, e3 as +above. +.sp +.ti -29 +SUB e3 SUB H Subtract reg e3 from A without +carry, e3 is defined as above. +.sp +.ti -29 +SBB e3 SBB 2 Subtract register e3 from A with +carry, e3 defined as above. +.sp +.ti -29 +ANA e3 ANA 1+1 Logical and reg with A, e3 as +above. +.sp +.ti -29 +XRA e3 XRA A Exclusive or with A, e3 as above. +.sp +.ti -29 +ORA e3 ORA B Logical or with A, e3 defined as +above. +.sp +.ti -29 +CMP e3 CMP H Compare register with A, e3 as +above. +.sp +.ti -29 +DAA Decimal adjust register A based +upon last arithmetic logic unit operation. +.sp +.ti -29 +CMA Complement the bits in register A. +.sp +.ti -29 +STC Set the carry flag to 1. +.sp +.ti -29 +CMC Complement the carry flag. +.sp +.ti -29 +RLC Rotate bits left, (re)set carry as a +side effect. High-order A bit becomes carry. +.sp +.ti -29 +RRC Rotate bits right, (re)set carry as +side effect. Low-order A bit becomes carry. +.bp +.in 0 +.ll 65 +.ce +.sh +Table 3-8. (continued) +.ll 60 +.sp +.in 5 +.nf +Form with Example Meaning +Bit Value +.fi +.sp +.in 35 +.ti -29 +RAL Rotate carry/A register to left. +Carry is involved in the rotate. +.sp +.ti -29 +RAR Rotate carry/A register to right. +Carry is involved in the rotate. +.sp +.ti -29 +DAD e3 DAD B Double-precision add register pair +e3 to HL. e3 must produce B, D, H, or SP. +.in 0 +.ll 65 +.sp 2 +.tc 3.5.6 Control Instructions +.sh +3.5.6 Control Instructions +.qs +.pp +The four remaining instructions, categorized as control instructions, are +the following: +.sp +.nf +.in 3 +o HLT halts the 8080 processor. +o DI disables the interrupt system. +o EI enables the interrupt system. +o NOP means no operation. +.in 0 +.fi +.sp 2 +.tc 3.6 Error Messages +.he CP/M Operating System Manual 3.6 Error Messages +.sh +3.6 Error Messages +.qs +.pp +When errors occur within the assembly-language program, they are +listed as single-character flags in the leftmost position of the +source listing. The line in error is also echoed at the console +so that the source listing need not be examined to determine if +errors are present. The error codes are listed in the following +table. +.sp 2 +.ce +.sh +Table 3-9. Error Codes +.sp +.ll 60 +.in 3 +.nf +Error Code Meaning +.fi +.sp +.in 16 +.ti -13 +D Data error: element in data statement cannot be placed in +the specified data area. +.sp +.ti -13 +E Expression error: expression is ill-formed and cannot be +computed at assembly time. +.sp +.ti -13 +L Label error: label cannot appear in this context; might be +duplicate label. +.sp +.ti -13 +N Not implemented: features that will appear in future ASM +versions. For example, macros are recognized, but flagged in this +version. +.bp +.in 0 +.ll 65 +.ce +.sh +Table 3-9. (continued) +.sp +.ll 60 +.in 3 +.nf +Error Code Meaning +.fi +.sp +.in 16 +.ti -13 +O Overflow: expression is too complicated (too many +pending operators) to be computed and should be simplified. +.sp +.ti -13 +P Phase error: label does not have the same value on two +subsequent passes through the program. +.sp +.ti -13 +R Register error: the value specified as a register is not +compatible with the operation code. +.sp +.ti -13 +S Syntax error: statement is not properly formed. +.sp +.ti -13 +V Value error: operand encountered in expression is +improperly formed. +.in 0 +.ll 65 +.sp +.pp +Table 3-10 lists the error messages that are due to terminal error +conditions. +.sp 2 +.ce +.sh +Table 3-10. Error Messages +.sp +.ll 60 +.in 5 +.nf +Message Meaning +.fi +.sp +NO SOURCE FILE PRESENT +.sp +.in 19 +The file specified in the ASM command does not exist on disk. +.sp 2 +.in 5 +NO DIRECTORY SPACE +.sp +.in 19 +The disk directory is full; erase files that are not needed and retry. +.sp 2 +.in 5 +SOURCE FILE NAME ERROR +.sp +.in 19 +Improperly formed ASM filename, for example, it is specified with ? fields. +.sp 2 +.in 5 +SOURCE FILE READ ERROR +.sp +.in 19 +Source file cannot be read properly by the assembler; execute a +TYPE to determine the point of error. +.bp +.in 0 +.ll 65 +.ce +.sh +Table 3-10. (continued) +.sp +.ll 60 +.in 5 +.nf +Message Meaning +.fi +.sp +OUTPUT FILE WRITE ERROR +.sp +.in 19 +Output files cannot be written properly; most likely cause is a full +disk, erase and retry. +.sp 2 +.in 5 +CANNOT CLOSE FILE +.sp +.in 19 +Output file cannot be closed; check to see if disk is write protected. +.in 0 +.ll 65 +.sp 3 +.tc 3.7 A Sample Session +.he CP/M Operating System Manual 3.7 A Sample Session +.sh +3.7 A Sample Session +.qs +.pp +The following sample session shows interaction with the assembler and +debugger in the development of a simple assembly-language +program. The arrow represents a carriage return keystroke. +.sp 2 +.ll 90 +.nf +A>\c +.sh +ASM SORT \c +.qs +Assemble SORT.ASM +.sp +CP/M ASSEMBLER - VER 1.0 +.sp +0015C Next free address +003H USE FACTOR Percent of table used 00 to ff (hexadecimal) +END OF ASSEMBLY +.sp +A>\c +.sh +DIR SORT.* +.qs +.sp +SORT ASM Source file +SORT BAK Back-up from last edit +SORT PRN Print file (contains tab characters) +SORT HEX Machine code file +.sp +A>\c +.sh +TYPE SORT.PRN +.qs + Source line +.sp + ; SORT PROGRAM IN CP/M ASSEMBLY LANGUAGE + ; START AT THE BEGINNING OF THE TRANSIENT + PROGRAM AREA +.sp +Machine code location +0100 ORG 100H +.sp +Generated machine code +0100 214601 SORT: LXI H,SW ;ADDRESS SWITCH TOGGLE +0103 3601 MVI M,1 ;SET TO 1 FOR FIRST ITERATION +0105 214701 LXI H,I ;ADDRESS INDEX +0108 3600 MVI M,0 ;I=0 + ; + ; COMPARE I WITH ARRAY SIZE +010A 7E COMPL: MOV A,M ;A REGISTER = I +010B FE09 CPI N-1 ;CY SET IF I<(N-1) +010D D21901 JNC CONT ;CONTINUE IF I<=(N-2) + ; + ; END OF ONE PASS THROUGH DATA +0110 214601 LXI H,SW ;CHECK FOR ZERO SWITCHES +0113 7EB7C200001 MOV A, M! ORA A! JNZ SORT ;END OF SORT IF SW=0 + ; +0118 FF RST 7 ;GO TO THE DEBUGGER INSTEAD OF REB + ; + ; CONTINUE THIS PASS +Truncated ; ADDRESSING I, SO LOAD AV(I) INTO REGISTERS +0119 + 5F16002148CONT: MOV E, A! MVI D, 0! LXI H, AV! DAD D! DAD D +0121 4E792346 MOV C, M! MOV A, C! INX H! MOV B, M + ; LOW ORDER BYTE IN A AND C, HIGH ORDER BYTE IN B + ; + ; MOV H AND L TO ADDRESS AV(I+1) +0125 23 INX H + ; + ; COMPARE VALUE WITH REGS CONTAINING AV (I) +0126 965778239E SUB M! MOV D, A! MOV A, B! INX H! SBB M ;SUBTRACT + ; + ; BORROW SET IF AV(I+1)>AV(I) +012B DA3F01 JC INCI ;SKIP IF IN PROPER ORDER + ; + ; CHECK FOR EQUAL VALUES +012E B2CA3F01 ORA D! JZ INCI ;SKIP IF AV(I) = AV(I+1) +0132 56702B5E MOV D, M! MOV M, B! DCX H! MOV E, M +0136 712B722B73 MOV M, C! DCX H! MOV M, D! DCX H! MOV M, E + ; + ; INCREMENT SWITCH COUNT +013B 21460134 LXI H,SW! INR M + ; + ; INCREMENT I +013F 21470134C3INCI:LXI H,I! INR M! JMP COMP + ; + ; DATA DEFINITION SECTION +0146 00 SW: DB 0 ;RESERVE SPACE FOR SWITCH COUNT +0147 I: DS 1 ;SPACE FOR INDEX +0148 050064001EAV: DW 5, 100, 30, 50, 20, 7, 1000, 300, 100, -32767 +000A = N EQU($-AV)/2 ;COMPUTE N INSTEAD OF PRE +015C END +A>\c +.sh +TYPE SORT.HEX \c +.qs +Equate value + +:10010000214601360121470136007EFE09D2190140 +:100110002146017EB7C20001FF5F16002148011988 Machine code in +:10012000194E79234623965778239EDA3F01B2CAA7 HEX format +.mb 5 +.fm 1 + +:100130003F0156702B5E712B722B732146013421C7 +:07014000470134C30A01006E Machine code in +:10014800050064001E00320014000700E8032C01BB HEX format +:0401580064000180BE +:0000000000 +A>\c +.sh +DDT SORT.HEX \c +.qs +Start debug run +.mb 6 +.fm 2 + +16K DDT VER 1.0 +NEXT PC +015C 0000 Default address (no address on END statement) +-XP + +P=0000 100 Change PC to 100 + +-UFFFF Untrace for 65535 steps + Abort with rubout +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=0100 LXI H,0146*0100 +-T10 Trace 10\d16\u steps + +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0100 LXI H, 0146 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M, 01 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H, 0147 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M, 00 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=010A MOV A, M +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010B CPI 09 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010D JNC 0119 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0110 LXI H, 0146 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0113 MOV A, M +C1Z0M1E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0114 ORA A +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0115 JNZ 0100 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0100 LXI H, 0146 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M, 01 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H, 0147 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M, 00 +C0Z0M0E0I0 A=01 B=0000 D=0000 H=0147 S=0100 P=010A MOV A, M*010B +-A10D Stopped at 10BH + +010D JC 119 Change to a jump on carry +0110 + +-XP + +P=010B 100 Reset program counter back to beginning of program + +-T10 Trace execution for 10H steps + + Altered instruction +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0100 LXI H,0146 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0103 MVI M,01 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0146 S=0100 P=0105 LXI H,0147 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0108 MVI M,00 +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010A MOV A,M +C0Z0M0E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010B CPI 09 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=010D JC 0119 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=0119 MOV E,A +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=011A MVI D,00 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0147 S=0100 P=011C LXI H,0148 +C1Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=011F DAD D +C0Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=0120 DAD D +C0Z0M1E0I0 A=00 B=0000 D=0000 H=0148 S=0100 P=0121 MOV C,M +C0Z0M1E0I0 A=00 B=0005 D=0000 H=0148 S=0100 P=0122 MOV A,C +C0Z0M1E0I0 A=05 B=0005 D=0000 H=0148 S=0100 P=0123 INX H +C0Z0M1E0I0 A=05 B=0005 D=0000 H=0149 S=0100 P=0124 MOV B,M*0125 +-L100 Automatic breakpoint + + 0100 LXI H,0146 + 0103 MVI M,01 + 0105 LXI H,0147 + 0108 MVI M,00 + 010A MOV A,M List some code + 010B CPI 09 from 100H + 010D JC 0119 + 0110 LXI H,0146 + 0113 MOV A,M + 0114 ORA A + 0115 JNZ 0100 + -L + + 0118 RST 07 + 0119 MOV E,A List more + 011A MVI D,00 + 011C LXI H,0148 +-Abort list with rubout +-G,11B Start program from current PC (0125H) + and run in real time to 11BH + + + +*0127 Stopped with an external interrupt 7 from front panel +-T4 (program was looping indefinitely) + Look at looping program in trace mode + +C0Z0M0E0I0 A=38 B=0064 D=0006 H=0156 S=0100 P=0127 MOV D,A +C0Z0M0E0I0 A=38 B=0064 D=3806 H=0156 S=0100 P=0128 MOV A,B +C0Z0M0E0I0 A=00 B=0064 D=3806 H=0156 S=0100 P=0129 INX H +C0Z0M0E0I0 A=00 B=0064 D=3806 H=0157 S=0100 P=012A SBB M*012B +-D148 + Data are sorted, but program does not stop. +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D.,........ + +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-G0 Return to CP/M + +A>\c +.sh +DDT SORT.HEX \c +.qs +Reload the memory image + +16K DDT VER 1.0 +NEXT PC +015C 0000 +-XP + +P=0000 100 Set PC to beginning of program + +-L10D List bad OPCODE + + 010D JNC 0119 + 0110 LXI H,0146 +-Abort list with rubout +-A10D Assemble new OPCODE + +010D JC 119 + +0110 + +-L100 List starting section of program + + 0100 LXI H,0146 + 0103 MVI M,01 + 0105 LXI H,0147 + 0108 MVI M,00 +-Abort list with rubout +-A103 Change switch initialization to 00 + +0103 MVI M,0 + +0105 + +-^C Return to CP/M with CTRL-C (G0 works as well) + +SAVE 1 SORT.COM Save 1 page (256 bytes, from 100H to 1ffH) on + disk in case there is need to reload later +A>\c +.sh +DDT SORT.COM \c +.qs +Restart DDT with saved memory image + +16K DDT VER 1.0 +NEXT PC +0200 0100 COM file always starts with address 100H +-G Run the program from PC=100H + +*0118 Programmed stop (RST 7) encountered +-D148 + + Data properly sorted +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D......... + +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ +0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-G0 Return to CP/M + +A>\c +.sh +ED SORT.ASM \c +.qs +Make changes to original program + +*N,0^Z0TT Find next ,0 + MVI M,0 ;I = 0 + +*- Up one line in text + LXI H,I ;ADDRESS INDEX +.bp +*- Up another line + MVI M,1 ;SET TO 1 FOR FIRST ITERATION + +*KT Kill line and type next line + LXI H,I ;ADDRESS INDEX + +*I Insert new line + MVI M,0 ;ZERO SW + +*T + LXI H,I ;ADDRESS INDEX + +*NJNC^Z0T + JNC*T + CONT ;CONTINUE IF I<=(N-2) + +*-2DIC^Z0LT + JC CONT ;CONTINUE IF I<=(N-2) + +*E Source from disk A + HEX to disk A +A>\c +.sh +ASM SORT.AAZ \c +.qs +Skip PRN file + +CP/M ASSEMBLER - VER 1.0 + +015C Next address to assemble +003H USE FACTOR +END OF ASSEMBLY + +A>\c +.sh +DDT SORT.HEX \c +.qs +Test program changes + +16K DDT VER 1.0 +NEXT PC +015C 0000 +-G100 + +*0118 +-D148 + Data sorted +0148 05 00 07 00 14 00 1E 00........ +0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D.......... +0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00................ + +-Abort with rubout + +-G0 Return to CP/M--program checks OK. +.in 0 +.ll 65 +.sp 2 +.ce +End of Section 3 +.nx foura + \ No newline at end of file diff --git a/Source/Doc/CPM 22 Manual/two.tex b/Source/Doc/CPM 22 Manual/two.tex new file mode 100644 index 00000000..e534f9d3 --- /dev/null +++ b/Source/Doc/CPM 22 Manual/two.tex @@ -0,0 +1,1124 @@ +.bp 1 +.op +.cs 5 +.mt 5 +.mb 6 +.pl 66 +.ll 65 +.po 10 +.hm 2 +.fm 2 +.he +.ft 2-% +.pc 1 +.tc 2 The CP/M Editor +.ce 2 +.sh +Section 2 +.sp +.sh +The CP/M Editor +.sp 3 +.tc 2.1 Introduction to ED +.he CP/M Operating System Manual 2.1 Introduction to ED +.sh +2.1 Introduction to Ed +.qs +.pp 5 +Ed is the context editor for CP/M, and is used to create and alter CP/M source +files. To start ED, type a command of the following form: +.sp +.nf +.ti 8 +ED filename +or +.ti 8 +ED filename.typ +.fi +.sp +Generally, ED reads segments of the source file given by filename or +filename.typ into the central memory, where you edit the file +and it is subsequently written back to disk after alterations. If the +source file does not exist before editing, it is created by ED and +initialized to empty. The overall operation of Ed is shown in +Figure 2-1. +.sp 2 +.tc 2.1.1 ED Operation +.sh +2.1.1 ED Operation +.qs +.pp +Ed operates upon the source file, shown in Figure 2-1 by x.y, and passes +all text through a memory buffer where the text can be viewed or altered. +The number of lines that can be maintained in the memory buffer varies with +the line length, but has a total capacity of about 5000 characters in a 20K +CP/M system. +.pp +Edited text material is written into a temporary +work file under your command. Upon termination of the edit, the +memory buffer is written to the temporary file, followed by any remaining +(unread) text in the source file. The name of the original file is changed +from x.y to x.BAK so that the most recent edited source file can +be reclaimed if necessary. See the CP/M commands ERASE and RENAME. The +temporary file is then changed from x.$$$ to x.y, which becomes the resulting +edited file. +.pp +The memory buffer is logically between the source file and working file, as +shown in Figure 2-2. +.bp +.sp 27 +.ce +.sh +Figure 2-1. Overall ED Operation +.sp 3 +.nf + Source File Memory Buffer Temporary File + + 1 First Line 1 First Line 1 First Line + 2 Appended 2 Buffered 2 Processed + 3 Lines 3 Text 3 Text + + + + SP MP TP + + + + Unprocessed Next Free Next Free File + Source Append Memory Write Space + Lines Space + + + + SP = Source Pointer + MP = Memory Pointer + TP = Temporary Pointer +.sp 2 +.fi +.ce +.sh +Figure 2-2. Memory Buffer Organization +.bp +.tc 2.1.2 Text Transfer Functions +.sh +2.1.2 Text Transfer Functions +.qs +.pp +Given that n is an integer value in the range 0 through 65535, several +single-letter ED commands transfer lines of text from the source file through +the memory buffer to the temporary (and eventually final) file. Single letter +commands are shown in upper-case, but can be typed in either upper- or +lower-case. +.sp 2 +.ce +.sh +Table 2-1. ED Text Transfer Commands +.sp + Command Result +.sp +.ll 60 +.in 15 +.ti -10 +nA Appends the next n unprocessed source lines from the source file at +SP to the end of the memory buffer at MP. Increment SP and MP by n. If +upper-case translation is set (see the U command) and the A command is typed +in upper-case, all input lines will automatically be translated to upper-case. +.sp +.ti -10 +nW Writes the first n lines of the memory buffer to the temporary +file free space. Shift the remaining lines n+1 through MP to the top of the +memory buffer. Increment TP by n. +.sp +.ti -10 +E Ends the edit. Copy all buffered text to temporary file and copy +all unprocessed source lines to temporary file. Rename files. +.sp +.ti -10 +H Moves to head of new file by performing automatic E command. The +temporary file becomes the new source file, the memory buffer is emptied, and +a new temporary file is created. The effect is equivalent to issuing an E +command, followed by a reinvocation of ED, using x.y as the file to edit. +.sp +.ti -10 +O Returns to original file. The memory buffer is emptied, the +temporary file is deleted, and the SP is returned to position 1 of the +source file. The effects of the previous editing commands are thus nullified. +.sp +.ti -10 +Q Quits edit with no file alterations, returns to CP/M. +.in 0 +.ll 65 +.sp +.pp +There are a number of special cases to consider. If the integer n is omitted +in any ED command where an integer is allowed, then 1 is assumed. Thus, the +commands A and W append one line and write one line, respectively. In +addition, if a pound sign # is given in the place of n, then the integer +65535 is assumed (the largest value for n that is allowed). Because most +source files can be contained entirely in the memory buffer, +the command #A is often issued at the beginning of the edit to read the +entire source file to memory. Similarly, the command #W writes the entire +buffer to the temporary file. +.pp +Two special forms of the A and W commands +are provided as a convenience. The command 0A fills the current memory +buffer at least half full, while 0W writes lines until the buffer is at least +half empty. An error is issued if the memory buffer size is exceeded. +You can then enter any command, such as W, that does not increase +memory requirements. The remainder of any partial line read during the +overflow will be brought into memory on the next successful append. +.sp 2 +.tc 2.1.3 Memory Buffer Organization +.sh +2.1.3 Memory Buffer Organization +.qs +.pp +The memory buffer can be considered a sequence of source lines brought +in with the A command from a source file. The memory buffer has an imaginary +character pointer (CP) that moves throughout the memory buffer +under command of the operator. +.pp +The memory buffer appears logically as shown +in Figure 2-3, where the dashes represent characters of the source line of +indefinite length, terminated by carriage return () and line-feed () +characters, and CP represents the imaginary character pointer. +Note that the CP is always located ahead of the first character of the +first line, behind the last character of the last line, or between two +characters. The current line CL is the source line that contains the CP. +.sp 3 +.nf + Memory Buffer + + + first line ----------------------- + + + ----------------------- + + + current line CL --------------------------- + + + CP + + last line ----------------------- +.sp 2 +.sh + Figure 2-3. Logical Organization of Memory Buffer +.qs +.fi +.sp 5 +.tc 2.1.4 Line Numbers and ED Start-up +.sh +2.1.4 Line Numbers and ED Start-up +.qs +.pp +ED produces absolute line number prefixes that are used to reference a +line or range of lines. The absolute line number is displayed at the +beginning of each line when ED is in insert mode (see the I command in +Section 2.1.5). Each line number takes the form +.sp +.ti 8 +nnnnn: +.sp +where nnnnn is an absolute line number in the range of 1 to 65535. If the +memory buffer is empty or if the current line is at the end of the memory +buffer, nnnnn appears as 5 blanks. +.pp +You can reference an absolute line number by preceding any command by +a number followed by a colon, in the same format as the line number display. +In this case, the ED program moves the current line reference to the absolute +line number, if the line exists in the current memory buffer. The line +denoted by the absolute line number must be in the memory buffer (see the +A command). Thus, the command +.sp +.ti 8 +345:T +.sp +is interpreted as move to absolute 345, and type the line. Absolute line +numbers are produced only during the editing process and are not recorded +with the file. In particular, the line numbers will change following a +deleted or expanded section of text. +.pp +You can also reference an absolute line number as a backward or forward +distance from the current line by preceding the absolute number by a colon. +Thus, the command +.sp +.ti 8 +:400T +.sp +is interpreted as type from the current line number through the line whose +absolute number is 400. Combining the two line reference forms, the +command +.sp +.ti 8 +345::400T +.sp +is interpreted as move to absolute line 345, then type through +absolute line 400. Absolute line references of this sort can precede any +of the standard ED commands. +.pp +Line numbering is controlled by the V (Verify Line Numbers) command. Line +numbering can be turned off by typing the -V command. +.bp +If the file to edit does not exist, ED displays the following message: +.sp +.ti 8 +NEW FILE +.sp +To move text into the memory buffer, you must enter an i command before typing +input lines and terminate each line with a carriage return. A single +CTRL-Z character returns ED to command mode. +.sp 2 +.tc 2.1.5 Memory Buffer Operation +.sh +2.1.5 Memory Buffer Operation +.qs +.pp +When ED begins, the memory buffer is empty. You can either append +lines from the source file with the A command, or enter the lines directly +from the console with the insert command. The insert command takes the +following form: +.sp +.ti 8 +I +.sp +ED then accepts any number of input lines. You must terminate each line with +a (the is supplied automatically). A single CTRL-Z, denoted +by a caret (^)Z, returns ED to command mode. The CP is positioned after the +last character entered. The following sequence: +.sp +.in 8 +.nf +I +NOW IS THE +TIME FOR +ALL GOOD MEN +^Z +.fi +.in 0 +.sp +leaves the memory buffer as +.sp +.in 8 +.nf +NOW IS THE +TIME FOR +ALL GOOD MEN +.fi +.in 0 +.pp +Generally, ED accepts command letters in upper- or lower-case. If the +command is upper-case, all input values associated with the command are +translated to upper-case. If the I command is typed, all +input lines are automatically translated internally to upper-case. The +lower-case form of the i command is most often used to allow both upper- and +lower-case letters to be entered. +.pp +Various commands can be issued that control the CP or display source text +in the vicinity of the CP. The commands shown below with a preceding n +indicate that an optional unsigned value can be specified. When preceded +by +\b_, the command can be unsigned, or have an optional preceding plus or +minus sign. As before, the pound sign # is replaced by 65535. If an +integer n is optional, but not supplied, then n=1 is assumed. Finally, if a +plus sign is optional, but none is specified, then + is assumed. +.bp +.ce +.sh +Table 2-2. Editing Commands +.sp + Command Action +.sp +.ll 60 +.in 15 +.ti -10 ++\b_B Move CP to beginning of memory buffer if + and to bottom if -. +.sp +.ti -10 ++\b_nC Move CP by +\b_n characters (moving ahead if +), counting the + as two characters. +.sp +.ti -10 ++\b_nD Delete n characters ahead of CP if plus and behind CP if minus. +.sp +.ti -10 ++\b_nK Kill (remove) +\b_n lines of source text using CP as the +current reference. If CP is not at the beginning of the current line when K +is issued, the characters before CP remain if + is specified, while the +characters after CP remain if - is given in the command. +.sp +.ti -10 ++\b_nL If n = 0, move CP to the beginning of the current +line, if it is +not already there. If n =\b/ 0, first move the CP to the beginning of the +current line and then move it to the beginning of the line that is n lines +down (if +) or up (if -). The CP will stop at the top or bottom of the +memory buffer if too large a value of n is specified. +.sp +.ti -10 ++\b_nT If n = 0, type the contents of the current line up to CP. If +n = 1, type the contents of the current line from CP to the end of the line. +If n>1, type the current line along with n - 1 lines that follow, if + is +specified. Similarly, if n>1 and - is given, type the previous n lines up to +the CP. Any key can be depressed to abort long type-outs. +.sp +.ti -10 ++\b_n Equivalent to +\b_nLT, which moves up or down and types a +single line. +.in 0 +.ll 65 +.sp 3 +.tc 2.1.6 Command Strings +.sh +2.1.6 Command Strings +.qs +.pp +Any number of commands can be typed contiguously (up to the capacity of +the console buffer) and are executed only after you press the . Table 2-3 +summarizes the CP/M console line-editing commands used to control the input +command line. +.bp +.ce +.sh +Table 2-3. Line-editing Controls +.sp + Command Result +.sp +.ll 60 +.in 16 +.ti -11 +CTRL-C Reboots the CP/M system when typed at the start of a line. +.sp +.ti -11 +CTRL-E Physical end of line: carriage is returned, but line is not sent +until the carriage return key is depressed. +.sp +.ti -11 +CTRL-H Backspaces one character position. +.sp +.ti -11 +CTRL-J Terminates current input (line-feed). +.sp +.ti -11 +CTRL-M Terminates current input (carriage return). +.sp +.ti -11 +CTRL-R Retypes current command line: types a clean line character +deletion with rubouts. +.sp +.ti -11 +CTRL-U Deletes the entire line typed at the console. +.sp +.ti -11 +CTRL-X Same as CTRL-U. +.sp +.ti -11 +CTRL-Z Ends input from the console (used in PIP and ED). +.sp +.ti -11 +rub/del Deletes and echos the last character typed at the +console. +.in 0 +.ll 65 +.sp +.pp +Suppose the memory buffer contains the characters shown in the +previous section, with the CP following the last character of the +buffer. In the following example, the command strings on the left produce +the results shown to the right. Use lower-case command letters to avoid +automatic translation of strings to upper-case. +.sp 2 + Command String Effect +.sp +.fi +.in 20 +.ll 60 +.ti -15 +B2T Move to beginning of the buffer and type two lines: +.nf +.sp +NOW IS THE +TIME FOR +.fi +The result in the memory buffer is +.sp +.nf +NOW IS THE +TIME FOR +ALL GOOD MEN +.fi +.in 0 +.bp + Command String Effect +.in 20 +.sp +.ti -15 +5C0T Move CP five characters and type the beginning of the line NOW +I. The result in the memory buffer is +.sp +NOW I S THE +.sp 2 +.ti -15 +2L-T Move two lines down and type the previous line TIME FOR. +The result in the memory buffer is +.sp +.nf +NOW IS THE +TIME FOR +ALL GOOD MEN +.fi +.sp 2 +.ti -15 +-L#K Move up one line, delete 65535 lines that follow. The result +in the memory buffer is +.sp +NOW IS THE +.sp 2 +.ti -15 +I Insert two lines of text with automatic +.ti -15 +TIME TO translation to upper-case. The result in +.ti -15 +INSERT the memory buffer is +.ti -15 +^Z +.sp +.nf +NOW IS THE +TIME TO +INSERT +.fi +.sp 2 +.ti -15 +-2L#T Move up two lines and type 65535 lines ahead of CP NOW IS THE. +The result in the memory buffer is +.sp +.nf +NOW IS THE +TIME TO +INSERT +.fi +.sp 2 +.ti -15 + Move down one line and type one line INSERT. The result in +the memory buffer is +.sp +.nf +NOW IS THE +TIME TO +INSERT +.fi +.in 0 +.ll 65 +.bp +.tc 2.1.7 Text Search and Alteration +.sh +2.1.7 Text Search and Alteration +.qs +.pp +ED has a command that locates strings within the memory +buffer. The command takes the form +.sp +.nf +.ti 8 +nF s +or +.ti 8 +nF s ^Z +.fi +.sp +where s represents the string to match, followed by either a +or CTRL-Z, denoted by ^Z. ED starts at the current position +of CP and attempts to match the string. The match is attempted n +times and, if successful, the CP is moved directly after the +string. If the n matches are not successful, the CP is not moved +from its initial position. Search strings can include CTRL-L, +which is replaced by the pair of symbols . +.pp +The following commands illustrate the use of the F command: +.sp 2 + Command String Effect +.in 20 +.sp +.ll 60 +.ti -15 +B#T Move to the beginning and type the entire buffer. The result +in the memory buffer is +.sp +.nf +NOW IS THE +TIME FOR +ALL GOOD MEN +.fi +.sp 2 +.ti -15 +FS T Find the end of the string S T. The result in the memory +buffer is +.nf +.sp +NOW IS T HE +.fi +.sp 2 +.ti -15 +FIs^Z0TT Find the next I and type to the CP; then type the remainder +of the current line ME FOR. The result in the memory buffer is +.nf +.sp +NOW IS THE +TI ME FOR + +ALL GOOD MEN +.fi +.in 0 +.ll 65 +.sp +.pp +An abbreviated form of the insert command is also allowed, which +is often used in conjunction with the F command to make simple +textual changes. The form is +.sp +.ti 8 +.nf +| s ^Z +or +.ti 8 +| s +.fi +.sp +where s is the string to insert. If the insertion string is +terminated by a CTRL-Z, the string is inserted directly following +the CP, and the CP is positioned directly after the string. The +action is the same if the command is followed by a except +that a is automatically inserted into the text following +the string. The following command sequences are examples +of the F and I commands: +.sp 2 + Command String Effect +.in 20 +.ll 60 +.sp +.ti -15 +BITHIS IS ^Z +.sp +Insert THIS IS at the beginning of the text. The result in the +memory buffer is +.sp +THIS IS NOW THE +.nf + +TIME FOR +ALL GOOD MEN +.sp 2 +.fi +.ti -15 +FTIME^Z-4DIPLACE^Z +.sp +Find TIME and delete it; then insert PLACE. The result in the memory +buffer is +.nf +.sp +THIS IS NOW THE +PLACE FOR + +ALL GOOD MEN +.sp 2 +.ti -15 +3FO^Z-3D5D1 +.fi +.ti -15 +CHANGES^Z Find third occurrence of O (that is, the +second O in GOOD), +delete previous 3 characters and the subsequent 5 characters; then insert +CHANGES. The result in the memory buffer is +.nf +.sp +THIS IS NOW THE +PLACE FOR +ALL CHANGES +.fi +.sp 2 +.ti -15 +-8CISOURCE +.sp +Move back 8 characters and insert the line SOURCE. The result in the +memory buffer is +.nf +.sp +THIS IS NOW THE +PLACE FOR +ALL SOURCE + CHANGES +.fi +.ll 65 +.in 0 +.sp +.pp +ED also provides a single command that combines the F and I +commands to perform simple string substitutions. The command +takes the following form: +.sp +.nf +.ti 8 +nS s\d1\u^Zs\d2\u +or +.ti 8 +nS s\d1\u^Zs\d2\u ^Z +.fi +.sp +and has exactly the same effect as applying the following command +string a total of n times: +.sp +.nf +.ti 8 +F s\d1\u^Z-kDIs\d2 +or +.ti 8 +F s\d1\u^Z-kDIs\d2\u ^Z +.fi +.sp +where k is the length of the string. ED searches the +memory buffer starting at the current position of CP and +successively substitutes the second string for the first string +until the end of buffer, or until the substitution has been +performed n times. +.pp +As a convenience, a command similar to F is provided by ED that +automatically appends and writes lines as the search proceeds. +The form is +.sp +.nf +.ti 8 +n N s +or +.ti 8 +n N s ^Z +.fi +.sp +which searches the entire source file for the nth occurrence of +the strings (you should recall that F fails if the string +cannot be found in the current buffer). The operation of the N +command is precisely the same as F except in the case that the +string cannot be found within the current memory buffer. In this +case, the entire memory content is written (that is, an automatic #W +is issued). Input lines are then read until the buffer is at +least half full, or the entire source file is exhausted. The +search continues in this manner until the string has been found n +times, or until the source file has been completely transferred to +the temporary file. +.pp +A final line editing function, called the juxtaposition command, +takes the form +.sp +.nf +.ti 8 +n J s\d1\u^Zs\d2\u^Zs\d3\u +or +.ti 8 +n J s\d1\u^Zs\d2\u^Zs\d3\u ^Z +.fi +.sp +with the following action applied n times to the memory buffer: search from +the current CP for the next occurrence of the string s1. If found, +insert the string s2, and move CP to follow s2. Then delete all +characters following CP up to, but not including, the string s\d3\u, leaving +CP directly after s\d2\u. If s\d3\u cannot be found, then no deletion is +made. If the current line is +.sp 4 +.ti 8 +.nf +NOW IS THE TIME +.sp +the command +.sp +.ti 8 +JW ^ZWHAT^Z^1 +.sp +results in +.sp +.ti 8 +NOW WHAT +.fi +.sp +You should recall that ^1 (CTRL-L) represents the pair + in search and substitute strings. +.pp +The number of characters ED allows in the F, S, N, and J +commands is limited to 100 symbols. +.sp 2 +.tc 2.1.8 Source Libraries +.sh +2.1.8 Source Libraries +.qs +.pp +ED also allows the inclusion of source libraries during the +editing process with the R command. The form of this command is +.sp +.nf +.ti 8 +R filename ^Z +or +.ti 8 +R filename +.fi +.sp +where filename is the primary filename of a source file on the +disk with an assumed filetype of LIB. ED reads the specified +file, and places the characters into the memory buffer after CP, +in a manner similar to the I command. Thus, if the command +.sp +.ti 8 +RMACRO +.sp +is issued by the operator, ED reads from the file MACRO.LIB until +the end-of-file and automatically inserts the characters into the +memory buffer. +.pp +ED also includes a block move facility implemented through the +X (Transfer) command. The form +.sp +.ti 8 +nX +.sp +transfers the next n lines from the current line to a temporary +file called +.sp +.ti 8 +X$$$$$$.LIB +.sp +which is active only during the editing process. You can +reposition the current line reference to any portion of +the source file and transfer lines to the temporary file. The +transferred lines accumulate one after another in this file and +can be retrieved by simply typing +.sp +.ti 8 +R +.sp +which is the trivial case of the library read command. In this +case, the entire transferred set of lines is read into the memory +buffer. Note that the X command does not remove +the transferred lines from the memory buffer, although a K +command can be used directly after the X, and the R command does +not empty the transferred LIB file. That is, given that a set of +lines has been transferred with the X command, they can be +reread any number of times back into the source file. The +command +.sp +.ti 8 +0X +.sp +is provided to empty the transferred line file. +.pp +Note that upon normal completion of the ED +program through Q or E, the temporary LIB file is removed. If ED +is aborted with a CTRL-C, the LIB file will exist if lines have +been transferred, but will generally be empty (a subsequent ED +invocation will erase the temporary file). +.sp 2 +.tc 2.1.9 Repetitive Command Execution +.sh +2.1.9 Repetitive Command Execution +.qs +.pp +The macro command M allows you to group ED commands +together for repeated evaluation. The M command takes the following form: +.sp +.nf +.ti 8 +n M CS +or +.ti 8 +n M CS ^Z +.sp +.fi +where CS represents a string of ED commands, not including +another M command. ED executes the command string n times if +n>1. If n=0 or 1, the command string is executed repetitively +until an error condition is encountered (for example, the end of the +memory buffer is reached with an F command). +.pp +As an example, the following macro changes all occurrences of +GAMMA to DELTA within the current buffer, and types each line +that is changed: +.sp +.ti 8 +MFGAMMA^Z-5DIDELTA^Z0TT +.sp +or equivalently +.sp +.ti 8 +MSGAMMA^ZDELTA^Z0TT +.sp 2 +.tc 2.2 ED Error Conditions +.he CP/M Operating System Manual 2.2 ED Error Conditions +.sh +2.2 ED Error Conditions +.qs +.pp +On error conditions, ED prints the message BREAK X AT C where X +is one of the error indicators shown in Table 2-4. +.bp +.ce +.sh +Table 2-4. Error Message Symbols +.sp + Symbol Meaning +.sp +.ll 62 +.in 15 +.ti -10 +? Unrecognized command. +.sp +.ti -10 +> Memory buffer full (use one of the commands D, K, N, S, +or W to remove characters); F, N, or S strings too long. +.sp +.ti -10 +# Cannot apply command the number of times specified +(for example, in F command). +.sp +.ti -10 +O Cannot open LIB file in R command. +.in 0 +.ll 65 +.sp 2 +If there is a disk error, CP/M displays the following message: +.sp +.ti 8 +BDOS ERR on d: BAD SECTOR +.sp +You can choose to ignore the error by pressing RETURN +at the console (in this case, the memory buffer data +should be examined to see if they were incorrectly read), or you +can reset the system with a CTRL-C and reclaim the back-up file +if it exists. The file can be reclaimed by first typing the +contents of the BAK file to ensure that it contains the proper +information. For example, type the following: +.sp +.ti 8 +TYPE x.BAK +.sp +where x is the file being edited. Then remove the primary file +.sp +.ti 8 +ERA x.y +.sp +and rename the BAK file +.sp +.ti 8 +REN x.y=x.BAK +.sp +The file can then be reedited, starting with the previous +version. +.pp +ED also takes file attributes into account. If you +attempt to edit a Read-Only file, the message +.sp +.ti 8 +** FILE IS READ/ONLY ** +.sp +appears at the console. The file can be loaded and examined, but +cannot be altered. You must end the edit +session and use STAT to change the file attribute to R/W. If +the edited file has the system attribute set, the following message: +.sp +.ti 8 +'SYSTEM' FILE NOT ACCESSIBLE +.sp +is displayed and the edit session is aborted. Again, the STAT +program can be used to change the system attribute, if desired. +.sp 2 +.tc 2.3 Control Characters and Commands +.he CP/M Operating System Manual 2.3 Control Characters and Commands +.sh +2.3 Control Characters and Commands +.qs +.pp +Table 2-5 summarizes the control characters and +commands available in ED. +.sp 2 +.ce +.sh +Table 2-5. ED Control Characters +.sp +.ll 60 +.nf + Control Function + Character +.sp +.fi +.in 20 +.ti -16 +CTRL-C System reboot +.sp +.ti -16 +CTRL-E Physical (not actually entered +in command) +.sp +.ti -16 +CTRL-H Backspace +.sp +.ti -16 +CTRL-J Logical tab (cols 1, 9, 16, ...) +.sp +.ti -16 +CTRL-L Logical in search and +substitute strings +.sp +.ti -16 +CTRL-R Repeat line +.sp +.ti -16 +CTRL-U Line delete +.sp +.ti -16 +CTRL-X Line delete +.sp +.ti -16 +CTRL-Z String terminator +.sp +.ti -16 +rub/del Character delete +.sp +.in 0 +.ll 65 +.pp +Table 2-6 summarizes the commands used in ED. +.sp 2 +.ce +.sh +Table 2-6. ED Commands +.sp +.nf + Command Function +.ll 60 +.fi +.sp +.in 20 +.ti -16 + nA Append lines +.sp +.ti -16 + +\b_B Begin or bottom of buffer +.sp +.ti -16 + +\b_nC Move character positions +.sp +.ti -16 + +\b_nD Delete characters +.sp +.ti -16 + E End edit and close files (normal end) +.sp +.ti -16 + nF Find string +.bp +.in 0 +.ll 65 +.ce +.sh +Table 2-6. (continued) +.sp + Command Function +.ll 60 +.in 20 +.sp +.ti -16 + H End edit, close and reopen files +.sp +.ti -16 + I Insert characters, use i if both upper +and lower-case characters are to be entered. +.sp +.ti -16 + nJ Place strings in juxtaposition +.sp +.ti -16 + +\b_nK Kill lines +.sp +.ti -16 + +\b_nL Move down/up lines +.sp +.ti -16 + nM Macro definition +.sp +.ti -16 + nN Find next occurrence with autoscan +.sp +.ti -16 + O Return to original file +.sp +.ti -16 + +\b_nP Move and print pages +.sp +.ti -16 + Q Quit with no file changes +.sp +.ti -16 + R Read library file +.sp +.ti -16 + nS Substitute strings +.sp +.ti -16 + +\b_nT Type lines +.sp +.ti -16 + +\b_U Translate lower- to upper-case if U, +no translation if -U +.sp +.ti -16 + +\b_V Verify line numbers, or show +remaining free character space +.sp +.ti -16 + 0V A special case of the V command, OV, +prints the memory buffer statistics in the form +.sp +free/total +.sp +where free is the number of free bytes in the memory buffer (in +decimal) and total is the size of the memory buffer +.sp +.ti -16 + nW Write lines +.sp +.ti -16 + nZ Wait (sleep) for approximately n +seconds +.sp +.ti -16 + +\b_n Move and type (+\b_nLT). +.in 0 +.ll 65 +.sp +.pp +Because of common typographical errors, ED requires several +potentially disastrous commands to be typed as single letters, +rather than in composite commands. The following commands: +.sp +.nf +.in 3 +o E(end) +o H(head) +o O(original) +o Q(quit) +.fi +.in 0 +.sp +must be typed as single letter commands. +.pp +The commands I, J, M, N, R, and S should be typed as i, j, m, n, +r, and s if both upper- and lower-case characters are used in the +operation, otherwise all characters are converted to upper-case. +When a command is entered in upper-case, ED automatically +converts the associated string to upper-case, and vice versa. +.sp 2 +.ce +End of Section 2 +.nx threea + + + + + \ No newline at end of file diff --git a/Doc/Source/Character Emulation Video Services.vsd b/Source/Doc/Character Emulation Video Services.vsd similarity index 100% rename from Doc/Source/Character Emulation Video Services.vsd rename to Source/Doc/Character Emulation Video Services.vsd diff --git a/Source/Doc/Clean.cmd b/Source/Doc/Clean.cmd new file mode 100644 index 00000000..0519b003 --- /dev/null +++ b/Source/Doc/Clean.cmd @@ -0,0 +1,7 @@ +@echo off +setlocal + +setlocal & pushd CPM 22 Manual && call Clean.cmd & endlocal +setlocal & pushd ZCPR Manual && call Clean.cmd & endlocal +setlocal & pushd RomWBW User Guide && call Clean.cmd & endlocal +setlocal & pushd RomWBW System Guide && call Clean.cmd & endlocal diff --git a/Doc/Source/RomWBW Architecture.docx b/Source/Doc/RomWBW Architecture.docx similarity index 100% rename from Doc/Source/RomWBW Architecture.docx rename to Source/Doc/RomWBW Architecture.docx diff --git a/Source/Doc/RomWBW System Guide/Build.cmd b/Source/Doc/RomWBW System Guide/Build.cmd new file mode 100644 index 00000000..3413f3fc --- /dev/null +++ b/Source/Doc/RomWBW System Guide/Build.cmd @@ -0,0 +1,19 @@ +@echo off +setlocal + +rem set MIKTEX_HOME=D:\miktex-portable\texmfs\install + +rem if "%MIKTEX_HOME%"=="" goto :eof + +rem set TEXSYSTEM=miktex +rem set MIKTEX_BINDIR=%MIKTEX_HOME%\miktex\bin +rem set MIKTEX_COMMONSTARTUPFILE=%MIKTEX_HOME%\miktex\config\miktexstartup.ini +rem set MIKTEX_GS_LIB=%MIKTEX_HOME%\ghostscript\base;%MIKTEX_HOME%\fonts +rem set MIKTEX_USERSTARTUPFILE=%MIKTEX_HOME%\miktex\config\miktexstartup.ini +rem set PATH=%MIKTEX_HOME%\miktex\bin;%PATH% + +call texify -p --clean Main.ltx + +if errorlevel 1 goto :eof + +move /Y Main.pdf "..\..\..\Doc\RomWBW System Guide.pdf" \ No newline at end of file diff --git a/Doc/Source/RomWBW System Guide/Clean.cmd b/Source/Doc/RomWBW System Guide/Clean.cmd similarity index 100% rename from Doc/Source/RomWBW System Guide/Clean.cmd rename to Source/Doc/RomWBW System Guide/Clean.cmd diff --git a/Doc/Source/RomWBW System Guide/Generate.cmd b/Source/Doc/RomWBW System Guide/Generate.cmd similarity index 100% rename from Doc/Source/RomWBW System Guide/Generate.cmd rename to Source/Doc/RomWBW System Guide/Generate.cmd diff --git a/Doc/Source/RomWBW System Guide/Logo.png b/Source/Doc/RomWBW System Guide/Logo.png similarity index 100% rename from Doc/Source/RomWBW System Guide/Logo.png rename to Source/Doc/RomWBW System Guide/Logo.png diff --git a/Doc/Source/RomWBW System Guide/Main.ltx b/Source/Doc/RomWBW System Guide/Main.ltx similarity index 100% rename from Doc/Source/RomWBW System Guide/Main.ltx rename to Source/Doc/RomWBW System Guide/Main.ltx diff --git a/Doc/Source/RomWBW User Guide/BoardNotes.ltx b/Source/Doc/RomWBW User Guide/BoardNotes.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/BoardNotes.ltx rename to Source/Doc/RomWBW User Guide/BoardNotes.ltx diff --git a/Source/Doc/RomWBW User Guide/Build.cmd b/Source/Doc/RomWBW User Guide/Build.cmd new file mode 100644 index 00000000..3218fc6c --- /dev/null +++ b/Source/Doc/RomWBW User Guide/Build.cmd @@ -0,0 +1,19 @@ +@echo off +setlocal + +rem set MIKTEX_HOME=D:\miktex-portable\texmfs\install + +rem if "%MIKTEX_HOME%"=="" goto :eof + +rem set TEXSYSTEM=miktex +rem set MIKTEX_BINDIR=%MIKTEX_HOME%\miktex\bin +rem set MIKTEX_COMMONSTARTUPFILE=%MIKTEX_HOME%\miktex\config\miktexstartup.ini +rem set MIKTEX_GS_LIB=%MIKTEX_HOME%\ghostscript\base;%MIKTEX_HOME%\fonts +rem set MIKTEX_USERSTARTUPFILE=%MIKTEX_HOME%\miktex\config\miktexstartup.ini +rem set PATH=%MIKTEX_HOME%\miktex\bin;%PATH% + +call texify -p --clean Main.ltx + +if errorlevel 1 goto :eof + +move /Y Main.pdf "..\..\..\Doc\RomWBW User Guide.pdf" \ No newline at end of file diff --git a/Doc/Source/RomWBW User Guide/Clean.cmd b/Source/Doc/RomWBW User Guide/Clean.cmd similarity index 100% rename from Doc/Source/RomWBW User Guide/Clean.cmd rename to Source/Doc/RomWBW User Guide/Clean.cmd diff --git a/Doc/Source/RomWBW User Guide/Customization.ltx b/Source/Doc/RomWBW User Guide/Customization.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/Customization.ltx rename to Source/Doc/RomWBW User Guide/Customization.ltx diff --git a/Doc/Source/RomWBW User Guide/DiskUsage.ltx b/Source/Doc/RomWBW User Guide/DiskUsage.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/DiskUsage.ltx rename to Source/Doc/RomWBW User Guide/DiskUsage.ltx diff --git a/Doc/Source/RomWBW User Guide/Features.ltx b/Source/Doc/RomWBW User Guide/Features.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/Features.ltx rename to Source/Doc/RomWBW User Guide/Features.ltx diff --git a/Doc/Source/RomWBW User Guide/FormatSamples.ltx b/Source/Doc/RomWBW User Guide/FormatSamples.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/FormatSamples.ltx rename to Source/Doc/RomWBW User Guide/FormatSamples.ltx diff --git a/Doc/Source/RomWBW User Guide/GFDL.ltx b/Source/Doc/RomWBW User Guide/GFDL.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/GFDL.ltx rename to Source/Doc/RomWBW User Guide/GFDL.ltx diff --git a/Doc/Source/RomWBW User Guide/GPL.ltx b/Source/Doc/RomWBW User Guide/GPL.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/GPL.ltx rename to Source/Doc/RomWBW User Guide/GPL.ltx diff --git a/Doc/Source/RomWBW User Guide/Generate.cmd b/Source/Doc/RomWBW User Guide/Generate.cmd similarity index 100% rename from Doc/Source/RomWBW User Guide/Generate.cmd rename to Source/Doc/RomWBW User Guide/Generate.cmd diff --git a/Doc/Source/RomWBW User Guide/GettingStarted.ltx b/Source/Doc/RomWBW User Guide/GettingStarted.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/GettingStarted.ltx rename to Source/Doc/RomWBW User Guide/GettingStarted.ltx diff --git a/Doc/Source/RomWBW User Guide/Licensing.ltx b/Source/Doc/RomWBW User Guide/Licensing.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/Licensing.ltx rename to Source/Doc/RomWBW User Guide/Licensing.ltx diff --git a/Doc/Source/RomWBW User Guide/Logo.png b/Source/Doc/RomWBW User Guide/Logo.png similarity index 100% rename from Doc/Source/RomWBW User Guide/Logo.png rename to Source/Doc/RomWBW User Guide/Logo.png diff --git a/Doc/Source/RomWBW User Guide/Main.ltx b/Source/Doc/RomWBW User Guide/Main.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/Main.ltx rename to Source/Doc/RomWBW User Guide/Main.ltx diff --git a/Doc/Source/RomWBW User Guide/OperatingSystems.ltx b/Source/Doc/RomWBW User Guide/OperatingSystems.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/OperatingSystems.ltx rename to Source/Doc/RomWBW User Guide/OperatingSystems.ltx diff --git a/Doc/Source/RomWBW User Guide/Overview.ltx b/Source/Doc/RomWBW User Guide/Overview.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/Overview.ltx rename to Source/Doc/RomWBW User Guide/Overview.ltx diff --git a/Doc/Source/RomWBW User Guide/SystemMonitor.ltx b/Source/Doc/RomWBW User Guide/SystemMonitor.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/SystemMonitor.ltx rename to Source/Doc/RomWBW User Guide/SystemMonitor.ltx diff --git a/Doc/Source/RomWBW User Guide/x - Copy (8).ltx b/Source/Doc/RomWBW User Guide/x - Copy (8).ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/x - Copy (8).ltx rename to Source/Doc/RomWBW User Guide/x - Copy (8).ltx diff --git a/Doc/Source/RomWBW User Guide/x - Copy.ltx b/Source/Doc/RomWBW User Guide/x - Copy.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/x - Copy.ltx rename to Source/Doc/RomWBW User Guide/x - Copy.ltx diff --git a/Doc/Source/RomWBW User Guide/x.ltx b/Source/Doc/RomWBW User Guide/x.ltx similarity index 100% rename from Doc/Source/RomWBW User Guide/x.ltx rename to Source/Doc/RomWBW User Guide/x.ltx diff --git a/Doc/Source/WBW.png b/Source/Doc/WBW.png similarity index 100% rename from Doc/Source/WBW.png rename to Source/Doc/WBW.png diff --git a/Doc/Source/WBW.vsdx b/Source/Doc/WBW.vsdx similarity index 100% rename from Doc/Source/WBW.vsdx rename to Source/Doc/WBW.vsdx diff --git a/Source/Doc/ZCPR Manual/Build.cmd b/Source/Doc/ZCPR Manual/Build.cmd new file mode 100644 index 00000000..84086e9b --- /dev/null +++ b/Source/Doc/ZCPR Manual/Build.cmd @@ -0,0 +1,19 @@ +@echo off +setlocal + +rem set MIKTEX_HOME=D:\miktex-portable\texmfs\install + +rem if "%MIKTEX_HOME%"=="" goto :eof + +rem set TEXSYSTEM=miktex +rem set MIKTEX_BINDIR=%MIKTEX_HOME%\miktex\bin +rem set MIKTEX_COMMONSTARTUPFILE=%MIKTEX_HOME%\miktex\config\miktexstartup.ini +rem set MIKTEX_GS_LIB=%MIKTEX_HOME%\ghostscript\base;%MIKTEX_HOME%\fonts +rem set MIKTEX_USERSTARTUPFILE=%MIKTEX_HOME%\miktex\config\miktexstartup.ini +rem set PATH=%MIKTEX_HOME%\miktex\bin;%PATH% + +call texify -p --clean "Main.ltx" + +if errorlevel 1 goto :eof + +move /Y Main.pdf "..\..\..\Doc\ZCPR Manual.pdf" \ No newline at end of file diff --git a/Source/Doc/ZCPR Manual/Clean.cmd b/Source/Doc/ZCPR Manual/Clean.cmd new file mode 100644 index 00000000..333e8f7a --- /dev/null +++ b/Source/Doc/ZCPR Manual/Clean.cmd @@ -0,0 +1,7 @@ +@echo off +if exist *.pdf del *.pdf +if exist *.prn del *.prn +if exist *.ix del *.ix +if exist *.log del *.log +if exist part?.txt del part?.txt +if exist *.synctex.gz del *.synctex.gz diff --git a/Source/Doc/ZCPR Manual/Main.ltx b/Source/Doc/ZCPR Manual/Main.ltx new file mode 100644 index 00000000..2cc18498 --- /dev/null +++ b/Source/Doc/ZCPR Manual/Main.ltx @@ -0,0 +1,25 @@ +\documentclass[letterpaper,10pt,oneside]{book} +\usepackage[T1]{fontenc} +%\usepackage[defaultmono]{droidmono} +\usepackage[scaled]{beramono} +\usepackage{fancyvrb} +\usepackage{geometry} +\usepackage{pdflscape} +%\usepackage{showframe} % Diagnostic + +% Suppress headers and footers completely +\pagestyle{empty} + +% 66 lines per page, portrait +\geometry{top=0.0in, bottom=0.0in, left=1.5in, right=1.5in} + +\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput} +{ + commandchars=\\\{\} +} + +\begin{document} + +\VerbatimInput{zcpr.ltx} + +\end{document} \ No newline at end of file diff --git a/Doc/Reference/zcpr.doc b/Source/Doc/ZCPR Manual/zcpr.ltx similarity index 95% rename from Doc/Reference/zcpr.doc rename to Source/Doc/ZCPR Manual/zcpr.ltx index 940508d3..732f43a7 100644 --- a/Doc/Reference/zcpr.doc +++ b/Source/Doc/ZCPR Manual/zcpr.ltx @@ -1,3 +1,6 @@ + + + ZCPR - A Z80 Replacement for the CP/M CCP @@ -5,7 +8,7 @@ - Documentation on ZCPR - A Z80 Replacement for the CP/M CCP + \textbf{Documentation on ZCPR - A Z80 Replacement for the CP/M CCP} @@ -68,7 +71,7 @@ - Documentation on ZCPR - A Z80 Replacement for the CP/M CCP + \textbf{Documentation on ZCPR - A Z80 Replacement for the CP/M CCP} @@ -238,6 +241,7 @@ integration is the placement of the new ZCPR onto disk in the proper place so that it will be loaded with the rest of CP/M on cold boot and executed properly. + To find the original CCP, you typically have to locate it by its appearance. It is probably stored contiguously on disk, so, once it is found, a sequential overwrite is all that is required. @@ -255,7 +259,6 @@ CCP. The CCP will probably start on an even page or half-page address (like 900H, 980H, 1100H, etc). - Page 4 @@ -368,7 +371,7 @@ -^C <-- Return to CP/M; I know that CPRLOC will be BD00H and the IMAGE offset is 1100H - B>ed cpr.asm {edit ZCPR here and place CPRLOC=BD00H}# + B>ed cpr.asm \{edit ZCPR here and place CPRLOC=BD00H\}# -- Detail Left Out -- B>mac cpr $pz sz <-- Now to assemble the CPR @@ -744,7 +747,7 @@ To illustrate this command hierarchy search, consider the following examples: - Example 1: DEFUSR equ 0 {default user number is 0} + Example 1: DEFUSR equ 0 \{default user number is 0\} B10> <-- User is on Drive B:, User Number 10 B10>ASM TEST.BBZ <-- User wishes to assemble TEST.ASM in @@ -810,9 +813,9 @@ issued from the console (or Indirect Command File): B10>WM TEST2.TXT - \ \ \__ File to be edited - \ \__ Invoke the WM.COM file (Word Master editor) - \__ User is on Drive B: in User Area 10 + ^ ^ ^-------- File to be edited + | +----------- Invoke the WM.COM file (Word Master editor) + +--------------- User is on Drive B: in User Area 10 Results: ZCPR searches B: User 10, B: User 0, and A: User 0 for @@ -820,8 +823,8 @@ back into B: User 10, and executes it. B10>MBASIC - \ \__ Invoke the MBASIC.COM file (MBASIC Interpreter) - \__ User is on Drive B: in User Area 10 + ^ ^----- Invoke the MBASIC.COM file (MBASIC Interpreter) + +--------- User is on Drive B: in User Area 10 Results: ZCPR searches B: User 10 and B: User 0 for MBASIC.COM; @@ -830,8 +833,8 @@ in the previous example. B10>TEST - \ \__ Invoke the TEST.COM file (TEST program) - \__ User is on Drive B: in User Area 10 + ^ ^--- Invoke the TEST.COM file (TEST program) + +------- User is on Drive B: in User Area 10 Results: ZCPR searches B: User 10 for TEST.COM; it finds @@ -840,8 +843,8 @@ then loaded and executed as described above. B10>TEST2 - \ \__ Invoke the TEST2.COM file (TEST2 program) - \__ User is on Drive B: in User Area 10 + | +--- Invoke the TEST2.COM file (TEST2 program) + +------- User is on Drive B: in User Area 10 Results: ZCPR searches B: User 10, B: User 0, and A: User 0 for @@ -1378,10 +1381,4 @@ - Page 21 - - - - - - \ No newline at end of file + Page 21 \ No newline at end of file diff --git a/Source/HBIOS/fd.asm b/Source/HBIOS/fd.asm index 6a91923f..7dc17831 100644 --- a/Source/HBIOS/fd.asm +++ b/Source/HBIOS/fd.asm @@ -1514,14 +1514,16 @@ FXR_NULL1: ; READ DATA ; FXR_READ: + HB_DI ; TIME CRITICAL , INTERRUPTS WILL CAUSE I/O ERRS LD HL,(FD_DSKBUF) ; POINT TO SECTOR BUFFER START LD DE,(FCD_SECSZ) ; TIMEOUT COUNTER IS CPU MHZ / 4 (MAKING SURE IT IS AT LEAST 1) ; LD A,(CPUMHZ + 3) / 4 - LD A,(HCB_CPUMHZ) ; GET CPU SPEED IN MHZ + LD A,(CB_CPUMHZ) ; GET CPU SPEED IN MHZ + ADD A,3 ; ROUND UP SRL A ; SHIFT RIGHT TWICE SRL A ; ... TO DIVIDE BY 4 - INC A ; MAKE SURE RESULT IS AT LEAST 1 + ;INC A ; MAKE SURE RESULT IS AT LEAST 1 LD (FCD_TO),A ; INIT TIMEOUT COUNTER FXRR1 LD C,0 ; OUTER LOOP TIMEOUT COUNTER FXRR2: LD B,0 ; SETUP FOR 256 ITERATIONS @@ -1554,14 +1556,16 @@ FXRR5: ; OUTER LOOP, REALLY ONLY HAPPENS WHEN WAITING FOR FIRST BYTE OR ABOR ; WRITE DATA ; FXR_WRITE: + HB_DI ; TIME CRITICAL , INTERRUPTS WILL CAUSE I/O ERRS LD HL,(FD_DSKBUF) ; POINT TO SECTOR BUFFER START LD DE,(FCD_SECSZ) ; TIMEOUT COUNTER IS CPU MHZ / 4 (MAKING SURE IT IS AT LEAST 1) ; LD A,(CPUMHZ + 3) / 4 - LD A,(HCB_CPUMHZ) ; GET CPU SPEED IN MHZ + LD A,(CB_CPUMHZ) ; GET CPU SPEED IN MHZ + ADD A,3 ; ROUND UP SRL A ; SHIFT RIGHT TWICE SRL A ; ... TO DIVIDE BY 4 - INC A ; MAKE SURE RESULT IS AT LEAST 1 + ;INC A ; MAKE SURE RESULT IS AT LEAST 1 LD (FCD_TO),A FXRW1 LD C,0 ; OUTER LOOP TIMEOUT COUNTER FXRW2: LD B,0 ; SETUP FOR 256 ITERATIONS @@ -1600,10 +1604,12 @@ FXR_ABORT: ; COMMON COMPLETION CODE FOR ALL EXECUTION ROUTINES ; FXR_ERR: + HB_EI ; INTERRUPTS OK AGAIN LD (FST_RC),A RET FXR_END: + HB_EI ; INTERRUPTS OK AGAIN CALL FC_PULSETC RET diff --git a/Source/HBIOS/hbios.asm b/Source/HBIOS/hbios.asm index e7b81486..fac52fe0 100644 --- a/Source/HBIOS/hbios.asm +++ b/Source/HBIOS/hbios.asm @@ -476,11 +476,11 @@ HBX_INT: ; COMMON INTERRUPT ROUTING CODE LD A,BID_BIOS ; HBIOS BANK CALL HBX_BNKSEL_INT ; SELECT IT - LD SP,HB_ISTACK ; NOW USE INT STACK IN HBIOS BANK + ;LD SP,HB_ISTACK ; NOW USE INT STACK IN HBIOS BANK CALL JPHL ; CALL INTERRUPT ROUTINE - LD SP,HBX_STACK ; USE STACK FRAME IN HI MEM + ;LD SP,HBX_STACK ; USE STACK FRAME IN HI MEM LD A,(HB_CURBNK) ; GET PRE-INT BANK CALL HBX_BNKSEL ; SELECT IT @@ -2936,9 +2936,9 @@ HB_TICKS .FILL 4,0 ; 32 BIT TICK COUNTER ; .FILL HB_STKSIZ,$FF ; 48 ENTRY STACK FOR HBIOS FUNCTION PROCESSING HB_STACK .EQU $ ; TOP OF HBIOS STACK -; - .FILL HB_ISTKSIZ,$FF ; 32 ENTRY STACK FOR INTERRUPT PROCESSING -HB_ISTACK .EQU $ ; TOP OF INTERRUPT PROCESSING STACK +;; +; .FILL HB_ISTKSIZ,$FF ; 32 ENTRY STACK FOR INTERRUPT PROCESSING +;HB_ISTACK .EQU $ ; TOP OF INTERRUPT PROCESSING STACK ; STR_BANNER .DB "RetroBrew HBIOS v", BIOSVER, ", ", TIMESTAMP, "$" STR_PLATFORM .DB PLATFORM_NAME, "$" @@ -2950,7 +2950,6 @@ HB_BCDTMP .FILL 5,0 ; TEMPORARY BCD NUMBER STORAGE ; HB_WRKBUF .FILL 512,0 ; INTERNAL DISK BUFFER ; -;HB_END .EXPORT HB_END ; EXPORT ENDING ADDRESS HB_END .EQU $ ; SLACK .EQU BNKTOP - $ diff --git a/Source/HBIOS/ide.asm b/Source/HBIOS/ide.asm index a362054b..8fa502ac 100644 --- a/Source/HBIOS/ide.asm +++ b/Source/HBIOS/ide.asm @@ -238,7 +238,7 @@ IDE_INIT0: ; AT 1MHZ, THE SCALER IS 961 (50000US / 52TS = 961) ; SCALER IS THEREFORE 961 * CPU SPEED IN MHZ LD DE,961 ; LOAD SCALER FOR 1MHZ - LD A,(HCB + HCB_CPUMHZ) ; LOAD CPU SPEED IN MHZ + LD A,(CB_CPUMHZ) ; LOAD CPU SPEED IN MHZ CALL MULT8X16 ; HL := DE * A LD (IDE_TOSCALER),HL ; SAVE IT ; diff --git a/Source/HBIOS/ppide.asm b/Source/HBIOS/ppide.asm index 6e578184..f7b5c558 100644 --- a/Source/HBIOS/ppide.asm +++ b/Source/HBIOS/ppide.asm @@ -258,7 +258,7 @@ PPIDE_INIT0: ; AT 1MHZ, THE SCALER IS 218 (50000US / 229TS = 218) ; SCALER IS THEREFORE 218 * CPU SPEED IN MHZ LD DE,218 ; LOAD SCALER FOR 1MHZ - LD A,(HCB + HCB_CPUMHZ) ; LOAD CPU SPEED IN MHZ + LD A,(CB_CPUMHZ) ; LOAD CPU SPEED IN MHZ CALL MULT8X16 ; HL := DE * A LD (PPIDE_TOSCALER),HL ; SAVE IT ; diff --git a/Tools/Win32 Disk Imager/Changelog.txt b/Tools/Win32 Disk Imager/Changelog.txt new file mode 100644 index 00000000..41358e74 --- /dev/null +++ b/Tools/Win32 Disk Imager/Changelog.txt @@ -0,0 +1,61 @@ +Release 0.9.5 +============= +Update copyright headers, bump for point release +Fixed broken translation (caused build error). +Converted build environment to QT 5.2/Mingw 4.8 +Added Italian translation (LP#1270388) +Added translations. +Start work on installer with Innosetup. + + +Release 0.9 +=========== +Added custom file dialog window. + +Bug fixes: +LP:1118217 - can not select SD card to write image to. +LP:1191156 - File-open dialog does not accept non-existing *.img files as targets. + + +Release 0.8 +=========== +Added drag and drop - Drag a file from Windows Explorer and drop it in the +text window. +Added DiskImagesDir environment variable for default images directory. +Improved startup Downloads directory search. +Add copy button for MD5. + +Bug fixes: +LP:1080880 Add a copy button for MD5. +LP:1157849 - Partial sectors not written. +LP:1117840 Initial startup can take a long time (+20s) due to the "Downloads" find routine. +LP:1118349 Application does not start. +LP:1157849 Partial sectors not written. +SF:1 Application doesn't start. No window appears. +SF:3 No support of russian characters in image file path +SF:5 Very long app opening time + + +Release 0.7 +=========== +Added default directory path pointing to the user's download directory. +Fixed permission settings to require administrator privileges in Vista/7 +Reinstated DiskImager.rc rc file (qmake method lost too many options - may revisit later). +Make MD5Sum selectable for copying. Fixes LP:1080880. +Add version info to the main window. +Cleanup, move winver resources to project file. +Renamed base translation for English. +More translation updates, minor cleanup. +Added translation capabilities. Cleaned up some code formatting (broke up long lines). +Testing changes for UTF16 support. +Clean up mixed indentation types, some minor code cleanup. no functional changes. +Updating the 'driveLabel' stuff to use QString rather than char * on a suggestion from Roland Rudenauer + +Bug fixes: +Fixed LP:1100228 "An error occured while accessing the device. Error1: Incorrect function" +Fixed LP:1102608 "Cannot load images from network shares" +Fixed LP:1095038 "Error message encoding is messed up" +Fixed LP:984510 "Cannot select Device" +Fixed LP:923719 "An error occured while accessing the device. Error1: Incorrect function" +Fixed LP:985080 "C: with windows 7 partition erased with all data" (NOT FULLY VERIFIED) +fixing memory leak diff --git a/Tools/Win32 Disk Imager/GPL-2 b/Tools/Win32 Disk Imager/GPL-2 new file mode 100644 index 00000000..d511905c --- /dev/null +++ b/Tools/Win32 Disk Imager/GPL-2 @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/Tools/Win32 Disk Imager/LGPL-2.1 b/Tools/Win32 Disk Imager/LGPL-2.1 new file mode 100644 index 00000000..602bfc94 --- /dev/null +++ b/Tools/Win32 Disk Imager/LGPL-2.1 @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/Tools/Win32 Disk Imager/License.txt b/Tools/Win32 Disk Imager/License.txt new file mode 100644 index 00000000..7948edca --- /dev/null +++ b/Tools/Win32 Disk Imager/License.txt @@ -0,0 +1,849 @@ +This program is licensed under the GNU GPL Version 2 License. Included libraries are licensed under GPL v2 and LGPL v2.1 accordingly. + + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + + + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/Tools/Win32 Disk Imager/Qt5Core.dll b/Tools/Win32 Disk Imager/Qt5Core.dll new file mode 100644 index 00000000..7cb96caf Binary files /dev/null and b/Tools/Win32 Disk Imager/Qt5Core.dll differ diff --git a/Tools/Win32 Disk Imager/Qt5Gui.dll b/Tools/Win32 Disk Imager/Qt5Gui.dll new file mode 100644 index 00000000..abdd60f9 Binary files /dev/null and b/Tools/Win32 Disk Imager/Qt5Gui.dll differ diff --git a/Tools/Win32 Disk Imager/Qt5Widgets.dll b/Tools/Win32 Disk Imager/Qt5Widgets.dll new file mode 100644 index 00000000..74ab1575 Binary files /dev/null and b/Tools/Win32 Disk Imager/Qt5Widgets.dll differ diff --git a/Tools/Win32 Disk Imager/QtCore4.dll b/Tools/Win32 Disk Imager/QtCore4.dll deleted file mode 100644 index 991dd19a..00000000 Binary files a/Tools/Win32 Disk Imager/QtCore4.dll and /dev/null differ diff --git a/Tools/Win32 Disk Imager/QtGui4.dll b/Tools/Win32 Disk Imager/QtGui4.dll deleted file mode 100644 index 26bf5dde..00000000 Binary files a/Tools/Win32 Disk Imager/QtGui4.dll and /dev/null differ diff --git a/Tools/Win32 Disk Imager/README.txt b/Tools/Win32 Disk Imager/README.txt new file mode 100644 index 00000000..3123e613 --- /dev/null +++ b/Tools/Win32 Disk Imager/README.txt @@ -0,0 +1,65 @@ +Image Writer for Microsoft Windows +Release 0.9.5 - Unnamed Edition 2: The oddly released sequel +====== +About: +====== +This utility is used to write img files to SD and USB memory devices. +Simply run the utility, point it at your img, and then select the +removable device to write to. + +This utility can not write CD-ROMs. + +Future releases and source code are available on our Sourceforge project: +http://sourceforge.net/projects/win32diskimager/ + +This program is Beta , and has no warranty. It may eat your files, +call you names, or explode in a massive shower of code. The authors take +no responsibility for these possible events. + +=================== +Build Instructions: +=================== +Requirements: +1. Now using QT 5.2.1/MinGW 4.8. Snapshot available in the Build Tools directory at +https://sourceforge.net/projects/win32diskimager/files/Build%20Tools/ + +Short Version: +1. Install the Qt Full SDK and use QT Creator to build. Included batch files + no longer updated and may be deleted in the future. + +============= +New Features: +============= +Build support for QT 5.2/MinGW 4.8. +Some additional language translations. +Now uses Innosetup to create an Installer. + +============= +Known Issues: +============= + +* Lack of reformat capabilities. +* Lack of file compression support +* Does not work with USB Floppy drives. + +These are being looked into for future releases. + +====== +Legal: +====== +Image Writer for Windows is licensed under the General Public +License v2. The full text of this license is available in +GPL-2. + +This project uses and includes binaries of the MinGW runtime library, +which is available at http://www.mingw.org + +This project uses and includes binaries of the Qt library, licensed under the +"Library General Public License" and is available at +http://www.qt-project.org/. + +The license text is available in LGPL-2.1 + +Original version developed by Justin Davis +Maintained by the ImageWriter developers (http://sourceforge.net/projects/win32diskimager). + diff --git a/Tools/Win32 Disk Imager/Win32DiskImager.exe b/Tools/Win32 Disk Imager/Win32DiskImager.exe index 05934a62..f257776d 100644 Binary files a/Tools/Win32 Disk Imager/Win32DiskImager.exe and b/Tools/Win32 Disk Imager/Win32DiskImager.exe differ diff --git a/Tools/Win32 Disk Imager/diskimager_cn.qm b/Tools/Win32 Disk Imager/diskimager_cn.qm new file mode 100644 index 00000000..9dad8dff Binary files /dev/null and b/Tools/Win32 Disk Imager/diskimager_cn.qm differ diff --git a/Tools/Win32 Disk Imager/diskimager_en.qm b/Tools/Win32 Disk Imager/diskimager_en.qm new file mode 100644 index 00000000..9dad8dff Binary files /dev/null and b/Tools/Win32 Disk Imager/diskimager_en.qm differ diff --git a/Tools/Win32 Disk Imager/diskimager_it.qm b/Tools/Win32 Disk Imager/diskimager_it.qm new file mode 100644 index 00000000..0c2424b2 Binary files /dev/null and b/Tools/Win32 Disk Imager/diskimager_it.qm differ diff --git a/Tools/Win32 Disk Imager/diskimager_pl.qm b/Tools/Win32 Disk Imager/diskimager_pl.qm new file mode 100644 index 00000000..e7b7c99b Binary files /dev/null and b/Tools/Win32 Disk Imager/diskimager_pl.qm differ diff --git a/Tools/Win32 Disk Imager/icudt51.dll b/Tools/Win32 Disk Imager/icudt51.dll new file mode 100644 index 00000000..f78424b6 Binary files /dev/null and b/Tools/Win32 Disk Imager/icudt51.dll differ diff --git a/Tools/Win32 Disk Imager/icuin51.dll b/Tools/Win32 Disk Imager/icuin51.dll new file mode 100644 index 00000000..7e199ecb Binary files /dev/null and b/Tools/Win32 Disk Imager/icuin51.dll differ diff --git a/Tools/Win32 Disk Imager/icuuc51.dll b/Tools/Win32 Disk Imager/icuuc51.dll new file mode 100644 index 00000000..089ec7d0 Binary files /dev/null and b/Tools/Win32 Disk Imager/icuuc51.dll differ diff --git a/Tools/Win32 Disk Imager/libgcc_s_dw2-1.dll b/Tools/Win32 Disk Imager/libgcc_s_dw2-1.dll index b2c6a7e9..82b27763 100644 Binary files a/Tools/Win32 Disk Imager/libgcc_s_dw2-1.dll and b/Tools/Win32 Disk Imager/libgcc_s_dw2-1.dll differ diff --git a/Tools/Win32 Disk Imager/libstdc++-6.dll b/Tools/Win32 Disk Imager/libstdc++-6.dll index 61c304f7..fcce1f69 100644 Binary files a/Tools/Win32 Disk Imager/libstdc++-6.dll and b/Tools/Win32 Disk Imager/libstdc++-6.dll differ diff --git a/Tools/Win32 Disk Imager/libwinpthread-1.dll b/Tools/Win32 Disk Imager/libwinpthread-1.dll new file mode 100644 index 00000000..22fa8390 Binary files /dev/null and b/Tools/Win32 Disk Imager/libwinpthread-1.dll differ diff --git a/Tools/Win32 Disk Imager/mingwm10.dll b/Tools/Win32 Disk Imager/mingwm10.dll deleted file mode 100644 index 926fb6ca..00000000 Binary files a/Tools/Win32 Disk Imager/mingwm10.dll and /dev/null differ diff --git a/Tools/Win32 Disk Imager/platforms/qwindows.dll b/Tools/Win32 Disk Imager/platforms/qwindows.dll new file mode 100644 index 00000000..ac722ecf Binary files /dev/null and b/Tools/Win32 Disk Imager/platforms/qwindows.dll differ diff --git a/Tools/cpm/bin/TEX21.COM b/Tools/cpm/bin/TEX21.COM new file mode 100644 index 00000000..019db191 Binary files /dev/null and b/Tools/cpm/bin/TEX21.COM differ diff --git a/Tools/cpm/bin/TEX21A.COM b/Tools/cpm/bin/TEX21A.COM new file mode 100644 index 00000000..f2f7bcb5 Binary files /dev/null and b/Tools/cpm/bin/TEX21A.COM differ