{"id":603,"date":"2009-06-05T00:01:47","date_gmt":"2009-06-05T07:01:47","guid":{"rendered":"http:\/\/www.wambooli.com\/blog\/?p=603"},"modified":"2009-05-31T10:02:42","modified_gmt":"2009-05-31T17:02:42","slug":"your-very-own-zip-file-creator-part-iii","status":"publish","type":"post","link":"https:\/\/www.wambooli.com\/blog\/?p=603","title":{"rendered":"Your Very Own ZIP File Creator, Part III"},"content":{"rendered":"<p>Nerd Warning! This blog entry is part of a series on creating a command line utility to build a ZIP file. It&#8217;s technical stuff!<br \/>\n<!--more--><br \/>\nFrom the last post, you read that an empty ZIP file could be created by using the DOS <code>DEBUG<\/code> utility. The object is to use various <code>DEBUG<\/code> commands to build the ZIP file&#8217;s contents from scratch, then save those bytes to a file on disk. <code>DEBUG<\/code> is utterly capable of that.<\/p>\n<p>If you&#8217;d like to, you can follow along with these instructions using the command prompt window on your PC. The end result is that a ZIP file will be created on your computer:<\/p>\n<p>1. Open a Command Prompt window. It&#8217;s found in the All Programs, Accessories menu on the Start button menu.<\/p>\n<p>2. At the command prompt, type <strong>DEBUG<\/strong> and press Enter.<\/p>\n<p>The DEBUG prompt is a hyphen. Yes, it&#8217;s a <em>very<\/em> unfriendly program.<\/p>\n<p>The E command in DEBUG is used to input bytes, to actually assign values to memory locations. You want to create the bytes, the raw data, for the ZIP file at memory location 100:<\/p>\n<p>3. Type <strong>E100<\/strong> and press Enter.<\/p>\n<p>Now you need to input the bytes. It&#8217;s not that hard because you need only carefully type in the first four values. The rest of the values are zeros.<\/p>\n<p>4. Type <strong>50<\/strong> and press the Spacebar.<\/p>\n<p>Pressing the Spacebar hops the input over to the next byte in memory. Do not press Enter or you&#8217;ll have to start all over with Step 3.<\/p>\n<p>5. Type <strong>4B<\/strong> and press the Spacebar.<br \/>\n6. Type <strong>5<\/strong> and press the Spacebar.<br \/>\n7. Type <strong>6<\/strong> and press the Spacebar.<\/p>\n<p>Now you need to type the zeros. There are 18 of them, so you&#8217;ll need to type 0 and then press the Spacebar 18 times:<\/p>\n<p>8. Type <strong>0<\/strong> and press the Spacebar.<br \/>\n9. Repeat Step 8 eighteen times.<\/p>\n<p>10. Press Enter to exit the input mode.<\/p>\n<p>When you&#8217;re done, the screen should look something like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.wambooli.com\/blog\/wp-content\/uploads\/2009\/05\/debug2.png\" alt=\"debug2\" title=\"debug2\" width=\"593\" height=\"85\" class=\"alignnone size-full wp-image-604\" srcset=\"https:\/\/www.wambooli.com\/blog\/wp-content\/uploads\/2009\/05\/debug2.png 593w, https:\/\/www.wambooli.com\/blog\/wp-content\/uploads\/2009\/05\/debug2-300x43.png 300w\" sizes=\"auto, (max-width: 593px) 100vw, 593px\" \/><\/p>\n<p>You&#8217;ve input the data, but you need two other pieces of information to create a file in <code>DEBUG<\/code>: the file size and the file name.<\/p>\n<p>To set the file size, you must assign a value to the processor&#8217;s CX register. Yes, this is machine language programming. <em>Ta-da!<\/em><\/p>\n<p>11. Type <strong>RCX<\/strong> and press Enter.<\/p>\n<p>The RCX command allows you to set the value of the CX register.<\/p>\n<p>12. Type <strong>16<\/strong> and press Enter.<\/p>\n<p>The value 16 is hexadecimal; it&#8217;s decimal value is 22, which is the size of an empty ZIP file.<\/p>\n<p>To name the file, use <code>DEBUG<\/code>&#8216;s N command:<\/p>\n<p>13. Type <strong>N NEW.ZIP<\/strong> and press Enter<\/p>\n<p>The filename is now set to NEW.ZIP and the size is 22 bytes.<\/p>\n<p>14. Type <strong>W<\/strong> and press Enter.<\/p>\n<p>W is the Write command. You&#8217;ve just created a new, empty ZIP file.<\/p>\n<p>15. Type <strong>Q<\/strong> and press Enter to quit <code>DEBUG<\/code> and return to the command prompt.<\/p>\n<p>You can use the <code>DIR<\/code> command to verify that you created an empty ZIP file named <code>NEW.ZIP<\/code>. It&#8217;s there. It exists. It&#8217;s empty. Congratulations!<\/p>\n<p>Next blog entry I&#8217;ll show you how to create a simple script to save you a ton of typing time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nerd Warning! This blog entry is part of a series on creating a command line utility to build a ZIP file. It&#8217;s technical stuff!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-603","post","type-post","status-publish","format-standard","hentry","category-main"],"_links":{"self":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=603"}],"version-history":[{"count":4,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/603\/revisions"}],"predecessor-version":[{"id":645,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/603\/revisions\/645"}],"wp:attachment":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}