Turbï Pascaì foò Ú-System Joå Wright 25 Augusô 89 Turbï Pascaì lendó itselæ verù nicelù tï Systeí-Specifiã programó anä Utilitieó anä especiallù tï thå Ú-System® TURBO.COÍ anä  itó COÍ-pilationó  becomå Ú-Systeí utilitieó bù overlayinç  TURBO.COÍ witè á Ú-Systeí Typå ± header® Uså á Pokå-anä-Gï aliaó like..   1 --> GET 100 TURBO.COM;   2 --> POKE 103 5A 33 45 4E 56 0± 0° 00;   3 --> GO Thå seconä linå oæ thå aliaó ió equivalenô tï thå assemblù code..             org     103h     0103    db      'Z3ENV'     0108    db      1 010¹ d÷ 0 Thió  effectivelù  'installs§ TURBO.COÍ foò  thå  Ú-System®   Thå Commanä Processoò oæ NÚ-COÍ oò Z3PLUÓ (ZCPR34© wilì automaticallù placå thå addresó oæ thå ZCPR³ Environmenô Descriptoò aô locatioî 0109È (GO). Thió ió thå onlù 'change§ tï TURBO.COÍ itself® Alì extensionó tï Turbï  Pascaì  foò  thå Ú-Systeí arå donå  usinç  standarä  Turbï Pascal. Turbï Pascaì haó aî 'absolute§ variablå construcô allowinç uó  tï definå  0109È aó thå 'location§ oæ á variable® Let'ó  namå  thió Z3EADR®   Z3´ haó 'installed§ thå addresó oæ thå  Environmenô  iî thió variable® Thió ió thå onlù hooë wå neeä iî Turbï Pascaì  tï havå   completå   accesó  tï  thå  Ú-Systeí   Environment®    Thå declaration..   VAR     Z3EADR : Integer Absolute $109; doeó  thå  trick® Froí no÷ on¬ referenceó tï Z3EADR  returî  thå addresó  oæ thå currenô Ú-Systeí Environmenô  Descriptor®   Giveî that¬  wå caî find¬ examinå anä manipulatå virtuallù anythinç  iî thå  entirå  systeí witè standarä Turbï Pascaì  Functionó  and/oò Procedures. Wå  wilì uså thå samå construcô tï declarå thå CP/Í variableó  iî Pagå 0. BIOSÖ º Integeò Absolutå $0001; IOBYÔ º Bytå Absolutå $0003; CDISË º Bytå Absolutå $0004; BDOSÖ º Integeò Absolutå $0006; etcetera. Turbï  Pascaì ió incrediblù ricè iî itó owî  intrinsiã  Functionó Šanä Procedures® Iô allowó anä encourageó thå Programmeò (us©  tï tï creatå ne÷ Functionó anä Procedureó oæ ouò own® Iî thió lighô É  havå addeä twï ne÷ Functionó anä onå Procedurå which¬ foò  me¬ makå Turbï Pascaì thå Compleaô Programminç System® HEX¬ GEÔ  anä PUT. Thå  Heø functioî wilì creatå anä returî á Strinç oæ twï oò  fouò Hexadecimaì  characteró  representinç thå Bytå oò  Integeò  valuå passeä tï it® Hex(255,1© returnó FF® Hex(8191,2© returnó 1FFF. Wå musô firsô creatå á Typå identifieò foò thå Strinç useä bù thå Heø function.     type       HEXSTR = String[4] of Char     Function HEX(Number:Integer; Bytes:Integer):HexStr;     const    T : Array[0..15] of Char = '0123456789ABCDEF';     var      D : Integer; H : HexStr;     begin       H[0]     := Chr(2*Bytes);       for D    := 2*Bytes downto 1 do       begin         H[D]   := T[Number and 15];         Number := Number shr 4       end;       Hex := H     end; Thå  Geô functioî returnó thå Integeò aô thå  specifieä  Address® Getó  caî bå nesteä allowinç á forí oæ indirecô addressing®   Foò example¬ wå kno÷ thaô thå addresó oæ thå IOPREÔ jumð tablå iî thå Ú-Systeí bioó ió helä iî thå targeô portioî oæ thå Colä Booô jumð iî thå maiî Bioó jumð table.     Get(1)         returns Bios+3 from page 0.     Get(1)-2       returns Bios+1.     Get(Get(1)-2)  returns the IOPRET address.     Function GET(Address:Integer):Integer;     begin       Get := Mem[Address+1] * 256 + Mem[Address]     end; Thå  Puô  procedurå  wilì  storå aî  Integeò  iî  memorù  aô  thå specifieä  address® Iô caî bå useä witè Geô storå aî Integeò  aô aî  indirecô  location® Foò example¬ wå mighô changå  thå  DRVEÃ entrù iî thå Z³ Environmenô Descriptoò aó follows..     Put(Get($109)+$34,$000F) I'í  surå  Puô  waó  intentionallù lefô  ouô  oæ  Turbï  Pascal'ó standarä functionó becauså iô ió verù dangerous® Impropeò uså oæ Puô caî easilù crasè thå system® Bå careful. Š    Procedure PUT(Address,Number:Integer);     begin       Mem[Address]   := Number;       Mem[Address+1] := Number div 256     end; Turbï  Pascaì  prå-defineó  á standarä arraù  sucè  thaô  wå  caî addresó  anù  giveî  bytå iî memory®   Mem[3Ý  iî  aî  expressioî returnó  thå CP/Í IOBYTÅ froí locatioî ³ iî thå baså  page®   Thå statemenô Mem[3Ý :½ ° wilì placå á zerï iî thå IOBYTE® Likå Put¬ Meí caî bå verù dangerous® Careful. Iô  ió  easù  tï writå Ú-Systeí utilitieó witè  Turbï  Pascaì  bù creatinç  ne÷ functionó anä procedureó whicè dï thå samå  aó  ouò familiaò SYSLIÂ anä Z3LIÂ routines.   Our familiar PHL4HC becomes..     Write(Hex(HL,2))   and PA2HC becomes..     Write(Hex(A,1)) Thå  variablå  HÌ caî bå anù Integeò variablå oò  constant®   Thå variablå Á caî bå anù Byte¬ Chaò oò Integeò variablå oò constant. Functionó anä Procedureó arå botè Subprogramó iî Turbï Pascal® Á Procedurå  ió á separatå subroutinå whicè ió executeä  eacè  timå itó 'statement§ ió encountereä iî anotheò program® Á Functioî ió similaò  excepô  thaô iô returnó á valuå oæ itó  designateä  typå wheneveò  iô ió encountereä iî aî expression® Wå simplù  Telì  á Procedurå  whaô tï do® Wå Telì á Functioî whaô tï dï anä  Asë  iô foò  á Result® Iî BIOÓ terms¬ CONOUÔ ió á Procedurå whilå  CONIÎ ió á Function. Functioî GETQUIET:Boolean» begiî getquieô :½ Boolean(Mem[z3eadr+$28]) end; Beforå  É  geô  boggeä dowî iî thå verù trivial¬ leô  må  makå  á couplå oæ observations® Thå assignmenô oæ variableó tï  absolutå addresseó  ió  usefuì foò thoså systeí variableó thaô  wå  alwayó kno÷ thå addresseó of® Specificallù thoså iî Pagå ° oæ alì  CP/Í systems¬  thå  warí booô vectoò aô 0001H¬ thå  iobytå  aô  0003H¬ cdisë aô 0004h¬ thå bdoó vectoò aô 0006H¬ thå twï fcb'ó aô  005CÈ anä 006CÈ anä thå commanä linå buffeò aô 0080H® Witè  thå Z3EADÒ aô 109È describeä abovå wå caî havå  thå  entirå systeí  naileä down¬ meaninç wå caî finä anythinç  thå  operatinç systeí  can® Oncå assigned¬ theså variableó arå treateä  exactlù aó anù otheò variablå iî Turbï Pascal® Giveî thå Pagå ° variableó (anä thå onå aô 109H© anä á  knowledgå oæ  thå systeí structure¬ wå caî uså Turbï Pascal'ó standarä  Meí Arraù  construcô anä ouò Geô anä Puô derivationó tï  examinå  anä manipulatå thå entirå memorù iî á Bytå anä Integeò manner® Therå Šarå otheò wayó too.. Memorù Method Pointeò Method Recorä Pointeò Method Foò  sakå  oæ description¬ thå foregoinç É wilì calì  thå  Memorù Method® Thå majoritù oæ Ú-Systeí programó merelù examinå oò tesô thå  Environmenô  foò  Quieô oò Prograí Erroò flagó  oò  foò  thå simplå addresseó oæ segments® Thå Memorù Methoä ió sufficienô tï theså tasks. Turbï  Pascaì waó ablå tï definå thå Pagå ° variableó aô  Compilå timå  becauså wå declareä theiò Absolutå addresseó iî thå  sourcå code® Thå addresseó oæ thå Ú-Systeí variableó arå onlù availablå aô Ruî time¬ toï latå foò thå compileò tï figurå iô out® Aô  Ruî time¬  however¬  Turbï Pascaì caî providå  Pointeró  tï  Externaì variableó sï thaô theù caî bå treateä almosô normally. Wå  caî assigî Pointeró tï anù particulaò variableó  oæ  interesô or¬ giveî thå Recorä structure¬ tï variableó withiî thå Record. Firsô thå individuaì Pointeò Method® Wå wilì definå thå Multiplå Commanä Linå strinç aó á Turbï Pascaì strinç variable. type mclstò ½ String[203]; var mcì º ^mclstr; z3cì º Integer; Thå  '^§  careô  iî  thå typå fielä  defineó  MCÌ  aó  á  Pointeò variable® No÷ withiî á prograí oò subprograí wå musô assigî  MCÌ witè thå standarä Ptò procedure. z3cì :½ Get(z3eadr+24); mcì :½ Ptr(z3cl+3); MCÌ ió no÷ á Turbï Pascaì pointeò variable® Iô ió addresseä witè á  '^§  suffiø  aó MCLÞ tï avoiä  typå  conflictó  witè  standarä variables®   WriteLn(MCL^© wilì prinô thå strinç foò us® Wå  caî dï  similaò definitionó witè anù oæ thå otheò 'variables§  withiî thå Z³ Environment. Thå  Recorä Method® Turbï Pascal'ó Recorä typå allowó  assigninç anù  numbeò oæ differenô variablå typeó withiî á  datá  structurå calleä Record® Tï thå extenô thaô thå Z³ Environmenô  Descriptoò caî  bå defineä aó á Record¬ eacè elemenô oæ iô caî bå  addresseä aó Turbï Pascaì variable® Likå this.. type enörec = record jð º Byte; Š cbioó º Integer; z3iä º Array[1..5Ý oæ Char; tyð º Byte; expatè » Integer; expathó » Byte; rcð » Integer; rcpó » Byte; .... shvaò » Array[1..11Ý oæ Char; file± » Array[1..11Ý oæ Char; .... end; var zenö º ^envrec; Now¬ iî thå program¬ wå dï thå assignment.. zenö :½ Ptr(z3eadr); No÷ wå havå á pointeò tï á Recorä oæ Variableó (rec^.var)® Hencå wå  caî tesô thå sizå oæ thå Patè witè (ZENV^.EXPATHS)¬ itó  typå witè (ZENV^.TYP)¬ etc. iæ zenv^.expathó ¾ ° then .... ô :½ zenv^.typ; Turbï Pascal'ó WITÈ statemenô simplifieó thingó á little. witè zenv^ do iæ expathó ¾ ° then .... ô :½ typ; end; Theså  threå Methods¬ perhapó iî combination¬ allo÷  thå  seriouó Turbï  Pascaì programmeò nï excuseó foò NOÔ takinç  advantagå  oæ thå Ú-Systeí wheî iô ió available® É havå starteä thió witè  thå variouó  .TYP¬  .VAR¬ .FUÎ anä .PRÏ fileó yoõ seå  here®   Pleaså don'ô consideò theså definitivå oò complete® Uså theí aó á quidå tï creatå youò owî anä morå oæ them. É offeò nï Turbï Pascaì programó here¬ onlù thå tooló foò yoõ  tï writå youò own® Thå Ú-Systeí programmeò caî no÷ uså Turbï Pascaì tï  fulì advantagå anä thå Turbï Pascaì programmeò caî makå  fulì uså oæ thå Ú-System® Turbï Pascaì 3.01á anä NZ-COÍ 1.2ä from.. ALPHÁ SYSTEMÓ CORPORATION 71± Chatswortè Place Saî Jose¬ CÁ 95128 (408© 297-5594