INTRODUCTION DISKEDIT has been designed as a robust, easy to use system. To start the program, simply switch on your PCW and insert the configured disk into drive A: (see supplied configuration notes). As soon as DISKEDIT has loaded, the screen will be cleared and an initialization message will be displayed on screen. Once DISKEDIT has been loaded it will check the system for one or two physical drives. On a two drive system you will be asked which drive the disk is to be edited in - A: or B:, while a one drive system will skip this stage and assume drive A:, ignoring virtual disking. On selection of the drive you will be asked to insert the disk to be edited into the selected drive. The disk will then be logged in, displaying the type of disk format; system, PCW, data only or CF2DD. DISKEDIT will operate on all of these formats, but not on non- CP/M formats. When the disk has been logged in, the two main display windows will be filled with data; the largest window contains numbers displayed in HEXADECIMAL (base 16), while the smaller window on the right shows an ASCII (American Standard Code for Information Interchange) representation. The ASCII display cannot give a true representation as ASCII only covers the range 0-127. Of these, codes below the space character (ASCII 32) are 'unprintable' (at least as far as we are concerned here) - tabs, form-feeds, carriage returns etc. These characters, with codes in the range 0-31, are displayed as decimal points. In addition, there are 128 '8-bit' characters with values ranging from 128-255. These characters are displayed using inverse ASCII characters where resetting bit 7 brings the character into the ASCII range, otherwise as inverse decimal points. It is also possible to examine the value of the byte under the cursor in several other formats (see [SHIFT]-x command later). Note that while other software packages you may have require complicated configuration of the program, with you having to say how many drives you have, what machine type and so on, DISKEDIT configures itself after checking what kind of computer you are using and how many drives are fitted, size of RAM disk etc. The minimum requirement for DISKEDIT to run is a machine running AMSTRAD CP/M Plus, with one single sided single density disk drive and a RAM disk with a capacity of 68K. If you wish to use the disk duplicate and check function (ALT-d) then your RAM drive must be bigger than this; the number of disk changes required during copying will be disk capacity/free space on RAM disk. If you are running any model of PCW your RAM disk will be assumed to be M:. DISKEDIT will also run on a CPC6128 with RAM disk, which will be assumed to be drive C:, as for the DK'Tronics silicon disk units marketed by RAM electronics. If you experience difficulty running DISKEDIT and are sure that your system exceeds the above minimum requirements, try removing any interfaces that you have attached and ensure there are no RSX routines loaded into memory before DISKEDIT (there is some free space above DISKEDIT, about 5K, but if anything tampers with memory below this then DISKEDIT will not work). For anyone who is interested in running batch files with DISKEDIT in them, note that the main DISKEDIT program and its UTILITY overlay chain between each other by returning FEFEh as the program return code. If a program run before DISKEDIT returns FEFEh as its return code, DISKEDIT will assume it is being reloaded after UTILITY and will not initialise properly, leading to rubbish in the instructions and probably some alarming and possibly damaging disk operations with the program trying to read past the end of the disk. DISCLAIMER The author disclaims all liability for any loss, consequential or otherwise, claimed or proved to be due to use of DISKEDIT or any of its associated utilities or mistakes found in the documentation (i.e. cock-ups on my part). Provided a sensible procedure is adopted there should be no real problem; make a backup before you start. MOVING THE CURSOR Inspection of the screen display should reveal a cursor 'blob' highlighting one byte of information. If the program has just been started and a disk logged-in, this will be at the top-left of the hexadecimal (hereafter referred to as 'HEX') display. This cursor can be moved using the arrow keys at the right of the keyboard. You should practice moving the cursor, and note the way the cursor can run off the edge of the display at one side to reappear at the opposite side. This wraparound feature operates in different ways, depending on the direction in which the cursor is travelling when it leaves the display. When moving vertically, the the cursor runs off the top or bottom of the screen to reappear directly opposite IN THE SAME COLUMN. Horizontal movement works slightly differently. If the cursor runs off the right of the screen it appears at the left-hand side ONE ROW BELOW that which it left. Conversely, if the cursor runs off to the left it moves UP ONE ROW before reappearing at the right of the display. This allows continuous movement through the data as if it were all displayed on a single line. The cursor should, therefore, be regarded as a 'window' through which you can view and alter individual bytes of information. THE COMMANDS In the following section, where an upper-case response is required the letter will be preceded by [SHIFT]. i.e. upper-case x is shown as [SHIFT]-x. For commands denoted by lower-case letters, care should be taken to avoid setting CAPS-LOCK or SHIFT-LOCK on the keyboard. The program is designed to run on a standard Amstrad CP/M keyboard, and may not work if the keyboard has been reconfigured using SETKEYS or a similar utility. Any invalid keypress will be greeted by a 'beep' from the computer. m: toggle HEX/ASCII mode. This command switches the cursor to the ASCII window if in HEX mode, and to the HEX window if in ASCII mode. Switching mode does not affect the relative position of the cursor in the data page. f: toggle page display. The editor works on a buffer containing one sector from the disk, each sector being 512 bytes in size. Since displaying all this information at once would make the screen rather cramped, the buffer is split into two logical pages of 256 bytes (logical, because there is in fact no physical split - the buffer is a continuous area of RAM). These are labelled as page 0 & page and 1, the display can be flipped from one page to the other without having to access the disk or lose any changes in the page being flipped out of sight. The current page number is always displayed at the bottom of screen. s: move forward one disk sector. The sectors are treated as logical numbers, 0 to 8, and if you go over 8 the sector count returns to 0 and advances on track. (See section on disk organization for details of track and sector numbering). [SHIFT]-s: move back one sector. If the sector number drops below 0, the count wraps round to 8 and moves back one track. This command is the opposite of 's' above. t: move forward one track. This works in the same way as 's' above but operates on tracks rather than sectors. If the track number exceeds 39 it returns to 0, but the sector number is not affected. [SHIFT]-t: move back one track. This command is the opposite of 't', with track numbers wrapping from 0 to 39. p: send current sector to LST: device (normally printer). The printed display is much the same as the console display, with both HEX and ASCII representations. l: login new disk for editing in current drive. Simply insert new disk into current drive when prompted. Note that to change drive in which you wish to edit the disk, it is necessary to quit DISKEDIT and restart, selecting the new drive at the start of the program. c: change contents of buffer. This command allows you to enter new data into the buffer area at the cursor position in preparation for saving to disk. This command functions in two slightly different ways, depending on the current mode (HEX or ASCII). HEX mode requires input of two hexadecimal digits for each byte. Non-hex digits will be accepted, but will be evaluated to zero. To exit change mode press STOP for either digit - the other digit can be any sort of junk, as it will be ignored. The byte under the cursor when STOP was pressed will be restored to its original value. ASCII mode takes the value returned from any keypress or combination of keypresses except STOP - note that CTRL-C is regarded as STOP - and stores it in the byte under the cursor. It is also possible to move around the page when in change mode by using the cursor keys. Remember that any changes are made IN THE BUFFER ONLY, not on disk. This can be seen as both a blessing and a curse - on the one hand it prevents you making foolish alterations to the disk by accident (or at least gives you a second chance to get it right !), while on the other it is possible to spend a long time editing a sector only to lose the changes by changing track/sector without writing the buffer to disk. It is not necessary to write to disk before using the 'f' (toggle page display) command, as both pages are held in memory together. w: write buffer to disk. This replaces the sector read from disk with the buffer in memory. It is not necessary to use this command except when you wish to save changes to disk (see 'c' command above). Any time a sector is read from disk, a copy is left on the disk, so no damage will be caused by not writing to disk when no alterations are made. [SHIFT]-i: display instruction summary. This is a brief list of commands to jog your memory without having to refer to these printed instructions all the time. [SHIFT]-c: toggle clock on/off. This displays a timer at the top right of the screen showing time elapsed since the current session of DISKEDIT was started, or the time if this was set at startup time. Note that the accuracy of this timer/clock is not to be depended on as the CP/M system clock which it uses is affected by disk access functions - which are used very often with a disk editor! [SHIFT]-x: toggle extra information display on/off. The extra information is shown in the message window at the bottom of the screen, and consists of HEX, DECIMAL, OCTAL, BINARY, BINARY CODED DECIMAL and ASCII equivalents for the byte under the cursor. Try moving the cursor with this display on, and watch the display change. Note that the BCD function forces any illegal values down to a legal BCD value eg. 'FF' becomes '99'. It is not advisable to leave this switched on permanently as it causes a considerable delay in the screen update when moving the cursor, hence the toggle on/off option. b: translate block number to track & sector ID. This is really only of use in directory areas of disks. See appendix on disk organization for details. d: disk search function. This will search from the current sector to the end of the disk for an input search string. To search the entire disk, set the track & sector to zero before beginning the search. If you are in ASCII mode, simply enter the string to search for and wait for a find. It is best not to search for strings of great length, as this increases the chance of mistyping part of the search string - with no match found as a consequence! NOTE : In ASCII search mode you will be asked if you wish to ignore case in the search. If you reply 'N' the search will be for an exact find, while a positive response (i.e. 'Y') will treat the search string as upper case and treat each character on the disk as upper case. This allows you to search for things like names, where you may no be sure how it is spelt on the disk e.g. john, JOHN, John or even JOhN can be found by ignoring case with a search string of "john", but if you choose not to ignore case, only the first example would be found. Also, in ASCII mode only, it is possible to use a 'wild card' character in search strings. Thus you may enter DIS???IT to find DISKEDIT somewhere on the disk. Conversely, of course, there are disadvantages in having a very short search string - this increases the likelihood of the search function stopping before it has found the item you want. e.g. if you enter "night" to find "nightingale", but the word "knight" appears before "nightingale" on the disk, the search will stop at "knight". A HEX mode search will first of all prompt for the number of characters to search for. This is to cut down the likelihood of error during entry of the search string, as it is very easy when keying HEX strings to duplicate a byte by accident. You then enter the required number of two-digit HEX numbers - no is required between numbers, and no illegal characters will be accepted. In both modes, a successful search will leave the cursor placed on the first byte of a matching string, while a failure returns the cursor to the original position before the search started. To find the next occurrence, press 'd' again, and enter the same data (with ASCII mode search the previous search string will be popped up on each subsequent search operation - press RETURN to use the same string or type the new string in; the old string will vanish in this case). The program will then search from the cursor position onwards. A disk search may be aborted at any time by pressing a key - a prompt will appear asking 'Abandon search (Y/N) ?'; Y aborts the function, N restarts the search. Abandoning the search causes the program to behave as if no matching string could be found. g: goto selected track and sector. You must enter the required track when prompted, press , then enter the sector number at the prompt. Invalid track and sector numbers will be brought into the legal range for that particular disk by the program. [SHIFT]-g: goto CP/M block number; requires a 4 digit hex number. ALT-S on main screen gives access to nine scratch pads numbered 0-8. You can copy the current buffer to the selected scratchpad, destroying what is already in the scratchpad, or you can swap the contents of the buffer with the contents of the scratchpad. Copying is faster than swapping. A comment can be entered for each scratchpad at each access time to remind you of what is in it and why - very useful! ALT-B gives the free space on the current drive. This is totally useless information for disk editing but it was easy to put in so there you are! Note that this is only guaranteed to work correctly if the drive is not marked Read Only. ALT-D : Duplicate Disks. To use, first ensure you have a blank formatted disk of the same format type as the disk you wish to copy (this function will NOT format as it copies) then press ALT-D. Note that for disks which have been corrupted in track 0, sector 0 the format read by DISKEDIT may be in error - it may read track 0 sector 0 as PCW format when the rest of the disk is CF2DD format. In such cases the blank disk must be formatted as CF2DD, as 706K obviously will not go onto a 40 track disk (a bit of common sense may do wonders here). The program will ask you to enter the disk to read, and will tell you how many parts the disk will be copied in. Drive M: is used as a buffer so the less space you have used up on drive M:, the fewer disk changes will be needed for a copy. With a PCW8256 M: is 112K, while DISKEDIT.COM and UTILITY.COM take up about 62K between them; thus you have a 70K buffer. Your A: disk needs 180K to back up, giving a three part copy. On an 8512 M: gives a 306K buffer, allowing CF2 disks to be backed up in one go, and CF2DD disks in a three part copy. The duplicator logs all disk errors found during the copy to DISKEDIT for future reference. If you simply wish to search out errors rather than back up the disk, select the N option when prompted. n: next error. This consults the error log from the last ALT-D command and displays the next error. [ALT]-n: reset to first error in list. [SHIFT]-n: output error list to LST: device (normally printer). [ALT]-o: One's complement of sector in buffer. This converts all binary 1s to 0, and all binary 0s to 1. As such it is a reversible operation. q: quit program and return to operating system. This function 'tidies up' the operating system before leaving the program. [SHIFT]-u: Utilities menu. This gives access to commands similar to those available at the CP/M system prompt, with some enhancements. Note that this will not work if the UTILITY.COM file is not present on the M:drive beside DISKEDIT.COM; see configuration notes for details. The utilities are as follows : D: disk Directory - identical to CP/M dir command, with wild card characters ('*' and '?') allowed in the filename. E: Erase file(s) - as for era command in CP/M. Again, wild card characters are observed. Note that only files in the current user group which match the input filename will be erased. R: Rename file - asks which file is to be renamed then prompts for the new filename. This is more logical than the CP/M system of entering new name then current filename. Both filenames must be unambiguous (no wild card characters allowed). T: Type file - similar to CP/M type command for screen display. Asks for unambiguous filename (no wild card characters) to display on screen. The function waits for a keypress after displaying each screen page of information. There is also an enhanced printer option, giving numbered pages with the filename and entered date as a heading on each page. The date can actually be replaced with any heading you choose, provided the length is less than 30 characters. U: change User number. This is identical to the CP/M user command, accepting user numbers in the range 0 to 15. A: Alter directory - a separate directory editor, giving the user an easy way of setting files to READ/WRITE or READ ONLY & DIR or SYS. Q: Quit utilities and return to main display. COPYRIGHT NOTICE ---------------- DISKEDIT was produced originally as a package for my own use, due to the fact that at the time, HiSoft's Knife was the only decent disk/sector editor around and I couldn't afford to buy it (it also didn't much appeal to me in its method of operation). As it grew, I began to think of it as a package which would be of interest to other computer users, and also as a possible source of income ("beer money"). I duly shipped it off to a computer magazine for review, and the review said basically 'OK, but . . . ' so I upgraded it again to wipe out the 'but'. I then sent the new version (which incidentally was a total re-write in a different language) to another magazine, '8000 PLUS'. They said "Definitely a package for the experienced PCW user who is already intimately acquainted with the anatomy of his discs" and rated it 5/5 for performance, with 2/5 for documentation due to the fact that there was no idiots guide and the manual (47K) was on disk. Basically, it was a flop as an earner with the total revenue being well below what would keep a hamster drunk for 3 days (okay I might be exagerrating slightly, but I do NOT have a swimming pool or a Rolls-Royce). So now you have a copy. And I am still poor. And hungry. And thirsty. And unable to earn a crust due to arthitis brought on by hacking out this program. lskdgfhjlkfm. Sorry about that, I must have blacked out in my weakness. If you use this program, please (please! please! please!) send some money! Also , note that this program, with its associated utilities and documentation are COPYRIGHT D.McIntosh, of 47 Almondell Terrace, East Calder, West Lothian, EH53 OEZ, and is in the public domain for distribution only. It may NOT be hired out or sold, or supplied with any package which is hired or sold, and the copyright notices must not be altered or removed. In addition, all copies of DISKEDIT must be supplied with all utilities and documentation as supplied in the original package. Having said that I would like to acknowledge the copyright of HiSoft on some of the code as DISKEDIT was produced with a HiSoft compiler (v1.0 - v1.3 in C, v1.4 onwards in PASCAL80). EXTRA UTILITIES --------------- Supplied on disk with DISKEDIT are a couple of little utilities which may prove useful to many Amstrad users. The first is a program called RFORMAT which is simply a format routine to give 178K data disks, rather than the normal 173K you get from the PCW version of DISCKIT. Simply put the disk in the drive, type RFORMAT , and follow the on-screen instructions. Operation is similar to formatting with DISCKIT, with the option to "Format another (Y/N)" after each run. PCWFORM is a formatter which gives PCW format disks, but without the boot sector. It is handy in as much as you can format disks with this utility, copy files onto them & post them to people with PCWs who can then copy the disk with DISCKIT, rather than PIP. PRINT does as it says - prints things! It allows you to output ASCII files to the printer, with headings and numbered pages. Use the command line format PRINT . Since PRINT automatically prints the filename at the top of each page, it is recommended that you enter the date as a heading. e.g. PRINT manual "1st November 1988" Note that if your heading contains spaces you must enclose the whole heading in double quotes. Alternatively, simply type PRINT at the CP/M command line and follow the prompts for input. DISK ORGANIZATION ----------------- This section is intended to give the user some insight into how the information is stored on a disk, to allow intelligent use of the editor rather than juvenile fiddling about with the occasional on-screen message. First we will deal with the A: drive, that is the drive built into a CPC6128 or PCW8256, and the top drive on a PCW8512. These drives are 'single-sided' - this means that they can only read and write information to one side of the disk. As far as the drive is concerned, if you flip the disk over it is then looking at a 'new' disk - it has no way of knowing what is on the other side. A disk used by CP/M Plus is split up into 40 segments called 'TRACKS'. Each track is further divided into 9 parts known as 'SECTORS'. Each sector has two numbers associated with it - a physical sector number and a logical sector number. Physical sector numbers can be 1-9 for PCW format, #41-#49 for system format or #C1-#C9 for data only format. As you can see, the physical sector numbers vary with different types of disk format, which can cause problems. For example, if you have a disk where you wish to edit the first sector on the fifth track, should you be looking for track 5/sector1, track 5/sector #41 or track 5/sector #C1 ? It is easy to work out which sector you wish to access when you know the format of the disk (DISKEDIT actually tells you which type of format the logged-in disk is), but it can be rather irritating having to do conversions all the time. For this reason CP/M Plus also uses LOGICAL sector numbering, where sectors are numbered from 0 to 8 NO MATTER WHAT FORMAT OF DISK IS BEING USED. The track numbers are also numbered, from 0, going up to 39. The allocation of space on the disk varies with different formats as well, but this cannot be solved by such a simple concept as logical numbering. The variation is due mainly to the different requirements of certain disk formats - a system disk requires space for the boot sector, while data disks do not. The boot sector is the part of the disk which holds the program used to load the CP/M operating system and is normally the first sector on a disk. PCW format disks set aside one track for this, CPC6128 system disks use two and data only disks require 0. These tracks set aside are called RESERVED tracks. Note that the version of DISCKIT supplied with the PCW range will only give PCW format disks; i.e. the first track will always be reserved for the bootstrap loader - a shame really when the extra 5K can sometimes be of vital importance. The amount of code in a boot program is generally not more than one or two sectors, but CP/M Plus on the Amstrad systems reserves much more space for compatibility with the earlier CP/M 2.2 system on earlier machines, which stored the entire operating system in the reserved tracks (it also makes life easier in general for programmers). CP/M Plus stores only a boot program in the reserved tracks, with the actual operating system being in a file on the disk called filename.ems (it doesn't matter what you change the filename part to, as long as the filetype remains .EMS as the boot sector refers to it using wild card characters - '????????.EMS' - load up DISKEDIT and have a look at track 0 sector 0 of your system disk! Each sector on the disk can store 512 bytes, so each track is 9*0.5=4.5K. With 40 tracks this gives a total of 180K. The directory accounts for 2K of this space, leaving 178K for data - this is the case on a data format disk. Other formats lose space due to reserved tracks - system format reserves 2 tracks, giving 180-2-2*4.5=169K, while PCW format is 180-2-1*4.5K=173K (disk functions, such as SHOW or DIR, show space rounded to the nearest whole 1K block). The 2K directory space is split into 64 blocks of 32 bytes. Each block is called a directory entry, and contains information such as filename, filetype, length and distribution of the file around the disk. Inspection of the directory sectors with DISKEDIT will reveal quite clearly the format of these directory labels (directory sectors are the first 4 sectors after the reserved tracks; thus track 0/sector 0 for data format, track 1/sector 0 for PCW format and track 2/sector 0 for system format disks). The allocation, for those of you who may not have an eye for such things, is as follows:- BYTE 00 : User number (#E5 means the file has been deleted) 01-08 : Filename (padded out with spaces if less than 8 characters long) 09-11 : Filetype extension (COM, BIN, TXT etc) 12 : Extent number (normally 0, may be greater for files >16K long) 13 : Not used 14 : Number of extents 15 : Record count - shows how many 128 byte records are in file 16-31 : Disk map for file, showing blocks occupied by file on disk Armed with this information, we can start to edit the disk in a more intelligent manner. One of the easiest (and most valuable) functions is to unerase a disk file. That is to say, if you have been working away at a file for hours, with regular backups (what do you mean you don't make backups ?!) and the disk becomes full, you type ERA *.BAK to erase the old versions to make room for a new backup. Calamity strikes ! You typed ERA *.* by mistake (it happens - I know!) and all copies are gone. Simply edit the directory area, finding the offending E5 byte at the start of the directory entry - change it to 0 (or some other user number from 0 to 15), save the sector - and your file is recovered! Note that as an extra bonus, you can unerase files from the utilities menu by selecting A - alter directory. This allows you to alter the user number of any file directly, and shows you on screen whether the file is erased or not. Conversely, to erase a file using either the A option or editing directly, change the user number byte to E5 (using the alter directory facility, you are asked for the user number in decimal - E5h is 229d). The main thing to bear in mind here is that this technique is only guaranteed to work if you have not written anything to the disk after erasing the file, as new data may be saved over the space occupied by the erased file. Another use for the directory area in DISKEDIT is to restrict the search area. Find the directory entry of the file you wish to alter and place the cursor over byte 16 (the one below the user number) and press 'b'. This is the translate byte function, which will translate the block number into a logical track and sector value - and offer a chance to jump directly to that position on disk! Using this technique saves time on disk searches, and also avoids finding an occurrence of a word (or string of bytes) before the relevant file is reached. Drive B: on a CPC6128 (assuming the official Amstrad FD-1 3" drive is used) will be identical to drive A:. Drive B: on a PCW8512 is a different kettle of fish. It uses both sides of the disk at the same time, with 80 tracks on each side. Wow! That's four times as much as drive A: . . . 4*200K = 800K ! Take off 2K for the directory and you still have (gasp!) 788K. 'Wait a minute, that's not right' I hear you cry (if you've got a PCW8512 anyway), 'I get much less!'. Correct - award yourself a gold star for observation. When you think about it, to use 788K with only 64 directory entries (see above) you would need an average file length of just over 12K. Now this is not a lot in days where people are used to talking in hundreds of K, or even megabytes. But you do a directory of a few disks using DIR[A] (this gives file lengths), and see how big most of your files are. Unless you use your computer for writing books, you will be talking about a lot of 2-3K files. The B: drive therefore uses 256 directory entries and has one system track (which doesn't seem to contain anything useful on a PCW8512 but makes it compatible with disks for a PCW9512 - see PCW9512 supplement). Close examination of a directory entry on a CF2DD also provides another interesting fact: each sector number on a single sided disk corresponds to 2 sectors on disk; on a double sided disk it maps out four sectors! This means that while the minimum size of a directory entry on a single sided disk is 1K, a CF2DD cannot hold files smaller than 2K. Or rather it can hold smaller files but it treats them as if they were 2K long. What we get from all this is one outstanding fact : 800K disks under CP/M are LESS EFFICIENT than 200K disks for small files. This does not mean that 200K disks are better (far from it) but because of the way CP/M works if you are saving small files you are making better use of your disk space by saving onto the top drive of a PCW8512. As an example, suppose you had a hundred 1K files (such as invoice records) which must be stored. If you put them on a CF2 disk, it will require 100K of disk space - while on a CF2DD it would use up 200K. Thus in real terms, if you are only saving small files of 1K or less, the CF2DD only stores twice as much as a CF2 as opposed to the original estimate of four times as much. On the other hand, try saving a 400K database onto a CF2! The whole point of this seemingly useless monologue is this : you get more from your system if you understand how it works. You need not take this to extremes, learning everything there is to know about the NEC uPD765A disk controller and internal workings of the Z80 CPU (although this is helpful when writing utilities*), but at least get to know the fundamentals. Compare it to a car: you know you get greater mileage driving at 40mph than at 70 mph - but do you know the reasons behind this improved efficiency ? Of course not, but this is not relevant to driving and running a car. Likewise with your computer system - work on a need to know basis. * Note : I do not claim to know these things either, but it would, I am sure, have been handy. Most of the time this information will be irrelevant to you in day to day operation of your equipment, it is only when space is at a premium that the knowledge becomes useful. As a comparison, a businessman driving hundreds of miles each day can save a small fortune on petrol costs by driving at optimum speed - but granny can quite happily scream down to the bank once a week in her Ferrari at 90mph with no practical benefits to be gained from slow driving. Moral : never buy a used car from your granny. Enough of this : anyone requiring more information can buy (or borrow) a copy of SOFT971 - operator's and programmer's guide for the Amstrad CPC6128 and PCW8256, and while away many a happy hour prising information from the text and some disks. At least you'll have DISKEDIT to help: I had to write DISKEDIT in bits and bobs on the way to fruition of knowledge. PCW9512 SUPPLEMENT ------------------ Lucky owners of the PCW9512 will not have to concern themselves with CF2 formats as their A: drive is double sided, as would B: be if fitted. All disks should be CF2DD format. If you wish to copy disks from CF2 format to CF2DD, use PIP to copy file by file to a freshly formatted disk. NUMBER SYSTEMS -------------- This is the really painful bit for the uninitiated. Numbers are stored as bit patterns (8 bits=1 byte, 4 bits=1 nibble, 2 bits=1 peck) with the least significant bit (LSB) on the right with value 1 or 0, progressing left by powers of two to the most significant bit (MSB), assuming of course that it is not a real number with sign bit, exponent and mantissa. Got that ? Didn't think so. Look up any good academic text on computers and you will most likely find pages and pages of stuff like this: s exp s mantissa 0 1101101 1 00000011110110110101100 which equals -11110110110101100 times 2d to the power of 1101101 " " -11110110110101100 times 2d to the power of 109d " " -126380d times 2d to the power of 109d " " -82,025,309,540,000,000,000,000,000,000,000,000,000 But who the hell cares ? I don't often expect to need to store numbers like this, as I am not into counting the number of atoms in 5 kilos of salt. [NOTE: Don't tell me if the above is silly or unworkable; I don't want to hear about it. HiSoft, who wrote the Pascal80 compiler used, use a "sign/normalised mantissa/exponent in binary 2's complement" system. If you want to know about it (?!), write to HiSoft with the query marked F.A.O. David; they all seem to be called David at HiSoft!] So back we go to our need-to-know theory. What you need to know are things like how to read hexadecimal numbers (because this is what DISKEDIT shows you rather large quantities of). We will start off in a funny place, because most of us have ten fingers. Human beings have a marked tendency to use the decimal numbering system, that is base 10. Due of course, to aforementioned number of digits. (NOTE: digits - posh word for fingers, but remember the word.) If you start off with a pen full of sheep, and someone lets them out one at a time while you count (beginning with clenched fists) you go along quite happily popping up a finger as sheep go past. One, two, three, four, five (one hand gone), six, seven, eight, nine, ten - and suddenly this guy is getting all these sheep for free because you can't keep track any longer. Now, say what you like about dumb shepherds, but these guys know when they're getting ripped off. Pop! Up comes a foot, but this has obvious limitations - like landing on your dignity after twenty sheep. You may have noticed that I have written every number in this little section in longhand so far - this is to tie in with the story. A bit of soft stone, a flat rock, a few flourishes of the soft stone and hey presto! 0,1,2,3,4,5,6,7,8,9. Arabic numbers - symbols to replace fingers. Once you have used up all your symbols, the obvious step is to join symbols together for high numbers 20 is two hands and a foot, 30 is two hands and two feet, without having to argue with gravity! The point to be noted here is that to have an open-ended system of counting, you must have some way of counting over the base set of numbers. With base 10, or decimal, the highest number is nine. After nine, you go back to zero and bung a one in front of it to show that you have gone through the sequence one time already. Now this is fine for humans, but when did you last see a computer count on its fingers ? A computer, being plugged into mains supply, is concerned only with the same thing you or I would be in the same predicament : whether the current is on or off. On or off : two states, therefore a base 2 numbering system - binary. Binary makes many people cringe or go back to showing off their digital watch, but it is really quite simple when you think about understanding it. If you go back to the sheep, and remember what used to happen to people who steal (CHOP, CHOP). . . Assume a benevolent judge allows a thief to keep his thumbs only, on condition that he becomes a lowly shepherd. He has the problem of counting his flock, and solves it in the same fashion as our ten- digited friend earlier. No sheep, pop up a thumb, one sheep, pop up a thumb, two sheep, - and so on until he falls over after only three sheep have gone past - what a rip off, eh? So, soft stone & flat rock, 0,1, . . . . Aha! This poor guy doesn't have any idea of 3,4,5 etc since they got cut off. So he would probably be a better programmer than the first shepherd (a bit slow typing maybe . . .). His sequence goes 0, 1, 10 (back to zero plus a one in front to show he's gone round the sequence once), 11, 100 and so on. Every time all his symbols are used up he puts all the digits back to 0 and puts a 1 at the left hand side. So, to compare the two systems : Decimal Binary 0 0 1 1 2 10 3 11 4 100 5 101 6 110 7 111 8 1000 9 1001 10 1010 11 1011 12 1100 13 1101 14 1110 15 1111 16 10000 17 10001 18 10010 19 10011 20 10100 Now, the guy who counts with his thumbs is going to use more chalk, but he will still get paid for his sheep. You should try counting a little bit like this until you get a firm grasp of the idea. Changing a life-long system can be a bit mind boggling at first, but once the initial shock is over it becomes quite easy. Just as the value of decimal digits increase by powers of ten progressing left, the value of BInary digiTS (BITS; this is why I asked you to remember digits means fingers - BInary fingERS abbreviates to BIERS which sounds like BEERS and everyone goes off the the pub leaving Babbage with a state of the art computing machine!) increase by powers of two. This is true for all numbering systems: the digits progress by powers of the base (this is important to remember). So, we have the traditional ten thousands, thousands, hundreds, tens, units for the decimal, or base ten, system and eights, fours, twos, units for the binary, or base two, system. So, if we have a binary number and wish to translate it to decimal so that our prehistoric craniums can cope, we can assign the appropriate decimal value to each binary digit, multiply each by the binary digit and add the sums. 8 4 2 1 (decimal) 1 0 1 1 (binary) 8 + 0 + 2 + 1 = 11 (decimal) or (8x1)+(4x0)+(2x1)+(1X1)=11 This progression can be extended as far to the left as is necessary to obtain the magnitude of numbers required. A fairly common number of bits used for a number is 16, giving a maximum of 65,535 (decimal) or 1111111111111111 (binary). 'Oh, no, what a horrible looking number - I could cope with eleven!' Split it up. 32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1(d) 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1(b) Multiply and add as before to give the sum of all the top numbers which is 65,535. It is obvious that our meagre brains begin to seize up with larger numbers, but that is just as true in base 10. You think not ? 2x12=24. OK. 13x137=????. Point made I think. Smart alecs can try 3246793x387639023 - without the pocket calculator, please. On the subject of pocket calculators, they are handy things to have. All work in base 10, since that is the regulation number of fingers, but some also do other wondrous transformations. Mine is a Casio fx-570, and does binary, octal and hexadecimal as well as decimal (base 2, 8, 16 and 10), translating between all of these quite happily. As things stand, however, all we require for the purpose of simple editing is the ability to read numbers in base 16, or hexadecimal (big word normally abbreviated to HEX). Now why the hell did we go through all that stuff about fingers and thumbs to land up with base 16 ? Well, for a start I thought it was a good story, and for another binary is the heart of all computer operations. Base 16 numbers go 0 1 2 3 4 5 6 7 8 9 as they do in base 10, but from there we get stuck because whoever made up arabic numerals didn't have the extra fingers to worry about ! Obviously we cannot make up arbitrary symbols like a pig flying backwards for eleven or whatever, because it's very difficult to get a keyboard with a pig flying backwards on it. So, we fudge it and use the letters A-F for the required missing numerals giving 0 1 2 3 4 5 6 7 8 9 A B C D E F. Another equivalence chart to make things clear; Decimal Hex 0 0 1 1 As in decimal and binary, the digits 2 2 progress in powers of their base value 3 3 to the left eg 20d=2dx10d(base)=twenty 4 4 5 5 So F0=F(15d)x16d(base)=240d 6 6 7 7 And FC=(15d x 16d) + 12d = 252d 8 8 9 9 NOTE : As you may have noticed by now 10 A it is common practice to denote number 11 B base by a letter after the number eg 12 C 12d or 12h, the former denoting twelve 13 D (decimal), the latter eighteen (hex). 14 E Also used are b (binary) and o (octal). 15 F Now if you're ready for the clever bit, think about why we want to use hex numbers in the first place. Computers, as we now know, count in binary. Humans count in decimal (or denary). Neither of us counts in hex, but humans make rather a lot of errors writing down lines of ones and zeros and conversion from binary to decimal is painful to say the least. Conversion from binary to hex is child's play ! Honest ! To prove the point we have to examine once more the way that computers store their information. Everything is split into bytes : that is, eight bits. Eight bits can store a number from zero (0000 0000) through two hundred and fifty five (1111 1111). You may have noticed that these binary numbers have been split into groups of four digits, which makes it easier to count the number of 0's and 1's. The clever thing is connecting the groups of four digits to hex. Four digits can denote numbers from zero (0000) to fifteen (1111), or in hex 0h to Fh. Dropping the h notation from the numbers gives us a range of 0000 0000 binary/00 hex to 1111 1111 binary/FF hex. In other words we can display any byte value with two hex digits, and do conversions from hex to binary and back with great ease as we never have to work with more than four binary digits at once. A few examples may be in order to show the ease of conversion. Binary 1011 1101 1101 0001 1010 1111 0101 1011 Hex B D D 1 A F 5 B As well as using less ink when written, hex characters are easier to read and therefore less prone to copying errors - as an example, look at the two following data lists:- DEFB 00011011,01000101,00011011,01001000 DEFB 1B,45,1B,48 These each represent the same escape sequence to clear an Amstrad screen and locate the cursor at the top of the screen, a trivial example, but even so which would you prefer to type ? Now, as a little extra, here are a couple of interesting hex values which you should spot frequently when editing files containing any text using DISKEDIT. 0A Line feed 0D Carriage return 09 Tab 1B Escape (used in terminal escape sequences such as that above, which would read as ('escape E escape H'). BIBLIOGRAPHY ============ The following books are thoroughly recommended. Mastering CP/M, Alan R. Miller (Sybex 0-89588-068-7) The CP/M Plus Handbook, Alan R. Miller (Sybex 0-89588-158-6) Operator's And Programmer's Guide For The Amstrad CPC6128 And PCW8256 Digital Research Inc. & Amstrad Consumer Electronics plc (Heinemann 0-434-90320-5) CP/M The Software Bus, A. Clarke/J. M. Eaton/D. Powys-Lybbe (Sigma Technical Press 0-905104-18-8) The Lord Of The Rings, J R R Tolkien (Unwin 0-04-823187-8) NOTE : I believe the Miller books may be out of print now, but they are well worth a read if you can beg, borrow or steal a copy from someone.