home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / funkybox.zip / PEEKFILE.DOC < prev    next >
Text File  |  1983-05-02  |  17KB  |  453 lines

  1.    
  2.  
  3. ***************************************************************
  4.  
  5.      P E E K I N G   I N T O   F I L E S   A N D   R O M 
  6.  
  7. ***************************************************************
  8.  
  9.               PEOPLE SYSTEMS, LTD. (C)1983
  10.  
  11. Have you tried the X-RAY machine program in your IBM-PC ? Perhaps
  12. you know it by another name. Its officially called DEBUG in DOS, but
  13. it has the longest nose of any software around. All you have to do
  14. is learn where things are kept and how to control its ability to get 
  15. into mischief and you've got the finest tool for learning about 
  16. your IBM-PC a little at a time.
  17.  
  18. A map -- a map -- my kingdom for a map. Well without being too dramatic
  19. there really aren't any in the manuals. Lots of address lists here and
  20. there but a good old fashioned road-map is needed. Maybe before we get 
  21. through we'll develope one and you can print it out and put it up on
  22. your operating room wall. But for now, pick up your IBM manual and 
  23. look at what's there. It will give you a general idea of how the memory
  24. is utilized in the PC and on the screen and graphic boards. (Both have 
  25. about 16 Kbytes in addition to your own plugged in chips.)
  26.  
  27. Incidentally, adding RAM to your empty boards is not very difficult,
  28. in fact, if you look for it you'll find a tutorial STUFCHIP
  29. included in Programmer's Toolbox. Chips are available from good and
  30. dependable dealers like Microprocessors Unlimited in Beggs. OKlahoma
  31. ZIP 74421. Mr. John Gilchrist will give you good service and quality
  32. parts you can depend on at (918)267-4961. His prices and chips are the
  33. best around and he'll stand behind them if you need help.
  34.  
  35. Since we are going to be looking into both files and ROM we should get 
  36. familiar with DEBUG's  LOAD  command. If you find it under DEBUG in DOS
  37. and take a look you'll find there are several options (isn't that 
  38. always the way). There are 2 options and No.2 has two formats. Lets do
  39. Option 1 first. We used this in DISKMOD.DBG to recover a small, just
  40. erased file. You may want to try that for an experiment. Please make
  41. a TEST disk by DISKCOPY for fooling around purposes. DEBUG can really
  42. screw up a Directory or FAT (File Allocation Table) if you're not
  43. careful. But on a test disk you can't harm anything permanently.
  44. If you remember, the LOAD command we used for disk sectors was in HEX
  45.      
  46.                 -L 04B5:0100   0   3   4          <enter>
  47.  
  48. It means   -   (hyphen-DEBUG prompt)  04B5:0100 (hex address DOS 1.1 in
  49. segment:offset )     0   means Drive A:   3 (starting sector on disk --
  50. absolute)    4 (LOAD 4 sectors). In this example the HEXidecimal and
  51. the decimal numbers are the same (up to 9). This is DOS 1.1 address.
  52. 04B5:0100 may be different in DOS 2.0.
  53.  
  54. This command LOADed the disk Directory which occupies sector numbers
  55. 3, 4, 5, 6, in that order. (there are 40 tracks with 8 sectors @ 512 
  56. bytes each on IBM-PC 160 Kbyte SS drives--this adds up to sectors 0-319
  57. in absolute numbers). Sector 0 is the boot sector and sector 1-2 is the
  58. FAT (File Allocation Table).
  59.  
  60. Converting Track - Sector to absolute sector is not difficult. Tracks 
  61. run from 0 to 39 on a 40 track disk there are 8 sectors on each track
  62. and, in this case,  are numbered 1 thru 8 (just to be cute). So to 
  63. convert DOS 1.1 SS say Track 10 Sector 6 to absolute sector use:
  64.  
  65.               (8 * Track No. +  Sectors) -1 = Absolute sector
  66.  
  67. In this case  (8 *  10       +    6)     -1  =  85
  68. Of couse if you want absolute sectors 85 to 95 inclusive  there are 11.
  69. Do it on your fingers if you have trouble -- really.
  70. The fingers are the world's oldest Abacus. (Chinese bead computer)
  71.  
  72. Sometimes it helps to see it graphically:
  73.  
  74. THIS IS A DISK INITIALIZED WITH FORMAT/S (SYSTEM AND COMMAND.COM INCL.)
  75.  
  76.         This is a single sided disk - 8 sectors per track DOS 1.1
  77.  
  78. Track   Sector  Abs.Sector      File
  79.  
  80.   0      1      0        BOOT record  Part of System in Format/s
  81.   0       2       1             File Allocation Table
  82.   0       3       2             FAT second copy -- same as 2
  83.   0       4       3             Directory
  84.   0       5       4             Directory
  85.   0       6       5             Directory
  86.   0       7       6             Directory
  87.   0       8       7             IBMBIO.COM (OR DATA-if FORMAT NOT/S)
  88. NEXT    Sector 8  above is called Cluster 002 -- beginning of DATA
  89.   1       1       8             IBMBIO.COM
  90.   1       2       9             IBMBIO.COM
  91.   1       3       10            IBMBIO.COM
  92.   1       4       11            IBMDOS.COM  FIRST SECTOR OF IBMDOS.COM
  93.   1       5       12            IBMDOS.COM
  94.   1       6       13            IBMDOS.COM
  95.   1       7       14            IBMDOS.COM
  96.   1       8       15            IBMDOS.COM
  97. NEXT
  98.   2       1       16            DO
  99.   2       2       17            DO
  100.   2       3       18            DO
  101.   2       4       19            DO
  102.  (we have skipped a few lines of monotony)
  103.   2       8       23            LAST SECTOR OF IBMDOS.COM
  104. NEXT
  105.   3       1       24            COMMAND.COM BEGINS
  106.  
  107. COMMAND.COM CONTINUES FOR 12 SECTORS
  108. NEXT
  109.   4       4       35            COMMAND.COM ENDS
  110.   4       5       36            YOUR PROGRAM OR DATA BEGINS
  111.  
  112.   
  113. MANY - MANY SECTORS LATER 
  114.   
  115.   39      8       319           LAST SECTOR AVAILABLE ON SS DISK
  116.  
  117. D.S.D.D. records each track front and back before proceeding to next.
  118. There are 40 tracks (0-39) front and back and the disk drive covers 
  119. Track 0 side 0 then Track 0 side 1 and goes back to the front(0) and 
  120. moves to Track 1 side 0 then track 1 side 1 then T1-S0, T1-S1, 
  121. T2-S0, T2-S1 etc. across the disk, reducing unnecessary head travel.
  122.  
  123. It would be easier to fathom  the arrangement IBM-PC chose 
  124. if these terms were in rational order as they should have been. The 
  125. progression logically is SIDE 0,1 TRACK 0-39 and SECTOR 1-8 but because
  126. every one was used to working without a side number, IBM moguls added
  127. the side designation to the end of the train instead of up front where
  128. it belongs.
  129.  
  130. Double sided disks have a slightly different format -- they add 3 more
  131. sectors to the Directory beginning at Track 0 sector 8 side 0, then on
  132. back, Track 0 Sectors 1,2 Side 1, splitting the directory S0,S1. All of
  133. the track 0 operations above take place on single sided disks. But the
  134. system/data files don't start until Track 0 sector 3 side 1 (backside),
  135. (on D.S.D.D. Disks).
  136.  
  137. DOS 1.1 is more complicated to compute the absolute sector number on 
  138. double sided disks. D.S. disks use each track front and back before 
  139. proceeding to the next track. DOS 2.0 increases the storage and the
  140. problem, adding another sector to each track making it 9 instead of 8.
  141.  
  142. Sector numbering for debug is changed in DOS 2.0 -- so we will 
  143. take that up. Just compare page 6-8 in DOS 1.1 with  12-11 in DOS 2.0
  144. and if that doesn't confuse you for a while, I'll eat my IBM-PC. But,
  145. they are now making the relative numbering (absolute) follow the
  146. head and side counting system, as it should have been.
  147.  
  148. Try ABSECTOR.TBX and CLUSECTOR.TBX for computing on ToolBox disks.
  149.  
  150. Now there are 9 sectors on 40 Tracks (0-39) on Side 0 and Side 1 or 
  151. 9 * 40 * 2 = 720 sectors total. At 512 bytes per sector gives
  152. a grand total of 720 * 512 = 368,640 bytes OR 2,949,120 Bits.
  153.     
  154. At 6 characters per word this is over 60,000 words. WOW, most folks
  155. don't need a hard disk unless they have a humongous data base and 
  156. people who are constantly entering data and maintaining the files,
  157. like accessing a mainframe's database (as some PC's do.)
  158.  
  159. Why, 60,000 words is a paperback's  (about 160 pages) worth of memory
  160. on a D.S.D.D.disk. Technical data recording, like analog to digital 
  161. could produce a large amount of data storage. But the average computer
  162. user might do well to avoid the expense and dubious advantages of a
  163. hard disk. Who wants all their eggs (programs) in one basket with
  164. no easy back-up?
  165.  
  166. In case you aren't  interested in getting a fixed disk (IBM jargon).
  167. Here is a table from page C-2 in DOS 2.0 that will explain the vagaries
  168. of 1 or 2 sides and 8 or 9 sectors. We have added the last column for
  169. ease in computing absolute sectors from cluster numbers.
  170.  
  171. No. of   Sectors/  FAT size    DIR       DIR      Sectors/  Sector No.
  172. Sides    Track      Sectors    Sectors   Entries   Cluster  Begin Data
  173.  
  174. 1          8          1 * 2       4         64        1         6
  175. 2          8          1 * 2       7        112        2         9
  176. 1          9          2 * 2       4         64        1         8
  177. 2          9          2 * 2       7        112        2         11
  178.  
  179. Notice the change from  DOS 1.1 . Fat was 2 sectors -- each containing
  180. a separate copy of FAT so that if one copy was unreadable there was an-
  181. other. Now the FAT is two sectors times two copies for DOS 2.0 nine
  182. sector disks. This change accompanied relative (absolute) renumbering
  183. mentioned above in DOS 2.0.
  184.  
  185. In DOS 1.1 there is a table converting clusters to relative segments.
  186. The pages begin on C-9 and cover single and double sided disks.
  187. To convert a starting cluster (from Directory) to a "logical" sector
  188. number used by DEBUG do the following in DOS 2.0.
  189.  
  190. 1. Subtract 2 from the cluster number (first cluster of data is 002)
  191. 2. Multiple this result by the number of sectors/cluster.(1 or 2)
  192. 3. Add number of sectors to the beginning of data area. (Table above,
  193. last column.)
  194.  
  195.  
  196.                COMPOSITE MEMORY MAP FOR THE IBM-PC
  197.  
  198.  
  199. 0000:0000_____( 1.5 K ROM )
  200.          @@@
  201.          XXX    64K RAM    )<---------
  202.          XXX               |  SEE DETAIL
  203. 0FFF:0000XXX____________   |     "A"
  204.   65,536 XXX               |   96 K UNIT
  205.          XXX    64K RAM    )<---------
  206.          |X|
  207. 1FFF:0000|X|____________
  208.  131,072 |X|
  209.          |X|    64K RAM
  210.          |X|
  211. 2FFF:0000|X|____________
  212.  196,408 |X|
  213.          |X|    64K RAM
  214.          |X|
  215. 3FFF:0000|X|____________
  216.  262,144 |O|
  217.          |O|    DO                    NOTE ADDRESSES
  218.          |O|
  219. 4FFF:0000|O|____________
  220.  327,680 |O|
  221.          |O|    DO                    ARE APPROXIMATE
  222.          |O|
  223. 5FFF:000 |O|____________
  224.  393,216 |O|
  225.          |O|    DO                  USE DEBUG AND MANUALS
  226.          |O|
  227. 6FFF:0000|O|____________
  228.  458,752 |O|
  229.          |O|    DO                        FOR EXACT
  230.          |O|
  231. 7FFF:0000|O|____________
  232.  524,288 |O|
  233.          |O|    DO                        ADDRESSES.
  234.          |O|
  235. 8FFF:0000|O|____________
  236.  589,824 |O|
  237.          |O|    DO
  238.          |O|
  239. 9FFF:0000|O|____________
  240.  655,360 |O|    16K RESERVED
  241.          |0|
  242.          |0|    48K RESERVED
  243. B000:0000|0|____________
  244.  720,896 XXX    16K MONO SCREEN     )<--------
  245. B800:0000|O|    16K EXPANSION       |  SEE DETAIL
  246.  753,664 XXX    16K COLOR/GRAPHICS  |      "B"
  247. BFFF:0000|O|____16K EXPANSION       )<--------
  248.  786,432 |O|
  249.          |O|    64K RESERVED
  250.          |O|
  251. CFFF:0000|O|____________
  252.  851,986 |O|
  253.          |O|    64K RESERVED
  254.          |O|
  255. DFFF:0000|O|____________
  256.  917,504 |O|
  257.          |O|    64K RESERVED
  258.          |O|
  259. EFFF:0000|O|____________
  260.  983,040 |O|    16K RESERVED        )<---------
  261.          @@@    8K ROM SOCKET       |  SEE DETAIL
  262.          @@@    32K ROM BASIC       |      "C"
  263. FFFF:0000@@@____8K ROM BIOS         )<--------
  264. 1,048,576
  265.  
  266.  
  267.  
  268.    DETAIL "A"  DOS 1.1 & BASICA              DOS 1.1 & DEBUG.COM
  269.  
  270.       0000:0000_________________________________0000:0000_____________
  271.                  @@@@    SYSTEM ROM 1.5 K Bytes            @@@@
  272.       0060:0000  O~~O    BOOT-DISK RTN 600 Bytes           O~~O
  273.                  OXXO                                      OXXO
  274.                  OXXO    IBMBIO.COM IBMDOS.COM             OXXO
  275.                  OXXO         COMMAND.COM                  OXXO  DOS1.1
  276.                  OXXO    DOS 1.1 ABOUT 12 K                OXXO   
  277.       PS:0000    OxxO    dos work space 256 bytes          OxxO
  278. 16 K  PS:0100   _OXXO_                                    _OXXO_      
  279.                  OXXO                                      OXXO  DEBUG
  280.   PS=DOS prog    OXXO                                      OXXO    6K
  281.    segment       OXXO                                      OXXO
  282.                  OXXO    BASICA (ADV) EXT                  OXXO  EDLIN
  283.                  OXXO         about 13 K                   OXXO--------
  284.      DS:0000-----OXXO------------------------              OXXO
  285.                  OXXO   BASIC INTERPRETER                  OXXO
  286. 32K  DS:xxxx    _OXXO_    WORK AREA 4K  ----O----         _OXXO_  PROG-
  287.                  OXXO                       |              OXXO
  288.                  OXXO  _BASIC PROGRAM MIN.  |              OXXO   RAM
  289.   DS=BASIC DATA  OXXO |     variables      MIN             OXXO
  290.     SEGMENT      OXXO |     arrays        PROGRAM          OXXO
  291.   xxxx @         OXXO |     string space    |              OXXO
  292.    DS:30 Lo      OXXO |     basic stack     |              OXXO
  293.    DS:31 Hi      OXXO |                 ----X----          OXXO
  294. 48K              OXXO |                     |             _OXXO_    
  295.                  OXXO |-BASIC PROGRAM MAX.  |
  296.    DS:yyyy_______OXXO_|                     |
  297.   yyyy @         OXXO                    MAXIMUM       DETAIL "A"
  298.    DS:358 Lo     OXXO                       |         -------------
  299.    DS:359 Hi     OXXO                       |         DOS W/ DEBUG
  300.                  OXXO                       |        (SAVEDLIN.TBX)
  301.                  OXXO    V A R I A B L E S  |
  302. 64 K Bytes      _OXXO_                      |
  303.                  OXXO                       |
  304.                  OXXO                    PROGRAM
  305.                  OXXO                       |
  306.                  OXXO    A R R A Y S        |
  307.                  OXXO                       |
  308.                  OXXO                       |
  309.                  OXXO                       |
  310. 80 K Bytes      _OXXO_                      |
  311.                  OXXO                       |
  312.                  OXXO    STRING SPACE       |
  313.                  OXXO                       |
  314.                  OXXO                       |
  315.                  OXXO    BASIC STACK        |       512 BYTES OR SET 
  316.                  OXXO                   ----O----        BY CLEAR
  317.                  OXXO
  318. 96 K Bytes      _OXXO_    
  319.                  OXXO
  320.                  OXXO
  321.                  OXXO
  322.                  OXXO
  323.                  OXXO
  324.                  OXXO
  325.  
  326.             DETAIL "A" DOS 1.1 
  327.             ------------------
  328.                  & BASICA
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.      DETAIL "B"  DISPLAY CARD'S RAM
  337.      --------------------------------
  338.                  OXXO
  339.                  OXXO
  340.                  OXXO
  341.                  OXXO    48K RESERVED
  342.                  OXXO
  343.                  OXXO
  344.                  OXXO
  345. B000:0000 _______OXXO__
  346.  720,896         xXXx
  347.                  xXXx
  348.                  xXXx    16K MONO SCREEN
  349.                  xXXx         (ON CARD)
  350.                  xXXx         (ON CARD)
  351.                  xXXx
  352.                  xXXx
  353.                __xXXx__
  354.                  OXXO
  355.                  OXXO
  356.                  OXXO    16K EXPANSION
  357.                  OXXO
  358.                  OXXO
  359.                  OXXO
  360.                  OXXO
  361. B800:0000   _____OXXO__
  362.  753,664         xXXx
  363.                  xXXx
  364.                  xXXx    16K COLOR/GRAPHICS
  365.                  xXXx       (ON CARD)
  366.                  xXXx
  367.                  xXXx
  368.                  xXXx
  369.                __xXXx__
  370.                  OXXO
  371.                  OXXO
  372.                  OXXO    16K EXPANSION
  373.                  OXXO
  374.                  OXXO
  375.                  OXXO
  376.                  OXXO
  377. C000:0000 _______OXXO__
  378.  786,432         OXXO
  379.                  OXXO
  380.                  OXXO
  381.                  OXXO    64K RESERVED
  382.                  OXXO
  383.                  OXXO
  384.                  OXXO
  385.                __OXXO__
  386.                  OXXO
  387.                  OXXO
  388.                  OXXO
  389.                  OXXO
  390.  
  391.  
  392.     DETAIL "B"   DISPLAY CARD'S RAM
  393.     -------------------------------
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.     DETAIL "C"   IBM-PC ROM
  401.     -----------------------
  402.  
  403.                  OXXO
  404.                  OXXO
  405.                  OXXO
  406.                  OXXO
  407.                  OXXO
  408.                  OXXO
  409.                  OXXO
  410.                __OXXO__
  411.                  OXXO
  412.                  OXXO
  413.                  OXXO
  414.                  OXXO     16 K
  415.                  OXXO
  416.                  OXXO     RESERVED
  417.                  OXXO
  418.                __OXXO__
  419.                  OXXO
  420.                  OXXO     8 K  R O M 
  421.                  OXXO     S O C K E T 
  422.  F600:0000 ______OXXO__
  423.  1,007,616       @@@@
  424.                  @@@@
  425.                  @@@@
  426.                __@@@@__   32 K  OF
  427.                  @@@@
  428.                  @@@@    
  429.                  @@@@
  430.                  @@@@
  431.                  @@@@      R O M 
  432.                  @@@@    
  433.                  @@@@
  434.                __@@@@__
  435.                  @@@@
  436.                  @@@@    B A S I C
  437.                  @@@@
  438.  FE00:0000 ______@@@@__
  439.  1,040,384       @@@@
  440.                  @@@@    8K ROM BIOS
  441.                  @@@@
  442.  FFFF:0000 ______@@@@__
  443.  1,048,576
  444.  
  445.  
  446.       DETAIL "C"  IBM-PC ROM
  447.       ----------------------
  448.  
  449.  
  450.   (TO PRINT OUT A COPY OF THE ABOVE MEMORY MAPS AND DETAILS)
  451.   ( AT THE DOS PROMPT  A>TYPE PEEKFILE.ROM <Ctrl-PrtSc-Enter>  )
  452.  
  453.