home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol030 / sigmlog.023 < prev    next >
Text File  |  1985-02-09  |  38KB  |  978 lines

  1. Sig/M volume 23        MBasic disassembler
  2.             Date Routines
  3.             miscellaneous utilities
  4.  
  5.     (original materials from Pascal Z User Group volume 5)
  6.  
  7.     -CATALOG.023        contents of Sig/M volume 23
  8.     ABSTRACT.023        comments
  9.     CRCKFILE.023        CRC of Sig/M volume 23
  10.  
  11.  
  12. 23.1    EXPO.PAS    á         demo on the use of exponents
  13. 23.2    EXPO.COM              /
  14. 23.3    COMPARE.DOC           UCSD program Compare documentation
  15. 23.4 á  DISASMB.DO├           disassembler in MICROSOFT Basic
  16.  
  17.     related modules
  18. 8085      LST            8085      TAB            XREF      BAS
  19. ZILOG     LST            ZILOG     TAB            XREF      SUB
  20. INTEL     LST            INTEL     TAB            TDL       LST
  21. TDL       TAB            LST8085   BAS            LSTINTEL  BAS
  22. LSTTDL    BAS            LSTZILOG  BAS            TAB8085   BAS
  23. TABINTEL  BAS            TABTDL    BAS            TABZILOG  BAS
  24. DISASMB   BAS            
  25.  
  26. 23.5.   DATE.DOC             dates routines 
  27.  
  28.     related modules
  29. PROMT     LIB            MAKEDATE  LIB            RMAKEDA  LIB
  30. BRKDATE   LIB            DASTRLON  LIB            DASTRSH  LIB
  31. DASTRFIX  LIB            DATE      PAS            DATEFUNC LIBè
  32. 23.6    MISC.DOC         miscellaneous routines
  33.  
  34.     related modules
  35. GETINT    LIB            CAPCHAR   LIB            PADSTR   LIB
  36. CAPSTR    LIB            DEPAD     LIB            STRVAL   LIB
  37.  
  38. 23.7   HANOI COM/PAS        
  39. 23.8   DIS.ASM/DOC          
  40. 23.9   CONFER.PAS/COM       conference scheduling
  41.  
  42.                CONTENTS OF VOLUME #5
  43.  
  44.   ╔á aφ startinτ t∩ ge⌠ feedbacδ froφ thσ membershi≡ no≈ anΣ thi≤ ì
  45. disδ i≤ thσ beginning«á  ╔ aφ ver∙ happ∙ t∩ pas≤ oε mos⌠ anythinτ ì
  46. tha⌠á anyonσ writes«á  ╔ onl∙ asδ tha⌠ i⌠ work«á  Iµ you≥ prograφ ì
  47. ha≤á specia∞ requirement≤ bσ surσ anΣ includσá tha⌠á information«  ì
  48. A⌠á first¼á ╔ wa≤ goinτ t∩ onl∙ includσ sourcσ oε thesσ disk≤á s∩ ì
  49. tha⌠á ╔ coulΣ ge⌠ morσ item≤ oε them«á  But¼á s∩ man∙ peoplσá arσ ì
  50. eithe≥ jus⌠ startinτ ou⌠ anΣ don'⌠ havσ enougΦ knowledgσ o≥ can'⌠ ì
  51. afforΣá everythinτ tha⌠ ma∙ bσ necessary«á  S∩ tha⌠ i≤ wh∙ ╔á pu⌠ ì
  52. botΦá sourcσá anΣ runninτ program≤ oε thesσ disks«á Tha⌠ wa∙á thσ ì
  53. advanceΣá caε modif∙ t∩ thei≥ heart≤ conten⌠ anΣ ye⌠á thσá novicσ ì
  54. can use the programs.  
  55.  
  56.       Kenneth Kuller of Eagan, Maine submitted these programs.
  57.  
  58. 1« EXPO.PAS/CO═á         Hσá wanteΣ ß benchmarδ prograφá s∩á hσ ì
  59.                          wrote this. It is a good Demo on the use
  60.                          of exponents.
  61. 2. COMPARE.DOC           Ken feels, as I do, that credit should
  62.                          be given when due. On disk#1 there is a
  63.                          UCSD program called Compare that needed
  64.                          to be converted to Pascal/Z. I didn't
  65.                          receive the Doc file with the program
  66.                          but Ken found it.So here it is and the
  67.                          proper credits are included.
  68.  
  69.      This next large group was submitted by Scott Custin of
  70. Washington,DC.
  71.  
  72. 3«á  DISASMB.DO├-----ReaΣ thi≤ firs⌠ becausσ therσ arσ ß lo⌠á oµ ì
  73.      small program associated with this disassembler. It is in
  74.      MICROSOFT Basic,Version 5.1 which I would not normally use
  75.      but since it does disassemble TDL plus Z80 plus 8080 plus
  76.      8085 I figured someone, somewhere would be tickled to get
  77.      this.
  78.  
  79. 8085      LST            8085      TAB            XREF      BAS
  80. ZILOG     LST            ZILOG     TAB            XREF      SUB
  81. INTEL     LST            INTEL     TAB            TDL       LST
  82. TDL       TAB            LST8085   BAS            LSTINTEL  BAS
  83. LSTTDL    BAS            LSTZILOG  BAS            TAB8085   BAS
  84. TABINTEL  BAS            TABTDL    BAS            TABZILOG  BAS
  85. DISASMB   BAS            
  86.  
  87. 4.   DATE.DOC-----Again, read this first since Scott has included
  88.      several programs, all dealing with dates. These routines 
  89.      treat a date as one of a series of consecutive integers.
  90.      The concept is similar to Julian dates, used by a number of
  91.      "BIG" computer programs, and has a number of advantages over
  92.      storing the month, day and year separately.
  93.  
  94. PROMT     LIB            MAKEDATE  LIB            RMAKEDA  LIB
  95. BRKDATE   LIB            DASTRLON  LIB            DASTRSH  LIB
  96. DASTRFIX  LIB            DATE      PAS            DATEFUNC LIBè
  97. 5.  MISC.DOC-----Yep, read this first. Scott tossed in some odds
  98.      and ends. You have to give Scott credit, he sure has been
  99.      creative. Keep this up folks, and we will have a excellent
  100.      LIBRARY.
  101.  
  102. GETINT    LIB            CAPCHAR   LIB            PADSTR   LIB
  103. CAPSTR    LIB            DEPAD     LIB            STRVAL   LIB
  104.  
  105. 6.  HANOI COM/PAS        I included this not for its game value
  106.                          but it is an excellent Demo on recursive
  107.                          procedures. If you can see how this works
  108.                          (its deep) you'll certainly understand
  109.                          local versus global variables.
  110.      
  111. 7.  DIS.ASM/DOC          This was given to me for our TDL use.
  112.                          However, the three or four assemblers
  113.                          I had available would not assemble it
  114.                          without massive errors. So if anyone
  115.                          does make a COM file that works good
  116.                          be sure and send me a copy. Let me
  117.                          know what assembler you used also.
  118.  
  119. 8.  CONFER.PAS/COM       Just to show you how long Ray has been
  120.                          chipping away at Pascal/Z, I thought
  121.                          I would include this old one.  It 
  122.                          does have some useful ideas and can
  123.                          be used as is. It sets up a schedule
  124.                          for a conference.
  125.  COMPARE - Compare Two Textfiles                  03 Jan 79
  126.  
  127.       Compare - Compare Two Textfiles and Report Their Differences
  128.  
  129.                 James F.  Miner
  130.            Social Science Research Facilities Center
  131.                   Andy Mickel
  132.                University Computer Center
  133.             University of Minnesota
  134.                Minneapolis, MN 55455 USA
  135.  
  136.                Copyright (c) 1977, 1978.
  137.  
  138.  What COMPARE Does
  139.  -----------------
  140.  
  141.       COMPARE is used to display the differences  between  two    similar
  142.  texts    (referred  to as "FILEA" and "FILEB").    Such textfiles could be
  143.  Pascal source programs, character data, documentation, etc.
  144.  
  145.       COMPARE is line-oriented, meaning the smallest unit of comparison
  146.  is  the  text    line  (ignoring  trailing blanks).  COMPARE generates a
  147.  report of differences (mismatches  or    extra  text)  between  the  two
  148.  textfiles.   The criterion for determining the locality of differences
  149.  is the number of consecutive lines on each file which must match after
  150.  a prior mismatch, and can be selected as a parameter.
  151.  
  152.       By selecting other parameters, you can direct COMPARE to restrict
  153.  the comparison to various linewidths, mark column-wise the differences
  154.  in  pairs  of    mismatched lines, generate text-editor directives to be
  155.  used to convert FILEA into FILEB, or generate    a  listing  which  will
  156.  flag  lines on FILEB indicating their addition or deletion as a result
  157.  of the application of the editor directives.
  158.  
  159.  How to Use COMPARE
  160.  ------------------
  161.  
  162.       COMPARE is available as an operating system control statement  on
  163.  CDC  6000/Cyber  70,170  computer  systems.   The  general form of the
  164.  control statement is:
  165.  
  166.       COMPARE(a,b,list,modfile/options)
  167.  
  168.       COMPARE.    means  COMPARE(FILEA,FILEB,MODS/C6,D,W120)
  169.  
  170.       "FILEA" and "FILEB" are the names  of  the  two  textfiles  being
  171.  compared, "OUTPUT" is the report file, and "MODS" is the file name for
  172.  the  generation  of  text-editor  directives  if  the    "M"  option  is
  173.  selected--see below.  The various options are:  C, D, F, M, P, and W.
  174.  
  175.  
  176.  
  177.                  - 1 -
  178.  
  179.  
  180.  COMPARE - Compare Two Textfiles                  03 Jan 79
  181.  
  182.   Cn   Match Criterion (1 <= n <= 100).
  183.       C  determines  the  number  of consecutive lines on each file
  184.       which  must  match  in  order  that  they  be  considered  as
  185.       terminating  a prior mismatch.  C therefore affects COMPARE's
  186.       "sensitivity" to the "locality" of differences.  Setting C to
  187.       a  large value tends to produce fewer (but longer) mismatches
  188.       than does a small value.  C6 appears to give good results  on
  189.       Pascal  source  files,  but  may  be    inappropriate for other
  190.       applications.
  191.       Default:  C6.
  192.  
  193.   D    Report Differences.
  194.       D directs  COMPARE  to  display  mismatches  and  extra  text
  195.       between  FILEA and FILEB in a clearly annotated report.  Only
  196.       one of D, F, or M can be explicitly selected at one time.
  197.       Default:  selected.
  198.  
  199.   F    Select Flag-form output.
  200.       F directs COMPARE to list FILEB annotated with lines prefixed
  201.       by  an  "A"  or  "D"    indicating  "additions"  or "deletions"
  202.       respectively.  Such modifications could have    been  generated
  203.       with    the M option.  Only one of D, F, or M can be explicitly
  204.       selected at one time.
  205.       Default:  not selected.
  206.  
  207.   M    Produce MODS file.
  208.       M directs COMPARE to produce a file of "INSERT"  or  "DELETE"
  209.       directives  ready  for  the CDC MODIFY or UPDATE text editors
  210.       (an "IDENT" directive must be  added).   The    insertions  and
  211.       deletions  will  convert  FILEA  into FILEB.    FILEA and FILEB
  212.       should be files with sequencing appearing in    columns  beyond
  213.       the  linewidth  specified  by  the W option.    This is true of
  214.       MODIFY and  UPDATE  "COMPILE"  files    (W72  is  recommended).
  215.       Sequence numbers are of the form:
  216.  
  217.            {Blanks} IdentName {Blanks} UnsignedInteger.
  218.  
  219.       Only    one  of  D,  F,  or M can be explicitly selected at one
  220.       time.
  221.       Default:  not selected.
  222.  
  223.   P    Mark Pairs of mismatched lines.
  224.       P alters the action of the D directive by  marking  differing
  225.       columns in pairs of lines which mismatch in sections of equal
  226.       length.  This is especially useful for comparing packed  data
  227.       files.
  228.       Default:  not selected.
  229.  
  230.   Wn   Specify significant line Width (length) (10 <= n <= 150).
  231.       W  determines  the fixed number of columns of each line which
  232.       will be compared.  W is ideal to use when  sequence  informa-
  233.       tion is present at the right edge of the text file.
  234.       Default:  W120.
  235.  
  236.  
  237.  
  238.                  - 2 -
  239.  
  240.  
  241.  COMPARE - Compare Two Textfiles                  03 Jan 79
  242.  
  243.  Example
  244.  -------
  245.  
  246.  Suppose FILEA is:
  247.  
  248.      PROGRAM L2U(INPUT, OUTPUT);
  249.       (* CONVERT CDC 6/12-ASCII LOWER-CASE
  250.          LETTERS TO UPPER CASE.  *)
  251.      BEGIN
  252.       WHILE NOT EOF(INPUT) DO
  253.        BEGIN
  254.         WHILE NOT EOLN(INPUT) DO
  255.          BEGIN
  256.           IF INPUT^ <> CHR(76) THEN WRITE(INPUT^);
  257.           GET(INPUT)
  258.          END;
  259.         READLN;
  260.         WRITELN
  261.        END;
  262.       (*ALL DONE.*)
  263.      END.
  264.  
  265.  
  266.  
  267.  and FILEB is:
  268.  
  269.      PROGRAM U2L(INPUT, OUTPUT);
  270.       (* CONVERT CDC ASCII UPPER-CASE LETTERS
  271.          TO 6/12 LOWER CASE.  *)
  272.      BEGIN
  273.       WHILE NOT EOF(INPUT) DO
  274.        BEGIN
  275.         WHILE NOT EOLN(INPUT) DO
  276.          BEGIN
  277.           IF INPUT^ IN ['A'..'Z'] THEN WRITE(CHR(76));
  278.           WRITE(INPUT^);
  279.           GET(INPUT)
  280.          END;
  281.         READLN;
  282.         WRITELN
  283.        END;
  284.      END.
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.                  - 3 -
  293.  
  294.  
  295.  COMPARE - Compare Two Textfiles                  03 Jan 79
  296.  
  297.  then a report from COMPARE looks like this:
  298.  
  299.    COMPARE,L2U,U2L,LIST/C1,D,P.             78/12/31. 20.23.25.
  300.    COMPARE VERSION 3.0 CDC               (78/12/19)
  301.  
  302.    OUTPUT OPTION    = DIFFERENCES.
  303.    INPUT LINE WIDTH = 120 CHARACTERS.
  304.    MATCH CRITERION  = 1 LINES.
  305.  
  306.    FILEA: L2U
  307.    FILEB: U2L
  308.  
  309.      ***********************************
  310.    MISMATCH: L2U LINES 1 THRU 3 <NOT EQUAL TO> U2L LINES 1 THRU 3:
  311.  
  312.  A    1. PROGRAM L2U(INPUT, OUTPUT);
  313.  B    1. PROGRAM U2L(INPUT, OUTPUT);
  314.          ^ ^
  315.  
  316.  A    2.  (* CONVERT CDC 6/12-ASCII LOWER-CASE
  317.  B    2.  (* CONVERT CDC ASCII UPPER-CASE LETTERS
  318.              ^^^^^^^^^^^^^^^^^^^^^^^^
  319.  
  320.  A    3.     LETTERS TO UPPER CASE.  *)
  321.  B    3.     TO 6/12 LOWER CASE.  *)
  322.          ^^^^^^^ ^ ^^^^^^^^^^^^ ^^
  323.  
  324.      ***********************************
  325.    MISMATCH: L2U LINE 9 <NOT EQUAL TO> U2L LINES 9 THRU 10:
  326.  
  327.  A    9.      IF INPUT^ <> CHR(76) THEN WRITE(INPUT^);
  328.  
  329.  B    9.      IF INPUT^ IN ['A'..'Z'] THEN WRITE(CHR(76));
  330.  B   10.      WRITE(INPUT^);
  331.  
  332.      ***********************************
  333.    EXTRA TEXT ON L2U, BETWEEN LINES 15 AND 16 OF U2L
  334.  
  335.  A   15.  (*ALL DONE.*)
  336.  
  337.  How COMPARE Works
  338.  -----------------
  339.  
  340.       COMPARE employs a simple backtracking-search algorithm to isolate
  341.  mismatches  from  their  surrounding  matches.  Each mismatch requires
  342.  dynamic storage roughly  proportional    to  the  size  of  the    largest
  343.  mismatch,  and  time roughly proportional to the square of the size of
  344.  the mismatch.    Thus it may not be feasible to    use  COMPARE  on  files
  345.  with very long mismatches.
  346.  
  347.  
  348.  
  349.  
  350.                  - 4 -
  351.  
  352.  
  353.  COMPARE - Compare Two Textfiles                  03 Jan 79
  354.  
  355.  History
  356.  -------
  357.  
  358.       COMPARE was developed as a portable-Pascal software tool by James
  359.  Miner    of  the  Social  Science  Research  Facilities    Center    at  the
  360.  University  of  Minnesota,  in early 1977.  It was written in standard
  361.  Pascal and developed initially under CDC 6000    Pascal.   Although  the
  362.  original  version  simply  reported differences in a textfile, COMPARE
  363.  was designed to fit  naturally  into  a  larger  text-editing    system.
  364.  Plans    for  COMPARE's  accommodating  later  enhancements  to generate
  365.  text-editor directives were made from the  beginning.     In  summer  of
  366.  1977,    John  Strait  at  the  University  of Minnesota Computer Center
  367.  adapted COMPARE not only to generate such a  modifications  file,  but
  368.  also flag-form output and user-selectable options.
  369.  
  370.       COMPARE has been distributed to several Pascal enthusiasts in the
  371.  United States who have made it operational on other Pascal implementa-
  372.  tions.   See  Pascal  News #12, May, 1978, pages 20-23.  In late 1978,
  373.  Willett Kempton of the Anthropology Department at  the  University  of
  374.  California  Berkeley,    installed  COMPARE  (with  no  changes required
  375.  whatsoever) under Berkeley UNIX Pascal on a PDP 11/70 computer system.
  376.  He  later adapted the program to note column-wise differences in pairs
  377.  of different lines and made minor changes to the format of the report.
  378.  
  379.       Rick  Marcus  and  Andy  Mickel  at  the    University of Minnesota
  380.  Computer Center made minor enhancements to COMPARE and fully  documen-
  381.  ted it it for Release 3 of Pascal 6000 in December, 1978.
  382.  
  383.       COMPARE  is  a  model  program  in  many    respects.  It serves to
  384.  illustrate just how powerful and flexible such  a  comparison    program
  385.  can be.
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.                  - 5 -
  401. THE DATE LIBRARY
  402.  
  403. This package of routines :
  404. -- Allows a date to be entered in the relatively comfortable form of
  405.    number/separator/number/separator/number -- eg: 10-22-80 or 1/1/77.
  406.    The full year can also be entered [eg: 12-11-1980], although the
  407.    leading numbers are stripped, which means that 12-11-1680 equals
  408.    12-11-1980.
  409. -- Can insist that the entered year be within a specified range,
  410.    refusing to continue processing until the restrictions are
  411.    complied with.
  412. -- Converts the entered date into a two-byte integer value [in the range
  413.    1..maxint] which reflects the total number of days between the entered
  414.    date and Jan 1 of the program's base year. This means that calculations
  415.    made using this value do not have to take into consideration the
  416.    number of days in any given month -- or year for that matter.
  417. -- Breaks the date back into separate values for the month, date, year
  418.    and day of week [Sun..Sat].
  419. -- Prepares the broken date into strings with the various names spelled
  420.    out [eg: Thursday, January 1, 1981] or as a fixed eight place value
  421.    [11-11-80]. In the former the day-of-week name can be omitted and/or
  422.    names abbreviated and in the latter spaces can be substituted for
  423.    leading zeroes for the month and date [ie: 01-01-81 or  1- 1-80].
  424.  
  425. I have set the beast up in two forms: [1] separate .LIB modules for
  426. each routine, allowing them to be included in any Pascal program with
  427. the editor and [2] a complete external subprogram for separate compilation
  428. with ver 3.2 or later.
  429.  
  430. The separate routines are:
  431.  
  432. PROMPT                PROMPT.LIB
  433. This is actually a general-purpose routine, but it is specifically called
  434. by GETDATE. PROMPT is passed a string, pads it to a specified length,
  435. and writes it to the console. It allows pretty data entry.
  436.  
  437. MAKEDATE with GETDATE        MAKEDATE.LIB
  438. RMAKEDATE with RGETDATE        RMAKEDA.LIB
  439. Prompts the console to enter a date and returns the calculated integer
  440. value. RMAKEDATE is passed the minimum and maximum year values and
  441. checks to ensure that the entered value falls within the range.
  442.     GETDATE and RGETDATE perform the actual data entry. When compiled
  443. separately they are not accessible to the main program but if included
  444. within the program text these names obviously cannot be used for other
  445. routines.
  446.  
  447. BRKDATE                BRKDATE.LIB
  448. Breaks the integer date value into the month, day, year and weekday.
  449. Note that the latter is in the range 0..6 rather than 1..7. Breakdate
  450. fully corrects for leap years.
  451.  
  452. DASTRLONG            DASTRLON.LIB
  453. DASTRSHORT            DASTRSH.LIB
  454. DASTRFIXED            DASTRFIX.LIB
  455. The names are admittedly crunched a bit, but that's to fit within the
  456. six-character name limit for separate compilation.
  457.     Each function is passed a date value and returns a string in
  458. the appropriate format. They all use BRKDATE. DASTRLONG spells out all
  459. words while DASTRSHORT abbreviates the month and day name [but not with
  460. periods -- I think they're ugly]. In addition a boolean value WITHDAY
  461. is passed to indicate whether the day name is to be included [true] or
  462. omitted [false].
  463.     DASTRFIXED returns the date in an eight-place fixed length
  464. format. The separator character is specified as a constant and can
  465. be changed if desired. The function includes a boolean parameter WITHSPACE
  466. which determines whether leading zeroes are converted into spaces or
  467. left as numeric characters.
  468.  
  469. STRBYTE
  470. This routine is contained within DASTRFIX.LIB. It is passed a byte value
  471. and WITHSPACE and returns a two-place string equivalent. It is broken out
  472. in case it proves useful elsewhere in the program.
  473.  
  474. ----------
  475.  
  476. DATE.PAS has all of the date library routines plus PROMPT set up as an
  477. external module for separate compilation. Note, however, that it is
  478. necessary to change "progname" in the first line of the program to
  479. the name of the main program before it will properly compile. It also
  480. appears that the program names cannot exceed six characters [rather than
  481. just having only the first six be significant].
  482.  
  483. DATE.LIB can then be inserted in the main program to provide the relevant
  484. external declarations. DATE.LIB includes declarations for LENGTH and
  485. SETLENGTH.
  486.  
  487. Generally, the date routines require the following global type declarations:
  488.     TYPE    string255 = string 255;
  489.         byte = 0..255;
  490. There are two important constants used in MAKEDATE, RMAKEDATE and BRKDATE.
  491. YRBASE is the base year, which equals 10 in the package as written.
  492. YRSPAN is the total number of years which constitute the acceptable
  493. maximum range of entries. This number is dicated by maxint and thus cannot
  494. exceed 89.
  495.  
  496. This means that as written the routines can handle dates in the range
  497. 1910..1999. Since 1900 was not a leap year and there is no provision
  498. for dealing with that occurrence, 1901 [yrbase = 1] is the lowest possible
  499. base year. Since 2000 will be a leap year [wouldn't life be easier if
  500. the sun rose and set only 360 times a year and pi equalled three?] the
  501. routines could be extended beyond 1999, but the yr mod 100 statement
  502. within GETDATE and RGETDATE -- which permits dates to be entered
  503. 1-11-1980, if you're so moved -- would have to be modified to permit
  504. 00 to be higher than 99. I just didn't see any reason to clutter the
  505. program up with this business for a few more years.
  506.  
  507. As long as two integer date values share a common base year they are
  508. directly comparable. This is an argument for sticking with just one
  509. base year for all purposes. Thus the difference between any two date
  510. values is the number of days between them. More importantly, your
  511. programs should have a much easier time of scanning through data to
  512. determine whether the records fall within a designate range -- and
  513. are thus eligible for further processing -- when that range is specified
  514. as a number of days -- 10, 30, 90, etc.
  515.  
  516. It should also be noted that the string returned by DASTRFIXED with
  517. spaces passed as false can be used to create a CP/M file name if you have
  518. a series of data files which you want to keep broken down by date.
  519. Thus one set of files could be 01-11-80.ORD, 01-12-80.ORD, etc. if you
  520. wanted to keep, say, orders as a set of separate files.
  521.  
  522. Please note that DATEFUNC.LIB includes declarations for LENGTH and
  523. SETLENGTH, since they are used within DATE.PAS, so these should not
  524. be declared elsewhere in the main module.
  525.  
  526. The following global types are generally required:
  527.     TYPE    string255 = string 255;
  528.         byte = 0..255;
  529.  
  530. The datestring routines are all functions returning strings, which means
  531. that Pascal/Z ver 3.2 or later is required for proper compilation.
  532.  
  533. ----------
  534.  
  535. Scott Custin
  536. 2410 20th St NW #10
  537. Washington DC 20009
  538.  
  539.  
  540. Z-80/8080 TDL BASED DISASSEMBLER
  541.  
  542. The program will disassemble any Z-80 or 8080 object program
  543. and reconstruct a TDL assembly format compatible source file
  544. on the console or disk. The object file resides in memory at
  545. any location up to the starting address of the disassembler.
  546. Binary files may  be loaded  at any time and  utilities are
  547. provided to manipulate and examine loaded files. Disassembly
  548. may be effected  in multi-segment passes,  with each segment
  549. starting at any location  and ending at  any location within
  550. the range  0000-ORIGIN.  The latter  may or  may not  be the
  551. execution locations   of   the  object   program.  For  each
  552. segment/pass, run-time options may be specified as follows:
  553.  
  554.     [a] Use the  symbol table  for the label
  555.     field and address field (see option g)
  556.  
  557.     [b] Do not  initialize the  symbol table
  558.     nor the disk  source file  (see option i
  559.     for  exception).  Use   this  option  to
  560.     append entries to  the symbol  table and
  561.     new lines to the disk file.
  562.  
  563.     [c] Build symbol  table using  the Lxxxx
  564.     format    for     extended     reference
  565.     instructions. (see options  a and  g for
  566.     execptions)
  567.  
  568.     [d] Generate labels Lxxxx instead of the
  569.     default HEX values xxxxH.
  570.  
  571.     [e] Generate ASCII  characters in quotes
  572.     depending on option  f.  If option f  is
  573.     true,  all  printable  ASCII  characters
  574.     will be placed  in quotes  following the
  575.     .Byte pseudo  opcode.  If  option  f  is
  576.     false, all two operand instructions with
  577.     data will  be followed  as a  comment by
  578.     the quoted ASCII character corresponding
  579.     to the data.
  580.  
  581.     [f] Generate .BYTE pseudo opcode instead
  582.     of  default  assembly   code.  Use  this
  583.     option   for   proper   disassembly   of
  584.     segments consisting of  tables and ASCII
  585.     strings.
  586.  
  587.     [g] Normally the operands  of LXI instr.
  588.     are treated as  2 byte  data rather than
  589.     as an address.  Use this  option to over
  590.     ride this  default.  If  this  option is
  591.     selected, the  2  byte  operand  of  LXI
  592.     instructions will be  used to  build the
  593.     symbol table and  if already  there, the
  594.     symbol entries will be  used in place of
  595.     the default HEX format.
  596.  
  597.     [h] Write/Build  a  reconstructed SOURCE
  598.     FILE in disk and  in a compatible format
  599.     ready for re-assembly  by the  TDL MACRO
  600.     RELOCATING ASSEMBLER. If the source file
  601.     is new, you  will  be  prompted  for the
  602.     filename.
  603.  
  604.     [i] Restart the disk  file regardless of
  605.     option b. Use  this option  to over ride
  606.     the APPEND mode  without  affect  on the
  607.     specified action on the symbol table.
  608.  
  609.     [j] Close the source  file at the normal
  610.     termination of this segment/pass.
  611.  
  612.     [k] Suppress  console  output.  Use this
  613.     option  during  symbol   table  building
  614.     pasess to expedite disassembly.
  615.  
  616. ALL OPTION ARE SELECTED  WITH THE 'O'   COMMAND. ALL OPTIONS
  617. ARE INITIALIZED OFF. EACH TIME THE 'O'  COMMAND IS USED, ALL
  618. DESIRED OPTIONS MUST  BE SELECTED  SINCE THE  COMMAND RESETS
  619. EACH OPTION.
  620.  
  621. The  following   describes   the   command   mode   of   the
  622. disassembler.  All line   editing   features   of   CPM  are
  623. available in the command  mode except Control-C.  DO NOT USE
  624. CONTROL-C TO RETURN TO CPM.
  625.  
  626. RUBOUT        delete and echo the last character typed
  627.  
  628. ctl-U        delete entire line
  629.  
  630. ctl-X        (same as ctl-U)
  631.  
  632. ctl-R        retype current line
  633.  
  634. ctl-E        physical end of line
  635.  
  636. ctl-S        stop the console output temporalily
  637.  
  638. D aaaa,bbbb    Disassemble memory from start address aaaa to
  639.         end address bbbb
  640.  
  641. R drive:file    Read a binary file into memory. All files must
  642.         have a 'COM' extension. Files are loaded at
  643.         start address 100H and the length of the file
  644.         will be displayed at the console.
  645.  
  646. O a,b,c,...    Set runtime options. All options are reset
  647.         with this command and selectively set.
  648.  
  649. Q        Quit session and return to CPM. The number of
  650.         current symbol table entries is displayed.
  651.  
  652. M aaaa,bbbb,cccc    Move memory starting at aaaa and 
  653.             ending at bbbb address cccc.
  654.  
  655. H aaaa,bbbb    Hex math. The sum and difference will be
  656.         displayed.
  657.  
  658. S aaaa,bbbb    Show memory in HEX.
  659.  
  660. T aaaa,bbbb    Type memory in ASCII.
  661.  
  662. C        Close source file. Use this command when write
  663.         errors occur or end of medium.
  664.  
  665.     ---ALL PARAMETERS ARE IN HEX ---
  666.  
  667. AUTHOR: Timothy Mark Burke
  668. DATE:   October, 1979
  669.  
  670. DISASMB -- A TABLE DRIVEN DISASSEMBLER WRITTEN IN MICROSOFT BASIC
  671.  
  672. This package consists of two main programs and a set of support programs
  673. and files.
  674.  
  675. Among its features:
  676.  
  677. -- By loading assembler mnenomics tables at run-time, the program can
  678.    disassemble into any assembly language for which tables are available.
  679.  
  680. -- Output can be sent to the console, printer and/or a disk file.
  681.  
  682. -- A cross-reference file can be created as part of disassembly,
  683.    sorted, and listed on the printer and/or console.
  684.  
  685. -- Source code can be either a disk file or located in memory.
  686.  
  687. -- All 16-bit values are converted to labels, which permit relocation.
  688.  
  689. -- Every byte of code is disassembled. The program treats secondary code
  690.    as a comment.
  691.  
  692. -- In addition to its mnenomic value, the hex value and ASCII equivalent
  693.    of each byte is listed. This facilitates location of data and text
  694.    blocks.
  695.  
  696. -- The program runs reasonably fast under the Basic interpreter and can
  697.    presumably be compiled with the Microsoft Basic compiler, although
  698.    this does require a few modifications of the program.
  699.  
  700. ----------
  701.  
  702. RUNNING DISASMB.BAS
  703.  
  704. To begin with, you have to have Microsoft Basic-80 ver 5.1 or later,
  705. since this program makes use of the long variable names facilitated
  706. as part of ver 5.
  707.  
  708. The disassembler first requests the name of the assembly language to
  709. be used. A .LST file, which contains the opcode and operand mnenomics,
  710. and a .TAB file, which contains a table to define the names of each
  711. byte, must be available under that name. Thus, if INTEL is specified,
  712. the files INTEL.LST and INTEL.TAB must be found. Otherwise, an error
  713. message will be printed and a new name will be requested.
  714.  
  715. Once the tables have been loaded, a menu is displayed and the user is
  716. allowed to specify actions to be taken. The options available are:
  717.  
  718. -- END
  719.    Self explanatory.
  720.  
  721. -- CONSOLE toggle
  722.    PRINTER toggle
  723.    Switching these will determine where generated listings will be
  724.    displayed. If the printer is enabled, hitting "P" disables it,
  725.    hitting "P" again re-enables it.
  726.  
  727. -- TABLE LOAD
  728.    If you want to switch assembly languges you can do so. If the
  729.    .LST file is not found an error message is issued and the old files
  730.    remain loaded.
  731.  
  732. -- LIST OPCODES
  733.    This generates a table showing the mnenomic equivalent for each
  734.    opcode under the currently loaded assembly language tables. Note
  735.    that since Zilog index codes are disassembled by testing for
  736.    reference to the HL register, these codes are not listed in this
  737.    table.
  738.  
  739. -- WRITE LISTING TO DISK
  740.    The dissembled code is written to disk. The standard source file
  741.    extension is provided as part of the .LST file, and this is used
  742.    as a default value. If a cross-reference file has been specifed,
  743.    this file name is used as a default as well. A new name and/or
  744.    extension can, of course, be provided.
  745.  
  746. -- X-REF FILE GENERATION
  747.    A cross-reference file is generated, listing each 16-bit value loaded,
  748.    the current address and whether it is appears to be a primary or
  749.    secondary [ie: not necessarily valid] value.
  750.  
  751. -- MEMORY DISASSEMBLE
  752.    The first value requested is the starting address in memory for the
  753.    program to be disassembled. A second program starting address is then
  754.    required. The memory starting address is assumed, but if a different
  755.    value is entered the diassembler assumes the program has been
  756.    relocated in memory and acts accordingly. The final value to be
  757.    entered is the program end address, relative to the program starting
  758.    address, NOT the memory start.
  759.  
  760. -- DISK DISASSEMBLE
  761.    This disassembles from a disk file. If a write or x-ref file has been
  762.    specified that file name is assumed, as is the extension .COM. The
  763.    program start is assumed to be at 100H, but a different value can
  764.    be entered.
  765.  
  766. Miscellaneous notes:
  767.  
  768. To begin with, the disassembler has no real way of knowing what is
  769. machine instruction and what is data. Similarly, it can not know
  770. if a 16-bit value loaded into a register is an absolute value or a
  771. memory reference. Thus, for a file to be re-assembled it will first
  772. have to be edited. Some of this is easy -- blocks of text will stick
  773. out in the ASCII column -- but determining whether a 16-bit value
  774. should be be converted from a label to an absolute value, by removing the
  775. the prefix "x", can prove a bit tricky, although the x-ref listings
  776. should help.
  777.  
  778. It is also important to keep in mind that every byte of source code
  779. generates 30-40 bytes of disassembled disk file. Which means that
  780. even rather small source files can generate rather large output files.
  781.  
  782. Commands issued from the menu are entered via the INPUT$(1) command,
  783. which means that simply hitting a key serves to enter the command.
  784. By the time you hit a return it's too late.
  785.  
  786. When an assumed value is given, hitting a return means that it will
  787. be used.
  788.  
  789. The menu is updated to show the status of each function, including the
  790. names of any designated output disk files.
  791.  
  792. Output disk files are disabled at the end of any disassembly cycle
  793. but console and printer status are not changed.
  794.  
  795. The program includes a convert-to-caps routine, so that data can be entered
  796. as lower case if desired.
  797.  
  798. ----------
  799.  
  800. USING XREF.BAS
  801.  
  802. Since this program is not table-dependent, the menu is displayed
  803. immediately. The options available are:
  804.  
  805. -- CONSOLE TOGGLE
  806.    PRINTER TOGGLE
  807.    These work the same as with DISASMB.BAS.
  808.  
  809. -- SORT FILE
  810.    This sorts an .XRF file generated by DISASMB and then prints it.
  811.  
  812. -- LIST FILE
  813.    This takes a sorted file and simply lists it.
  814.  
  815. The sort program is a heap sort but under the interpreter this still
  816. takes time. So a submit file, XREF.SUB, is provided to permit MicroPro's
  817. SuperSort to do the deed with great dispatch.
  818.  
  819. The first column of the listing is the destination address, the second
  820. column contains primary source addresses, the third column contains
  821. secondary source addresses.
  822.  
  823. The listing is paginated and normally displays two columns to a page.
  824. Both of these values can be changed by modifying indicated constants at
  825. the start of the program.
  826.  
  827. ----------
  828.  
  829. CREATING .LST AND .TAB FILES
  830.  
  831. This package contains four sets of files:
  832.  
  833. -- INTEL -- standard Intel mnenomics for the 8080 and CP/M assembler.
  834.  
  835. -- 8085 -- adds the SIM and RIM instructions to INTEL.
  836.  
  837. -- ZILOG -- standard Zilog mnenomics with extension .MAC for Macro-80.
  838.  
  839. -- TDL -- TDL's Intel-extended-to-Zilog mnenomics with extension .SRC
  840.    for the InterSystems assembler.
  841.  
  842. I have included the TAB<name>.BAS and LST<name>.BAS programs which
  843. generated these files in order to facilitate changes.
  844.  
  845. The .LST file contains the mnenomic names and miscellaneous values
  846. for the disassemblers. The order is:
  847.     ALEN -- The number of columns in the .TAB file. Standard
  848.         Intel has 3, Zilog has 9.
  849.     ZCOM -- The comment character/string, generally ";".
  850.     ZLAB -- The label terminator string. This is optional but
  851.         permissible to most assemblers, but Macro-80 apparently
  852.         requires it.
  853.     ZBYTE -- The byte pseudo-op.
  854.     ZEXT -- The extension assumed by the assembler.
  855.     AZIL -- Since the index register codes can be easily
  856.         disassembled by testing for use of the HL registers,
  857.         this approach was used. However, this requires
  858.         language-dependent code, so this value tells the
  859.         disassembler what, if any, procedures to use.
  860.         The provided values are:
  861.             0 - no index-register codes
  862.             1 - standard Zilog mnenomics
  863.             2 - TDL mnenomics
  864.     Number of operands
  865.     null operand
  866.     1..n operands
  867.     Number of opcodes
  868.     null operand
  869.     "N" operand
  870.     "NN" operand
  871.     "(NN)" operand
  872.     relative displacement operand
  873.     5..n non-reserved operands
  874.  
  875. The reserved operands must be allowed for, whether or not the language
  876. provides for that instruction. Other than that, opcodes and operands
  877. may be listed in any order.
  878.  
  879. The .TAB file contains the .LST position of the opcode and the first
  880. and second operands for each byte. The values are stored as bytes.
  881. New .LST and .TAB files can be checked using the list opcodes procedure
  882. in DISASMB.
  883.  
  884. ----------
  885.  
  886. FINAL BITS OF INFORMATION
  887.  
  888. [1] MBasic allows strings to be of an arbitrary length. There is a price,
  889. however: When a string is created or changed it is simply tossed on top
  890. of the string stack. From time to time this process exhausts available
  891. memory and the intepreter has to stop to purge the stack of extraneous
  892. strings. Thus, during the generation of a disassembler listing the
  893. process will stall for a number of seconds to permit the purge.
  894.  
  895. [2] In order to conserve memory, the opcode, operand and table arrays
  896. are dynamically redimensioned in DISASMB. If this program is to be
  897. compiled using BASCOM, these have to be changed to absolute values.
  898. The maximum values for the various tables are:
  899.     
  900.     name        opcodes        operands    table
  901.     INTEL         80        22        2,255
  902.     8085         80        22        2,255
  903.     ZILOG         67        48        8,255
  904.     TDL        136        22        8,255
  905.  
  906. [3] There are two ways which MBasic can tell whether it has reached
  907. the end of an input file: (a) It is told by CP/M that it is on the
  908. last sector of the current extent and that there are no further
  909. last sector of the current extent and taht there are no further extents
  910. or (b) it encounters a control-z code at the start of a logical block
  911. (a line in a sequential file or a sector in a random file).
  912.  
  913. There are some problems with this approach. Since DISASMB reads source
  914. files as a series of sector-long records it has been instructed to
  915. continue reading if both EOF is true and the first byte on the sector
  916. is a 1AH (control-z). This may cause the program to read past the end
  917. of a file, but ultimately it will be forced to initialize a sector
  918. which will result in a proper stop.
  919.  
  920. For .XRF files the end of file is indicated by two 0FFH bytes followed
  921. by 1AH's. This is the FFZZ end flag for SuperSort.
  922.  
  923. [4] Disassembled disk files use horizontal tabs to separate columns in
  924. order to compress the length of the files at least a little.
  925.  
  926. [5] MBasic clears the input buffer for normal data input but not for
  927. INPUT$. With interrupt-based input, however, this means that it is
  928. possible to accidently enter commands in response to the menu's prompt.
  929.  
  930. [6] XREF.BAS creates and then erases two files named XREFWORK.### and
  931. XREFWORK.$$$. XREF.SUB creates and then erates XREFWORK.###.
  932.  
  933. ----------
  934.  
  935. Scott Custin
  936. 2410 20th St NW #10
  937. Washington DC 20009
  938.  
  939.  
  940. SOME MISCELLANEOUS LIBRARY ROUTINES I'VE TOSSED IN
  941.  
  942. GETINT.LIB
  943. You pass a message and the minimum and maximum values and this function
  944. asks for a value to be entered. It will not proceed until the value
  945. falls within the designated limits. This avoids unpleasant surprises
  946. when someone enters bad data. I'm afraid compilers aren't quite as
  947. unforgiving of this problem as are interpreters. Often, a lot of data
  948. is lost through a little foul-up.
  949.  
  950. CAPCHAR.LIB
  951. CAPSTR.LIB
  952. The former makes lower case letters into cap ones, the latter passes
  953. through a string capitalizing where necessary. Numbers and symbols
  954. are unaffected.
  955.     I'm not sure, but I suspect that the boolean comparison used
  956. here is more efficient than the set-inclusion test used in Z-UG's
  957. STRLIB.
  958.  
  959. PADSTR.LIB
  960. DEPAD.LIB
  961. PADSTRr sticks spaces at the end of a string until is hits the length
  962. passed as part of the function call. I implemented this as a function
  963. so that the original string can be left intact if desired.
  964.     This serves two purposes:
  965.     [1] Pretty printouts, since ver 3.2 pads strings to the left, just
  966. like numbers, rather than to the right, which means that simply going
  967. str:20 isn't satisfactory.
  968.     [2] Microsoft stores strings in random access records padded with
  969. blanks rather than with a length byte [used in Pascal/Z]. Personally,
  970. InterSystem's approach has its advantages, since you get back exactly
  971. what you stored, rather than a fixed-length string. But I also have
  972. SuperSort, which does not support the length byte [although it can
  973. always be passed over in setting up the keys], which means that padding
  974. the stored records prevents unpleasant surprises during the sort.
  975.     DEPAD starts dropping spaces off the right side of a string until
  976. it hits the first non-space character. Again, this is a function rather
  977. than a procedure, in case the original string needs to be left intact.
  978.