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
/
JSAGE
/
ZSUS
/
PROGPACK
/
V42-DOCS.LBR
/
SYSLIB42.DZC
/
SYSLIB42.DOC
Wrap
Text File
|
1990-06-08
|
208KB
|
4,176 lines
.hm1
.fm1
.sr0
.he ZCPR3: THE LIBRARIES 4.2
.fo Page #
.pn 1
Preface
Thσ áLibraries¼ Versioε 4¼ ha≤ takeε ove≥ tw∩ year≤ t∩ arrivσ áa⌠ ì
thi≤ ápoin⌠ áiε árelease« Durinτ tha⌠ time¼ áwσ áhavσ áwitnesseΣ ì
change≤ áiε thσ maiε supplie≥ fo≥ ┌-Tool≤ froφ Echeloε át∩ áAlphß ì
System≤ anΣ others¼ witΦ aε addeΣ glitcΦ oµ ownershi≡ anΣ ájustiì
ficatioε áfo≥ upgradinτ thσ Libraries« Thank≤ t∩ Joσ áWrigh⌠ áoµ ì
Alphß áSystem≤ fo≥ authorizinτ thi≤ effort¼ anΣ iε áallowinτ áthσ ì
downloadinτ áanΣ otherwisσ freσ distributioε oµ thσ RE╠ anΣ áHEL╨ ì
files« á Sourcσ codσ i≤ availablσ froφ Alphß Systems¼ áCorp¼ á71▒ ì
ChatswortΦ Place¼ Saε Jose¼ C┴ 95128.
╔ woulΣ likσ t∩ thanδ Keε Taschne≥ anΣ Brucσ Morgeε fo≥ instigatì
inτ áthi≤ effor⌠ anΣ fo≥ thei≥ hel≡ durinτ thσ firs⌠ year« á Speì
cia∞ thank≤ g∩ t∩ Ja∙ Sagσ fo≥ allowinτ hi≤ Z33LI┬ module≤ t∩ ábσ ì
integrateΣ áint∩ áZ3LI┬ fo≥ ß completσ package¼ áanΣ át∩ áBridge≥ ì
Mitchel∞ áfo≥ áallowinτ mσ t∩ usσ somσ oµ hi≤ codσ iε áDSLI┬ áfo≥ ì
DateStamper interfaces.
Thank≤ als∩ t∩ somσ oµ thσ bes⌠ tester≤ iε thσ busines≤ wh∩ átooδ ì
thσ áLibrarie≤ througΦ thei≥ pace≤ anΣ kep⌠ mσ u≡ latσ áa⌠ ánigh⌠ ì
exterminatinτ thσ pesk∙ bugs« The∙ are║ Cameroε Cotrill¼ HowarΣ ì
Goldstein¼ áMalcoφ Kemp¼ Brucσ Morgen¼ anΣ Carsoε Wilson« á Iµ á╔ ì
havσ forgotteε anyone¼ i⌠ wa≤ inadvertant¼ anΣ m∙ thank≤ a≤ well.
Iε thσ lega∞ department¼ man∙ trademark≤ arσ referenceΣ iε áthesσ ì
files« á The∙ áare║ DateStamper¼ DosDisk¼ áBackGrounde≥ áii¼ áoµ ì
Plu*Perfec⌠ áSystems╗ CP/M¼ CP/═ Plus¼ oµ Digita∞ Research╗ áZAS¼ ì
ZDH¼ ZDM¼ ZRDOS¼ oµ Echelon¼ Inc╗ Macr∩-8░ Linδ-80¼ oµ MicroSoft╗ ì
ZSDOS¼ áZDDOS¼ oµ Cameroε Cotrill¼ HarolΣ Bower¼ áCarsoε áWilson« ì
"Thσ áLibraries¼ áVersioε 4ó i≤ Copyrigh⌠ 198╣ b∙ áAlphß áSystem≤ ì
Corporation¼ subjec⌠ t∩ thσ releasσ previousl∙ stateΣ fo≥ RE╠ anΣ ì
HEL╨ files.
11 Apr 89
Harold F. Bower
P.O. Box 313
Ft. Meade, MD 20755
.paè
Introduction to the Libraries, Version 4
Versioε á┤ oµ thσ Librarie≤ i≤ thσ culminatioε oµ ove≥ tw∩ áyear≤ ì
oµ work« Beginninτ witΦ thσ Versioε 3.╢ libraries¼ eacΦ ároutinσ ì
wa≤ optimizeΣ fo≥ performancσ oε Z8░ compatiblσ ámicroprocessors¼ ì
anΣ ámucΦ árestructurinτ wa≤ performeΣ t∩ reducσ ácodσ ásizσ áanΣ ì
increasσ áfunctionalit∙ áfo≥ program≤ usinτ thesσ áne≈ ároutines« ì
Somσ oµ thσ grounΣ rule≤ fo≥ thi≤ effor⌠ were:
o Conver⌠ sourcσ codσ t∩ Ziloτ mnemonic≤ anΣ optimizσ routine≤ ì
áááááfo≥ executioε oε Z8░ anΣ HD6418░ Processors
o Isolatσ áunitializeΣ ádatß int∩ thσ DSE╟ wherσ ápossiblσ át∩ ì
ááááápermi⌠ ROMminτ oµ program≤ anΣ fo≥ futurσ growtΦ t∩ thσ Z28░ ì
áááááprocessor
o Extract common code in routines to reduce redundancy
o AdΣ routine≤ anΣ ß ne≈ librar∙ t∩ takσ advantagσ oµ developì
áááááment≤ iε commanΣ processor≤ anΣ operatinτ system≤ fo≥ áCP/═-ì
ááááácompatiblσ computers
Thσ ánewe≥ famil∙ oµ ╕-bi⌠ processors¼ sucΦ a≤ thσ Z80¼ áNS├-800¼ ì
64180¼ anΣ Z18░ arσ capablσ oµ mucΦ morσ thaε thσ olde≥ 808░ áanΣ ì
808╡ áchips« Unti∞ now¼ the∙ havσ beeε saddleΣ witΦ thσ áineffiì
cien⌠ ároutine≤ áiε thσ olde≥ Versioε 3.╢ libraries« á Sincσ áthσ ì
majorit∙ oµ system≤ havσ migrateΣ t∩ thσ ZCPR│ commanΣ áprocesso≥ ì
replacemen⌠ whicΦ canno⌠ operatσ oε thσ olde≥ processors¼ ásacriì
ficinτ backwarΣ compatibilit∙ witΦ thσ 808░ wa≤ no⌠ considereΣ áß ì
significan⌠ shortcoming« Iε ß likσ vein¼ CP/═ 1.┤ remnant≤ áhavσ ì
beeε deleted¼ requirinτ CP/═ 2.▓ o≥ late≥ "typeó system≤ t∩ operì
atσ correctly.
Thσ áorigina∞ routine≤ placeΣ datß a≤ wel∞ a≤ executablσ codσ áiε ì
thσ ácodσ ásegment¼ o≥ CSEG« Iε somσ routines¼ ásevera∞ áhundreΣ ì
byte≤ áoµ uninitializeΣ datß wa≤ includeΣ iε prograφ ácodσ áwhicΦ ì
serveΣ áonl∙ t∩ increasσ thσ sizσ oµ thσ prograφ image« á Anothe≥ ì
undesireablσ featurσ oµ thi≤ approacΦ i≤ tha⌠ thi≤ practicσ áwil∞ ì
no⌠ bσ permitteΣ iε newe≥ processor≤ usinτ thσ s∩-calleΣ protectì
eΣ modσ oµ execution« Movinτ datß storagσ t∩ ß separatσ ásegmen⌠ ì
witΦ thσ DSE╟ assemble≥ directivσ wil∞ makσ program≤ portablσ át∩ ì
thesσ ánewe≥ ásystems¼ anΣ allo≈ theφ t∩ bσ placeΣ iε áreaΣ áonl∙ ì
memor∙ á(ROM)« á Becausσ oµ initializatioε requirement≤ áiε ásomσ ì
modules¼ thi≤ goa∞ coulΣ no⌠ bσ totall∙ achieved.
Man∙ case≤ oµ duplicatσ codσ werσ identifieΣ withiε librar∙ árouì
tines« SucΦ case≤ werσ simplifieΣ b∙ extractinτ thσ commoε fragì
ments¼ áanΣ linkinτ theφ onl∙ once« Thi≤ featurσ i≤ átransparen⌠ ì
anΣ handleΣ automaticall∙ b∙ you≥ linker« Onl∙ onσ precautioε i≤ ì
necessar∙ witΦ thi≤ scheme« Thesσ extracteΣ routinσ name≤ generì
all∙ begiε witΦ aε "ató sigε (@)¼ and¼ witΦ ß fe≈ exceptions¼ arσ ì
undocumented« á Iµ áyo⌡ linδ you≥ owε librar∙ routine≤ áwitΦ áthσ ì
Versioε á┤ Libraries¼ insurσ tha⌠ n∩ duplicatioε oµ name≤ áoccur≤ ìèo≥ strangσ thing≤ wil∞ happen.
Correctioε áoµ deficiencie≤ anΣ difference≤ betweeε librar∙ árouì
tine≤ anΣ thσ documentatioε wa≤ als∩ ß higΦ priorit∙ durinτ áthi≤ ì
effort« Thesσ hel≡ file≤ shoulΣ exactl∙ reflec⌠ routinσ áparameì
ter≤ anΣ functioning« Wherσ difference≤ exis⌠ betweeε thσ printì
eΣ manua∞ anΣ thesσ hel≡ files¼ thσ hel≡ file≤ shoulΣ bσ áconsidì
ereΣ thσ morσ accurate.
Thσ áonl∙ deviatioε froφ thσ documentatioε i≤ iε ároutine≤ áwherσ ì
thσ ┴ registe≥ return≤ ß valuσ oµ ░ witΦ thσ zer∩ flaτ se⌠ (Z⌐ oε ì
onσ ácondition¼ anΣ thσ zer∩ flaτ rese⌠ (NZ⌐ oε thσ othe≥ ácondiì
tion« á Fo≥ mos⌠ routines¼ thσ noε-zer∩ valuσ i≤ deriveΣ áfroφ áß ì
0FFΦ valuσ iε thσ ┴ registe≥ a≤ specifieΣ iε thσ printeΣ documenì
tation« á Thi≤ shoulΣ no⌠ bσ considereΣ a≤ aε absolute¼ áhowever¼ ì
anΣ iε ne≈ development¼ yo⌡ shoulΣ conside≥ an∙ noε-zer∩ valuσ a≤ ì
valid¼ áno⌠ ájus⌠ 0FFh« Thi≤ changσ i≤ reflecteΣ iε áthesσ áhel≡ ì
files.
Thσ áareß oµ robustnes≤ wa≤ als∩ tackled¼ primaril∙ fo≥ VLI┬ áanΣ ì
Z3LIB¼ áiε aε effor⌠ t∩ minimizσ thσ adversσ effect≤ áoµ árunninτ ì
program≤ usinτ thosσ routine≤ oε system≤ no⌠ equippeΣ witΦ ZCPR3« ì
Whilσ no⌠ al∞ area≤ coulΣ bσ madσ "bulletproof"¼ the∙ arσ considì
erabl∙ morσ toleran⌠ thaε previou≤ libraries.
Ja∙ áSage¼ autho≥ oµ ZCP╥ 3.│ anΣ 3.4¼ ha≤ contributeΣ man∙ árouì
tine≤ t∩ Z3LI┬ t∩ usσ thσ additiona∞ feature≤ oµ thσ lates⌠ ácomì
manΣ áprocesso≥ áreplacements« Hi≤ ácontribution≤ áals∩ ácorrec⌠ ì
deficiencie≤ áiε existinτ modules« Thσ ne≈ Z3LI┬ ha≤ áals∩ ábeeε ì
updateΣ át∩ usσ thσ extendeΣ environmen⌠ descriptioε needeΣ áwitΦ ì
NZCO═ anΣ ZCP╥ 3.4« A≤ such¼ somσ oµ thσ definition≤ anΣ parameì
ter≤ havσ changed« Seσ specifiπ Z3LI┬ Hel≡ fo≥ morσ details.
VLI┬ ha≤ beeε significantl∙ modifieΣ witΦ additiona∞ feature≤ anΣ ì
mucΦ faste≥ operation« Busines≤ graphic≤ anΣ pul∞-dowε menu≤ arσ ì
amonτ áthσ addeΣ capabilities« Detail≤ oε thσ ne≈ Z3TCA╨ áneedeΣ ì
t∩ takσ advantagσ oµ thesσ routine≤ arσ iε thσ VLI┬ hel≡ section.
Severa∞ áenhancement≤ havσ beeε madσ t∩ SYSLI┬ ároutines« á Amonτ ì
thσ morσ significan⌠ are:
- DFREE now additionally returns CP/M Plus free space.
- xFN1 filename print routines mask most significant bits.
- DIRQ/DIRQ╙ ároutine≤ cal∞ DBUFFE╥ t∩ reducσ programminτ áreì
áááááquirement≤ fo≥ additiona∞ suppor⌠ functions
- DIRF/DIRQ/DIRQS routines now ignore CP/M Plus date stamps.
- Ne≈ ároutine≤ havσ beeε addeΣ fo≥ filenamσ comparisons¼ áhe° ì
áááááconversions¼ anΣ consolσ outpu⌠ maskinτ thσ MSB« Thesσ áarσ ì
ááááádocumenteΣ iε thσ SYSLI┬ hel≡ file.
┴ ne≈ library¼ DSLIB¼ ha≤ beeε createΣ t∩ providσ tool≤ fo≥ worδì
inτ witΦ clock≤ anΣ filσ timσ anΣ datσ stampinτ feature≤ provideΣ ì
b∙ áZSDOS/ZDDOS¼ áDateStamper¼ anΣ Digita∞ Research'≤ áCP/═ áPlu≤ ì
(als∩ knowε a≤ CP/═ 3.x)« Utilit∙ routine≤ arσ als∩ featureΣ fo≥ ì
conversion≤ betweeε ß variet∙ oµ differen⌠ datσ anΣ timσ formats« ìèFo≥ use≥ programs¼ however¼ ß standardizeΣ forma⌠ patterneΣ afte≥ ì
Plu*Perfec⌠ áSystemsº áDateStampe≥ i≤ used« á Director∙ ároutine≤ ì
patterneΣ áafte≥ áthosσ iε SYSLI┬ wil∞ returε áfilσ ádatσ ástamp≤ ì
alonτ witΦ basiπ filσ information.
.paè.he ZCPR3: THE LIBRARIES 4.2 -- SYSLIB
I« SYSLI┬ -¡ Genera∞ Routines
Introductioε « « « « « « « « « « « « « « « « « « « « « « 10
Comment≤ oε Softwarσ Engineerinτ « « « « « « « « « 10
Definition≤ anΣ Term≤ « « « « « « « « « « « « « « « 11
Parameter-Passinτ Convention≤ « « « « « « « « « « « 12
Overvie≈ oµ Routine≤ « « « « « « « « « « « « « « « 13
Director∙ Manipulatioε « « « « « « « « « « « « « « « « « 15
Director∙ Buffe≥ Structurσ « « « « « « « « « « « « 16
Ho≈ T∩ Usσ Thesσ Routine≤ « « « « « « « « « « « « « 16
Buffe≥ Allocatioε « « « « « « « « « « « « « « « « « 18
DBUFFER
Disδ Freσ Spacσ « . « « « « « « « « « « « « « « « « 18
DFREE
Director∙ Alphabetizatioε « « « « « « « « « « « « « 18
DIRALPHA
GeneralizeΣ Di≥ectory Routine≤ « « « « « « « « « « 19
DIRF¼ DIRFS
Director∙ LoaΣ Routine≤ « « « « . « « « « « « « « « 20
DIRLOAD¼ DIRSLOAD
Director∙ Pacδ Routine≤ « « « « « « « « « « « « « « 21
DIRPACK¼ DIRNPACK
Optima∞ Director∙ Routine≤ « « « « « « « « « « « « 21
DIRQ¼ DIRQS
Director∙ Entr∙ Selectioε Routinσ « « « « « « « « « 22
DIRSEL
Disk Paramete≥ Informatioε « « « « « « « « « « « « 23
DPARAMS¼ BLKSH╞ (global)¼ BLKMS╦ (global),
EXTEN╘ (global)¼ BLKMA╪ (global)¼ DIRMA╪ (global)
Filσ Sizσ Computatioε « « « . « « « « « « « « « « « 23
FSIZE
Byte-OrienteΣ Filσ Input/Outpu⌠ Routine≤ « « « « « « « « 24
Byte-OrienteΣ I/╧ Filσ Opeε « « « « « « « « « « « « 25
FI0$OPEN¼ FI1$OPEN¼ FI2$OPEN¼ FI3$OPEN,
FO0$OPEN¼ FO1$OPEN¼ FO2$OPEN¼ FO3$OPEN
Byte-OrienteΣ I/╧ Filσ Closσ « « « « « « « « « « « 25
FI0$CLOSE¼ FI1$CLOSE¼ FI2$CLOSE¼ FI3$CLOSE,
FO0$CLOSE¼ FO1$CLOSE¼ FO2$CLOSE¼ FO3$CLOSE
Byte-OrienteΣ Input/Outpu⌠ « « « « « « « « « « « « 26
F0$GET¼ F1$GET¼ F2$GET¼ F3$GET,
F0$PUT¼ F1$PUT¼ F2$PUT¼ F3$PUT
Erro≥ Returε Code≤ « « « « « « « « « « « « « « « « 27
Byte-OrienteΣ Filσ I/╧ witΦ Variablσ Buffer≤ « « « « « « 28
Inpu⌠ anΣ Outpu⌠ Filσ Opeε « « « « « « « « « « « « 30
FXI$OPEN¼ FXO$OPEN
Inpu⌠ anΣ Outpu⌠ Filσ Closσ « « « « « « « « « « « « 30
FXI$CLOSE¼ FXO$CLOSE
Inpu⌠ anΣ Outpu⌠ « « « « « « « « « « « « « « « « « 30
FX$GET¼ FX$PUT
Byte-OrienteΣ Filσ I/╧ witΦ Variablσ Buffer≤ anΣ UNGE╘ « 31
Inpu⌠ anΣ Outpu⌠ Filσ Opeε « « « « « « « « « « « « 33
FYI$OPEN¼ FYO$OPEN
Inpu⌠ anΣ Outpu⌠ Filσ Closσ « « « « « « « « « « « « 33
FYI$CLOSE¼ FYO$CLOSEè Input¼ Unget¼ anΣ Outpu⌠ « « « « « « « « « « « « « 33
FY$GET¼ FY$UNGET¼ FY$PUT
General-Purposσ CP/═ Filσ Manipulatioε Routine≤ « « « « 34
Closσ ß Filσ « « « « « « « « « « « « « « « « « « « 34
F$CLOSE
Deletσ ß Filσ « « « « « « « « « « « « « « « « « « « 34
F$DELETE
Tes⌠ Filσ Existencσ « « « « « « « « « « « « « « « « 35
F$EXIST
Create ß Filσ « « « « « « « « « « « « « « « « « « « 35
F$MAKE
Opeε ß Filσ « « « « « « « « « « « « « « « « « « « « 35
F$OPEN¼ F$MOPEN
AppenΣ t∩ ß Filσ « « « « « « « « « « « « « « « « « 35
F$APPEND¼ F$APPL
ReaΣ Blocδ froφ Filσ « « « « « « « « « « « « « « « 36
F$READ
Renamσ ß Filσ « « « « « « « « « « « « « « « « « « « 37
F$RENAME
Computσ Filσ Size « « « « « « « « « « « « « « « « « 37
F$SIZE
Writσ ß Blocδ t∩ ß Filσ « « « « « « « « « « « « « « 37
F$WRITE
Returε Randoφ RecorΣ Nuφbe≥ « « « « « « « « « « « « 37
GETRR¼ GETRR1
Returε Filσ Sizσ « « « « « « « « « « « « « « « « « 38
GETFS¼ GETFS1
Ge⌠ Filσ Attribute≤ « « « « « « « « « « « « « « « « 38
GFA
ReaΣ Filσ Blocδ Randoφ « « « « « « « « « « « « « « 38
R$READ
Writσ Filσ Blocδ Randoφ « « « « « « « « « « « « « « 39
R$WRITE
Se⌠ o≥ Clea≥ Filσ Attribute≤ « « « « « « « « « « « 39
SCFA¼ SFA
Librar∙ Filσ Manipulatioε « « « « « « « « « « « « « « « 40
Initializσ Librar∙ « « « « « « « « « « « « « « « « 40
LUINIT
Returε Library Director∙ « « « « « « « « « « « « « 40
LUDIR
Opeε ß Librar∙ Filσ « « « « « « « « « « « « « « « « 41
LUOPEN
Closσ ß Librar∙ Filσ « « « « « « « « « « « « « « « 41
LUCLOSE
ReaΣ ß Librar∙ Filσ « « « « « « « « « « « « « « « « 41
LUREAD
Filσnamσ Strinτ Parse≥ « « « « « « « « « « « « « « « « « 41
FNAME
Filσ Contro∞ ┬lock Initializatioε « « « « « « « « « « « 42
INITFCB
Disk/User Manipulatioε « « « « « « « « « « « « « « « « « 42
Ge⌠ and Se⌠ Curren⌠ Use≥ Areß « « « « « « « « « « « 43
GUA¼ SUA
Returε thσ Curren⌠ Disδ anΣ Use≥ « « « « « « « « « 43
RETUDè Loτ int∩ ß SpecifieΣ Disδ anΣ Use≥ « « « « « « « « 43
LOGUD
Savσ anΣ Restorσ Curren⌠ Disδ anΣ Use≥ « « « « « « 44
PUTUD¼ GETUD
Se⌠ DM┴ Transfe≥ Addres≤ « « « « « « « « « « « « « 44
SETDMA
Numeriπ Strinτ Evaluatioε « « « « « « « « « « « « « « « 44
Genera∞ ╨urpose Numeriπ Strinτ Evaluatioε « « « « « 44
EVAL
Hexadecima∞ Strinτ Evaluatioε « « « « « « « « « « « 45
EVAL16
Decima∞ Strinτ Evaluatioε « « « . « « « « « « « « « 45
EVAL10
Octa∞ Strinτ Evaluatioε « « « « « « « « « « « « « « 45
EVAL8
Binar∙ Strinτ Evaluatioε « « « « « « « « « « « « « 46
EVAL2
The L¼ M¼ P¼ anΣ ╙ Numeriπ Outpu⌠ Routine≤ « « « « « « « 46
Samplσ Numeriπ Output≤ « « « « « « « « « « « « « « 47
▓ Hexadecima∞ Characters « « « « « « « « « « « « « 47
LA2HC¼ PA2HC¼ SA2HC¼ MA2HC
│ Decimal Character≤ « « « « « « « « « « « « « « « 47
LA3DC¼ PA3DC¼ SA3DC¼ MA3DC
▒ t∩ │ Decimal Characters witΦ Leadinτ Space≤ « « « 48
LADC¼ PADC¼ SADC¼ MADC
▒ t∩ │ Decima∞ Character≤ « « « « « « « « « « « « « 48
LAFDC¼ PAFDC¼ SAFDC¼ MAFDC
┤ Hexadecima∞ Characters « « « « « « « « « « « « « 48
LHL4HC¼ PHL4HC¼ SHL4HC¼ MHL4HC
╡ Decima∞ Character≤ « « « « « « « « « « « « « « « 49
LHL5DC¼ PHL5DC¼ SHL5DC¼ MHL5DC
▒ t∩ ╡ Decimal Characters witΦ Leadinτ Space≤ « « « 49
LHLDC¼ PHLDC¼ SHLD├¼ MHLDC
▒ t∩ ╡ Decima∞ Character≤ « « « « « « « « « « « « . 49
LHLFDC¼ PHLFDC¼ SHLFDC¼ MHLFDC
Inpu⌠ Linσ Editor≤ « « « « « « « « « « « « « « « « « « « 50
BDOS-BaseΣ Inpu⌠ Linσ Editor≤ « « « « « « « « « « « 50
BBLINE¼ BLINE
Independen⌠ Inpu⌠ Linσ Edito≥ « « « « « « « « « « « 51
INLINE
Strinτ anΣ SwitcheΣ Outpu⌠ « « « « « « « « « « « « « « « 52
Prin⌠ Strinτ froφ Stacδ « « « « « « « « « « « « « « 53
PRINT¼ EPRINT¼ LPRINT¼ SPRINT
Prin⌠ Strinτ froφ H╠ « « « « « « « « « « « « « « « 53
PSTR¼ EPSTR¼ LPSTR¼ SPSTR
Filσnamσ Outpu⌠ « « « « « « « « « « « « « « « « « « « « 53
Prin⌠ Filσnamσ « « « « « « « « « « « « « « « « « « 54
LFNn¼ PFNn¼ SFNn
Storσ Filσnamσ iε Memor∙ « « « « « « « « « « « « « 54
MFNn
Character-OrienteΣ Input/Outpu⌠ « « « « « « « « « « « « 55
Cha≥acter Inpu⌠ Viß BDO╙ « « « « « « « « « « « « « 56
BIN
Cha≥acter Inpu⌠ Statu≤ Viß BDO╙ « « « « « « « « « « 56
BISTè Cha≥acter Outpu⌠ Viß BDO╙ « « « « « « « « « « « « « 56
BOUT
Cha≥acter Inpu⌠ and Capitalization witΦ Ech∩ « « « 56
CAPIN¼ CAPINE
Cha≥acter Inpu⌠ « « « « « « . « « « « « « « « « « « 56
CIN¼ RIN
Characte≥ Outpu⌠ « « « « « « « « « « « « « « « « « 57
COUT¼ COUT7,áLOUT¼ POUT¼ SOUT
Cha≥acter Outpu⌠ witΦ Contro∞ Character≤ « « « « « 57
CCOUT¼ CLOUT¼ CPOUT¼ CSOUT
Conditiona∞ Inpu⌠ « « « « « « « « « « « « « « « « « 57
CONDIN
Ne≈ Linσ Outpu⌠ « « « « « « « « « « « « « « « « « « 58
CRLF¼ LCRLF¼ SCRLF
Consolσ Statu≤ « « « « « « « « « « « « « « « « « « 58
CST
Branchinτ « « « « « « « « « « « « « « « « « « « « « « « 58
Casσ viß ┴ Registe≥ « « « « « « « « « « « « « « « « 59
ACASE1¼ ACASE2¼ ACASE3
Casσ viß H╠ Reτister Pai≥ « « « « « « « « « « « « « 61
HCASE1¼ HCASE2¼ HCASE3
ComputeΣ GOT╧ viß ┴ « « « « « « « « « « « « « « « « 62
AGOTO1¼ AGOTO2¼ BGOTO1¼ BGOTO2
ComputeΣ GOT╧ viß H╠ « « « « « « « « « « « « « « « 63
HGOTO1¼ HGOTO2¼ DGOTO1¼ DGOTO2
Arithmetiπ I╞ viß ┴ « « « « « « « « « « « « « « « « 65
AIF1¼ AIF2
Arithmetiπ I╞ viß H╠ « « « « « « « « « « « « « « « 66
HIF1¼ HIF2
Parsinτ Aid≤ « « « « « « « « « « « « « « « « « « « « « « 67
UNIX-Stylσ ARGC/ARG╓ Strinτ Parsinτ « « « « « « « « 67
ARGV
Capitalizatioε « « « « « « « « « « « « « « « « « « 68
CAPS¼ CAPSTR
Characte≥ Tes⌠ Routine≤ « « « « « « « « « « « « « « 68
ISALNUM¼ ISALPHA¼ ISCTRL¼ ISDIGIT¼ ISGRAPH¼
ISPRINT¼ ISPUN¼ ISSP
Characte≥ Ski≡ Routine≤ « « « « « « « « « « « « « « 69
SKNPUN¼ SKNSP¼ SKPUN¼ SKSP
General-Purposσ Arithmetiπ « « « « « « « « « « « « « « « 69
Arithmetiπ -¡ Add¼ Subtract¼ Multiply¼ Dividσ « « « 69
ADDHD¼ SUBHD¼ MULHD¼ DIVHD
Complemen⌠ -¡ Negatσ (2'≤) anΣ Complemen⌠ (1's⌐ « « 70
NEGH¼ CMPH
Logica∞ -¡ And, Or¼ Xo≥ « « « « « « « « « « « « « « 71
ANDHD¼ ORHD¼ XORHD
Rotatσ and Shif⌠ -¡ Lef⌠ anΣ Righ⌠ « « « « « « « « 71
ROTLH¼ ROTRH¼ SHFTLH¼ SHFTRH
CR├ Calculatioε « « « « « « « « « « « « « « « « « « « « 72
Initialization « « « « « « « « « « « « « « « « « « 72
CRCCLR¼ CRC1CLR¼ CRC2CLR¼ CRC3CLR¼ CRC3INIT
CR├ Updatinτ « « « « « « « « « « « « « « « « « « « 73
CRCUPD¼ CRC1UPD¼ CRC2UPD¼ CRC3UPD
CR├ Completioε « « « « « « « « « « « « « « « « « « 73
CRCDONE¼ CRC1DONE¼ CRC2DONE¼ CRC3DONEè Randoφ Numbe≥ Generatioε « « « « « « « « « « « « « « « « 73
Initializσ Randoφ Numbe≥ Generato≥ SeeΣ « « « « « « 73
RNDINI╘
Se⌠ Knowε SeeΣ Valuσ « « « « « « « « « « « « « « « 73
RNDSEE─
Returε 8-bi⌠ Pseudo-Randoφ Numbe≥ « « « « « « « « « 74
RN─
Strinτ anΣ Valuσ Comparisoε « « « « « « « « « « « « « « 74
Comparσ Vector≤ « « « « . « « « « « « « « « « « « « 74
COMPB¼ COMPBC
Comparσ Filename≤ « « « « « « « « « « « « « « « « « 74
@FNCMP¼ @AFNCMP
Comparσ H╠ t∩ D┼ « « « « « « « « « « « « « « « « « 75
COMPHD
Substrinτ SearcΦ « « « « « « « « « « « « « « « « « 75
INSTR
Vecto≥ SearcΦ « . « « « « « « « « « « « « « « « « « 76
SCANNER
Memor∙ Allocatioε « « « « « « « « « « « « « « « « « « « 76
Allocatσ ß Blocδ oµ Memor∙ « « « « « « « « « « « « 77
ALLOC
Initializσ Memor∙ Allocatioε Systeφ « « « « « « « « 78
IALLOC
Checδ fo≥ To≡ oµ Availablσ Memor∙ « « « « « « « « « 78
GMEMTOP
Sor⌠ Routine≤ « « « « « « « « « « « « « « « « « « « « « 78
Sor⌠ Specification Blocδ Initialize≥ « « « « « « « 79
SSBINIT
Maiε Sor⌠ Routinσ « « « « « « « « « « « « « « « « « 80
SORT
Miscellaneou≤ Routine≤ « « « « « « « « « « « « « « « « « 80
BDO╙ anΣ BIO╙ Routine≤ « « « « « « « « « « « « « « 80
BDOS¼ BIOS
Characte≥ anΣ Nybblσ Conversion≤ « « « « « « « « « 81
CATH¼ @B2HH¼ @B2HL
CommanΣ Linσ Tai∞ Extractioε « « « « « « « « « « « 82
CLINE
EnΣ oµ Codσ « « « « « « « « . « « « « « « « « « « « 82
CODEND¼ $MEMR┘ (global)
Exchangσ Nybble≤ « « « « « « « « « « « « « « « « « 83
EN
Memor∙ Fil∞ Routine≤ « « « « « « « « « « « « « « « 83
FILLB¼ FILLBC¼ HFILB¼ HFILBC
Memor∙ Movσ Routine≤ « « « « « « « « « « « « « « « 83
MOVEB¼ MOVEBC, HMOVB¼ HMOVBC
Dela∙ Routinσ « « « « « « « « « « « « « « « « « « « 84
PAUSE
Versioε Numbe≥ oµ SYSLI┬ « « « « « « « « « « « « « 84
VERSION
.paè
SYSLI┬ -¡ Genera∞ Routines
INTRODUCTION:é á SYSLI┬ ┤ i≤ aε integrateΣ too∞ se⌠ whicΦ ái≤ ádeì
signeΣ t∩ assis⌠ you¼ thσ assembl∙ languagσ programmer¼ iε áwritì
inτ áprograms« I⌠ i≤ intendeΣ t∩ placσ yo⌡ a⌠ ß highe≥ leve∞ áoµ ì
abstractioε áanΣ allo≈ yo⌡ t∩ concentratσ oε thσ probleφ a⌠ áhanΣ ì
withou⌠ havinτ t∩ concerε yourselµ witΦ thσ lo≈-leve∞ implementaì
tioε ádetail≤ áoµ thσ operatinτ systeφ áinterface¼ áinput/output¼ ì
tex⌠ parsinτ anΣ evaluation¼ math¼ anΣ sorting.
T∩ áillustratσ thi≤ point¼ conside≥ aε assembl∙ languagσ áprograφ ì
whicΦ áneed≤ át∩ acces≤ ß disδ directory¼ theε displa∙ áß ásorteΣ ì
lis⌠ áoµ áfilenames« Withou⌠ SYSLI┬ ┤ o≥ ásimila≥ álibrary¼ áyo⌡ ì
woulΣ áhavσ t∩ writσ ß relativel∙ sophisticateΣ bod∙ t∩ ácodσ át∩ ì
acces≤ thσ directory¼ loaΣ i⌠ iε memory¼ sort¼ anΣ displa∙ it.
SYSLI┬ á4¼ however¼ provide≤ yo⌡ witΦ ß "toolboxó oµ routine≤ át∩ ì
cal∞ áoε t∩ perforφ somσ oµ thσ morσ tediou≤ functions« á Onσ áoµ ì
thesσ átools¼ DIRF¼ load≤ thσ element≤ oµ ß disδ director∙ áwhicΦ ì
matcΦ ß filσ specificatioε int∩ ß memor∙ buffe≥ fo≥ you.
But¼ ámorσ thaε jus⌠ providinτ ß se⌠ oµ tools¼ SYSLI┬ ┤ áwa≤ ádeì
signeΣ áwitΦ structureΣ programminτ anΣ softwarσ áengineerinτ áiε ì
mind« á Thσ ábasiπ goa∞ iε softwarσ desigε i≤ tha⌠ áthσ áprogram≤ ì
mee⌠ thσ stateΣ requirements« Iε applyinτ softwarσ áengineering¼ ì
wσ áwan⌠ ámorσ thaε jus⌠ this« Amonτ othe≥ things¼ wσ áwan⌠ áthσ ì
prograφ t∩ be:
o Modifiable
o Efficient
o Reliable
o Understandable
SYSLI┬ ┤ offer≤ ß significan⌠ se⌠ oµ facilitie≤ whicΦ caε hel≡ t∩ ì
achievσ thesσ goals.
COMMENT╙ O╬ SOFTWAR┼ ENGINEERING:é Wσ arσ experiencinτ ß softwarσ ì
crisi≤ today¼ thσ basi≤ oµ whicΦ i≤ simpl∙ tha⌠ i⌠ i≤ morσ diffΘì
cul⌠ át∩ builΣ reliablσ softwarσ system≤ tha⌠ wσ thinδ i⌠ áshoulΣ ì
be« Al∞ to∩ often¼ thσ symptom≤ oµ thσ softwarσ crisi≤ arσ seen:
o Cost -- unpredictable and judged excessive
o Efficienc∙ ¡¡ timσ anΣ spacσ utilitizatioε arσ no⌠ efficient
o Modifiability -- software is difficult to change
o Reliability -- software often fails
o Responsiveness -- user needs are not met
o Timeliness -- software is not delivered on time
o Transportabilit∙ á¡¡ softwarσ useΣ oε onσ systeφ ma∙ no⌠ ábσ ì
áááááuseΣ oε another
Thσ ábottoφ linσ iε thσ desigε oµ ß softwarσ systeφ i≤ átha⌠ áthσ ì
softwarσ áshoulΣ mee⌠ it≤ stateΣ requirements« T∩ áachievσ áthi≤ ì
end¼ thσ fielΣ oµ softwarσ engineerinτ ha≤ arisen« Thσ goal≤ áoµ ì
softwarσ engineerinτ are:
1.Modifiabilit∙ ¡¡ Softwarσ shoulΣ bσ eas∙ t∩ change¼ áanΣ ìèááááásoftwarσ shoulΣ bσ designeΣ witΦ late≥ changσ iε mind.
2.Efficienc∙ á¡¡ Thσ softwarσ systeφ shoulΣ usσ áavailablσ ì
áááááresource≤ iε aε optima∞ manner.
3.Reliabilit∙ ¡¡ Thσ softwarσ shoulΣ perforφ accordinτ át∩ ì
áááááspecificatioε anΣ recove≥ safel∙ froφ failurσ durinτ use.
4.Understandabilit∙ ¡¡ Softwarσ shoulΣ bσ eas∙ t∩ reaΣ anΣ ì
áááááfollow« á Understandabilit∙ i≤ thσ too∞ useΣ t∩ pas≤ froφ áß ì
áááááparticula≥ probleφ spacσ t∩ ß solution.
SYSLI┬ ┤ attempt≤ t∩ hel≡ yo⌡ achievσ thσ goal≤ oµ softwarσ engiì
neerinτ b∙ applyinτ thesσ principles:
1.Abstractioε anΣ Informatioε Hidinτ ¡¡ Unnecessar∙ detai∞ ì
ááááái≤ hiddeε froφ you« Fo≥ example¼ thσ DIR╞ routinσ load≤ thσ ì
ááááácontent≤ oµ ß disδ director∙ int∩ ß memor∙ buffer« Ho≈ thi≤ ì
áááááloaΣ ái≤ ádonσ i≤ hidden╗ al∞ yo⌡ neeΣ t∩ kno≈ i≤ átha⌠ áthσ ì
áááááloaΣ wa≤ donσ anΣ yo⌡ havσ ß vecto≥ oµ director∙ entries.
2.Modularit∙ ¡¡ SYSLI┬ ┤ i≤ ver∙ modula≥ iε design« á EacΦ ì
ááááároutinσ áiε thσ librar∙ perform≤ onσ anΣ onl∙ onσ áfunction¼ ì
áááááanΣ áthσ documentatioε provide≤ completσ detai∞ a≤ át∩ áwha⌠ ì
ááááátha⌠ áfunctioε is¼ wha⌠ it≤ inpu⌠ parameter≤ are¼ áwha⌠ áit≤ ì
áááááoutpu⌠ parameter≤ are¼ wha⌠ it≤ sidσ effect≤ are¼ anΣ áothe≥ ì
ááááádata.
3.Localizatioε anΣ Loosσ Couplinτ ¡¡ SYSLI┬ ┤ module≤ áarσ ì
áááááloosel∙ coupled╗ eacΦ modulσ ma∙ bσ treateΣ independentl∙ oµ ì
áááááthσ áothers« Additionally¼ thσ module≤ arσ ástrongl∙ ácoheì
ááááásive╗ áthσ component≤ oµ eacΦ modulσ arσ intimatel∙ árelateΣ ì
ááááát∩ eacΦ othe≥ bu⌠ no⌠ t∩ component≤ oµ othe≥ modules.
4.Uniformit∙ ¡¡ Thσ callinτ convention≤ betweeε thσ ávariì
áááááou≤ SYSLI┬ ┤ module≤ arσ consisten⌠ witΦ eacΦ other¼ anΣ ái⌠ ì
ááááái≤ áfrequentl∙ thσ casσ tha⌠ thσ outpu⌠ parameter≤ froφ áonσ ì
ááááámodulσ ma∙ bσ directl∙ useΣ a≤ inpu⌠ parameter≤ t∩ another.
5.Completenes≤ ¡¡ EacΦ modulσ o≥ grou≡ oµ relateΣ ámodule≤ ì
áááááarσ áfunctionall∙ ácomplete« N∩ áadditiona∞ áfunction≤ áarσ ì
áááááneeded.
6.Confirmabilit∙ ¡¡ ┴ prograφ writteε usinτ SYSLI┬ ┤ ámodì
áááááule≤ caε bσ readil∙ decomposeΣ fo≥ incrementa∞ testing.
DEFINITION╙ áAN─ áTERMS:é Somσ term≤ arσ useΣ frequentl∙ áiε áthσ ì
SYSLI┬ ┤ documentation« Thesσ term≤ arσ defineΣ below.
1.Bufferé á¡¡ ┴ contiguou≤ vecto≥ oµ byte≤ iε memory« á Thσ ì
ááááábuffe≥ i≤ knowε b∙ it≤ startinτ addres≤ anΣ sizσ as:
BUFFER║ DEF╙ 4░ ; 40-byte buffer
2.Character á¡¡ ┴ onσ-bytσ (╕-bit⌐ value« ┴ ávaluσ árangσ ì
áááááwithiε áthσ ASCI╔ characte≥ se⌠ (ß ╖-bi⌠ value⌐ ái≤ áimplieΣ ìèááááábu⌠ no⌠ required¼ s∩ ß characte≥ coulΣ havσ ß valuσ oµ 81h.
3.Directory á¡¡ Aε inde° t∩ file≤ oε ß disk« ┴ ádirector∙ ì
áááááentr∙ ácontain≤ thσ namσ oµ ß file¼ thσ use≥ numbe≥ ái⌠ áreì
áááááside≤ áin¼ thσ filσ size¼ anΣ wherσ thσ filσ i≤ álocateΣ áoε ì
áááááthσ ádisk« Thσ informatioε loadeΣ b∙ SYSLI┬ director∙ árouì
ááááátine≤ ádoe≤ no⌠ includσ filσ locatioε information¼ bu⌠ ádoe≤ ì
áááááincludσ everythinτ else« Iε anothe≥ sense¼ thσ terφ ádirecì
ááááátor∙ ái≤ áuseΣ t∩ refe≥ t∩ ß particula≥ disδ anΣ áuse≥ áareß ì
ááááá(sucΦ a≤ A┤ o≥ B31).
4.FC┬ (File Control Block⌐ ¡¡ ┴ 3╢-bytσ buffe≥ ásatisfyinτ ì
áááááthσ ful∞ definitioε oµ ß CP/═ Filσ Contro∞ Block« SYSLI┬ á┤ ì
áááááFCB'≤ áarσ alway≤ 3╢ byte≤ long« Iε man∙ cases¼ áwheε árouì
ááááátine≤ áneeΣ ß use≥-supplieΣ FCB¼ yo⌡ neeΣ onl∙ fil∞ áiε áthσ ì
áááááfilenamσ áanΣ typσ field≤ (byte≤ ▒-11⌐ anΣ neeΣ no⌠ áconcerε ì
áááááyourselµ áwitΦ thσ res⌠ oµ thσ fields« Thσ INITFC┬ ároutinσ ì
ááááástore≤ zer∩ iε al∞ byte≤ excep⌠ byte≤ ▒-1▒ oµ thσ FCB.
5.File ¡¡ An∙ CP/═ file¼ eithe≥ tex⌠ o≥ binary« SYSLI┬ á┤ ì
ááááámake≤ n∩ distinctioε betweeε thesσ tw∩ type≤ oµ files.
6.String ¡¡ An∙ sequencσ oµ ASCI╔ character≤ terminateΣ b∙ ì
áááááß <NUL╛ character¼ whicΦ i≤ ß bytσ oµ valuσ 0« Example≤ áoµ ì
ááááástring≤ are:
DEF┬ 'This is a string',0
DEF┬ 1,2,3,'This is also',0
PARAMETE╥-PASSIN╟ áCONVENTIONS:é SYSLI┬ ┤ i≤ ver∙ áconsisten⌠ áiε ì
it≤ paramete≥-passinτ conventions« Iε al∞ cases¼ parameter≤ áarσ ì
passeΣ t∩ anΣ froφ SYSLI┬ ┤ routine≤ iε registers« Iµ morσ ávalì
ue≤ arσ requireΣ thaε therσ arσ availablσ registers¼ thσ registe≥ ì
value≤ áarσ ápointer≤ t∩ specificatioε block≤ whicΦ ácontaiε áthσ ì
desireΣ parameter≤ (seσ thσ FXn$xxxxxÖ anΣ thσ SOR╘ routines)« Iε ì
nearl∙ al∞ cases¼ thσ followinτ registe≥ usagσ rule≤ apply:
The HL register pair is used:
1.a≤ áß buffe≥ pointer╗ fo≥ example¼ H╠ contain≤ áthσ áadì
ááááádres≤ oµ thσ buffe≥ useΣ b∙ DIRF
2.a≤ ß strinτ pointer╗ fo≥ example¼ H╠ point≤ t∩ thσ firs⌠ ì
ááááábytσ oµ ß strinτ fo≥ thσ EVA╠ routine
3.t∩ áholΣ thσ firs⌠ operanΣ fo≥ matΦ routines╗ fo≥ áexamì
áááááple¼ DIVH─ divide≤ H╠ b∙ DE
The DE register pair is used:
1.t∩ poin⌠ t∩ aε FCB╗ fo≥ example¼ D┼ contain≤ thσ addres≤ ì
áááááoµ thσ FC┬ useΣ b∙ DIRF
2.t∩ ácontaiε áthσ seconΣ operanΣ fo≥ matΦ ároutines╗ áfo≥ ì
áááááexample¼ SUBH─ subtract≤ D┼ froφ HL
è 3.t∩ ápoin⌠ t∩ specia∞ block≤ (buffers⌐ useΣ b∙ áSYSLI┬ á┤ ì
ááááároutines╗ áfo≥ example¼ D┼ point≤ t∩ thσ sor⌠ áspecificatioε ì
áááááblocδ fo≥ thσ SOR╘ routine
The BC register pair is used:
1.t∩ contaiε ß D╒ form¼ wherσ ┬ hold≤ ß disδ numbe≥ á(A=0⌐ ì
áááááanΣ ├ hold≤ ß use≥ number
The A register is used:
1.t∩ ácontaiε aε inpu⌠ flag╗ fo≥ example¼ ┴ ácontain≤ áthσ ì
áááááselectioε flaτ useΣ b∙ DIRF
2.t∩ ácontaiε aε erro≥ returε code╗ iµ thσ valuσ áoµ áthi≤ ì
ááááácodσ ái≤ 0¼ thσ zer∩ flaτ (Z⌐ i≤ als∩ set¼ áanΣ ávicσ-versa╗ ì
áááááfo≥ áexample¼ ┴ contain≤ ß TP┴ overflo≈ erro≥ flaτ áreturneΣ ì
áááááb∙ thσ DIR╞ routine
3.t∩ contaiε ß characte≥ inpu⌠ o≥ outpu⌠ froφ ß ß SYSLI┬ ┤ ì
ááááároutine╗ fo≥ example¼ CI╬ return≤ ß characte≥ iε ┴ anΣ áCOU╘ ì
áááááoutput≤ ß characte≥ iε A
OVERVIE╫ áO╞ ROUTINES:é SYSLI┬ ┤ contain≤ man∙ ároutine≤ ágroupeΣ ì
int∩ thσ followinτ functiona∞ areas:
1.Director∙ áManipulatioε Routinesé ¡¡ Thesσ routine≤ ádea∞ ì
áááááwitΦ director∙ access« Thσ entrie≤ oµ ß disδ director∙ ácaε ì
ááááábσ áloadeΣ áint∩ ß memor∙ buffer¼ selecteΣ agains⌠ áaε áFCB¼ ì
ááááásorted¼ anΣ manipulated.
2.Numeriπ áStrinτ áEvaluatioε Routinesé ¡¡ áThesσ ároutine≤ ì
áááááconver⌠ áácharacte≥ ástring≤ áint∩ á1╢-bi⌠ ábinar∙ áávalues« ì
áááááString≤ likσ thosσ belo≈ arσ processed:
DEF┬ '123',░ ; value is 123 decimal
DEF┬ '5AH',░ ; value is 5A hexadecimal
DEF┬ '110B',░ ; value is 110 binary
DEF┬ '77Q',░ ; value is 77 octal
3.Bytσ-OrienteΣ áFilσ Input/Outpu⌠ Routinesé ¡¡ Thesσ áro⌡ì
ááááátine≤ ásuppor⌠ áinpu⌠ anΣ outpu⌠ t∩ anΣ froφ áfile≤ áoε áthσ ì
ááááábasi≤ oµ ß bytσ a⌠ ß time« FX$GET¼ fo≥ example¼ return≤ thσ ì
ááááánex⌠ bytσ froφ thσ curren⌠ filσ iε A.
4.CP/═ áFilσ Input/Outpu⌠ Routinesé ¡¡ Thesσ routine≤ ásu≡ì
ááááápor⌠ áinpu⌠ anΣ outpu⌠ t∩ anΣ froφ file≤ oε thσ basi≤ áoµ áß ì
ááááá12╕-bytσ áblocδ a⌠ ß time« Provision≤ fo≥ ádeletinτ áfiles¼ ì
ááááárenaminτ files¼ anΣ computinτ filσ size≤ als∩ exist.
5.User/Disδ Manipulatioε Routinesé ¡¡ Thesσ routine≤ áallo≈ ì
áááááthσ prograφ t∩ finΣ ou⌠ wha⌠ disδ anΣ use≥ areß i⌠ i≤ iε anΣ ì
ááááát∩ movσ betweeε directories.
6.Filenamσ áStrinτ Parseré ¡¡ Thi≤ routinσ i≤ useΣ t∩ ácoεì
áááááver⌠ áß áfilenamσ tex⌠ strinτ int∩ aε áacceptablσ áforφ áanΣ ìèáááááplacσ i⌠ int∩ aε FCB« Fo≥ example¼ thσ followinτ conversioε ì
ááááácaε bσ done:
DEF┬ 'MYFILE.TXT',░ ; string
DEF┬ ░ ; ..converted to
DEF┬ 'MYFILE '
DEF┬ 'TXT'
DEF╙ 24
7.Inpu⌠ áLinσ Editorsé ¡¡ Thesσ routine≤ accep⌠ use≥ áinpu⌠ ì
áááááwitΦ editinτ anΣ returε ß pointe≥ t∩ thσ firs⌠ bytσ oµ áuse≥ ì
áááááinpu⌠ iε strinτ forφ (terminateΣ b∙ ß binar∙ 0).
8.Strinτ Outpu⌠ Routinesé ¡¡ Thesσ routine≤ senΣ string≤ t∩ ì
ááááávariou≤ ádevices« Routine≤ arσ provideΣ t∩ senΣ string≤ áoµ ì
ááááácharacter≤ át∩ thσ consolσ o≥ printe≥ witΦ o≥ áwithou⌠ ácoεì
ááááátro∞-characte≥ processing.
9.Numeriπ Outpu⌠ Routinesé ¡¡ Thesσ routine≤ conver⌠ binar∙ ì
ááááávalue≤ át∩ ácharacte≥ sequence≤ anΣ outpu⌠ theφ át∩ ávariou≤ ì
ááááádevices« Outpu⌠ t∩ thσ consolσ anΣ printe≥ i≤ provided¼ anΣ ì
áááááthσ áoutpu⌠ i≤ eithe≥ iε thσ forφ oµ decima∞ o≥ áhexadecima∞ ì
ááááánumbers.
10.Strinτ anΣ Valuσ Comparisoε Routinesé ¡¡ Thesσ ároutine≤ ì
áááááprovidσ ávariou≤ comparisoε function≤ fo≥ botΦ ástring≤ áanΣ ì
ááááánumbers« Onσ strinτ ma∙ bσ compareΣ agains⌠ anothe≥ ástrinτ ì
áááááo≥ ß substrinτ oµ anothe≥ string« Tw∩ 1╢-bi⌠ number≤ caε bσ ì
ááááácompared.
11.Characte≥-OrienteΣ Input/Outpu⌠ Routinesé ¡¡ Thesσ áro⌡ì
ááááátine≤ providσ inpu⌠ anΣ outpu⌠ service≤ oε ß ácharacte≥-fo≥-ì
ááááácharacte≥ ábasi≤ át∩ ß variet∙ oµ devices« á Outpu⌠ át∩ áthσ ì
áááááconsolσ áanΣ thσ printe≥ i≤ provided« Also¼ devicσ ástatus¼ ì
ááááásucΦ a≤ consolσ inpu⌠ status¼ routine≤ arσ available.
12.MatΦ áRoutinesé ¡¡ Thesσ routine≤ áperforφ ámathematica∞ ì
ááááácalculation≤ oε 1╢-bi⌠ quantities« Add¼ subtract¼ multiply¼ ì
ááááádivide¼ rotate¼ shift¼ logica∞ AND¼ logica∞ OR¼ anΣ álogica∞ ì
áááááXO╥ arσ somσ oµ thσ function≤ provided.
13.CR├ áRoutinesé ¡¡ Thesσ routine≤ suppor⌠ computatioε áoµ ì
áááááCycliπ áRedundanc∙ Checδ value≤ fo≥ bytσ streams« ┴ ánumbe≥ ì
áááááoµ ádifferen⌠ áCR├ calculatioε routine≤ áarσ áavailablσ áfo≥ ì
ááááádifferen⌠ CR├ polynomials.
14.Randoφ áNumbe≥ áGenerato≥ Routinesé á¡¡ áThesσ ároutine≤ ì
áááááimplemen⌠ ß pseud∩-randoφ numbe≥ generato≥ whicΦ return≤ áaε ì
ááááá╕-bi⌠ valuσ wheε called« Thσ seeΣ valuσ fo≥ thi≤ ágenerato≥ ì
áááááma∙ ábσ feΣ t∩ it¼ thereb∙ generatinτ thσ samσ sequencσ áfo≥ ì
áááááeacΦ giveε seed¼ o≥ i⌠ ma∙ bσ selecteΣ randomly.
15.Sort áRoutines ¡¡ Thesσ routine≤ providσ ß áfast¼ ágenì
áááááera∞-purposσ iε-memor∙ sor⌠ capability« Thσ sor⌠ áalgorithφ ì
ááááái≤ ver∙ efficien⌠ (ß shel∞ sort)¼ anΣ ma∙ bσ performeΣ usinτ ìèáááááelemen⌠ ápointer≤ o≥ no⌠ usinτ pointer≤ (pointer≤ cos⌠ ámorσ ì
ááááámemor∙ bu⌠ speeΣ u≡ thσ sor⌠ eveε further).
16.Capitalizatioε áanΣ áCharacte≥ áTest/Ski≡ áRoutine≤ á¡¡ ì
áááááThesσ ároutine≤ arσ usefu∞ fo≥ tex⌠ parsing« ┴ ávariet∙ áoµ ì
áááááevaluatioε ároutine≤ arσ provideΣ t∩ determinσ thσ átypσ áoµ ì
ááááácharacte≥ ábeinτ ádeal⌠ witΦ (sucΦ a≤ áalphabetic¼ ánumeric¼ ì
áááááhexadecimal¼ áspace¼ ápunctuation¼ etc.)« BotΦ ástrinτ áanΣ ì
áááááindividua∞ ácharacte≥ capitalizatioε capabilitie≤ áarσ áals∩ ì
áááááprovided.
17.Memory Allocation Routines ¡¡ Thesσ routine≤ providσ áß ì
ááááádynamiπ ámemor∙ allocatioε mechanisφ tha⌠ constantl∙ ácheck≤ ì
áááááfo≥ áTP┴ áoverflow« Afte≥ defininτ thσ bound≤ oµ áß ámemor∙ ì
ááááábuffer¼ request≤ fo≥ spacσ froφ thi≤ areß ma∙ bσ issueΣ oε ß ì
ááááábytσ-fo≥-bytσ basis.
DIRECTOR┘ áMANIPULATIO╬ áROUTINES:é Thi≤ se⌠ oµ áSYSLI┬ ároutine≤ ì
concern≤ itselµ witΦ thσ loadinτ oµ anΣ acces≤ oµ ß disδ direct∩ì
r∙ fo≥ thσ genera∞ purpose≤ oµ thσ user« IncludeΣ iε thi≤ se⌠ oµ ì
routine≤ arσ thσ function≤ of:
- Pre-allocation of buffer space for the routines
- Loadinτ áoµ al∞ undeleteΣ director∙ entrie≤ int∩ áß ábuffer¼ ì
áááááconstantl∙ checkinτ fo≥ memor∙ overflow
- Determining the amount of free space on the disk
- Computing the size of a file in Kilobytes (K)
- Sortinτ ß loadeΣ director∙ b∙ filσ namσ anΣ typσ o≥ b∙ áfilσ ì
ááááátypσ anΣ name
- Selectinτ á(b∙ ámarking⌐ ß se⌠ oµ ádirector∙ áentrie≤ áwhicΦ ì
ááááámatcΦ ß giveε ambiguou≤ filσ spec
- Packinτ áthσ loadeΣ directory¼ leavinτ iε i⌠ onl∙ thosσ áenì
ááááátrie≤ markeΣ b∙ thσ selec⌠ routine
Thσ majorit∙ oµ thesσ routine≤ i≤ intendeΣ t∩ bσ useΣ t∩ áprovidσ ì
ß áflexiblσ director∙ acces≤ systeφ whicΦ caε bσ tailoreΣ b∙ áthσ ì
use≥ t∩ hi≤ specifiπ needs« Fo≥ instance¼ witΦ thσ DIRLOA─ árouì
tinσ áseparateΣ áfroφ thσ rest¼ severa∞ differen⌠ áload≤ áoµ áthσ ì
director∙ á(from¼ fo≥ instance¼ differen⌠ ambiguou≤ áfilσ áspecs⌐ ì
caε bσ performed¼ anΣ theε onσ selectioε anΣ onσ sor⌠ oε al∞ filσ ì
spec≤ loadeΣ caε bσ done.
Thσ DIRQ/DIRQ╙ pai≥ arσ intendeΣ fo≥ thosσ application≤ whicΦ ád∩ ì
no⌠ neeΣ thi≤ kinΣ oµ flexibility« DIR╤ (quick⌐ anΣ DIRQ╙ (quicδ ì
witΦ ásizinτ information⌐ perforφ ß load¼ select¼ anΣ sor⌠ ábaseΣ ì
oε áonl∙ áonσ filσ specification« Usinτ áDIRQ/DIRQ╙ áinsteaΣ áoµ ì
DIRF/DIRF╙ áresult≤ iε les≤ codσ beinτ generateΣ anΣ á(generally⌐ ì
faste≥ execution.
.paèDIRECTOR┘ áBUFFE╥ áSTRUCTURE:é DIRLOA─ anΣ DIRSLOA─ arσ áuseΣ át∩ ì
loaΣ áß director∙ froφ disδ int∩ memory« Thσ entrie≤ loadeΣ áarσ ì
al∞ ánoε-deleteΣ entrie≤ iε eithe≥ ß particula≥ use≥ areß o≥ áal∞ ì
use≥ area≤ oε thσ disδ whicΦ i≤ currentl∙ loggeΣ in.
Each file entry is 16 bytes long, structured as:
byte 1 1 1 1 1 1
offset 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
00 T E S T C O M 01 00 00 79
| \______________________/\_______/ | | | |
user-+ filename typσ | | | |
*extent number--+ S2 DM |
record number--+
*exten⌠ ái≤ áthσ filσ extent╗ fo≥ DIRLOAD¼ i⌠ i≤ áthσ áfirs⌠ ì
áááááexten⌠ ánumbe≥ áoµ thσ file╗ fo≥ DIRSLOAD¼ i⌠ ái≤ áthσ álas⌠ ì
áááááexten⌠ numbe≥ oµ thσ file
HO╫ T╧ US┼ THES┼ ROUTINES:é Thσ DIR╞ o≥ DIRF╙ routine≤ wil∞ probì
abl∙ bσ useΣ t∩ perforφ you≥ director∙ acces≤ function≤ thσ ávas⌠ ì
majorit∙ áoµ thσ time« Giveε ß buffer¼ aε ambiguou≤ áfilσ áspec¼ ì
anΣ áß selectioε flag¼ DIR╞ anΣ DIRF╙ loaΣ thσ desireΣ file≤ áfo≥ ì
yo⌡ áanΣ átheε yo⌡ caε worδ witΦ thσ 1╢-bytσ áfilσ áentrie≤ áfroφ ì
there« ┴ typica∞ callinτ sequencσ fo≥ DIR╞ o≥ DIRF╙ is:
CAL╠ CODEN─ ; point to buffer space
L─ DE,FC┬ ; point to FCB of file spec
L─ A,11000000┬ ; select all files in user 0
CAL╠ DIR╞ ; load entries
J╥ Z,TPAOVF╠ ; ..jump if error
..« ; HL pts to 1st entry,
; ..BC=number of files
Iµ yo⌡ wisΦ t∩ deviatσ froφ thσ "normaló usσ fo≥ DIR╞ anΣ áDIRFS¼ ì
acces≤ át∩ thσ routine≤ useΣ b∙ DIR╞ anΣ DIRF╙ i≤ áavailable« á ┴ ì
casσ iε whicΦ yo⌡ ma∙ wan⌠ t∩ d∩ thi≤ i≤ wheε yo⌡ arσ áinteresteΣ ì
iε áfile≤ whicΦ matcΦ morσ thaε onσ filσ spec¼ sucΦ a≤ *.AS═ áanΣ ì
*.TXT« ┴ typica∞ callinτ sequencσ fo≥ thi≤ typσ oµ acces≤ is:
; setup
CAL╠ CODEN─ ; point to buffer space
CAL╠ DBUFFE╥ ; get internal info and ptrs
CAL╠ DIRLOA─ ; ..or DIRSLOAD to load names
J╥ Z,TPAOVF╠ ; jump if error condition
...
; select first set of files
L─ DE,FCB▒ ; pt to first FCB to match
L─ A,11000000┬ ; select all files in user 0
CAL╠ DIRSE╠ ; select entries from buffer
; repeat the following 2 lines as necessary
L─ DE,FCB▓ ; pt to 2nd FCB to match
CAL╠ DIRSE╠ ; select again
; finish up
CAL╠ DIRPAC╦ ; pack the file entries,
; ..leaving only the validè ; ..entries in the buffer
L─ A,░ ; alphabetize
CAL╠ DIRALPHA
; done -- HL pts to first file entry, BC=number of entries
.paèBUFFE╥ ALLOCATION:
Routine║ DBUFFER
Function║ Buffer allocation routine
Entry: HL = address of buffer start (usually CODEND to CCP)
Exit: HL = points to first byte at which DIR entries loaded
A <> 0, zero flag clear (NZ) if OK
A = 0, zero flag set (Z) if CCP overwritten
Affected║ AF¼ HL
Usage: Allocate≤ áthσ buffe≥ spacσ necessar∙ fo≥ thσ áse⌠ ì
áááááááááááááááoµ director∙ function≤ iε general« Iε particular¼ ì
ááááááááááááááái⌠ allocate≤ thσ necessar∙ spacσ fo≥ thσ alphabetì
áááááááááááááááizatioε áfunctioε a≤ wel∞ a≤ thσ loadeΣ ádirector∙ ì
áááááááááááááááitself« Thi≤ routinσ mus⌠ bσ useΣ iµ thσ DIRALPH┴ ì
ááááááááááááááároutinσ i≤ t∩ bσ late≥ useΣ t∩ sor⌠ thσ directory╗ ì
áááááááááááááááthi≤ routinσ allocate≤ al∞ thσ spacσ necessar∙ áb∙ ì
áááááááááááááááDIRALPH┴ t∩ sor⌠ thσ routinσ (pointe≥ space)« á Iµ ì
áááááááááááááááthi≤ ároutinσ ái≤ called¼ i⌠ i≤ no⌠ ánecessar∙ át∩ ì
ááááááááááááááácal∞ thσ DPARAM╙ routine.
DIS╦ FRE┼ SPACE:
Routine║ DFREE
Function║ Free space computation routine (CP/M 2.2 and 3)
Entry: None
DPARAM╙ á(o≥ DBUFFE╥ whicΦ call≤ DPARAMS⌐ mus⌠ ábσ ì
ááááááááááááááácalleΣ ábeforσ usinτ thi≤ routinσ unde≥ áCP/═ á2.▓ ì
ááááááááááááááácompatiblσ systems.
Exit: DE = free disk space in kilobytes on current disk
Affected: DE
Usage: Commonl∙ áuseΣ áiε director∙ listinτ ároutine≤ át∩ ì
áááááááááááááááobtaiε áthσ áamoun⌠ oµ freσ spacσ áoε áthσ áloggeΣ ì
ááááááááááááááádisk« á I⌠ ma∙ als∩ bσ useΣ beforσ ß filσ cop∙ át∩ ì
áááááááááááááááinsurσ tha⌠ adequatσ spacσ exist≤ oε thσ ádestinßì
ááááááááááááááátioε drive« Unde≥ CP/═ Plu≤ (CP/═ 3)¼ BDO╙ áfuncì
ááááááááááááááátioε á4╢ i≤ automaticall∙ useΣ t∩ properl∙ áreturε ì
áááááááááááááááfilσ sizσ iε ß bankeΣ system.
DIRECTOR┘ ALPHABETIZATION:
Routine║ DIRALPHA
Function║ Directory alphabetization routine
Entry: H╠ ╜ pointe≥ t∩ firs⌠ director∙ entr∙ (usuall∙ se⌠ ì
áááááááááááááááb∙ DBUFFER)
B├ á╜ ánumbe≥ áoµ file≤ t∩ sor⌠ á(usuall∙ áse⌠ áb∙ ì
áááááááááááááááDIRLOA─ o≥ DIRSLOAD)
┴ á╜ ásor⌠ flag╗ ░ ╜ sor⌠ b∙ filenamσ átheε átype¼ ì
ááááááááááááááánoε-░ ╜ sor⌠ b∙ filetypσ theε name
Exit: None (directory list is sorted)
Affected: AF
Usage: T∩ alphabetizσ thσ file≤ iε thσ director∙ ápointeΣ ì
ááááááááááááááát∩ áb∙ H╠ b∙ eithe≥ filenamσ anΣ átypσ á(STEST.AS═ ì
ááááááááááááááágoe≤ ábeforσ áTEST.AAA⌐ o≥ b∙ áfiletypσ áanΣ ánamσ ì
ááááááááááááááá(TEST.AA┴ goe≤ beforσ STEST.ASM)« Iε thσ unlikel∙ ì
áááááááááááááááeven⌠ átha⌠ aε interna∞ erro≥ i≤ detecteΣ áiε áthσ ìèáááááááááááááááinterna∞ ásor⌠ routine¼ DIRALPH┴ wil∞ senΣ áß áBE╠ ì
ááááááááááááááácharacte≥ t∩ thσ consolσ anΣ abor⌠ t∩ thσ áoperatì
áááááááááááááááinτ systeφ viß thσ BDO╙ warφ boo⌠ vector.
GENERALIZE─ DIRECTOR┘ ROUTINES:
Routine║ DIRF
Function║ Generalized directory routine without sizing
Entry: HL = pointer to buffer area after user code
DE = pointer selection FCB (first 12 bytes used)
A = selection flag structured as:
b7 -- set to select non-system files
b6 -- set to select system files
b5 -- set to select all user areas
b┤-b░ ¡¡ iµ bi⌠ ╡ rese⌠ (0)¼ contain≤ numbe≥
oµ use≥ areß t∩ select
Exit: HL = pointer to first 16-byte file entry in buffer
BC = number of files selected
A <> 0, zero flag clear (NZ) if OK
A = 0, zero flag set (Z) if TPA overflow
Affected: AF¼ BC¼ HL
Usage: Thσ mos⌠ flexible¼ thougΦ slowest¼ oµ thσ directoì
ááááááááááááááár∙ routine≤ iε SYSLIB« I⌠ initialize≤ thσ ábuffe≥ ì
áááááááááááááááarea¼ load≤ ß disδ directory¼ select≤ ß áspecifieΣ ì
áááááááááááááááse⌠ áoµ files¼ pack≤ anΣ sort≤ thσ lis⌠ oµ áfiles« ì
áááááááááááááááDIR╞ áexecute≤ slightl∙ faste≥ sincσ i⌠ ádoe≤ áno⌠ ì
áááááááááááááááobtaiε sizinτ information¼ whilσ DIRF╙ obtain≤ al∞ ì
áááááááááááááááinformatioε whicΦ ma∙ bσ passeΣ t∩ thσ FSIZ┼ árouì
ááááááááááááááátinσ át∩ determinσ thσ sizσ oµ eacΦ entr∙ áiε áthσ ì
ááááááááááááááádirectory« Fo≥ entr∙ parameters¼ thσ addres≤ áfo≥ ì
áááááááááááááááthσ ábuffe≥ ái≤ usuall∙ obtaineΣ froφ áß ácal∞ át∩ ì
áááááááááááááááCODEN─ áwhicΦ return≤ thσ addres≤ oµ áfreσ ámemor∙ ì
áááááááááááááááabovσ áyou≥ program« Thσ FC┬ useΣ áfo≥ áselectioε ì
áááááááááááááááneeΣ no⌠ bσ ß completσ FC┬ sincσ onl∙ thσ ácharacì
áááááááááááááááter≤ iε thσ filenamσ anΣ typσ field≤ arσ used« I⌠ ì
áááááááááááááááma∙ thereforσ bσ a≤ shor⌠ a≤ 1▓ byte≤ (drivσ byte¼ ì
áááááááááááááááfilenamσ anΣ type).
Routine║ DIRFS
Function║ Generalized directory routine with sizing data
Entry: HL = pointer to buffer area after user code
DE = pointer selection FCB (first 12 bytes used)
A = selection flag structured as:
b7 -- set to select non-system files
b6 -- set to select system files
b5 -- set to select all user areas
b┤-b░ ¡¡ iµ bi⌠ ╡ rese⌠ (0)¼ contain≤ numbe≥
oµ use≥ areß t∩ select
Exit: HL = pointer to first 16-byte file entry in buffer
BC = number of files selected
A <> 0, zero flag clear (NZ) if OK
A = 0, zero flag set (Z) if TPA overflow
Affected: AF¼ BC¼ HL
Usage: Thσ mos⌠ flexible¼ thougΦ slowest¼ oµ thσ directoì
ááááááááááááááár∙ routine≤ iε SYSLIB« I⌠ initialize≤ thσ ábuffe≥ ìèáááááááááááááááarea¼ load≤ ß disδ directory¼ select≤ ß áspecifieΣ ì
áááááááááááááááse⌠ áoµ files¼ pack≤ anΣ sort≤ thσ lis⌠ oµ áfiles« ì
áááááááááááááááDIR╞ áexecute≤ slightl∙ faste≥ sincσ i⌠ ádoe≤ áno⌠ ì
áááááááááááááááobtaiε sizinτ information¼ whilσ DIRF╙ obtain≤ al∞ ì
áááááááááááááááinformatioε whicΦ ma∙ bσ passeΣ t∩ thσ FSIZ┼ árouì
ááááááááááááááátinσ át∩ determinσ thσ sizσ oµ eacΦ entr∙ áiε áthσ ì
ááááááááááááááádirectory« Fo≥ entr∙ parameters¼ thσ addres≤ áfo≥ ì
áááááááááááááááthσ ábuffe≥ ái≤ usuall∙ obtaineΣ froφ áß ácal∞ át∩ ì
áááááááááááááááCODEN─ áwhicΦ return≤ thσ addres≤ oµ áfreσ ámemor∙ ì
áááááááááááááááabovσ áyou≥ program« Thσ FC┬ useΣ áfo≥ áselectioε ì
áááááááááááááááneeΣ no⌠ bσ ß completσ FC┬ sincσ onl∙ thσ ácharacì
áááááááááááááááter≤ iε thσ filenamσ anΣ typσ field≤ arσ used« I⌠ ì
áááááááááááááááma∙ thereforσ bσ a≤ shor⌠ a≤ 1▓ byte≤ (drivσ byte¼ ì
áááááááááááááááfilenamσ anΣ type).
DIRECTOR┘ LOA─ ROUTINES:
Routine║ DIRLOAD
Function║ Directory load routine without sizing
Entry: HL = pointer to buffer area after user code
Exit: BC = number of 16-byte file entries loaded in buffer
A <> 0, zero flag clear (NZ) if load OK
A = 0, zero flag set (Z) if TPA overflow error
Affected: AF¼ BC
Usage: Load≤ entrie≤ fo≥ al∞ undeleteΣ file≤ oε thσ ácurì
ááááááááááááááárentl∙ áloggeΣ drivσ fo≥ late≥ selection¼ ásortinτ ì
áááááááááááááááo≥ othe≥ actions« DIRLOA─ i≤ faste≥ thaε DIRSLOA─ ì
ááááááááááááááásincσ i⌠ doe≤ no⌠ havσ t∩ loaΣ sizinτ information¼ ì
áááááááááááááááwhilσ áthσ latte≥ return≤ informatioε áwhicΦ áwil∞ ì
áááááááááááááááallo≈ áFSIZ┼ t∩ returε thσ filσ size« Iµ ásortinτ ì
ááááááááááááááái≤ át∩ bσ done¼ thσ valuσ returneΣ iε H╠ froφ áthσ ì
áááááááááááááááDBUFFE╥ routinσ i≤ ß correc⌠ inpu⌠ fo≥ thesσ árouì
ááááááááááááááátines.
Routine: DIRSLOAD
Function║ Directory load routine with sizing data
Entry: HL = pointer to buffer area after user code
Exit: BC = number of 16-byte file entries loaded in buffer
A <> 0, zero flag clear (NZ) if load OK
A = 0, zero flag set (Z) if TPA overflow error
Affected: AF¼ BC
Usage: Load≤ entrie≤ fo≥ al∞ undeleteΣ file≤ oε thσ ácurì
ááááááááááááááárentl∙ áloggeΣ drivσ fo≥ late≥ selection¼ ásortinτ ì
áááááááááááááááo≥ othe≥ actions« DIRLOA─ i≤ faste≥ thaε DIRSLOA─ ì
ááááááááááááááásincσ i⌠ doe≤ no⌠ havσ t∩ loaΣ sizinτ information¼ ì
áááááááááááááááwhilσ áthσ latte≥ return≤ informatioε áwhicΦ áwil∞ ì
áááááááááááááááallo≈ áFSIZ┼ t∩ returε thσ filσ size« Iµ ásortinτ ì
ááááááááááááááái≤ át∩ bσ done¼ thσ valuσ returneΣ iε H╠ froφ áthσ ì
áááááááááááááááDBUFFE╥ routinσ i≤ ß correc⌠ inpu⌠ fo≥ thesσ árouì
ááááááááááááááátines.
.paèDIRECTOR┘ PAC╦ ROUTINES:
Routine║ DIRPACK
Function║ Pack directory buffer retaining selected entries
Entry: HL = pointer to directory buffer (from DBUFFER)
BC = number of files in buffer (from DIRLOAD)
Exit: BC = number of files remaining in buffer
Affected: BC
Usage: UseΣ áafte≥ selectioε oµ director∙ ároutine≤ áwitΦ ì
áááááááááááááááDIRSE╠ áo≥ áequivalen⌠ t∩ deletσ al∞ áfile≤ áwhicΦ ì
áááááááááááááááhavσ no⌠ beeε selecteΣ b∙ settinτ thσ mos⌠ ásignΘì
áááááááááááááááfican⌠ ábi⌠ áoµ áthσ firs⌠ ábytσ áiε áeacΦ áentry« ì
áááááááááááááááDIRPAC╦ áremove≤ áreference≤ t∩ áthosσ áfile≤ ánotÖ ì
ááááááááááááááámarked« DIRNPAC╦ remove≤ thosσ entrie≤ whicΦ áareÖ ì
ááááááááááááááámarked¼ keepinτ thosσ whicΦ arσ no⌠ markeΣ á(negßì
ááááááááááááááátivσ pack)« DIRSE╠ MUS╘ bσ calleΣ beforσ DIRNPAC╦ ì
ááááááááááááááái≤ áuseΣ sincσ DIRNPAC╦ use≤ aε interna∞ flaτ áse⌠ ì
áááááááááááááááb∙ DIRSE╠ (fo≥ SYSTE═ anΣ R/╧ information).
Routine║ DIRNPACK
Function║ Pack directory buffer retaining non-selected entries
Entry: HL = pointer to directory buffer (from DBUFFER)
BC = number of files in buffer (from DIRLOAD)
Exit: BC = number of files remaining in buffer
Affected: BC
Usage: UseΣ áafte≥ selectioε oµ director∙ ároutine≤ áwitΦ ì
áááááááááááááááDIRSE╠ áo≥ áequivalen⌠ t∩ deletσ al∞ áfile≤ áwhicΦ ì
áááááááááááááááhavσ no⌠ beeε selecteΣ b∙ settinτ thσ mos⌠ ásignΘì
áááááááááááááááfican⌠ ábi⌠ áoµ áthσ firs⌠ ábytσ áiε áeacΦ áentry« ì
áááááááááááááááDIRPAC╦ áremove≤ áreference≤ t∩ áthosσ áfile≤ ánotÖ ì
ááááááááááááááámarked« DIRNPAC╦ remove≤ thosσ entrie≤ whicΦ áareÖ ì
ááááááááááááááámarked¼ keepinτ thosσ whicΦ arσ no⌠ markeΣ á(negßì
ááááááááááááááátivσ pack)« DIRSE╠ MUS╘ bσ calleΣ beforσ DIRNPAC╦ ì
ááááááááááááááái≤ áuseΣ sincσ DIRNPAC╦ use≤ aε interna∞ flaτ áse⌠ ì
áááááááááááááááb∙ DIRSE╠ (fo≥ SYSTE═ anΣ R/╧ information).
OPTIMA╠ DIRECTOR┘ ROUTINES:
Routine║ DIRQ
Function║ Quick access directory routine without sizing
Entry: HL = pointer to buffer area (from CODEND)
DE = pointer to 12-byte select FCB
A = modσ selection flag
b7 -- if set, select non-system files
b6 -- if set, select system files
b╡ ¡¡ iµ se⌠ (1)¼ sor⌠ b∙ filetypσ anΣ name╗
iµ rese⌠ (0)¼ sor⌠ b∙ filenamσ anΣ type
b4-b0 -¡ unused
Exit: HL = points to first 16-byte buffer entry
BC = number of files selected
A <> 0, zero flag clear (NZ) if load OK
A = 0, zero flag set (Z) if TPA overflow
Affected: AF¼ BC¼ HL
Usage: Commonl∙ useΣ wherσ ß simplσ sorteΣ director∙ lis⌠ ì
ááááááááááááááái≤ áneedeΣ áwitΦ minimuφ timσ anΣ ácodσ áoverhead« ìèáááááááááááááááInformatioε i≤ gathereΣ b∙ DIRQ╙ whicΦ wil∞ áallo≈ ì
áááááááááááááááFSIZ┼ át∩ ácalculatσ filσ sizes¼ whilσ áDIR╤ ádoe≤ ì
ááááááááááááááánot« Sincσ DIRQ╙ obtain≤ sizinτ informatioε a≤ i⌠ ì
áááááááááááááááload≤ thσ director∙ information¼ i⌠ run≤ áslightl∙ ì
áááááááááááááááslower« á Iε áthσ unlikel∙ even⌠ áoµ áaε áinterna∞ ì
ááááááááááááááápointe≥ ásor⌠ error¼ ß BE╠ characte≥ wil∞ bσ ásen⌠ ì
ááááááááááááááát∩ áthσ áconsolσ anΣ thσ prograφ wil∞ ábσ áaborteΣ ì
áááááááááááááááwitΦ ß warφ boot.
Routine║ DIRQS
Function║ Quich access directory routine With sizing data
Entry: HL = pointer to buffer area (from CODEND)
DE = pointer to 12-byte select FCB
A = modσ selection flag
b7 -- if set, select non-system files
b6 -- if set, select system files
b╡ ¡¡ iµ se⌠ (1)¼ sor⌠ b∙ filetypσ anΣ name╗
iµ rese⌠ (0)¼ sor⌠ b∙ filenamσ anΣ type
b4-b0 -- unused
Exit: HL = points to first 16-byte buffer entry
BC = number of files selected
A <> 0, zero flag clear (NZ) if load OK
A = 0, zero flag set (Z) if TPA overflow
Affected: AF¼ BC¼ HL
Usage: Commonl∙ useΣ wherσ ß simplσ sorteΣ director∙ lis⌠ ì
ááááááááááááááái≤ áneedeΣ áwitΦ minimuφ timσ anΣ ácodσ áoverhead« ì
áááááááááááááááInformatioε i≤ gathereΣ b∙ DIRQ╙ whicΦ wil∞ áallo≈ ì
áááááááááááááááFSIZ┼ át∩ ácalculatσ filσ sizes¼ whilσ áDIR╤ ádoe≤ ì
ááááááááááááááánot« Sincσ DIRQ╙ obtain≤ sizinτ informatioε a≤ i⌠ ì
áááááááááááááááload≤ thσ director∙ information¼ i⌠ run≤ áslightl∙ ì
áááááááááááááááslower« á Iε áthσ unlikel∙ even⌠ áoµ áaε áinterna∞ ì
ááááááááááááááápointe≥ ásor⌠ error¼ ß BE╠ characte≥ wil∞ bσ ásen⌠ ì
ááááááááááááááát∩ áthσ áconsolσ anΣ thσ prograφ wil∞ ábσ áaborteΣ ì
áááááááááááááááwitΦ ß warφ boot«
DIRECTOR┘ ENTR┘ SELECTION:
Routine║ DIRSEL
Function║ Directory entry selection routine
Entry: HL = pointer to directory buffer (set by DBUFFER)
DE = pointer to 12-byte selection FCB
B├ ╜ numbe≥ oµ file≤ iε director∙ (froφ DIRLOA─ o≥ ì
áááááááááááááááDIRSLOAD)
A = modσ selection flag:
b7 -- set to select non-system files
b6 -- set to select system files
b5 -- set to select all user areas
b┤-b░ ¡¡ iµ bi⌠ ╡ rese⌠ (0)¼ contain≤ numbe≥
oµ use≥ areß t∩ select
Exit: None. MSB set on first byte of selected entries
Affected: None
Usage: Mark≤ áal∞ file≤ iε thσ director∙ buffe≥ ámatchinτ ì
áááááááááááááááthσ áspecifieΣ criteriß b∙ settinτ thσ MS┬ oµ áthσ ì
áááááááááááááááfirs⌠ ábyte« á I⌠ áma∙ bσ useΣ afte≥ áan∙ áoµ áthσ ì
áááááááááááááááSYSLI┬ ádirector∙ ároutine≤ á(DIRF¼ áDIRFS¼ áDIRQ¼ ìèáááááááááááááááDIRQS⌐ át∩ selec⌠ ß subse⌠ oµ al∞ entrie≤ áiε áthσ ì
ááááááááááááááádirector∙ buffer.
DIS╦ PARAMETE╥ INFORMATION:
Routine║ DPARAMS
Function║ Disk parameter information extraction routine
Entry: None
Exit: None (information is placed in local buffers)
Affected: None
Usage: Extract≤ necessar∙ informatioε froφ thσ disδ paraì
ááááááááááááááámete≥ áblocδ (DPB⌐ anΣ store≤ i⌠ awa∙ fo≥ áusσ áb∙ ì
áááááááááááááááothe≥ disδ director∙ routines« Iµ DBUFFE╥ (o≥ an∙ ì
áááááááááááááááoµ thσ SYSLI┬ director∙ routines⌐ i≤ called¼ i⌠ i≤ ì
áááááááááááááááno⌠ necessar∙ t∩ cal∞ DPARAM╙ again« Thσ áfollowì
áááááááááááááááinτ globa∞ variable≤ arσ se⌠ froφ DP┬ information:
.ix BLKSHF (g)
Global║ BLKSHF -- Block shift factor (1 byte)
.ix BLKMSK (g)
Global║ BLKMSK -- Block mask (1 byte)
.ix EXTENT (g)
Global║ EXTENT -- Extent mask (1 byte)
.ix BLKMAX (g)
Global: BLKMAX á¡¡ áMaximuφ numbe≥ oµ block≤ áoε ádisδ á(▓ ì
ááááááááááááááábytes)
.ix DIRMAX (g)
Global: DIRMAX á¡¡ Maximuφ numbe≥ oµ director∙ entrie≤ á(▓ ì
ááááááááááááááábytes)
FIL┼ SIZ┼ COMPUTATION:
Routine║ FSIZE
Function║ File size computation routine
Entry: HL = pointer to first byte of 16-byte file entry
DPARAM╙ (o≥ DBUFFER¼ DIRFS¼ DIRQS¼ DIRSLOAD⌐ ámus⌠ ì
ááááááááááááááábσ ácalleΣ beforσ FSIZ┼ s∩ tha⌠ thσ ácorrec⌠ ádisδ ì
áááááááááááááááparamete≥ informatioε i≤ established.
Exit: DE = file size in kilobytes (K)
Affected: DE
Usage: Normall∙ áuseΣ t∩ computσ thσ sizσ oµ ß filσ áconì
ááááááááááááááátaineΣ áiε áß director∙ produceΣ áb∙ áDIRSLOA─ áo≥ ì
áááááááááááááááDIRQS« á Thi≤ ároutinσ wil∞ ágenerall∙ áwork¼ ábu⌠ ì
áááááááááááááááreturε incorrec⌠ results¼ iµ thσ entr∙ wa≤ áloadeΣ ì
áááááááááááááááb∙ áDIRLOA─ áo≥ DIR╤ whicΦ d∩ áno⌠ áreturε ásizinτ ì
áááááááááááááááinformation.
.paèBYT┼-ORIENTE─ FIL┼ INPUT/OUTPU╘ ROUTINES:é Thσ followinτ documenì
tatioε cover≤ thσ serie≤ oµ bytσ-orienteΣ filσ input/outpu⌠ árouì
tine≤ áiε SYSLIB« Thesσ routine≤ allo≈ yo⌡ t∩ sequentiall∙ áreaΣ ì
froφ á(GET⌐ anΣ writσ t∩ (PUT⌐ ß filσ oε ß ábytσ-fo≥-bytσ ábasis« ì
Hence¼ thesσ routine≤ providσ aε exceptionall∙ simplσ methoΣ áfo≥ ì
handlinτ inpu⌠ froφ anΣ outpu⌠ t∩ ß file.
┴ átypica∞ áprograφ whicΦ employ≤ thesσ routine≤ ámus⌠ áopeε áthσ ì
requireΣ file≤ beforσ doinτ an∙ processing¼ mus⌠ theε perforφ thσ ì
processinτ áoε áthσ openeΣ files¼ anΣ mus⌠ theε closσ áthσ áfile≤ ì
wheε áthσ processinτ i≤ completσ (closinτ thσ file≤ ái≤ áoptiona∞ ì
fo≥ inpu⌠ file≤ anΣ mandator∙ fo≥ outpu⌠ files).
SYSLI┬ áprovide≤ áfou≥ set≤ oµ routine≤ áfo≥ ábytσ-orienteΣ áfilσ ì
inpu⌠ anΣ output:
input open output open GET PUT input close output close
FI0$OPEN FO0$OPEN F0$GET F0$PUT FI0$CLOSE FO0$CLOSE
FI1$OPEN FO1$OPEN F1$GET F1$PUT FI1$CLOSE FO1$CLOSE
FI2$OPEN FO2$OPEN F2$GET F2$PUT FI2$CLOSE FO2$CLOSE
FI3$OPEN FO3$OPEN F3$GET F3$PUT FI3$CLOSE FO3$CLOSE
Thi≤ systeφ allow≤ thσ use≥ t∩ havσ u≡ t∩ ╕ file≤ opeε simultaneì
ousl∙ ¡¡ fou≥ arσ opeε fo≥ inpu⌠ usinτ GE╘ anΣ fou≥ arσ opeε áfo≥ ì
outpu⌠ áusinτ PUT« Fo≥ example¼ thσ followinτ i≤ ß ásamplσ ácodσ ì
sectioε usinτ thesσ routine≤ fo≥ tw∩ files:
EX╘ FI0$OPE╬ ; declare library references
EXT FO0$OPEN
EXT FI0$CLOSE
EXT FO0$CLOSE
EXT F0$GET
EXT F0$PUT
...
LD DE,FCBI ; pt to FCB of input file
CALL FI0$OPEN
LD DE,FCBO ; pt to FCB of output file
CALL FO0$OPEN
...
[body containing CALL F0$GET and CALL F0$PUT]
...
CALL FI0$CLOSE ; close file
CALL FO0$CLOSE
...
END
Notσ tha⌠ onl∙ thσ routine≤ t∩ bσ useΣ arσ referenceΣ iε thσ áEX╘ ì
statements« á Iµ áyo⌡ d∩ no⌠ neeΣ ß particula≥ ároutine¼ ád∩ áno⌠ ì
referencσ it« No⌠ referencinτ aε unneedeΣ routinσ usuall∙ ásave≤ ì
thσ overheaΣ memor∙ spacσ oµ loadinτ i⌠ froφ thσ library.
EacΦ áse⌠ oµ INPU╘ OPEN¼ INPU╘ CLOSE¼ OUTPU╘ OPEN¼ OUTPU╘ áCLOSE¼ ì
GET¼ áanΣ áPU╘ routine≤ i≤ containeΣ iε onσ álibrar∙ ámodule¼ ás∩ ì
referencinτ an∙ oµ thesσ routine≤ cause≤ thσ entirσ modulσ t∩ ábσ ì
loaded¼ anΣ al∞ thσ routine≤ arσ accessablσ t∩ thσ use≥ (provideΣ ìèthe∙ arσ mentioneΣ iε thσ externa∞ definitions⌐ withou⌠ an∙ addiì
tiona∞ ámemor∙ áoverhead« á Specifically¼ áFI0$OPEN¼ ááFI0$CLOSE¼ ì
FO0$OPEN¼ áFO0$CLOSE¼ áF0$GET¼ anΣ F0$PU╘ arσ ácontaineΣ áiε áonσ ì
module¼ áanΣ referencσ t∩ an∙ oµ thesσ routine≤ load≤ thσ áentirσ ì
module╗ thσ samσ i≤ truσ fo≥ thσ othe≥ set≤ oµ routines.
Thσ áCLOS┼ routinσ fo≥ outpu⌠ (FOn$CLOSE⌐ i≤ alwaysÖ required╗ ái⌠ ì
fill≤ áthσ áres⌠ oµ thσ curren⌠ blocδ witΦ ^┌ followeΣ áb∙ á<NUL╛ ì
byte≤ áanΣ áproperl∙ close≤ file« Thσ CLOS┼ ároutinσ áfo≥ áinpu⌠ ì
(FIn$CLOSE⌐ i≤ requireΣ onl∙ ifÖ yo⌡ arσ goinτ t∩ late≥ opeε áanoì
the≥ áfilσ áfo≥ áinpu⌠ áusinτ áthσ ácorrespondinτ áOPE╬ áároutinσ ì
(FIn$OPEN)« á FIn$CLOS┼ onl∙ serve≤ t∩ rese⌠ thσ OPE╬ flaτ á(useΣ ì
t∩ GE╘ t∩ ascertaiε tha⌠ thσ filσ ha≤ beeε properl∙ opened).
Routines║ FI0$OPEN, FI1$OPEN, FI2$OPEN, FI3$OPEN
Function║ Open file for byte inpu⌠
Entry: DE = address of FCB of file to open
Exit: A = 0, zero flag set (Z) if open successful
A = error code, zero flag clear (NZ) if error
Affected: AF
Usage: Open≤ áthσ áspecifieΣ áfilσ fo≥ áinpu⌠ á(usσ áwitΦ ì
áááááááááááááááF$GET)¼ áanΣ outpu⌠ (usσ witΦ F$PUT)« á The∙ áiniì
ááááááááááááááátializσ thσ FC┬ fields¼ s∩ furthe≥ áinitializßtioε ì
ááááááááááááááái≤ no⌠ necessary« Thσ outpu⌠ opeε function≤ áals∩ ì
ááááááááááááááácreatσ áthσ indicateΣ filσ iµ i⌠ doe≤ no⌠ áalread∙ ì
áááááááááááááááexist.
Routines: FO0$OPEN, FO1$OPEN, FO2$OPEN, FO3$OPEN
Function║ Open file for byte output
Entry: DE = address of FCB of file to open
Exit: A = 0, zero flag set (Z) if open successful
A = error code, zero flag clear (NZ) if error
Affected: AF
Usage: Open≤ áthσ áspecifieΣ áfilσ fo≥ áinpu⌠ á(usσ áwitΦ ì
áááááááááááááááF$GET)¼ áanΣ outpu⌠ (usσ witΦ F$PUT)« á The∙ áiniì
ááááááááááááááátializσ thσ FC┬ fields¼ s∩ furthe≥ áinitializßtioε ì
ááááááááááááááái≤ no⌠ necessary« Thσ outpu⌠ opeε function≤ áals∩ ì
ááááááááááááááácreatσ áthσ indicateΣ filσ iµ i⌠ doe≤ no⌠ áalread∙ ì
áááááááááááááááexist.
Routines║ FI0$CLOSE, FI1$CLOSE, FI2$CLOSE, FI3$CLOSE
Function║ Close byte input file
Entry: None
Exit: A = 0, zero flag set (Z) if close successful
A = error code, zero flag clear (NZ) if error
Affected: AF
Usage: Close≤ file≤ previousl∙ openeΣ b∙ thσ ácorrespondì
áááááááááááááááinτ FI$OPE╬ o≥ FO$OPE╬ routines« Whilσ closinτ aε ì
áááááááááááááááinpu⌠ filσ i≤ optiona∞ iµ anothe≥ filσ wil∞ no⌠ bσ ì
áááááááááááááááopeneΣ late≥ b∙ thσ correspondinτ FI$OPE╬ routine¼ ì
ááááááááááááááái⌠ ái≤ poo≥ programminτ practicσ whicΦ áma∙ ácausσ ì
áááááááááááááááproblem≤ áiε ámorσ áadvanceΣ áopera⌠inτ áásystems« ì
áááááááááááááááClosinτ áoutpu⌠ file≤ i≤ mandatoryÖ iµ yo⌡ wan⌠ át∩ ì
áááááááááááááááretaiε thσ file.
è Routines║ FO0$CLOSE, FO1$CLOSE, FO2$CLOSE, FO3$CLOSE
Function║ Close byte output file
Entry: None
Exit: A = 0, zero flag set (Z) if close successful
A = error code, zero flag clear (NZ) if error
Affected: AF
Usage: Close≤ file≤ previousl∙ openeΣ b∙ thσ ácorrespondì
áááááááááááááááinτ FI$OPE╬ o≥ FO$OPE╬ routines« Whilσ closinτ aε ì
áááááááááááááááinpu⌠ filσ i≤ optiona∞ iµ anothe≥ filσ wil∞ no⌠ bσ ì
áááááááááááááááopeneΣ late≥ b∙ thσ correspondinτ FI$OPE╬ routine¼ ì
ááááááááááááááái⌠ ái≤ poo≥ programminτ practicσ whicΦ áma∙ ácausσ ì
áááááááááááááááproblem≤ áiε ámorσ áadvanceΣ áopera⌠inτ áásystems« ì
áááááááááááááááClosinτ áoutpu⌠ file≤ i≤ mandatoryÖ iµ yo⌡ wan⌠ át∩ ì
áááááááááááááááretaiε thσ file.
Routines║ F0$GET, F1$GET, F2$GET, F3$GET
Function║ Get next byte from input file
Entry: None
Exit: A = byte from file, zero set (Z) if OK
A = error code, zero clear (NZ) if error
Affected: AF
Usage: Get≤ ß bytσ froφ thσ filσ specifieΣ iε thσ ácorreì
áááááááááááááááspondinτ Fn$OPE╬ routine.
Routines: F0$PUT, F1$PUT, F2$PUT, F3$PUT
Function║ Put a byte to output file
Entry: A = byte to add to file
Exit: A = 0, zero flag set (Z) if OK
A = error code, zero clear (NZ) if error
Affected: AF
Usage: Put≤ áß bytσ t∩ thσ filσ specifieΣ iε áthσ ácorreì
áááááááááááááááspondinτ Fn$OPE╬ routine.
.paèERRO╥ áRETUR╬ áCODES:é Fo≥ eacΦ oµ thσ routine≤ iε áthi≤ áse⌠ áoµ ì
bytσ-orienteΣ filσ I/╧ routines¼ thσ zer∩ flaτ anΣ thσ ┴ registe≥ ì
pla∙ áß ke∙ rolσ iε indicatinτ thσ erro≥ condition≤ oµ áthσ árouì
tines.
Iµ áthσ zer∩ flaτ i≤ se⌠ (Z⌐ afte≥ ß routinσ ha≤ ábeeε áexecuted¼ ì
theε áthi≤ indicate≤ tha⌠ n∩ erro≥ ha≤ occurred« Thσ ┴ áregiste≥ ì
i≤ eithe≥ unaffecteΣ (iε mos⌠ cases⌐ o≥ contain≤ ß returneΣ valuσ ì
(iµ s∩ indicated¼ a≤ iε Fn$GE╘ routines).
Iµ thσ zer∩ flaτ i≤ clea≥ (NZ⌐ afte≥ ß routinσ ha≤ beeε executed¼ ì
theε áthi≤ indicate≤ tha⌠ aε erro≥ ha≤ occurred« Thσ ┴ áregiste≥ ì
no≈ contain≤ thσ erro≥ code« Followinτ i≤ ß summar∙ oµ thσ erro≥ ì
codes.
code meaning
▒ GET or PUT attempted on an unopened file
2 Disk full (ran out of space)
3 Input file not found
4 Attempt to read past EOF
5 Directory full
6 Error in closing a file
7 ┴ttempt to open a file which is already open
.paèBYT┼-ORIENTE─ FIL┼ I/╧ WIT╚ VARIABL┼ BUFFERS:é Iε additioε t∩ thσ ì
routine≤ ámentioneΣ previously¼ ß se⌠ oµ bytσ-orienteΣ áfilσ áI/╧ ì
routine≤ ái≤ availablσ unde≥ SYSLI┬ ┤ whicΦ permit≤ thσ áuse≥ át∩ ì
definσ áthσ ásizσ anΣ locatioε oµ thσ buffer≤ t∩ ábσ áused« á Thσ ì
routine≤ mentioneΣ abovσ al∞ usσ 12╕¡ bytσ buffers¼ and¼ oε largì
e≥ capacit∙ disδ system≤ (anΣ oε an∙ system≤ iε general)¼ i⌠ áma∙ ì
bσ morσ efficien⌠ t∩ buffe≥ morσ thaε 12╕ byte≤ a⌠ ß time« á Thi≤ ì
wil∞ ácu⌠ dowε oε disδ activit∙ anΣ leavσ morσ memor∙-baseΣ áproì
cessinτ overhead« Thσ routine≤ describeΣ iε thi≤ sectioε are:
routine function
FXI$OPEN open file for input (similar to FIn$OPEN)
FXO$OPEN open file for output (similar to FOn$OPEN)
FXI$CLOS┼ close input file (similar to FIn$CLOSE)
FXO$CLOSE close output file (similar to FOn$CLOSE)
FX$GET get a byte (similar to Fn$GET)
FX$PUT put a byte (similar to Fn$PUT)
Al∞ oµ thσ filσ extendeΣ bytσ I/╧ routine≤ (F╪ mean≤ filσ extendì
ed⌐ worδ witΦ aε I/╧ Contro∞ Blocδ whicΦ i≤ structureΣ as:
block length user-
offset (bytes) set?* function
0 1 Y Number of 128-byte pages in
working buffer
1 1 N End of file flag
2 2 N byte counter
4 2 N Next byte pointer
6 2 Y Address of working buffer
8 36 Y FCB of file (only Fn and Ft
fields set by user)
*"Use≥-Setó mean≤ tha⌠ yo⌡ mus⌠ initializσ thi≤ valuσ beforσ ì
áááááthesσ routine≤ arσ called.
Thσ áfollowinτ áDEFB/DEF╙ structurσ caε bσ useΣ áiε áthσ ácallinτ ì
prograφ t∩ implemen⌠ thσ I/╧ Contro∞ Block:
IOCTL: DEFB 8 ; use 8 128-byte pages (1K)
DEFS 1 ; filled in by FXIO
DEFS 2 ; filled in by FXIO
DEFS 2 ; filled in by FXIO
DEFW WORK ; address of working buffer
IOCFCB:
DEFS 1 ; filled in by FXIO to 0
DEFB 'MYFILE ' ; filename
DEFB 'TXT' ; filetype
DEFS 24 ; filled in by FXIO
WORK: DEFS 128*8 ; working buffer (1K)
.paèAl∞ oµ thσ FXI╧ routine≤ arσ consisten⌠ iε tha⌠ D┼ alway≤ ápoint≤ ì
t∩ thσ I/╧ Contro∞ Blocδ (IOCT╠ above⌐ anΣ ┴ anΣ thσ PS╫ arσ useΣ ì
t∩ ápas≤ áflag≤ anΣ values« ┴ samplσ prograφ bod∙ áwhicΦ áillusì
trate≤ thσ callinτ procedures:
...
[Initialize IOCTL1 and IOCTL2, where 1 is input, 2 is output]
...
LD DE,IOCTL1
CALL FXI$OPEN ; open 1 for input
JR Z,FNF ; file not found error
LD DE,IOCTL2
CALL FXO$OPEN ; open 2 for output
JR Z,NODIR ; no dir space error
...
...
LD DE,IOCTL1
CALL FX$GET ; get next input byte in A
JR Z,EOF ; process EOF
...
LD DE,IOCTL2
CALL FX$PUT ; put byte in A to output file
JR Z,WERR ; process write error
...
LD DE,IOCTL1
CALL FXI$CLOSE ; close input file
JR Z,FCERR ; file close error
LD DE,IOCTL2
CALL FXO$CLOSE ; close output file
JR Z,FCERR
...
Thi≤ simplσ examplσ illustrate≤ thσ flexibilit∙ oµ thσ FXI╧ árouì
tines« A≤ man∙ file≤ a≤ desireΣ ma∙ bσ opeε fo≥ inpu⌠ o≥ output¼ ì
eacΦ áfilσ havinτ it≤ owε I/╧ Contro∞ Blocδ anΣ áworkinτ ábuffer« ì
Thσ advantage≤ iε efficien⌠ disδ accessinτ witΦ thi≤ se⌠ oµ árouì
tine≤ ove≥ thσ previou≤ one≤ arσ notable.
Thσ ámajo≥ disadvantagσ oµ usinτ thesσ routine≤ i≤ tha⌠ thσ ábufì
fer≤ áarσ álarge≥ áanΣ thσ overheaΣ oµ alway≤ áensurinτ átha⌠ áD┼ ì
point≤ át∩ áthσ prope≥ I/╧ Contro∞ Blocδ beforσ eacΦ ároutinσ ái≤ ì
calleΣ i≤ present.
.paè Routines║ FXI$OPEN¼ FXO$OPEN
Function║ Open file for inpu⌠ o≥ output
Entry: DE = address of I/O Control Block of file to open
Exit: A <> 0, zero flag clear (NZ) if OK
A = 0, zero flag set (Z) if error
Affected: AF
Usage: Open≤ thσ filσ specifieΣ b∙ thσ addresseΣ I/╧ Coεì
ááááááááááááááátro∞ áBlocδ fo≥ inpu⌠ o≥ output« á FXI$OPE╬ áopen≤ ì
áááááááááááááááthσ filσ iε thσ curren⌠ director∙ afte≥ initiali·ì
áááááááááááááááinτ thσ FC┬ anΣ load≤ a≤ mucΦ oµ thσ buffe≥ áspacσ ì
áááááááááááááááa≤ possiblσ witΦ datß froφ thσ file« Iµ thσ áfilσ ì
ááááááááááááááádoe≤ áno⌠ exist¼ FXI$OPE╬ return≤ aε áerro≥ ácode« ì
áááááááááááááááFXO$OPE╬ delete≤ thσ filσ referenceΣ b∙ thσ FC┬ iµ ì
ááááááááááááááái⌠ áexist≤ anΣ open≤ thσ referenceΣ filσ fo≥ áou⌠ì
áááááááááááááááput« Iµ therσ i≤ n∩ director∙ spacσ remaininτ áiε ì
áááááááááááááááwhicΦ t∩ storσ thσ file'≤ entry¼ FXO$OPE╬ áreturn≤ ì
áááááááááááááááaε áerro≥ ácode« Thσ FXI╧ standarΣ áerro≥ áreturε ì
ááááááááááááááácode≤ áarσ áused« A=░ anΣ zer∩ flaτ áse⌠ á(Z⌐ áiµ ì
áááááááááááááááerror.
Routines║ FXI$CLOSE¼ FXO$CLOSE
Function║ Close inpu⌠ o≥ outpu⌠ file
Entry: DE = address of an I/O Control Block
Exit: A <> 0, zero flag clear (NZ) if OK
A = 0, zero flag set (Z) if close error
Affected: AF
Usage: Close≤ áthσ áfilσ whosσ I/╧ Contro∞ Blocδ ái≤ áadì
ááááááááááááááádresseΣ b∙ DE« FXI$CLOS┼ simpl∙ close≤ thσ áfile« ì
áááááááááááááááFXO$CLOS┼ áflushe≤ áthσ workinτ ábuffe≥ át∩ ádisk¼ ì
áááááááááááááááfillinτ áthσ las⌠ 12╕-bytσ blocδ witΦ ^Z'≤ iµ áno⌠ ì
ááááááááááááááácompletel∙ filleΣ already¼ anΣ close≤ thσ filσ áoε ì
ááááááááááááááádisk« á Thσ FXI╧ standarΣ erro≥ returε ácode≤ áarσ ì
áááááááááááááááuseΣ áwitΦ áA=░ anΣ thσ zer∩ flaτ se⌠ á(Z⌐ áiµ áaε ì
áááááááááááááááerro≥ occured.
Routine║ FX$GET
Function║ Byte input routine
Entry: None
Exit: A = next byte from file, zero clear (NZ) if no error
A = 0, zero flag set (Z) if read past EOF
Affected: AF
Usage: Get≤ thσ nex⌠ bytσ froφ thσ filσ whosσ I/╧ Contro∞ ì
áááááááááááááááBlocδ i≤ pointeΣ t∩ b∙ DE« Thσ correspondinτ opeε ì
áááááááááááááááfunctioε á(FXI$OPEN⌐ mus⌠ havσ beeε calleΣ ábeforσ ì
áááááááááááááááan∙ cal∞ t∩ FX$GET.
Routine║ FX$PUT
Function║ Byte output routine
Entry: A = byte to output to specified file
Exit: A = output byte, zero clear (NZ) if put OK
A = 0, zero flag set if write error
Affected: AF
Usage: Put≤ thσ specifieΣ bytσ int∩ thσ filσ speπifieΣ iε ì
áááááááááááááááthσ I/╧ Contro∞ Blocδ pointeΣ t∩ b∙ DE« Thσ ácorì
ááááááááááááááárespondinτ opeε functioε (FXO$OPEN⌐ mus⌠ havσ beeε ìèááááááááááááááácalleΣ beforσ an∙ cal∞ t∩ FX$PUT.
BYT┼-ORIENTE─ FIL┼ I/╧ WIT╚ VARIABL┼ BUFFER╙ AN─ UNGET:é Iε áaddiì
tioε át∩ thσ F╪ routine≤ covereΣ iε thσ previou≤ sectioε arσ áthσ ì
F┘ routines« Fo≥ onl∙ ß sligh⌠ increasσ iε memor∙ árequirements¼ ì
thσ F┘ prefi° routine≤ providσ thσ samσ function≤ a≤ thσ F╪ árouì
tine≤ anΣ adΣ thσ UNGE╘ function.
FY$UNGE╘ set≤ thσ nex⌠ characte≥ t∩ bσ returneΣ b∙ FY$GET« á Onl∙ ì
onσ characte≥ aheaΣ caε bσ set« Thi≤ functioε i≤ extremel∙ áuseì
fu∞ iε application≤ whicΦ reaΣ anΣ parsσ aε inpu⌠ filσ iε ß ásinì
glσ ápass« á Ofteε thσ enΣ oµ ß tokeε i≤ detecteΣ onl∙ áwheε áthσ ì
characte≥ áafte≥ thσ tokeε i≤ pickeΣ u≡ anΣ áexamined« á FY$UNGE╘ ì
allow≤ áyo⌡ t∩ pu⌠ thi≤ characte≥ back¼ s∩ tha⌠ thσ ánex⌠ áFY$GE╘ ì
pick≤ ái⌠ áu≡ anΣ caε proces≤ i⌠ iε it≤ owε righ⌠ a≤ áopposeΣ át∩ ì
beinτ ß par⌠ oµ thσ tokeε processinτ routine.
Asidσ froφ thσ ne≈ FY$UNGE╘ function¼ F┘ prefi° routine≤ áprovidσ ì
thσ ásamσ function≤ a≤ thσ F╪ prefi° routines« Thσ áI/╧ áContro∞ ì
Blocδ fo≥ thσ F┘ routines¼ however¼ i≤ tw∩ byte≤ large≥ thaε áthσ ì
IOC┬ fo≥ thσ F╪ routines« Thσ routine≤ describeΣ iε thi≤ sectioε ì
are:
routine similar to function
FYI$OPEN FXI$OPEN open file for input
FYO$OPEN FXO$OPEN open file for output
FYI$CLOSE FXI$CLOSE close input file
FYO$CLOSE FXO$CLOSE close output file
FY$GET FX$GET get byte
FY$UNGET unget byte
FY$PUT FX$PUT put byte
Al∞ oµ thσ filσ extendeΣ bytσ I/╧ routine≤ (F┘ mean≤ filσ extendì
eΣ beyonΣ FX⌐ worδ witΦ aε I/╧ Contro∞ Blocδ structureΣ as:
block length user-
offset (bytes) set?* function
0 1 Y Number of 128-byte pages in
working buffer
1 1 N End of file flag
2 2 N Byte counter
4 2 N Next byte pointer
6 1 N Character pending flag
7 1 N Pending character
8 2 Y Address of working buffer
10 36 Y FCB of file (only Fn and Ft
fields set by user)
*"use≥-setó mean≤ tha⌠ yo⌡ mus⌠ initializσ thi≤ valuσ beforσ ì
áááááthesσ routine≤ arσ called.
.paèThσ áfollowinτ áDEFB/DEF╙ structurσ caε bσ useΣ áiε áthσ ácallinτ ì
prograφ t∩ implemen⌠ thσ I/╧ Contro∞ Block:
IOCTL: DEFB ╕ ; use 8 128-byte pages (1K)
DEFS 7 ; filled in by FYIO
DEF╫ WOR╦ ╗ addres≤ oµ workinτ buffer
IOCFCB:
DEFS 1 ; filled in by FYIO to 0
DEFB 'MYFILE ' ; filename
DEFB 'TXT' ; filetype
DEFS 24 ; filled in by FYIO
WORK: DEFS 128*8 ; working buffer (1K)
Al∞ oµ thσ FYI╧ routine≤ arσ consisten⌠ iε tha⌠ D┼ alway≤ ápoint≤ ì
t∩ thσ I/╧ Contro∞ Blocδ (IOCT╠ above⌐ anΣ ┴ anΣ thσ PS╫ arσ useΣ ì
t∩ ápas≤ áflag≤ anΣ values« ┴ samplσ prograφ bod∙ áwhicΦ áillusì
trate≤ thσ callinτ procedures:
...
[Initialize IOCTL1 and IOCTL2, where 1 is input, 2 is output]
...
LD D,IOCTL1
CALL FYI$OPEN ; open 1 for input
J╥ Z,FN╞ ╗ ..jum≡ iµ filσ no⌠ found err
LD D,IOCTL2
CALL FYO$OPEN ; open 2 for output
JR Z,NODIR ; ..jump if no dir space error
...
...
LD D,IOCTL1
CALL FY$GET ; get next input byte in A
JR Z,EOF ; ..jump to process EOF
...
LD D,IOCTL1
LD A,CH ; unget character CH
CALL FY$UNGET
...
LD D,IOCTL2
CALL FY$PUT ; put byte in A to output file
JR Z,WERR ; ..jump to process write error
...
LD D,IOCTL1
CALL FYI$CLOSE ; close input file
JR Z,FCERR ; ..jump if file close error
LD D,IOCTL2
CALL FYO$CLOSE ; close output file
JR Z,FCERR ; ..jump if error
...
Thi≤ simplσ examplσ illustrate≤ thσ flexibilit∙ oµ thσ FYI╧ árouì
tines« A≤ man∙ file≤ a≤ desireΣ ma∙ bσ opeε fo≥ inpu⌠ o≥ output¼ ì
eacΦ áfilσ havinτ it≤ owε I/╧ Contro∞ Blocδ anΣ áworkinτ ábuffer« ì
Thσ advantage≤ iε efficien⌠ disδ accessinτ witΦ thi≤ se⌠ oµ árouì
tine≤ ove≥ thσ previou≤ one≤ arσ notable.
èThσ ámajo≥ disadvantagσ oµ usinτ thesσ routine≤ i≤ tha⌠ thσ ábufì
fer≤ áarσ álarge≥ áanΣ thσ overheaΣ oµ alway≤ áensurinτ átha⌠ áD┼ ì
point≤ át∩ áthσ prope≥ I/╧ Contro∞ Blocδ beforσ eacΦ ároutinσ ái≤ ì
calleΣ i≤ present.
Routines║ FYI$OPEN, FYO$OPEN
Function║ FYIO filσ open routines
Entry: DE = pointer to I/O Control Block of file to open
Exit: A <> 0, zero flag clear (NZ) if OK
A = 0, zero flag set (Z) if error
Affected: AF
Usage: Open≤ file≤ fo≥ subsσquen⌠ processinτ b∙ othe≥ F┘-ì
áááááááááááááááprefi° ároutines« FYI$OPE╬ open≤ thσ filσ iε áthσ ì
ááááááááááááááácurren⌠ ádirector∙ afte≥ initializinτ thσ FC┬ áanΣ ì
áááááááááááááááload≤ a≤ mucΦ oµ thσ buffe≥ spacσ a≤ possiblσ witΦ ì
ááááááááááááááádatß áfroφ thσ file« Iµ thσ filσ doe≤ no⌠ áexist¼ ì
áááááááááááááááFYI$OPE╬ rσturn≤ aε erro≥ code« FYO$OPE╬ ádelete≤ ì
áááááááááááááááthσ áfilσ referenceΣ b∙ thσ FC┬ iµ i⌠ áexist≤ áanΣ ì
áááááááááááááááopen≤ thσ referenceΣ filσ fo≥ output« Iµ therσ i≤ ì
ááááááááááááááán∩ direπtor∙ spacσ remaininτ iε whicΦ t∩ storσ thσ ì
áááááááááááááááfile'≤ entry¼ FYO$OPE╬ return≤ aε erro≥ code.
Routine║ FYI$CLOSE, FYO$CLOSE
Function║ FYIO file close routines
Entry: DE = pointer to I/O Control Block
Exit: A <> 0, zero flag clear (NZ) if OK
A = 0, zero flag set (Z) if close error
Affected: AF
Usage: Close≤ áfile≤ openeΣ b∙ thσ árespectivσ áF┘-prefi° ì
áááááááááááááááopeε routines« FYI$CLOS┼ simpl∙ close≤ thσ áfile« ì
áááááááááááááááFYO$CLOS┼ áflushe≤ áthσ workinτ ábuffe≥ át∩ ádisk¼ ì
áááááááááááááááfillinτ thσ las⌠ 12╕-bytσ blocδ witΦ ^┌ character≤ ì
áááááááááááááááiµ áno⌠ completel∙ filleΣ already¼ anΣ close≤ áthσ ì
áááááááááááááááfile.
Routine║ FY$GET
Function║ FYIO bytσ inpu⌠ routine
Entry: None
Exit: A = next byte, zero clear (NZ) if no error
A = 0, zero flag set (Z) if past EOF
Affected: AF
Usage: Read≤ thσ content≤ oµ file≤ openeΣ b∙ áa≡propriatσ ì
áááááááááááááááF┘ opeε routines« FY$GE╘ get≤ thσ nex⌠ bytσ áfroφ ì
áááááááááááááááthσ áspecifieΣ áfile« á FYI$OPE╬ ámus⌠ áhavσ ábeeε ì
ááááááááááááááácalleΣ beforσ an∙ cal∞ t∩ FY$GET.
Routine║ FY$UNGET
Function║ FYIO bytσ unge⌠ routine
Entry: A = byte to "Unget"
Exit: A = character, zero flag clear (NZ) if OK
A = character, zero set (Z) if byte pending already
Affected: AF
Usage: Set≤ áthσ ánex⌠ ábytσ t∩ bσ áreturneΣ áb∙ áFY$GET« ì
áááááááááááááááFY$UNGE╘ áma∙ onl∙ bσ calleΣ oncσ beforσ thσ ánex⌠ ì
áááááááááááááááFY$GET¼ sincσ i⌠ work≤ onl∙ onσ bytσ ahead« Iµ áß ìèááááááááááááááábytσ áwa≤ áalread∙ pending¼ áFY$UNGE╘ áreturn≤ áaε ì
áááááááááááááááerro≥ ácodσ áwitΦ n∩ UNGE╘ function« á ┴ ácal∞ át∩ ì
áááááááááááááááFYI$OPE╬ i≤ requireΣ beforσ FY$UNGE╘ caε bσ used.
Routine║ FY$PUT
Function║ FYIO bytσ output routine
Entry: A = byte to output
Exit: A = character, zero flag clear (NZ) if OK
A = 0, zero flag set (Z) if write error
Affected: AF
Usage: Change≤ thσ content≤ oµ file≤ openeΣ b∙ áappropriì
áááááááááááááááatσ áF┘ opeε routines« FY$PU╘ put≤ thσ nex⌠ ábytσ ì
áááááááááááááááint∩ thσ specifieΣ file« FYO$OPE╬ mus⌠ havσ ábeeε ì
ááááááááááááááácalleΣ beforσ an∙ cal∞ t∩ FY$PUT.
GENERA╠ áPURPOS┼ CP/═ FIL┼ MANIPULATIO╬ ROUTINES:é áThσ áfollowinτ ì
routine≤ arσ genera∞-purposσ filσ I/╧ routine≤ whicΦ interfacσ t∩ ì
CP/═ áthrougΦ thσ entr∙ poin⌠ a⌠ locatioε 5« The∙ ápreservσ áBC¼ ì
DE¼ anΣ HL¼ anΣ returε witΦ thσ standarΣ CP/═ erro≥ code≤ fo≥ thσ ì
correspondinτ routines« Thesσ routine≤ are:
F$CLOS┼ F$MAK┼ F$REA─ F$WRITE
F$DELET┼ F$MOPE╬ F$RENAM┼ R$READ
F$EXIS╘ F$OPE╬ F$SIZ┼ R$WRITE
Thσ ároutine≤ GFA¼ SCFA¼ anΣ SF┴ al∞ dea∞ witΦ gettinτ (GFA⌐ áanΣ ì
settinτ á(SCF┴ áanΣ SFA⌐ thσ attribute≤ oµ file≤ whosσ áFCB≤ áarσ ì
addresseΣ b∙ DE.
Thσ followinτ file≤ allo≈ yo⌡ t∩ appenΣ t∩ thσ enΣ oµ aε existinτ ì
filσ conveniently« The∙ returε uniquσ erro≥ codes.
F$APPEN─ GETR╥ GETFS
F$APPL GETRR1 GETFS1
Routine║ F$CLOSE
Function║ Close a file
Entry: DE = points to FCB for desired file
Exit: A = 0, ·ero flag set (Z) if close OK
A <> 0, zero clear (NZ) if error in closing
Affected: AF
Usage: Close≤ áß specifieΣ filσ iε thσ curren⌠ drivσ áanΣ ì
áááááááááááááááuse≥ area.
Routine║ F$DELETE
Function║ Delete a file
Entry: DE = points to FCB for file to delete
Exit: A = 0, zero flag set (Z) if delete OK
A <> 0, zero clear (NZ) if file not found
Affected: AF
Usage: Delete≤ áß specifieΣ filσ froφ curren⌠ ádrivσ áanΣ ì
áááááááááááááááuse≥ area.
.paè Routine║ F$EXIST
Function║ Test for existence of a file
Entry: DE = address of an FCB for file to test
Exit: A <> 0, zero flag clear (NZ) if file exists
A = 0, zero flag set (Z) if file not found
Affected: AF
Usage: Test≤ fo≥ thσ presencσ oµ ß specifieΣ filσ iε áthσ ì
ááááááááááááááácurren⌠ ádisδ anΣ use≥ area« Statu≤ ái≤ áreturneΣ ì
áááááááááááááááshowinτ thσ result≤ oµ thσ search.
Routine║ F$MAKE
Function║ Create a file
Entry: DE = points to an FCB for the desired file
Exit: A = directory code [0..3] if file i≤ created OK
A = 0FFh if no directory space i≤ available
Affected: AF
Usage: Create≤ á(makes⌐ ß specifieΣ filσ iε áthσ ácurren⌠ ì
ááááááááááááááádrivσ anΣ use≥ area.
Routine║ F$OPEN
Function║ Open a file
Entry: DE = pointer to FCB for desired file
Exit: A = 0, zero flag set (Z) if file opened OK
A <> 0, zero flag clear (NZ) if not opened
Affected: AF
Usage: Open≤ áß specifieΣ filσ iε thσ curren⌠ ádrivσ áanΣ ì
áááááááááááááááuse≥ area.
Routine║ F$MOPEN
Function║ Open a file with creation
Entry: DE = pointer to FCB for file to open
Exit: A = 0, zero flag set (Z) if file opened OK
A <> 0, zero clear (NZ) if no directory space (error)
Affected: AF
Usage: Open≤ ß specifieΣ file« Iµ thσ filσ i≤ no⌠ found¼ ì
áááááááááááááááF$MOPE╬ trie≤ t∩ creatσ one« Thi≤ routinσ áshoulΣ ì
áááááááááááááááno⌠ bσ useΣ a≤ ß substitutσ fo≥ existencσ átestinτ ì
áááááááááááááááwitΦ F$EXIST.
Routine║ F$APPEND
Function║ Append to a file
Entry: DE = pointer to an FCB for the desired file
Exit: A = 0, zero flag set (Z) if file opened OK
A = error code, zero flag clear (NZ) if error is:
1 ╜ file not found
2 = file is full (no more room)
3 = file found but empty
Affected: AF¼ current DMA buffer has last file record if A=0
Usage: Open≤ áß filσ fo≥ appending« Thσ result≤ áoµ áthσ ì
áááááááááááááááoperatioε arσ reported« Variou≤ erro≥ condΘtion≤ ì
ááááááááááááááácaε áoccur¼ anΣ arσ reported« Erro≥ │ i≤ áß ánotσ ì
ááááááááááááááátha⌠ thσ filσ i≤ empt∙ anΣ i≤ no⌠ fata∞ á(pr∩cessì
áááááááááááááááinτ ácaε continue)« Iµ thσ appenΣ i≤ ásucces≤ful¼ ì
áááááááááááááááthσ curren⌠ DM┴ buffe≥ contain≤ thσ las⌠ recorΣ iε ì
áááááááááááááááthσ file« Thσ nex⌠ sequentia∞ writσ wil∞ writσ t∩ ìèáááááááááááááááthσ árecorΣ afte≥ thσ las⌠ onσ iε thσ file« á (Seσ ì
áááááááááááááááF$APP╠ whicΦ start≤ writinτ oε thσ las⌠ recorΣ áoµ ì
áááááááááááááááthσ file).
Example║ Seσ F$APP╠ below.
Routine║ F$APPL
Function║ AppenΣ t∩ ß file
Entry: DE = pointer to FCB for desired file
Exit: A = 0, zero flag set (Z) if file opened OK
A = error code, zero flag clear (NZ) if error
1 = file not found
2 = file is full (no more room)
3 = file found but empty
Affected: AF¼ current DMA buffer has last record if A=0
Usage: Open≤ áß filσ fo≥ appending« Thσ result≤ áoµ áthσ ì
áááááááááááááááoperatioε arσ reported« Variou≤ erro≥ condΘtion≤ ì
ááááááááááááááácaε áoccur¼ anΣ arσ reported« Erro≥ │ i≤ áß ánotσ ì
ááááááááááááááátha⌠ thσ filσ i≤ empt∙ anΣ i≤ no⌠ fata∞ á(pr∩cessì
áááááááááááááááinτ caε continue)« Iµ thσ APP╠ i≤ successful¼ thσ ì
ááááááááááááááálas⌠ árecorΣ áiε thσ filσ i≤ iε áthσ ácurren⌠ áDM┴ ì
ááááááááááááááábuffer« Thσ nex⌠ sequentia∞ writσ (F$WRITE⌐ áwil∞ ì
áááááááááááááááwritσ bacδ ove≥ thσ las⌠ recorΣ iε thσ file.
Example: Thσ followinτ codσ segmen⌠ illustrate≤ thσ intendì
áááááááááááááááeΣ usagσ fo≥ thσ tw∩ filσ appenΣ routines.
With F$APPEND: With F$APPL:
... ...
LD DE,FCB L─ DE,FCB
CALL F$APPEND CALL F$APPL
... ...
[Preparσ nex⌠ record▌ [Modif∙ las⌠ record]
... ...
LD DE,FCB LD DE,FCB
CALL F$WRITE ╗ after last CALL F$WRITE ; on last
... ...
LD DE,FCB LD DE,FCB
CALL F$CLOSE ╗ close file CALL F$CLOSE ; close
... ...
Routine║ F$READ
Function║ Read a block from a file
Entry: DE = pointer to FCB for desired file
Exit: A = 0, zero flag set (Z) if read OK
A = error code, zero flag clear (NZ) if error
1 ╜ read past end of file
2 ╜ reading unwritten data in random access
Usage: Read≤ áthσ nex⌠ blocδ (12╕ bytes⌐ oµ datß froφ áaε ì
áááááááááááááááopeε filσ iε thσ curren⌠ drivσ anΣ use≥ area« Thσ ì
ááááááááááááááádatß i≤ loadeΣ int∩ thσ curren⌠ DM┴ buffer.
.paè Routine║ F$RENAME
Function║ Rename a file
Entry: HL = pointer to first 12 bytes of new FCB
DE = pointer to first 12 bytes of old FCB
Exit: A <> 0, zero flag clear (NZ) if rename OK
A = 0, zero flag set (Z) if file not found error
Affected: AF
Usage: Rename≤ ß filσ iε thσ curren⌠ drivσ anΣ use≥ area« ì
áááááááááááááááOnl∙ áthσ Fε anΣ F⌠ field≤ arσ signifΘcan⌠ iε áthσ ì
áááááááááááááááFCB's¼ s∩ thσ res⌠ oµ thσ FC┬ neeΣ no⌠ bσ ápresen⌠ ì
áááááááááááááááfo≥ thi≤ functioε t∩ work.
Routine║ F$SIZE
Function║ Compute file size
Entry: DE = pointer to the 1st 12 bytes of an FCB
Exit: HL = file size in kilobytes
Affected: AF
Usage: Obtain≤ áthσ computeΣ sizσ oµ ß filσ (iε K⌐ ábaseΣ ì
áááááááááááááááoε it≤ recorΣ count« Thi≤ routinσ give≤ thσ áfilσ ì
ááááááááááááááásizσ ácorrec⌠ át∩ thσ nex⌠ 1K¼ bu⌠ doe≤ áno⌠ átakσ ì
áááááááááááááááint∩ accoun⌠ thσ groupinτ factor.
Routine║ F$WRITE
Function║ Write a block to a file
Entry: DE = pointer to FCB for open file
Exit: A = 0, zero flag set (Z) if write OK
A = error code, zero clear (NZ) if error
1 = error in extending file
2 = end of disk data
0FFh ╜ no more directory space
Affected: AF
Usage: Writσ áthσ ánex⌠ 12╕ bytσ blocδ oµ datß áfroφ áthσ ì
ááááááááááááááácurren⌠ DM┴ buffe≥ t∩ ß specifieΣ opeε filσ iε thσ ì
ááááááááááááááácurren⌠ drivσ anΣ use≥ area.
Routines║ GETRR, GETRR1
Function║ Get random record number
Entry: DE = pointer to FCB
Exit: HL = random record number
A = 0, zero flag set (Z) if no error
┴ á<╛ á0¼ zer∩ flaτ clea≥ (NZ⌐ áiµ árandoφ árecorΣ ì
áááááááááááááááoverflo≈ (valuσ iε ┴ i≤ erro≥ code)
Affected: AF¼ HL
Usage: Returε thσ randoφ recorΣ numbe≥ oµ thσ las⌠ recorΣ ì
áááááááááááááááreaΣ áo≥ writteε sequentiall∙ froφ áthσ áspecifieΣ ì
áááááááááááááááfile« Thesσ routine≤ arσ convenien⌠ iε ádetermiεì
áááááááááááááááinτ áthσ curren⌠ positioε iε ß file« á GETR╥ ádoe≤ ì
áááááááááááááááno⌠ áaffec⌠ thσ randoφ recorΣ numbe≥ fielΣ oµ áthσ ì
áááááááááááááááFC┬ anΣ i≤ large≥ iε size« GETRR▒ i≤ smaller¼ bu⌠ ì
ááááááááááááááádoesô affec⌠ thσ randoφ recorΣ numbe≥ fielΣ oµ áthσ ì
áááááááááááááááFCB.
.paè Routines║ GETFS, GETFS1
Function║ Get file size in records
Entry: DE = pointer to FCB
Exit: HL = number of records in file (file size)
A = 0, zero flag set (Z) if no error
┴ á<╛ á0¼ zer∩ flaτ clea≥ (NZ⌐ áiµ árandoφ árecorΣ ì
áááááááááááááááoverflo≈ (valuσ iε ┴ i≤ erro≥ code)
Affected: AF¼ HL
Usage: Returε thσ filσ sizσ (iε term≤ oµ records⌐ oµ áthσ ì
áááááááááááááááfilσ áwhosσ FC┬ i≤ pointeΣ t∩ b∙ DE« á Thesσ áro⌡ì
ááááááááááááááátine≤ arσ convenien⌠ iε determininτ thσ numbe≥ áoµ ì
ááááááááááááááárecord≤ áiε áß file« GETF╙ doe≤ áno⌠ áaffec⌠ áthσ ì
ááááááááááááááárandoφ recorΣ numbe≥ fielΣ oµ thσ FC┬ anΣ i≤ larτì
áááááááááááááááe≥ áiε size« GETFS▒ i≤ smaller¼ bu⌠ ádoe≤ áaffec⌠ ì
áááááááááááááááthσ randoφ recorΣ numbe≥ fielΣ oµ thσ FCB.
Routine║ GFA
Function║ Get file attributes
Entry: DE = pointer to FCB
Exit: A = attribute code
b0 = read-only attribute (1 = R/O, 0 = R/W)
b7 = system attribute (1 = SYS, 0 = DIR)
Affected: AF
Usage: Return≤ áthσ attribute≤ oµ thσ filσ whosσ áFC┬ ái≤ ì
ááááááááááááááápointeΣ át∩ b∙ DE« Oε return¼ ┴ contain≤ áß ácodσ ì
áááááááááááááááindicatinτ áthσ R/╧ anΣ SY╙ attributes¼ wherσ áthσ ì
ááááááááááááááá8tΦ ábi⌠ áoµ ┴ (b7⌐ i≤ ▒ iµ thσ filσ i≤ áß ásysteφ ì
áááááááááááááááfilσ anΣ ░ iµ thσ filσ i≤ ß director∙ (noε-system⌐ ì
áááááááááááááááfilσ anΣ thσ 1s⌠ bi⌠ oµ ┴ (b0⌐ i≤ ▒ iµ thσ filσ i≤ ì
áááááááááááááááread/onl∙ áanΣ ░ iµ thσ filσ i≤ read/write« A≤ áß ì
ááááááááááááááásidσ effect¼ thσ MSB≤ oµ al∞ byte≤ iε thσ filenamσ ì
áááááááááááááááanΣ filetypσ field≤ oµ thσ origina∞ FC┬ (byte≤ á▒-ì
ááááááááááááááá11¼ áwherσ bytσ ░ i≤ first⌐ arσ se⌠ equa∞ át∩ áthσ ì
áááááááááááááááMSB≤ oµ thσ correspondinτ director∙ entry.
Routine║ R$READ
Function║ Random read a block from a file
Entry: DE = pointer to FCB
HL = random record number
Exit: A = 0, zero flag set (Z) if no error
A = error code, zero clear (NZ) if error where:
1 ╜ attempt to read unwritten record
3 ╜ CP/M could not close current extent
4 ╜ attempt to read unwritten extent
6 ╜ attempt to read beyond end of disk
Affected: AF
Usage: Read≤ áß blocδ froφ thσ specifieΣ filσ áiε árandoφ ì
ááááááááááááááámode« á I⌠ ái≤ assumeΣ tha⌠ thσ filσ áha≤ áalread∙ ì
ááááááááááááááábeeε openeΣ b∙ thσ F$OPE╬ routinσ o≥ equΘvalent.
.paè Routine║ R$WRITE
Function║ Random write of a block to a file
Entry: DE = pointer to FCB
HL = random record number
Exit: A = 0, zero flag set (Z) if no error
A = error code, zero flag clear (NZ) if error:
0 ╜ no error (Z flag set)
1 ╜ attempt to read unwritten record
3 ╜ CP/M could not close current extent
4 ╜ attempt to read unwritten extent
5 ╜ directory full
6 ╜ attempt to read beyond end of disk
Affected: AF
Usage: Write≤ ádatß áa⌠ thσ curren⌠ DM┴ positioε át∩ áthσ ì
ááááááááááááááádesignateΣ filσ iε ß specifiπ recorΣ number« Thi≤ ì
áááááááááááááááfilσ shoulΣ havσ beeε previousl∙ openeΣ b∙ ß ácal∞ ì
ááááááááááááááát∩ F$OPE╬ o≥ equivalent.
Routine║ SCFA
Function║ Set and clear file attributes
Entry: DE = pointer to FCB
A = attribute code:
b0 = read-only (1=set to R/O, 0=set to R/W)
b7 = system (1=set to SYS, 0=set to DIR)
Exit: A = 0, zero flag set (Z) if operation OK
A <> 0, zero clear (NZ) if ambiguous filσ o≥ not found
Affected: AF
Usage: Set≤ o≥ clear≤ reaΣ-onl∙ anΣ systeφ attribute≤ áoµ ì
áááááááááááááááthσ specifieΣ filσ anΣ clea≥ al∞ othe≥ áattribute≤ ì
ááááááááááááááát∩ ░ (thσ MSB≤ oµ byte≤ ▒-╕ anΣ 1▒ arσ se⌠ t∩ á0)« ì
áááááááááááááááBit≤ ░ anΣ ╖ oµ thσ ┴ registe≥ arσ se⌠ t∩ ásignif∙ ì
áááááááááááááááho≈ thσ reaΣ-onl∙ anΣ systeφ bit≤ arσ t∩ bσ se⌠ iε ì
áááááááááááááááthσ file« Al∞ attributσ bit≤ othe≥ theε reaΣ-onl∙ ì
áááááááááááááááanΣ systeφ arσ cleareΣ t∩ zero.
Routine║ SFA
Function║ Set file attributes
Entry: DE = pointer to FCB
A = attribute code:
b0 = read-only (1 = set to R/O, 0 = set to R/W)
b7 = system (1 = set t∩ SYS, 0 = set DIR)
Exit: A = 0, zero flag set (Z) if operation OK
A <> 0, zero clear (NZ) if ambiguous filσ o≥ not found
Affected: AF
Usage: Set≤ o≥ clear≤ thσ reaΣ-onl∙ and/o≥ systeφ áattriì
ááááááááááááááábute≤ áoµ thσ specifieΣ filσ whilσ áno⌠ áaffec⌠inτ ì
áááááááááááááááthσ othe≥ attributσ bit≤ (byte≤ ▒-11¼ wherσ bytσ ░ ì
ááááááááááááááái≤ áfirst)« Al∞ attribute≤ iε thσ FC┬ arσ se⌠ át∩ ì
áááááááááááááááthosσ oµ thσ director∙ entr∙ excep⌠ fo≥ áreaΣ-onl∙ ì
áááááááááááááááanΣ system.
.paèLIBRAR┘ FIL┼ MANIPULATION:é Librarie≤ arσ ß methoΣ oµ combininτ ß ì
numbe≥ oµ file≤ int∩ ß singlσ filσ iε sucΦ ß wa∙ tha⌠ eacΦ membe≥ ì
filσ ácaε ábσ discretel∙ accessed« Advantage≤ oµ álibrarie≤ áarσ ì
tha⌠ áonl∙ onσ director∙ entr∙ i≤ needeΣ fo≥ thσ álibrar∙ árathe≥ ì
thaε onσ fo≥ eacΦ file¼ anΣ onl∙ ß maximuφ oµ 12╖ byte≤ pe≥ áfilσ ì
i≤ áwasteΣ ácompareΣ t∩ severa∞ thousanΣ byte≤ wasteΣ áfo≥ ásmal∞ ì
file≤ oε largσ harΣ disks.
Thesσ ároutine≤ providσ ß standarΣ wa∙ t∩ acces≤ file≤ ácontaineΣ ì
iε libraries« Acces≤ t∩ librar∙ file≤ i≤ viß ß librar∙ utility
descriptor which is a block of memory organized as:
LUD║ DEFS 2 ; length of lbr directory (set by LUxx)
DEFS 2 ; next block of curr file (set by LUxx)
DEFS 2 ; # of remaining blks in file (by LUxx)
LUFIL: DEFS 11 ; name of current file (set by LUOPEN)
LUFCB: DEFS 36 ; FCB of library (Fn.Ft set by user)
Multiple Libraries may be accessed by using several LUD's.
Routine║ LUINIT
Function║ Initialize file for library file manipulation
Entry: D┼ á╜ pointe≥ t∩ aε LU─ containinτ FC┬ áanΣ áothe≥ ì
áááááááááááááááinf∩ áDrivσ áanΣ use≥ oµ librar∙ mus⌠ áalread∙ ábσ ì
áááááááááááááááset.
Exit: A = 0, zero flag set (Z) if no error
A = error code, zero reset (NZ) if error is:
1 = file not found
2 = file empty
3 = library file format error
Affected: AF¼ DMA address is set to 80hH by this routine
Usage: Mus⌠ ábσ calleΣ fo≥ eacΦ LU─ beforσ i⌠ i≤ useΣ át∩ ì
áááááááááááááááacces≤ an∙ oµ thσ othe≥ routine≤ iε thi≤ ásection« ì
áááááááááááááááYo⌡ mus⌠ insurσ tha⌠ byte≤ ▒-1▒ iε thσ FC┬ sectioε ì
áááááááááááááááoµ áthσ LU─ arσ se⌠ witΦ thσ desireΣ librar∙ ánamσ ì
áááááááááááááááanΣ typσ beforσ callinτ LUINIT.
Routine║ LUDIR
Function║ Return directory list for library
Entry: DE = address of a library utility descriptor (LUD)
HL = address of ambiguous 11-char filename and type
BC = pointer to start of memory buffer
Drivσ anΣ use≥ oµ librar∙ mus⌠ alread∙ bσ set.
Exit: A = 0, zero flag set (Z) if operation OK
A <> 0, zero flag reset (NZ) if TPA overflow
Affected: AF¼ DMA address is set to 80h by this routine
Usage: Locate≤ áal∞ file≤ iε ß librar∙ matchinτ ß áspeciì
áááááááááááááááfieΣ ambiguou≤ o≥ noε-ambiguou≤ filenamσ anΣ type« ì
áááááááááááááááIµ áal∞ questioε mark≤ o≥ space≤ arσ specΘfied¼ áß ì
áááááááááááááááfilσ witΦ al∞ space≤ iε namσ anΣ typσ field≤ áwil∞ ì
ááááááááááááááábσ returned« File≤ arσ listeΣ iε 1╖-bytσ áentrie≤ ì
áááááááááááááááorganizeΣ as:
DEF┬ 'FILENAMEº ; 11-char filename
DEF┬ 'TYPº ╗ │-cha≥ filetype
DEFW START_IDX ; index of file start
DEFW LENGTH ; # of 128-byte blocks in fileè DEFW FILE_CRC ; CRC of file
Routine║ LUOPEN
Function║ Open a library file for access
Entry: DE = address of a library utility descriptor (LUD)
HL = pointer to filename and type
Drive and user of library must already be set
Exit: A = 0, zero flag set (Z) if open OK
A <> 0, zero flag reset (NZ) if file not found
Affected: AF¼ DM┴ addres≤ i≤ se⌠ t∩ 80Φ b∙ thi≤ routine
Usage: Open≤ áß filσ iε ß librar∙ fo≥ acces≤ áb∙ áLUREAD« ì
áááááááááááááááThσ áfilenamσ anΣ typσ addresseΣ b∙ H╠ ma∙ bσ áamì
ááááááááááááááábiguou≤ iε whicΦ casσ thσ firs⌠ filσ iε thσ libraì
ááááááááááááááár∙ matchinτ thσ specificatioε wil∞ bσ opened« Thσ ì
áááááááááááááááexac⌠ ánamσ áma∙ bσ determineΣ áb∙ áexamininτ áthσ ì
ááááááááááááááácurren⌠ filσ Namσ sectioε oµ thσ LU─ afte≥ callinτ ì
áááááááááááááááLUOPEN.
Routine║ LUCLOSE
Function║ Close a library file
Entry: DE = points to library utility descriptor
Exit: None
Affected║ None
Usage: Zero≤ thσ inde° anΣ lengtΦ field≤ oµ thσ LUD¼ ábu⌠ ì
ááááááááááááááádoe≤ ánothinτ elsσ sincσ n∩ closσ i≤ needeΣ áoε áß ì
áááááááááááááááfilσ whicΦ i≤ onl∙ accesseΣ fo≥ reading.
Routine║ LUREAD
Function║ Read record from a file in a library
Entry: DE = address of a library utility descriptor (LUD)
Drive and user of library must already be set
Exit: A = 0, zero flag set (Z) if read OK
A <> 0, zero flag reset (NZ) if end-of-file
Affected: AF
Usage: Ma∙ ábσ áuseΣ iε thσ samσ manne≥ a≤ áothe≥ áSYSLI┬ ì
ááááááááááááááároutine≤ át∩ reaΣ ß singlσ 12╕-bytσ recorΣ t∩ áthσ ì
ááááááááááááááácurren⌠ DM┴ address« Thσ curren⌠ recorΣ anΣ ánumì
ááááááááááááááábe≥ áoµ árecord≤ remaininτ field≤ oµ thσ áLU─ áarσ ì
áááááááááááááááupdateΣ b∙ eacΦ cal∞ t∩ LUREAD.
FILENAME STRING PARSER:
Routine║ FNAME
Function║ Filename string parser
Entry: HL = pointer to target string ending with delimiter
DE = pointer to a 36-byte long FCB
Exit: ┬ ╜ disk (drive A=1..P=16, 0FFΦ=no disk specified)
├ ╜ user (0..31, '?'=all users, 0FFh=no user spec)
HL = pointer to the character which ended the scan
A <> 0, zero flag clear (NZ) if string parsed OK
A = 0, zero set (Z) if invalid disk or user
Affected: AF¼ BC¼ HL
Usage: Parse≤ ß strinτ t∩ ß specifieΣ FCB¼ anΣ put≤ ádisδ ì
áááááááááááááááanΣ áuse≥ t∩ registers« Thσ strinτ i≤ assumeΣ át∩ ì
ááááááááááááááábσ iε form:è ü DU:FILENAME.TYP
wherσ áan∙ par⌠ oµ thσ specificatioε i≤ áoptional« ì
áááááááááááááááI⌠ clear≤ al∞ byte≤ oµ thσ FC┬ t∩ zer∩ excep⌠ áfo≥ ì
áááááááááááááááthσ áFε (filename⌐ anΣ F⌠ (filetype⌐ field≤ áwhicΦ ì
áááááááááááááááarσ áinitializeΣ át∩ ávalue≤ áextracteΣ áfroφ áthσ ì
ááááááááááááááástring¼ o≥ space≤ iµ absent.
Thσ strinτ pointeΣ t∩ b∙ H╠ i≤ no⌠ ß áconventiona∞ ì
ááááááááááááááástrinτ áiε áthσ sensσ oµ thσ res⌠ áoµ áthσ áSYSLI┬ ì
ááááááááááááááároutines« á I⌠ ái≤ endeΣ b∙ an∙ oµ áthσ áfollowinτ ì
ááááááááááááááádelimiters¼ a≤ opposeΣ b∙ simpl∙ alway≤ beinτ te≥ì
áááááááááááááááminateΣ áb∙ áß binar∙ zero« Thσ ádelimiter≤ áare║ ì
ááááááááááááááá<NUL>¼ <SP>¼ "="¼ "_"¼ ";"¼ ","¼ "<"¼ ">"
Examples║ TEST.TXT ╜ FN=TEXT, FT=TXT, B=0FFh, C=0FFh
A:T = FN=T, FT=<Spaces>, B=1, C=0FFh
5:T = FN=T, FT=<Spaces>, B=0FFh, C=5
C10:X.Y = FN=X, FT=Y, B=3, C=10
FIL┼ CONTRO╠ BLOC╦ INITIALIZTION:
Routine║ INITFCB
Function║ FCB initialization
Entry: DE = pointer to 36-byte FCB buffer
Exit: None
Affected: None
Usage: ┴ ágenera∞ purposσ applicatioε t∩ clea≥ al∞ ábyte≤ ì
áááááááááááááááiε aε FC┬ t∩ zer∩ excep⌠ fo≥ thσ filenamσ anΣ typσ ì
áááááááááááááááfields« á Usinτ áINITFC┬ t∩ preparσ FCB≤ áfo≥ áusσ ì
ááááááááááááááádestroy≤ an∙ drivσ specificatioε iε thσ firs⌠ bytσ ì
áááááááááááááááoµ áthσ FCB« I⌠ wil∞ bσ se⌠ t∩ zer∩ áequatinτ át∩ ì
áááááááááááááááthσ currentl∙ loggeΣ drive.
DISK/USE╥ áMANIPULATIO╬ ROUTINES:é Thi≤ i≤ ß se⌠ oµ si° ároutine≤ ì
whicΦ áallo≈ áthσ use≥ t∩ readil∙ movσ arounΣ betweeε ádisk≤ áanΣ ì
use≥ Areas« Thesσ routine≤ are:
GUA -¡ return the current user
SUA -¡ log into a specified user area
RETUD -- return the current disδ anΣ user
LOGUD -- log into a specified disδ anΣ user
PUTUD -- save away the current disδ anΣ user
GETUD -- restore the disδ anΣ user saved by PUTUD
GU┴ anΣ SU┴ arσ t∩ bσ useΣ t∩ finΣ ou⌠ wha⌠ use≥ areß thσ prograφ ì
i≤ áiε (GUA⌐ anΣ t∩ ente≥ ß specifiπ use≥ areß (SUA)« Fo≥ áexamì
ple:
CAL╠ GUA ; find out current user
PUSH AF ; save it
[move around on other user areas]
POP AF ; get current user
CALL SUA ; log into user
GU┴ áanΣ áSU┴ arσ usefu∞ iε conjunctioε witΦ thσ áautomatiπ ádisδ ì
logginτ áfeaturσ oµ CP/M¼ wherσ thσ firs⌠ bytσ oµ thσ áFC┬ áindiì
cate≤ ß disδ t∩ autoloτ (0=default¼ 1=A¼ 2=B¼ etc.).
RETU─ áanΣ LOGU─ arσ t∩ bσ useΣ t∩ finΣ ou⌠ wherσ thσ prograφ ái≤ ìè(RETUD⌐ anΣ t∩ ente≥ ß specifiπ disδ anΣ use≥ areß (LOGUD)« á Fo≥ ì
example:
CALL RETUD ; find out where we are
PUSH BC ; save disk/user
[move around on disks/users]
POP BC ; get disk/user
CALL LOGUD ; log into disk/user
PUTUD and GETUD are designed to be used as a place marker and ì
return combination. They are intended to be used in such code ì
sequences as the following:
CALL PUTUD ; mark current location
[move around on disks/users]
CALL GETUD ; return to marked location
Sincσ PUTU─ store≤ thσ value≤ iε ß singlσ leve∞ buffer¼ ámultiplσ ì
call≤ át∩ áPUTU─ shoulΣ bσ avoideΣ sincσ GETU─ wil∞ árestorσ áthσ ì
las⌠ disk/use≥ saveΣ b∙ PUTUD.
Routine║ GUA
Function║ Return current user area
Entry: None
Exit: A = user area (0-31)
Affected: AF
Usage: Return≤ thσ currentl∙ loggeΣ use≥ area« N∩ áerro≥ ì
ááááááááááááááácode≤ exis⌠ witΦ thi≤ function.
Routine: SUA
Function║ Set current user area
Entry: A = user area (0-31)
Exit: None
Affected: None
Usage: Log≤ áint∩ thσ use≥ areß representeΣ b∙ áthσ álo≈-ì
áááááááááááááááorde≥ á╡ bit≤ oµ thσ supplieΣ valuσ (valuσ á░-31)« ì
áááááááááááááááN∩ erro≥ code≤ exis⌠ witΦ thi≤ function.
Routine║ RETUD
Function║ Return the current disδ anΣ user
Entry: None
Exit: ┬ ╜ disk (drive A=0), ├ ╜ user (0..31)
Affected: BC
Usage: Return≤ thσ currentl∙ loggeΣ use≥ numbe≥ anΣ ácurì
ááááááááááááááárentl∙ loggeΣ drivσ iε ß singlσ operation.
Routine║ LOGUD
Function║ Log into a disδ anΣ user
Entry: ┬ ╜ disk (drive A=0), ├ ╜ user (0..31)
Exit: None
Affected: None
Usage: Log≤ áiε ß specifieΣ drivσ anΣ set≤ thσ áspecifieΣ ì
áááááááááááááááuse≥ areß t∩ curren⌠ iε ß singlσ operation.
.paè Routine║ PUTUD
Function║ Save away disδ anΣ user
Entry: None
Exit: None
Affected: None
Usage: Commonl∙ áuseΣ nea≥ thσ beginninτ oµ ß prograφ áo≥ ì
ááááááááááááááároutinσ t∩ savσ thσ curren⌠ use≥ anΣ disδ ánumber≤ ì
áááááááááááááááfo≥ árestoratioε áupoε prograφ áo≥ ároutinσ áexit« ì
áááááááááááááááPUTU─ ásave≤ thσ curren⌠ disδ anΣ use≥ iε ß áloca∞ ì
ááááááááááááááábuffer¼ whilσ GETU─ restore≤ thesσ saveΣ ásetting≤ ì
ááááááááááááááát∩ áthσ currentl∙ loggeΣ BDO╙ values« Thσ ábuffe≥ ì
áááááááááááááááuseΣ b∙ PUTU─ anΣ GETU─ i≤ interna∞ anΣ no⌠ availì
áááááááááááááááablσ fo≥ genera∞ use.
Routine: GETUD
Function║ Restore disδ anΣ user saved by PUTUD
Entry: None
Exit: None
Affected: None
Usage: Commonl∙ áuseΣ nea≥ thσ beginninτ oµ ß prograφ áo≥ ì
ááááááááááááááároutinσ t∩ savσ thσ curren⌠ use≥ anΣ disδ ánumber≤ ì
áááááááááááááááfo≥ árestoratioε áupoε prograφ áo≥ ároutinσ áexit« ì
áááááááááááááááPUTU─ ásave≤ thσ curren⌠ disδ anΣ use≥ iε ß áloca∞ ì
ááááááááááááááábuffer¼ whilσ GETU─ restore≤ thesσ saveΣ ásetting≤ ì
ááááááááááááááát∩ áthσ currentl∙ loggeΣ BDO╙ values« Thσ ábuffe≥ ì
áááááááááááááááuseΣ b∙ PUTU─ anΣ GETU─ i≤ interna∞ anΣ no⌠ availì
áááááááááááááááablσ fo≥ genera∞ use.
Routine║ SETDMA
Function║ Set the BDOS DMA transfer address
Entry: HL = start of DMA buffer to set
Exit: None
Affected: None
Usage: Set≤ thσ DM┴ transfe≥ addres≤ withiε thσ BDO╙ áanΣ ì
áááááááááááááááBIO╙ t∩ thσ specifieΣ address« Sincσ n∩ register≤ ì
áááááááááááááááarσ destroyeΣ b∙ thi≤ routine¼ i⌠ i≤ suitablσ áfo≥ ì
áááááááááááááááusσ withiε loop≤ iε programs.
NUMERIC STRING EVALUATION:
Routine║ EVAL
Function║ General-purpose numeric string evaluation
Entry: HL = address of first byte of string to convert
Exit: H╠ á╜ point≤ t∩ characte≥ afte≥ áconverteΣ ástrinτ ì
ááááááááááááááá(o≥ characte≥ causinτ erro≥ iµ erro≥ flaτ set)
DE = 16-bit binary value of string
A = E value, carry flag clear (NC) if OK
Carry flag set (C) if error in string
Affected: AF¼ DE¼ HL
Usage: Convert≤ áthσ ácharacte≥ strinτ pointeΣ t∩ áb∙ áH╠ ì
áááááááááááááááint∩ áß 1╢-bi⌠ binar∙ representation« á EVA╠ áperì
áááááááááááááááform≤ thσ conversioε unti∞ ß noε-hexadecima∞ charì
áááááááááááááááacte≥ ái≤ encountered¼ a⌠ whicΦ timσ i⌠ álook≤ áa⌠ ì
áááááááááááááááthσ álas⌠ characte≥ anΣ thσ previou≤ characte≥ át∩ ì
ááááááááááááááádeterminσ iµ thσ strinτ i≤ representinτ ß ábinary¼ ìèáááááááááááááááoctal¼ ádecimal¼ áo≥ áhexadecima∞ ánumber« á Inpu⌠ ì
ááááááááááááááástrinτ ácharacter≤ ma∙ bσ uppercasσ o≥ álowercase« ì
áááááááááááááááValiΣ inpu⌠ strinτ format≤ are:
binar∙ strinτ¼ wherσ b=░ o≥ b=1
bbbbbbbbbbbbbbbbB
decima∞ string¼ wherσ ░ <╜ ⌠ <= ╣
ttttt
tttttD
hexadecima∞ string¼ wherσ ░ <╜ Φ <╜ F
hhhhH
hhhhX
octa∞ string¼ wherσ ░ <╜ ∩ <╜ 7
oooooooO
oooooooQ
Routine║ EVAL16
Function║ Hexadecimal string evaluation
Entry: H╠ ╜ addres≤ oµ firs⌠ characte≥ oµ strinτ t∩ áconì
ááááááááááááááávert
Exit: HL = points to character terminating conversion
DE = contains the 16-bit binary value of string
A = E value
Affected: AF¼ DE¼ HL
Usage: Convert≤ áthσ strinτ oµ ASCI╔ hexadecima∞ ácharacì
áááááááááááááááter≤ pointeΣ t∩ b∙ H╠ int∩ ß 1╢-bi⌠ binar∙ ávalue« ì
áááááááááááááááConversioε progresse≤ unti∞ aε invaliΣ hexadecima∞ ì
ááááááááááááááádigi⌠ (░-9¼ ┴-F⌐ i≤ encountered.
Routine║ EVAL10
Function║ Decimal string evaluation
Entry: HL = address of first character of string to convert
Exit: HL = points to character terminating conversion
DE = contains the 16-bit binary value of string
A = E value
Affected: AF¼ DE¼ HL
Usage: Convert≤ áthσ strinτ oµ ASCI╔ ádecima∞ ácha≥acter≤ ì
ááááááááááááááápointeΣ át∩ áb∙ áH╠ int∩ ß á1╢-bi⌠ ábinar∙ áva∞ue« ì
áááááááááááááááConversioε áprogresse≤ áunti∞ aε áinvaliΣ ádecΘma∞ ì
ááááááááááááááádigi⌠ (░-9⌐ i≤ encountered.
Routine║ EVAL8
Function║ Octal string evaluation
Entry: HL = address of first character of string to convert
Exit: HL = points to character terminating conversion
DE = contains the 16-bit binary value of string
A = E value
Affected: AF¼ DE¼ HL
Usage: Convert≤ áthσ ástrinτ oµ áASCI╔ áocta∞ ácharacter≤ ì
ááááááááááááááápointeΣ át∩ áb∙ áH╠ int∩ ß á1╢-bi⌠ ábinar∙ ávalue« ì
áááááááááááááááConversioε progresse≤ unti∞ aε invaliΣ octa∞ digi⌠ ì
ááááááááááááááá(░-7⌐ i≤ encountered.
.paè Routine║ EVAL2
Function║ Binary string evaluation
Entry: HL = address of first character of string to convert
Exit: HL = points to character terminating conversion
DE = contains the 16-bit binary value of string
A = E value
Affected: AF¼ DE¼ HL
Usage: Convert≤ áthσ ástrinτ oµ ASCI╔ ábinar∙ ácharacter≤ ì
ááááááááááááááápointeΣ át∩ áb∙ áH╠ int∩ ß á1╢-bi⌠ ábinar∙ ávalue« ì
áááááááááááááááConversioε áprogresse≤ áunti∞ áaε áinvaliΣ ábinar∙ ì
ááááááááááááááádigi⌠ (░-1⌐ i≤ encountered.
TH┼ áL¼ M¼ P¼ AN─ ╙ NUMERI├ OUTPU╘ ROUTINES:é Thσ numeriπ áoutpu⌠ ì
routine≤ describeΣ herσ arσ useΣ t∩ outpu⌠ eithe≥ thσ H╠ registe≥ ì
pai≥ o≥ thσ ┴ registe≥ iε ß variet∙ oµ forms« Thesσ form≤ arσ a≤ ì
hexadecima∞ characters¼ a≤ decima∞ characters¼ a≤ decima∞ characì
ter≤ witΦ leadinτ spaces¼ anΣ a≤ decima∞ character≤ witΦ n∩ leadì
inτ zeroe≤ o≥ spaces.
Iε addition¼ eacΦ oµ thesσ routine≤ ha≤ ß prefi° t∩ thei≥ ánames║ ì
L¼ áM¼ P¼ o≥ S« Thesσ prefixe≤ indicatσ thσ outpu⌠ ádestination« ì
╠ áindicate≤ thσ LS╘ devicσ (o≥ printer)¼ ═ indicate≤ ámemory¼ á╨ ì
indicate≤ áthσ áconsolσ á(prin⌠ thσ output)¼ anΣ á╙ áindicate≤ áß ì
switcheΣ outpu⌠ t∩ nothing¼ thσ console¼ thσ printer¼ o≥ both.
Fo≥ áexample¼ áPAD├ send≤ ┴ a≤ decima∞ ácharacter≤ áwitΦ áleadinτ ì
space≤ át∩ thσ console¼ whilσ LAD├ send≤ ┴ a≤ decima∞ ácharacter≤ ì
witΦ leadinτ space≤ t∩ thσ printer.
Thσ á╙-serie≤ oµ routine≤ i≤ differen⌠ froφ thσ othe≥ áserie≤ áiε ì
tha⌠ áthσ ╙-serie≤ use≤ aε externa∞ datß bytσ t∩ determinσ áwherσ ì
thσ áoutpu⌠ i≤ t∩ bσ routed« Thi≤ bytσ i≤ referreΣ t∩ a≤ áSCTLF╠ ì
(╙ áContro∞ Flag)¼ anΣ it≤ switchinτ functioε i≤ áillustrateΣ áiε ì
thσ followinτ table.
SCTLFL:
binary hex outputs to
00000000b 00h nothing
00000001b 01h console
10000000b 80h printer
10000001b 81h console and printer
Iµ yo⌡ d∩ no⌠ initializσ thσ SCTLF╠ variablσ beforσ usinτ thσ á╙-ì
routine¼ outpu⌠ wil∞ g∩ t∩ thσ consolσ (thσ defaul⌠ i≤ 01h).
An example of code using S-routines is:
EX╘ SCTLFL,SADC ; SCTLFL flag, SADC routine
...
LD A,81H ; enable printer and console
LD (SCTLFL),A
...
LD A,32 ; print number 32
CALL SADC
...
LD A,80H ; enable printer onlyè LD (SCTLFL),A
...
LD A,150 ; print number 150
CALL SADC
...
SAMPL┼ áNUMERI├ áOUTPUTS:é Thσ followinτ átable≤ áillustratσ áho≈ ì
value≤ áwil∞ bσ outpu⌠ b∙ thσ variou≤ routines« á Thσ áunderscorσ ì
characte≥ (_⌐ indicate≤ ß space.
Value xA2HC xA3DC xADC xAFDC
0 00 000 __0 0
10 0A 010 _10 10
255 FF 255 255 255
Value xHL4HC xHL5DC xHLDC xHLFDC
0 0000 00000 ____0 0
10 000A 00010 ___10 10
100 0064 00100 __100 100
1000 03E8 01000 _1000 1000
65535 FFFF 65535 65535 65535
Routines║ LA2HC, PA2HC, SA2HC
Function║ Print A as two hex characters
Entry: A = value to be converted and printed
Exit: None
Affected: None
Usage: Print≤ áß ábytσ a≤ tw∩ hexidecima∞ ácharacter≤ áoε ì
áááááááááááááááLST║ á(LA2HC)¼ CON║ (PA2HC)¼ o≥ switcheΣ áoutpu⌠ ì
ááááááááááááááá(SA2HC).
Routine: MA2HC
Function║ Store A as two hex characters in memory
Entry: A = value to be converted and stored
DE = pointer to start of 2-byte buffer
Exit: DE = points to byte after string
Affected: DE
Usage: Store≤ áß ábytσ iε memor∙ a≤ tw∩ á(2⌐ áhexadecima∞ ì
ááááááááááááááácharacters.
Routines║ LA3DC, PA3DC, SA3DC
Function║ Print A as three decimal digits
Entry: A = binary value to convert and print
Exit: None
Affected: None
Usage: Print≤ ß bytσ (0..255⌐ a≤ threσ (3⌐ decima∞ ácha≥ì
áááááááááááááááacter≤ áiε ß fixeΣ lengtΦ spacσ oε áLST║ á(LA3DC)¼ ì
áááááááááááááááCON║ (PA3DC)¼ o≥ switcheΣ outpu⌠ (SA3DC).
.paè Routine║ MA3DC
Function║ Store A as three decimal digits in memory
Entry: A = binary value to convert and store
DE = pointer to 3-byte buffer
Exit: DE = points to the byte after the buffer
Affected: DE
Usage: Store≤ ß bytσ iε memor∙ a≤ threσ (3⌐ decima∞ ádigì
áááááááááááááááits.
Routines║ LADC, PADC, SADC
Function║ Print byte as up to three decimal digits
Entry: A = binary value to convert and print
Exit: None
Affected: None
Usage: Print≤ áß ábytσ iε variablσ áforma⌠ áwitΦ áleadinτ ì
áááááááááááááááspace≤ á(righ⌠ ájustified⌐ oε áLST║ á(LADC)¼ áCON║ ì
ááááááááááááááá(PADC)¼ o≥ switcheΣ outpu⌠ (SADC).
Routine: MADC
Function║ Store a byte as up to three digits in memory
Entry: A = binary value to convert and store
DE = pointer to 3-byte memory buffer
Exit: DE = points to byte after the buffer
Affected: DE
Usage: Store≤ ß bytσ iε memor∙ iε ß fixeΣ threσ characte≥ ì
ááááááááááááááábuffe≥ a≤ u≡ t∩ threσ (3⌐ decima∞ character≤ áwitΦ ì
áááááááááááááááleadinτ spaces.
Routines║ LAFDC, PAFDC, SAFDC
Function║ Print A as 1 to 3 digits (variable)
Entry: A = binary value to be converted and printed
Exit: None
Affected: None
Usage: Print≤ áß bytσ a≤ onσ t∩ threσ decima∞ ácharacter≤ ì
áááááááááááááááwitΦ án∩ áleadinτ áspace≤ oε áLST║ á(LAFDC)¼ áCON║ ì
ááááááááááááááá(PAFDC)¼ o≥ switcheΣ outpu⌠ (SAFDC).
Routine: MAFDC
Function║ Store A as 1 to 3 digits (variable) in memory
Entry: A = value to be converted and stored
DE = pointer to a 3-byte buffer
Exit: DE = points to the byte after the last one saved
Affected: DE
Usage: Store≤ ß bytσ a≤ u≡ t∩ threσ (3⌐ decima∞ digit≤ iε ì
áááááááááááááááß │-bytσ memor∙ buffer.
Routines║ LHL4HC, PHL4HC, SHL4HC
Function║ Print 16-bit value as four hexadecimal chars
Entry: HL = 16-bit value to print
Exit: None
Affected: None
Usage: Print≤ áH╠ a≤ fou≥ (4⌐ hexadecima∞ ácharacter≤ áoε ì
áááááááááááááááLST║ á(LHL4HC)¼ CON║ (PHL4HC)¼ o≥ switcheΣ áoutpu⌠ ì
ááááááááááááááá(SHL4HC).
.paè Routine: MHL4HC
Function║ Save 16-bit value as four hexadecimal characters
Entry: HL = 16-bit value to convert and save
DE = pointer to 4-byte buffer
Exit: DE = points to byte after buffer
Affected: DE
Usage: Store≤ H╠ a≤ fou≥ (4⌐ hexadecima∞ character≤ iε áß ì
ááááááááááááááá┤-bytσ memor∙ buffer.
Routine║ LHL5DC, PHL5DC, SHL5DC
Function║ Print 16-bit value as 5 decimal characters
Entry: HL = 16-bit value to print
Exit: None
Affected: None
Usage: Print≤ áH╠ a≤ fivσ (5⌐ decima∞ character≤ oε áLST║ ì
ááááááááááááááá(LHL5DC)¼ ááCON║ á(PHL5DC)¼ áo≥ áswitcheΣ ááoutpu⌠ ì
ááááááááááááááá(SHL5DC).
Routine: MHL5DC
Function║ Save 16-bit value as 5 decimal characters
Entry: HL = value to be converted and stored
DE = pointer to 5-byte buffer
Exit: DE = points to byte after buffer
Affected: DE
Usage: Store≤ áH╠ a≤ fivσ (5⌐ decima∞ character≤ iε ß á╡-ì
ááááááááááááááábytσ memor∙ buffer.
Routine║ LHLDC, PHLDC, SHLDC
Function║ Print 16-bit value as 1-5 decimal digits
Entry: HL = value to be printed
Exit: None
Affected: None
Usage: Print≤ áH╠ áa≤ áonσ t∩ fivσ ádecima∞ ádigit≤ áwitΦ ì
áááááááááááááááleadinτ áspace≤ oε LST║ (LHLDC)¼ CON║ (PHLDC)¼ áo≥ ì
áááááááááááááááswitcheΣ outpu⌠ (SHLDC).
Routine: MHLDC
Function║ Store 16-bit value as 1-5 decimal digits in memory
Entry: HL = value to convert and store
DE = pointer to five byte memory buffer
Exit: DE = points to byte after buffer
Affected: DE
Usage: Convert≤ áanΣ ástore≤ H╠ a≤ onσ át∩ áfivσ ádecima∞ ì
ááááááááááááááácharacter≤ witΦ leadinτ space≤ iε ß ╡-bytσ ámemor∙ ì
ááááááááááááááábuffer.
Routine║ LHLFDC, PHLFDC, SHLFDC
Function║ Print HL as 1 to 5 decimal digits
Entry: HL = value to be printed
Exit: None
Affected: None
Usage: Print≤ áH╠ a≤ onσ t∩ fivσ decima∞ digit≤ áwitΦ án∩ ì
áááááááááááááááleadinτ space≤ oε LST║ (LHLFDC)¼ CON║ (PHLFDC)¼ o≥ ì
áááááááááááááááswitcheΣ outpu⌠ (SHLFDC).
.paè Routine: MHLFDC
Function║ Store HL as 1 to 5 decimal digits in memory
Entry: HL = value to convert and store
DE = pointer to 5-byte memory buffer
Exit: DE = points to byte after last one stored
Affected: DE
Usage: Convert≤ áanΣ ástore≤ H╠ a≤ onσ át∩ áfivσ ádecima∞ ì
ááááááááááááááádigit≤ iε ß ╡-bytσ buffer.
INPU╘ áLIN┼ áEDITORS:é Aε inpu⌠ linσ edito≥ i≤ useΣ t∩ áaccep⌠ áß ì
linσ áoµ tex⌠ froφ thσ terminal¼ allowinτ yo⌡ t∩ áissuσ ácommand≤ ì
likσ ábackspacσ anΣ ^╪ (erasσ al∞ oµ linσ typeΣ s∩ far⌐ át∩ áedi⌠ ì
tex⌠ a≤ yo⌡ ente≥ it« Oncσ thσ tex⌠ ha≤ beeε entered¼ thσ áinpu⌠ ì
linσ edito≥ return≤ t∩ thσ callinτ prograφ witΦ you≥ tex⌠ ástoreΣ ì
iε ß buffer« Thi≤ tex⌠ i≤ terminateΣ b∙ ß binar∙ 0.
Tw∩ áoµ áthσ inpu⌠ linσ editor≤ iε SYSLI┬ usσ thσ áCP/═ áBDO╙ át∩ ì
providσ thσ linσ edito≥ function« The∙ mainl∙ servσ t∩ ápreservσ ì
thσ register≤ durinτ thσ functioε cal∞ anΣ t∩ storσ thσ terminatì
inτ zer∩ a⌠ thσ enΣ oµ thσ text« The∙ occup∙ les≤ spacσ thaε thσ ì
thirΣ inpu⌠ linσ editor¼ INLINE.
Thσ áthirΣ áinpu⌠ linσ editor¼ INLINE¼ i≤ useΣ wheε ásecurit∙ ái≤ ì
important« Unlikσ thσ othe≥ two¼ wheε typinτ ß ^├ t∩ INLINE¼ thσ ì
inpu⌠ álinσ edito≥ (anΣ callinτ program⌐ i≤ no⌠ aborteΣ anΣ áconì
tro∞ áreturneΣ át∩ áCP/M« Instead¼ thσ ^├ ácharacte≥ ái≤ ásimpl∙ ì
storeΣ áiε you≥ line« Also¼ unlikσ thσ othe≥ two¼ INLIN┼ caε ábσ ì
instructeΣ át∩ ech∩ o≥ no⌠ ech∩ thσ inpu⌠ characters« Thi≤ áfeaì
turσ ái≤ áusefu∞ áfo≥ program≤ whicΦ wan⌠ t∩ áinpu⌠ áß ápassword« ì
INLIN┼ ácaε bσ instructeΣ no⌠ t∩ ech∩ thσ password¼ bu⌠ ái⌠ áwil∞ ì
stil∞ providσ thσ linσ editinτ function≤ s∩ tha⌠ yo⌡ caε ácorrec⌠ ì
an∙ mistakes.
Routine║ BBLINE
Function║ BDOS-based line editor with internal buffer
Entry: A = 0 to not capitalize line
A <> 0 to capitalizσ line
Exit: HL = pointer to first character in the line
┴ á╜ numbe≥ oµ characters≤ iε thσ linσ á(excludinτ ì
áááááááááááááááendinτ zero)
Affected: AF¼ HL
Usage: BBLIN┼ provide≤ ß ver∙ convenien⌠ interfacσ t∩ thσ ì
áááááááááááááááBDO╙ fo≥ inpu⌠ linσ edito≥ functions« I⌠ contain≤ ì
áááááááááááááááaε áinterna∞ buffe≥ fo≥ storagσ oµ thσ inpu⌠ álinσ ì
ááááááááááááááá(20░ byte≤ allocated)¼ anΣ i⌠ return≤ ß pointe≥ t∩ ì
áááááááááááááááthσ firs⌠ bytσ oµ thσ linσ upoε return« Thσ álinσ ì
ááááááááááááááástoreΣ iε thi≤ buffe≥ i≤ terminateΣ b∙ ß NU╠ á(0)« ì
áááááááááááááááT∩ áusσ BBLINE¼ yo⌡ onl∙ neeΣ t∩ cal∞ i⌠ witΦ áthσ ì
ááááááááááááááácapitalizatioε flaτ se⌠ fo≥ thσ desireΣ action.
.paè Routine║ BLINE
Function║ BDOS-based line editor with user-supplied buffer
Entry: A = 0 to not capitalize line
A <> 0 to capitalizσ line
HL = pointer to first byte of user-supplied buffer
Exit: HL = pointer to first character in the line
┴ á╜ numbe≥ oµ character≤ iε thσ álinσ á(excludinτ ì
áááááááááááááááendinτ zero)
Affected: AF¼ HL
Usage: BLIN┼ áperform≤ áthσ ásamσ átypσ áoµ áfunctioε áa≤ ì
áááááááááááááááBBLINE¼ ábu⌠ doe≤ no⌠ contaiε aε interna∞ ábuffer« ì
áááááááááááááááYo⌡ áarσ expecteΣ t∩ providσ ß buffer¼ ástructureΣ ì
áááááááááááááááas:
SIZE║ DEF┬ ╗ sizσ oµ buffer
CCNT: DEF╙ 1
LINE: DEFS ╗ size of buffer + 1
T∩ áusσ áBLINE¼ cal∞ i⌠ witΦ thσ áaddres≤ áoµ áthσ ì
ááááááááááááááábuffe≥ (SIZ┼ iε thσ example)¼ anΣ thσ ácapitalizaì
ááááááááááááááátioε áflag« BLIN┼ return≤ ß pointe≥ t∩ thσ áfirs⌠ ì
ááááááááááááááábytσ áoµ áthσ linσ (LINE⌐ upoε return« á Thσ álinσ ì
ááááááááááááááástoreΣ iε thi≤ buffe≥ i≤ NU╠-terminated.
Routine║ INLINE
Function║ Independent input line editor
Entry: HL = pointer to input line buffer
A = echo flag (A=0 for no echo, A<>0 to echo input)
Exit: None
Affected: None
Usage: INLIN┼ essentiall∙ provide≤ al∞ oµ thσ conventioεì
áááááááááááááááa∞ áinpu⌠ linσ edito≥ functions« I⌠ ái≤ ásomewha⌠ ì
ááááááááááááááámorσ áflexiblσ áthaε áBLIN┼ anΣ áBBLINE¼ ábu⌠ áthσ ì
ááááááááááááááátradeofµ ái≤ tha⌠ INLIN┼ take≤ u≡ morσ space« á Iµ ì
ááááááááááááááásecurit∙ i≤ no⌠ required¼ yo⌡ shoulΣ usσ BLIN┼ áo≥ ì
áááááááááááááááBBLIN┼ áinsteaΣ oµ INLINE« Yo⌡ ma∙ edi⌠ thσ átex⌠ ì
áááááááááááááááa≤ yo⌡ typσ i⌠ witΦ thσ followinτ edito≥ commands:
ke∙ function
<BS> Deletσ previou≤ characte≥ anΣ ábacδ ì
ááááááááááááááááááááááááááááááu≡ cursor
<DEL> Delete previous character and echo it
<CR> Inpu⌠ ácomplete¼ returε t∩ ácallinτ ì
ááááááááááááááááááááááááááááááprogram
<LF> G∩ t∩ nex⌠ physica∞ line╗ addinτ áß ì
áááááááááááááááááááááááááááááá<CR><LF╛ t∩ buffer
<TAB> Movσ to next tab stop (every ╕ spaces)
^U Erasσ álinσ (clea≥ buffer⌐ anΣ áreì
áááááááááááááááááááááááááááááástar⌠ inpu⌠ (samσ a≤ ^X)
^X Erasσ álinσ (clea≥ buffer⌐ anΣ áreì
áááááááááááááááááááááááááááááástar⌠ inpu⌠ (samσ a≤ ^U)
^R Retype current line
^E G∩ át∩ nex⌠ physica∞ line╗ adΣ ánoì
ááááááááááááááááááááááááááááááthinτ t∩ buffer
Oε áexit¼ áthσ buffe≥ contain≤ áthσ átex⌠ áentereΣ ì
áááááááááááááááfolloweΣ b∙ ß <NUL╛ (binar∙ 0)╗ thσ <CR╛ typeΣ át∩ ì
áááááááááááááááenΣ thσ inpu⌠ i≤ no⌠ placeΣ iε thσ buffer.è
INLIN┼ offer≤ tw∩ feature≤ no⌠ founΣ iε BLIN┼ áanΣ ì
áááááááááááááááBBLINE« First¼ i⌠ canno⌠ bσ aborteΣ b∙ ß ^C╗ thi≤ ì
ááááááááááááááái≤ good¼ sincσ i⌠ caε bσ useΣ iε "secureó program≤ ì
áááááááááááááááwithou⌠ áfea≥ áoµ ábreakinτ ou⌠ áoµ áthσ áprogram« ì
áááááááááááááááSecond¼ ái⌠ ácaε bσ madσ t∩ ech∩ o≥ no⌠ áech∩ áthσ ì
áááááááááááááááinput╗ thi≤ provide≤ somσ protectioε fo≥ inputtinτ ì
ááááááááááááááásensitivσ information¼ sucΦ a≤ passwords.
┴ áBE╠ ácharacte≥ (bee≡ oε console⌐ i≤ áoutpu⌠ áiµ ì
áááááááááááááááattemp⌠ ái≤ madσ t∩ deletσ character≤ witΦ áB╙ áo≥ ì
áááááááááááááááDE╠ beforσ thσ beginninτ oµ thσ line« N∩ limi⌠ o≥ ì
áááááááááááááááerro≥ ácheckinτ i≤ madσ oε thσ sizσ oµ áthσ áinpu⌠ ì
ááááááááááááááálinσ ábuffer¼ s∩ yo⌡ shoulΣ madσ thσ buffe≥ áarbiì
ááááááááááááááátraril∙ álargσ t∩ avoiΣ buffe≥ overflow« á ┴ áhasΦ ì
ááááááááááááááámarδ (#⌐ i≤ printeΣ iε responsσ t∩ ^R¼ ^U¼ anΣ ^X.
STRIN╟ áAN─ SWITCHE─ OUTPUT:é Thσ switcheΣ outpu⌠ serie≤ oµ árouì
tine≤ ái≤ ádifferen⌠ froφ thσ othe≥ serie≤ iε tha⌠ áthσ áswitcheΣ ì
outpu⌠ serie≤ use≤ ß globa∞ datß bytσ (SCTLF╠ ¡¡ ╙ Coεtro∞ áFlag⌐ ì
t∩ ádeterminσ áwherσ thσ outpu⌠ i≤ t∩ bσ routed« á It≤ áswitchinτ ì
function≤ are:
SCTLFL:
binary hex outputs to
00000000Γ 00Φ nothing
00000001b 01h console
10000000b 80h printer
10000001b 81h console and printer
Iµ áyo⌡ d∩ no⌠ initializσ thσ SCTLF╠ variablσ beforσ usinτ aε á╙-ì
routine¼ áoutpu⌠ wil∞ g∩ t∩ thσ consolσ (defaul⌠ valuσ oµ áSCTLF╠ ì
i≤ 01h).
An example of code using S-routines is:
EX╘ SCTLFL,SADC,SOUT ; declare routines/value
...
LD A,81H ; enable printer and console
LD (SCTLFL),A
...
LD A,32 ; print number 32
CALL SADC
...
LD A,80H ; enable printer only
LD (SCTLFL),A
...
LD A,'D' ; print letter "D"
CALL SOUT
...
.paè Routines║ PRINT¼ EPRINT¼ LPRINT¼ SPRINT
Function: PRIN╘ print≤ t∩ consolσ interpretinτ contro∞ charì
áááááááááááááááacters¼ áEPRIN╘ print≤ t∩ consolσ áonl∙ áexpandinτ ì
ááááááááááááááátabs¼ áLPRIN╘ print≤ t∩ printe≥ interpretinτ áconì
ááááááááááááááátro∞ ácharacters¼ SPRIN╘ print≤ t∩ switcheΣ á(conì
ááááááááááááááásole/printer⌐ interpretinτ contro∞ characters
Entry: stack ╜ points to NUL-terminated (binary 0) string
Exit: None (execution resumes at byte after ending NUL)
Affected: None
Usage: Mos⌠ áofteε useΣ fo≥ "inlineó áprin⌠ árequirement≤ ì
áááááááááááááááwherσ áthσ átex⌠ string≤ arσ embeddeΣ áwithiε áthσ ì
áááááááááááááááexecutablσ ácode« WitΦ thσ exceptioε áoµ áEPRINT¼ ì
ááááááááááááááácontro∞ character≤ othe≥ thaε TAB¼ BS¼ CR¼ LF¼ anΣ ì
áááááááááááááááBE╠ arσ outpu⌠ a≤ "^có sequences« (Seσ ácharacte≥ ì
áááááááááááááááoutpu⌠ routines.)
Example:
EX╘ PRINT ; declare the routine
... ; ..preceeding code
CALL PRINT ; print the following string
DEFB 'Hello World',0
... ; execution resumes here
Routines║ PSTR¼ EPSTR¼ LPSTR¼ SPSTR
Function: PST╥ print≤ t∩ consolσ interpretinτ contro∞ ácharì
áááááááááááááááacters¼ áEPST╥ áprint≤ t∩ consolσ áonl∙ áexpandinτ ì
ááááááááááááááátabs¼ LPST╥ print≤ t∩ printe≥ interpretinτ contro∞ ì
ááááááááááááááácharacters¼ áSPST╥ print≤ t∩ áswitcheΣ á(console/ì
áááááááááááááááprinter⌐ interpretinτ contro∞ characters
Entry: HL = pointer to NUL-terminated (binary 0) string
Exit: HL = points to byte following NUL terminating string
Affected: HL
Usage: Print≤ NU╠-terminateΣ string≤ froφ indexeΣ string≤ ì
áááááááááááááááo≥ remotel∙-locateΣ place≤ iε thσ codσ body« WitΦ ì
áááááááááááááááthσ áexceptioε oµ EPSTR¼ contro∞ character≤ áothe≥ ì
áááááááááááááááthaε áTAB¼ BS¼ CR¼ LF¼ anΣ BE╠ arσ outpu⌠ a≤ á"^có ì
ááááááááááááááásequences« (Seσ characte≥ outpu⌠ routines.)
FILENAM┼ áOUTPUT:é á Filenamσ outpu⌠ routine≤ describeΣ áherσ áarσ ì
useΣ át∩ displa∙ thσ filenamσ anΣ filetypσ storeΣ iε aε FC┬ iε áß ì
variet∙ áoµ forms« Thesσ form≤ arσ denoteΣ iε thσ routinσ áname≤ ì
(xFNn⌐ as:
xFN1 -- print filename in 12-character field, embedded spaces
xFN2 -- print filename in n-character field, no spaces
xFN3 -- print filename in 12-character field, trailing spaces
Thσ áfollowinτ áillustrate≤ ho≈ value≤ wil∞ bσ áoutpu⌠ áb∙ áthesσ ì
routines« Thσ underscorσ characte≥ (_⌐ indicate≤ ß space.
FCB name/type xFN1 xFN2 xFN3
FILENAMETYP FILENAME.TYP FILENAME.TYP FILENAME.TYP
MYFILE TXT MYFILE__.TXT MYFILE.TXT MYFILE.TXT__
R R R_______.R__ R.R R.R_________
S S_______.___ S. S.__________
T ________.T__ .T .T__________
.paèIε additioε t∩ thσ methoΣ oµ printinτ thσ filenamσ anΣ áfiletype¼ ì
eacΦ oµ thesσ routine≤ ha≤ ß prefi° t∩ it≤ name║ L¼ M¼ P¼ o≥ áS« ì
Thesσ prefixe≤ indicatσ wherσ thσ outpu⌠ i≤ t∩ bσ sent« ╠ áindiì
cate≤ áthσ printe≥ (o≥ LS╘ device)¼ ═ fo≥ memory¼ ╨ fo≥ thσ áconì
solσ (prin⌠ thσ output)¼ anΣ ╙ fo≥ ß switcheΣ outpu⌠ t∩ ánothing¼ ì
thσ console¼ thσ printer¼ o≥ both« Thσ lis⌠ is:
letter example outputs to
╠ LFN1 LST device (printer)
M MFN1 Memory pointed to by HL
P PFN1 CON device (console)
S SFN1 Switched output
Routines║ LFNn¼ PFNn¼ SFNn
Function: LFNnÖ print≤ filenamσ t∩ printe≥ (LS╘ device)¼ PFNnÖ ì
áááááááááááááááprint≤ áfilenamσ át∩ consolσ á(CO╬ ádevice)¼ áSFNnÖ ì
áááááááááááááááprint≤ filenamσ t∩ switcheΣ (LST/CON⌐ devices
Entry: DE = address of FCB+1
Exit: None
Affected: None
Usage: Print≤ áfilenamσ anΣ filetypσ informatioε áfroφ áß ì
áááááááááááááááFilσ áContro∞ Blocδ (FCB)« Thσ nÖ iε áthσ ároutinσ ì
ááááááááááááááánamσ specifie≤ thσ methoΣ iε whicΦ t∩ displa∙ áthσ ì
áááááááááááááááinformation« á Value≤ áoµ nÖ arσ ▒ t∩ á3¼ áwherσ á▒ ì
áááááááááááááááprint≤ áfixeΣ á1▓-characte≥ outpu⌠ áwitΦ áembeddeΣ ì
áááááááááááááááspaces¼ ▓ print≤ variablσ lengtΦ (u≡ t∩ 1▓ áchars⌐ ì
áááááááááááááááwitΦ án∩ trailinτ spaces¼ anΣ │ print≤ áfixeΣ á1▓-ì
ááááááááááááááácha≥ áoutpu⌠ witΦ trailinτ spaces« (Seσ áFilenamσ ì
áááááááááááááááOutpu⌠ above.)
Routine║ MFNn
Function║ Store filename in memory
Entry: DE = pointer to FCB+1
H╠ ╜ pointe≥ t∩ memor∙ buffe≥ oµ a⌠ leas⌠ 1▓ charì
áááááááááááááááacters
Exit: None
Affected: None
Usage: Store≤ ß filenamσ anΣ filetypσ iε memor∙ formatteΣ ì
áááááááááááááááa≤ áthσ routine≤ fo≥ consolσ anΣ áprinte≥ áoutput« ì
áááááááááááááááThσ ásuffi° ánÖ iε thσ routinσ namσ áspecifie≤ áthσ ì
áááááááááááááááforφ áoµ áthσ informatioε wherσ wherσ ▒ ástore≤ áß ì
áááááááááááááááfixeΣ á1▓-characte≥ fielΣ witΦ embeddeΣ spaces¼ á▓ ì
ááááááááááááááástore≤ ß variablσ lengtΦ (u≡ t∩ 1▓ characters⌐ áiε ì
áááááááááááááááthσ fielΣ witΦ n∩ trailinτ spaces¼ anΣ │ store≤ áß ì
áááááááááááááááfixeΣ á1▓-characte≥ áfielΣ witΦ átrailinτ áspaces« ì
ááááááááááááááá(Seσ áFilenamσ áOutpu⌠ above.⌐ MFN▒ anΣ áMFN│ áarσ ì
áááááááááááááááquitσ ástraigh⌠-forwarΣ t∩ usσ sincσ áthe∙ áalway≤ ì
áááááááááááááááfil∞ exactl∙ 1▓ byte≤ oµ memory« Advancinτ t∩ thσ ì
ááááááááááááááánex⌠ bytσ afte≥ thσ las⌠ onσ useΣ i≤ quitσ simple¼ ì
áááááááááááááááa≤ showε by:
L─ DE,FCB+▒ ; point to Fn field
LD HL,BUFFER ; ..and to memory buffer
CALL MFN1 ; store the name
LD BC,12 ; skip to after last byte
ADD HL,BC ; ..by adding 12 to startè MFN▓ i≤ no⌠ quitσ a≤ eas∙ t∩ usσ sincσ i⌠ fill≤ a⌠ ì
ááááááááááááááámos⌠ 1▓ bytes¼ bu⌠ coulΣ fil∞ les≤ thaε this« Thσ ì
áááááááááááááááprobleφ áma∙ bσ overcomσ b∙ usinτ áß á1│-characte≥ ì
ááááááááááááááábuffe≥ anΣ thσ FILL┬ anΣ SKNS╨ routines¼ as:
LD HL,BUFFER ; point to buffer
LD B,13 ; fill 13 bytes w/spaces
LD A,' '
CALL FILLB
LD DE,FCB+1 ; point to Fn field
CALL MFN2 ; ..and store
CALL SKNSP ; skip over non-spaces (HL now
... ; ..points to byte after last)
CHARACTE╥-ORIENTE─ áINPUT/OUTPUT:é Thi≤ se⌠ oµ routine≤ áprovide≤ ì
simplσ áI/╧ capabilitie≤ witΦ absolutel∙ n∩ sidσ effect≤ áoε áan∙ ì
registers« Direc⌠ BIO╙ call≤ arσ useΣ oε al∞ routine≤ excep⌠ fo≥ ì
BIN¼ áBIST¼ anΣ BOUT¼ s∩ function≤ sucΦ a≤ ^╨ (whicΦ áarσ áimpleì
menteΣ b∙ thσ BDOS⌐ wil∞ no⌠ worδ b∙-anΣ-large.
The I/O capabilities provided by these routines include:
Character input from console and reader
Character output to console, printer, and punch
Characte≥ outpu⌠ t∩ console¼ printer¼ anΣ puncΦ witΦ contro∞ ì
áááááááááácharacte≥ processing
Console input status
Conditional input
New line (CRLF) output
Capitalized character input
SwitcheΣ áoutpu⌠ i≤ provideΣ iε thi≤ se⌠ oµ routines╗ áthesσ áarσ ì
calleΣ thσ ╙-serie≤ oµ routines¼ anΣ arσ complementar∙ t∩ thσ á╙-ì
serie≤ numeriπ prin⌠ routines.
.ix SCTLFL (g)
Thσ á╙-serie≤ oµ routine≤ i≤ differen⌠ froφ thσ othe≥ áserie≤ áiε ì
tha⌠ áthσ ╙-serie≤ use≤ aε externa∞ datß bytσ t∩ determinσ áwherσ ì
thσ áoutpu⌠ i≤ t∩ bσ routed« Thi≤ bytσ i≤ referreΣ t∩ a≤ áSCTLF╠ ì
(╙ áContro∞ Flag)¼ anΣ it≤ switchinτ functioε i≤ áillustrateΣ áiε ì
thσ followinτ table:
SCTLFL:
binary hex outputs to
00000000Γ 00Φ nothing
00000001b 01h console
10000000b 80h printer
10000001b 81h console and printer
Iµ áyo⌡ d∩ no⌠ initializσ thσ SCTLF╠ variablσ beforσ usinτ aε á╙-ì
routine¼ outpu⌠ wil∞ g∩ t∩ thσ consolσ (thσ defaul⌠ i≤ 01h).
An example of code using S-routines is:
EX╘ SCTLFL,SOU╘ ; SCTLFL flag, SOUT routine
...
LD A,81H ; enable printer and console
LD (SCTLFL),A
...è LD A,'A' ; print character 'A'
CALL SOUT
...
LD A,80H ; enable printer only
LD (SCTLFL),A
...
LD A,'a' ; print character 'a'
CALL SOUT
...
Routine║ BIN
Function║ BDOS console character input routine
Entry: None
Exit: A = character input from CON
Affected: AF
Usage: Input≤ áß characte≥ froφ thσ consolσ áwitΦ ánorma∞ ì
áááááááááááááááBDO╙ processinτ (echo¼ ^╨ anΣ ^╙ sensing).
Routine║ BIST
Function║ BDOS character input status routine
Entry: None
Exit: A <> 0, zero flag clear (NZ) if character ready
A = 0, zero flag set (Z) if no character
Affected: AF
Usage: Return≤ thσ consolσ inpu⌠ statu≤ viß BDO╙ functioε ì
ááááááááááááááá11.
Routine║ BOUT
Function║ BDOS character output routine
Entry: A = character to send to console display
Exit: None
Affected: None
Usage: Output≤ ß characte≥ t∩ thσ consolσ viß BDO╙ áfuncì
ááááááááááááááátioε 2.
Routines║ CAPIN¼ CAPINE
Function║ Capitalized character input
Entry: None
Exit: A = capitalized character input from console
Affected: AF
Usage: Wait≤ áfo≥ áaε inpu⌠ characte≥ froφ áthσ áconsole¼ ì
ááááááááááááááácapitalize≤ áit¼ anΣ return≤ i⌠ t∩ áyou≥ áprogram« ì
áááááááááááááááCAPI╬ ásimpl∙ return≤ thσ ácapitalizeΣ ácharacter¼ ì
áááááááááááááááwhilσ áCAPIN┼ als∩ echoe≤ i⌠ t∩ thσ áconsolσ ádisì
áááááááááááááááplay.
Routines║ CIN¼ RIN
Function: Inpu⌠ ß characte≥ froφ thσ consolσ o≥ reade≥ (auxì
áááááááááááááááiliar∙ device)
Entry: None
Exit: A = character from console (CIN) or reader (RIN)
Affected: AF
Usage: Provide≤ characte≥ inpu⌠ function≤ witΦ BIO╙-leve∞ ì
áááááááááááááááinterface≤ áavoidinτ áBDO╙ processing« á The∙ áarσ ì
ááááááááááááááásomewha⌠ faste≥ iε responsσ thaε thei≥ BDO╙ ácounìèáááááááááááááááterparts.
Routines║ COUT¼ COUT7¼ LOUT¼ POUT¼ SOUT
Function: COU╘ áoutput≤ áß characte≥ t∩ thσ áconsole¼ áCOUT╖ ì
áááááááááááááááoutput≤ ß characte≥ t∩ thσ consolσ strippinτ áhigΦ ì
ááááááááááááááábit¼ áLOU╘ output≤ ß characte≥ t∩ thσ lis⌠ ádevicσ ì
ááááááááááááááá(printer)¼ áPOU╘ output≤ ß characte≥ t∩ thσ ápuncΦ ì
ááááááááááááááá(auxiliary⌐ ádevice¼ SOU╘ output≤ ß ácharacte≥ át∩ ì
áááááááááááááááthσ switcheΣ (CON/LST⌐ output
Entry: A = character to send to output device
Exit: Nonσ á(COUT╖ return≤ characte≥ iε ┴ witΦ higΦ ábi⌠ ì
áááááááááááááááclear)
Affected: AF
Usage: Fo≥ ádirec⌠ áBIO╙-leve∞ outpu⌠ withiε áß áprogram¼ ì
áááááááááááááááthesσ routine≤ avoiΣ thσ BDO╙ characte≥ trap≤ áanΣ ì
áááááááááááááááprocessing¼ anΣ arσ thereforσ somewha⌠ faste≥ thaε ì
áááááááááááááááBDO╙ routines« COUT╖ i≤ identica∞ t∩ COU╘ áexcep⌠ ì
ááááááááááááááátha⌠ thσ higΦ-orde≥ bi⌠ i≤ strippeΣ froφ thσ áoutì
ááááááááááááááápu⌠ characte≥ beforσ passinτ i⌠ t∩ thσ driver.
Routines║ CCOUT¼ CLOUT¼ CPOUT¼ CSOUT
Function: CCOU╘ áoutput≤ t∩ consolσ witΦ ácontro∞ ácharacte≥ ì
ááááááááááááááádisplay¼ CLOU╘ output≤ t∩ lis⌠ devicσ witΦ contro∞ ì
ááááááááááááááácharacte≥ ádisplay¼ CPOU╘ output≤ t∩ puncΦ ádevicσ ì
áááááááááááááááwitΦ ácontro∞ characte≥ display¼ CSOU╘ output≤ át∩ ì
áááááááááááááááswitcheΣ CON/LS╘ witΦ contro∞ characte≥ display
Entry: A = character to output
Exit: None
Affected: Flags
Usage: Thesσ routine≤ shoulΣ bσ useΣ t∩ contro∞ áprintinτ ì
ááááááááááááááát∩ device≤ whicΦ ma∙ bσ disturbeΣ b∙ ánoε-printinτ ì
ááááááááááááááá(control⌐ ácharacters« á The∙ áfunctioε áa≤ áthei≥ ì
áááááááááááááááprimar∙ counterpart≤ fo≥ norma∞ printablσ ácharaπì
áááááááááááááááters¼ bu⌠ trea⌠ al∞ ASCI╔ code≤ les≤ thaε ß áspacσ ì
ááááááááááááááá(20H⌐ áexcep⌠ áfo≥ <NUL>¼ <BEL>¼ <BS>¼ á<LF>¼ áanΣ ì
ááááááááááááááá<CR╛ iε ß specia∞ manner« Thesσ value≤ arσ outpu⌠ ì
áááááááááááááááa≤ áaε ácare⌠ (^⌐ followeΣ áb∙ áthσ ácorrespondinτ ì
ááááááááááááááálette≥ ágenerateΣ b∙ addinτ 40Φ t∩ áthσ ácharacte≥ ì
ááááááááááááááávaluσ (i.e.¼ ▒ output≤ a≤ "^A"¼ ▓ a≤ "^B"¼ etc.).
Routine║ CONDIN
Function║ Conditional console input
Entry: None
Exit: A = console character, zero clear (NZ) if present
A indeterminate, zero set (Z) if n∩ character
Affected: AF
Usage: Test≤ áfo≥ an∙ waitinτ characte≥ oε áthσ áconsole¼ ì
áááááááááááááááanΣ áreturn≤ it« Iµ n∩ characte≥ i≤ waiting¼ áthσ ì
ááááááááááááááároutinσ return≤ ß flaτ indicatinτ tha⌠ n∩ ácharacì
áááááááááááááááte≥ wa≤ returned.
.paè Routine║ CRLF¼ LCRLF¼ SCRLF
Function: CRL╞ senΣ carriagσ returε anΣ linefeeΣ t∩ console¼ ì
áááááááááááááááLCRL╞ ásenΣ ácarriagσ returε anΣ linefeeΣ át∩ áLS╘ ì
ááááááááááááááá(printer)¼ SCRL╞ senΣ carriagσ returε anΣ linefeeΣ ì
ááááááááááááááát∩ switcheΣ output
Entry: None
Exit: None
Affected: None
Usage: Send≤ áß ne≈ linσ combinatioε oµ ácarriagσ áreturε ì
áááááááááááááááanΣ álinefeeΣ t∩ thσ CO╬ (CRLF)¼ LS╘ á(LCRLF)¼ áo≥ ì
áááááááááááááááswitcheΣ outpu⌠ (SCRLF).
Routine║ CST
Function║ Return console status routine
Entry: None
Exit: A = 0, zero flag set (Z) if console data available
A = 1, zero clear (NZ) if no data available
Affected: AF
Usage: Quickl∙ ásample≤ thσ consolσ statu≤ witΦ ß ádirec⌠ ì
áááááááááááááááBIO╙ interface.
BRANCHING:é á Thσ routine≤ iε thi≤ sectioε dea∞ áwitΦ áconditiona∞ ì
branchinτ viß CASE¼ computeΣ GOTO¼ anΣ arithmetiπ I╞ áconstructs« ì
Thσ followinτ examplσ illustrate≤ thσ CASE concept:
[register A = key value]
CAL╠ ACASE1
DEFB SIZE ; number of entries in table
DEFW ERROR ; ..go here if no match
DEFB VAL1 ; first value to test for
DEFW ADDR1 ; ..go here if A = VAL1
DEFB VAL2 ; 2nd value to test for
DEFW ADDR2 ; ..go here if A = VAL2
...
DEFB VALSIZE ╗ 'SIZE' value to test for
DEFW ADDRSIZE ; ..go here if A = VALSIZE
The following example illustrates the computed GOTO:
[register A = index (zero-relative)]
CALL AGOTO1
DEFW ADDR0 ; go here if A = 0
DEFW ADDR1 ; go here if A = 1
...
DEFW ADDRN ; go here if A = N
Thσ followinτ examplσ illustrate≤ thσ computeΣ GOT╧ witΦ limits:
[register A = index (zero-relative)]
[register B = limit]
CALL AGOTO1
DEFW ADDR0 ; go here if A = 0
DEFW ADDR1 ; go here if A = 1
...
DEFW ADDRN ; go here if A = N
[error code] ; ..come here if A > B
.paèThe following example illustrates the arithmetic IF:
[register A = key value]
[register B = test value]
CALL AIF1
DEFW ADDRLT ; go here if A < B
DEFW ADDREQ ; go here if A = B
DEFW ADDRGT ; go here if A > B
The following routines are provided:
ACASE▒ -¡ case statement with A = key value
ACASE2 -¡ like ACASE1, but DE = address of case table
ACASE3 -¡ like ACASE2, but return address is left on stack
HCASE1 -¡ like ACASE1, but HL = key value
HCASE2 -¡ like ACASE2, but HL = key value
HCASE3 -¡ like ACASE3, but HL = key value
AGOTO1 -¡ computed GOTO with A = key value
AGOTO2 -¡ like AGOTO1, but JPs rather than DEFW follow
HGOTO1 -¡ computed GOTO with HL = key value
HGOTO2 -¡ like AGOTO2, but HL = key value
BGOTO1 -¡ like AGOTO1, but B = limit value
BGOTO2 -¡ like AGOTO2, but B = limit value
DGOTO1 -¡ like HGOTO1, but DE = limit value
DGOTO2 -¡ like HGOTO2, but DE = limit value
AIF1 -¡ arithmetic IF with A, B = values
AIF2 -¡ like AIF1, but JPs rather than DEFW follow
HIF1 -¡ arithmetic IF with HL, DE = values
HIF2 -¡ like AIF2, but HL, DE = values
Routine║ ACASE1
Function║ Multiway jump from A register value, embedded table
Entry: A = value to test for branch
Exit: None (branch is made)
Affected: None
Usage: ┴ casσ statemen⌠ processo≥ whicΦ act≤ a≤ ß ámultiì
áááááááááááááááwa∙ ájum≡ áinstruction¼ sincσ thσ áreturε áaddres≤ ì
áááááááááááááááfroφ áthσ ácal∞ t∩ ACASE▒ i≤ áno⌠ áretained« á Thσ ì
ááááááááááááááávaluσ át∩ átes⌠ i≤ compareΣ t∩ value≤ áiε áß ácasσ ì
ááááááááááááááátablσ anΣ contro∞ i≤ transferreΣ t∩ aε áassociateΣ ì
áááááááááááááááaddres≤ iµ ß matcΦ i≤ found.
Example:
LD A,TEST
CALL ACASE1
DEFB N ; number of entries in table
DEFW DEFAULT ; goto address if no match
DEFB VAL1 ; test for TEST = VAL1
DEFW ADDR1 ; go here if TEST = VAL1
...è DEFB VALN ; test for TEST = VALN
DEFW ADDRN ; go here if TEST = VALN
Routine: ACASE2
Function║ Multiway jump from A register value, external table
Entry: A = value to test for branch
DE = address of case table
Exit: None (branch is made)
Affected: None
Usage: ┴ casσ statemen⌠ processo≥ whicΦ act≤ a≤ ß ámultiì
áááááááááááááááwa∙ ájump« á Thσ returε addres≤ froφ thσ ácal∞ át∩ ì
áááááááááááááááACASE▓ ái≤ no⌠ retained« Aε entr∙ valuσ ái≤ ácomì
ááááááááááááááápareΣ át∩ ávalue≤ iε aε externa∞ ácasσ átablσ áanΣ ì
ááááááááááááááácontro∞ ái≤ transferreΣ t∩ thσ associateΣ áaddres≤ ì
áááááááááááááááupoε ß match.
Example:
L─ A,TEST ; value to test for
LD DE,TABLE ; address of table
CALL ACASE2
...
TABLE: DEFB N ; number of entries in table
DEFW DEFAULT ; goto address if no match
DEFB VAL1 ; test for TEST = VAL1
DEFW ADDR1 ; go here if TEST = VAL1
...
DEFB VALN ; test for TEST = VALN
DEFW ADDRN ; go here if TEST = VALN
Routine: ACASE3
Function║ Multiway call from A register, external table
Entry: A = value to test for call
DE = address of case table
Exit: None (branch is made)
Affected: None
Usage: ACASE│ ái≤ ß casσ statemen⌠ processo≥ whicΦ áfuncì
ááááááááááááááátion≤ áa≤ áß multiwa∙ CAL╠ áinstructioε áwitΦ áthσ ì
áááááááááááááááreturε addres≤ froφ thσ cal∞ t∩ ACASE│ lef⌠ oε thσ ì
ááááááááááááááástack« Thσ routinσ i≤ entereΣ witΦ ß valuσ áwhicΦ ì
ááááááááááááááái≤ ácompareΣ át∩ thosσ iε ß tablσ anΣ ácontro∞ ái≤ ì
ááááááááááááááátransferreΣ t∩ aε associateΣ addres≤ iµ ß matcΦ i≤ ì
ááááááááááááááámade.
Example:
L─ A,TEST ; value to test for
LD DE,TABLE ; address of table
CALL ACASE3
[resume execution here if routines execute a RET instr]
...
TABLE: DEFB N ; number of entries in table
DEFW DEFAULT ; ..go here if no match
DEFB VAL1 ; test for TEST = VAL1
DEFW ADDR1 ; ..go here if TEST = VAL1
...
DEFB VALN ; test for TEST = VALN
DEFW ADDRN ; ..go here if TEST = VALN
.paè Routine║ HCASE1
Function║ Multiway jump from HL, embedded table
Entry: HL = value to test for
Exit: None (branch is made)
Affected: None
Usage: ┴ casσ statemen⌠ processo≥ wherσ ß 1╢-bi⌠ valuσ i≤ ì
ááááááááááááááácompareΣ át∩ áentrie≤ iε ß table« Upoε áß ámatch¼ ì
ááááááááááááááácontro∞ ái≤ transferreΣ t∩ aε associateΣ áaddress« ì
áááááááááááááááThσ returε addres≤ froφ thσ CAL╠ t∩ HCASE▒ i≤ áno⌠ ì
áááááááááááááááretaineΣ makinτ thi≤ analagou≤ t∩ ß jum≡ áinstrucì
ááááááááááááááátion.
Example:
L─ HL,TEST
CALL HCASE1
DEFW N ; number of entries in table
DEFW DEFAULT ; ..go here if no match
DEFW VAL1 ; test for TEST = VAL1
DEFW ADDR1 ; ..go here if TEST = VAL1
...
DEFW VALN ; test for TEST = VALN
DEFW ADDRN ; ..go here if TEST = VALN
Routine: HCASE2
Function║ Multiway jump from HL, external table
Entry: HL = value to test for
DE = address of case table
Exit: None (branch is made)
Affected: None
Usage: ┴ casσ statemen⌠ processo≥ wherσ ß 1╢-bi⌠ valuσ i≤ ì
ááááááááááááááácompareΣ át∩ entrie≤ iε aε addresseΣ table« Iµ áß ì
ááááááááááááááámatcΦ i≤ found¼ contro∞ i≤ transferreΣ t∩ aε assoì
áááááááááááááááciateΣ addres≤ froφ thσ table« Thσ returε addres≤ ì
áááááááááááááááfroφ áthσ CAL╠ t∩ HCASE▓ i≤ no⌠ retained¼ s∩ áthi≤ ì
ááááááááááááááároutinσ function≤ a≤ ß jump.
Example:
LD H,TEST ; value to test for
LD DE,TABLE ; address of table
CALL HCASE2
...
TABLE: DEFW N ; number of entries in table
DEFW DEFAULT ; ..go here if no match
DEFW VAL1 ; test for TEST = VAL1
DEFW ADDR1 ; ..go here if TEST = VAL1
...
DEFW VALN ; test for TEST = VALN
DEFW ADDRN ; ..go here if TEST = VALN
Routine: HCASE3
Function║ Multiway call from HL, external table
Entry: HL = value to test for
DE = address of case table
Exit: None (branch is made)
Affected: None
Usage: ┴ casσ statemen⌠ processo≥ wherσ ß 1╢-bi⌠ valuσ i≤ ì
ááááááááááááááácompareΣ át∩ entrie≤ iε aε addresseΣ table« Iß áß ìèááááááááááááááámatcΦ i≤ found¼ contro∞ i≤ transferreΣ t∩ aε assoì
áááááááááááááááciateΣ addres≤ froφ thσ table« Thσ returε addres≤ ì
áááááááááááááááfroφ áthσ CAL╠ t∩ HCASE│ i≤ retaineΣ s∩ thi≤ árouì
ááááááááááááááátinσ function≤ a≤ ß call.
Example:
LD HL,TEST ; value to test for
LD DE,TABLE ; address of table
CALL HCASE3
[resume execution here if routines execute an RET instr]
...
TABLE║ DEF╫ N ╗ numbe≥ oµ entrie≤ iε table
DEFW DEFAULT ; ..go here if no match
DEFW VAL1 ; test for TEST = VAL1
DEFW ADDR1 ; ..go here if TEST = VAL1
...
DEFW VALN ; test for TEST = VALN
DEFW ADDRN ; ..go here if TEST = VALN
Routine║ AGOTO1
Function║ Computed GOTO on A register
Entry: A = index value (zero-relative)
Exit: None
Affected: None
Usage: ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ ╕-bi⌠ ávalue« ì
áááááááááááááááN∩ árangσ o≥ limi⌠ checkinτ i≤ done¼ s∩ áyo⌡ ámus⌠ ì
áááááááááááááááinsurσ tha⌠ thσ computeΣ GOT╧ doe≤ no⌠ exceeΣ áthσ ì
ááááááááááááááátablσ limit.
Example:
LD A,INDEX ; index value
CALL AGOTO1
DEFW ADDR0 ; go here if A = 0
DEFW ADDR1 ; go here if A = 1
...
DEFW ADDRN ; go here if A = N
Routine: AGOTO2
Function║ Computed GOTO on A register
Entry: A = index value (zero-relative)
Exit: None
Affected: None
Usage: ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ ╕-bi⌠ ávalue« ì
áááááááááááááááN∩ árangσ o≥ limi⌠ checkinτ i≤ done¼ s∩ áyo⌡ ámus⌠ ì
áááááááááááááááinsurσ tha⌠ thσ computeΣ GOT╧ doe≤ no⌠ exceeΣ áthσ ì
ááááááááááááááátablσ limit.
Example:
LD A,INDEX ; index value
CALL AGOTO2
JP ADDR0 ; return to this JP if A = 0
JP ADDR1 ; return to this JP if A = 1
...
JP ADDRN ; return to this JP if A = N
[next instruction] ; return here if A = N+1
.paè Routine: BGOTO1
Function║ Computed GOTO on A register with limit check
Entry: A = index value (zero-relative)
B = maximum index value allowed
Exit: None
Affected: None
Usage: ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ ╕-bi⌠ ávalue« ì
ááááááááááááááá┴ seconΣ bytσ i≤ passeΣ specifyinτ ß limi⌠ ávalue« ì
áááááááááááááááIµ áthσ tes⌠ valuσ exceed≤ thσ limit¼ ácontro∞ ái≤ ì
ááááááááááááááátransferreΣ át∩ afte≥ thσ las⌠ addres≤ iε thσ átaì
áááááááááááááááble.
Example:
LD A,INDEX ; index value
L─ B,LIMI╘ ╗ maximuφ inde° value
CALL BGOTO1
DEFW ADDR0 ; go here if A = 0
DEFW ADDR1 ; go here if A = 1
...
DEFW ADDRLIMIT ; go here if A = LIMIT
[next instruction] ; return here if A > LIMIT
Routine: BGOTO2
Function║ Computed GOTO on A register with limit check
Entry: A = index value (zero-relative)
B = maximum index value
Exit: None
Affected: None
Usage: ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ ╕-bi⌠ ávalue« ì
ááááááááááááááá┴ seconΣ bytσ i≤ passeΣ specifyinτ ß limi⌠ ávalue« ì
áááááááááááááááIµ áthσ tes⌠ valuσ exceed≤ thσ limit¼ ácontro∞ ái≤ ì
ááááááááááááááátransferreΣ át∩ afte≥ thσ las⌠ addres≤ iε thσ átaì
áááááááááááááááble.
Example:
LD A,INDEX ; index value
L─ B,LIMI╘ ╗ maximuφ inde° value
CALL BGOTO2
JP ADDR0 ; return to this JP if A = 0
JP ADDR1 ; return to this JP if A = 1
...
JP ADDRLIMIT ; return to this JP if A=LIMIT
[next instruction▌ ; return here if A > LIMIT
Routine║ HGOTO1
Function║ Computed GOTO on HL register pair
Entry: HL = index value (zero-relative)
Exit: None
Affected: None
Usage: ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ 1╢-bi⌠ value« ì
áááááááááááááááN∩ árangσ áo≥ limi⌠ check≤ arσ performed¼ ás∩ áyo⌡ ì
ááááááááááááááámus⌠ insurσ tha⌠ thσ rangσ oµ thσ computeΣ GOT╧ i≤ ì
áááááááááááááááno⌠ exceeded.
Example:
L─ HL,INDEX ; index value
CALL HGOTO1
DEFW ADDR0 ; go here if HL = 0è DEFW ADDR1 ; go here if HL = 1
...
DEFW ADDRN ; go here if HL = N
Routine: HGOTO2
Function║ Computed GOTO on HL register pair
Entry: HL = index value (zero-relative)
Exit: None
Affected: None
Usage: ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ 1╢-bi⌠ value« ì
áááááááááááááááN∩ árangσ áo≥ limi⌠ check≤ arσ performed¼ ás∩ áyo⌡ ì
ááááááááááááááámus⌠ insurσ tha⌠ thσ rangσ oµ thσ computeΣ GOT╧ i≤ ì
áááááááááááááááno⌠ exceeded.
Example:
LD HL,INDE╪ ; index value
CALL HGOTO2
JP ADDR0 ; return to this JP if HL = 0
JP ADDR1 ; return to this JP if HL = 1
...
JP ADDRN ; return to this JP if HL = N
[next instruction] ; return here if HL = N+1
Routine: DGOTO1
Function║ Computed GOTO on HL with limit check
Entry: HL = index value (zero-relative)
DE = maximum index value allowed
Exit: None
Affected: None
Usage: ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ 1╢-bi⌠ value« ì
ááááááááááááááá┴ áseconΣ á1╢-bi⌠ valuσ i≤ passeΣ áspecifyinτ áthσ ì
áááááááááááááááuppe≥ limi⌠ oµ computeΣ values« Iµ thσ áspecifieΣ ì
ááááááááááááááátes⌠ ávaluσ exceed≤ thσ limi⌠ value¼ theε ácontro∞ ì
ááááááááááááááái≤ átransferreΣ t∩ afte≥ thσ las⌠ addres≤ áiε áthσ ì
ááááááááááááááátable.
Example:
LD HL,INDEX ; index value
LD DE,LIMIT ; maximum index value
CALL DGOTO1
DEFW ADDR0 ; go here if HL = 0
DEFW ADDR1 ; go here if HL = 1
...
DEFW ADDRLIMIT ; go here if HL = LIMIT
[next instruction] ; return here if HL > LIMIT
Routine: DGOTO2
Function║ Computed GOTO on HL with limit check
Entry: HL = index value (zero-relative)
DE = maximum index value
Exit: None
Affected: None
Usage: ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ 1╢-bi⌠ value« ì
ááááááááááááááá┴ áseconΣ á1╢-bi⌠ valuσ i≤ passeΣ áspecifyinτ áthσ ì
áááááááááááááááuppe≥ limi⌠ oµ computeΣ values« Iµ thσ áspecifieΣ ì
ááááááááááááááátes⌠ ávaluσ exceed≤ thσ limi⌠ value¼ theε ácontro∞ ì
ááááááááááááááái≤ átransferreΣ t∩ afte≥ thσ las⌠ addres≤ áiε áthσ ìèááááááááááááááátable.
Example:
LD HL,INDEX ; index value
L─ DE,LIMI╘ ╗ maximuφ inde° value
CALL DGOTO2
JP ADDR0 ; return to this JP if HL = 0
JP ADDR1 ; return to this JP if HL = 1
...
JP ADDRLIMIT ; return to this JP if HL = LIMIT
[next instruction▌ ; return here if HL > LIMIT
Routine║ AIF1
Function║ Arithmetic IF on A register
Entry: A = test value
B = key value
Exit: None
Affected: None
Usage: Aε áarithmetiπ I╞ facilit∙ wherσ ß áspecifieΣ áke∙ ì
ááááááááááááááávaluσ (iε B⌐ i≤ compareΣ t∩ ß specifieΣ tes⌠ valuσ ì
ááááááááááááááá(iε áA)« Branchinτ i≤ donσ dependinτ oε thσ áfolì
ááááááááááááááálowinτ tests║ ┴╝B¼ ┴╜B¼ anΣ ┴╛B.
Example:
LD A,TEST ; test value
LD B,KEY ; key value
CALL AIF1
DEFW ALTB ; go here if A<B
DEFW AEQB ; go here if A=B
DEFW AGTB ; go here if A>B
Routine: AIF2
Function║ Arithmetic IF on A register
Entry: A = test value
B = key value
Exit: None
Affected: None
Usage: Aε áarithmetiπ I╞ facilit∙ wherσ ß áspecifieΣ áke∙ ì
ááááááááááááááávaluσ (iε B⌐ i≤ compareΣ t∩ ß specifieΣ tes⌠ valuσ ì
ááááááááááááááá(iε áA)« Branchinτ i≤ donσ dependinτ oε thσ áfolì
ááááááááááááááálowinτ tests║ A<B¼ A=B¼ anΣ A>B.
Example:
LD A,TEST ; test value
LD B,KEY ; key value
CALL AIF2
JP ALTB ; resume at this JP if A<B
JP AEQB ; resume at this JP if A=B
JP AGTB ; resume at this JP if A>B
.paè Routine║ HIF1
Function║ Arithmetic IF on HL register pair
Entry: HL = test value
DE = key value
Exit: None
Affected: None
Usage: Aε áarithmetiπ I╞ facilit∙ wherσ ß áspecifieΣ áke∙ ì
ááááááááááááááávaluσ á(iε áDE⌐ i≤ compareΣ t∩ áß áspecifieΣ átes⌠ ì
ááááááááááááááávaluσ (iε HL)« Branchinτ i≤ donσ dependinτ oε thσ ì
áááááááááááááááfollowinτ tests║ HL<DE¼ HL=DE¼ anΣ HL>DE.
Example:
LD HL,TEST ; test value
LD DE,KEY ; key value
CALL HIF1
DEFW HLTD ; go here if HL<DE
DEFW HEQD ; go here if HL=DE
DEFW HGTD ; go here if HL>DE
Routine: HIF2
Function║ Arithmetic IF on HL register pair
Entry: HL = test value
DE = key value
Exit: None
Affected: None
Usage: Aε áarithmetiπ I╞ facilit∙ wherσ ß áspecifieΣ áke∙ ì
ááááááááááááááávaluσ á(iε áDE⌐ i≤ compareΣ t∩ áß áspecifieΣ átes⌠ ì
ááááááááááááááávaluσ (iε HL)« Branchinτ i≤ donσ dependinτ oε thσ ì
áááááááááááááááfollowinτ tests║ HL<DE¼ HL=DE¼ anΣ HL>DE.
Example:
LD HL,TEST ; test value
LD DE,KEY ; key value
CALL HIF2
JP HLTD ; resume at this JP if HL<DE
JP HEQD ; resume at this JP if HL=DE
JP HGTD ; resume at this JP if HL>DE
.paèPARSIN╟ AIDS:
UNIX-STYLE ARGC/ARGV STRIN╟ PARSING:
Routine║ ARGV
Function║ UNIX-style ARGC/ARGV string parser
Entry: HL = address of NUL-terminated string to parse
DE = address of token table
A <> 0 if NUL is to be placed after each token
A = 0 if NUL not to be placed after each token
Exit: A = 0, zero flag set (Z) if no error
┴ á<╛ 0¼ zer∩ flaτ rese⌠ (NZ⌐ iµ morσ token≤ áthaε ì
áááááááááááááááalloweΣ (las⌠ tokeε pointe≥ point≤ t∩ thσ res⌠ áoµ ì
áááááááááááááááthσ string)
Affected: AF
Usage: Isolate≤ átoken≤ áwithiε ß strinτ áfo≥ ásubsequen⌠ ì
áááááááááááááááaction¼ ásucΦ áa≤ filenamσ áo≥ áargumen⌠ áparsing« ì
áááááááááááááááToken≤ áarσ ádelimiteΣ b∙ space≤ áanΣ átabs« á Fo≥ ì
áááááááááááááááexample:
" THIS IS FUN "
contain≤ threσ tokens¼ anΣ ARG╓ wil∞ returε pointì
áááááááááááááááer≤ t∩ thσ "Tó iε "THIS"¼ thσ "Ió iε "IS"¼ anΣ thσ ì
ááááááááááááááá"Fó iε "FUN"« Iµ ┴ <╛ ░ oε input¼ ARG╓ wil∞ storσ ì
ááááááááááááááábinar∙ 0'≤ (NUL's⌐ ove≥ thσ firs⌠ spacσ afte≥ áthσ ì
ááááááááááááááá"Só áiε á"THIS"¼ thσ "Só iε "IS"¼ anΣ thσ á"Nó áiε ì
ááááááááááááááá"FUN"« N∩ change≤ arσ madσ t∩ thσ strinτ iµ ┴ ╜ ░ ì
áááááááááááááááoε entry.
ARG╓ i≤ calleΣ witΦ thσ addres≤ oµ ß tablσ ástrucì
ááááááááááááááátureΣ as:
DEFB MAXEN╘ ; number of token pointers
filled / DEFS 1 ; number of tokens found by ARGV
in | DEFS 2 ; pointer to token 1 (in string)
by | DEFS 2 ; pointer to token 2 (in string)
ARGV | ...
\ DEFS 2 ; Ptr to token MAXENT (in string)
Iµ átherσ werσ morσ token≤ iε thσ strinτ thaε áalì
áááááááááááááááloweΣ áiε thσ tokeε table¼ ARG╓ return≤ witΦ áA<>░ ì
áááááááááááááááanΣ áthσ zer∩ flaτ rese⌠ (NZ)« Iε thi≤ case¼ áthσ ì
ááááááááááááááálas⌠ átokeε pointe≥ point≤ t∩ thσ las⌠ átokeε áalì
ááááááááááááááálowed¼ anΣ extend≤ t∩ thσ enΣ oµ thσ string« á Thσ ì
áááááááááááááááNU╠ ái≤ áno⌠ placeΣ afte≥ thσ las⌠ token¼ ás∩ áthσ ì
áááááááááááááááres⌠ oµ thσ strinτ appear≤ a≤ ß singlσ tokeε á(anΣ ì
áááááááááááááááma∙ bσ parseΣ b∙ ARG╓ again).
.paèCAPITALIZATION:
Routine║ CAPS
Function║ Capitalize a character
Entry: A = character to capitalize
Exit: A = capitalized character
Affected: AF
Usage: Return≤ áthσ áuppercasσ versioε oµ áan∙ álowercasσ ì
áááááááááááááááASCI╔ characte≥ specified« Character≤ othe≥ áthaε ì
áááááááááááááááthosσ áiε thσ se⌠ [ß-z▌ arσ áreturneΣ áunaffected« ì
áááááááááááááááIµ thσ characte≥ i≤ ß lowercasσ alphabetiπ charaπì
áááááááááááááááter¼ ái⌠ ái≤ áconverteΣ t∩ Uppercasσ áiε áthσ áse⌠ ì
ááááááááááááááá[A..Z]« Onl∙ thσ lowe≥ seveε bit≤ oµ thσ bytσ arσ ì
áááááááááááááááconsidered¼ áanΣ áthσ ámos⌠ ásignifican⌠ ábi⌠ áái≤ ì
ááááááááááááááázeroed.
Routine║ CAPSTR
Function║ Capitalize a string
Entry: HL = pointer to first byte of a string
Exit: None (string is capitalized)
Affected: None
Usage: Capitalize≤ áß NU╠-terminateΣ strinτ specifieΣ áiε ì
áááááááááááááááthσ callinτ parameters.
CHARACTE╥ TES╘ ROUTINES:é Characte≥ tes⌠ routine≤ checδ thσ specì
ifieΣ ASCI╔ characte≥ (afte≥ maskinτ ofµ thσ higΦ bit⌐ t∩ seσ áiµ ì
i⌠ meet≤ ß specifieΣ condition« Al∞ routine≤ conforφ t∩ thσ samσ ì
convention≤.
Routines║ ISALNUM¼ ISALPHA¼ ISCTRL¼ ISDIGIT¼ ISGRAPH¼ ISHEX¼ ì
áááááááááááááááISPRINT¼ ISPUN¼ ISSP
Function║ Tes⌠ fo≥ specifiπ type≤ oµ characters
Entry: A = character to test
Exit║ ┴ ╜ character¼ zer∩ flaτ se⌠ (Z⌐ iµ conditioε true
Zero flag reset (NZ) if condition false
Affected: Flags
Usage: ISALNU═ test≤ fo≥ aε alphanumeriπ characte≥ á(┴-Z¼ ì
áááááááááááááááß-z¼ ░-9)¼ ISALPH┴ test≤ fo≥ aε alphabetiπ characì
áááááááááááááááte≥ (┴-Z¼ ß-z)¼ ISCTR╠ test≤ fo≥ ß contro∞ characì
áááááááááááááááte≥ á(les≤ thaε SP¼ o≥ DEL)¼ ISDIGI╘ test≤ áfo≥ áß ì
ááááááááááááááádigi⌠ (░-9)¼ ISGRAP╚ test≤ fo≥ ß graphiπ characte≥ ì
ááááááááááááááá(betweeε S╨ anΣ DEL)¼ ISHE╪ test≤ fo≥ ß áhexadeciì
áááááááááááááááma∞ characte≥ (░-9¼ ┴-F¼ ß-f)¼ ISPRIN╘ test≤ fo≥ ß ì
áááááááááááááááprintablσ characte≥ (betweeε S╨ anΣ DEL¼ includinτ ì
áááááááááááááááSP)¼ ISPU╬ test≤ fo≥ ß punctuatioε characte≥ á(beì
ááááááááááááááátweeε áS╨ anΣ DEL¼ inc∞ DEL¼ bu⌠ no⌠ ░-9¼ ┴-Z¼ áo≥ ì
áááááááááááááááß-z)¼ áISS╨ test≤ fo≥ ß spacσ characte≥ á(HT¼ áLF¼ ì
áááááááááááááááVT¼ FF¼ CR¼ anΣ SP)
.paèCHARACTE╥ áSKI╨ áROUTINES:é Thesσ routine≤ arσ useΣ t∩ áski≡ áove≥ ì
character≤ áiε thσ strinτ specifieΣ unti∞ eithe≥ ß ácharacte≥ áoµ ì
thσ átypσ áno⌠ ábeinτ skippeΣ i≤ encountereΣ o≥ thσ áenΣ áoµ áthσ ì
strinτ á(NU╠ character⌐ i≤ found« The∙ al∞ conforφ t∩ áthσ ásamσ ì
parameter≤ as:
Routines║ SKNPUN¼ SKNSP¼ SKPUN¼ SKSP
Function║ Ski≡ ove≥ specifiπ typσ oµ character
Entry: H╠ ╜ pointe≥ t∩ firs⌠ characte≥ iε áNU╠-terminateΣ ì
ááááááááááááááástring
Exit: HL = pointer to character which terminated skip
Affected: HL
Usage: SKNPU╬ áskip≤ áove≥ ánoε-punctuatioε áácharacters¼ ì
áááááááááááááááSKNS╨ skip≤ ove≥ noε-spacσ characters¼ SKPU╬ skip≤ ì
áááááááááááááááove≥ punctuatioε characters¼ SKS╨ skip≤ ove≥ spacσ ì
ááááááááááááááácharacters« á Punctuatioε ácharacter≤ áarσ ááthosσ ì
ááááááááááááááábetweeε S╨ anΣ DE╠ whicΦ arσ no⌠ ░-9¼ ┴-Z¼ o≥ ß-z« ì
áááááááááááááááSpacσ ácharacter≤ arσ an∙ oµ thσ se⌠ HT¼ áLF¼ áVT¼ ì
áááááááááááááááFF¼ CR¼ o≥ SP.
GENERA╠ áPURPOS┼ ARITHMETIC:é Thesσ routine≤ arσ fo≥ á1╢-bi⌠ áunì
signeΣ arithmetic« Al∞ usσ H╠ a≤ thσ accumulato≥ o≥ thσ áresult¼ ì
anΣ H╠ anΣ D┼ contaiε thσ operand≤ requireΣ (iµ onl∙ onσ áoperanΣ ì
i≤ needed¼ H╠ i≤ used).
The available routines are:
ADDH─ -¡ HL = HL + DE
SUBHD -¡ HL = HL - DE
MULHD -¡ HL = HL * DE
DIVHD -¡ HL = HL / DE
NEGH -¡ HL = 2's complement of HL
CMPH -¡ HL = 1's complement of HL
ROTLH -¡ HL is rotated left one bit position
ROTRH -¡ HL is rotated right one bit position
SHFTLH -¡ HL is shifted left one bit position
SHFTRH -¡ HL is shifted right one bit position
ANDHD -¡ HL = HL AND DE
ORHD -¡ HL = HL OR DE
XORHD -¡ HL = HL XOR DE
The carry flag is frequently used to indicate overflow.
Routine║ ADDHD
Function║ 16-bit addition
Entry: HL = operand 1
DE = operand 2
Exit: HL = operand 1 + operand 2
Carry set (C) if overflow, otherwise clear (NC)
Affected: F¼ HL
Usage: This routine is not really needed since a simple
AD─ HL,DE
instructioε accomplishe≤ thσ samσ thinτ witΦ áonl∙ ì
áááááááááááááááonσ bytσ insteaΣ oµ ß │-bytσ call.
è Routine║ SUBHD
Function║ 16-bit subtraction
Entry: HL = minuend
DE = subtrahend
Exit: HL = minuend - subtrahend
Carry set (C) if DE > HL, otherwise clear (NC)
Affected: F¼ HL
Usage: Thi≤ routinσ i≤ n∩ longe≥ needeΣ witΦ Z8░ áprocesì
ááááááááááááááásor≤ sincσ the
SB├ HL,DE
operatioε áaccomplishe≤ thσ samσ functioε áwithou⌠ ì
áááááááááááááááresortinτ t∩ ß functioε call.
Routine║ MULHD
Function║ 16-bit multiplication
Entry: HL = operand 1
DE = operand 2
Exit: HL = operand 1 times operand 2
Carry set (C) if result is > 65535
Affected: F¼ HL
Usage: Multiplie≤ átw∩ ánumbers« á I⌠ ái≤ áoptimizeΣ áfo≥ ì
áááááááááááááááspeed¼ áwitΦ áß mino≥ sacrificσ oε ásize¼ áanΣ ái⌠ ì
áááááááááááááááalway≤ átake≤ 1╢ loop≤ t∩ perforφ an∙ ámultiplicaì
ááááááááááááááátion.
Routine║ DIVHD
Function║ 16-bit division
Entry: HL = dividend
DE = divisor
Exit: HL = HL / DE
Affected: HL
Usage: Divide≤ átw∩ numbers« I⌠ i≤ optimizeΣ fo≥ áspeed¼ ì
áááááááááááááááwitΦ áß mino≥ sacrificσ oε size¼ anΣ alway≤ átake≤ ì
ááááááááááááááá1╢ loop≤ t∩ perforφ an∙ division.
Routine║ NEGH
Function║ Two's complement (negate) a 16-bit number
Entry: HL = 16-bit operand
Exit: HL = two's complement of operand
Affected: HL
Usage: Return≤ thσ 2'≤ complemen⌠ oµ ß 1╢-bi⌠ number.
Routine║ CMPH
Function║ One's complement a 16-bit number
Entry: HL = 16-bit operand
Exit: HL = one's complement of operand
Affected: HL
Usage: Return≤ thσ 1'≤ complemen⌠ oµ ß 1╢-bi⌠ number.
.paè Routine║ ANDHD
Function║ Logically AND two 16-bit values
Entry: HL = operand 1
DE = operand 2
Exit: HL = bitwise logical AND of two operands
Affected: HL
Usage: Perform≤ áthσ specifieΣ Booleaε operatioε áoε áthσ ì
ááááááááááááááátw∩ supplieΣ 1╢-bi⌠ values¼ anΣ returε thσ result.
Routine: ORHD
Function║ Logically OR two 16-bit values
Entry: HL = operand 1
DE = operand 2
Exit: H╠ ╜ bitwise logical OR of two operands
Affected: HL
Usage: Perform≤ áthσ specifieΣ Booleaε operatioε áoε áthσ ì
ááááááááááááááátw∩ supplieΣ 1╢-bi⌠ values¼ anΣ returε thσ result.
Routine║ XORHD
Function║ Logically XOR two 16-bit values
Entry: HL = operand 1
DE = operand 2
Exit: H╠ ╜ bitwise logical XOR of two operands (XORHD)
Affected: HL
Usage: Perform≤ áthσ specifieΣ Booleaε operatioε áoε áthσ ì
ááááááááááááááátw∩ supplieΣ 1╢-bi⌠ values¼ anΣ returε thσ result.
Routines║ ROTLH¼ ROTRH
Function: ROTL╚ ádoe≤ áß onσ bi⌠ righ⌠ árotatioε áoµ á1╢-bi⌠ ì
ááááááááááááááávalue¼ áROTR╚ doe≤ ß onσ bi⌠ lef⌠ rotatioε oµ á1╢-ì
ááááááááááááááábi⌠ value
Entry: HL = 16-bit operand to rotate
Exit: HL = rotated operand left (ROTLH) or right (ROTRH)
Affected: HL
Usage: Rotate≤ thσ furnisheΣ 1╢-bi⌠ valuσ lef⌠ (ROTLH⌐ o≥ ì
ááááááááááááááárigh⌠ (ROTRH⌐ onσ bi⌠ position« Thesσ arσ ácircuì
ááááááááááááááála≥ rotates¼ iε whicΦ thσ mos⌠ significan⌠ bi⌠ áoµ ì
ááááááááááááááá╚ i≤ rotateΣ int∩ thσ leas⌠ significan⌠ bi⌠ áposiì
ááááááááááááááátioε oµ ╠ (ROTLH)¼ anΣ leas⌠ significan⌠ bi⌠ oµ á╠ ì
ááááááááááááááái≤ rotateΣ int∩ thσ mos⌠ significan⌠ bi⌠ ápositioε ì
áááááááááááááááoµ ╚ (ROTRH).
Routines║ SHFTLH¼ SHFTRH
Function: SHFTL╚ doe≤ ß onσ bi⌠ righ⌠ shif⌠ oµ 1╢-bi⌠ value¼ ì
ááááááááááááááázer∩ fill¼ SHFTR╚ doe≤ ß onσ bi⌠ lef⌠ shif⌠ oµ 1╢-ì
ááááááááááááááábi⌠ value¼ zer∩ fill
Entry: HL = 16-bit operand to shift
Exit: HL = shifted operand left (SHFTLH) or right (SHFTRH)
Affected: HL
Usage: Shift≤ thσ furnisheΣ 1╢-bi⌠ valuσ lef⌠ (SHFTLH⌐ o≥ ì
ááááááááááááááárigh⌠ á(SHFTRH⌐ áonσ ábi⌠ ápositioε áfillinτ ááthσ ì
ááááááááááááááácleareΣ ápositioε witΦ ß zero« Iε SHFTLH¼ áH╠ ái≤ ì
áááááááááááááááshifteΣ lef⌠ onσ bi⌠ positioε witΦ thσ leas⌠ ásigì
ááááááááááááááánifican⌠ bi⌠ oµ ╠ filleΣ witΦ ß zero« Iε áSHFTRH¼ ì
áááááááááááááááH╠ i≤ shifteΣ righ⌠ onσ bi⌠ positioε witΦ thσ mos⌠ ìèááááááááááááááásignifican⌠ ábi⌠ oµ ╚ filleΣ witΦ ß zero« á SHFTL╚ ì
ááááááááááááááái≤ equivalen⌠ t∩ thσ morσ efficien⌠ singlσ byte
AD─ HL,HL
operatioε áanΣ áSHFTR╚ i≤ equivalen⌠ t∩ áthσ áfou≥ ì
ááááááááááááááábytσ Z8░ sequence:
SRL H
RR L
CR├ áCALCULATION:é Thσ CR├ routine≤ ma∙ bσ useΣ t∩ checδ thσ ávaì
lidit∙ oµ aε incominτ seria∞ bytσ streaφ o≥ checδ fo≥ validit∙ oµ ì
datß ácopies« á Thesσ routine≤ computσ anΣ checδ áß átruσ á1╢-bi⌠ ì
cycliπ redundanc∙ codσ (CRC).
Thσ usσ oµ thesσ routine≤ wil∞ guaranteσ detectioε oµ al∞ singlσ-ì
bi⌠ anΣ doublσ-bi⌠ errors¼ al∞ error≤ witΦ aε odΣ numbe≥ oµ erro≥ ì
bits¼ al∞ burs⌠ error≤ oµ lengtΦ 1╢ o≥ less¼ 99.9969Ñ oµ al∞ á1╖-ì
bi⌠ áerro≥ ábursts¼ áanΣ 99.9984Ñ oµ al∞ ápossiblσ álonge≥ áerro≥ ì
bursts.
CR├ áanΣ CRC│ routine≤ usσ thσ X^1╢ ½ X^1▓ ½ X^╡ ½ á▒ ápolynomia∞ ì
commonl∙ useΣ iε flopp∙ disδ controller≤ anΣ modeφ programs« Thσ ì
CRC▒ routinσ use≤ thσ X^1╢ ½ X^1╡ ½ X^▓ ½ ▒ polynomia∞ als∩ áuseΣ ì
iε synchronou≤ communications« CRC▓ use≤ thσ X^1╢ ½ X^1╡ ½ áX^1│ ì
½ X^╖ ½ X^┤ ½ X^▓ ½ ╪ ½ ▒ polynomia∞ founΣ iε publiπ-domaiε áfilσ ì
CR├ checkinτ programs.
Al∞ áfou≥ familie≤ oµ routine≤ arσ useΣ iε thσ samσ áway¼ áexcep⌠ ì
tha⌠ ß uniquσ initializatioε routine¼ CRC3INIT¼ i≤ requireΣ áwitΦ ì
CRC│ ábeforσ áan∙ processinτ i≤ performed« Thi≤ i≤ ábecausσ áthσ ì
CRC│ updatσ routinσ i≤ tablσ-driveε compareΣ t∩ thσ other≤ áwhicΦ ì
calculatσ áthσ áCR├ "oε thσ fly"« Thσ addeΣ routinσ ábuild≤ áthσ ì
tablσ oµ prσ-computeΣ remainders« Typica∞ usσ is:
CRCMAKE: ; call CRC3INIT here if using CRC3
CAL╠ CRCCL╥ ; clear the CRC
[loop CALLing CRCUPD] ; ..acquire values
CALL CRCDONE ; get the finished value
LD (CRCVAL),HL ; ..and save
CRCCK: ; routine to check incoming CRC
CALL CRCCLR ; clear CRC
[loop CALLing CRCUPD] ; ..acquire new set of values
CALL CRCDONE ; get the finished value in HL
LD DE,(CRCVAL) ; get the first value in DE
CALL COMPHD ; compare HL to DE
JR NZ,ERROR ; ..error if CRC's don't match
Routines║ CRCCLR, CRC1CLR, CRC2CLR, CRC3CLR
Function║ Clear CRC accumulator
Entry: None
Exit: None
Affected: None
Usage: Mus⌠ bσ executeΣ beforσ beginninτ ß ne≈ áoperatioε ì
áááááááááááááááoε ß file¼ block¼ o≥ secto≥ oµ data« D∩ no⌠ ácal∞ ì
áááááááááááááááthesσ routine≤ beforσ completinτ calculation≤ oε ß ì
áááááááááááááááblocδ o≥ thσ accumulateΣ datß wil∞ bσ incorrect.è
Routine: CRC3INIT
Function║ Initialize CRC3 table for use
Entry: HL = pointer to 512-byte space for table
Exit: None
Affected: AF¼ BC¼ DE
Usage: Mus⌠ ábσ executeΣ beforσ usinτ thσ áCRC│ áupdatinτ ì
ááááááááááááááároutine¼ áo≥ incorrec⌠ result≤ wil∞ ábσ áobtained« ì
áááááááááááááááI⌠ áinitialize≤ ß tablσ witΦ prσ-computeΣ CR├ áreì
ááááááááááááááámainder≤ fo≥ usσ b∙ thσ updatinτ routine.
Routine║ CRCUPD, CRC1UPD, CRC2UPD, CRC3UPD
Function║ Update CRC accumulator count
Entry: A = byte to be included in CRC
Exit: None
Affected: None
Usage: CalleΣ áoncσ fo≥ ever∙ bytσ t∩ bσ includeΣ iε áthσ ì
áááááááááááááááCR├ calculation.
Routines║ CRCDONE, CRC1DONE, CRC2DONE, CRC3DONE
Function║ Return CRC value
Entry: None
Exit: HL = calculated CRC value
Affected: HL
Usage: Thi≤ routinσ i≤ useΣ t∩ terminatσ CR├ accumulatioε ì
áááááááááááááááanΣ returε thσ calculateΣ 1╢-bi⌠ CR├ value.
RANDO═ NUMBE╥ GENERATION:
Routine║ RNDINIT
Function║ Initialize random number generator seed
Entry: None
Exit: None
Affected: None
Usage: Versioε á┤ oµ thσ librarie≤ change≤ thi≤ áfunctioε ì
áááááááááááááááfroφ áthσ keyboard/loo≡ counte≥ useΣ áiε ápreviou≤ ì
áááááááááááááááversion≤ t∩ onσ wherσ thσ refresΦ registe≥ oµ áthσ ì
áááááááááááááááZ80/Z18░ i≤ reaΣ t∩ forφ thσ initia∞ seed¼ requirì
áááááááááááááááinτ n∩ use≥ action« Thi≤ methoΣ wil∞ no⌠ worδ áoε ì
áááááááááááááááthσ Z28░ wherσ refresΦ i≤ jus⌠ anothe≥ register.
Routine: RNDSEED
Function║ Set known seed value
Entry: A = 8-bit seed value
Exit: None
Affected: None
Usage: Allow≤ yo⌡ t∩ providσ ß seeΣ valuσ fo≥ thσ árandoφ ì
ááááááááááááááánumbe≥ ágenerato≥ insteaΣ oµ usinτ áthσ áautomatiπ ì
ááááááááááááááámethoΣ iε RNDINIT.
.paè Routine║ RND
Function║ Return 8-bit pseudo-random number
Entry: None
Exit: A = random number
Affected: AF
Usage: Provide≤ ß pseud∩-randoφ byte« Thσ returneΣ ávalì
áááááááááááááááue≤ áarσ ábetweeε zer∩ anΣ 255« Yo⌡ mus⌠ ád∩ áan∙ ì
áááááááááááááááscalinτ needeΣ fo≥ you≥ application.
STRIN╟ AN─ VALU┼ COMPARISON:
Routines║ COMPB¼ COMPBC
Function║ Comparσ vectors
Entry: HL, DE = pointers to vectors to compare
B├ á(fo≥ COMPBC)¼ ┬ (fo≥ COMPB⌐ ╜ numbe≥ oµ ábyte≤ ì
ááááááááááááááát∩ compare
Exit: zero flag set (Z)║ HL = DE
carry flag set (C)║ HL < DE
zero and carry reset (NZ and NC)║ HL > DE
Affected: AF
Usage: Mos⌠ commonl∙ useΣ t∩ d∩ strinτ comparison« Sincσ ì
áááááááááááááááal∞ eigh⌠ bit≤ arσ useΣ iε thσ comparσ logic¼ the∙ ì
áááááááááááááááarσ als∩ suitablσ fo≥ ra≈ binar∙ element≤ a≤ well« ì
áááááááááááááááCOMP┬ use≤ onl∙ aε ╕-bi⌠ counte≥ (┬ register⌐ áanΣ ì
ááááááááááááááácaε comparσ onσ t∩ 25╢ bytes¼ whilσ COMPB├ use≤ áß ì
ááááááááááááááá1╢-bi⌠ ácounte≥ (B├ pair⌐ anΣ caε comparσ áonσ át∩ ì
ááááááááááááááá65,53╢ bytes« Thσ maximuφ count≤ oµ 25╢ anΣ 6553╢ ì
áááááááááááááááarσ áachieveΣ b∙ settinτ thσ counte≥ register≤ át∩ ì
ááááááááááááááázero.
Routine║ @FNCMP
Function║ Unambiguous 7-bit filenamσ comparison
Entry: HL = pointer to first string to match
DE = pointer to second string to match
B = number of characters to check (0 checks 256)
Exit: zero flag set (Z) if strings match
zero flag reset (NZ) if no match
carry flag set (C) if (DE) is less than (HL)
Affected: AF¼ BC¼ DE¼ HL
Usage: Mos⌠ áofteε áuseΣ t∩ comparσ filename≤ áanΣ áfileì
ááááááááááááááátypes« á I⌠ perform≤ ╖-bi⌠ ácomparisons¼ áignorinτ ì
áááááááááááááááan∙ áattributσ bit≤ (bi⌠ 7)« Iε genera∞ áuse¼ ái⌠ ì
ááááááááááááááácompare≤ átw∩ string≤ oµ onσ t∩ 25╢ character≤ áiε ì
ááááááááááááááálength« Iε additioε t∩ equality¼ thσ inequalitie≤ ì
áááááááááááááááoµ ágreate≥ thaε anΣ les≤ thaε arσ als∩ ásupporteΣ ì
áááááááááááááááb∙ als∩ sensinτ thσ carr∙ flag.
.paè Routine║ @AFNCMP
Function║ Perform ambiguous 7-bit filenamσ comparison
Entry: HL = pointer to possibly ambiguous string
DE = pointer to second string to match
B = number of characters to check (0 checks 256)
Exit: zero flag set (Z) if match
zero flag reset (NZ) if no match
Affected: AF¼ BC¼ DE¼ HL
Usage: Mos⌠ áofteε áuseΣ t∩ comparσ filename≤ áanΣ áfileì
ááááááááááááááátypes¼ áwherσ onσ namσ ma∙ bσ ambiguou≤ á(questioε ì
ááááááááááááááámarks¼ "?"¼ matcΦ an∙ character)« HigΦ bit≤ á(bi⌠ ì
ááááááááááááááá7⌐ oµ botΦ string≤ arσ maskeΣ witΦ onl∙ thσ áleas⌠ ì
ááááááááááááááásignifican⌠ ábit≤ beinτ compared« I⌠ ma∙ als∩ ábσ ì
áááááááááááááááuseΣ a≤ ß genera∞ ╖-bi⌠ utilit∙ comparσ string≤ oµ ì
áááááááááááááááonσ t∩ 25╢ character≤ iε length.
Examples:
EXT @AFNCMP,@FNCM╨ ; declare the routines
... ; ..preceeding code
LD HL,AMBIG ; set ptr to ambiguous name
LD DE,FNAME ; set to name to check
LD B,11 ; match filename and type only
CALL @AFNCMP ; ..call the routine
JR Z,OK ; jump if match
... ; else here if mismatch
...
LD HL,ENTRY1 ; set ptr to first name
LD DE,ENTRY2 ; ..and name to check
LD B,11 ; mMatch filename and type only
CALL @FNCMP ; ..call the routine
JR Z,EQUAL ; jump if same
JR C,ONEMORE ; ..jump here if ENTRY1>ENTRY2
... ; else here if ENTRY1 < ENTRY2
Routine║ COMPHD
Function║ 16-bit value comparision
Entry: HL, DE = values to compare
Exit: Zero flag set (Z)║ HL = DE
Carry flag set (C)║ HL < DE
Carry and zero reset (NZ and NC)║ HL > DE
Affected: AF
Usage: Commonl∙ useΣ t∩ comparσ tw∩ 1╢-bi⌠ value≤ sucΦ a≤ ì
áááááááááááááááaddresse≤ o≥ intege≥ values.
Routine║ INSTR
Function║ Substring search (NUL-terminated character strings)
Entry: HL = pointer to NUL-terminated string to be scanned
DE = pointer to NUL-terminated substring to locate
Exit: H╠ á╜ pointe≥ t∩ beginninτ oµ substrinτ iε ástrinτ ì
áááááááááááááááiµ founΣ (unaffecteΣ iµ no⌠ found)
A = 0, zero flag set (Z) if found
A <> 0, zero flag clear if not found
Affected: AF¼ HL
Usage: Mos⌠ ofteε useΣ t∩ locatσ ß characte≥ strinτ withì
áááááááááááááááiε ß large≥ bod∙ oµ text¼ sucΦ a≤ withiε ß ásimplσ ì
ááááááááááááááátex⌠ editor« Automatiπ succes≤ iµ substrinτ i≤ oµ ìèááááááááááááááázer∩-lengtΦ (nul∞ string).
Routine║ SCANNER
Function║ Vector search
Entry: HL = pointer to vector to be scanned
DE = pointer to vector to locate
BC = vector lengths:
B = number of bytes in HL-vector
C = number of bytes in DE-vector
Exit: H╠ á╜ pointe≥ t∩ locateΣ vecto≥ (unchangeΣ iµ áno⌠ ì
áááááááááááááááfound)
Zero flag set (Z) if found (A indeterminate)
A <> 0, zero flag reset (NZ) if not found
Affected: AF¼ HL
Usage: Locate≤ ß strinτ oµ byte≤ iε ß blocδ oµ u≡ t∩ á25╡ ì
ááááááááááááááábytes« Sincσ onl∙ ╕-bit≤ arσ availablσ fo≥ lengtΦ ì
ááááááááááááááávalue≤ áfo≥ ábotΦ thσ searcΦ anΣ átarge⌠ ávectors¼ ì
áááááááááááááááneithe≥ álengtΦ ácaε exceeΣ 256« Becausσ áoµ áthσ ì
ááááááááááááááálogiπ áused¼ áthσ blocδ t∩ bσ scanneΣ mus⌠ ábσ áoµ ì
ááááááááááááááánoε-zer∩ álengtΦ át∩ áavoiΣ aε áerro≥ áfo≥ ásearcΦ ì
ááááááááááááááálength≤ les≤ thaε 25╢ (░ lengtΦ byte)« á Automatiπ ì
áááááááááááááááfailurσ áiµ scanneΣ vecto≥ i≤ shorte≥ thaε ávecto≥ ì
ááááááááááááááát∩ locatσ (┬ ╝ C).
MEMOR┘ áALLOCATION:é Thσ concep⌠ oµ memor∙ allocatioε witΦ áthesσ ì
routine≤ i≤ relativel∙ simple╗ SYSLI┬ routine≤ providσ áprimativσ ì
memor∙ áallocation/dσ-allocatioε ácapabilities¼ bu⌠ yo⌡ ásta∙ áiε ì
control.
Thσ ábasiπ áideß i≤ t∩ reservσ ß buffe≥ iε memor∙ froφ áwhicΦ át∩ ì
takσ ábit≤ anΣ piece≤ froφ a⌠ ß time« Thσ boundinτ addresse≤ áoµ ì
thi≤ buffe≥ arσ specifieΣ (o≥ se⌠ b∙ default⌐ b∙ thσ IALLO├ árouì
tine¼ áanΣ áthσ ALLO├ routinσ i≤ useΣ t∩ obtaiε ásubbuffer≤ áfroφ ì
thi≤ álarge≥ buffe≥ wheε needed« ALLO├ constantl∙ check≤ t∩ áseσ ì
iµ áthσ buffe≥ ha≤ enougΦ spacσ lef⌠ t∩ gran⌠ thσ reques⌠ áfo≥ áß ì
subbuffer¼ anΣ iµ i⌠ does¼ thσ subbuffe≥ i≤ provided.
Thσ larges⌠ buffe≥ whicΦ ma∙ bσ reserveΣ b∙ thσ IALLO├ routinσ i≤ ì
tha⌠ ábuffe≥ áwhicΦ extend≤ froφ thσ enΣ oµ thσ prograφ át∩ ájus⌠ ì
belo≈ thσ CCP« Thi≤ buffe≥ i≤ selecteΣ iµ IALLO├ i≤ calleΣ áwitΦ ì
A=0.
The following illustrates use of the largest buffer possible:
XOR A ; select full buffer
CALL IALLOC
...
LD DE,1024 ; request 1K
CALL ALLOC
JR Z,MEMOVFL ; abort if memory overflow
LD (BUF1),HL ; set pointer to 1st subbuffer
...
LD DE,36 ; request 36 bytes
CALL ALLOC
JR Z,MEMOVFL ; abort if memory overflow
LD (BUF2),HL ; set pointer to 2nd subbufferè ...
Thi≤ memor∙ allocatioε schemσ als∩ permit≤ thσ divisioε oµ memor∙ ì
int∩ áß grou≡ oµ buffers« Onσ buffe≥ ma∙ bσ allocated¼ áit≤ áadì
dres≤ ápreserved¼ áanothe≥ buffe≥ ma∙ bσ allocated¼ áit≤ áaddres≤ ì
preserved¼ áanΣ átheε subsequen⌠ call≤ t∩ IALLO├ ma∙ bσ áuseΣ át∩ ì
selec⌠ áonσ buffe≥ o≥ thσ other« EacΦ cal∞ t∩ IALLO├ áfree≤ áthσ ì
entirσ ábuffe≥ area¼ s∩ carσ shoulΣ bσ takeε iε doinτ this« á Fo≥ ì
example:
...
CALL CODEND ; use CODEND as first buffer
LD (BUF1),HL
EX DE,HL ; address in DE
LD HL,1024 ; 1K for this buffer
ADD HL,DE ; HL pts to after this buffer
EX DE,HL ; HL is start, DE is end
LD A,3 ; select start and end
CALL IALLOC
...
...
CALL ALLOC ; calls to ALLOC
...
LD HL,(BUF1) ; pt to 1st buffer
LD DE,1024 ; set 2nd buffer
ADD HL,DE ; pt to 2nd buffer
LD (BUF2),HL
EX DE,HL
ADD HL,DE ; pt to end of 2nd 1K buffer
EX DE,HL ; HL is start, DE is end
LD A,3 ; select start and end
CALL IALLOC
...
CALL ALLOC ; calls to ALLOC
...
Routine║ ALLOC
Function║ Allocate a block of memory
Entry: DE = number of bytes requested
Exit: HL = address of first byte allocated
A <> 0, zero flag reset (NZ) if request granted
A = 0, zero flag set (Z) if not enough space
Affected: AF¼ HL
Usage: Allocate≤ ß blocδ oµ memor∙ froφ thσ large≥ áblocδ ì
áááááááááááááááreserveΣ áb∙ IALLOC« Blocδ size≤ ma∙ bσ a≤ ásmal∞ ì
áááááááááááááááa≤ onσ byte¼ o≥ a≤ largσ a≤ thσ entirσ buffer« Iµ ì
áááááááááááááááthσ ámemor∙ reques⌠ i≤ granted¼ thσ ástartinτ áadì
ááááááááááááááádres≤ i≤ returned« ┴ cal∞ t∩ IALLO├ mus⌠ bσ ámadσ ì
ááááááááááááááábeforσ callinτ ALLOC.
.paè Routine║ IALLOC
Function║ Initialize memory allocation buffer
Entry: HL = possible starting address of buffer
DE = possible ending address of buffer
A = selection code:
b░ - 1 = use HL as starting address
0 = use CODEND value
b1 - 1 = use DE as ending address
0 = use CCP-1
Exit: None
Affected: None
Usage: Initialize≤ thσ buffe≥ froφ whicΦ memor∙ i≤ áalloì
ááááááááááááááácateΣ áviß ácall≤ t∩ ALLOC« Yo⌡ ma∙ áspecif∙ áthσ ì
ááááááááááááááábound≤ áoµ thi≤ buffer¼ o≥ usσ defaul⌠ bound≤ áse⌠ ì
áááááááááááááááb∙ IALLOC.
Routine║ GETMTOP
Function║ Return the highest TPA byte below the CCP
Entry: None
Exit: HL = addres≤ oµ the highest byte below CCP
Affected: HL¼ AF
Usage: Determine≤ thσ to≡ oµ availablσ memor∙ iε routine≤ ì
áááááááááááááááwhicΦ áexi⌠ bacδ t∩ thσ commanΣ processo≥ áwitΦ áß ì
ááááááááááááááásimplσ returε instructioε insteaΣ oµ ß warφ áboot« ì
áááááááááááááááThi≤ routinσ return≤ thσ highes⌠ availablσ ámemor∙ ì
ááááááááááááááálocatioε ábeneatΦ thσ commanΣ processo≥ át∩ áavoiΣ ì
áááááááááááááááoverwritinτ áit« Iµ yo⌡ arσ writinτ fo≥ áß áZCPR│ ì
áááááááááááááááenvironment¼ usσ thσ correspondinτ GZMTO╨ ároutinσ ì
áááááááááááááááiε Z3LIB.
SOR╘ áROUTINES:é Tw∩ routine≤ arσ provideΣ whicΦ givσ yo⌡ áacces≤ ì
t∩ áß áver∙ flexiblσ sortinτ system« Thσ maiε routinσ ái≤ áSORT¼ ì
providinτ áß utilit∙ whicΦ sort≤ iε-memor∙ ß se⌠ oµ áfixeΣ-lengtΦ ì
records« á Thσ ásortinτ techniquσ useΣ i≤ ß Shel∞ ásort¼ áadapteΣ ì
froφ áthσ ábooδ "Softwarσ Toolsó b∙ Kernigaε anΣ áPlaugher¼ ápubì
lisheΣ áb∙ áAddisoε-Wesley¼ 1976¼ pagσ 106« Thi≤ ásor⌠ ái≤ ámucΦ ì
faste≥ thaε thσ simplσ bubblσ sort.
┴ áShel∞ ásor⌠ caε bσ donσ iε tw∩ ways║ witΦ áo≥ áwithou⌠ áusinτ ì
pointers« á Sortinτ áwithou⌠ usinτ pointer≤ i≤ átypicall∙ áslowe≥ ì
thaε ásortinτ witΦ pointers¼ anΣ thσ onl∙ advantagσ t∩ no⌠ áusinτ ì
pointer≤ i≤ thσ spacσ saving≤ froφ no⌠ havinτ pointer≤ (▓ ¬ ánumì
be≥ áoµ entrie≤ bytes)« Iµ pointer≤ arσ useΣ fo≥ thσ sort¼ átheε ì
wheneve≥ aε exchangσ i≤ done¼ thσ pointer≤ arσ simpl∙ áexchanged¼ ì
rathe≥ áthaε áthσ ful∞ records¼ thereb∙ decreasinτ sor⌠ átimσ áiε ì
mos⌠ casts.
Thσ áSOR╘ ároutinσ i≤ controlleΣ b∙ passinτ ß pointe≥ t∩ áß áSor⌠ ì
Specificatioε áBlocδ (SSB)« Thi≤ Sor⌠ Specificatioε Blocδ ái≤ áß ì
serie≤ oµ ▓-bytσ word≤ organizeΣ a≤ follows:
Bytes ░ ª ▒ ╜ starting address of 1st record
Bytes ▓ ª │ = number of records to sort
Bytes ┤ ª ╡ = size of each record (in bytes)
Bytes 6 & 7 = addres≤ áoµ áuse≥-supplieΣ ácomparσ ároutine¼ ì
ááááááááááááááááááááwhicΦ compare≤ tw∩ records¼ onσ pointeΣ t∩ b∙ ìèááááááááááááááááááááH╠ áanΣ thσ othe≥ pointeΣ t∩ b∙ DE« á Iµ áthσ ì
áááááááááááááááááááárecorΣ ápointeΣ t∩ b∙ D┼ i≤ les≤ áiε ásortinτ ì
ááááááááááááááááááááorde≥ áthaε tha⌠ pointeΣ t∩ b∙ HL¼ thi≤ ácomì
ááááááááááááááááááááparσ routinσ i≤ t∩ returε witΦ carr∙ se⌠ (C)« ì
ááááááááááááááááááááIµ áthσ record≤ arσ equa∞ iε ásortinτ áorder¼ ì
ááááááááááááááááááááthi≤ ácomparσ routinσ i≤ t∩ returε witΦ ázer∩ ì
ááááááááááááááááááááse⌠ á(Z)« Onl∙ thσ A╞ i≤ t∩ bσ áaffecteΣ áb∙ ì
ááááááááááááááááááááthσ comparσ routine.
Bytes ╕ ª ╣ = address of pointer table
Byte 1░ = flag (0FFh means to use pointers, 0 means not)
Byte 1▒ = unused
A≤ mentioneΣ previously¼ tw∩ routine≤ arσ availablσ iε thi≤ ásor⌠ ì
module« Thσ firs⌠ routine¼ SSBINIT¼ look≤ a⌠ thσ beginninτ oµ áß ì
scratcΦ áareß áanΣ thσ initia∞ content≤ oµ aε SS┬ áanΣ áallocate≤ ì
spacσ fo≥ thσ pointe≥ table« I⌠ als∩ check≤ t∩ seσ iµ thσ buffe≥ ì
requireΣ overflow≤ thσ transien⌠ prograφ area.
Thσ seconΣ routine¼ SORT¼ perform≤ thσ sort¼ anΣ i≤ controlleΣ b∙ ì
thσ SS┬ pointe≥ passeΣ t∩ i⌠ iε DE.
Routine║ SSBINIT
Function║ Sor⌠ Specificatioε Block initializer
Entry: HL = pointer to start of scratch RAM area
DE = pointer to SSB
Exit: A <> 0, zero flag reset (NZ) if OK
A = 0, zero flag set (Z) if TPA overflow
Affected: AF
Usage: Thi≤ routinσ ma∙ bσ useΣ a≤ describeΣ abovσ beforσ ì
áááááááááááááááan∙ árecord≤ arσ loadeΣ int∩ memor∙ fo≥ thσ ásort¼ ì
áááááááááááááááo≥ ái⌠ ma∙ bσ useΣ afte≥ thσ record≤ havσ áalread∙ ì
ááááááááááááááábeeε loaded« Iε thσ latte≥ case¼ yo⌡ shoulΣ ásavσ ì
áááááááááááááááthσ ástar⌠ áaddres≤ oµ thσ firs⌠ recorΣ áanΣ ácal∞ ì
áááááááááááááááSSBINI╘ áwitΦ thσ addres≤ oµ thσ firs⌠ bytσ áafte≥ ì
áááááááááááááááthσ álas⌠ árecord« Oncσ SSBINI╘ áha≤ áloadeΣ áthσ ì
ááááááááááááááábuffer≤ iε thσ SS┬ anΣ checkeΣ fo≥ ß TP┴ áoverflo≈ ì
ááááááááááááááá(notσ tha⌠ thi≤ i≤ donσ fo≥ thσ pointer≤ only)¼ i⌠ ì
áááááááááááááááwil∞ áreturε át∩ áthσ caller¼ a⌠ áwhicΦ átimσ áyo⌡ ì
áááááááááááááááshoulΣ árestorσ thσ firs⌠ tw∩ byte≤ oµ thσ SS┬ át∩ ì
áááááááááááááááthei≥ áprope≥ values¼ thσ actua∞ star⌠ addres≤ áoµ ì
áááááááááááááááthσ firs⌠ record.
SSBINI╘ áload≤ byte≤ ░ ª ▒ (addres≤ oµ firs⌠ árecì
áááááááááááááááord⌐ áanΣ ╕ ª ╣ (addres≤ oµ pointe≥ table⌐ áoµ áaε ì
áááááááááááááááSSB¼ checkinτ fo≥ TP┴ overflow« I⌠ set≤ thσ poinì
áááááááááááááááte≥ átablσ t∩ star⌠ a⌠ thσ specifieΣ áscratcΦ áRA═ ì
áááááááááááááááarea¼ áexamine≤ thσ recorΣ sizσ anΣ árecorΣ ácoun⌠ ì
áááááááááááááááentrie≤ áoµ aε SSB¼ anΣ add≤ thσ produc⌠ oµ áthesσ ì
ááááááááááááááátw∩ t∩ thσ startinτ addres≤ oµ thσ pointe≥ átable« ì
áááááááááááááááThσ áresultinτ addres≤ i≤ returneΣ a≤ thσ áaddres≤ ì
áááááááááááááááoµ thσ firs⌠ record.
.paè Routine║ SORT
Function║ Sort set of fixed length records
Entry: DE = pointer to sort specification block (SSB)
Exit: None (records are sorted)
Affected: None
Usage: Sort≤ thσ se⌠ oµ fixeΣ lengtΦ record≤ accordinτ t∩ ì
áááááááááááááááthσ contro∞ informatioε iε thσ Sor⌠ áSpecificatioε ì
áááááááááááááááBlocδ (SSB⌐ addresseΣ b∙ DE« N∩ specia∞ actioε i≤ ì
ááááááááááááááárequired¼ áno≥ possiblσ iε it≤ operation« Iε áthσ ì
áááááááááááááááunlikel∙ áeven⌠ oµ aε erro≥ withiε thσ áSOR╘ árouì
ááááááááááááááátine¼ áthσ erro≥ messagσ "SOR╘ Pointe≥ Erroró áma∙ ì
ááááááááááááááábσ áprinted« Thi≤ indicate≤ ß fla≈ ha≤ ádevelopeΣ ì
áááááááááááááááwitΦ áthσ SOR╘ routinσ anΣ i⌠ coulΣ no⌠ áSOR╘ áthσ ì
áááááááááááááááse⌠ oµ record≤ a≤ desired« Thi≤ i≤ fata∞ anΣ wil∞ ì
áááááááááááááááabor⌠ t∩ CP/M.
MISCELLANEOU╙ ROUTINES:é Thσ followinτ routine≤ arσ describeΣ áiε ì
thi≤ section:
BDOS -¡ direct BDOS interface
BIOS -¡ direct BIOS interface
CAPS -¡ character capitalization
CAPSTR -¡ string capitalization
CATH -¡ convert ASCII character to hexadecimal
@B2HH,@B2HL -¡ convert high and low nybbles of byte to hex
CLINE -¡ command line extraction
CODEND -¡ provide end of code/data area
EN -¡ exchange nybbles in A
FILLB -¡ fill memory (up to 255 bytes)
FILLBC -¡ fill memory (up to 65,535 bytes)
HFILB -¡ fill memory (up to 255 bytes)
HFILBC -¡ fill memory (up to 65,535 bytes)
MOVEB -¡ move memory (up to 255 bytes)
MOVEBC -¡ move memory (up to 65,535 bytes)
HMOVB -¡ move memory (up to 255 bytes)
HMOVBC -¡ move memory (up to 65,535 bytes)
PAUSE -¡ delay n 10ths of a second
VERSION -¡ return version number of SYSLIB
Routine║ BDOS
Function║ Call a BDOS function
Entry: DE = arguments (if needed for function)
C = BDOS function number
Exit: A = return statu≤ o≥ parameter (if returned)
HL = return parameter (if returned)
Affected: AF¼ HL
Usage: ┴ wa∙ oµ callinτ thσ BDO╙ whilσ preservinτ thσ áB├ ì
áááááááááááááááanΣ áD┼ registers« Thi≤ i≤ ofteε oµ benefi⌠ áwheε ì
ááááááááááááááádealinτ witΦ FC┬ addresse≤ iε D┼ and/o≥ loo≡ counì
áááááááááááááááter≤ iε thσ ┬ register.
.paè Routine║ BIOS
Function║ Call a BIOS function directly
Entry: A = offset to BIOS function entry in jump table
BC = function parameters (if needed)
Exit: A¼ BC = return parameters (if returned)
Affected: AF¼ BC¼ DE¼ HL
Usage: Provide≤ áver∙ fas⌠ responsσ wherσ áBDO╙ áoverheaΣ ì
ááááááááááááááácanno⌠ ábσ tolerated« Thi≤ routinσ áprovide≤ áyo⌡ ì
áááááááááááááááwitΦ ß direc⌠ interfacσ int∩ thσ CP/═ BIOS« I⌠ i≤ ì
ááááááááááááááácalleΣ áwitΦ áaε inde° offse⌠ int∩ thσ áBIO╙ ájum≡ ì
ááááááááááááááátable« á N∩ register≤ arσ preserveΣ b∙ áthi≤ árouì
ááááááááááááááátine.
Thσ followinτ tablσ summarize≤ thσ offset≤ oµ áthσ ì
áááááááááááááááBIO╙ jum≡ tablσ entries:
░ Cold start
1 Warm boot
2 Consolσ status╗ return≤ A=0FFΦ iµ ácharì
áááááááááááááááááááááááááacte≥ ready¼ A=░ iµ not
3 Console input; returns character in A
4 Console output; character passed in C
5 List output; character passed in C
6 Punch output; character passed in C
7 Reader input; returns character in A
8 Home disk head
9 Selec⌠ ádisk╗ ádisδ numbe≥ á(A=0¼ áetc.⌐ ì
ááááááááááááááááááááááááápasseΣ iε C
10 Se⌠ tracδ number╗ tracδ numbe≥ passeΣ iε ì
áááááááááááááááááááááááááC
11 Se⌠ secto≥ number╗ secto≥ numbe≥ ápasseΣ ì
áááááááááááááááááááááááááiε C
12 Set DMA address; DMA address passed in BC
13 ReaΣ blocδ froφ disk╗ return≤ A=░ iµ OK¼ ì
áááááááááááááááááááááááááA=▒ iµ error
14 Writσ blocδ t∩ disk╗ return≤ A=░ iµ áOK¼ ì
áááááááááááááááááááááááááA=▒ iµ error
15 Lis⌠ ástatus╗ return≤ A=0FFΦ áiµ áready¼ ì
áááááááááááááááááááááááááA=░ iµ not
16 Secto≥ translation¼ logica∞-t∩-physical╗ ì
ááááááááááááááááááááááááálogica∞ ásecto≥ ánumbe≥ ápasseΣ áiε áBC¼ ì
ááááááááááááááááááááááááátranslatσ átablσ addres≤ iε DE╗ áreturn≤ ì
áááááááááááááááááááááááááphysica∞ secto≥ numbe≥ iε HL
Routine║ CATH
Function║ Convert ASCII to hexadecimal
Entry: A = ASCII hex character ("0"-"9", "A"-"F")
Exit: A = binary value represented by character
Affected: AF
Usage: Usefu∞ áiε numeriπ conversioε anΣ entr∙ ároutines« ì
áááááááááááááááI⌠ simpl∙ convert≤ thσ ASCI╔ hexadecima∞ characte≥ ì
áááááááááááááááprovideΣ át∩ áit≤ binar∙ árepresentation« á Iµ áaε ì
áááááááááááááááinvaliΣ he° characte≥ i≤ passed¼ ß spacσ (20h⌐ ái≤ ì
áááááááááááááááreturneΣ iε A.
.paè Routines║ @B2HH¼ @B2HL
Function║ Conver⌠ binar∙ t∩ hexadecimal
Entry: A = data byte to convert
Exit: A = hex character (0..9¼ A..F) for specified nybble
Affected: AF
Usage: Perform≤ conversion≤ froφ binar∙ nybble≤ t∩ áhexaì
ááááááááááááááádecima∞ áASCI╔ ácharacters« @B2H╚ áconvert≤ áhigΦ ì
ááááááááááááááánybblσ áoµ bytσ t∩ he° digit¼ whilσ @B2H╠ áconver⌠ ì
ááááááááááááááálo≈ nybblσ oµ bytσ t∩ he° digit.
Example:
EX╘ @B2HH,@B2HL
... ; enter with byte in A
PUSH AF ; save the byte
CALL @B2HH ; call the routine
... ; do something with high nybble
POP AF ; restore original byte
CALL @B2HL ; now have hex char of low nybble
... ; do something with it
Routine║ CLINE
Function║ Command line tail extraction
Entry: H╠ á╜ áaddres≤ oµ commanΣ linσ ábuffe≥ á(characte≥ ì
ááááááááááááááácount)
Exit: HL = address of command line string (1st character)
A <> 0, zero flag clear (NZ) if buffer OK
A = 0, zero flag set (Z) if buffer truncated
Affected: AF¼ HL
Usage: Free≤ áthσ ádefaul⌠ buffe≥ a⌠ 80Φ b∙ ácopyinτ áthσ ì
ááááááááááááááácontent≤ át∩ ß loca∞ buffer« Thσ ápreserveΣ ácop∙ ì
áááááááááááááááma∙ átheε bσ parseΣ o≥ evaluateΣ a⌠ ß late≥ átime« ì
áááááááááááááááThσ linσ ma∙ bσ u≡ t∩ 25╡ character≤ lonτ anΣ wil∞ ì
ááááááááááááááábσ truncateΣ iµ longer« Thσ strinτ wil∞ bσ termiì
ááááááááááááááánateΣ áb∙ áß <NUL╛ a≤ pe≥ thσ áSYSLI┬ áconcep⌠ áoµ ì
ááááááááááááááástrings.
Routine║ CODEND
Function║ End of code
Entry: None
Exit: HL = address of page above last byte used in program
Affected: HL
Usage: UseΣ t∩ determinσ thσ basσ addres≤ oµ freσ ámemor∙ ì
áááááááááááááááfo≥ áusσ iε sorting¼ director∙ listing¼ anΣ áothe≥ ì
áááááááááááááááprograms« á ScratcΦ memor∙ extend≤ froφ thσ ávaluσ ì
áááááááááááááááreturneΣ b∙ CODEN─ t∩ thσ basσ oµ thσ CC╨ o≥ BDOS.
.ix $MEMRY (g)
Global: $MEMRY ¡¡ Contain≤ thσ addres≤ oµ thσ nex⌠ áavailì
áááááááááááááááablσ ábytσ oµ memor∙ afte≥ thσ las⌠ modulσ áloadeΣ ì
áááááááááááááááanΣ áresolveΣ b∙ MicroSoft'≤ LIN╦-8░ álinker¼ áSL╥ ì
áááááááááááááááSystemsº áSLRNK¼ o≥ Mitek'≤ ZLINK« Thi≤ áreserveΣ ì
ááááááááááááááágloba∞ variablσ shoulΣ bσ accesseΣ as:
...
EXT $MEMRY
...
LD HL,($MEMRY) ; get value
...è
Routine║ EN
Function║ Exchange nybbles
Entry: A = byte to manipulate
Exit: A = manipulated Byte
Affected: AF
Usage: Exchange≤ áthσ ánybble≤ iε thσ ┴ áregister╗ áhigΦ-ì
áááááááááááááááorde≥ fou≥ bit≤ arσ exchangeΣ witΦ lo≈-orde≥ áfou≥ ì
ááááááááááááááábits.
Routines║ FILLB, FILLBC, HFILB, HFILBC
Function║ Memory fill routines
Entry: HL = pointer to first byte of memory area to fill
BC (FILLBC and HFILBC) = number of bytes to fill
B (FILLB and HFILB) = number of bytes to fill
A = value to store in buffer
Exit: H╠ (HFIL┬ anΣ HFILB├ only⌐ ╜ pointe≥ t∩ bytσ afte≥ ì
ááááááááááááááálast
Affected: HL (HFILB and HFILBC only)
Usage: Fill≤ aε areß oµ memor∙ witΦ ß constan⌠ bytσ ávalì
áááááááááááááááue« á FILL┬ caε fil∞ u≡ t∩ ß 25╢-bytσ buffer¼ áanΣ ì
áááááááááááááááFILLB├ ácaε fil∞ u≡ t∩ ß 65,53╢-bytσ (withiε áreaì
áááááááááááááááson⌐ buffer.
FILL┬ anΣ FILLB├ havσ n∩ effect≤ oε an∙ registers« ì
áááááááááááááááHFIL┬ anΣ HFILB├ botΦ affec⌠ thσ H╠ registe≥ pair¼ ì
áááááááááááááááanΣ the∙ returε witΦ H╠ pointinτ t∩ thσ bytσ afte≥ ì
áááááááááááááááthσ las⌠ bytσ filled« HFIL┬ anΣ HFILB├ arσ usefu∞ ì
áááááááááááááááwheε furthe≥ processinτ froφ thσ las⌠ poin⌠ filleΣ ì
ááááááááááááááái≤ desired.
Routines║ MOVEB, MOVEBC, HMOVB, HMOVBC
Function║ Memory move routines
Entry: HL = pointer to first byte of source buffer
DE = pointer to first byte of destination buffer
BC (MOVEBC & HMOVBC) = number of bytes to move
B (MOVEB & HMOVB) = number of bytes to move
Exit: H╠ á(HMOV┬ ª HMOVBC⌐ ╜ pointe≥ t∩ bytσ afte≥ álas⌠ ì
ááááááááááááááásource
D┼ á(HMOV┬ ª HMOVBC⌐ ╜ pointe≥ t∩ bytσ afte≥ álas⌠ ì
ááááááááááááááádestination
Affected: HL¼ DE (HMOVB & HMOVBC only)
Usage: Move≤ thσ blocδ oµ memor∙ specifieΣ b∙ thσ ásourcσ ì
áááááááááááááááaddres≤ t∩ thσ specifieΣ destinatioε memor∙ álocßì
ááááááááááááááátion« MOVE┬ caε movσ u≡ t∩ ß 25╢-bytσ buffer¼ anΣ ì
áááááááááááááááMOVEB├ caε movσ u≡ t∩ ß 65,53╢-bytσ buffer« MOVE┬ ì
áááááááááááááááanΣ áMOVEB├ áhavσ án∩ effect≤ áoε áan∙ áregisters« ì
áááááááááááááááHMOV┬ anΣ HMOVB├ botΦ affec⌠ thσ H╠ registe≥ pair¼ ì
áááááááááááááááanΣ áthe∙ áreturε witΦ H╠ anΣ D┼ pointinτ át∩ áthσ ì
ááááááááááááááábytσ afte≥ thσ las⌠ bytσ moved« HMOV┬ anΣ HMOVB├ ì
áááááááááááááááarσ áusefu∞ wheε furthe≥ processinτ froφ thσ álas⌠ ì
ááááááááááááááápoin⌠ filleΣ i≤ desired.
.paè Routine║ PAUSE
Function║ Delay routine
Entry: HL = number of 10ths of a second delay desired
B = processor speed in MHz (1¼ 2¼ 3¼ ...)
Exit: None
Affected: None
Usage: Fo≥ delay≤ froφ onσ t∩ 65,53╢ tenth≤ oµ ß ásecond« ì
áááááááááááááááCalculation≤ arσ approximatσ anΣ depenΣ oε accuraì
ááááááááááááááác∙ áoε áclocδ specificatioε anΣ ánumbe≥ áoµ áclocδ ì
ááááááááááááááácycle≤ ápe≥ opcodσ iε thσ dela∙ code« á(i.e.¼ áthσ ì
áááááááááááááááZ180/6418░ executσ iε fewe≥ clocδ cycle≤ thaε áthσ ì
áááááááááááááááZ80).
Routine║ VERSION
Function║ Version number of SYSLIB
Entry: None
Exit: HL = version (H=major, L=minor); H=4, L=2 for 4.2
Affected: HL
Usage: Return≤ áthσ álibrar∙ versioε áanΣ áidentificatioε ì
ááááááááááááááátex⌠ string.
.paè