home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
ZCPR33
/
A-R
/
IOPUG.LBR
/
IOPANAL.SZ
/
IOPANAL.SI
Wrap
Text File
|
2000-06-30
|
14KB
|
268 lines
.PN 1
.FO 4-#
4. Analysis of a Sample IOP
Thi≤ chapte≥ i≤ ß runninτ commentar∙ oε thσ Samplσ IO╨ whosσ ì
sourcσá codσá i≤á presenteΣ iε Appendi°á B«á Al∞á commentar∙á i≤ ì
referenceΣá b∙á thσá linσá number≤ giveεá iεá thi≤á sourcσá code« ì
Sectioεá ▒ oµ Appendi° ┬ shoulΣ bσ examineΣ whilσ readinτ througΦ ì
thi≤ chapter.
4.1. Analysis of the Sample IOP Source
Line≤ ▒ t∩ 3╕ comprisσ thσ fron⌠ oµ thσ IOP«á Notσ thσ basσ ì
addres≤ oµ thσ IO╨ oε linσ 6¼á thσ jum≡ tablσ oε line≤ 1╢ t∩á 34¼ ì
anΣ thσ IO╨ I─ oε linσ 38«á Wheε LD╥ load≤ aε IOP¼á i⌠ check≤ t∩ ì
seσá tha⌠á thσá prope≥ numbe≥ oµ jump≤ anΣ tha⌠ thσá IO╨á I─á arσ ì
present.
4.1.1. STATUS, SELECT, and NAMER Routines
Thσá STATUS¼á SELECT¼á anΣ NAME╥ routine≤ arσ iε line≤ 4╣ t∩ ì
130«á I⌠ i≤ througΦ thesσ routine≤ tha⌠ thσ externa∞ environmen⌠ ì
determine≤ thσ attribute≤ oµ thσ IO╨ anΣ issue≤ devicσá selectioε ì
commands to the IOP.
STATU╙áá return≤á thσá addres≤á oµá thσá IO╨á Statu≤áá Tablσ ì
(IOPTABLE)¼ whicΦ i≤ showε iε line≤ 4│ t∩ 47« Thi≤ tablσ i≤ useΣ ì
t∩á determinσ ho≈ man∙ devicσ driver≤ fo≥ eacΦ logica∞ devicσ arσ ì
availablσ anΣ whicΦ devicσ drive≥ i≤ currentl∙ selected«á STATU╙ ì
als∩á return≤á ßá valuσ iε A«á Thσ MS┬ oµ ┴ i≤á se⌠á iµá thσá I╧ ì
Recorde≥á functioεá oµá thσá IO╨ i≤ supported«á Thσá res⌠á oµá ┴ ì
contain≤á ßá numbe≥á froφá ▒ t∩ 12╖ whicΦá i≤á useΣá b∙á thσá IO╨ ì
implemente≥á t∩ identif∙ thσ IOP«á Iµ thσ valuσ oµ ┴ i≤ 0¼á theε ì
thσá IO╨ i≤ considereΣ t∩ bσ non-operationa∞ b∙ thσá ZCPR│á tool≤ ì
whicΦá addres≤ thσ IOP«á Thσ IO╨ numbe≥ i≤ no⌠ useΣ b∙ an∙ ZCPR│ ì
tools except to insure that this value is not zero.
SELEC╘ i≤ useΣ t∩ assigε ß devicσ drive≥ fo≥ ß giveε logica∞ ì
device«á Thσ logica∞ devicσ i≤ identifieΣ b∙ thσ ┬ register¼ anΣ ì
thσ desireΣ drive≥ i≤ identifieΣ b∙ thσ ├ register«á ┬ mus⌠ havσ ì
ß valuσ froφ ░ t∩ │ o≥ aε erro≥ conditioε i≤ returneΣ (seσá line≤ ì
6╕ t∩ 70)« B=░ select≤ thσ CO╬ device¼ ▒ thσ RDR¼ ▓ thσ PUN¼ anΣ ì
│ select≤ thσ LS╘ device.
Line≤á 6╕ t∩ 7╕ arσ useΣ t∩ locatσ thσ bytσ pai≥á associateΣ ì
witΦ ß giveε logica∞ device« Sincσ IOPTABL┼ consist≤ oµ two-bytσ ì
entries¼ thσ valuσ oµ ┬ (whicΦ i≤ ░ t∩ 3⌐ i≤ doubleΣ (t∩ 0¼ 2¼ 4¼ ì
6⌐ anΣ useΣ a≤ aε offse⌠ froφ thσ basσ addres≤ oµ IOPTABLE« Thi≤ ì
locate≤á thσ desireΣ bytσ pair«á Line≤ 7╡ t∩ 7╕ theε comparσ thσ ì
maximuφ numbe≥ oµ device≤ t∩ thσ requesteΣ device¼á insurinτ tha⌠ ì
thσá requesteΣá devicσ numbe≥ i≤ withiεá range«á Iµá no⌠á withiε ì
range¼á thσá erro≥á routinσ (SELERR⌐ i≤ brancheΣ to«á Iµá withiε ì
range¼á thσ pointe≥ i≤ advanceΣ t∩ thσ 2nΣ bytσ oµ thσ bytσá pai≥ ì
(linσ 79)¼ anΣ thσ ne≈ devicσ i≤ selecteΣ b∙ storinτ thσ content≤ ì
oµ ├ int∩ thσ curren⌠ selectioε bytσ (linσ 80).
.cp 2è NAME╥ i≤ useΣ t∩ returε ß strinτ whicΦ name≤ ß devicσ drive≥ ì
anΣá optionall∙ provide≤ ß description«á Likσ thσ SELEC╘á input¼ ì
NAME╥á expect≤ ß logica∞ devicσ numbe≥ iε ┬ (░ t∩ 3⌐ anΣ ß devicσ ì
drive≥á numbe≥ iε C«á Thσ indexinτ anΣ erro≥ checkinτá iεá NAME╥ ì
(seσá line≤á 9╡á t∩ 106⌐ arσ simila≥ t∩ thosσá iεá SELECT«á Oncσ ì
certaiε tha⌠ ┬ anΣ ├ arσ withiε range¼ NAME╥ theε indexe≤ througΦ ì
two address tables to locate the string.
Thσá firs⌠ table¼á IOPDNAMES¼á i≤ addresseΣ b∙ thσá codσá iε ì
line≤á 10╖ t∩ 112«á Thσ tablσ IOPDNAME╙ i≤ iε line≤ 13╢ t∩á 140« ì
A⌠á linσá 107¼á D┼ contain≤ thσ offse⌠ (0¼á 2¼á 4¼á 6⌐á int∩á thσ ì
IOPDNAME╙á tablσá fo≥á thσá CON¼áá RDR¼á PUN¼á anΣá LS╘á devices¼ ì
respectively«á Afte≥á linσá 11▓á i≤ executed¼á H╠á contain≤á thσ ì
addres≤ oµ ß tablσ oµ addresse≤ fo≥ thσ string≤ associateΣ witΦ ß ì
particula≥ logica∞ device«á Iε thi≤ case¼á H╠ contain≤ thσ valuσ ì
of one of these symbols:
.uj 0
CONNAMES RDRNAMES PUNNAMES LSTNAMES
.uj 1
See lines 132 to 173 for a review of these tables.
No≈á tha⌠ thσ addres≤ oµ thσ desireΣ addres≤ tablσ i≤ known¼ ì
thσá codσá indexe≤á int∩ thi≤ tablσ baseΣ oεá thσá devicσá drive≥ ì
identifieΣ iε thσ ├ register« Line≤ 11│ t∩ 12▒ d∩ thi≤ indexing« ì
Likσ thσ codσ iε line≤ 9╢ t∩ 112¼á thσ techniquσ oµ doublinτá thσ ì
inde°á valuσ (iε thσ ├ registe≥ a⌠ linσ 113⌐ anΣ theε addinτ thi≤ ì
t∩á HL¼á whicΦá contain≤ thσ basσ addres≤ oµ thσá strinτá addres≤ ì
tablσ fo≥ ß particula≥ logica∞ device¼á i≤ applied«á Afte≥á linσ ì
11╖á i≤ executed¼á H╠ contain≤ thσ addres≤ oµ thσ addres≤ oµá thσ ì
desireΣá string«á Line≤á 11╕ t∩ 12▒ simpl∙ extrac⌠ thσá string'≤ ì
addres≤ anΣ returε i⌠ iε HL.
Notσ that¼á fo≥ thσ sakσ oµ debugging¼á thσ NAMERRO╥ routinσ ì
no⌠ onl∙ return≤ thσ erro≥ codσ (A=░ anΣ Zer∩ Flaτ Set)¼á bu⌠á i⌠ ì
also returns the address of an Error Message in HL.
Thσ string≤ iε line≤ 16▒ t∩ 17▓ providσ name≤ t∩ thσ variou≤ ì
devices« Notσ tha⌠ wheε n∩ description≤ arσ provideΣ (line≤ 161¼ ì
162¼ 167¼ 169¼ 171¼ anΣ 172)¼ thσ name≤ arσ terminateΣ b∙ ß spacσ ì
followeΣ b∙ aε endinτ ░ (thσ strinτ terminator)«á Als∩ notσ tha⌠ ì
thσ name≤ arσ capitalized.
4.1.2. Initialization and Device Drivers
Thσá INI╘á routinσá iε line≤ 17┤ t∩ 18▒ i≤á simplσá iεá thi≤ ì
example« I⌠ turn≤ ofµ thσ I╧ Recorde≥ flags« Iε ß differen⌠ IO╨ ì
implementation¼áá withiεá thσá INI╘á routinσá woulΣá bσá codσá t∩ ì
configurσá thσ UART╙ (╖ o≥ ╕ bits¼á parit∙ o≥á none¼á bauΣá rate¼ ì
etc).
Line≤ 19▓ t∩ 23▒ sho≈ thσ fou≥ basiπ routine≤ fo≥á providinτ ì
I/╧ t∩ thσ CR╘ hardware« Notσ tha⌠ the≤e example≤ show thσ CRT'≤ ì
UAR╘á a≤á beinτ memor∙ mappeΣ (LD┴ anΣ ST┴ instruction≤ arσá useΣ ì
insteaΣá oµá I╬á anΣ OUT)¼á anΣ thσ datß anΣá statu≤á value≤á arσ ì
inverteΣ (notσ thσ CM┴ instruction≤ iε line≤ 203¼á 211¼á 221¼ anΣ ì
229)«á Thσ value≤ returneΣ anΣ thσ registe≥ convention≤ useΣ arσ ì
compatiblσá witΦ thosσ requireΣ fo≥ thσ BIO╙ routine≤ likσá CONI╬ ì
and CONOUT (ie, passing output character in the C register).
Line≤á 23┤ t∩ 27╡ sho≈ thσ fou≥ basiπ routine≤ fo≥ providinτ ì
I/╧ t∩ thσ modeφ hardware«á Thesσ example≤ sho≈ thσ modem'≤ UAR╘ ì
a≤ beinτ I/╧ mappeΣ (I╬ anΣ OU╘ arσ used)«á Similarly¼ line≤ 27╕ ìèt∩á 31▓á sho≈ thσ fou≥ basiπ routine≤ fo≥ providinτá I/╧á t∩á thσ ì
printer hardware.
4.1.3. BIOS Interface Routines
Line≤á 31┤ t∩ 37╡ contaiε thσ routine≤ entereΣ froφ thσ jum≡ ì
tablσá whicΦá arσ indexeΣ int∩á froφá thσá BIOS«á Namely¼á thesσ ì
routines (lines 317 to 345) are:
.uj 0
CONST CONIN CONOUT LIST PUNCH READER
LISTST
.uj 1
Iε al∞ cases¼á thσ inpu⌠ anΣ statu≤ routine≤ (CONST¼á CONIN¼ ì
READER¼ LISTST⌐ returε thei≥ value≤ iε thσ ┴ registe≥ anΣ requirσ ì
n∩ inpu⌠ values¼á anΣ thσ outpu⌠ routine≤ (CONOUT¼á LIST¼á PUNCH⌐ ì
obtaiεá thσ value≤ t∩ outpu⌠ froφ thσ ├ register«á Consequently¼ ì
sincσ ├ carrie≤ thσ onl∙ inpu⌠ value¼á thσ samσ codσ (DRVRUN⌐ caε ì
bσ useΣ t∩ proces≤ al∞ oµ thσ BIO╙ entr∙ routine≤ iµ DRVRU╬á doe≤ ì
not have an effect on the C register.
Thσ routine≤ arσ table-driven«á DRVRU╬ accept≤ a≤ inpu⌠ thσ ì
addres≤á oµ thσ tablσ fo≥ thσ logica∞ devicσ iε H╠ anΣ thσ numbe≥ ì
oµ thσ logica∞ devicσ iε ┬ (a≤ fo≥ thσ SELEC╘ anΣ NAME╥ routines¼ ì
┬ contain≤ ß valuσ froφ ░ t∩ 3)«á DRVRU╬ use≤ thσ valuσ iε ┬á t∩ ì
obtaiεá thσá numbe≥ oµ thσ currently-selecteΣ devicσ drive≥á froφ ì
thσ IOPTABL┼ (seσ line≤ 35╢ t∩ 363)« Afte≥ linσ 36│ i≤ executed¼ ì
┬ contain≤ thσ numbe≥ oµ thσ desireΣ devicσ driver« Line≤ 36┤ t∩ ì
36╖á theε doublσ thi≤ numbe≥ (iε orde≥ t∩ usσ i⌠ a≤á aεá offset)¼ ì
anΣ placσ i⌠ int∩ DE« Linσ 36╕ obtain≤ thσ addres≤ oµ thσ devicσ ì
driver address table.
Afte≥ linσ 36╕ i≤ executed¼á H╠ contain≤ thσ address oµ onσ oµ ì
the following tables:
.uj 0
TCONST TCONIN TCONOUT TLIST TREADER TPUNCH
TLISTST
.uj 1
D┼á contain≤á thσ offse⌠ int∩ thσ tablσ pointeΣ t∩ b∙á H╠á which¼ ì
wheε addeΣ t∩ H╠ (linσ 369)¼á provide≤ thσ addres≤ oµ thσ addres≤ ì
oµ thσ devicσ driver« Line≤ 37░ t∩ 37│ obtaiε thσ addres≤ oµ thσ ì
devicσ drive≥ iε HL¼ anΣ linσ 37┤ (PCHL⌐ transfer≤ contro∞ t∩ thσ ì
device driver.
Note the device driver tables in lines 376 to 416.
4.1.4. IO Recorder
Thσá I╧ Recorde≥ functioε i≤ addresseΣ iε thσ BIO╙ Interfacσ ì
Routines«á Notσá thσ cal∞ t∩ CRECOR─ iε linσ 32╢ anΣ LRECOR─á iε ì
linσá 331«á Thσ codσ oµ CRECOR─ anΣ LRECOR─ i≤ iε line≤á 44│á t∩ ì
454«á Notσ that¼á iε thi≤ particula≥ implementation¼ CRECOR─ anΣ ì
LRECOR─á simpl∙á senΣ thσ characte≥ t∩ bσ outpu⌠ t∩ thσ Modeφá iµ ì
thσ CRE├ anΣ LRE├ flags¼á respectively¼á arσ set«á Remembe≥á thσ ì
initializatioε routine¼á INIT¼ iε line≤ 17╖ t∩ 181┐ Al∞ INI╘ diΣ ì
wa≤ clea≥ thesσ flag≤ s∩ thσ IO╨ woulΣ no⌠ comσ u≡ witΦ recordinτ ì
on.
Iεá thi≤á implementation¼á thσ I╧ Recorde≥á serve≤á t∩á senΣ ì
outpu⌠á t∩á thσ Modeφ a≤ wel∞ a≤ t∩ thσ selecteΣ CONOU╘á o≥á LIS╘ ì
device« Iε operation¼ thσ use≥ i≤ expecteΣ t∩ havσ ruε ß prograφ ìèoεá thσá compute≥ a⌠ thσ othe≥ enΣ oµ thσ Modeφ connectioεá whicΦ ì
receive≤á characters¼á send≤ ß ^╙ wheε it≤ buffe≥ i≤á ful∞á (notσ ì
tha⌠ MODOU╘ iε line≤ 26│ t∩ 27╡ pay≤ attentioε t∩ ^S)¼ write≤ it≤ ì
buffe≥á t∩á disk¼á anΣá theε send≤ somσ othe≥ characte≥á (^Q⌐á t∩ ì
resumσ transmissioε througΦ thσ MODOU╘ driver« Thσ ZCPR│ commanΣ ì
linσá "RECOR─á ONó call≤ thσ COPE╬ routinσ (line≤á 46░á t∩á 463)¼ ì
whicΦá simpl∙ set≤ thσ CRE├ flaτ t∩ true«á Likewise¼á "RECOR─ O╬ ì
PRINTERóá call≤ thσ LOPE╬ routinσ (line≤ 47░á t∩á 473)«á "RECOR─ ì
OFFó call≤ thσ CCLOS┼ routinσ (line≤ 46┤ t∩ 469⌐ whicΦ clear≤ thσ ì
CRE├á flaτá anΣ send≤ ß ^┌ t∩ thσ modeφ (whicΦ tell≤ thσá prograφ ì
runninτ therσ t∩ closσ it≤ filσ anΣ exit)«á Likewisσ fo≥á LCLOS┼ ì
(lines 474 to 479).
Iεá lookinτá back¼á ╔ realizσ tha⌠ MODOU╘ shoulΣá havσá als∩ ì
checkeΣá fo≥ thσ outpu⌠ oµ ^┌ anΣ no⌠ alloweΣ i⌠ s∩ thσá recorde≥ ì
oεá thσá compute≥á tieΣá t∩á thσá modeφá woulΣá no⌠á accidentall∙ ì
terminatσ operation« Sligh⌠ oversight.
4.1.5. Hardware Combinations
Thσá simplσ devicσ driver≤ iε line≤ 19▓ t∩ 31│ caε bσ easil∙ ì
combineΣ int∩ "hybridó devices« Thσ routine≤ iε line≤ 41╖ t∩ 43╣ ì
sho≈ sucΦ devices«á CRTMODIS╘ return≤ thσ inpu⌠ statu≤ froφá thσ ì
CR╘á anΣá Modeφá iε parallel«á I⌠ indicate≤ iµá ßá characte≥á i≤ ì
pendinτ oε eithe≥ device« CRTMODI╬ input≤ ß characte≥ froφ ß CR╘ ì
anΣá Modeφ combination¼á wherσ thσ characte≥ inpu⌠ come≤ froφ thσ ì
CR╘á o≥á thσá Modem¼áá whicheve≥á receive≤á ßá characte≥áá first« ì
CRTMODOU╘ output≤ t∩ thσ CR╘ anΣ Modeφ iε paralle∞ (notσ tha⌠ thσ ì
├á registe≥á contain≤á thσ characte≥ t∩ output¼á anΣá CRTOU╘á anΣ ì
MODOU╘á d∩á no⌠ affec⌠ thσ ├ registe≥ iε line≤ 225-23▒á anΣá 263-ì
275)« CRTPRTOU╘ i≤ simila≥ t∩ CRTMODOUT.
Thesσá combination≤á oµá device≤ arσá declareΣá t∩á thσá IO╨ ì
througΦá thσ devicσ drive≥ table≤ (line≤ 37╢ t∩ 415)«á Notσ tha⌠ ì
thσá thirΣá consolσá (selecteΣá drive≥ i≤á 2⌐á i≤á identifieΣá b∙ ì
CRTMODIS╘á (linσ 382⌐ fo≥ inpu⌠ status¼á CRTMODI╬ (linσ 390⌐á fo≥ ì
input¼á anΣ CRTMODOU╘ (linσ 398⌐ fo≥ output« Thi≤ i≤ thσ CR╘ anΣ ì
Modeφ iε paralle∞ fo≥ botΦ inpu⌠ anΣ output«á Iεá contrast¼á thσ ì
fourtΦá consolσ (selecteΣ drive≥ i≤ 3⌐ i≤ identifieΣ b∙á CRTISTA╘ ì
(linσá 383⌐á fo≥ inpu⌠ status¼á CRTI╬ (linσ 391⌐ fo≥á input¼á anΣ ì
CRTPRTOU╘ (linσ 399⌐ fo≥ output«á Thi≤ i≤ thσ CR╘ inpu⌠ witΦ CR╘ ì
and printer output.
4.1.6. IOP Patching
Thσá PATC╚ routinσ i≤ thσ las⌠ t∩ bσ discussed«á I⌠á i≤á iε ì
line≤á 48┤ t∩ 500«á Notσ tha⌠ it≤ solσ purposσ i≤ t∩ changσá thσ ì
addresse≤á fo≥á thσ fiftΦ consolσ (selecteΣ drive≥á i≤á 4)«á Thσ ì
addresse≤ fo≥ PATISTAT¼á PATIN¼ anΣ PATOU╘ arσ iε line≤ 384¼ 392¼ ì
and 400, respectively.
PATC╚áá i≤á extremel∙á usefu∞á iεá debugginτá candidatσá IO╨ ì
routines« Thσ consolσ caε selec⌠ thσ TES╘ devicσ (viß thσ SELEC╘ ì
routine)¼á thσ tes⌠ caε bσ done¼á anΣ theε thσ consolσ caε selec⌠ ì
some other console device to restore order.
.paè4.1.7. Adding Device Drivers
Thσá samplσá IO╨ caε bσ easil∙ modifieΣ t∩á adΣá anΣá removσ ì
devicσá drivers«á Thσ codσ fo≥ thσ devicσ drive≥ itselµ mus⌠á bσ ì
added¼ anΣ thσ followinτ change≤ mus⌠ bσ made:
.uj 0
1. modify the number of devices in IOPTABLE (lines 43-47)
2« modify thσ strinτ addres≤ table≤ (line≤ 145-157)
3. modify the strings (lines 161-172)
4. modify the device driver tables (lines 376-415):
Console - Change TCONST, TCONIN, TCONOUT
Reader - Change TREADER
Punch - Change TPUNCH
List - Change TLIST, TLISTST
.uj 1
4.2. Terminal Session
Thσá termina∞ sessioε iε sectioε ▓ oµ Appendi° ┬á show≤á ho≈ ì
thσá IO╨á whicΦ wa≤ analyzeΣ abovσ i≤ assembleΣ anΣ prepareΣá fo≥ ì
usσá oε ß ZCPR│ system«á Thσ command≤ arσ discusseΣ iε orde≥á iε ì
the following paragraphs.
Thσá commanΣá "lasφá samiop.bbzóá assemble≤á SAMIOP.AS═á anΣ ì
generate≤ SAMIOP.HE╪ oε drivσ B« Thσ commanΣ "mloaΣ samiopó theε ì
creates SAMIOP.COM from SAMIOP.HEX (the assembler output).
SAMIOP.CO═á i≤á no⌠ ß truσ CO═ file«á I⌠ i≤ ORGeΣá a⌠á somσ ì
valuσ othe≥ thaε 100╚ (seσ line≤ 6-1▒ iε thσ Samplσ IO╨ listing)« ì
Thσá commanΣ "reε sample.iop=samiop.comó create≤ thσ desireΣá IO╨ ì
file, with the file type of IOP.
SAMPLE.IO╨á i≤ theε loadeΣ int∩ thσ IO╨ buffe≥ (anΣá checkeΣ ì
fo≥á validit∙ beforσ thσ load⌐ b∙ thσ commanΣá "ld≥á sample.iop"« ì
The IOP is now active (the INIT routine was called by LDR).
Thσá commanΣá "de÷ Σ aó display≤ al∞á devices«á Thσá devicσ ì
names and any descriptive comments are clearly displayed.
Thσá commanΣá "de÷ π testó select≤ thσ devicσ nameΣ TES╘á a≤ ì
thσ CONsolσ device«á Iε SAMPLE.IOP¼ TES╘ i≤ thσ devicσ whicΦ caε ì
bσ patcheΣ b∙ PATCH¼ anΣ i⌠ default≤ t∩ thσ CR╘ (whicΦ i≤ wh∙ thσ ì
systeφ i≤ stil∞ running)«á Thσ commanΣ whicΦ follows¼ "de÷ Σ c"¼ ì
displays the console device names and current selection.
Finally¼á "de÷ π crtó reassign≤ thσ devicσ nameΣ CR╘ t∩á thσ ì
CONsole.