home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
funkybox.zip
/
PEEKFILE.DOC
< prev
next >
Wrap
Text File
|
1983-05-02
|
17KB
|
453 lines
***************************************************************
P E E K I N G I N T O F I L E S A N D R O M
***************************************************************
PEOPLE SYSTEMS, LTD. (C)1983
Have you tried the X-RAY machine program in your IBM-PC ? Perhaps
you know it by another name. Its officially called DEBUG in DOS, but
it has the longest nose of any software around. All you have to do
is learn where things are kept and how to control its ability to get
into mischief and you've got the finest tool for learning about
your IBM-PC a little at a time.
A map -- a map -- my kingdom for a map. Well without being too dramatic
there really aren't any in the manuals. Lots of address lists here and
there but a good old fashioned road-map is needed. Maybe before we get
through we'll develope one and you can print it out and put it up on
your operating room wall. But for now, pick up your IBM manual and
look at what's there. It will give you a general idea of how the memory
is utilized in the PC and on the screen and graphic boards. (Both have
about 16 Kbytes in addition to your own plugged in chips.)
Incidentally, adding RAM to your empty boards is not very difficult,
in fact, if you look for it you'll find a tutorial STUFCHIP
included in Programmer's Toolbox. Chips are available from good and
dependable dealers like Microprocessors Unlimited in Beggs. OKlahoma
ZIP 74421. Mr. John Gilchrist will give you good service and quality
parts you can depend on at (918)267-4961. His prices and chips are the
best around and he'll stand behind them if you need help.
Since we are going to be looking into both files and ROM we should get
familiar with DEBUG's LOAD command. If you find it under DEBUG in DOS
and take a look you'll find there are several options (isn't that
always the way). There are 2 options and No.2 has two formats. Lets do
Option 1 first. We used this in DISKMOD.DBG to recover a small, just
erased file. You may want to try that for an experiment. Please make
a TEST disk by DISKCOPY for fooling around purposes. DEBUG can really
screw up a Directory or FAT (File Allocation Table) if you're not
careful. But on a test disk you can't harm anything permanently.
If you remember, the LOAD command we used for disk sectors was in HEX
-L 04B5:0100 0 3 4 <enter>
It means - (hyphen-DEBUG prompt) 04B5:0100 (hex address DOS 1.1 in
segment:offset ) 0 means Drive A: 3 (starting sector on disk --
absolute) 4 (LOAD 4 sectors). In this example the HEXidecimal and
the decimal numbers are the same (up to 9). This is DOS 1.1 address.
04B5:0100 may be different in DOS 2.0.
This command LOADed the disk Directory which occupies sector numbers
3, 4, 5, 6, in that order. (there are 40 tracks with 8 sectors @ 512
bytes each on IBM-PC 160 Kbyte SS drives--this adds up to sectors 0-319
in absolute numbers). Sector 0 is the boot sector and sector 1-2 is the
FAT (File Allocation Table).
Converting Track - Sector to absolute sector is not difficult. Tracks
run from 0 to 39 on a 40 track disk there are 8 sectors on each track
and, in this case, are numbered 1 thru 8 (just to be cute). So to
convert DOS 1.1 SS say Track 10 Sector 6 to absolute sector use:
(8 * Track No. + Sectors) -1 = Absolute sector
In this case (8 * 10 + 6) -1 = 85
Of couse if you want absolute sectors 85 to 95 inclusive there are 11.
Do it on your fingers if you have trouble -- really.
The fingers are the world's oldest Abacus. (Chinese bead computer)
Sometimes it helps to see it graphically:
THIS IS A DISK INITIALIZED WITH FORMAT/S (SYSTEM AND COMMAND.COM INCL.)
This is a single sided disk - 8 sectors per track DOS 1.1
Track Sector Abs.Sector File
0 1 0 BOOT record Part of System in Format/s
0 2 1 File Allocation Table
0 3 2 FAT second copy -- same as 2
0 4 3 Directory
0 5 4 Directory
0 6 5 Directory
0 7 6 Directory
0 8 7 IBMBIO.COM (OR DATA-if FORMAT NOT/S)
NEXT Sector 8 above is called Cluster 002 -- beginning of DATA
1 1 8 IBMBIO.COM
1 2 9 IBMBIO.COM
1 3 10 IBMBIO.COM
1 4 11 IBMDOS.COM FIRST SECTOR OF IBMDOS.COM
1 5 12 IBMDOS.COM
1 6 13 IBMDOS.COM
1 7 14 IBMDOS.COM
1 8 15 IBMDOS.COM
NEXT
2 1 16 DO
2 2 17 DO
2 3 18 DO
2 4 19 DO
(we have skipped a few lines of monotony)
2 8 23 LAST SECTOR OF IBMDOS.COM
NEXT
3 1 24 COMMAND.COM BEGINS
COMMAND.COM CONTINUES FOR 12 SECTORS
NEXT
4 4 35 COMMAND.COM ENDS
4 5 36 YOUR PROGRAM OR DATA BEGINS
MANY - MANY SECTORS LATER
39 8 319 LAST SECTOR AVAILABLE ON SS DISK
D.S.D.D. records each track front and back before proceeding to next.
There are 40 tracks (0-39) front and back and the disk drive covers
Track 0 side 0 then Track 0 side 1 and goes back to the front(0) and
moves to Track 1 side 0 then track 1 side 1 then T1-S0, T1-S1,
T2-S0, T2-S1 etc. across the disk, reducing unnecessary head travel.
It would be easier to fathom the arrangement IBM-PC chose
if these terms were in rational order as they should have been. The
progression logically is SIDE 0,1 TRACK 0-39 and SECTOR 1-8 but because
every one was used to working without a side number, IBM moguls added
the side designation to the end of the train instead of up front where
it belongs.
Double sided disks have a slightly different format -- they add 3 more
sectors to the Directory beginning at Track 0 sector 8 side 0, then on
back, Track 0 Sectors 1,2 Side 1, splitting the directory S0,S1. All of
the track 0 operations above take place on single sided disks. But the
system/data files don't start until Track 0 sector 3 side 1 (backside),
(on D.S.D.D. Disks).
DOS 1.1 is more complicated to compute the absolute sector number on
double sided disks. D.S. disks use each track front and back before
proceeding to the next track. DOS 2.0 increases the storage and the
problem, adding another sector to each track making it 9 instead of 8.
Sector numbering for debug is changed in DOS 2.0 -- so we will
take that up. Just compare page 6-8 in DOS 1.1 with 12-11 in DOS 2.0
and if that doesn't confuse you for a while, I'll eat my IBM-PC. But,
they are now making the relative numbering (absolute) follow the
head and side counting system, as it should have been.
Try ABSECTOR.TBX and CLUSECTOR.TBX for computing on ToolBox disks.
Now there are 9 sectors on 40 Tracks (0-39) on Side 0 and Side 1 or
9 * 40 * 2 = 720 sectors total. At 512 bytes per sector gives
a grand total of 720 * 512 = 368,640 bytes OR 2,949,120 Bits.
At 6 characters per word this is over 60,000 words. WOW, most folks
don't need a hard disk unless they have a humongous data base and
people who are constantly entering data and maintaining the files,
like accessing a mainframe's database (as some PC's do.)
Why, 60,000 words is a paperback's (about 160 pages) worth of memory
on a D.S.D.D.disk. Technical data recording, like analog to digital
could produce a large amount of data storage. But the average computer
user might do well to avoid the expense and dubious advantages of a
hard disk. Who wants all their eggs (programs) in one basket with
no easy back-up?
In case you aren't interested in getting a fixed disk (IBM jargon).
Here is a table from page C-2 in DOS 2.0 that will explain the vagaries
of 1 or 2 sides and 8 or 9 sectors. We have added the last column for
ease in computing absolute sectors from cluster numbers.
No. of Sectors/ FAT size DIR DIR Sectors/ Sector No.
Sides Track Sectors Sectors Entries Cluster Begin Data
1 8 1 * 2 4 64 1 6
2 8 1 * 2 7 112 2 9
1 9 2 * 2 4 64 1 8
2 9 2 * 2 7 112 2 11
Notice the change from DOS 1.1 . Fat was 2 sectors -- each containing
a separate copy of FAT so that if one copy was unreadable there was an-
other. Now the FAT is two sectors times two copies for DOS 2.0 nine
sector disks. This change accompanied relative (absolute) renumbering
mentioned above in DOS 2.0.
In DOS 1.1 there is a table converting clusters to relative segments.
The pages begin on C-9 and cover single and double sided disks.
To convert a starting cluster (from Directory) to a "logical" sector
number used by DEBUG do the following in DOS 2.0.
1. Subtract 2 from the cluster number (first cluster of data is 002)
2. Multiple this result by the number of sectors/cluster.(1 or 2)
3. Add number of sectors to the beginning of data area. (Table above,
last column.)
COMPOSITE MEMORY MAP FOR THE IBM-PC
0000:0000_____( 1.5 K ROM )
@@@
XXX 64K RAM )<---------
XXX | SEE DETAIL
0FFF:0000XXX____________ | "A"
65,536 XXX | 96 K UNIT
XXX 64K RAM )<---------
|X|
1FFF:0000|X|____________
131,072 |X|
|X| 64K RAM
|X|
2FFF:0000|X|____________
196,408 |X|
|X| 64K RAM
|X|
3FFF:0000|X|____________
262,144 |O|
|O| DO NOTE ADDRESSES
|O|
4FFF:0000|O|____________
327,680 |O|
|O| DO ARE APPROXIMATE
|O|
5FFF:000 |O|____________
393,216 |O|
|O| DO USE DEBUG AND MANUALS
|O|
6FFF:0000|O|____________
458,752 |O|
|O| DO FOR EXACT
|O|
7FFF:0000|O|____________
524,288 |O|
|O| DO ADDRESSES.
|O|
8FFF:0000|O|____________
589,824 |O|
|O| DO
|O|
9FFF:0000|O|____________
655,360 |O| 16K RESERVED
|0|
|0| 48K RESERVED
B000:0000|0|____________
720,896 XXX 16K MONO SCREEN )<--------
B800:0000|O| 16K EXPANSION | SEE DETAIL
753,664 XXX 16K COLOR/GRAPHICS | "B"
BFFF:0000|O|____16K EXPANSION )<--------
786,432 |O|
|O| 64K RESERVED
|O|
CFFF:0000|O|____________
851,986 |O|
|O| 64K RESERVED
|O|
DFFF:0000|O|____________
917,504 |O|
|O| 64K RESERVED
|O|
EFFF:0000|O|____________
983,040 |O| 16K RESERVED )<---------
@@@ 8K ROM SOCKET | SEE DETAIL
@@@ 32K ROM BASIC | "C"
FFFF:0000@@@____8K ROM BIOS )<--------
1,048,576
DETAIL "A" DOS 1.1 & BASICA DOS 1.1 & DEBUG.COM
0000:0000_________________________________0000:0000_____________
@@@@ SYSTEM ROM 1.5 K Bytes @@@@
0060:0000 O~~O BOOT-DISK RTN 600 Bytes O~~O
OXXO OXXO
OXXO IBMBIO.COM IBMDOS.COM OXXO
OXXO COMMAND.COM OXXO DOS1.1
OXXO DOS 1.1 ABOUT 12 K OXXO
PS:0000 OxxO dos work space 256 bytes OxxO
16 K PS:0100 _OXXO_ _OXXO_
OXXO OXXO DEBUG
PS=DOS prog OXXO OXXO 6K
segment OXXO OXXO
OXXO BASICA (ADV) EXT OXXO EDLIN
OXXO about 13 K OXXO--------
DS:0000-----OXXO------------------------ OXXO
OXXO BASIC INTERPRETER OXXO
32K DS:xxxx _OXXO_ WORK AREA 4K ----O---- _OXXO_ PROG-
OXXO | OXXO
OXXO _BASIC PROGRAM MIN. | OXXO RAM
DS=BASIC DATA OXXO | variables MIN OXXO
SEGMENT OXXO | arrays PROGRAM OXXO
xxxx @ OXXO | string space | OXXO
DS:30 Lo OXXO | basic stack | OXXO
DS:31 Hi OXXO | ----X---- OXXO
48K OXXO | | _OXXO_
OXXO |-BASIC PROGRAM MAX. |
DS:yyyy_______OXXO_| |
yyyy @ OXXO MAXIMUM DETAIL "A"
DS:358 Lo OXXO | -------------
DS:359 Hi OXXO | DOS W/ DEBUG
OXXO | (SAVEDLIN.TBX)
OXXO V A R I A B L E S |
64 K Bytes _OXXO_ |
OXXO |
OXXO PROGRAM
OXXO |
OXXO A R R A Y S |
OXXO |
OXXO |
OXXO |
80 K Bytes _OXXO_ |
OXXO |
OXXO STRING SPACE |
OXXO |
OXXO |
OXXO BASIC STACK | 512 BYTES OR SET
OXXO ----O---- BY CLEAR
OXXO
96 K Bytes _OXXO_
OXXO
OXXO
OXXO
OXXO
OXXO
OXXO
DETAIL "A" DOS 1.1
------------------
& BASICA
DETAIL "B" DISPLAY CARD'S RAM
--------------------------------
OXXO
OXXO
OXXO
OXXO 48K RESERVED
OXXO
OXXO
OXXO
B000:0000 _______OXXO__
720,896 xXXx
xXXx
xXXx 16K MONO SCREEN
xXXx (ON CARD)
xXXx (ON CARD)
xXXx
xXXx
__xXXx__
OXXO
OXXO
OXXO 16K EXPANSION
OXXO
OXXO
OXXO
OXXO
B800:0000 _____OXXO__
753,664 xXXx
xXXx
xXXx 16K COLOR/GRAPHICS
xXXx (ON CARD)
xXXx
xXXx
xXXx
__xXXx__
OXXO
OXXO
OXXO 16K EXPANSION
OXXO
OXXO
OXXO
OXXO
C000:0000 _______OXXO__
786,432 OXXO
OXXO
OXXO
OXXO 64K RESERVED
OXXO
OXXO
OXXO
__OXXO__
OXXO
OXXO
OXXO
OXXO
DETAIL "B" DISPLAY CARD'S RAM
-------------------------------
DETAIL "C" IBM-PC ROM
-----------------------
OXXO
OXXO
OXXO
OXXO
OXXO
OXXO
OXXO
__OXXO__
OXXO
OXXO
OXXO
OXXO 16 K
OXXO
OXXO RESERVED
OXXO
__OXXO__
OXXO
OXXO 8 K R O M
OXXO S O C K E T
F600:0000 ______OXXO__
1,007,616 @@@@
@@@@
@@@@
__@@@@__ 32 K OF
@@@@
@@@@
@@@@
@@@@
@@@@ R O M
@@@@
@@@@
__@@@@__
@@@@
@@@@ B A S I C
@@@@
FE00:0000 ______@@@@__
1,040,384 @@@@
@@@@ 8K ROM BIOS
@@@@
FFFF:0000 ______@@@@__
1,048,576
DETAIL "C" IBM-PC ROM
----------------------
(TO PRINT OUT A COPY OF THE ABOVE MEMORY MAPS AND DETAILS)
( AT THE DOS PROMPT A>TYPE PEEKFILE.ROM <Ctrl-PrtSc-Enter> )