-CATALOG083CRCK COM U-G-FORMLIB# ABSTRACT083 APPENDIXDOCMARITH% MUS*ATRG TRG  CMATH DOC]!"#$%&'()*+,al to parallel impedance convert 83.25 2K SMATX.SRT convert S matrix to X matrix 83.26 2K XMATS.SRT Convert X matrix to S matrix 83.27 2K YZZY.SRT convert Y to Z or Z to Y matrix 83.28 1K Z/REFC.SRT Z to reflection coefficient convert 83.29 1K ZXBER SIZE NAME COMMENTS 2K -CATALOG.083 CONTENTS OF CPMUG VOL. 83 4K ABSTRACT.083 Abstract of volume 2K CRCK.COM CRC check program. 2K FILES.CRC CRC of files on disk 5K U-G-FORM.LIB CPMUG contribution form ---- 83.1 6K ARITH%.MUS muMATide two complex quantities 83.16 8K LPFILTAN.BAS Source code for multipole filter analysis program 83.17 4K LPFILTAN.INT Compiled LPFILTAN.BAS 83.18 1K MPYCOM.SRT Multiply two complex quantities 83.19 1K MTXMPY.SRT Matrix multiplication 83.20COMCALC BASY-./012345678COMCALC INT$9:;<=COMDISK DOC->?@ABCCONTENT DSKDEFCPMFN MAC^GHIJKLMNOPQRCPMFN RELSCPMFNA MACTUVCPMFNA RELWries 83.8 5K SOLVE4%.EQN muMATH solution of equations 83.9 3K TRGNEG%.ALG muMATH trigonometric functions ---- 83.10 11K APPENDIX.DOC Appendix to CMATH/DOC. matrix math and circuit relationships. 83.11 13K CMATH.DOC Documentation for other compH arithmetic 83.2 2K ATRG.TRG muMATH inverse trig functions 83.3 1K INT%.DIF muMATH integrals 83.4 1K LIM%.DIF muMATH limits 83.5 1K LOG%.ALG muMATH logarithms 83.6 12K MUMATH%.DOC explanations of the files 83.7 10K SERIES%.DIF muMATH infinite se 1K PAR/SER.SRT Parallel to serial impedance convert 83.21 1K POL/REC.SRT Complex polar to rectangular convert 83.22 1K REC/POL.SRT Complex rectangular to polar convert 83.23 1K REFC/Z.SRT Reflection coefficient to Z conv 83.24 1K SER/PAR.SRT SeriCPMUG VOLUME 83 DESCRIPTION: Extensions for commercial languages: 1. MuMath/MuSimp enhancements; (Gerald A. Edgar) 2. CBASIC complex math routines; (E.R. Le Clear) 3. CP/M functions for Fortran-80; (William R. Brandoni) NUMCPMINT FORXYZ[\]^_`abcdefgCPMINT FORjhijklmnopqrstuCPMINT REL'vwxyzlex math files except COMCALC/BAS 83.12 12K COMCALC.BAS Source code for "calculator" mode complex math operation. 83.13 5K COMCALC.INT Compiled COMCALC/BAS 83.14 6K COMDISK.DOC DOC for complex subroutines XXXXXX.SRT 83.15 1K DIVCOM.SRT DivXZ.SRT Convert Z to X or X to Z matrix ---- 83.30 3K CONTENT.DSK Brief description of disk contents. 83.31 12K CPMFN.MAC Microsoft M80 source for part of CPMLIB. 83.32 1K CPMFN.REL Assembled version of CPMFN.MAC 83.33 3K CPMFNA.MAC Microsoft M80 she Users Group makes no representations as to the utility of the material in the library for any purpose. Contributions should be submitted on 8" single density diskettes in CP/M file form. Please cross reference any rewrites or bug-fixes to K\<7=Ɓo& K] K2h2|2DD~$#~# xK :F°*}p">d<¨ è CANNOT CLOSE CRCFILE$ ++ABORTED++$ *)TEST.FOR FORTRAN source for program to test library. ---- Library which can be used to interface Microsoft FORTRAN-80 to CP/M BDOS and other system-level functions. 83.40 5K ** to the CP/M users group. It will aid in the ** cataloging of the disks, and in helping people choose ** which programs they might be interested in. ** ** Send the contributions with the completed forms to - ** ** CP/M Users Group ** 1651 Third  CANNOT CLOSE CRCFILE$>CRCKLISTCRC DISK FULL: CRCFIL] w# N!I DONE$!e<ʨ!]K!eKsXXXXXXXX.XXX CRC = \<V++OPEN FAILED++$!"!"*| \\ !~2ource for part of CPMLIB. 83.34 1K CPMFNA.REL Assembled version of CPMFNA.MAC 83.35 30K CPMINT.FOR Microsoft F80 source for part of CPMLIB. 83.36 5K CPMINT.REL Compiled version of CPMINT.FOR 83.37 17K CPMLIB.DOC Documentation on the use of CPMLIB. CRCK.COM 4.3 01/17/81 RBS!9")1)̀:] Y ++NO FILE NAME SPECIFIED++ To use this program: COMMANDS: CRCK [drive:] [F] Examples: CRCK MYFILE.ASM Check only MYFILE.ASM CRCK *.ASM Check all .ASM files CRAvenue ** New York, NY 10028 ** Software contributions are received for inclusion into the library with the understanding that the contributor is authorized to make the material available to others for their individual, non-commercial use. T#"?(:\> ͇:\̀èV++FILE READ ERROR++$*|):oX|g}o"e n0Ç~͇#~t> ͇> _͛:F{2h2|:!\ K:\2!\ K\ !\ K\!\83.38 4K CPMLIB.MOD Documentation on methods to modify or add to the functions supported by CPMLIB. 83.39 6K CPMLIB.REL Library which can be used to interface Microsoft FORTRAN-80 to CP/M BDOS and other system-level functions. 83.40 5K ** Created 02/21/80 WLC ** Last Rev. 10/04/81 Ward C. ** Reason. Ask for more "what's diff" doc. ** ** If you have any comments on this form please pass ** them on to the CP/M users group. ** ** Please fill out this form for all material submitted *" +( DISK FULL: CRCFILE$!"**#"ɯ22!`"!"<¨ ( NO DIR SPACE: CRCFILE$1)ͦp:V++FILE NOT FOUND++$:Ff*}">< CK *.* F Check all files and make file of results $sCRCK ver 4.3 - 24K Buffer - 01/17/91 RBS CTL-S pauses, CTL-C aborts :m2F¨CRCKLIST$$$ Check only MYFILE.A+` ^**}|N!"*{z@*prior distributions. ** ** It is intended that this form be filled out with an ** editor, and left on the submitted disk for each ** program. (You may group similar programs together). ** All lines starting ** are comments which should be ** dele, ** and if so, what was its "name" (e.g. 23.05). "What is ** Different" and, if its not obvious, "why was it changed" ** (e.g. "bug fix" - it would not work under CP/M 2.2; or ** "modified to work with blah-blah type terminal", etc.) Hardware depen delete all comments lines via... bmn**$0ltk National CP/M Users Group - Program Submission Form Submission Date: File name: ** (or names). Include a 1 line description of each ** ** examples... ** ** MORSE.ASM Sends Morse code from ASCII ** E.G. "COM file only" ** "Well commented .ASM file" ** "Poorly commented .ASM file" e software "drop in": ** i.e. what type of modifications are required to make ** it run? How easy is the code to modify: ** some other .DOC file on this disk. Where is further documentation available: ** E.G. name the appropriate .DOC files on this disk; ** Was anything published in a magazine, etc. NOTE- If you are ** sending in something from a magazine, please incted from the form. Remember to keep an original ** of the form around for submitting more than one program. ** ** (If you don't mind, there are still a lot of us out here ** with 64 wide displays. We would appreciate your limiting ** your lines to 6hich is NOT on this disk? Timing dependencies? ** ** "STANDARD CP/M" means it runs with 8" disks (or similarly ** behaving ones like Northstar), 24K or more memory, CP/M 1.4. ** ** Do you think/know it works with CP/M 2.x? Source processor: ** Indencies: ** E.G. specific processor, disk controller, plotter, printer, ** modem, viedo board, etc. Software dependencies: ** E.G. I/O via PROM calls, or hard-coded ports; JMPS/CALLS ** to specific machine-size BIOS; Other software required ** wfile to port. ** SAMPLE.DAT Sample data file for MORSE. Author: ** Please include address and phone number. If either ** is not to be published, so indicate, but include ** them for the Users Group disk cataloging process, ** in case there are qulude ** the magazine's permission. For example, "Creative Computing" ** has allowed programs to be published, but not a "blanket ** permission", but rather written permission, one-by-one. ** ** Is this a modification of a previous Users Group program3 characters. <>) ** ** This form is most easily filled out with a full screen ** editor. You may do a "macro next colon" (mn:$v) to locate ** the fields which have to be filled in. ** ** Save this file as "filename.CPM" ** ** You can the.E. if this is a source program, what do you "run it ** with"... MAC, ASM, Microsoft BASIC version x.y, TDL ASM etc. Does the software "drop in": ** i.e. what type of modifications are required to make ** it run? How easy is the code to modify: etc. Who would this program be useful to: ** e.g. "All CP/M users" or "People with Tarbell floppy ** controllers" or "People with one-disk systems" etc. Briefly describe the program function: ** Include run instructions only if not included in estions. Submitted by: ** (if different than author). Also include address ** and phone if different. This program is public domain because: ** E.G. Submitted by author; author's approval, ** approval from magazine in which it was published, Abstract for CPMUG volume 83. 1. Gerald A. Edgar's muMATH/muSIMP routines 2. E.R. Le Clear's Complex math routines for CBASIC 2 3. William R. Brandoni's CP/M subroutines for FORTRAN-80. -------- 1. Routines for users of Microsoft's muMATH/muSIMP e. The individual matrices are mathematically manipulated according to the rules of matrix algebra presented in section 2.0 . The two port s parameters are derived from measurements of incident, reflected and transmitted powk using LINK-80. More complete documentation is available in the CPMLIB.DOC and CPMLIB.MOD files. ---- Abstract compiled 06/28/82 by Ward Christensen  MUMATH%.DOC explains the capabilities of each of the files on the disk. Instructions for using each of the files (usually by merging it with an existing muMATH file) are given as a comment at the beginning of the file. A text editor (not included) nd open circuit measurements on a "black box" circuit that contains two separate input and output connections. signal return connections may be common (3 terminal device) or may be separate (4 terminal device). If all circuit values OMDISK.DOC supply more information. ------------------------------------------------------------ 3. William R. Brandoni's CP/M subroutines for FORTRAN-80. CPMLIB.REL is a library of subroutines which permits the Microsoft FORTRAN-80 user to takesymbolic mathematics system. Tested at muSIMP-80 level 2.12. by Gerald A. Edgar 107 W. Dodridge St. Columbus, OH 43202 614-262-3232 Several files provided here extend the capabilities of the files provided with the muMATH/muSIMP distrmust be used to merge these files with existing muMATH files. Instructions for what to do have been placed at the beginning of each file. ------------------------------------------------------------ 2. Complex math routines for CBASIC 2, including are known, the coefficients may be calculated instead of measured. these coefficients may be arranged in a matrix form so that two or more two port networks can be mathematically combined into a single two port equivalent devic advantage of some CP/M and BDOS functions not supported in the FORTRAN language. For example, file manipulation such as renaming or erasing files. Direct console input is also supported. The library is set up so that it can be searched during a linibution disk. For example: evaluation of inverse trigonometric functions, for- mulas for the solution of fourth degree equations, summation of infinite series. Generally speaking, the added capabilities must be paid for in space and time. The file APPENDIX A RELATIONSHIPS BETWEEN CIRCUITS & MATRICES 1.0 TWO PORT PARAMETERS ------------------- Two port parameters are network equation coefficients derived by making various short aroutines in other programs. Several complex math subroutines are included as well as two application programs to illustrate the use of the subroutines and the method, such as a multipole filter analysis program. Files APPENDIX.DOC, CMATH.DOC, and C information on using them for circuit design, etc. by E.R. Le Clear. 209 Alverno Dr. Ft. Wayne, Ind. 46816 219-745-7652 Documentation on the disk describes a method for generating CBASIC "public library" files to be incorporated as suber instead of open and short circuit measurements. A. Z PARAMETERS ------------ I1 I2 --------- ^ 0-->--! !--->----O ! V1 ! ! [Z] ! ! V2 ! ---- 2*ZO 2*ZO FOR ZL = ZO (A2 = 0) FOR ZG = ZO (A1 = 0) -------------------- -------------------- S11 = B1/A1 S12 = B1/A2 S21 = B2/A1 S22 = B2/A2 ->--! !--->----O ^ V1 ! ! [X] ! ! V2 ! O-----! !--------O ! --------- V1 = A*V2 + B*I2 ( V1 ) ( A B ) ( V2 ) ( ) = ( ) * ( ) PARAMETERS ------------ I1 I2 --------- ^ O-->--! !--->----O ! V1 ! ! [Y] ! ! V2 ! O-----! !--------O V --------- I1 = Y 1 ---------- ------------------------------- 2*ZO 2*ZO A2 = V2 + I2*ZO = VOLTAGE WAVE INCIDENT ON PORT 2 ---------- ------------------------------- 2*ZO 2*ZO B1 = ( ) = ( ) * ( ) I2 = H21*I1 + H22*V2 ( I2 ) ( H21 H22 ) ( V2 ) WITH OUTPUT SHORTED (V2 = 0) WITH INPUT OPEN (I1 = 0) ---------------------------- --------------------O-----! !--------O V --------- V1 = Z11*I1 + Z12*I2 ( V1 ) ( Z11 Z12 ) ( I1 ) ( ) = ( ) * ( ) V2 = Z21*I1 + Z22*I2 ( V2 ) ( Z21 Z22 ) ( I2 ) B = V1/I2 C = I1/V2 D = I1/I2 E. S PARAMETERS ------------ A1--> <--A2 --------- O-------! !-------O ZG V1,I1 ! [S] ! V2,I2 ZL I1 = C*V2 + D*I2 ( I1 ) ( C D ) ( I2 ) WITH OUTPUT OPEN (I2 = 0) WITH OUTPUT SHORTED (V2 = 0) ------------------------- --------------------------- A = V1/V2 11*V1 + Y12*V2 ( I1 ) ( Y11 Y12 ) ( V1 ) ( ) = ( ) * ( ) I2 = Y21*V1 + Y22*V2 ( I2 ) ( Y21 Y22 ) ( V2 ) WITH OUTPUT SHORTED (V2 = 0) WITH INPUT SHORTED (V1 = 0) V1 - I1*ZO = VOLTAGE WAVE EMENATING FROM PORT 1 ---------- ---------------------------------- 2*ZO 2*ZO B2 = V2 - I2*ZO = VOLTAGE WAVE EMENATING FROM PORT 2 ---------- --------------------------------- H11 = V1/I1 H12 = V1/V2 H21 = I2/I1 H22 = I2/V2 D. X PARAMETERS (TRANSMISSION) ------------ I1 I2 --------- ^ O- WITH OUTPUT OPEN (I2 = 0) WITH INPUT OPEN (I1 = 0) ------------------------- ---------------------- Z11 = V1/I1 Z12 = V1/I2 Z21 = V2/I1 Z22 = V1/I2 B. Y O-------! !-------O --------- <--B1 B2--> ZO = IMPEDANCE OF TRANSMISSION LINE SYSTEM USED FOR MEASUREMENT (NORMALLY 50 OHMS) A1 = V1 + I1*ZO = VOLTAGE WAVE INCIDENT ON PORT1 I2 --------- ^ O-->--! !--->----0 ! V1 ! ! [H] ! ! V2 ! O-----! !--------O V --------- V1 = H11*I1 + H12*V2 ( V1 ) ( H11 H12 ) ( I1 ) ---------------------------- -------------------------- Y11 = I1/V1 Y12 = I1/V2 Y21 = I2/V1 Y22 = I2/V2 C. H PARAMETERS (HYBRID) ------------ I S11 = Z1 - ZO S12 = I1 (Z1 - ZO) ------- -- * --------- Z1 + ZO I2 (Z2 + ZO) S21 = I2 (Z2 - ZO) S22 = Z2 - ZO -- * --------------! !----- ! --------- ! ! ! ! --------- ! -----! !----- ! [ZB] ! O--------! !--------O --------- [ZC] = [ZA] + [ZB] ) ( M21 M22 ) ( N21 N22 ) ( Q21 Q22 ) [M] = [N] * [Q] -1 -1 [N] * [M] = [Q] ( N22 -N12 ) -1 ( quantities may be complex. The general network representation is: EQUATIONS MATRIX REPRESENTATION --------- --------------------- X1 = A11*P1 + A12*P2 ( X1 ) ( A11 A12 )---- --------- ------! !------ ! ! [YA] ! ! ! ---! !--- ! ! ! --------- ! ! ! ! ! ! ! ! --------- ! ! O--O--!--! !--!--O--O ) = ( ) ( M21 M22 ) ( N21 N22 ) ( (M21*N11 + M22*N21) (M21*N12 + M22*N22) ) [M] * [N] = [Q] NOTE: Multiplication must be taken in specific order ------- I1 (Z1 + ZO) Z2 + ZO Z1 = ZO (1 + S11) INPUT Z WITH OUTPUT TERMINATED IN ZO * --------- (1 - S11) Z2 = Z0 (1 + S22) OUTPUT Z WITH INPUT TERMINATED ( ) ( ) [Q]= ( Q21 Q22 ) = (-N21 N22 ) * ( M21 M22 ) -------------- DET [N] ( N22/DEL -N12/DEL ) ( M11 M12 ) [Q] = ( ) [N] = ADJOINT [N] = (-N21 N11 ) ----------- -------------------------- DET [N] ( N11*N22 - N12*N21 ) ( Q11 Q12 ) ( N22 -N12 ) ( M11 M12 ) ( ) ( P1 ) ( ) = ( ) * ( ) X2 = A21*P1 + A22*P2 ( X2 ) ( A21 A22 ) ( P2 ) X = [A] * [P] (SENDING END MATRIX) = (NETWORK MATRIX) * (RECEIVING END MATRIX) ! ! [YB] ! ! O-----O--! !--O-----O --------- [YC] = [YA] + [YB] B. SERIES NETWORKS --------------- --------- O--------! !--------O ! [ZA] ! [M] * [N] IS NOT EQUAL TO [N] * [M] D. DIVISION -------- Not normally used in analysis. Included for information only. ( M11 M12 ) ( N11 N12 ) ( Q11 Q12 ) ( ) = ( ) * ( IN ZO * --------- (1 - S22) 2.0 TWO PORT MATRIX ALGEBRA ----------------------- A. GENERAL ------- The following algebraic relations hold when manipulating two port matrices. Any or all ) * ( ) (-N21/DEL N11/DEL ) ( M21 M22 ) DEL = DET [N] = (N11*N22 - N12*N21) 3.0 COMBINING NETWORK MATRICES -------------------------- A. PARALLEL NETWORKS ------------- N22 ) ( (M21 + N21) (M22 + N22) ) ( Q21 Q22 ) [M] + [N] = [Q] C. MULTIPLICATION -------------- ( M11 M12 ) ( N11 N12 ) ( (M11*N11 + M12*N12) (M11*N12 + M12*N22) ) ( ) * ( B. ADD-SUBTRACT ----------- ( M11 M12 ) ( N11 N12 ) ( (M11 + N11) (M12 + N12) ) ( Q11 Q12 ) ( ) + ( ) = ( ) = ( ) ( M21 M22 ) ( N21 C. CASCADE NETWORKS ---------------- --------- --------- O--------! !---------! !---------O ! [XA] ! ! [XB] ! O--------! !---------! !---------O -***************% PRIMES: '(2, 3, 5, 7, 11, 13, 17, 19) $ FUNCTION ROOT (EX1, EX2, EX3, LEX1, EX4, EX5, EX6, % Local: % EX7), LOOP BLOCK WHEN ZERO (REST (EX7: DIVIDE(EX6,FIRST(LEX1)))), EX6: FIRST(EX7), WHEN (EX51) EXIT, WHEN EX1 EQ 1, EX1 EXIT, LIST ('^, EX1, -1) EXIT, EXPT (EX1, EX2) EXIT, WHEN EX2 EQ 1, EX1 EXIT, WHEN ZERO (EX2) AND ZEROEXPT, 1 EXIT, WHEN EX1 EQ #I, EX2: MOD (EX2, 4), WHEN EX2 EQ 2, -1 EXIT, S OR NUMBER(EX2) OR EX1<0), LOGBAS ^ (EX2*LOG(EX1,LOGBAS)) EXIT, LIST ('^, EX1, EX2) EXIT, WHEN APPLY (GET('EXPON,FIRST(EX2)), ADJOIN(EX1,ARGEX(EX2))) EXIT, WHEN APPLY (GET('BASE,FIRST(EX1)), ADJOIN(EX2,ARGEX(EX1))) EXIT, WHEN POSM from this file (ARITH%. MUS). This is everything between the two lines of stars ( ******** ), about 80 lines. --------------------------------------------------------------- FUNCTION ^ (EX1, EX2), WHEN INTEGER (EX2), WHEN INTEGER -------- --------- [XC] = [XA] * [XB] 4.0 MATRIX CONVERSIONS ------------------ Analysis of networks containing even a few series, parallel and cascade circuits will require conversion of matrices from one tRO (EX1), WHEN EX2 < 0, ? (LIST('^, EX1, EX2)) EXIT, WHEN EX2 > 0 OR ZEROBASE, 0, EXIT, LIST ('^, EX1, EX2) EXIT, WHEN ATOM (EX2), WHEN EX1 EQ #E AND EX2 EQ #I AND NEGMULT(TRGEXPD,7), COS(1) + #I*SIN(1) EXIT, WHEN EX2 EQ 3, -#I EXIT, EX1^EX2 EXIT, WHEN ATOM (EX1), LIST ('^, EX1, EX2) EXIT, WHEN APPLY (GET('BASE,FIRST(EX1)), ADJOIN(EX2,ARGEX(EX1))) EXIT, LIST ('^, EX1, EX2) EXIT, WHEN ATOM (EX1), WHEN EX1 EQ 1, 1 EXIT, WHEN ZE file ARITH%.MUS GAE - Feb. 1982 Make a new version of file ARITH.MUS as follows: (1) Start with the original file ARITH.MUS. (2) Delete FUNCTION ^ . This begins approximately 500 lines from the beginning of the filULT(LOGEXPD,7) AND NOT(EX1=LOGBAS OR NUMBER(EX2) OR EX1<0), LOGBAS ^ (EX2*LOG(EX1,LOGBAS)) EXIT, LIST ('^, EX1, EX2), ENDFUN $ ------------------------------------------------------------ %************* optional fractional-power package ***(EX1), WHEN EX1 EQ 1, 1 EXIT, WHEN ZERO(EX1) AND ZERO(EX2), ?(LIST('^, EX1, EX2)) EXIT, WHEN NEGATIVE (EX2), WHEN ZERO (EX1), ?(LIST('^, EX1, EX2)) EXIT, EX1: EXPT (EX1, -EX2), WHEN NEGATIVE (EX1), -((-EX1)^-ype to another. subroutines SMATX.SRT, XMATS.SRT, ZXXZ.SRT AND YZZY.SRT are provided for this purpose. networks containing even a few series, parallel and cascade circuits will require conversion of matrices from one t WHEN POSMULT(LOGEXPD,7) AND NOT(EX1=LOGBAS OR EX1<0), LOGBAS ^ (EX2*LOG(EX1,LOGBAS)) EXIT, LIST ('^, EX1, EX2) EXIT, WHEN APPLY (GET('EXPON,FIRST(EX2)), ADJOIN(EX1,ARGEX(EX2))) EXIT, WHEN POSMULT(LOGEXPD,7) AND NOT(EX1=LOGBA lines. It runs up to (but not including) the next line ( ---------- ). (4) Next delete everything between the two lines of stars ( ******** ) This is the `optional fractional-power package'. (5) Replace it with the same packagee. Delete everything through ENDFUN $ . It is about 50 lines. (3) In the place where the deletion was made, insert the new FUNCTION ^ from this file (ARITH%.MUS). It begins just after the line ( ------ ) below, and is also about 50 :EX5+1) EQ EX3, EX4: EX4*FIRST(LEX1), EX5: 0, EXIT EXIT, EX5: 0, WHEN NOT (POP(LEX1) < FIRST(EX7)), EX6: 1 EXIT, WHEN ATOM(LEX1), EX7: EX3 - 1, LEX1: EX6, LOOP EX5: LEX1^EX7, WHEN NO WHEN EX1=1, PION2 EXIT, WHEN POSMULT(TRGEXPD,7), #I*LOG((1-EX1^2)^(1/2)-#I*EX1,#E) EXIT, SIMPU('ASIN,EX1), ENDFUN $ FUNCTION ATAN(EX1), WHEN NOT PBRCH, SIMPU('ATAN,EX1) EXIT, EX1: TRGEXPD(EX1,-2), WHEN EX1=MINF, -PION2 EXIT, W1), EXIT ENDLOOP, ENDFUN $ PION2: #PI/2 $ PROPERTY EXPON, *, FUNCTION (EX1, EX2, EX3), WHEN EX1 EQ #E, WHEN INTEGER(EX2: EX2*EX3/PION2/#I), #I^EX2 EXIT, WHEN NEGMULT(TRGEXPD,7), WHEN FREE (EX2: EX2*PION2, #I), COS(EX2) F*#PI $ PION4: HALF*PION2 $ PION6: HALF*PION3 $ ONRT2: HALF^HALF $ ROOT3: 3^HALF $ ONRT3: 1/ROOT3 $ RT3ON2: ROOT3*HALF $ FUNCTION IDPBRCH(EX1), WHEN PBRCH, EX1 EXIT, ENDFUN $ FUNCTION COPBRCH(EX1), WHEN PBRCH, PION2-EX1 EXIT, ENDFUNMES, 1, 0, EX1) EXIT, WHEN ZERO(MOD(EX2,2)), #I^(2/EX2) * ROOT(-EX1, 1, EX2, PRIMES, 1, 0, -EX1) EXIT, -ROOT(-EX1, 1, EX2, PRIMES, 1, 0, -EX1) EXIT EXIT EXIT, WHEN EX1=#I OR EX1=-#I, WHEN INTEGER(EX2), WHEN PBRT ((EX5:QUOTIENT(EX6+EX7*LEX1*EX5,EX3*EX5)) < LEX1) EXIT, LEX1: EX5 ENDLOOP, WHEN LEX1^EX3 EQ EX6, EX4: EX4*LEX1, EX6: 1 EXIT, EX6: 1 EXIT, ENDBLOCK, WHEN EX6 EQ 1, EX1: EX1/(EX4^EX3), EX4: EX4^EX2,+ #I*SIN(EX2) EXIT EXIT EXIT, WHEN INTEGER(EX1), WHEN PBRCH AND INTEGER(EX2), WHEN INTEGER(EX3:1/EX3), WHEN EX1 > 0, ROOT(EX1, EX2, EX3, PRIMES, 1, 0, EX1) EXIT, WHEN ZERO(MOD(EX3,2)), #I^(2*EX2/EX3) $ FUNCTION ASIN(EX1), WHEN NOT PBRCH, SIMPU('ASIN,EX1) EXIT, EX1: TRGEXPD(EX1,-2), WHEN NEGLT(EX1), -ASIN(-EX1) EXIT, WHEN ZERO(EX1), 0 EXIT, WHEN EX1=HALF, PION6 EXIT, WHEN EX1=ONRT2, PION4 EXIT, WHEN EX1=RT3ON2, POIN3 EXIT,CH AND EX3 EQ -1, WHEN EX1=#I, #E^(#PI*#I/EX2/2) EXIT, #E^(3*#PI*#I/EX2/2) EXIT EXIT EXIT, ENDFUN $ %****************** optional factorial package********************%  WHEN EX1 EQ 1, EX4 EXIT, EX4 * LIST ('^, EX1, EX2/EX3) EXIT ENDLOOP, ENDFUN $ FUNCTION FREE (EX1, EX2), WHEN EX1 = EX2, FALSE EXIT, WHEN ATOM(EX1) EXIT, LOOP WHEN NOT FREE(POP(EX1),EX2), FALSE EXIT, WHEN ATOM(EX% file ATRG.TRG GAE - March, 1982 Inverse trig functions. This file can be compiled as-is. It requires TRGNEG.ALG. --------------------------------------------------------------% PION3: #PI/3 $ PION2: HAL2/EX3/2) EXIT, #E^(3*#I*#PI*EX2/EX3/2) EXIT, EXIT EXIT, ENDFUN $ PROPERTY EXPON, ^, FUNCTION (EX1, EX2, EX3), WHEN INTEGER(EX1), WHEN INTEGER(EX2), WHEN PBRCH AND EX3 EQ -1, WHEN EX1 > 0, ROOT (EX1, 1, EX2, PRI*ROOT(-EX1,EX2,EX3,PRIMES,1,0,-EX1) EXIT, (-1)^EX2 * ROOT(-EX1, EX2, EX3, PRIMES, 1, 0, -EX1) EXIT EXIT EXIT, WHEN EX1=#I OR EX1=-#I, WHEN PBRCH AND INTEGER(EX2), WHEN INTEGER(EX3:1/EX3), WHEN EX1=#I, #E^(#I*#PI*EXHEN NEGLT(EX1), -ATAN(-EX1) EXIT, WHEN ZERO(EX1), 0 EXIT, WHEN EX1=ONRT3, PION6 EXIT, WHEN EX1=1, PION4 EXIT, WHEN EX1=ROOT3, PION3 EXIT, WHEN EX1=PINF, PION2 EXIT, WHEN POSMULT(TRGEXPD,7), HALF*#I*LOG((#I+EX1)/(#I-EX1),#E) EXIT, reference while writing new programs. A brief description of each subroutine is provided including the "line number" of the subroutine and a definition of the input and output variable formats. When a subroutine is used, the appropriate varia The program file NETWORK.BAS now includes all three files concatenated to form a single program file which is ready to compile and run. Note: all of the library subroutine file headings are of the format XXXXXX.SRT . ***** COMPomplex multiplication, division and other functions become quite tedious to handle and are prime candidates for subroutine implementation. File DISK.DOC is the documentation file for the author's CBASIC complex math disk. This File iwritten and reference predefined "line numbers" which define subprograms that can be appended to the main program prior to compilation. These subprograms are maintained on the disk as a library of files that can be concantenated to t SIMPU('ATAN,EX1), ENDFUN $ FUNCTION ACOS(EX1), PION2-ASIN(EX1), ENDFUN $ FUNCTION ACOT(EX1), ATAN(1/EX1), ENDFUN $ FUNCTION ASEC(EX1), PION2 - ASIN(1/EX1), ENDFUN $ FUNCTION ACSC(EX1), ASIN(1/EX1), ENDFUN $ PROPERTY ASIN, the following program segments might be used: BR=WWWW REAL PART OF B BI=XXXX IMAGINARY PART OF B CR=YYYY REAL PART OF C CI=ZZZZ IMAGINARY PART OF C AR=BR+CR REAL PART OF A LEX MATH SUBROUTINES ***** Basic cannot handle complex math expressions directly. It is usually necessary to carry the real and imaginary parts through the program separately. For instance, in order to add two complex quantities (A=B+C), COMPLEX MATH SUBROUTINES FOR CBASIC by E.R. LE CLEAR 10/12/1980 This file describes a method for storing and using CBASIC "public library" subroutines as well as providing listings for specis used to provide documentation of the disk programs. Removing documentation from individual subroutine files and accumulating them in a separate documentation file minimizes the length of the final source file while a printout provides a handy he main program. For instance, suppose that main program file NETWORK.TMP has been written which uses subroutines REC/POL and POL/REC. A CBASIC source file is then generated as follows: PIP NETWORK.BAS=NETWORK.TMP,REC/POL.SRT,POL/REC.SRT SIN, IDPBRCH $ PROPERTY ATAN, TAN, IDPBRCH $ PROPERTY ASIN, COS, COPBRCH $ PROPERTY ATAN, COT, COPBRCH $ RDS() $ N $ FUNCTION ASEC(EX1), PION2 - ASIN(1/EX1), ENDFUN $ FUNCTION ACSC(EX1), ASIN(1/EX1), ENDFUN $ PROPERTY ASIN, 1 AI=BI+CI IMAGINARY PART OF A IE. (AR+JAI)=(BR+JBI)+(CR+JCI) ADDITION and subtraction are straightforward and are usually simpler TO do in line as they are required. C ***** THE PUBLIC LIBRARY ***** Since CBASIC does not normally use line numbers, the numeric lables required to identify program transfer statement entry can occur anywhere in the program and in any order. This allows programs to be fic complex math routines. In order to illustrate the general use of these subroutines, program LPFILTAN.BAS is provided which can be used to predict the input impedance and voltage transfer characteristics of multiple low pass filters. bles must be renamed to that of the input variable required by the subroutine. In the same manner, output variables must be renamed if the data is to be saved for future use. Many times, the current output variable can be used immediately by t- RB,LB,CB FOR SECTION 3 ?-,-,1.337 LA,RLA FOR SECTION 4 ? .8300,- CA,RCA FOR SECTION 4 ? .8402,- RB,LB,CB FOR SECTION 4 ? -,-,1.204 LA,RLA FOR SECTION 5 ? 1.088,- CA,RCA FOR SECTION 5 ? .3188,- RB,LB,CB FOR SECTION 5 ? -,-,1.516 LA,RLA FOR all component data, the program will ask whether a hard copy is desired. Any response other than "Y" will cause the printout to be directed to the console. The program will next ask for the minimum and maximum frequencies and the number of fretrix type to another. These types are: S SCATTERING MATRIX X TRANSMISSION MATRIX Z IMPEDANCE MATRIX Y ADMITTANCE MATRIX A brief discussion on the relationships between the different matrices i>CRUN2 B:LPFILTAN CRUN VER 2.05 LOW PASS FILTERS NUMBER OF SECTIONS ? 6 RG,RL ? 1,1 TYPE IN SECTION PARAMETERS. TYPE - IF ELEMENT NOT USED FOR SHORTED SERIES ARM, SET RB=1E+15 FOR OPEN SHUNT ARM, SET RB=1E+15 LA,RLA FOR SEractical filter. The program will first ask for the number of sections (N), generator source resistance (RG) and load (RL). After entering these, the program will request values for each component in each section. Entering a "-" reshe next subroutine without renaming the variables. The most commonly used subroutines will be 100.00 through 104.100. It is almost impossible to do even the simplest ac circuit analysis without using one of these. Subroutines 105.100 andll of the desired frequencies, the program will ask if you want to run a new frequency plot with the same part values (F), rerun the whole program with new values and frequency parameters (P) or quit (Q). The following dialog shows the evaluquency points to be calculated. These points will be distributed in a logrithmic manner so that data can be plotted on a LIN-LOG graph with physically equal spacing. 3 After calculating and printing the results at as provided in appendix A. 2 Subroutine 111.100 provides the means for multiplying matrices (primarily x matrices). Matrices must be multiplied in the correct direction or errors will result. ***** ACTION 1 ? 1.323,- CA,RCA FOR SECTION 1 ? .0833,- RB,LB,CB FOR SECTION 1 ? -,-,1.284 LA,RLA FOR SECTION 2 ? 1.011,- CA,RCA FOR SECTION 2 ? .5563,- RB,LB,CB FOR SECTION 2 ? -,-,1.807 LA,RLA FOR SECTION 3 ? .7551,- CA,RCA FOR SECTION 3 ? 1.004,ponse results in the following: COMPONENT VALUE AUTOMATICALLY ENTERED --------- --------------------------- LA,CB 1E+15 ALL OTHERS 1E-15 Any value other than "-" will be entered directly. After entering 106.100 will be useful in certain microwave engineering calculations while subroutines 107.100 through 111.100 are used in advanced circuit analysis using matrix algebra. Routines 107.100 through 110.100 provide means to change from one maation of a six section eliptic filter. This particular filter is a low pass prototype. Prototype filters are normalized to RG=RL=1 and a cutoff frequency of 1 RADIAN/SEC (.1592 HERTZ). Program run to evaluate pass band A 1 1 1 O-----------------------------O The number of sections is limited by the first DIM statement. The value can be changed but 10 sections is more than adaquate to handle any pPPLICATION PROGRAM ***** File LPFILTAN.BAS is a program for predicting the characteristics of low pass filters with up to 10 sections of the following type: --------- 1 1 O-------------------O 1 SECTION 6 ? 0,0 CA,RCA FOR SECTION 6 ?-,- RB,LB,CB FOR SECTION 6 ? -,-,1.087 HARD COPY ? (Y OR N) Y LOW PASS FILTER ANALYSIS FILTER CONSTANTS RG= 1 RL= 1 4 LA 1 = 1.323 RLA 1 = 1E-15 CA 1 = 0.0833 RCA 1 an elaborate ladder network representation. This results in a simpler and shorter program. In addition,the program can be easily modified for other types of filter sections without a major rewrite (ie. hi-pass, bandpass and bandstop). In order t ? .1592,..3184 NUMBER OF DATA POINTS ? 20 FREQ ALPHA(DB) ANG(ALPHA) ZIN ANG(ZIN) ---------------------------------------------------------------------- 1.592E-01 -0.22 26.99 8.275E-01 22.50 1.651E-01 -20.72 83.7RLA 6 = 0 CA 6 = 1E-15 RCA 6 = 1E-15 RB 6 = 1E-15 LB 6 = 1E-15 CB 6 = 1.087 FMIN,FMAX ? .01592,.1592 NUMBER OF DATA POINTS ? 20 FREQ ALPHA(DB) ANG(ALPHA) ZIN ANG(ZIN) ---------------------------------------------------0 2.752E-01 -105.49 -34.47 5.264E-01 -90.00 2.854E-01 -96.52 -37.05 4.979E-01 -90.00 2.960E-01 -92.90 -39.45 4.720E-01 -90.00 3.070E-01 -90.97 -41.71 4.482E-01 -90.00 3.184E-01 9.289E-01 -18.59 8.685E-02 -0.18 -42.34 7.677E-01 -17.12 9.804E-02 -0.08 -78.54 7.693E-01 -3.15 1.107E-01 -0.02 53.78 1.101E 00 -4.15 1.249E-01 -0.18 -9.02 9.403E-01 -22.22 1.410E-01 = 1E-15 RB 1 = 1E-15 LB 1 = 1E-15 CB 1 = 1.284 LA 2 = 1.011 RLA 2 = 1E-15 CA 2 = 0.5563 RCA 2 = 1E-15 RB 2 = 1E-15 LB 2 = 1E-15 CB 2 =1.807 LA 3 = 0.7751 RLA 3 = 1E-15 CA 3 = 1.004 RCA 3 = 1E-15 RB 3 = 1E-15 LB 3 = 1E9.51 3.52 1.063E 00 -90.00 2.055E-01 -93.28 -2.99 9.488E-01 -90.00 2.132E-01 -110.71 -8.60 8.599E-01 -90.00 2.211E-01 -92.85 -13.52 7.878E-01 -90.00 2.293E-01 -89.74 -17.90 7.21 1.815E 01 -87.78 1.712E-01 -41.30 51.20 2.840E 00 -90.00 1.776E-01 -63.29 33.29 1.853E 00 -90.00 1.842E-01 -91.06 20.83 1.450E 00 -90.00 1.911E-01 -108.44 11.27 1.219E 00 -90.00 1.982E-01 -8------------------ 1.592E-02 -0.09 -37.70 8.401E-01 -13.09 1.797E-02 -0.11 -42.50 8.101E-01 -13.39 2.029E-02 -0.13 -47.91 7.779E-01 -13.26 2.290E-02 -0.15 -54.00 7.451E-01 -12.53 -89.93 -43.82 4.262E-01 -90.00 NEW FREQ PLOT(F), NEW PARAMETERS(P) OR QUIT(Q) Q A> It should be pointed out that the program utilizes the X parameter matrix to calculate the overall filter characteristics rather than -0.08 73.88 1.294E 00 -4.34 1.592E-01 -0.22 26.99 8.275E-01 22.50 5 PROGRAM RUN TO EVALUATE STOP BAND NEW FREQ PLOT(F), NEW PARAMETERS(P) OR QUIT(Q) F FMIN,FMAX-15 CB 3 = 1.337 LA 4 = 0.83 RLA 4 = 1E-15 CA 4 = 0.8402 RCA 4 = 1E-15 RB 4 =1E-15 LB 4 = 1E-15 CB 4 =1.204 LA 5 = 1.088 RLA 5 = 1E-15 CA 5 = 0.3188 RCA 5 = 1E-15 RB 5 = 1E-15 LB 5 =1E-15 CB 5 =1.516 LA 6 = 0 77E-01 -90.00 2.378E-01 -89.63 -21.84 6.764E-01 -90.00 2.466E-01 -91.43 -25.41 6.319E-01 -90.00 2.558E-01 -95.44 -28.68 5.927E-01 -90.00 2.653E-01 -104.97 -31.69 5.578E-01 -90.00.92 7.123E-01 3.16 4.738E-02 -0.08 67.49 7.809E-01 5.93 5.349E-02 -0.03 51.78 8.861E-01 5.46 6.038E-02 -0.00 33.37 9.996E-01 0.03 6.816E-02 -0.03 11.87 1.037E 00 -9.91 7.694E-02 -0.12 -13.082.585E-02 -0.16 -60.86 7.142E-01 -11.03 2.918E-02 -0.18 -68.63 6.890E-01 -8.58 3.294E-02 -0.18 -77.44 6.751E-01 -5.16 3.718E-02 -0.16 -87.51 6.798E-01 -1.00 4.198E-02 -0.13 8o simplify programming, a unit matrix is defined prior to entering the matrix multiplication loop. This allows a valid matrix product when passing through the loop the first time. 6 Although this file is not int1=";S21.REAL,"+J";S21.IMAG PRINT "S22=";S22.REAL,"+J";S22.IMAG RETURN 12.0 PRINT "Z AND X MATRIX CONVERSIONS" INPUT "Z11(X11), Z12(X12),Z21(X21),Z22(X22) ?";TEMPA.REAL,TEMPA.IMAG,TEMPB.REAL,TEMPB.IMAG,TEMPC.REAL,TEMPC.IMAG,TEMPD.REAL,TEMPD.IMAG GOMP.PHA RETURN 4.0 PRINT "SERIAL TO PARALLEL IMPEDANCE " INPUT "SERIES R,SERIES X ?";TEMP.REAL,TEMP.IMAG GOSUB 101.100 PRINT"PARALLEL R= ";TEMP.REAL,"PARALLEL X=";TEMP.IMAG RETURN 5.0 PRINT "PARALLEL TO SERIAL IMPEDANCE " INPUT "PARALLEL R, PAETURN 10.0 PRINT "S TO X MATRIX CONVERSION" INPUT "S11,S12,S21,S22";S11.REAL,S11.IMAG,S12.REAL,S12.IMAG,S21.REAL,S21.IMAG,S22.REAL,S22.IMAG GOSUB 107.100 PRINT "A=";A.REAL,"+J";A.IMAG PRINT "B=";B.REAL,"+J";B.IMAG PRINT "C=";C.REAL,"+J";C.IMAG GOSUB 9.0 IF SELECT$="SMATX" THEN GOSUB 10.0 IF SELECT$="XMATS" THEN GOSUB 11.0 IF SELECT$="ZXXZ" THEN GOSUB 12.0 IF SELECT$="YZZY" THEN GOSUB 13.0 IF SELECT$="MTXMPY" THEN GOSUB 14.0 GOTO 1.0 2.0 PRINT "POLAR TO RECTANGULAR " INPUT "MAGNIended as a tutorial on ac circuit theory, it was felt that some exposure was required. File APPENDIX.DOC presents the circuit interpretations of the Z,Y,S and X matrices. TEMP.IMAG RETURN 7.0 PRINT "COMPLEX DIVISION " INPUT "A+JB /C+JD";TEMP.REAL,TEMP.IMAG,TEMP1.REAL,TEMP1.IMAG GOSUB 104.100 PRINT "C=";TEMP.REAL,"JD=";TEMP.IMAG RETURN 8.0 PRINT "REFLECTION COEFFICIENT TO LOAD Z " INPUT "MAGNITUDE, PHASE ?";TEMRALLEL X ?";TEMP.REAL,TEMP.IMAG GOSUB 102.100 PRINT "SERIES R=";TEMP.REAL,"SERIES X=";TEMP.IMAG RETURN 6.0 PRINT "COMPLEX MULTIPLICATION " INPUT "A+JB, C+JD ?";TEMP.REAL,TEMP.IMAG,TEMP1.REAL,TEMP1.IMAG GOSUB 103.100 PRINT "C=";TEMP.REAL,"JD="; REM PROGRAM SRT BY E.R. LE CLEAR 8-16-79 REM THIS PROGRAM PROVIDES CALCULATOR TYPE REM OPERATION FOR COMPLEX QUANTITY MATH REM OPERATIONS INCLUDING SEVERAL MATRIX REM CONVERSION ROUTINES. DESCRIPTIONS OF REM EACH COMPLEX SUBROUTINE IS GIVEN IN PRINT "D=";D.REAL,"+J";D.IMAG RETURN 11.0 PRINT "X TO S MATRIX CONVERSION" INPUT "A,B,C,D";A.REAL,A.IMAG,B.REAL,B.IMAG,C.REAL,C.IMAG,D.REAL,D.IMAG GOSUB 108.100 PRINT "S11=";S11.REAL,"+J";S11.IMAG PRINT "S12=";S12.REAL,"+J";S12.IMAG PRINT "S2TUDE, PHASE ?";TEMP.MAG,TEMP.PHA GOSUB 100.000 PRINT "REAL= ";TEMP.REAL,"IMAGINARY= ";TEMP.IMAG RETURN 3.0 PRINT "RECTANGULAR TO POLAR " INPUT "REAL, IMAGINARY ?";TEMP.REAL,TEMP.IMAG GOSUB 100.100 PRINT "MAGNITUDE= ";TEMP.MAG,"PHASE(DEG)= ";TE 7 circuit interpretations of the Z,Y,S and X matrices. P.MAG,TEMP.PHA GOSUB 105.100 PRINT "SERIES R=";TEMP.REAL,"SERIES X=";TEMP.IMAG RETURN 9.0 PRINT "LOAD Z TO REFLECTION COEFFICIENT" INPUT "SERIES R, SERIES X ?";TEMP.REAL,TEMP.IMAG GOSUB 106.100 PRINT "MAGNITUDE=";TEMP.MAG,"PHASE=";TEMP.PHA R 2.0 IF SELECT$="REC/POL" THEN GOSUB 3.0 IF SELECT$="SER/PAR" THEN GOSUB 4.0 IF SELECT$="PAR/SER" THEN GOSUB 5.0 IF SELECT$="MPYCOM" THEN GOSUB 6.0 IF SELECT$="DIVCOM" THEN GOSUB 7.0 IF SELECT$="REFC/Z" THEN GOSUB 8.0 IF SELECT$="Z/REFC" THEN REM FILE DISK.DOC . 1.0 PRINT "MENUE" PRINT "POL/REC REC/POL SER/PAR PAR/SER" PRINT "MPYCOM DIVCOM REFC/Z Z/REFC" PRINT "SMATX XMATS ZXXZ YZZY" PRINT "MTXMPY" INPUT "WHICH ?";SELECT$ IF SELECT$="POL/REC" THEN GOSUBSUB 109.100 PRINT "X11(Z11)=";TEMPA.REAL,"+J";TEMPA.IMAG PRINT "X12(Z12)=";TEMPB.REAL,"+J";TEMPB.IMAG PRINT "X21(Z21)=";TEMPC.REAL,"+J";TEMPC.IMAG PRINT "X22(Z22)=";TEMPD.REAL,"+J";TEMPD.IMAG RETURN 13.0 PRINT "Z AND Y MATRIX CONVERSIONS" INPU0R-4*T5R : Q11I=Q10I-4*T5I TEMP.REAL=Q11R : TEMP.IMAG=Q11I TEMP1.REAL=S21.REAL : TEMP1.IMAG=S21.IMAG GOSUB 104.100 TEMP1.REAL=Q5R : TEMP1.IMAG=Q5I GOSUB 104.100 Q14R=TEMP.REAL : Q14I=TEMP.IMAG B.REAL=25*Q14R : B.IMAG=25*Q14I RETURN 108.100REFC*********** A=TEMP.REAL TEMP.REAL=A-50 TEMP1.REAL=A+50 : TEMP1.IMAG=TEMP.IMAG GOSUB 104.100 TEMP.MAG=SQR(TEMP.REAL*TEMP.REAL+TEMP.IMAG*TEMP.IMAG) TEMP.PHA=57.296*ATN(TEMP.IMAG/TEMP.REAL) RETURN 107.100 REM ***********SMATX*********** ";B11.REAL,B11.IMAG,B12.REAL,B12.IMAG,B21.REAL,B21.IMAG,B22.REAL,B22.IMAG GOSUB 111.100 PRINT "C11=";C11.REAL,"+J";C11.IMAG PRINT "C12=";C12.REAL,"+J";C12.IMAG PRINT "C21=";C21.REAL,"+J";C21.IMAG PRINT "C22=";C22.REAL,"+J";C22.IMAG RETURN 100.S21.IMAG GOSUB 104.100 Q6R=TEMP.REAL : Q6I=TEMP.IMAG C.REAL=Q6R/100 : C.IMAG=Q6I/100 TEMP.REAL=T2R : TEMP.IMAG=T2I TEMP1.REAL=T3R : TEMP1.IMAG=T3I GOSUB 103.100 Q7R=TEMP.REAL : Q7I=TEMP.IMAG Q8R=Q7R+T5R : Q8I=Q7I+T5I TEMP.REAL=Q8R : TEMP.***********DIVCOM*********** A=TEMP.REAL : B=TEMP.IMAG C=TEMP1.REAL : D=TEMP1.IMAG E=C*C+D*D IF E<1E-12 THEN E=1E-12 TEMP.REAL=(A*C+B*D)/E TEMP.IMAG=(B*C-A*D)/E RETURN 105.100 REM ***********REFC/Z*********** A=TEMP.MAG : B=TEMP.PHA SR=AT "Z11(Y11), Z12(Y12), Z21(Y21), Z22(Y22) ?";TEMPA.REAL,TEMPA.IMAG,TEMPB.REAL,TEMPB.IMAG,TEMPC.REAL,TEMPC.IMAG,TEMPD.REAL,TEMPD.IMAG GOSUB 110.100 PRINT "Y11(Z11)=";TEMPA.REAL,"+J";TEMPA.IMAG PRINT "Y12(Z12)=";TEMPB.REAL,"+J";TEMPB.IMAG PRINT "Y21(.IMAG TEMP.REAL=T1R : TEMP.IMAG=T1I TEMP1.REAL=T4R : TEMP1.IMAG=T4I GOSUB 103.100 Q1R=TEMP.REAL : Q1I=TEMP.IMAG Q2R=Q1R+T5R : Q2I=Q1I+T5I TEMP.REAL=Q2R : TEMP.IMAG=Q2I TEMP1.REAL=S21.REAL : TEMP1.IMAG=S21.IMAG GOSUB 104.100 Q3R=TEMP.REAL T1R=1+S11.REAL : T1I=S11.IMAG T2R=1-S11.REAL : T2I=-S11.IMAG T3R=1+S22.REAL : T3I=S22.IMAG T4R=1-S22.REAL : T4I=-S22.IMAG TEMP.REAL=S12.REAL : TEMP.IMAG=S12.IMAG TEMP1.REAL=S21.REAL : TEMP1.IMAG=S21.IMAG GOSUB 103.100 T5R=TEMP.REAL : T5I=TEMP000 REM ***********POL/REC*********** TEMP.REAL=TEMP.MAG*COS(TEMP.PHA/57.296) TEMP.IMAG=TEMP.MAG*SIN(TEMP.PHA/57.296) RETURN 100.100 REM ***********REC/POL*********** TEMP.MAG=SQR(TEMP.REAL*TEMP.REAL+TEMP.IMAG*TEMP.IMAG) TEMP.PHA=57.296*ATN(TEMPIMAG=Q8I TEMP1.REAL=S21.REAL : TEMP1.IMAG=S21.IMAG GOSUB 104.100 Q9R=TEMP.REAL : Q9I=TEMP.IMAG D.REAL=Q9R/2 : D.IMAG=Q9I/2 TEMP.REAL=Q2R : TEMP.IMAG=Q2I TEMP1.REAL=Q8R : TEMP1.IMAG=Q8I GOSUB 103.100 Q10R=TEMP.REAL : Q10I=TEMP.IMAG Q11R=Q1*COS(B/57.296) IF SR<1E-12 THEN SR=1E-12 SI=A*SIN(B/57.296) TEMP.REAL=1+SR : TEMP.IMAG=SI TEMP1.REAL=1-SR : TEMP1.IMAG=-SI GOSUB 104.100 TEMR=TEMP.REAL : TEMI=TEMP.IMAG TEMP.REAL=50*TEMR : TEMP.IMAG=50*TEMI RETURN 106.100 REM ***********Z/Z21)=";TEMPC.REAL,"+J";TEMPC.IMAG PRINT "Y22(Z22)=";TEMPD.REAL,"+J";TEMPD.IMAG RETURN 14.0 PRINT "COMPLEX MATRIX MULTIPLICATION" INPUT "A11,A12,A21,A22";A11.REAL,A11.IMAG,A12.REAL,A12.IMAG,A21.REAL,A21.IMAG,A22.REAL,A22.IMAG INPUT "B11,B12,B21,B22: Q3I=TEMP.IMAG A.REAL=Q3R/2 : A.IMAG=Q3I/2 TEMP.REAL=T2R : TEMP.IMAG=T2I TEMP1.REAL=T4R : TEMP1.IMAG=T4I GOSUB 103.100 Q4R=TEMP.REAL : Q4I=TEMP.IMAG Q5R=Q4R-T5R : Q5I=Q4I-T5I TEMP.REAL=Q5R : TEMP.IMAG=Q5I TEMP1.REAL=S21.REAL : TEMP1.IMAG=AG Q=B/A IF Q<1E-12 THEN Q=1E-12 TEMP.REAL=A/(1+1/(Q*Q)) TEMP.IMAG=B/(1+Q*Q) RETURN 103.100 REM ***********MPYCOM*********** A=TEMP.REAL : B=TEMP.IMAG C=TEMP1.REAL : D=TEMP1.IMAG TEMP.REAL=A*C-B*D TEMP.IMAG=A*D+B*C RETURN 104.100 REM .IMAG/TEMP.REAL) RETURN 101.100 REM ***********SER/PAR*********** A=TEMP.REAL : B=TEMP.IMAG Q=B/A IF Q<1E-12 THEN Q=1E-12 TEMP.REAL=A*(1+Q*Q) TEMP.IMAG=B*(1+1/(Q*Q)) RETURN 102.100 REM ***********PAR/SER*********** A=TEMP.REAL : B=TEMP.IM REM ***********XMATS*********** TEMP.REAL=A.REAL : TEMP.IMAG=A.IMAG TEMP1.REAL=D.REAL : TEMP1.IMAG=D.IMAG GOSUB 103.100 Q1R=TEMP.REAL : Q1I=TEMP.IMAG TEMP.REAL=B.REAL : TEMP.IMAG=B.IMAG TEMP1.REAL=C.REAL : TEMP1.IMAG=C.IMAG GOSUB 103.100 Q=B21.IMAG : G2=B22.REAL : H2=B22.IMAG C11.REAL=A1*A2-B1*B2+C1*E2-D1*F2 C11.IMAG=B1*A2+A1*B2+C1*F2+D1*E2 C12.REAL=A1*C2-B1*D2+C1*G2-D1*H2 C12.IMAG=B1*C2+A1*D2+D1*G2+C1*H2 C21.REAL=A2*E1-B2*F1+E2*G1-F2*H1 C21.IMAG=A2*F1+B2*E1+E2*H1+F2*G1 C22.RE.IMAG=0 TEMP1.REAL=TEM3R : TEMP1.IMAG=TEM3I GOSUB 104.100 TEMPC.REAL=TEMP.REAL : TEMPC.IMAG=TEMP.IMAG TEMP.REAL=TEMPD.REAL : TEMP.IMAG=TEMPD.IMAG TEMP1.REAL=TEM3R : TEMP1.IMAG=TEM3I GOSUB 104.100 TEMPD.REAL=TEMP.REAL : TEMPD.IMAG=TEMP.IMAG T7I=Q4I-T1I TEMP.REAL=T2R : TEMP.IMAG=T2I TEMP1.REAL=T5R : TEMP1.IMAG=T5I GOSUB 103.100 Q5R=TEMP.REAL : Q5I=TEMP.IMAG T8R=Q5R-T1R : T8I=Q5I-T1I TEMP.REAL=T7R : TEMP.IMAG=T7I TEMP1.REAL=T6R : TEMP1.IMAG=T6I GOSUB 104.100 S11.REAL=TEMP.REA=TEMP.IMAG TEMP.REAL=TEM2R : TEMP.IMAG=TEM2I TEMP1.REAL=Q3R : TEMP1.IMAG=Q3I GOSUB 104.100 TEMPB.REAL=TEMP.REAL : TEMPB.IMAG=TEMP.IMAG TEMP.REAL=TEM1R : TEMP.IMAG=TEM1I TEMP1.REAL=Q3R : TEMP1.IMAG=Q3I GOSUB 104.100 TEMPD.REAL=TEMP.REAL : TEIMAG=TEMPB.IMAG TEMP1.REAL=TEMPC.REAL : TEMP1.IMAG=TEMPC.IMAG GOSUB 103.100 TEM2R=TEMP.REAL : TEM2I=TEMP.IMAG DELR=TEM1R-TEM2R : DELI=TEM1I-TEM2I TEMP.REAL=TEMPA.REAL : TEMP.IMAG=TEMPA.IMAG TEMP1.REAL=TEMPC.REAL : TEMP1.IMAG=TEMPC.IMAG GOSUB 2R=TEMP.REAL : Q2I=TEMP.IMAG T1R=Q1R-Q2R : T1I=Q1I-Q2I T2R=A.REAL+50*C.REAL : T2I=A.IMAG+50*C.IMAG T3R=A.REAL-50*C.REAL : T3I=A.IMAG-50*C.IMAG T4R=D.REAL+50*C.REAL : T4I=D.IMAG+50*C.IMAG T5R=D.REAL-50*C.REAL : T5I=D.IMAG-50*C.IMAG TEMP.REAL=T2RAL : TEMP1.IMAG=TEMPC.IMAG GOSUB 103.100 Q2R=TEMP.REAL : Q2I=TEMP.IMAG Q3R=Q1R-Q2R : Q3I=Q1I-Q2I TEM1R=TEMPA.REAL : TEM1I=TEMPA.IMAG TEM2R=-TEMPB.REAL : TEM2I=-TEMPB.IMAG TEM3R=-TEMPC.REAL : TEM3I=-TEMPC.IMAG TEM4R=TEMPD.REAL : TEM4I=TEMPD.IMRETURN 110.100 REM ***********YZZY*********** TEMP.REAL=TEMPA.REAL : TEMP.IMAG=TEMPA.IMAG TEMP1.REAL=TEMPD.REAL : TEMP1.IMAG=TEMPD.IMAG GOSUB 103.100 Q1R=TEMP.REAL : Q1I=TEMP.IMAG TEMP.REAL=TEMPB.REAL : TEMP.IMAG=TEMPB.IMAG TEMP1.REAL=TEMPC.REL : S11.IMAG=TEMP.IMAG Q6R=100*C.REAL : Q6I=100*C.IMAG TEMP.REAL=T1R : TEMP.IMAG=T1I TEMP1.REAL=T6R : TEMP1.IMAG=T6I GOSUB 104.100 Q7R=TEMP.REAL : Q7I=TEMP.IMAG TEMP.REAL=Q6R : TEMP.IMAG=Q6I TEMP1.REAL=Q7R : TEMP1.IMAG=Q7I GOSUB 103.100 SMPD.IMAG=TEMP.IMAG RETURN 111.100 REM ***********MTXMPY*********** A1=A11.REAL : B1=A11.IMAG : C1=A12.REAL : D1=A12.IMAG E1=A21.REAL : F1=A21.IMAG : G1=A22.REAL : H1=A22.IMAG A2=B11.REAL : B2=B11.IMAG : C2=B12.REAL : D2=B12.IMAG E2=B21.REAL : F2104.100 TEMPA.REAL=TEMP.REAL : TEMPA.IMAG=TEMP.IMAG TEMP.REAL=DELR : TEMP.IMAG=DELI TEMP1.REAL=TEMPC.REAL : TEMP1.IMAG=TEMPC.IMAG GOSUB 104.100 TEMPB.REAL=TEMP.REAL : TEMPB.IMAG=TEMP.IMAG TEM3R=TEMPC.REAL : TEM3I=TEMPC.IMAG TEMP.REAL=1 : TEMP : TEMP.IMAG=T2I TEMP1.REAL=T4R : TEMP1.IMAG=T4I GOSUB 103.100 Q3R=TEMP.REAL : Q3I=TEMP.IMAG T6R=Q3R-T1R : T6I=Q3I-T1I TEMP.REAL=T3R : TEMP.IMAG=T3I TEMP1.REAL=T4R : TEMP1.IMAG=T4I GOSUB 103.100 Q4R=TEMP.REAL : Q4I=TEMP.IMAG T7R=Q4R-T1R :AG TEMP.REAL=TEM4R : TEMP.IMAG=TEM4I TEMP1.REAL=Q3R : TEMP1.IMAG=Q3I GOSUB 104.100 TEMPA.REAL=TEMP.REAL : TEMPA.IMAG=TEMP.IMAG TEMP.REAL=TEM3R : TEMP.IMAG=TEM3I TEMP1.REAL=Q3R : TEMP1.IMAG=Q3I GOSUB 104.100 TEMPC.REAL=TEMP.REAL : TEMPC.IMAGTEMP.REAL : S22.IMAG=TEMP.IMAG RETURN 109.100 REM ***********ZXXZ*********** TEMP.REAL=TEMPA.REAL : TEMP.IMAG=TEMPA.IMAG TEMP1.REAL=TEMPD.REAL : TEMP1.IMAG=TEMPD.IMAG GOSUB 103.100 TEM1R=TEMP.REAL : TEM1I=TEMP.IMAG TEMP.REAL=TEMPB.REAL : TEMP.12.REAL=TEMP.REAL : S12.IMAG=TEMP.IMAG TEMP.REAL=Q6R : TEMP.IMAG=Q6I TEMP1.REAL=T6R : TEMP1.IMAG=T6I GOSUB 104.100 S21.REAL=TEMP.REAL : S21.IMAG=TEMP.IMAG TEMP.REAL=T8R : TEMP.IMAG=T8I TEMP1.REAL=T6R : TEMP1.IMAG=T6I GOSUB 104.100 S22.REAL=AL=C2*E1-D2*F1+G1*G2-H1*H2 C22.IMAG=C2*F1+D2*E1+H1*G2+G1*H2 RETURN D2+C1*G2-D1*H2 C12.IMAG=B1*C2+A1*D2+D1*G2+C1*H2 C21.REAL=A2*E1-B2*F1+E2*G1-F2*H1 C21.IMAG=A2*F1+B2*E1+E2*H1+F2*G1 C22.RELMKINLJMN   dOPOpPpCDGH 3QRSQITRJST   dUVUdpVdpCDEF 3WXYWIZXJYZ   d[\"' kA=$#5+J$#d4B=$#5+J$#d4C=$#5+J$#d4D=$#5+J$#d4X TO S MATRIX CONVERSION$d4A,B,C,Dn;""""""""' vS11=$#5+J$#d4S12=$ #5+J$ #d4S21=$ #5+J$ #d4S22=$ #5+J$#d4Z AND X MATp789879.7 9.799pp899p78:;7:8;7;8:78:;<::;;<.7 <.7:8;<8:7;<78=78.F=.7 =.>7PARALLEL X ?n;""'SERIES R=$#5SERIES X=$#d4COMPLEX MULTIPLICATION $d4A+JB, C+JD ?n;""""' 3C=$#5JD=$#d4COMPLEX DIVISION $d4A+JB /C+JDn;""""' dC=$#5JD=$#d4REFLECTION COEFFICIENT TO LOAD Z1(Y21), Z22(Y22) ?n;""""""""'`Y11(Z11)=$#5+J$#d4Y12(Z12)=$#5+J$#d4Y21(Z21)=$#5+J$#d4Y22(Z22)=$#5+J$#d4COMPLEX MATRIX MULTIPLICATION$d4A11,A12,A21,A22n;" "!"""#"$"%"&"'B11,B12RIX CONVERSIONS$d4Z11(X11), Z12(X12),Z21(X21),Z22(X22) ?n;""""""""'}X11(Z11)=$#5+J$#d4X12(Z12)=$#5+J$#d4X21(Z21)=$#5+J$#d4X22(Z22)=$#5+J$#d4Z AND Y MATRIX CONVERSIONS$d4Z11(Y11), Z12(Y12), Z21$57.296$1E-12$*MENUE$d4POL/REC REC/POL SER/PAR PAR/SER$d4MPYCOM DIVCOM REFC/Z Z/REFC$d4SMATX XMATS ZXXZ YZZY$d4MTXMPY$d4WHICH ?n;1'POL/REC7REC/POL7SER/PAR7JPAR/SER8.E=p>=p>0 d?@2?p2@p772p72p dI.GApBCpD0E pFG pH0     3IJABGH 3K $d4MAGNITUDE, PHASE ?n;""' SERIES R=$#5SERIES X=$#d4LOAD Z TO REFLECTION COEFFICIENT$d4SERIES R, SERIES X ?n;""' /MAGNITUDE=$#5PHASE=$#d4S TO X MATRIX CONVERSION$d4S11,S12,S21,S22n;"" " " " " ",B21,B22n;'"(")"*"+","-"."'cC11=$/#5+J$0#d4C12=$1#5+J$2#d4C21=$3#5+J$4#d4C22=$5#5+J$6#d4.F.EI.G789879.7À9.799p899pd4RECTANGULAR TO POLAR $d4REAL, IMAGINARY ?n;""'MAGNITUDE= $#5PHASE(DEG)= $#d4SERIAL TO PARALLEL IMPEDANCE $d4SERIES R,SERIES X ?n;""'PARALLEL R= $#5PARALLEL X=$#d4PARALLEL TO SERIAL IMPEDANCE $d4PARALLEL R, 7MPYCOM7"DIVCOM7wREFC/Z7!Z/REFC73.SMATX7DXMATS7U8ZXXZ7eYZZY7uMTXMPY76POLAR TO RECTANGULAR $d4MAGNITUDE, PHASE ?n;""'iREAL= $#5IMAGINARY= $#[p\pMNYZ 3]^_]Ip`^Jp_`   dST dabapbp 3KL 3MNAKMBLNC2pD2pESRT * "LINE NUMBER"=102.100 THIS SUBROUTINE IS USED TO CONVERT A PARALLEL IMPEDANCE CONSISTING OF (TEMP.REAL) AND (TEMP.IMAG) INTO A SERIES IMPEDANCE (TEMP.REAL)+J(TEMP.IMAG). * MPYCOM.SRT * "LINE NUMBER"=103.100 THIS SUBROUTINE IS SRT SMATX.SRT XMATS.SRT YZZY.SRT Z/REFC.SRT ZXXZ.SRT The programs on this disk include several "subroutine" (.SRT) program files. The "subroutine" program files each contain a numeric "line number" at the beginning of the routine. The normal mdmn dopppop dop d 3KL 3MNOKMPLNijk0l0o0p0qrqEMP.PHA) INTO RECTANGULAR UNITS (TEMP.REAL)+J(TEMP.IMAG). PHASE IS IN DEGREES. * REC/POL.SRT * "LINE NUMBER"=100.100 THIS SUBROUTINE IS USED TO CONVERT COMPLEX QUANTITY (TEMP.REAL)+J(TEMP.IMAG) INTO POLAR MAGNITUDE (TEMP.MAG) AND PHA2pF2pG2pH2pI2pJ2pCDGH 3OPcOAdPBEFGH 3QReQAfRBCDIJ 3STgSAhTBefcd dPAR/SER.SRT Upon compiling, the intermediate code file END$PROG.INT contains the combined code for the three concantanated files. Since CBASIC only requires line identification for control transfer statements, the subroutines will be cethod for using these subroutines is to generate the CBASIC program with the text editor and then generate a new XXXXX.BAS file by concantinating the program file and desired subroutines as follows: PIP END$PROG.BAS=INIT$PROG.ASC,SER/PAR.SRT,rOP dopOP dklOP dijOP dst u!v"w#x$y%z&{'|(})~*+,-./s{t|uv0t{s|uvSE (TEMP.PHA). PHASE IS IN DEGREES. * SER/PAR.SRT * "LINE NUMBER"=101.100 THIS SUBROUTINE IS USED TO CONVERT SERIES IMPEDANCE (TEMP.REAL)+J(TEMP.IMAG) INTO PARALLEL COMPONENTS (TEMP.REAL) AND J(TEMP.IMAG). * PAR/SER.Documentation on complex math routines in CBASIC by E.R. Le Clear. Files: APPENDIX.DOC CMATH.DOC COMCALC.BAS COMCALC.INT COMDISK.DOC DIVCOM.SRT LPFILTAN.BAS LPFILTAN.INT MPYCOM.SRT MTXMPY.SRT PAR/SER.SRT POL/REC.SRT REC/POL.SRT REFC/Z.SRT SER/PAR.UdpVdpABcd dWXUVWX 3  UVcd d  ghcd d  3ij 3klmiknjl alled by any control statement with the approriate "line number" suffix. ***** SUBROUTINES ***** * POL/REC.SRT * "LINE NUMBER"=100.000 THIS SUBROUTINE IS USED TO CONVERT POLAR MAGNITUDE (TEMP.MAG) AND PHASE (T1s}t~uv2t}s~vu3{w|xyz4{x|wzy5}w~xyz6}x~wzy 3ij 3klmiknjl USED TO MULTIPLY TWO COMPLEX NUMBERS AND RETURN THE RESULTANT COMPLEX NUMBER. (TEMP.REAL)+J(TEMP.IMAG)=((TEMP.REAL)+J(TEMP.IMAG))* ((TEMP1.REAL)+J(TEMP1.IMAG)) * DIVCOM.SRT * "LINE NUMBER"=104.100 THIS SUBRO 2X2 X MATRIX (A,B,C,D) OR VISA VERSA. REQUIRES MPYCOM.SRT AND DIVCOM.SRT TO RUN. INPUTS: (TEMPA.REAL)+J(TEMPA.IMAG) (TEMPB.REAL)+J(TEMPB.IMAG) (TEMPC.REAL)+J(TEMPC.IMAG) (TEMPD.REAL)+J(TEMPD.IMAG) RETURNS:SAME FORMAT AS * Z/REFC.SRT * "LINE NUMBER"=106.100 THIS SUBROUTINE IS USED TO CONVERT A COMPLEX IMPEDANCE (TEMP.REAL)+J(TEMP.IMAG) INTO A REFLECTION COEFFICIENT (TEMP.MAG) AT PHASE (TEMP.PHA). PHASE IS IN DEGREES. REQUIRES DIVCOM.SRT TO RUN. AL)+J(B11.IMAG) (A12.REAL)+J(A12.IMAG) (B12.REAL)+J(B12.IMAG) (A21.REAL)+J(A21.IMAG) (B21.REAL)+J(B21.IMAG) (A22.REAL)+J(A22.IMAG) (B22.REAL)+J(B22.IMAG) RETURNS:(C11.REAL)+J(C11.IMAG) (C12.REAL)+J(C12.IMAG) (C MATRIX DOES NOT HAVE TO BE NORMALIZED. THIS IS BUILT INTO THE PROGRAM. REQUIRES MPYCOM.SRT AND DIVCOM.SRT TO RUN. INPUTS: (A.REAL)+J(A.IMAG) (B.REAL)+J(B.IMAG) (C.REAL)+J(C.IMAG) (D.REAL)+J(D.IMAG) RETURNS:(S11.REAL)+JUTINE DIVIDES ONE COMPLEX QUANTITY BY ANOTHER AND RETURNS THE RESULTANT COMPLEX QUANTITY. (TEMP.REAL)+J(TEMP.IMAG)=((TEMP.REAL)+J(TEMP.IMAG))/ ((TEMP1.REAL)+J(TEMP1.IMAG)) * REFC/Z.SRT * "LINE NUMBER"=105.1TO RUN. INPUTS: (TEMPA.REAL)+J(TEMPA.IMAG) (TEMPB.REAL)+J(TEMPB.IMAG) (TEMPC.REAL)+J(TEMPC.IMAG) (TEMPD.REAL)+J(TEMPD.IMAG) RETURNS:SAME FORMAT AS INPUTS * MTXMPY.SRT * "LINE NUMBER"=111.100 THIS SUBRO INPUTS * YZZY.SRT * "LINE NUMBER"=110.100 THIS SUBROUTINE IS USED TO CONVERT A COMPLEX 2X2 ADMITTANCE MATRIX (Y11,Y12,Y21,Y22) INTO A COMPLEX 2X2 IMPEDANCE MATRIX (Z11,Z12,Z21,Z22) AND VICA VERSA. REQUIRES MPYCOM.SRT AND DIVCOM.SRT * SMATX.SRT * "LINE NUMBER"=107.100 THIS SUBROUTINE IS USED TO CONVERT A COMPLEX 2X2 "S" MATRIX INTO A COMPLEX 2X2 "X" MATRIX (A,B,C,D). CON- VERSION IS BASED ON A 50 OHM SYSTEM AND THE X MATRIX IS DENORMALIZED TO ALLOW DIRECT CONVERSION T21.REAL)+J(C21.IMAG) (C22.REAL)+J(C22.IMAG)  (A22.REAL)+J(A22.IMAG) (B22.REAL)+J(B22.IMAG) RETURNS:(C11.REAL)+J(C11.IMAG) (C12.REAL)+J(C12.IMAG) (C(S11.IMAG) (S12.REAL)+J(S12.IMAG) (S21.REAL)+J(S21.IMAG (S22.REAL)+J(S22.IMAG) * ZXXZ.SRT * "LINE NUMBER"=109.100 THIS SUBROUTINE IS USED TO CONVERT A COMPLEX 2X2 IMPEDANCE MATRIX (Z11,Z12,Z21,Z22) TO A COMPLEX 00 THIS SUBROUTINE IS USED TO CONVERT A COMPLEX REFLECTION COEFFICIENT (TEMP.MAG) AT (TEMP.PHA) INTO AN EQUIVALENT SERIES IMPEDANCE IN A 50 OHM TRANSMISSION SYSTEM (TEMP.REAL)+J(TEMP.IMAG). PHASE (TEMP.PHA) IS IN DEGREES. REQUIRES DIVCOM.SRT TO RUN. UTINE IS USED TO MULTIPLY A COMPLEX 2X2 MATRIX (A11,A12,A21,A22) BY ANOTHER COMPLEX 2X2 MATRIX (B11,B12,B21,B22) AND RETURN COMPLEX 2X2 MATRIX (C11,C12,C21,C22). INPUTS: 1 2 (A11.REAL)+J(A11.IMAG) (B11.RE (C.REAL)+J(C.IMAG) (D.REAL)+J(D.IMAG) * XMATS.SRT * "LINE NUMBER"=108.100 THIS SUBROUTINE IS USED TO CONVERT A COMPLEX 2X2 "X" (A,B,C,D) MATRIX INTO A COMPLEX 2X2 "S" MATRIX. CONVERSION IS BASED ON A 50 OHM SYSTEM AND THE "X"O A "Z" MATRIX. REQUIRES MPYCOM.SRT AND DIVCOM.SRT TO RUN. INPUTS: (S11.REAL)+J(S11.IMAG) (S12.REAL)+J(S12.IMAG) (S21.REAL)+J(S21.IMAG) (S22.REAL)+J(S22.IMAG) RETURNS:(A.REAL)+J(A.IMAG) (B.REAL)+J(B.IMAG) CONTENT.DSK This disk contains a library of routines which enable Microsoft FORTRAN programs to make direct CP/M BDOS function calls. The routines were written specifically to implement the following functions which are not normally supported from to provide ; an interface between Microsoft FORTRAN-80 and ; several I/O operations not supported in that ; language. ; ; This file is intended as support to Microsoft FORTRAN ; subroutines which in turn provide all of the ; interfacing and setup fevel calls to CP/M version 2.x BDOS functions. CPMFN.REL (*) Assembled version of CPMFN.MAC in Microsoft Relocatable format. This is also included in the last part of the CPMLIB.REL file. CPMFNA.MAC (*) Microsoft M80 source for the machine-le ; ; Author: William R. Brandoni ; ; Language: Microsoft M80 (MACRO-80 assembler) Version 3.4 (26-Nov-80) ; ; ; See the "User-Defined Equates" section for modifications ; you may have to make to reassemble this file. ; ; Note that function classeof routines which can be used to interface Microsoft FORTRAN-80 to the CP/M BDOS functions. This library can be searched in the link process to include those functions desired. (See CPMLIB.DOC). TEST.FOR FORTRAN source for a test program which within FORTRAN: ERASE Erase a file. EXIST Test to see if a file exists. GETCMD Input the command line "tail". INCHR Input a single character without a terminating carriage return. INKEY Input a character (if one is pending) or vel interface to the command line. CPMFNA.REL (*) Assembled version of CPMFNA.MAC in Microsoft Relocatable format. This is also included in the last part of the CPMLIB.REL file. CPMINT.FOR (*) Microsoft F80 source for the FORTRAN-80 interfacs that are not active at this ; time are untested. ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; This file is a general purpose interface for ; BDOS calls to CP/M version 2.x. ; ; The main reason for its existance is will test all of the functions currently in the the library. Note: Files marked (*) are only required to modify CPMLIB.REL  a null (if not). RENAME Rename a file. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Contents of this disk are: CONTENT.DSK This file (contents of this disk). CPMFN.MAC (*) Microsoft M80 source for the machine-l; ; CPMFN ; ; CP/M BDOS Functions - interface routines ; ; ; Originally written: November, 1981 ; ; Pre-release modifications: ; Dec. 10, 1981 - Added EXIST routine (FN17) ; ; Released to CP/M User's Group as: ; Version 1.0 ; January 12, 1982ion on the use of CPMLIB. Topics include the arguments to each routine and the linkage conventions required to use the library. CPMLIB.MOD (*) Documentation on methods to modify or add to the functions supported by CPMLIB. CPMLIB.REL Library e routines to implement all CPMLIB calls from within a FORTRAN-80 program. CPMINT.REL (*) Compiled version of CPMINT.FOR in Microsoft Relocatable format. This is also included as the first part of the CPMLIB.REL file. CPMLIB.DOC Documentatunctions prior to calling ; one of these entry points. ; As a result, this file is NOT a complete BDOS interface. ; It provides only the basic machine-level system calls. ; Arguments are assumed to be passed into these routines ; in Microsoft format (EQU 0 ;get address (disk parms) FN32 EQU 0 ;set/get user code FN33 EQU 0 ;read random FN34 EQU 0 ;write random FN35 EQU 0 ;compute file size FN36 EQU 0 ;set random record FN37 EQU 0 ;reset drive FN38 EQU 0 ;*** not defined *** FN39 EQU 0 ;* ; 30, 33, 34, 40 ; G 37 ; H 12, 24, 29 ; I 27, 31 ; (undefined) 38, 39 ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * PAGE ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; User-Defined added ; at a future time. ; (Note that many BDOS I/O functions are already contained ; within FORTRAN, so they do not need to be supported here.) ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; For an explanation of thedisk FN15 EQU 0 ;open file FN16 EQU 0 ;close file FN17 EQU 1 ;search for first EXIST (1) FN18 EQU 0 ;search for next FN19 EQU 1 ;delete file ERASE FN20 EQU 0 ;read sequential FN21 EQU 0 ;write sequential FN22 EQU 0 ;make file FN23 EQU 1 Returned value: A ; ; CLASS H: Function value: C ; Returned value: HL ; ; CLASS I: Function value: C ; Returned address: ; ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; Using this classification, tie. all arguments passed as addresses). ; ; The structure of this file is such that a maximum of ; two arguments can be passed from FORTRAN. This is because ; the third would be passed in the BC register pair, and ; register B is overwritten immediat ; Function FORTRAN ; Description Interface ; Routine ; FN0 EQU 0 ;system reset FN1 EQU 1 ;console input INCHR FN2 EQU 0 ;console output FN3 EQU 0 ;reader input FN4 EQU 0 ;punch output FN5 EQU 0 ;list output FN6 EQU 1 ;dirEquates ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; Define base of CP/M (std version is 0000H) ; ; BASE EQU 0000H ;<--- set to base of your CP/M ; ; ; ; Define which functions to support: 0 = no / 1 = yes ; ; various BDOS functions, see ; the "CP/M 2.0 INTERFACE GUIDE" (c) 1979 by Digital ; Research -- including the addendum for CP/M 2.2 ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; For programming expediency, the BDOS fun;rename file RENAME FN24 EQU 0 ;return login vector FN25 EQU 0 ;return current disk FN26 EQU 0 ;set DMA address FN27 EQU 0 ;get address (alloc) FN28 EQU 0 ;write protect disk FN29 EQU 0 ;get R/O vector FN30 EQU 0 ;get file attributes FN31 he functions (0 - 40) ; provided by CP/M version 2.2 are assigned ; as follows: ; ; CLASS FUNCTION ; ; A 0, 13, 28 ; B 1, 3, 7, 11, 18, 25 ; C 2, 4, 5, 8, 14 ; D 6, 32 ; E 9, 10, 26, 35, 36 ; F 15, 16, 17, 19, 20, 21, 22, 23, ely upon entry. ; If more than two arguments should be required at a future ; time, then the entry point would need to be restructured. ; ; For the time being, only a few BDOS functions are supported. ; However, the structure is such that more can be ect console I/O INKEY FN7 EQU 0 ;get I/O byte FN8 EQU 0 ;set I/O byte FN9 EQU 0 ;print string FN10 EQU 0 ;read console buffer FN11 EQU 0 ;get console status FN12 EQU 0 ;return version number FN13 EQU 0 ;reset disk system FN14 EQU 0 ;select alue: C ; Input value: E ; Returned value: A ; ; CLASS E: Function value: C ; Input address: ; ; CLASS F: Function value: C ; Input address: ; Returned value: A ; ; CLASS G: Function value: C ; Input value: DE ;ctions ; were assigned to arbitrary "classes". ; ; The "classes" are defined as: ; ; CLASS A: Function value: C ; ; CLASS B: Function value: C ; Returned value: A ; ; CLASS C: Function value: C ; Input value: E ; ; CLASS D: Function v** not defined *** FN40 EQU 0 ;write random with zero fill ; ; Notes: (1) used in RENAME, also. ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * PAGE ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * address of P1 in HL value of P1 in A ; GOTOB: SHLD P1 ;save address of param 1 CALL BDOS LHLD P1 ;restore address of param 1 MOV M,A ; and move returned value to it RET ENDIF PAGE IF CLASSC ; ; CLASS C ; -------- ; ; Arguments FO1 JMP GOTOF ENDIF ; IF FN22 ENTRY CPMF22 CPMF22: MVI C,22 JMP GOTOF ENDIF ; IF FN23 ENTRY CPMF23 CPMF23: MVI C,23 JMP GOTOF ENDIF ; IF FN24 ENTRY CPMF24 CPMF24: MVI C,24 JMP GOTOH ENDIF ; IF FN25 ENTRY CPMF25 CPMF25:KEP2+CLASSB+CLASSC+CLASSE+CLASSH ; PAGE ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; Define the entry points ; IF FN0 ENTRY CPMF0 CPMF0: MVI C,0 JMP GOTOA ENDIF ; IF FN1 ENTRY CPMF1 CPMF1: MVI C,1 JMP ENTRY CPMF37 CPMF37: MVI C,37 JMP GOTOG ENDIF ; IF FN38 .PRINTX /ERROR --- Function 38 is not defined in BDOS./ ENDIF ; IF FN39 .PRINTX /ERROR --- Function 39 is not defined in BDOS./ ENDIF ; IF FN40 ENTRY CPMF40 CPMF40: MVI C,4ENDIF ; IF FN14 ENTRY CPMF14 CPMF14: MVI C,14 JMP GOTOC ENDIF ; IF FN15 ENTRY CPMF15 CPMF15: MVI C,15 JMP GOTOF ENDIF ; IF FN16 ENTRY CPMF16 CPMF16: MVI C,16 JMP GOTOF ENDIF ; IF FN17 ENTRY CPMF17 CPMF17: MVI C,17 JMP ; ; Miscellaneous Equates ; BDOS EQU BASE+0005H ; ; Define which classes are active ; CLASSA EQU FN0+FN13+FN28 CLASSB EQU FN1+FN3+FN7+FN11+FN18+FN25 CLASSC EQU FN2+FN4+FN5+FN8+FN14 CLASSD EQU FN6+FN32 CLASSE EQU FN9+FN10+FN26+FN35+FN36 CPMF29: MVI C,29 JMP GOTOH ENDIF ; IF FN30 ENTRY CPMF30 CPMF30: MVI C,30 JMP GOTOF ENDIF ; IF FN31 ENTRY CPMF31 CPMF31: MVI C,31 JMP GOTOI ENDIF ; IF FN32 ENTRY CPMF32 CPMF32: MVI C,32 JMP GOTOD ENDIF ; IF FN33 ENTRY MVI C,25 JMP GOTOB ENDIF ; IF FN26 ENTRY CPMF26 CPMF26: MVI C,26 JMP GOTOE ENDIF ; IF FN27 ENTRY CPMF27 CPMF27: MVI C,27 JMP GOTOI ENDIF ; IF FN28 ENTRY CPMF28 CPMF28: MVI C,28 JMP GOTOA ENDIF ; IF FN29 ENTRY CPMF29 GOTOB ENDIF ; IF FN2 ENTRY CPMF2 CPMF2: MVI C,2 JMP GOTOC ENDIF ; IF FN3 ENTRY CPMF3 CPMF3: MVI C,3 JMP GOTOB ENDIF ; IF FN4 ENTRY CPMF4 CPMF4: MVI C,4 JMP GOTOC ENDIF ; IF FN5 ENTRY CPMF5 CPMF5: MVI C,5 JMP GOTOC 0 JMP GOTOF ENDIF ; PAGE IF CLASSA ; ; CLASS A ; -------- ; ; Arguments FORTRAN BDOS ; (none) ; GOTOA: CALL BDOS RET ENDIF PAGE IF CLASSB ; ; CLASS B ; -------- ; ; Arguments FORTRAN BDOS ; P1 (1-byte out) GOTOF ENDIF ; IF FN18 ENTRY CPMF18 CPMF18: MVI C,18 JMP GOTOB ENDIF ; IF FN19 ENTRY CPMF19 CPMF19: MVI C,19 JMP GOTOF ENDIF ; IF FN20 ENTRY CPMF20 CPMF20: MVI C,20 JMP GOTOF ENDIF ; IF FN21 ENTRY CPMF21 CPMF21: MVI C,2CLF EQU FN15+FN16+FN17+FN19+FN20+FN21+FN22+FN23 CLASSF EQU CLF+FN30+FN33+FN34+FN40 CLASSG EQU FN37 CLASSH EQU FN12+FN24+FN29 CLASSI EQU FN27+FN31 ; ; Define which temporary variables are needed ; MAKEP2 EQU CLASSD+CLASSF+CLASSG MAKEP1 EQU MA CPMF33 CPMF33: MVI C,33 JMP GOTOF ENDIF ; IF FN34 ENTRY CPMF34 CPMF34: MVI C,34 JMP GOTOF ENDIF ; IF FN35 ENTRY CPMF35 CPMF35: MVI C,35 JMP GOTOE ENDIF ; IF FN36 ENTRY CPMF36 CPMF36: MVI C,36 JMP GOTOE ENDIF ; IF FN37 IF FN10 ENTRY CPMF10 CPMF10: MVI C,10 JMP GOTOE ENDIF ; IF FN11 ENTRY CPMF11 CPMF11: MVI C,11 JMP GOTOB ENDIF ; IF FN12 ENTRY CPMF12 CPMF12: MVI C,12 JMP GOTOH ENDIF ; IF FN13 ENTRY CPMF13 CPMF13: MVI C,13 JMP GOTOA ENDIF ; IF FN6 ENTRY CPMF6 CPMF6: MVI C,6 JMP GOTOD ENDIF ; IF FN7 ENTRY CPMF7 CPMF7: MVI C,7 JMP GOTOB ENDIF ; IF FN8 ENTRY CPMF8 CPMF8: MVI C,8 JMP GOTOC ENDIF ; IF FN9 ENTRY CPMF9 CPMF9: MVI C,9 JMP GOTOE ENDIF ;RTRAN BDOS ; P1 (1-byte in) address of P1 in HL value of P1 in E ; GOTOC: SHLD P1 ;save address of param 1 MOV E,M ; and move contents to E CALL BDOS LHLD P1 ;restore address of param 1 RET ENDIF PAGE IF CLASSD ; ; CLASS D ; m 1 address MOV M,E ;then, transfer DE contents to INX H ; memory at P1 and P1+1 MOV M,D DCX H RET ENDIF PAGE IF CLASSI ; ; CLASS I ; -------- ; ; .PRINTX /WARNING -- CLASS I code not implemented yet./ ENDIF PAGE ; * * * * E ; -------- ; ; Arguments FORTRAN BDOS ; P1 (address in) address of P1 in HL address of P1 in DE ; GOTOE: SHLD P1 ;save param 1 XCHG ; and move to DE for BDOS CALL BDOS LHLD P1 ;restore param 1 RET ENDIF PAGE IF CLASSF ; ; d restore original order MOV E,M ;transfer 2-byte data in INX H ; param 1 into MOV D,M ; reg. pair DE CALL BDOS LHLD P2 ;restore param 2 to HL MOV M,A ; move returned value to it XCHG ; and return to DE LHLD P1 ;restore param 1 to HL RET -------- ; ; Arguments FORTRAN BDOS ; P1 (1-byte in) address of P1 in HL value of P1 in E ; P2 (1-byte out) address of P2 in DE value of P2 in A ; GOTOD: SHLD P1 ;save address of param 1 XCHG ; and swap SHLD P2 ;save address of param* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; Define temporary variables ; IF MAKEP1 P1: DS 2 ENDIF IF MAKEP2 P2: DS 2 ENDIF END  CLASS F ; -------- ; ; Arguments FORTRAN BDOS ; P1 (address in) address of P1 in HL address of P1 in DE ; P2 (1-byte out) address of P2 in DE value of P2 in A ; GOTOF: SHLD P1 ;save param 1 XCHG ; and swap params (ok for BDOS, too ENDIF PAGE IF CLASSH ; ; CLASS H ; -------- ; ; Arguments FORTRAN BDOS ; P1 (address out) address of P1 in HL 2-byte value in HL ; GOTOH: SHLD P1 ;save address of P1 CALL BDOS XCHG ;swap HL to DE LHLD P1 ; and restore para 2 XCHG ; and swap back MOV E,M ; and move contents to E CALL BDOS LHLD P2 ;restore param 2 to HL MOV M,A ; move returned value to it XCHG ; and swap back to DE LHLD P1 ;restore param 1 to HL RET ENDIF PAGE IF CLASSE ; ; CLASS PQT5c A5CPMF17QN`d5c#9@@aѐpI9taӐLf@wd`ESeh*wX2DU0" (USULdS% c j & bsj FqP m8ts FORTRAN BDOS ; P1 (2-byte in) address of P1 in HL value of P1 in DE ; P2 (1-byte out) address of P2 in DE value of P2 in A ; GOTOG: SHLD P1 ;save address of param 1 XCHG ; and swap params SHLD P2 ;save address of param 2 XCHG ; an) SHLD P2 ;save address of param 2 CALL BDOS LHLD P2 ;restore address of param 2 MOV M,A ; move returned value to it XCHG ; and return to DE LHLD P1 ;restore param 1 RET ENDIF PAGE IF CLASSG ; ; CLASS G ; -------- ; ; Argumen; ; CPMFNA ; ; CP/M Command Line - interface routine ; ; ; Originally written: November, 1981 ; ; Pre-release modifications: ; (none) ; ; Released to CP/M User's Group as: ; Version 1.0 ; January 12, 1982 ; ; Author: William R. Brandoni ; counter INX D ;Increment command line address INX H ;Increment param 1 address MOV C,A ;Save loop counter LDAX D ;Get next byte of line MOV M,A ; store in param 1 MOV A,C ;Restore loop counter JMP LOOP ; and try again EXIT: LHLD P1 ;ss input to ; a FORTRAN program at the command level. ; ; This file is intended as support to Microsoft FORTRAN ; subroutines which in turn provide all of the ; interfacing and setup functions prior to calling ; this subroutine. ; ; Arguments are a * * * * * * * * * * * * * * * * PAGE ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; ; Arguments FORTRAN ; P1 (address in) address of P1 in HL ; ENTRY CPMFNA CPMFNA: SHLD P1 ;Store param 1 and leave in LXI ; Language: Microsoft M80 (MACRO-80 assembler) Version 3.4 (26-Nov-80) ; ; ; See the "User-Defined Equates" section for modifications ; you may have to make to reassemble this file. ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *Restore original P1 address RET ; and return ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; Define temporary storage ; P1: DS 2 END ssumed to be passed into this routine ; in Microsoft format (ie. all arguments passed as addresses). ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; For an explanation of the command line processing, see ; the "CP/M 2.0 D,CMDLIN ;Load address of command line in LDAX D ;Get first byte (=no of bytes left) MOV M,A ; store in param 1 ; and leave in A as a counter MVI B,0 ;Set up B as loop counter LOOP: CMP B ;"Are we done?" JZ EXIT INR B ;Increment * * * ; ; This file is an interface for ; extracting the "Command Line Tail" from ; the CP/M operating system. ; ; The main reason for its existance is to provide ; an interface between Microsoft FORTRAN-80 and ; the command line, as a means to paQ`d5d@xEG(h.T`Gs &Z<j 3CPMFN MAC^GHIJKLMNOPQRCPMFN RELSCPMFNA MACTUVCPMFNA $$$CP/M (std version is 0000H) ; ; BASE EQU 0000H ;<--- set to base of your CP/M ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; Miscellaneous Equates ; CMDLIN EQU BASE+0080H ; ; * * * * * * * * * * * * * * * * * * *INTERFACE GUIDE" (c) 1979 by Digital ; Research ; ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * PAGE ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; User-Defined Equates ; ; ; Define base of C C C CPMINT.FOR C C Library of CP/M Function Subroutines for C Microsoft FORTRAN-80. C C C Originally written: November, 1981 C C Pre-release modifications: C Dec. 10, 1981 - Added EXIST routine C Dec. 18, 1981 - R Error Handling Routines C C NO FILE TO ERASE error IF ( CODE .NE. CERROR ) GOTO 100 CALL ERROR$ ( 1, SUBNAM, FCB ) GOTO 100 C DRIVE CONFLICT error 90 CALL ERROR$ ( 3, SUBNAM, FCB ) Cgenerated. C If the file to be erased cannot be found, C a NO FILE error will be generated. C C Output Arguments: C (none) C C C Examples of valid calls: C C CALL ERASE ( 0, 'b:ab.x', 6 ) C CAL * * C * E R A S E * C * * C * * * * * * * * * * C C SUBROUTINE ERASE ( NDRIVE, STRING, NBYTES ) C C CALL FCB$ ( STRING, LSTRNG, FCB ) C C Get the drive number, C set NDR to the maximum of these values, C and test for any conflicts. C NDRFCB = FCB(1) of bytes in the STRING array. C If entered as zero, the STRING will be assumed C to be 11 bytes long, with the file name blank C filled (in the same format as for a Microsoft C OPEN call). Ievised options for INCHR and INKEY C C Released to CP/M User's Group as: C Version 1.0 C January 12, 1982 C C Author: William R. Brandoni C C Language: Microsoft F80 (FORTRAN-80 compiler) Version 3.4 (26-Nov-80) C C C C C + examples will erase the file AB.X on drive B:. C IMPLICIT LOGICAL*1 ( A-H, O-Z ), INTEGER ( I-N ) C DIMENSION FCB (36) DIMENSION STRING (1) DIMENSION SUBNAM (6) C DATA SUBNAM / 'E','R','A','S','E',' ' / C C ThL ERASE ( 2, 'AB.X', 4 ) C CALL ERASE ( 2, 'AB X ', 11 ) C CALL ERASE ( NDR, FILNAM, NLONG ) C C Assuming that, in the last example, NDR = 2, FILNAM is a byte C array containing "ab.x", and NLONG = 4, then all of the C NDRIVE = < integer > C STRING = < byte array > C NBYTES = < integer > C C Erase a CP/M file. C C The file being erased should be closed before this routine C is called. Otherwise, duplicate FCB's will NDR = MAX0 ( NDRIVE, NDRFCB ) IF ( NDRFCB .LE. 0 .OR. NDRIVE .LE. 0 ) GOTO 20 IF ( NDRIVE .NE. NDRFCB ) GOTO 90 C 20 FCB(1) = NDR C C Call BDOS function 19 C CALL CPMF19 ( FCB, CODE ) C Cn this mode, the drive cannot be C passed in the file name. C C Note: The drive may be specified in several ways. If more C than one specification is used, they must all agree C or a DRIVE CONFLICT error will be + + + + + + + + + + + + + HIGH LEVEL ROUTINES + + + + + + + + + + + + + + C C Primary Entry Points C into the Library C C C * * * * * * * * * * C e following data statement sets CERROR to 0FFH, C which is the return code for an error (file not found). C DATA CERROR /.TRUE./ C C Set Up the FCB C LSTRNG = NBYTES IF ( NBYTES .EQ. 0 ) LSTRNG = 11ray contains C a drive specification in the file name. C STRING ... A byte array containing a valid CP/M file name. C The name may contain a drive specification if C desired. C NBYTES ... The numberexist for the C file and unpredictable results may occur. C C Input Arguments: C NDRIVE ... Drive number (1=A:, 2=B:, etc.) C If entered as zero, then the currently-logged C drive is used unless the STRING ar C Return to calling program C 100 RETURN END C * * * * * * * * * * C * * C * E X I S T * C o upper case. C C The user's program must interpret the "tail". All this C routine does is pass it to the FORTRAN program, after C leading blanks are stripped off. C C Some other considerations: C C You MUST get the "tail" these values, C and test for any conflicts. C NDRFCB = FCB(1) NDR = MAX0 ( NDRIVE, NDRFCB ) IF ( NDRFCB .LE. 0 .OR. NDRIVE .LE. 0 ) GOTO 20 IF ( NDRIVE .NE. NDRFCB ) GOTO 90 C 20 FCB(1) =rive is used unless the STRING array contains C a drive specification in the file name. C STRING ... A byte array containing a valid CP/M file name. C The name may contain a drive specification if C desiommand line tail" and pass it C into the calling program. C Leading blanks are stripped off. C C The "tail" is that part of the command line that follows C the program name. For example, if the following line C were typed at the 1 = file exists C IMPLICIT LOGICAL*1 ( A-H, O-Z ), INTEGER ( I-N ) DIMENSION FCB (36) DIMENSION STRING (1) DIMENSION SUBNAM (6) DATA CERROR /.TRUE./ DATA SUBNAM / 'E','X','I','S','T',' ' / C C * * C * * * * * * * * * * C C SUBROUTINE EXIST ( NDRIVE, STRING, NBYTES, IOK ) C C NDRIVE = < integer > C STRING = < byte array > C NBYTES error 90 CALL ERROR$ ( 3, SUBNAM, FCB ) C C Return to calling program C 100 RETURN END C * * * * * * * * * * C * * C NDR C C Call BDOS function 17 C CALL CPMF17 ( FCB, CODE ) IOK = 1 IF ( CODE .EQ. CERROR ) IOK = 0 GOTO 100 C C Error Handling Routines C C DRIVE CONFLICTred. C NBYTES ... The number of bytes in the STRING array. C If entered as zero, the STRING will be assumed C to be 11 bytes long, with the file name blank C filled (in the same format as for a Microsoftconsole following a CP/M prompt: C C b:foo options:a,c,d,f,l C C the system would load program FOO.COM from drive B: and the C "tail" would be the character string OPTIONS:A,C,D,F,L. C C CP/M will always map the command line t Set Up the FCB C LSTRNG = NBYTES IF ( NBYTES .EQ. 0 ) LSTRNG = 11 CALL FCB$ ( STRING, LSTRNG, FCB ) C C Get the drive number, C set NDR to the maximum of= < integer > C IOK = < integer > C C Test to see if a file exists. C C C Input Arguments: C NDRIVE ... Drive number (1=A:, 2=B:, etc.) C If entered as zero, then the currently-logged C d * G E T C M D * C * * C * * * * * * * * * * C C SUBROUTINE GETCMD ( ARRAY ) C C ARRAY = < byte array > C C This routine will get the "cr a DRIVE CONFLICT error will be generated. C If the file to be erased cannot be found, C a NO FILE error will be generated. C C Output Arguments: C IOK ...... Returned value: C 0 = file doesn't exist C C OPEN call). In this mode, the drive cannot be C passed in the file name. C C Note: The drive may be specified in several ways. If more C than one specification is used, they must all agree C obefore any disk operations C are performed in the program. Otherwise, CP/M may C overwrite the command line buffer during a disk C operation. Thus, you should call this routine as C one of the first activities in your * C * * * * * * * * * * C C SUBROUTINE INKEY ( NOPT, CHAR ) C C NOPT = < integer > C CHAR = < byte > C C This function reads a character from the console. C * * C * * * * * * * * * * C C SUBROUTINE INCHR ( NOPT, CHAR ) C C NOPT = < integer > C CHAR = < byte > C C This subroutine reads a ch program instructions may be overwritten C by the command line information. Dimensioning C the variable to 80 bytes is usually sufficient. C The FIRST BYTE of the returned array will contain C Output Arguments: C CHAR ..... The resulting character. C IMPLICIT LOGICAL*1 ( A-H, O-Z ), INTEGER ( I-N ) C DATA CTRLC / 3 / C CALL CPMF1 ( A ) CHAR = A IF ( NOPT .AND. 2 ) CALL MAP$ ( A, CHAR ) IF0 N = 1, NBYTES N1 = N + 1 N2 = N + 2 200 ARRAY(N1) = ARRAY(N2) GOTO 100 C C Return, making sure a one-character C command isn't a blank. C 500 CONTINUE IF ( ARRAprogram. C C You should scan the "tail" carefully, watching out C for trailing and imbedded blanks. The line C will be passed exactly as typed except for mapping C to upper case. C C Input arguments: C ( The character is transmitted as soon as it is typed. C The RETURN or ENTER key is not required to complete the C entry. C C Input Arguments: C NOPT ..... Option for interpretation of input character. C (Add the foaracter from the console. C The character is immediately echoed to the console. C It is also returned as the value of the argument CHAR. C C If no character is pending at the console, execution C halts until a character is typed. C C the number of characters to follow. Only these C characters are valid. The remainder of the array C will be unchanged from its original contents, or C will contain "garbage". C IMPLICIT LOGICAL*1 ( (NOPT .AND. 4) .AND. (A .EQ. CTRLC) ) STOP RETURN END C * * * * * * * * * * C * * C * I N K E Y * C *Y(1) .NE. 1 ) GOTO 550 IF ( ARRAY(2) .EQ. BLANK ) ARRAY(1) = ZERO 550 RETURN END C * * * * * * * * * * C * * C * I N C H R * C none) C C Output arguments: C ARRAY .... This is a byte array, which must be dimensioned C in the calling program to a length sufficient to C hold the entire "tail". Otherwise, important C data orllowing values together to determine C the value to use.) C 0 = (no option) C 1 = (no option) C 2 = map lower case alphabet to upper case C 4 = stop execution if ctrl-C C C Strip off leading blanks C by shifting contents left one byte. C 100 IF ( ARRAY(1) .LE. ONE ) GOTO 500 IF ( ARRAY(2) .NE. BLANK ) GOTO 500 ARRAY(1) = ARRAY(1) - ONE NBYTES = ARRAY(1) DO 20( A-H, O-Z ), INTEGER ( I-N ) DIMENSION ARRAY (1) DATA BLANK / ' ' / DATA ONE / 1 / DATA ZERO / 0 / C C Get the command line as typed C CALL CPMFNA ( ARRAY ) C C The character is not echoed to the console. C It is returned as the value of the argument CHAR. C C If no character is pending at the console, the C NUL character (ASCII 0) is returned and execution C of the program continues. C B1 = 4, and NB2 = 4, then all of the C examples will rename the file AB.X to CD.Y on drive B:. C IMPLICIT LOGICAL*1 ( A-H, O-Z ), INTEGER ( I-N ) C DIMENSION FCB (36) DIMENSION FNOLD (1) DIMENSION FNNEW (1) DIMENSame. C FNNEW .... A byte array containing a valid CP/M file name. C The name may contain a drive specification if C desired. C FNOLD is the old name; FNNEW is the new name. C NBOLD ... The number ofution if ctrl-C C C Output Arguments: C CHAR ..... The resulting character. C IMPLICIT LOGICAL*1 ( A-H, O-Z ), INTEGER ( I-N ) C DATA CTRLC / 3 / DATA FF /.TRUE./ DATA ZERO / 0 / C 10 CALL CPMF6 ( FF, A ) C C Output Arguments: C (none) C C C Examples of valid calls: C C CALL RENAME ( 0, 'b:ab.x', 'cd.y', 6, 4 ) C CALL RENAME ( 0, 'ab.x', 'b:cd.y', 4, 6 ) C CALL RENAME ( 2, 'ab.x', 'cd.y', 4, 4 ) C C The file being renamed should be closed before this routine C is called. Otherwise, duplicate FCB's will exist for the C file and unpredictable results may occur. C C Input Arguments: C NDRIVE ... Drive number (1=A:, 2=B:, etc.) C The character is transmitted as soon as it is typed. C The RETURN or ENTER key is not required to complete the C entry. C C Input Arguments: C NOPT ..... Option for interpretation of input character. C (Add the f as for a Microsoft C OPEN call). In this mode, the drive cannot be C passed in the file name. C C Note: The drive may be specified in several ways. If more C than one specification is used, they must all a bytes in the FNOLD array. C NBNEW ... The number of bytes in the FNNEW array. C If entered as zero, the array will be assumed C to be 11 bytes long, with the file name blank C filled (in the same format IF ( (NOPT .AND. 1) .AND. (A .EQ. ZERO) ) GOTO 10 CHAR = A IF ( NOPT .AND. 2 ) CALL MAP$ ( A, CHAR ) IF ( (NOPT .AND. 4) .AND. (A .EQ. CTRLC) ) STOP RETURN END C * * * * * * * * * * ALL RENAME ( 2, 'AB X ', 'CD Y ', 0, 0 ) C CALL RENAME ( NDR, FIL1, FIL2, NB1, NB2 ) C C Assuming that, in the last example, NDR = 2, FIL1 is a byte C array containing "ab.x", FIL2 is a byte array containing C "cd.y", N C If entered as zero, then the currently-logged C drive is used unless the FNOLD or FNNEW array C contains a drive specification in the file name. C FNOLD .... A byte array containing a valid CP/M file nollowing values together to determine C the value to use.) C 0 = (no option) C 1 = wait for a character to be typed C 2 = map lower case alphabet to upper case C 4 = stop execgree C or a DRIVE CONFLICT error will be generated. C If the new file name already exists, a FILE ALREADY C EXISTS error will be generated. If the old file C cannot be found, a NO FILE error will be generated. , NBOLD, NBNEW ) C C NDRIVE = < integer > C FNOLD = < byte array > C FNNEW = < byte array > C NBOLD = < integer > C NBNEW = < integer > C C Rename a CP/M file. C CC * * C * R E N A M E * C * * C * * * * * * * * * * C C SUBROUTINE RENAME ( NDRIVE, FNOLD, FNNEWION SUBNAM (6) C DATA SUBNAM / 'R','E','N','A','M','E' / DATA ONE / 1 / DATA ZERO / 0 / C C The following data statement sets CERROR to 0FFH, C which is the return code for an error (file not found). C DATA CER Fill out the file information C CALL FNAME$ ( STRING, LSTRNG, NDRIVE, FCB ) C C That's all, folks. C RETURN END C * * * * * * * * * * C DRIVE CONFLICT error 90 CALL ERROR$ ( 3, SUBNAM, FCB ) C C Return to calling program C 100 RETURN END C C C + + + + + + + + + + + + + + LOW LEVEL ROUTINES + + + + + + + + + + + + + + C C NDRIVE .GT. 0 ) DRIVES = DRIVES + ONE IF ( DRIVES .LE. ONE ) GOTO 20 IF ( NDRIVE .LE. 0 ) GOTO 10 C NDRIVE was specified, so compare to it DRIVES = DRIVES - ONE IF ( NDROLD .LE. 0 ) GOTO 5 IF (guments: C FCB ...... The completed FCB ( a byte array ) which must C be 36 bytes long. The first 12 bytes will be C initialized to the drive and file specified C in STRING. The remainder will be zeroed LSTRNG = NBNEW IF ( NBNEW .EQ. 0 ) LSTRNG = 11 CALL FNAME$ ( FNNEW, NBNEW, NDRNEW, FCB(17) ) FCB(17) = ZERO C C Call BDOS function 23 C CALL CPMF23 ( FCB, CODE ) C C ROR /.TRUE./ C C C C Get the drive info from each string, C set NDR to the maximum of these values, C and test for any conflicts. C CALL FNAME$ ( FNOLD, NBOLD * * C * * * * * * * * * * C C SUBROUTINE FCB$ ( STRING, LSTRNG, FCB ) C C STRING = < byte array > C LSTRNG = < integer > C FCB = < Service Routines for C High-Level Routines C C C C * * * * * * * * * * C * * C * F C B $ * C NDRIVE .NE. NDROLD ) GOTO 90 5 IF ( NDRNEW .LE. 0 ) GOTO 10 IF ( NDRIVE .NE. NDRNEW ) GOTO 90 C See if the two string drives need to be tested C and do it. 10 IF ( DRIVES .LE. ONE ) GOTO 20 IF ( NDROLD .NE.. C IMPLICIT LOGICAL*1 ( A-H, O-Z ), INTEGER ( I-N ) DIMENSION STRING(LSTRNG) DIMENSION FCB(36) DATA ZERO / 0 / C C Zero the FCB array C DO 100 K = 1, 36 100 FCB(K) = ZERO C C Error handling routines C C RENAME function error IF ( CODE .NE. CERROR ) GOTO 100 CALL ERROR$ ( 1, SUBNAM, FCB ) GOTO 100 C NEW FILE EXISTS error 80 CALL ERROR$ ( 2, SUBNAM, FCB ) GOTO 100 C , NDROLD, FCB ) CALL FNAME$ ( FNNEW, NBNEW, NDRNEW, FCB ) NDR = MAX0 ( NDRIVE, NDROLD, NDRNEW ) DRIVES = ZERO IF ( NDROLD .GT. 0 ) DRIVES = DRIVES + ONE IF ( NDRNEW .GT. 0 ) DRIVES = DRIVES + ONE IF ( byte array > C C Subroutine to build a valid File Control Block (FCB) C C Input arguments: C STRING ... Input string ( a byte array ) of length LSTRNG C LSTRNG ... Integer value is length of STRING array in bytes. C C Output ar Perform the RENAME operation C by setting up the proper format C for the FCB. C LSTRNG = NBOLD IF ( NBOLD .EQ. 0 ) LSTRNG = 11 CALL FCB$ ( FNOLD, LSTRNG, FCB ) NDRNEW ) GOTO 90 C C See if the New File already exists C 20 CONTINUE CALL FCB$ ( FNNEW, NBNEW, FCB ) FCB(1) = NDR CALL CPMF17 ( FCB, CODE ) IF ( CODE .NE. CERROR ) GOTO 80 C C * * C * F N A M E $ * C * * C * * * * * * * * * * C C SUBROUTINE FNAME$ ( STRING, LSTRNG, NDRIVE, FILNAM ) C ( WORKER(2) .NE. COLON ) GOTO 200 KSTART = 3 C C Drive is specified. Convert as follows: C C A: or 0: set to 1 C B: or 1: set to 2 C C: or 2: set to 3 C D: or 3: set to 4 C IF ( WO C DIMENSION FILNAM(12) DIMENSION STRING(LSTRNG) DIMENSION WORKER(14) C C DATA BLANK / ' ' / DATA COLON / ':' / DATA PERIOD / '.' / DATA QUEST / '?' / DATA STAR / '*' / C C tion is extracted C if it is included in the string as the first character C followed by a colon (:). C Thus, all valid CP/M file descriptions will be handled C properly. C C Input Arguments: C STRING ... Input string ( a byt = 0 KDOT = 0 C DO 100 K = KSTART, LSTRNG KOUNT = KOUNT + 1 IF ( KOUNT .GT. 14 ) GOTO 110 WORKER(KOUNT) = STRING(K) IF ( WORKER(KOUNT) .EQ. PERIOD ) KDOT = KOUNT CALL MAP$ ( WORKER(KOUNT), WORKER(KOUNlun, FILNAM(2), NDRIVE ) C where 'lun' is the unit number. Specifying FILNAM(2) in C the argument list passes the address of the second element C which is the first character of the 11-byte file name. C C 2) To construct a CPC STRING = < byte array > C LSTRNG = < integer > C NDRIVE = < integer > C FILNAM = < byte array > C C Subroutine to extract a CP/M file name from an input C character string. C 10 FILNAM(K) = BLANK C WORKER(13) = BLANK WORKER(14) = BLANK FILNAM( 1) = NDRIVE C C Search for first non-blank in STRING C KSTART = 0 C DO 20 K = 1, LSTRNG IF ( STRING(K) .EQ. BLANK ) GOTO 20 First, transfer STRING to WORKER array C and map any lower case to upper case. C C Blank-fill WORKER C Blank-fill FILNAM C NDRIVE = 0 C DO 10 K = 1, 12 WORKER(K) = BLANK e array ) of length LSTRNG C LSTRNG ... Integer value is length of STRING array in bytes. C C Output Arguments: C NDRIVE ... Integer value of drive number: C 0 = logged in drive C 1 = drive A: C T) ) 100 CONTINUE C C Then, check for drive specification. C This is true only if the second character C is a colon. C 110 NDRIVE = 0 KSTART = 1 IF/M file control block (FCB), use the C FILNAM array as the first 12 bytes of the FCB, and the C drive specification will be placed in the first byte as C required. C C C IMPLICIT LOGICAL*1 ( A-H, O-Z ), INTEGER ( I-N ) C Complete error trapping is NOT included in this routine. C Thus, the programmer should excercize some caution in C the use of this routine. C Asterisks (*) are expanded into questions for the file C name and file type, and drive informa KSTART = K GOTO 50 20 CONTINUE C GOTO 300 C C Transfer STRING into WORKER C starting at first non-blank. C Mapping to upper case takes place here. C Also, search for PERIOD character. C 50 KOUNT, blank-filled to exactly 11 characters. C C The format of the output arguments is such that they serve C two purposes: C C 1) To construct a Microsoft FORTRAN call to the OPEN subroutine, C use the form: C CALL OPEN ( 2 = drive B: C etc. C FILNAM ... Output string ( a byte array ) of length 12. C The first byte duplicates the drive value in C NDRIVE. The remaining bytes are the name and C extensionRKER(1) .GE. 65 ) WORKER(1) = WORKER(1) - 17 NDRIVE = WORKER(1) - 47 C C Set up the FILNAM vector. C 200 CONTINUE FILNAM(1) = NDRIVE C C Transfer the file name (first 8 characters). C Test 10 IF ( ARRAY(1) .EQ. ZERO ) GOTO 11 DRIVE = ARRAY(1) + ALPHA WRITE ( LIO, 9010 ) (ANAME(J), J = 1, 6), DRIVE, A (ARRAY(J), J = 2, 12) GOTO 1000 11 WRITE ( LIO, 9011 ) (ANAME(J), J = 1, 6), A 100 RETURN END C * * * * * * * * * * C * * C * E R R O R $ * C * * C haracters). C Test to see if first character is a star (*). C If so, make file type all questions (?). C 220 KOUNT = 9 KSTART = KSAVE + 1 IF ( KDOT .GT. 0 ) KSTART = KDOT + 1 KSTOP = KSTART + 2 QSTAR = .HA / 64 / C The LIO variable defines the output device for error C messages. Device 3 is the default device used by C Microsoft for FORTRAN run-time errors. DATA LIO / 3 / C The NMAX variable defines the maximumC C If the input character is not a lower case alphabet C character, no mapping takes place. C C Input Arguments: C AIN ..... The one-byte value to be mapped. C C Output Arguments: C AOUT .... The one-byte value mapped to u.to see if first character is a star (*). C If so, make file name all questions (?). C KOUNT = 1 KSTOP = KSTART + 7 QSTAR = .FALSE. IF ( WORKER(KSTART) .EQ. STAR ) QSTAR = .TRUE. C DO 210 K = KSTART, KSTOP Arguments: C NERROR ... Number of the error message to print. C ANAME .... A six-byte name for the routine which called C the error. C ARRAY .... A byte array, the contents of which depend on C the error bein * * * * * * * * * * C C SUBROUTINE ERROR$ ( NERROR, ANAME, ARRAY ) C C NERROR = < integer > C ANAME = < byte array > C ARRAY = < byte array > C C C Error printing routine. C C InputFALSE. IF ( WORKER(KSTART) .EQ. STAR ) QSTAR = .TRUE. C DO 250 K = KSTART, KSTOP KOUNT = KOUNT + 1 IF ( QSTAR ) GOTO 240 FILNAM(KOUNT) = WORKER(K) GOTO 250 240 FILNAM(KOUNT) = QUEST 250 CONTINUE C C error code C available in this version. DATA NMAX / 3 / DATA ZERO / 0 / C C IF ( NERROR .LT. 1 .OR. NERROR .GT. NMAX ) GOTO 500 GOTO ( 10, 20, 30 ), NERROR C C FILE NOT FOUND error C c. C IMPLICIT LOGICAL*1 ( A-H, O-Z ), INTEGER ( I-N ) C DATA ALOWER / 'a' / DATA AOFSET / 32 / DATA ZLOWER / 'z' / C IF ( AIN .LT. ALOWER ) GOTO 100 IF ( AIN .GT. ZLOWER ) GOTO 100 AOUT = AIN - AOFSET KOUNT = KOUNT + 1 KSAVE = K IF ( QSTAR ) GOTO 205 IF ( WORKER(K) .EQ. PERIOD ) GOTO 220 FILNAM(KOUNT) = WORKER(K) GOTO 210 205 FILNAM(KOUNT) = QUEST 210 CONTINUE C C Transfer the file type (last 3 cg processed. C C Output Arguments: C (none) C IMPLICIT LOGICAL*1 ( A-H, O-Z ), INTEGER ( I-N ) DIMENSION ANAME(6), ARRAY(1) C The ALPHA variable maps the drive number to upper C case alphabet. DATA ALP * * C * * * * * * * * * * C C SUBROUTINE MAP$ ( AIN, AOUT ) C C AIN = < byte > C AOUT = < byte > C C Map a lower cas