{"id":2207,"date":"2018-08-25T00:34:47","date_gmt":"2018-08-25T00:34:47","guid":{"rendered":"http:\/\/www.sydneysmith.com\/wordpress\/?p=2207"},"modified":"2018-08-25T00:34:47","modified_gmt":"2018-08-25T00:34:47","slug":"a-better-ccppatch-for-cp-m-2","status":"publish","type":"post","link":"https:\/\/www.sydneysmith.com\/wordpress\/2207\/a-better-ccppatch-for-cp-m-2\/","title":{"rendered":"A Better CCPPATCH for CP\/M 2"},"content":{"rendered":"<p>A patch was developed many years ago to cause CP\/M 2 to look on drive A: if it couldn&#8217;t find a .COM file. This is probably a precursor to the Windows and MSDOS search PATH command, though unix may have already had a PATH variable.<\/p>\n<p>You can find a copy of the patch to search drive a at: <a href=\"http:\/\/www.classiccmp.org\/cpmarchives\/cpm\/Software\/rlee\/D\/DIGITAL%20RESEARCH\/CPM_2-2\/PATCHES\/\">www.classiccmp.org<\/a>.<\/p>\n<p>BUT it has some side effects. <!--more--><\/p>\n<p>It worked great for me; until I mistyped a command.<\/p>\n<p>This is what you get normally:<code><\/p>\n<pre>\r\nB>dir\r\nNO FILE\r\nB>stat\r\nA: R\/W, Space: 372k\r\nB: R\/W, Space: 490k\r\n\r\n\r\nB><\/pre>\n<p><\/code><\/p>\n<p>This is what you get with a mistyped command:<code><\/p>\n<pre>\r\nB>stap\r\nBdos Err On C: Bad Sector<\/pre>\n<p><\/code><\/p>\n<p>I have two disks in the system (A: and B:) and the patch tries to access drive C.<\/p>\n<p>Here&#8217;s the text of the patch:<br \/>\n<code><\/p>\n<pre>\r\n; This patch causes the CCP of a cp\/m 2.x system to look on drive A\r\n; when you are logged into a drive other than A and call for a .COM\r\n; file that does not exist on that drive.  Giving an explicit drive\r\n; reference overrides this feature, so that you can always force\r\n; the file to be loaded from a specific drive.\r\n;\r\nmsize\tequ\t60\t\t; set this to your nominal system size\r\n;\r\ncpmb\tequ\t(msize-20)*1024+3400h\t; start of CCP in given sys size\r\n;\r\n\torg\tcpmb+6dbh\r\n\tjz\tpatch\t\t; replaces \"jz cpmb+76bh\"\r\n;\r\n\torg\tcpmb+7f2h\t; replaces an unused area of NOP's\r\npatch:\r\n\tlxi\th,cpmb+7f0h\t; get drive from current command\r\n\tora\tm\t\t; accum was 0 on entry, so this fetches drive\r\n\tjnz\tcpmb+76bh\t; command has explicit drive...give error\r\n\tinr\tm\t\t; force explicit reference to drive A\r\n\tlxi\td,cpmb+7d6h\t; we need de set up when we\r\n\tjmp\tcpmb+6cdh\t; re-enter ccp\r\n;\r\n\tend\r\n<\/pre>\n<p><\/code><br \/>\nThe idea is good: if open fails for the .COM file you jump to a patch area, change the drive specifier from 0 (default) to 1 (drive A), and then redo the process. It has enough smarts to exit if there is already a drive specifier (eg if we typed B:PROG). This also prevents loops if the .COM file isn&#8217;t on drive A either (because we now have a drive specifier).<\/p>\n<p>If you look at the code in the CCP that this is patching, you&#8217;ll notice that it is changing a drive setting for the CCP; not just for the .COM file we are trying to run. The &#8216;inr m&#8217; seems to be causing a broader impact (like accessing one more than the current drive &#8211; C: when we are on B:).<\/p>\n<p>I found an alternative approach to work better. For a 64K system (cpmb equ 0E400H, CCP at E400-EBFF) it looks like:<br \/>\n<code><\/p>\n<pre>\r\nEADB:  CAF2EB  JP Z,EBF2\r\n\r\nEBF2:  1A      LD   A,(DE)\r\nEBF3:  B7      OR   A\r\nEBF4:  C26BEB  JP   NZ,EB6B ; to the original error msg\r\nEBF7:  3C      INC  A       ; fcb[0] to 01, ie A:\r\nEBF8:  12      LD   (DE),A\r\nEBF9:  CDD0E4  CALL E4D0    ; retry the open that failed last time\r\nEBFC:  C3DBEA  JP   EADB    ; back to just after last time\r\nEBFF:  00      NOP\r\n<\/pre>\n<p><\/code><br \/>\nFor other memory sizes, subtract 4 from the &#8220;E4&#8221;, &#8220;EA&#8221; and &#8220;EB&#8221; values, for each 1K less. This is what the original &#8220;cpmb &#8230;&#8221; line does.<\/p>\n<p>The CCP is the first thing on a bootable disk after the boot sector. On an 8&#8243; SSSD or DSSD system it is in track 0 sector 2 to sector 17 so use a disk editor to patch sectors 15 (EA80-E400=680=13 sectors) and 17. DD sectors are 200H each so if you&#8217;re using DD disks, both parts will be in sector 5.<\/p>\n<p>I tend to edit disk images directly, using a hex editor in Windows. You could use GETSYS \/ PUTSYS and DDT\/ZSID within CP\/M to make the same changes.<\/p>\n<p>This is what I get normally:<code><\/p>\n<pre>\r\nB>dir\r\nNO FILE\r\nB>stat\r\nA: R\/W, Space: 372k\r\nB: R\/W, Space: 490k\r\n\r\n\r\nB><\/pre>\n<p><\/code><\/p>\n<p>This is what I get with a mistyped command:<code><\/p>\n<pre>\r\nB>stap\r\nSTAP?\r\n\r\nB><\/pre>\n<p><\/code><br \/>\nThe difference is I use the FCB address in DE and check and change the drive specifier for the .COM file instead of for the CCP.<\/p>\n<p>This is part of the <a href=\"http:\/\/www.sydneysmith.com\/wordpress\/cpm-programs\/\">CP\/M topic<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A patch was developed many years ago to cause CP\/M 2 to look on drive A: if it couldn&#8217;t find a .COM file. This is probably a precursor to the Windows and MSDOS search PATH command, though unix may have already had a PATH variable. You can find a copy of the patch to search &hellip; <a href=\"https:\/\/www.sydneysmith.com\/wordpress\/2207\/a-better-ccppatch-for-cp-m-2\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">A Better CCPPATCH for CP\/M 2<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,59],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/2207"}],"collection":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2207"}],"version-history":[{"count":5,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/2207\/revisions"}],"predecessor-version":[{"id":2212,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/2207\/revisions\/2212"}],"wp:attachment":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}