Anda di halaman 1dari 23

1

8086/8088 MICROPROCESSOR INT 21h FUNCTIONS INT 21h - The general function despatcher
Most of the general fun t!ons an" ser#! es offere" $% &OS are !'(le'ente" through th!s !nterru(t ) The fun t!ons a#a!la$le are *ell stan"ar"!se" an" shoul" $e o''on to all MS&OS+ PC&OS an" &OS Plus s%ste's) ,ell $eha#e" (rogra's+ therefore+ shoul" use these fa !l!t!es !n (referen e to an% other 'etho"s a#a!la$le for the *!"est range of o'(at!$!l!t%) INT 21h !n the -12.s !'(le'entat!on of &OS Plus 2)1 (ro#!"es // off! !al fun t!ons+ t*o of *h! h are non0fun t!onal an" return *!th no a t!on) ,!th!n th!s range so'e alls ha#e su$fun t!ons *h! h further e1ten" the range of o(erat!ons) In all alls+ on entr% 23 "ef!nes the fun t!on) Other (ara'eters 'a% also $e re4u!re" !n other reg!sters) ,here a 'e'or% $lo 5 !s use" $% the all th!s !s s(e !f!e" !n the nor'al seg'ent6offset for') In all ases the general (rogra''!ng te hn!4ue !s to set 23 to the fun t!on (o!nter+ set u( the re4u!re" reg!ster ontents 7an" the 'e'or% $lo 5 !f ne essar%8 then to !ssue the all $% the asse'$l% o"e INT !nstru t!on) To all the re o''en"e" (rogra' ter'!nate rout!ne+ INT 21h fun t!on 9Ch+ the rele#ant (arts of the o"e *oul" $e6
; Constant equates Prog_exit Function_despatcher equ 4ch equ 21h org 0100 program code here ....... ....... ....... mov mov int ; varia#le data !eturn_code '(% d# $ al ah !eturn_code Prog_exit ; common program exit ; set up result ; "et up terminate ; process ; and leave ; %e&ault 0 success ; set value on &ailure

exit: point

Function_despatcher

There are other 'etho"s of !'(le'ent!ng INT alls+ $ut the% are not re o''en"e" as nor'al te hn!4ues an" are less eff! !ent) The t*o 'ost l!5el% to $e en ountere" are !n lu"e" here onl% for !nfo'at!on) 1) Sett!ng u( the entr% on"!t!ons an" e1e ut!ng a long all to 00-0h !n the PSP 7onl% *or5s !n &OS #)2:8) 2) ;oa"!ng the C; reg!ster *!th the fun t!on nu'$er an" e1e ut!ng an !ntra0sg'ent all to offset 00-0h !n the PSP+ *h! h onta!ns a long all to the fun t!on "es(at her) Th!s 'etho" onl% *or5s for fun t!on alls of 29h or less+ an" has the further "!sa"#antage that the ontents of reg!ster 2< are al*a%s "estro%e") If alls are 'a"e $% the a((ro#e" 'etho" the ontents of all reg!sters are (reser#e" through alls+ e1 e(t *here those reg!sters are use" to return results) The o$#!ous e1 e(t!on to th!s !s fun t!on 9=h+ E<EC+ *h! h transfers ontrol to a s(a*ne" (rogra'+ *hen the state of all reg!sters e1 e(t the !nstru t!on (o!nters+ $ut !n lu"!ng the sta 5 (o!nters+ shoul" $e treate" as un"ef!ne" unless s(e !f! returne" #alues are e1(e te") If s(a*n!ng !s e'(lo%e" reg!ster ontents *h! h 'ust $e $e (reser#e" shoul" $e (ushe" onto the sta 5+ an" the sta 5 reg!sters the'sel#es 7!)e) SS6SI8 shoul" $e sa#e" !n 5no*n 'e'or% lo at!ons for e1(l! !t later retr!e#al) INT 21h fun t!ons 00h to 29h are $ase" on an" are+ *!th a fe* e1 e(t!ons+ "!re t e4u!#alents to the orres(on"!ng CP/M alls) In these alls su ess or fa!lure !s t%(! all% s!gnalle" $% the #alue returne" !n reg!ster 2;) For the re'a!n!ng 7!)e) MS&OS8 alls+ the arr% flag !s 'ore usuall% use"+ arr% lear

!n"! at!ng su ess+ arr% set !n"! at!ng fa!lure of the fun t!on+ often a o'(an!e" $% an error o"e !n reg!ster 2<) Fun t!ons u( to an" !n lu"!ng -/h are "o u'ente" !n th!s se t!on+ all INT 21h fun t!ons *!th a h!gher nu'$er a((l%!ng to later #ers!ons of &OS than 2)11) Note that fun t!ons >2h+ >9h an" -0h an" a$o#e are !n lu"e"+ though the% are not su((orte" $% &OS Plus+ $e ause these "o o ur !n MS&OS #ers!on 2)0 an" a$o#e+ an" '!ght $e en ountere" !n MS&OS #2)0 (rogra's) Function 0- Program terminate Action: On e1e ut!on the all restores #e tors for INTS 22h to 29h fro' the PSP+ flushes an% $uffers an" transfers ontrol to the ter'!nate han"ler a""ress) On entry: 23 ? 0 CS ? Seg'ent a""ress of PSP eturns: Noth!ng Notes: E4u!#alent of CP/M =&OS all 00h) INT 21h fun t!on 9Ch !s (referre") Function 1- !haracter input "ith echo Action: Rea"s a hara ter fro' the stan"ar" !n(ut "e#! e an" e hoes !t to the stan"ar" out(ut "e#! e) If no hara ter !s rea"% !t *a!ts unt!l one !s a#a!la$le) I/O an $e re0"!re te"+ $ut (re#ents "ete t!on of OEF) On entry: 23 ? 01h eturns: 2; ? 8 $!t "ata !n(ut Notes: E4u!#alent to CP/M =&OS all 01h+ e1 e(t that !f the hara ter !s CTR;0C an INT 2>h !s (erfor'e") Function 2 - !haracter output Action: Out(uts a hara ter to the stan"ar" out(ut "e#! e) I/O an $e re0"!re te"+ $ut (re#ents "ete t!on of ."!s full.) On entry: 23 ? 02h &; ? 8 $!t "ata 7usuall% 2SCII hara ter8 eturns: Noth!ng Notes: Function #- Au$iliary input Action: Rea"s a hara ter fro' the urrent au1!ll!ar% "e#! e) On entry: 23 ? 0>h eturns: 2; ? 8 $!t "ata !n(ut Notes: There !s no *a% to rea" the status of the ser!al (ort or to "ete t errors through th!s all+ therefore 'ost PC o''s (a 5ages "r!#e the har"*are "!re tl%+ hen e the!r general !n o'(at!$!l!t% *!th the -12) Function %- Au$iliary output Action: Out(uts a hara ter to the urrent au1!l!ar% "e#! e) On entry: 23 ? 09h &; ? 8 $!t "ata eturns: Noth!ng Notes: There !s no *a% to rea" the status of the ser!al (ort or to "ete t errors through th!s all) Co''ents as Fun t!on >) Function &- Printer output Action: Sen"s a Chara ter to the urrent l!st!ng "e#! e) On entry: 23 ? 0-h &; ? 8 $!t "ata eturns: Noth!ng Notes: If the (r!nter !s $us% th!s all *!ll *a!t unt!l the "ata !s sent) There !s no *a% to (oll the (r!nter status !n &OS) Function '- (irect console I)O Action: Rea"s a hara ter fro' the stan"ar" !n(ut "e#! e or returns @ero !f no hara ter a#a!la$le)

>

2lso an *r!te a hara ter to the urrent stan"ar" out(ut "e#! e) I/O an $e re"!re te" $ut (re#ents "ete t!on of EOF on !n(ut or ."!s full. on out(ut) On entry: 23 ? 06h &; ? fun t!on re4ueste"6 0Ch to 0FEh ? out(ut 7&; ? hara ter to $e out(ut8 0FFh ? In(ut re4uest eturns: If out(ut 0 noth!ng If !n(ut 0 "ata rea"%6 @ero flag lear+ 2; ? 8 $!t "ata If "ata not rea"%6 @ero flag set Notes: Th!s all !gnores CTR;0<) Function * - +nfiltered character input no echo Action: Rea"s a hara ter fro' the stan"ar" !n(ut "e#! e *!thout e ho!ng !t to the "!s(la%) If no hara ter !s rea"% !t *a!ts unt!l one !s a#a!la$le) On entry: 23 ? 0/h eturns: 2; ? 8 $!t "ata !n(ut Notes: Th!s all !gnores CTR;0C+ use fun t!on 8 !f CTR;0C (ro ess!ng !s re4u!re") There !s no CP/M e4u!#alent) Function 0,- !haracter input "ith no echo Action: Rea"s a hara ter fro' the stan"ar" !n(ut "e#! e *!thout o(%!ng !t to the "!s(la%) If no hara ter !s rea"% !t *a!ts unt!l one !s a#a!la$le) On entry: 23 ? 08h eturns: 2; ? 8 $!t "ata !n(ut Notes: If CTR;0C !s "ete te" INT 2>h !s e1e ute") Function 0-- Output character string Action: ,r!tes a str!ng to the "!s(la%) On entry: 23 ? 0Ah &S6&< ? seg'ent6offset of str!ng eturns: Noth!ng Notes: The str!ng 'ust $e ter'!nate" $% the B hara ter 729h8+ *h! h !s not trans'!tte") 2n% 2SCII o"es an $e e'$e""e" *!th!n the str!ng) Function 0Ah - .uffered input Action: Rea"s a str!ng fro' the urrent !n(ut "e#! e u( to an" !n lu"!ng an 2SCII arr!age return 70&h8+ (la !ng the re e!#e" "ata !n a user0"ef!ne" $uffer In(ut an $e re "!re te"+ $ut th!s (re#ents "ete t!on of EOF On entry: 23 ? 02h &S6&< ? seg'ent6offset of str!ng $uffer eturns: Noth!ng Notes: The f!rst $%te of the $uffer s(e !f!es the 'a1!'u' nu'$er of hara ters !t an hol" 71 to 2--8) Th!s #alue 'ust $e su((l!e" $% the user) The se on" $%te of the $uffer !s set $% &OS to the nu'$er of hara ters a tuall% rea"+ e1 lu"!ng the ter'!nat!ng RETURN) If the $uffer f!lls to one less than !ts 'a1!'u' s!@e the $ell !s soun"e" an" su$se4uent !n(ut !s !gnore") If a CTR;0C !s "ete te" an INT 2>h !s e1e ute") Nor'al &OS 5e%$oar" e"!t!ng !s su((orte" "ur!ng !n(ut Function 0.h - /et input status Action: Che 5s *hether a hara ter !s a#a!la$le fro' the stan"ar" !n(ut "e#! e) In(ut an $e re"!re te" On entry: 23 ? 0=h eturns: 2; ? 0 !f no hara ter a#a!la$le 2; ? 0FFh !f hara ter a#a!la$le

Notes:

Notes6 !f an !n(ut hara ter !s *a!t!ng th!s fun t!on ont!nues to return a true flag unt!l the hara ter !s rea" $% a all to fun t!on 1+ 6+ /+ 8 or 02h) Function 0!h - eset input 0uffer and input Action: Clears the stan"ar" !n(ut $uffer then !n#o5es one of the stan"ar" !n(ut fun t!ons) On entry: 23 ? 0Ch 2; ? nu'$er of !n(ut fun t!on to $e !n#o5e"+ *h! h 'ust $e 1+ 6+ /+ 8 or 02h) eturns: If fun t!on 02h 0 Noth!ng If fun t!on 1+ 6+ /+ or 8 then 2; ? 8 $!t "ata Notes: The (ur(ose of th!s fun t!on !s to !gnore an% t%(e0ahea" "ata an" for e a *a!t for ne* hara ter !n(ut *h! h 'ust o ur after the all !s !ssue") Function 0(h - (isc reset Action: Flush all outstan"!ng f!le $uffers $% (h%s! all% u("at!ng to "!s ) On entry: 23 ? 0&h eturns: Noth!ng Notes: Th!s all "oes not u("ate "!s "!re tor!es for an% o(en f!les) If the (rogra' fa!ls to lose f!les $efore the "!s !s re'o#e" an" the f!les ha#e hange" s!@e+ the!r "!re tor% entr!es *!ll $e !n orre t) Function 01h - 2et default disc dri3e Action: Sets the s(e !f!e" "r!#e to $e the "efault "r!#e an" returns the total nu'$er of log! al "r!#es !n the s%ste') On entry: 23 ? 0Eh &; ? "r!#e o"e 726 ? 0+ =6 ? 1+ et 8 eturns: 2; ? the nu'$er of log! al "r!#es !n the s%ste') Notes: In the -12.s &OS Plus 72)18 th!s all al*a%s returns f!#e as the nu'$er of log! al "r!#es+ though a 'a1!rnu' of four are su((orte") Function 0Fh - Open a file Action: O(ens a f!le an" 'a5es !t a#a!la$le for rea"/*r!te o(erat!ons) On entry: 23 ? 0Fh &S6&< ? seg'ent6offset of the f!le ontrol $lo 5 7FC=8 eturns: 2; ? 0 !f f!le foun" 2; ? FFh !f f!le not foun" Notes: Th!s all re4u!res a user allo ate" 'e'or% ontrol $lo 5) If the all !s su essful the FC= "ata !s f!lle" $% &OS) Function 10h - !lose file Action: Closes a f!le an" u("ates the "!re tor% !f the f!le has $een 'o"!f!e") On entry: 23 ? 10h &S6&< ? Seg'ent offset of the FC= for the f!le eturns: 2; ? 0 !f "!re tor% u("ate" su essfull% 2; ? 0FFh !f f!Ie not foun" !n "!re tor% Notes: Th!s all 'a% onl% $e use" after a f!le has $een su essfull% o(ene" an" an FC= reate") Function 11h - Find first file Action: Sear h for a s(e !f!e" f!lena'e !n the urrent "!re tor% of the urrent "r!#e) On entry: 23 ? 11h &S6&< ? Seg'ent6offset of the FC= eturns: 2; ? 0 !f 'at h!ng f!lena'e foun" 2; ? 0FFh !f no 'at h!ng f!le foun" Notes: It !s !'(ortant to use INT 21h fun t!on 12h to set the &T2 to a $uffer of a"e4uate s!@e $efore us!ng th!s all) In MS&OS #2 onl% the .C. *!l" ar" !s (er'!tte") If *!l" ar"s are s(e !f!e" the f!rst 'at h!ng na'e !s returne") If an e1ten"e" FC= !s use"+ an attr!$ute $%te "eter'!nes the t%(e of f!les sear he" for) INT 21h fun t!on 9Eh !s (referre" to th!s all)

Function 12h - Find ne$t file Action: Sear hes the urrent "!re tor% !n the urrent "r!#e for the ne1t 'at h!ng f!lena'e after a (re#!ousl% su essful all to fun t!on 11h) On entry: &S6&< ? seg'ent6offset of the FC= eturns: 2; ? 0 !f 'at h!ng f!lena'e foun" 2; ? 0FFh !f no 'at h!ng f!le foun" Notes: 2s for Fun t!on 11h) Fun t!on 9Fh !s (referre") Function 1#h - (elete file Action: &eletes all 'at h!ng f!les fro' the urrent "!re tor%) On entry: 23 ? 1>h &S6&< ? Seg'ent6offset of the FC= eturns: 2; ? 0 !f 'at h!ng f!e7s8 "elete" 2; ? 0FFh !f no 'at h!ng f!le foun" or all 'at h!ng f!les are rea"0onl%) Notes: The .C. *!l" ar" !s (er'!tte") If 'ore than one 'at h o urs all 'at he" f!lena'es *!ll $e "elete") Function 1%h - 2e4uential read Action: Rea"s the ne1t se4uent!al $lo 5 of "ata fro' a f!le an" !n re'ents the f!le (o!nter) On entry: 23 ? 19h &S)&< ? Seg'ent6offset of (re#!ousl% o(ene" FC= eturns: 2; ? 0 !f su essful 2; ? 1 !f en" of f!le rea he" 2; ? 2 !f seg'ent *ra( o urs 2; ? > !f (art!al re or" rea" at en" of f!le Notes: The re or" !s rea" !nto 'e'or% at the &T2 a""ress s(e !f!e" $% the 'ost re ent all to fun t!on 12h) The s!@e of the $lo 5 rea" !s !s s(e !f!e" $% the re or" s!@e f!el" !n the FC=) Function 1&h - 2e4uential "rite Action: ,r!tes the ne1t se4uent!al $lo 5 of "ata to a f!le an" !n re'ents the f!le (o!nter) On entry: 23 ? 1-h &S)&< ? Seg'ent6offset of (re#!ousl% o(ene" FC= eturns: 2; ? 0 !f su essful 2; ? 1 !f "!s full 2; ? 2 !f seg'ent *ra( o urs Notes: The re or" !s *r!tten fro' 'e'or% at the &T2 a""ress s(e !f!e" $% the 'ost re ent all to fun t!on 12h) The s!@e of the $lo 5 *r!tten !s s(e !f!e" $% the re or" s!@e f!el" !n the FC=) Function 1'h - !reate or truncate file Action: Creates a ne* entr% !n the urrent "!re tor% for the na'e" f!le+ or trun ates the length of an e1!st!ng f!le of the g!#en na'e to @ero length) The f!le !s o(ene" for rea"/*nte a ess) On entry: 23 ? 16h &S6&< ? seg'ent6offset of uno(ene" FC= eturns: 2; ? 00h !f su essful 2; ? 0FFh !f unsu essful 7"!re tor% full8 Notes: Notes6 Th!s all !s the e4u!#alent of .OPENOUT. !n ==C =2SIC an" shoul" $e use" *!th are) =% us!ng an e1ten"e" PC= an" sett!ng the a((ro(r!ate $!t the o(ene" f!le 'a% $e ass!gne" an attr!$ute) To reate f!les !n other "!re tor!es use fun t!on >Ch) Function 1*h- ename file Action: Rena'es all 'at h!ng f!les !n the urrent "!re tor% On entry: 23 ? 1/h &S6&< ? Seg'ent6offset of s(e !al FC= eturns: 2; ? 0 !f su essful 2; ? 0FFh !f no 'at h foun" or ne* f!lena'e alrea"% e1!sts Notes:

Function 1,h - eser3ed Function 1-h - /et default disc dri3e Action: Returns the "r!#e o"e of the urrent or "efault "r!#e) On entry: 23 ? 1Ah eturns: 2; ? "r!#e o"e 70 ? 26+ 1 ? =6 et 8 Notes: So'e &OS fun t!ons use "r!#e o"es start!ng at 1 7e)g) fun t!on 1Ch8 reser#!ng @ero for the urrent "n#e) Function 1Ah - 2et disc transfer area address Action: S(e !f!es the 'e'or% area to $e use" for su$se4uent FC= o(erat!ons) On entry: 23 ? 12h &S6&< ? Seg'ent6offset of &T2 eturns: Noth!ng Notes: If th!s fun t!on !s not use" $% a (rogra'+ the &T2 "efaults to a 128 $%te $uffer !n the PSP at 080h+ the area use" to hol" the or!g!nal o''an" ta!l+ *h! h *!ll then $e "estro%e" $% an% "!s a t!#!t%) It !s the (rogra''er.s res(ons!$!l!t% to ensure that the &T2 !s large enough for an% rele#ant "!s o(erat!on) The onl% e1 e(t!on !s that &OS *!ll a$ort an% transfer *h! h *oul" *ra( aroun" *!th!n the seg'ent) Th!s fun t!on must $e alle" $efore us!ng fun t!ons 11h+ 12h+ 19h or 9Fh+ to ensure that &OS has a large enough s rat h area *hen sear h!ng "!re tor!es) Function 1.h - /et current dri3e allocation data Action: O$ta!ns sele te" !nfor'at!on a$out the urrent "!s "r!#e an" a (o!nter to the !"ent!f! at!on $%te of the F2T) On entry: 23 ? 1=h eturns: If su essful 2; ? Nu'$er of se tors (er luster &S6=< ? Seg'ent6offset of F2T !"ent!f! at!on $%te C< ? S!@e !n $%tes of (h%s! al "!s se tor &< ? Nu'$er of lusters for the "r!#e If unsu essful 7!n#al!" "r!#e8 2; ? 0FFh Notes: &S6=< (o!nts onl% to the F2T !nfor'at!on $%te) To rea" the ontents of the F2T !nto 'e'or% use INT 2-h) To o$ta!n !nfo'at!on a$out "!s s other than the "efault "r!#e use fun t!on 1Ch) See also fun t!on >6h *h! h returns s!'!lar "ata) Function 1!h - /et alloc5 data for specified dri3e Action: 2 t!on6 2s for Fun t!on 1=h+ $ut an% "r!#e an $e s(e !f!e") On entry: 23 ? 1Ch &; ? &r!#e o"e 7NOTE 0 ? urrent+ 1 ? 26+ 2 ? =68 eturns: If su essful 2; ? Nu'$er of se tors (er luster &S)=< ? Seg'ent6offset of F2T !"ent!f! at!on $%te C< ? S!@e !n $%tes of (h%s! al "!s se tor &< ? Nu'$er of lusters for the s(e !f!e" "r!#e If unsu essful 7!n#al!" "r!#e or r!t! al error8 2; ? 0FFh Notes: E1 e(t for the a$!l!t% to s(e !f% a "r!#e th!s all !s the e4u!#alent of Fun t!on 1=h) Functions 1(h to 20h - eser3ed Function 2lh - andom read Action: Rea"s a sele te" re or" fro' an o(ene" f!le) On entry: 23 ? 21h &S6&< ? Seg'ent6offset of (re#!ousl% o(ene" FC= eturns: 2; ? 0 !f su essful 2; ? 1 !f en" of f!le rea he"

2; ? 2 !f seg'ent *ra( o urs 2; ? > !f (art!al re or" rea" at en" of f!le Notes: The re or" !s rea" !nto 'e'or% at the &T2 a""ress s(e"f!e" $% the 'ost re ent all to Fun t!on 12h) The s!@e of the $lo 5 rea" !s s(e !f!e" $% the re or" s!@e f!el" !n the FC=) If the s!@e of the &T2 an" the re or" are su h that seg'ent *ra( o urs+ the all fa!ls *!th a return o"e of 2) If a (art!al re or" rea" o urs the re'a!n!ng s(a e !s (a""e" *!th @eros) The urrent f!le (o!nter !s not a"#an e" after th!s fun t!on) Function 22h - andom "rite Action: On entry: 23 ? 22h &S6&< ? Seg'ent6offset of (re#!ousl% o(ene" FC= eturns: 2; ? 0 !f su essful 2; ? 1 !f "!s full 2; ? 2 !f seg'ent *ra( o urs Notes: The re or" !s *r!tten fro' 'e'or% at the &T2 a""ress s(e !f!e" $% the 'ost re ent all to Fun t!on 12h) The s!@e of the $lo 5 *r!tten !s s(e !f!e" $% the re or" s!@e f!el" !n the FC=) If the s!@e of the re or" an" the lo at!on of the &T2 are su h that seg'ent *ra( o urs+ the all fa!ls *!th a return o"e of 2) Function 2#h - /et file si6e in records Action: Returns the re or" ount of a 'at h!ng f!le) On entry: 23 ? 2>h &S6&< ? Seg'ent6offset of uno(ene" FC= eturns: 2; ? 0 !f 'at h!ng f!le foun" 2; ? 0FFh !f no 'at h!ng f!le foun" Notes: =efore us!ng th!s all %ou 'ust set an a((ro(r!ate re or" s!@e !n the FC=.s re or" s!@e f!el") 2fter the all the ran"o' re or" f!el" !s set to the re or" ount of the s(e !f!e" f!le) Function 2%h - 2et random record num0er Action: Sets the ran"o' re or" f!el" of an FC= to orres(on" to the urrent f!le (os!t!on as re or"e" !n the o(ene" FC=) On entry: 23 ? 29h &S6&< ? seg'ent6offset of (re#!ousl% o(ene" FC= eturns: Noth!ng) The ran"o' re or" f!el" !n the FC= !s u("ate" Notes: Th!s fun t!on !s use" to hange fro' se4uent!al to ran"o' I/O f!le a ess) Function 2&h - 2et interrupt 3ector Action: In!t!al!ses an !nterru(t #e tor to (o!nt to the su((l!e" a""ress) On entry: 23 ? 2-h 2; ? Interru(t nu'$er &S6&< ? seg'ent6offset of ne* #e tor a""ress eturns: Noth!ng Notes: Th!s !s the a((ro#e" *a% to a'en" !nterru(t #e tor ontents) =efore hang!ng the ontents of a #e tor+ Fun t!on >-h shoul" $e use" to o$ta!n the or!g!nal entr%+ *h! h shoul" $e re0!nstate" *hen %our o"e ter'!nates) The onl% e1 e(t!ons to th!s rule are !nterru(t #e tors 22h to 29h+ *h! h are auto'at! all% restore" fro' the PSP on (rogra' ter'!nat!on) Function 2'h - !reate program segment prefi$ Action: Co(!es the PSP of the urrent (rogra' to a s(e !f!e" seg'ent a""ress !n free 'e'or%+ then u("ates the ne* PSP to 'a5e !t usa$le $% a ne* (rogra') On entry: 23 ? 26h &< ? Seg'ent for ne* PSP eturns: Noth!ng Notes: Th!s all has $een ren"ere" o$solete $% E<EC+ Fun t!on 9=h !n &OS 2)0 an" later an" shoul" no longer $e use")

Function 2*h - andom 0loc7 read Action: Rea"s one or 'ore se4uent!al re or"s fro' an o(en f!le start!ng at the f!le.s urrent re or" (os!t!on On entry: 23 ? 2/h C< ? Nu'$er of re or"s to $e rea" &S)&< ? Seg'ent6offset of (re#!ousl% o(ene" FC= eturns: 2; ? 0 !f all re4ueste" re or"s rea" 2; ? 1 !f en" of f!le 2; ? 2 !f seg'ent *ra( 2; ? > !f (art!al re or" rea" at en" of f!le C< ? 2 tual nu'$er of re or"s rea" Notes: The re or"s are rea" !nto 'e'or% at the &T2 a""ress s(e !f!e" $% the 'ost re ent all to Fun t!on 12h) The s!@e an" nu'$er of $lo 5s rea" !s s(e !f!e" $% the ran"o' re or" an" the re or" s!@e f!el" !n the FC=) If the s!@e an") lo at!on of the &T2 an" the nu'$er of re or"s to $e rea" are su h that seg'ent *ra( o urs+ the all fa!ls *!th a return o"e of 2+ (oss!$l% after rea"!ng one or 'ore re or"s) !f a (art!al re or" rea" o urs at the en" of the f!le the re'a!n!ng re or" s(a e !s (a""e" *!th @eros The ran"o' re or"+ urrent $lo 5 an" urrent re or" f!el"s are u("ate" after th!s fun t!on) The all !s s!'!lar to Fun t!on 21h e1 e(t that 'ult!(le $lo 5s are (er'!tte") Function 2,h - andom 0loc7 "rite Action: ,r!te one or 'ore se4uent!al re or"s to an o(en f!le start!ng at the f!le.s urrent re or" (os!t!on) On entry: 23 ? 28h C< ? Nu'$er of re or"s to $e *r!flen or @ero 7see notes8 &S6&< ? Seg'ent6offset of (re#!ousl% o(ene" FC= eturns: 2; ? 0 !f all re4ueste" re or"s *r!tten 2; ? 1 !f "!s full 2; ? 2 !f seg'ent *ra( C< ? 2 tual nu'$er of *or"s *r!tten Notes: The re or"s are *r!tten fro' 'e'or% at the &T2 a""ress s(e !f!e" $% the 'ost re ent all to Fun t!on 12h) If the s!@e an" lo at!on of the &T2 an" the nu'$er of re or"s to $e *r!tten are su h that seg'ent *ra( o urs the all fa!ls *!th a return o"e of 2+ (oss!$l% after *r!t!ng one or 'ore re or"s) The ran"o' re or"+ urrent $lo 5 an" urrent re or" f!el"s are u("ate" after th!s fun t!on) The all !s s!'!lar to Fun t!on 21h e1 e(t that 'ult!(le re or"s 'a% $e rea") If the all !s e1e ute" *!th @ero !n C< no "ata !s *r!tten+ $ut the f!le length !s set to the #alue !'(l!e" $% the urrent ran"o' re or" f!el" an" the re or" s!@e) Th!s all !s s!'!lar to fun t!on 22h+ e1 e(t that 'ult!(le re or"s 'a% $e *r!tten) Function 2-h - Parse filename Action: Parses a te1t str!ng !nto the #ar!ous f!el"s of an FC=) On entry: 23 ? 2Ah 2; ? flags to ontrol (ars!ng+ as follo*s6 =!t >6 If set+ the e1tens!on f!el" !n an e1!st!ng FC= *!ll $e 'o"!f!e" onl% !f an e1tens!on !s s(e !f!e" !n the str!ng $e!ng (arse") If lear+ the e1tens!on f!el" *!ll al*a%s $e 'o"!f!e") If no e1tens!on !s s(e !f!e" the FC= e1tens!on f!el" *!ll $e set to $lan5s 720h8) =!t 26 !f set+ the f!lena'e f!el" !n an e1!st!ng FC= *!ll $e 'o"!f!e" onl% !f a f!lena'e !s s(e !f!e" !n the str!ng $e!ng (arse") !f lear+ the f!lena'e f!el" *!ll al*a%s $e 'o"!f!e") If no f!lena'e !s s(e !f!e" the FC= f!lena'e f!el" *!ll $e set to $lan5s 720h8) =!t 16 !f set+ the "r!#e I& $%te !n the result!ng FC= *!ll $e 'o"!f!e" onl% !f a "r!#e I& !s s(e !f!e" !n the str!ng $e!ng (arse") !f lear+ the "r!#e I& *!ll al*a%s $e 'o"!f!e") If no "r!#e !s s(e !f!e" the "r!#e I& !n the result!ng FC= *!ll $e set to @ero+ 7"efault8) =!t 06 !f set+ lea"!ng se(arators *!ll $e !gnore")

&S6SI ? Seg'ent6offset of te1t str!ng ES6&I ? Seg'ent6offset of FC= eturns: 2; ? 0 !f no glo$al 7*!l" ar"8 hara ters en ountere" 2; ? 1 !f (arse" str!ng onta!ns glo$al hara ters 2; ? 0FFh !f "r!#e s(e !f!er !s !n#al!" &S6SI ? Seg'ent6offset of f!rst hara ter after (arse" na'e ES6&I ? Seg'ent6offset of for'atte"+ uno(ene" FC= Notes: Per'!tte" se(arators are6 0 6 ) D + ? : T2= an" SP2CE The all regar"s all ontrol hara ters+ the a$o#e se(arators 7*hen tra!l!ng8 an" E F I / G H an" H as tern!nat!ng hara ters) If no #al!" f!lena'e !s (resent the ontents of ES6&I:1 !s a $lan5) If a .I. o urs !n an e1tens!on+ !t an" all re'a!n!ng hara ters !n the FC= are set to .C.) Th!s fun t!on 7an" FC=s !n general8 annot $e use" *!th f!le s(e !f! at!ons *h! h !n lu"e a (ath) Function 2Ah - /et system date Action: Returns the s%ste' "a%+ 'onth an" %ear (lus the "a% of the *ee5) On entry: 23 ? 22h eturns: C< ? %ear 71A80 to 20AA8 &3 ? 'onth 71 to 128 &; ? "a% of 'onth71 to >18 2; ? "a% nu'$er !n *ee5 70 to 6 ? Sun"a% to Satur"a%8 Notes: The for'at of the reg!sters returne" $% th!s all !s the sa'e as that re4u!re" $% Fun t!on 2=h) 2lthough sho*n a$o#e as "e !'al #alues for lar!t%+ all #alues are !n he1) Function 2.h - 2et system date Action: Reset the "ate hel" !n the s%ste' lo 5 On entry: 23 ? 2=h C< ? %ear 71A80 to 20AA8 &3 ? 'onth 71 to 128 &; ? "a% of 'onth 71 to >18 eturns: 2; ? 0 !f su essful 2; ? !f !n#al!" "ate su((l!e" 7no hange8 Notes: The s%ste' t!'e of "a% !s unaffe te" $% th!s all) Function 2!h - /et system time Action: Returns the t!'e of "a% as hel" $% the s%ste' lo 5) On entry: 23 ? 2Ch eturns: C3 ? hour70 to 2>8 C; ? '!nute 70 to -A8 &3 ? se on" 70 to -A8 &; ? ent!se on"s 70 to AA8 Notes: The reg!ster for'at returne" $% th!s all !s the sa'e as that re4u!re" $% Fun t!on 2&h) Function 2(h - 2et system time Action: Sets the t!'e of "a% hel" !n the s%ste' lo 5) On entry: 23 ? 2&h C3 ? hour70 to 2>8 C; ? '!nute 70 to -A8 &3 ? se on" 70 to -A8 &; ? ent!se on"s 70 to AA8 eturns: 2; ? 0 !f t!'e reset su essfull% 2; ? 0FFh !f !n#al!" t!'e su((l!e" 7no hange8 Notes: Function 21h - 2et 3erify flag Action: Sets or an els the s%ste' rea" after *r!te #er!f% flag) On entry: 23 ? 2Fh

10

2; ? 0 to turn #er!f! at!on off 2; ? 1 to turn #er!f! at!on on &; shoul" $e set to @ero eturns: Noth!ng Notes: Th!s all !s !nten"e" to (ro#!"e !n rease" "ata !ntegr!t% $% allo*!ng rea" after *r!te #er!f! at!on on all "ata *r!tten to "!s ) It !s the e4u!#alent to the &OS o''an" JERIFK an"+ l!5e the 'anual o''an"+ !s non0 fun t!onal !n &OS Plus 2)1) Function 2Fh - /et (TA address Action: Returns the seg'ent6offset of the urrent &T2 for rea"/*r!te o(erat!ons) On entry: 23 ? 2Fh eturns: ES6=< ? Seg'ent)offset of urrent &T2 Notes: If the &T2 has not $een e1(l! !tl% set !t "efaults to 080h !n the PSP) Function #0h - /et (O2 3ersion Action: Returns the #ers!on nu'$er of the O(erat!ng S%ste') On entry: 23 ? >0h eturns: 2; ? MaLor #ers!on nu'$er 7e)g) 2)10 ? 28 23 ? M!nor #ers!on nu'$er 7e)g) 2)10 ? 02h8 Notes: In the -12 th!s all returns 2)11) Function #1h - Terminate 8 stay resident 97eep: Action: Ter'!nate (rogra' e1e ut!on $ut lea#e 'e'or% allo ate") On entry: 23 ? >1h 2; ? Return o"e &< ? 'e'or% s!@e to $e reser#e" 7!n (aragra(hs8 eturns: Noth!ng Notes: Notes6 TSR (rogra's are usuall% re0entere" $% ha#!ng (re#!ousl% re0"!re te" an !nterru(t #e tor to (o!nt $a 5 !nto the o"e) In th!s *a% the (rogra' 'a% $e re0entere" as a result of nor'al s%ste' a t!#!t%+ or as a result of an e1(l! !t all $% another (rogra') Function #2h - /et disc info 9+ndocumented call: Action: Returns the (o!nter to the s(e !f!e" "!s "r!#e !nfor'at!on $lo 5 On entry: 23 ? >2h &; ? "r!#e nu'$er 70 ? "efault+ 1 ? 26 et 8 eturns: 2; ? 0 !f "r!#e #al!" &S6=< ? seg'ent6offset of "!s5 !nfor'at!on $lo 5 2; ? 0FFh !f !n#al!" "r!#e nu'$er Notes: Th!s all !s unoff! !al an" !s not su((orte" $% &OS Plus) Function ##h /et or set !T ;-. 1A< flag Action: Returns or sets the CTR;0=RE2M a t!on On entry: 23 ? >>h If gett!ng the status of the flag6 2; ? 0 If sett!ng the flag6 2; ? 1 &; ? 0 to turn CTR;0=RE2M he 5!ng off &; ? 1 to turn CTR;0=RE2M he 5!ng on eturns: &; ? 0 !f CTR;0=RE2M he 5!ng off &; ? 1 !f CTR;0=RE2M he 5!ng on Notes: Notes6 Th!s o''an" !s the fun t!onal e4u!#alent of the &OS o''an" =RE2M) ;!5e that o''an"+ !n the -12 th!s all !s non0fun t!onal) Function #%h - Find acti3e 0yte 9+ndocumented: Action: Returns the nu'$er of urrentl% a t!#e (ro esses On entry: 23 ? >9h eturns: ES6=< ? Seg'ent6offset of a t!#e $%te a""ress Notes: Th!s all !s unoff! !al an" !s not su((orte" $% &OS Plus) In MS&OS !t !s 'a!nl% use" $%

11

TRS) Function #&h - /et interrupt 3ector Action: Returns the seg'ent6offset of a no'!nate" #e tor) On entry: 23 ? >-h 2; ? !nterru(t nu'$er eturns: ES6=< ? Seg'ent offset of !nterru(t #e tor ontents Notes: Th!s !s the a((ro#e" *a% to rea" !nterru(t #e tor ontents) The or!g!nal ontents of the #e tor+ after storage+ an $e a'en"e" $% a all to fun t!on 2-h) Function #'h - /et free disc space Action: N!#es the nu'$er of free lusters on a s(e !f!e" "!s ) On entry: 23 ? >6h &; ? &r!#e o"e 70 ? "efault+ 1 ? 26 et 8 eturns: If s(e !f!e" "r!#e #al!"6 2< ? Se tors (er luster =< ? nu'$er of a#a!la$le lusters C< ? $%tes (er se tor &< ? Clusters 7allo at!on un!ts8 (er "r!#e If s(e !f!e" "r!#e !s !n#al!"6 2< ? 0FFFFh Notes: S!'!lar !nfor'at!on !s returne" $% fun t!ons 1=h an" 10h Function #*h- eser3ed Function #,h - /et country information Action: Rea"!ng geogra(h! all% #ar!a$le s%ste' onstants) On entry: 23 ? >8h 2; ? 0 &S)&< ? Seg'ent6offset of a >2 $%te ontrol $lo 5 eturns: If unsu essful Carr% flag set 2< ? Error o"e If su essful the >2 $%te $lo 5 ontents are as follo*s) - $%te urren % s%'$ol a""+ null ter'!nate" 2 $%te thousan"s se(arator+ null ter'!nate" 2 $%te "e !'al se(arator+ null ter'!nate" 2 $%te "ate se(arator+ null ter'!nate" 1 $%te $!t f!el" urren % for'at =!t 06 lear !f urren % s%'$ol (re e"es #alue+ set !f #alue (re e"es urren % s%'$ol =!t 16 lear !f no s(a e $et*een the #alue an" the urren % s%'$ol+ Set !f a s(a e re4u!re" 1 $%te t!'e for'at =!t 06 lear for 12 hour lo 5+ set for 29 hour lo 5 2 *or"s for ase 'a( all a""ress 2 $%tes "ata l!st se(arator+ null ter'!nate" - *or"s reser#e" Notes: Unl!5e !ts MS&OS ounter(art+ th!s all "oes not (er'!t the store" !nfor'at!on to $e a'en"e") Function #-h - !reate su0directory Action: Creates a ne* su$"!re tor% us!ng the s(e !f!e" "r!#e an" (ath "ata) On entry: 23 ? >Ah &S6&< ? Seg'ent6offset of 2SCIIO (ath s(e !f! at!on eturns: Carr%6 lear !f su essful+ set !f unsu essful+ *hen6 2< ? > !f (ath not foun"+ - !f a ess "en!e" Notes: The fun t!on fa!ls !f6 1) 2n% (art of the (athna'e "oes not e1!st) 2) 2 "!re tor% of the sa'e na'e alrea"% e1!sts !n the sa'e (ath) >) The (arent "!re tor% !s the root an" !t !s full)

12

Function #Ah - (elete su0directory Action: &eletes a s(e !f!e" su$"!re tor%) On entry: 23 ? >2h &S6&< ? Seg'ent6offset of 2SCIIO (ath s(e !f! at!on eturns: Carr% lear !f su esful Carr% set !f unsu essful+ *hen6 2< ? Error o"e as follo*s6 >6 (ath not foun" -6 a ess "en!e" 66 urrent "!re tor% 166 "!re tor% onta!ns f!les Notes: The fun t!on fa!ls !f6 1) 2n% (art of the (athna'e "oes not e1!st) 2) The s(e !f!e" "!re tor% !s the ur'nt "!re tor%) >) The s(e !f!e" "!re tor% st!ll onta!ns f!les) Function #.h - 2et current directory Action: Sets the s(e !f!e" "!re tor% to $e the urrent "!re tor%) On entry: 23 ? >=h &S)&< ? Seg'ent6offset of 2SCIIO (ath s(e !f! at!on eturns: Carr% lear !f su essful+ Set !f unsu essful+ *hen6 2< ? Error o"e >6 (ath not foun" Notes: The all fa!ls !f an% (art of the (athna'e "oes not e1!st) Co''onl% the urrent "!re tor% !s as erta!ne" $% a all to fun t!on 9/h+ then store" $% a (rogra' so the or!g!nal urrent "!re tor% an $e reset on o'(let!on of o(erat!ons) Function #!h - !reate or truncate file Action: Creates a ne* entr% !n the s(e !f!e" "!re tor% on the s(e !f!e" "r!#e for the na'e" f!le+ or trun ates the length of an e1!st!ng f!le of the g!#en na'e an" (ath s(e !f! at!on to @ero length) The f!le !s o(ene" for rea"/*r!te a ess an" a 16 $!t han"le !s returne" for future a ess) On entry: 23 ? >Ch C< ? F!le attr!$ute6 0 ? nor'al 1 ? rea" onl%+ 2 ? h!""en+ > ? s%ste' &S6&< ? Seg'ent6offset of 2SCIIO f!le s(e !f! at!on eturns: Carr% lear !f su essful6 2< ? f!le han"le Carr% set !f unsu essful6 2< ? Error o"e as follo*s >6 Path not foun" 96 No han"le a#a!la$le 7too 'an% f!les8 -6 2 ess "en!e" Notes: The fun t!on fa!ls !f6 1) 2n% (art of the (athna'e "oes not e1!st) 2) 2 f!le of the sa'e na'e afrea"% e1!sts !n the sa'e (ath *!th the rea" onl% attr!$ute set) >) The (arent "!re tor% !s the root an" !t !s full) Function #(h - Open file Action: O(ens a f!le !n the s(e !f!e" or "efault "!re tor% on the s(e !f!e" "r!#e for the na'e" f!le) 2 160$!t han"le !s returne" for future a ess) On entry: 23 ? >&h 2; ? a ess 'o"e+ *here6

1>

0 ? rea" a ess 1 ? *r!te a ess 2 ? rea"/*r!te a ess 2ll other $!ts off &S)&< ? Seg'ent6offset of 2SCIIO f!le s(e !f! at!on eturns: Carr% lear !f su essful6 2< ? f!le han"le Carr% set !f unsu essful 2< ? Error o"e as follo*s 26 F!le not foun" >6 Path "oes not e1!st 96 No han"le a#a!la$le 7too 'an% f!les8 -6 2 ess "en!e" 0Ch6 2 ess o"e !n#al!" Notes: 2n% nor'al s%ste' or h!""en f!le *!th a 'at h!ng na'e *!ll $e o(ene" $% th!s fun t!on) On return the rea"/*r!te (o!nter !s set to @ero+ the start of the f!le) The all fa!ls !f6 1) 2n% (art of the (ath "oes not e1!st) 2) 2 rea" onl% f!le !s o(ene" for *r!te or rea"/*r!te a ess) Function #1h - !lose file Action: Closes a su essfull% o(ene" f!le) 2ll $uffers are flushe" to "!s an" the f!le han"le !s free" for re0use) If the f!le *as 'o"!f!e"+ the "ate an" t!'e sta'(s an" the f!le length are u("ate" !n the "!re tor% entr%) On entry: 23 ? >Eh =< ? the f!le han"le eturns: Carr% lear !f su essful+ set !f fa!le"+ *hen 2< ? error o"e 6+ !n#al!" han"le or not o(en Notes: In MS&OS all!ng th!s fun t!on *!th a han"le of @ero loses the stan"ar" !n(ut "e#! eP &OS Plus "oes not suffer fro' th!s $ug) Function #Fh - ead file or de3ice Action: Rea"s a s(e !f!e" nu'$er of $%tes fro' a su essfull% o(ene" f!le or "e#! e) On entry: 23 ? >Fh =< ? F!le han"le C< ? Nurn$er of $%tes to $e rea" &S6&< ? Seg'ent6offset of $uffer area eturns: Carr% lear !f su essful 2< ? nu'$er of $%tes rea" 2< ? 0 'eans that EOF *as alrea"% rea he") Carr% set !f fa!le"+ an" 2< ? Error o"e as follo*s6 -6 2 ess "en!e" 66 In#al!" han"le or not o(en Notes: If rea"!ng frorn a hara ter "e#! e !n oo5e" 'o"e+ a 'a1!'u' of one l!ne *!ll $e rea"+ as a arr!age return 70&h8 !s treate" as a re or" ter'!nator) If the arr% flag !s lear an" 2< !s less than C< a (art!al re or" *as rea" or there *as an error) Function %0h - =rite to file or de3ice Action: Rea"s a s(e !f!e" nu'$er of $%tes fro' a su essfull% o(ene" f!le or "e#! e) On entry: 23 ? 90h =< ? F!le han"le C< ? Nu'$er of $%tes to $e *r!tten &S6&< ? Seg'ent6offset of $uffer area eturns: Carr% lear !f su essful+ *hen 2< ? nu'$er of $%tes *r!tten 2< ? 0 'eans the "!s !s full Carr% set !f fa!le"+ *hen6 2< ? Error o"e as follo*s6

19

-6 2 ess "en!e" 66 In#al!" han"le or not o(en Notes: If the arr% flag !s lear an" 2< !s less than C<+ th!s 'eans that a (art!al re or" *as *r!tten or there *as an error) Function %1h - (elete file Action: &eletes a f!le fro' the s(e !f!e" or "efault "!s an" "!re tor%) On entry: 23 ? 91h &S)&< ? Seg'ent6offset of 2SCIIO f!le s(e !f! at!on eturns: Carr% lear !f su essful+ set !f fa!le"+ *hen 2< ? Error o"e as follo*s6 26 F!le not foun" -6 2 ess "en!e" Notes: Th!s "eletes a f!le $% "elet!ng !ts "!re tor% entr%) The 2SCIIO str!ng s(e !f%!ng the f!le 'a% not !n lu"e *!l" ar"s) The fun t!on fa!ls !f6 1) 2n% (art of the (ath "oes not e1!st) 2) The s(e !f!e" f!le has a rea"0onl% attr!$ute) Function %2h- >o3e file pointer Action: Sets the f!le (o!nter to the s(e !f!e" (os!t!on relat!#e to the start or en" of the f!le+ or to the urrent (o!nter lo at!on) On entry: 23 ? 92h+ 2; ? 'etho" o"e as follo*s) 06 2$solute $%te offset fro' start of the f!le) 72l*a%s :#e "ou$le !nteger8 16 =%te offset fro' urrent lo at!on 7:#e or 0#e "ou$le !nteger8 26 =%te offset fro' the en" of the f!le 7:#e or 0#e "ou$le !nteger8 =< ? F!le han"le C< ? MS= of offset &< ? ;S= of offset eturns: Carr% lear !f su essful &< ? MS= of ne* (o!nter lo at!on 2< ? ;S= of ne* (o!nter lo at!on Carr% set !f fa!le"+ *hen 2< ? Error o"e as follo*s6 16 fun t!on nu'$er !n#al!" 66 !n#al!" han"le or not o(en Notes: The 'etho" o"e "eter'!nes the relat!#e $ase for the (o!nter 'o#e+ *h! h uses a >2 $!t !nteger to set the ne* lo at!on) Metho" 2+ !f alle" *!th an offset of @ero returns the length of the f!le as the ne* (o!nter #alue) Metho" 1 or 2 an set the (o!nter to a lo at!on $efore the start of the f!le+ $ut an error *!ll o ur !f a su$se4uent atte'(t !s 'a"e to use th!s (o!nter lo at!on) For all 'etho"s 7an" results8 the returne" (o!nter lo at!on !s al*a%s an a$solute $%te offset fro' the start of the f!le) Function %#h - /et or set file attri0utes Action: O$ta!ns or sets the attr!$utes of the s(e !f!e" f!le) On entry: 23 ? 9>h 2; ? 0+ get f!le attr!$ute or 2; ? 1+ set f!le attr!$ute C< ? ne* attr!$nte 7*hen 2; ? 18 as follo*s6 $!t - ? ar h!#e $!t 2 ? s%ste' $!t 1 ? h!""en $!t 0 ? rea" onl% &S6&< ? Seg'ent6offset of 2SCIIO f!le s(e !f! at!on eturns: Carr% lear !f su essful+ C< ? attr!$ute 7*hen 2; *as 18 Carr% set !f fa!le"+ 2< ? Error o"e as follo*s6

1-

16 fun t!on o"e !n#al!" 26 f!le not foun" >6 (ath not foun" or f!le not foun" -6 attr!$ute annot $e hange" Notes: Th!s fun t!on annot $e use" to set a f!le.s #olu'e la$el $!t 7>8+ or the su$0"!re tor% $!t 798) These 'a% onl% $e hange" $% us!ng an e1ten"e" EC=) Function %%h- (e3ice dri3er control 9IO!T;: Action: Passes !nfor'at!on "!re tl% $et*een an a((l! at!on an" a "e#! e "r!#er) On entry: 23 ? 99h 2; ? 6 get !n(ut status 2; ? / 0 get out(ut status =< ? han"le eturns: Carr% lear !f su essful 2; ? 06 For "e#! e or out(ut f!le ? Not Rea"%) For !n(ut f!le ? Po!nter at EOF 2; ? FFh6 For "e#! e+ !n(ut or out(ut f!le ? Rea"% Carr% set !f fa!le"+ *hen 2< ? Error o"e as follo*s6 16 2; not 6 or / -6 2 es "en!e" 66 In#al!" han"le or not o(en 0&h6 In#al!" "ata Notes: Th!s all !s a (art!al !'(le'entat!on of the full MS/PC&OS fl!n"!on+ as !t onl% su((orts status he 5ng !n the -12) Function %&h - (uplicate handle Action: Returns a se on" han"le for a f!le or "e#! e *h! h has alrea"% $een su essfull% o(ene") On entry: 23 ? 9-h =< ? e1!st!ng f!le or "e#! e han"le eturns: Carr% lear !f su essful 2< ? ne* han"le Carr% set !f fa!le"+ *hen 2< ? Error o"e as follo*s6 96 No han"le a#a!la$le 66 3an"le !n#al!" or not o(en Notes: If the f!le (o!nter atta he" to one han"le !s !'(l! !tl% 'o#e" $% a see5+ rea" or *r!te+ the (o!nter for the other han"le !s also 'o#e") The (ur(ose of th!s all !s to for e "!re tor% u("at!ng for a f!le *!thout ha#!ng to lose !t 7an" then re0o(en !t8) 2fter o$ta!!"ng the ne* han"le+ the log! al f!le asso !ate" *!th !t !s lose" $% fun t!on >Eh+ for !ng a "!re tor% u("ate+ $ut lea#!ng the or!g!nal han"le a#a!la$le for further !n(ut/out(ut o(erat!ons) Function %'h - Force duplicate of handle Action: N!#en t*o han"les+ 'a5e the se on" refer to the sa'e f!le at the sa'e (o!nt as the f!rst) On entry: 23 ? 96h =< ? f!rst f!le han"le C< ? se on" f!le han"le eturns: Carr% lear !f su essful+ set !f fa!le" *hen 2< ? Error o"e 96 No han"les a#a!la$le 66 In#al!" han"le or not o(en Notes: If the han"le s(e !f!e" !n C< alrea"% refers to an o(en f!le+ that f!le !s lose" $efore th!s fun t!on !s (erfor'e") 2fter the all+ !f the f!le (o!nter atta he" to one han"le !s !'(l! !tl% 'o#e" $% a see5+ rea" or *r!te+ the (o!nter for the other han"le !s also 'o#e") Function %*h - /et current directory Action: O$ta!ns the 2SCIIO str!ng of the urrent "!re tor%.s (ath) On entry: 23 ? 9/h

16

&; ? &r!#e o"e 70 ? "efault+ 1 ? 26+ et 8 &S6SI ? Seg'ent6offset of 69$%te s rat h $uffer eturns: Carr% lear !f su essful+ full "!re tor% (athnarne !s (la e" !n the $uffer) Carr% set !f fa!le" *hen 2< ? Error o"e as follo*s6 96 No han"le a#a!la$le 66 &r!#e s(e !f! at!on !n#al!" Notes: The returne" (athnarne "oes not '"u"e the "r!#e I&+ nor !s !t (ref!1e" *!th a .Q.) It !s ter'!nate" $% a null $%te+ therefore !f th!s all !s !ssue" fro' the root "!re tor%+ the f!rst $%te !n the $uffer *!ll $e @ero) Function %,h - Allocate memory Action: 2llo ates a $lo 5 of 'e'or% an" returns a (o!nter to the start of the area) On entry: 23 ? 98h =< Nu'$er of (aragra(hs of 'e'or% nee"e" eturns: Carr% lear !f su essful *hen 2< ? f!rst seg'ent of allo ate" $lo 5 Carr% set !f fa!le" *hen 2< ? Error o"e as follo*s6 /6 'e'or% ontrol $lo 5s "estro%e" 86 !nsuff! !ent 'e'or%+ =< ? s!@e of largest a#a!la$le $lo 5 Notes: If the all su ee"s 2<60000 (o!nts to the start of the $lo 5) ,hen a COM f!le loa"s+ !t on e(tuall% o*ns all the re'a!n"er of 'e'or% fro' !ts PSP u(*ar"s) Th!s all 'a% $e use" to l!rn!t a (rogra'.s 'e'or% allo at!on to !ts !''e"!ate re4u!re'ents) Function %-h - elease memory Action: Releases 'e'or% to 'a5e !t a#a!la$le to other (rogra's) On entry: 23 ? 9Ah =< ? Ne* re4ueste" $lo 5 s!@e !n (aragra(hs ES ? Start seg'ent of $lo 5 to $e 'o"!f!e" eturns: Carr% lear !f su essful+ set !f fa!le" *hen 2< ? Error o"e as follo*s6 / ? 'e'or% ontrol $lo 5s "estro%e" 8 ? !nsuff! !ent 'e'or% A ? !n orre t seg'ent !n ES =< ? S!@e of largest a#a!la$le $lo 5 Notes: Th!s all 'o"!f!es the s!@e of a $lo 5 of 'e'or% (re#!ousl% allo ate" through Fun t!on 98h) The all must $e use" $% a COM (rogra' to release all unuse" 'e'or% $efore s(a*n!ng $% 'eans of E<EC+ Fun t!on 9=h) E<E (rogra's 'a% also use th!s all) Function %.h - 1$ecute program Action: ;oa"s a (rogra' for e1e ut!on un"er the ontrol of an e1!st!ng (rogra') =% 'eans of alter!ng the INT 22h to 29h #e tors+ the all!ng (rograrn an ensure that+ on ter'!nat!on of the alle" (rogra'+ ontrol returns to !tself) On entry: 23 ? 9=h 2; ? 06 ;oa" an" e1e ute a (rogra' 2; ? >6 ;oa" an o#erla% &S)&< ? seg'ent6offset of the 2SCIIO (athna'e ES6=< ? Seg'ent6offset of the (ara'eter $lo 5 Para'eter $lo 5 $%tes6 0016 Seg'ent (o!nter to en#!''ne'nt $lo 5 20>6 Offset of o''an" ta!l 90-6 Seg'ent of o''an" ta!l 60/6 Offset of the f!rst FC= to $e o(!e" to ne* PSP:-Ch 80A6 Seg'ent of the f!rst FC= 2h0=h Offset of the se on" FC= to $e o(!e" to ne* PSP:6Ch Ch0&h Seg'ent of the se on" FC= eturns: Carr% lear !f su essful) On return all reg!ster ontents are "estro%e"+ !n lu"!ng the sta 5 (o!nters)

1/

Carr% set !f fa!le" *hen 2< ? Error o"e as follo*s6 16 Fun t!on !n#al!" 26 F!le not foun" or (ath !n#al!" -6 2 ess "en!e" 86 Insuff! !ent 'e'or% 02h6 En#!ron'ent !n#al!" 0=h For'at !n#al!" Notes: To (rote t the aller.s reg!ster ontents the% shoul" $e (ushe" on the sta 5 an" the sta 5 (o!nters+ SS6SP store" !n a 5no*n lo at!on $efore the all) On return these shoul" $e retr!e#e" !''e"!atel% *!th !nterru(ts "!sa$le" to (re#ent !nterru(ts o ur!ng $efore sta 5 !ntegr!t% !s rega!ne") The 2SCIIO (athnarne 'ust !n lu"e the "r!#e+ (ath an" f!lena'e of the (rogra' to $e loa"e") The en#!ron'ent $lo 5 'ust $e (aragra(h0al!gne" an" ons!st of one or 'ore 2SCIIO str!ngs+ all ter'!nate" $% an e1tra @ero $%te) Co''an" ta!ls are !n the usual for'at for PSPs+ that !s+ a ount $%te an" the o''an" ta!l ter'!nate" $% a arr!age return+ *h! h !s not !n lu"e" !n the ount) 2ll a t!#e han"les+ "e#! es an" I/O re"!re t!on ass!gn'ents !n the all!ng (rogra' are !nher!te" $% the e1e ute" (rogra') Function %!h - Terminate program "ith return code Action: Ter'!nates e1e ut!on of a (rogra' *!th return to C)**+(%.C)* or a all!ng rout!ne+ (ass!ng $a 5 a return o"e) 2llo ate" 'e'or% !s free"+ #e tors for !nterru(ts 22h to 29h are restore" fro' the PSP an" all f!le $uffers are flushe" to 'e"!a) 2ll f!les are lose" an" "!re tor!es are u("ate") On entry: 23 ? 9Ch 2; ? Return o"e 7Error le#el8 eturns: Noth!ng Notes: Th!s !s the a((ro#e" 'etho" of ter'!nat!ng (rogra' e1e ut!on) It !s the onl% *a% that "oes not rel% on the ontents of an% seg'ent reg!ster an" !s thus the s!'(lest e1!t+ (art! ularl% for E<E f!les) The return o"e an $e !nterrogate" $% a all!ng (rogra' $% 'eans of fun t!on 9&h+ an" $% the $at". f!le o''an"s+ IF ERRORLEVEL) Con#ent!onall% a return o"e of @ero !n"! ates su ess+ an% other #alue fa!lure) Stan"ar" &OS return o"es are6 06 Su essful o(erat!on 16 CTR;0=RE2M ter'!nat!on 26 Cr!t! al error terrn!nat!on >6 Ter'!nate" an" sta%e" res!"ent Return o"e #alues an $e use" at the "!s ret!on of the (rogra''er 7a#o!"!ng o"es 1 to >8+ thus $oth su ess or a *!"e range of fa!lure t%(es 'a% $e !n"! ate" $% #ar%!ng the o"e) For the return of result o"es to the aller $% an E<E e" (rogra' a $etter 'etho" !s to use other reg!sters+ $ut onl% the ontents of reg!ster 2; are s!gn!f! ant to the $at h o''an" '!!)!,'-',) Function %(h - /et return code Action: Use" $% a (arent tas5 to o$ta!n the return o"e of a (rogra' e1e ute" $% a all to fun t!on 9=h) On entry: 23 ? 9&h eturns: 23 ? E1!t t%(e6 0 Nor'al ter'!nat!on 16 CTR;0C ter'!nat!on 26 Ter'!nate" $% r!t! al "e#! e error >6 Ter'!nate" $% a all to fun t!on >1h 2; ? Return o"e Notes: Th!s all !s a .one0shot. fun t!on+ that !s+ !t *!ll %!el" the return o"e of a alle" (rogra' on e onl%)

18

Function %1h - 2earch for first match Action: Sear hes the "efault or s(e !f!e" "r!#e6"!re tor% for the f!rst o urren e of a 'at h!ng f!lena'e) On entry: 23 ? 9Eh eturns: C< ? 2ttr!$ute to use !n sear h &S6&< ? Seg'ent6offset of 2SCIIO f!le s(e !f! at!on Notes: C< ? 0 !f su essful) The urrent &T2 !s f!lle" as follo*s6 =%tes 00206 Reser#e" for use $% &OS !n su$se4uent alls 216 2ttr!$ute of 'at he" f!le 2202>6 F!le t!'e sta'( 2902-6 F!le "ate sta'( 2602/6 least s!gn!f! ant *or" of f!le s!@e 2802A6 Most s!gn!f! ant *or" of f!le s!@e >009266 F!lenarne)e1tens!on !n 2SCIIO str!ng for' Carr% set !f fa!le"+ 2< ? Error o"e as follo*s 02h (ath !n#al!" 12h6 no rnat h!ng "!re tor% entr% Th!s all assu'es the &T2 has heat set u( $% a su essful all to fun t!on 12h) =oth *!l" ar"s 7C an" I8 are (er'!tte" !n f!lena'es+ $ut onl% the f!rst 'at h!ng na'e !s returne") !f the attr!$ute !n C< !s @ero onl% nor'al f!les are sear he") If the #olu'e la$el attr!$ute $!t !s set onl% #olu'e la$els are returne") For all other attr!$ute sett!ngs+ 7!)e+ h!""en+ s%ste' or "!re tor%8 those f!les an" nor'al f!les are sear he" Function %Fh - 2earch for ne$t match Action: Sear hes for the ne1t 'at h!ng f!le after a (re#!ousl% su essful all to Fun t!on 9Eh) On entry: 23 ? 9Fh eturns: Carr% lear !f su essful The urrent &T2 !s f!lle" as follo*s60 =%tes 0020 6 reser#e" for use $% &OS !n su$se4uent alls 216 2ttr!$ute of 'at he" f!le 2202>6 F!le t!'e sta'( 2902-6 F!le "ate sta'( 2602/6 least s!gn!f! ant *or" of f!le s!@e 2802A6 Most s!gn!f! ant *or" of f!le s!@e >00926 F!lenarne)e1tens!on !n 2SCIIO str!ng for' Carr% set !f fa!le"+ 2< ? Error o"e 12h6 no 'at h!ng "!re tor% entr% Notes: ,hen use" th!s all re4u!res a &T2 onta!n!ng returne" "ata fro' a (re#!ousl% su essful all to fun t!on 9Eh or 9Fh) Use of fun t!on 9Fh !s onl% rele#ant *hen the or!g!nal f!le s(e"a at!on use" !n fun t!on 9Eh !n lu"e" at least one *!l" ar") Function &0h - /et disc information 9+ndocumented call: Action: Returns a (o!nter to the "!s !nfor'at!on $lo 5) On entry: 23 ? -0h &; ? "r!#e nu'$er 70 ? "efault+ 1 ? 26 et 8 eturns: 2; ? 0 !f "r!#e e1!sts &S6=< ? Seg'ent6offset of "!s !nfor'at!on $lo 5 2; ? 0FFh !f fa!le" Notes: Th!s all !s unoff! !al an" !s not su((orte" $% &OS Plus) Function &1h - eser3ed Function &2h- eser3ed

1A

Function &#h - eser3ed Function &%h - /et 3erify flag Action: Rea"s the urrent state of the #er!f% flag) On entry: 23 ? -9h eturns: 2; ? 0 !f #er!f% off 2; ? 1 !f #er!f% on Notes: Th!s all !s the ounte(art of fun t!on 2Eh) In &OS Plus 2; !s al*a%s returne" as @ero) Function &&h - eser3ed Fundion &'h - ename file Action: Rena'es a f!le an" or 'o#es !ts "!re tor% entr% to a "!fferent "!re tor% on the "!s ) On entry: 23 ? --h &S6&< ? Seg'ent6offset of urrent 2SCIIO f!lena'e ES6&I ? Seg'ent6offset of ne* 2SCIIO f!lena'e eturns: Carr% lear !f su essful Carr% set !f fa!le"+ 2< ? Error o"e as follo*s6 26 F!le not foun" > 6 (ath not foun" or the f!le "oesn.t e1!st -6 2 ess "en!e" 11h 6 ne* na'e not sa'e "e#! e Notes: The all fa!ls !f6 1) 2n% (art of the (athnarne "oes not e1!st) 2) The ne* f!lena'e refers to a "!fferent "!s ) >) The ne* na'e !s !n the root "!re tor%+ *h! h !s full) 9) 2 f!le *!th the ne* (ath an" na'e alrea"% e1!st) Function &*h - /et or set file date and time Action: On entry: 23 ? -/h =< ? f!le han"le 2; ? 0 to get "ate an" t!'e 2; ? 1 to set "ate an" t!'e C< ? t!'e6 $!ts A00Fh ? hours 7002>8 $!ts -08 ? '!nutes 700-A8 $!ts 009 ? No) of t*o0se on" !n re'ents 7002A8 &< ? "ate) $!ts A 0 ? %ear relat!#e to 1A80 70011A+ !)e) 1A80020AA8 $!ts -08 ? 'onth of %ear71 to 128 $!ts 009 ? "a% of 'onth71 to >18 eturns: Carr% lear !f su essful If gett!ng "ate an" t!'e6 C< ? t!'e 7!n for'at a$o#e8 &< ? "ate 7!n for'at a$o#e8 Carr% set !f fa!le"+ 2< ? Error o"e as follo*s6 1 0 fun t!on o"e !n#al!" 6 0 f!le han"le !n#al!" Notes: The f!le 'ust ha#e $een (re#!ousl% o(ene" or reate" $% a all to fun t!on >Ch or >&h) For s!'(l! !t% the "ate an" t!'e for'ats are sho*n a$o#e !n the se4uen e the% are store" !n the "!re tor%) Th!s o'(letes the l!st of INT 21h fun t!on o"es #al!" !n &OS PIus 2)1) Fun t!ons -8h an" a$o#e are onl% a#a!la$le !n #ers!ons of MS&OS later than 2)11+ an" *!th the e1 e(t!on of fun t!on 6>+ later than #ers!on >)0) Interru(ts 22h through 29 are not user alla$le an" are therefore not "o u'ente") 7See ha(ter 88)

20 NENER2; RU;ES FOR 8086/8088 INSTRUCTIONS 1) 2n !''e"!ate #alue 7!)e)+ a onstant 8 annot $e a "est!nat!on o(eran") For e1a'(le+ the follo*!ng !s !n#al!"6 2&& >9=Fh + =< 2) The "est!nat!on an" sour e o(eran"s 'ust $e of the sa'e s!@e+ e1 e(t !f the sour e o(eran" !s an !''e"!ate #alue of a lo*er s!@e than the "est!nat!on) For e1a'(le+ the follo*!ng !s #al!"6 MOJ 2< + 0>3 >) &!re t 'e'or% to 'e'or% transfer !s !n#al!"+ e1 e(t for str!ng !nstru t!ons) Su h a transfer 'ust $e "one !n"!re tl% us!ng a general reg!ster of the a((ro(r!ate s!@e) For e1a'(le+ !f J2R1 an" J2R2 are *or" #ar!a$les 7!)e)+ *or" 'e'or% o(eran"s8 then the transfer6 MOJ J2R1 + J2R2 !s !n#al!") The transfer an $e "one as6 MOJ 2< + J2R1 MOJ J2R2 + 2< 9) The transfer6 MOV SegmentRegister , SegmentRegister !s !n#al!" for all seg'ent reg!sters6 CS+ &S+ SS+ ES) -) The transfer6 MOV SegmentRegister , ImmediateValue !s !n#al!" for all Seg'ent Reg!sters6 CS+ &S+ SS+ ES) Su h a transfer an $e "one !n"!re tl% us!ng a 160$!t general reg!ster) For e1a'(le+ !f a (rogra' has a "ata seg'ent that !s "ef!ne" $% a s!'(l!f!e" seg'ent "!re t!#e 5&2T2+ the &S reg!ster an $e !n!t!al!@e" $%6 MOJ =<+ R&2T2 MOJ &S+ =< 6) The IP+ CS+ SS+ an" SP reg!sters annot $e "est!nat!on o(eran"s) For e1a'(le+ the follo*!ng !s !n#al!"6 MOJ CS + 2>9SOME 8086 INSTRUCTIONS INSTRUCTION MOJ &est!nat!on + Sour e INC &est!nat!on &EC &est!nat!on 2&& &est!nat!on + Sour e SU= &est!nat!on + Sour e <C3N &est!nat!on + Sour e EFFECT &est!nat!on 6? Sour e &est!nat!on 6? &est!nat!on : 1 7The o(eran" !s treate" as an uns!gne" nu'$er8 &est!nat!on 6? &est!nat!on 0 1 7The o(eran" !s treate" as an uns!gne" nu'$er8 &est!nat!on 6? &est!nat!on : Sour e 7=oth o(eran"s 'a% ha#e s!gne" or uns!gne" nu'$ers8 &est!nat!on 6? &est!nat!on 0 Sour e 7=oth o(eran"s 'a% ha#e s!gne" or uns!gne" nu'$ers8 E1 hanges the ontents of the sour e an" "est!nat!on) =oth Sour e an" &est!nat!on annot $e I''e"!ate o(eran"s)

The INTerru(t Instru t!on INT Interru(tNu'$er *here Interru(tNu'$er ranges fro' 003 to 0FF3 7!)e)+ fro' 0 to 2--8) The e1e ut!on of an INT !nstru t!on auses an Interru(t Ser#! e Rout!ne 7ISR8 asso !ate" *!th the Interru(tNu'$er to $e e1e ute") Man% of the ISRs ha#e 'ult!(le su$fun t!ons) To s(e !f% *h! h su$fun t!on !s to $e e1e ute" un"er a (art! ular Interru(tNu'$er+ the 23 reg!ster !s ass!gne" a su$fun t!on nu'$er $efore the e1e ut!on of the INT !nstru t!on) E1a'(le6 MOJ 23 + 083 INT 213 auses su$fun t!on nu'$er 083 of Interru(t nu'$er 213 to $e e1e ute") In a""!t!on+ so'e su$fun t!ons re4u!re other #alues to $e (asse" to the ISR !n (art! ular reg!sters) E1a'(le6 Su$fun t!on 0A3 of Interru(t 213 "!s(la%s a B0 ter'!nate" str!ng on the s reen) The su$fun t!on re4u!res the offset of that str!ng to $e (asse" !n the &< reg!ster6 MOJ &< + OFFSET STRINN MOJ 23 + 0A3 INT 213 &OS FUNCTION C2;;S 7INT 2138 &OS fun t!on alls (reser#e the ontents of all the reg!sters e1 e(t the 2< reg!ster an" an% other reg!ster or reg!sters !n *h! h the% e1(l! !tl% return "ata)

21 1) TERMIN2TE PRONR2M 2N& RETURN TO &OS 7&OS FUNCTION 9C38 MOJ 23 + 9C3 INT 213 2 o"e of 003 !n the 2; reg!ster !n"! ates nor'al (rogra' ter'!nat!on) Thus the fun t!on !s usuall% !n#o5e" as6 MOJ 2< + 9C003 INT 213 2) C32R2CTER INPUT ,IT3 EC3O 7&OS FUNCTION C2;; 0138 MOJ 23 + 013 INT 213 The code of the input character is returned in the A; register5 C32R2CTER INPUT ,IT3OUT EC3O 7&OS FUNCTION C2;; 0838 MOJ 23 + 083 INT 213 The code of the input character is returned in the A; register5 C32R2CTER OUTPUT 7&OS FUNCTION C2;; 0238 MOJ 23 + 023 MOJ &; + Chara ter or Chara terCo"e INT 213 The f!rst t*o l!nes 'a% $e !nter hange") Note6 One *a% of 'o#!ng the ursor to the $eg!nn!ng of the ne1t out(ut l!ne !s $% out(utt!ng 0&h 7Carr!age Return8 follo*e" $% 02h 7;!ne fee"86 MOJ 23 + 023 MOJ &; + 0&3 INT 213 MOJ &; + 023 INT 213 -) &ISP;2KINN 2 B0TERMIN2TE& STRINN CONT2ININN NO OT3ER B0C32R2CTER 7&OS FUNCTION 0A38 )&2T2 STRINNSN2ME &= TT3E STRINN TO =E &ISP;2KE&U + TBU 5CO&E ))) MOJ 23 + 0A3 MOJ &< + OFFSET STRINNSN2ME INT 213 5 5 5 Note: The ter'!nat!ng B !s not "!s(la%e"+ e#en !f !t a((ears *!th!n the str!ng) Thus th!s fun t!on annot $e use" to "!s(la% the B hara ter on the s reen) The l!nes MOJ 23 + 0A3 an" MOJ &< + OFFSET STRINNSN2ME 'a% $e !nter hange") The OFFSET o(erator returns the offset a""ress of a #ar!a$le or la$el) 2lso the state'ent6 MOJ &< + OFFSET STRINNSN2ME !s e4u!#alent to the state'ent6 ;1A (? @ 2T IN/ANA>1 ;E2 stan"s for ;oa" Effe t!#e 2""ress) If the ter'!nat!ng B !s o'!tte"+ the o(erat!on "!s(la%s hara ters !n the 'e'or%+ after the str!ng+ unt!l !t f!n"s a B hara ter+ !f an%) To 'o#e the ursor to the $eg!nn!ng of the ne1t out(ut l!ne+ after "!s(la%!ng a str!ng+ (ut 0&h an" 02h after the str!ng an" $efore the ter'!nat!ng B) E1a'(le6 PROMPT &= TP;E2SE+ ENTER KOUR N2ME6 U + 0&h + 02h + TBU 2nother *a% of 'o#!ng the ursor to the $eg!nn!ng of the ne1t out(ut l!ne !s to "!s(la% + us!ng &OS fun t!on 0A3+ a str!ng of the for'6 STRINN1 &= 0&h + 02h + TBU

>)

9)

22 6) &ISP;2KINN 2 STRINN ,3IC3 M2K CONT2IN 2 B0C32R2CTER 7&OS FUNCTION 9038 5&2T2 555 STRINNSN2ME &= TT3E STRINN TO =E &ISP;2KE&U STRINN;EN EVU B 0 STRINNSN2ME 555 5CO&E 555 MOJ 23 + 903 MOJ =< + 013 D f!le han"le for the s reen MOJ C< + STRINN;EN D str!ng length MOJ &< + OFFSET STRINNSN2ME INT 213 ))) The EVU "!re t!#e "ef!nes a #alue that the asse'$ler an use to su$st!tute !n other !nstru t!ons) M2SM or T2SM 'a5es t*o (asses through the sour e f!le) On the f!rst (ass+ M2SM or T2SM he 5s for s%nta1 errors an" reates a s%'$ol ta$le of na'es an" the!r relati3e lo at!ons *!th!n a seg'ent) To 5ee( tra 5 of lo at!ons+ !t uses a lo at!on ounter) The lo at!on ounter !s reset to 0 at the $eg!nn!ng of a seg'ent) ,hen an !nstru t!on !s en ountere"+ the lo at!on ounter !s !n rease" $% the nu'$er of $%tes nee"e" for the 'a h!ne o"e of the !nstru t!on) ,hen a na'e !s en ountere"+ !t !s entere" !n the s%'$ol ta$le along *!th the lo at!on ounterUs #alue) 2n o(eran" onta!n!ng a "ollar s%'$ol+ B+ refers to the urrent #alue !n the lo at!on ounter) Thus+ !n the a$o#e e1a'(le B - 2T IN/ANA>1 e#aluates to the nu'$er of $%tes $et*een STRINNSN2ME an" STRINN;EN *h! h !s the nu'$er of $%tes 7!)e)+ hara ters8 !n TT3E STRINN TO =E &ISP;2KE&U

/) =UFFERE& MEK=O2R& INPUT 7RE2&INN 2 STRINN87&OS FUNCTION 0238 7a8 To rea" a str!ng+ a $uffer 7!)e)+ an arra%8 'ust $e "ef!ne" to store that str!ng) One *a% of "ef!n!ng the $uffer !s6 =UFFERSN2ME &= Nu'1 + Nu'2 &UP7C8 *here Num1 !s the 'a1!'u' nu'$er of str!ng hara ters to $e rea" !n lu"!ng the Carr!age Return 70&h8+ *h! h !s also rea" an" store" !n the $uffer as the last str!ng hara ter) Num2 has a #alue *h! h !s one 'ore than Num1C !t !s the nu'$er of $%tes reser#e" to hol" the a tual length of the str!ng 7!)e)+ '!nus the Carr!age Return hara ter8+ the str!ng+ an" the ter'!nat!ng Carr!age Return hara ter) Note6 The 'a1!'u' #alue for Num1 !s FEh !)e)+ 2-9 E1a'(le6 &ef!ne a $uffer alle" =UFFER to store a str!ng of 'a1!'u' length -06 Solut!on6 =UFFER &= -1+ -2 &UP7C8 -2 $%tes -1 -0 $%tes -1 $%tes 2 tual str!ng length !s store" !n th!s $%te 7$8 To rea" a str!ng fro' the 5e%$oar" !nto a $uffer alle" =UFFER as "ef!ne" a$o#e+ *e !n#o5e &OS fun t!on 023 as6 MOJ 23 + 023 MOJ &< + OFFSET =UFFER INT 213 The o(erat!on e hoes the entere" hara ters on the s reen an" a"#an es the ursor) If 'ore hara ters than the s(e !f!e" 'a1!'u' 7!n $%te 08 are entere"+ the s(ea5er $ee(s an" the a""!t!onal hara ters are not rea") 0&h store" !n th!s $%te !f the length of the str!ng !s -0

2> 7 8 &!s(la%!ng a $uffer+ "ef!ne" !n /7a8 $% us!ng &OS fun t!on 9036 MOJ 23 + 903 MOJ =< + 013 MOJ C3 + 003 MOJ C; + =UFFERH1W ;E2 &< + =UFFERH2W INT 213 Note: The state'ent 6 MOJ &< + OFFSET =UFFERH2W !s e4u!#alent to6 ;E2 &< + =UFFERH2W 7"8 =UFFERE& MEK=O2R& INPUT 7RE2&INN 2 STRINN87&OS FUNCTION 02386 2NOT3ER ,2K OF &EFININN T3E =UFFER To rea" a str!ng of + sa%+ 'a1!'u' length -0 the $uffer an $e "ef!ne" as6 M2<;EN &= -1 2CT;EN &= C =UFFER &= -1 &UP7C8 To rea" a str!ng !nto the $uffer+ *e !n#o5e &OS fun t!on 023 as6 MOJ 23 + 023 MOJ &< + OFFSET M2<;EN INT 213 7e8 &!s(la%!ng a $uffer+ "ef!ne" !n /7"8 $% us!ng &OS fun t!on 9036 MOJ 23 + 903 MOJ =< + 013 MOJ C3 + 003 MOJ C; + 2CT;EN ;E2 &< + =UFFER INT 213 D f!le han"le for the s reen D In!t!al!@e C< *!th the str!ng length D D &!s(la% the $uffer D D f!le han"le for the s reen D In!t!al!@e C< *!th the str!ng length D D Out(ut the str!ng start!ng at $%te 2 D

Anda mungkin juga menyukai