home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / BEEHIVE / ZCAT / FNDERR14.LBR / FINDERR.MQC / FINDERR.MAC
Text File  |  2000-06-30  |  8KB  |  311 lines

  1.  
  2. ;
  3. ;  PROGRAM:  FINDERR
  4. ;  AUTHOR:  TED H. EMIGH
  5. ;  VERSION:  1.4 - D. Wright, added support for ZAS Version 2.0
  6. ;  DATE:  22 JUL 85
  7. ;  VERSION:  1.3 - J. Offenbecher, added support for CB80
  8. ;  DATE:  26 APR 85
  9. ;  PREVIOUS VERSION:  1.2  -  Joe Griffith, added support for BASCOM
  10. ;  DATE:  27 JAN 85
  11. ;  PREVIOUS VERSIONS: 1.1 (17 Sep 84)
  12. ;                     1.0 (11 Sep 84)
  13. ;                     0.1 (7 SEPT 84)
  14. ;
  15. VERSION    EQU    14
  16. EXTENV    EQU    1    ; 1 for External Environ, 0 for Internal Environ
  17.  
  18. ;
  19. ;    FINDERR is a program to set the ZCPR3 message registers if various
  20. ;    memory locations are nonzero
  21. ;
  22. ;  ZCPR3 Header
  23. ;
  24.     MACLIB    Z3BASE.LIB
  25.  
  26. ;
  27. ;  These are part of the built-in Help message.  They indicate what
  28. ;  registers are affected by this version of FINDERR
  29. ;
  30. regmsg    macro
  31.     db    0dh,0ah,' 0 - M80 Ver 3.44'
  32.     db    0dh,0ah,' 1 - F80'
  33.     db    0dh,0ah,' 2 - BASCOM Ver 5.30'
  34.     db    0dh,0ah,' 3 - CB-80 Vers 2.0'
  35.     db    0dh,0ah,' 4 - ZAS Vers 2.0'
  36.     endm
  37.  
  38. ;
  39. ;  These Locations Assume the use of M80/F80, Version 3.44
  40. ;
  41. m80f    equ    03cedh        ;location of number of fatal errors (M80)
  42. m80fb    equ    2        ;--16 bits (2 bytes)
  43. m80w    equ    03cefh        ;location of number of warning errors (M80)
  44. m80wb    equ    2        ;--16 bits (2 bytes)
  45.  
  46. f80f    equ    01c1h        ;location of number of fatal errors (F80)
  47. f80fb    equ    2        ;--16 bits (2 bytes)
  48. f80w    equ    02adh        ;location of number of warning errors (F80)
  49. f80wb    equ    2        ;--16 bits (2 bytes)
  50.  
  51. bcf    equ    017e0h        ;location of number of fatal errors (BASCOM)
  52. bcfb    equ    1        ;--08 bits (1 byte)
  53. bcw    equ    017e0h        ;location of number of warning errors (BASCOM)
  54. bcwb    equ    1        ;--08 bits (1 byte)
  55.  
  56. cbf    equ    0148ch        ;location of number of fatal errors (CB-80)
  57. cbfb    equ    1        ;--08 bits (1 byte)
  58. cbw    equ    0148ch        ;location of number of warning errors (CB-80)
  59. cbwb    equ    1        ;--08 bits (1 byte)
  60.  
  61. zasf    equ    010aah        ;location of number of fatal errors (ZAS)
  62. zasfb    equ    2        ;--16 bits (2 bytes)
  63. zasw    equ    010aah        ;location or number of warning errors (ZAS)
  64. zaswb    equ    2        ;--16 bits (2 bytes)
  65.  
  66. ;  System Equates
  67. ;  Add the location of the error indicator, and the number of byte
  68. ;  for the indicator for each indicator desired.  If the number of
  69. ;  bytes is zero, that particular memory location is ignored.
  70. ;
  71. fatal0    equ    m80f        ;location of number of fatal errors
  72. bytesf0    equ    m80fb        ;number of bytes
  73. warn0    equ    m80w        ;location of number of warning errors
  74. bytesw0    equ    m80wb        ;number of bytes
  75. fnderr0    equ    bytesf0 or bytesw0    ;register 0 used for these errors
  76.  
  77. fatal1    equ    f80f        ;location of number of fatal errors
  78. bytesf1    equ    f80fb        ;number of bytes
  79. warn1    equ    f80w        ;location of number of warning errors
  80. bytesw1    equ    f80wb        ;number of bytes
  81. fnderr1    equ    bytesf1 or bytesw1    ;register 1 used for these errors
  82.  
  83. fatal2    equ    bcf        ;location of number of fatal errors
  84. bytesf2    equ    bcfb        ;number of bytes
  85. warn2    equ    bcw        ;location of number of warning errors
  86. bytesw2    equ    bcwb        ;number of bytes
  87. fnderr2    equ    bytesf2 or bytesw2    ;register 2 used for these errors
  88.  
  89. fatal3    equ    cbf        ;location of number of fatal errors
  90. bytesf3    equ    cbfb        ;number of bytes
  91. warn3    equ    cbw        ;location of number of warning errors
  92. bytesw3    equ    cbwb        ;number of bytes
  93. fnderr3    equ    bytesf3 or bytesw3    ;register 3 used for these errors
  94.  
  95. fatal4    equ    zasf
  96. bytesf4    equ    zasfb
  97. warn4    equ    zasw
  98. bytesw4    equ    zaswb
  99. fnderr4    equ    bytesf4 or bytesw4
  100.  
  101. ;
  102. ;  The rest of the registers are not used at this time
  103. ;  (if bytes = 0, then the memory address is not checked)
  104. ;
  105. ;
  106. fatal5    equ    0        ;location of number of fatal errors
  107. bytesf5    equ    0        ;number of bytes
  108. warn5    equ    0        ;location of number of warning errors
  109. bytesw5    equ    0        ;number of bytes
  110. fnderr5    equ    bytesf5 or bytesw5    ;register 5 used for these errors
  111. ;
  112. fatal6    equ    0        ;location of number of fatal errors
  113. bytesf6    equ    0        ;number of bytes
  114. warn6    equ    0        ;location of number of warning errors
  115. bytesw6    equ    0        ;number of bytes
  116. fnderr6    equ    bytesf6 or bytesw6    ;register 6 used for these errors
  117. ;
  118. fatal7    equ    0        ;location of number of fatal errors
  119. bytesf7    equ    0        ;number of bytes
  120. warn7    equ    0        ;location of number of warning errors
  121. bytesw7    equ    0        ;number of bytes
  122. fnderr7    equ    bytesf7 or bytesw7    ;register 7 used for these errors
  123. ;
  124. fatal8    equ    0        ;location of number of fatal errors
  125. bytesf8    equ    0        ;number of bytes
  126. warn8    equ    0        ;location of number of warning errors
  127. bytesw8    equ    0        ;number of bytes
  128. fnderr8    equ    bytesf8 or bytesw8    ;register 8 used for these errors
  129. ;
  130. fatal9    equ    0        ;location of number of fatal errors
  131. bytesf9    equ    0        ;number of bytes
  132. warn9    equ    0        ;location of number of warning errors
  133. bytesw9    equ    0        ;number of bytes
  134. fnderr9    equ    bytesf9 or bytesw9    ;register 9 used for these errors
  135.  
  136. ;
  137. ; System Buffers and Entries
  138. ;
  139. fcb    equ    5ch
  140. bdos    equ    5
  141.  
  142. ;
  143. ;
  144. ; MACROS TO PROVIDE Z80 EXTENSIONS
  145. ;   MACROS INCLUDE:
  146. ;
  147. ;    jrnz    - Jump Relative if No Zero
  148. ;    djnz    - Decrement B and Jump Relative if No Zero
  149. ;
  150. ;    @gendd Macro used for Checking and Generating
  151. ;    8-Bit Jump Relative Displacements
  152. ;
  153. @gendd    macro    ?dd    ;;Used for checking range of 8-bit displacements
  154.     if2        ;;M80
  155.  
  156.     if (?dd gt 7FH) and (?dd lt 0FF80H)
  157.     db    100H,?dd    ;Displacement Range Error
  158.     else
  159.     db    ?dd
  160.     endif        ;;Range Error
  161.  
  162.     else        ;;M80
  163.     db    ?dd    ;;M80
  164.     endif        ;;M80
  165.  
  166.     endm
  167. ;
  168. ;
  169. ; Z80 MACRO EXTENSIONS
  170. ;
  171. jrnz    macro    ?n    ;;Jump Relative on No Zero
  172.     if    i8080    ;;8080/8085
  173.     jnz    ?n
  174.     else        ;;Z80
  175.     db    20H
  176.     @gendd    ?n-$-1
  177.     endif        ;;I8080
  178.     endm
  179. ;
  180. djnz    macro    ?n    ;;Decrement B and Jump Relative on No Zero
  181.     if    i8080    ;;8080/8085
  182.     dcr    B
  183.     jnz    ?n
  184.     else        ;;Z80
  185.     db    10H
  186.     @gendd    ?n-$-1
  187.     endif        ;;I8080
  188.     endm
  189. ;
  190. ;  Macros to do most of the work
  191. ;
  192. ;  SETBYT will set B register to 'value' if the any of the bytes
  193. ;    at location 'loc' to 'loc'+'bytes'-1 are nonzero
  194. ;    ('bytes' is the number of bytes to check)
  195. ;    If no error, then B=0.  errno is the error number
  196. ;
  197. setbyt    macro    loc,bytes,errno,value
  198.     local    nxtbyt
  199.     if bytes ne 0
  200. ;;
  201.     if bytes eq 1
  202.     lda    loc        ;;get byte
  203.     ora    a        ;;see if zero
  204.     endif            ;;bytes eq 1
  205.     if bytes eq 2
  206.     lxi    h,loc
  207.     mov    a,m        ;;get lower byte
  208.     inx    h        ;;point to higher byte
  209.     ora    m        ;;see if 16 bit number is zero
  210.     endif            ;;bytes eq 2
  211.     if bytes gt 2
  212.     lxi    h,loc
  213.     mov    a,m        ;;get first byte
  214.     mvi    b,bytes-1    ;;number of bytes
  215. nxtbyt:    inx    h        ;;point to next byte
  216.     ora    m        ;;see if number is zero
  217.     djnz    nxtbyt        ;;more bytes?
  218.     if i8080
  219.     ora    a        ;;set flags for a again
  220.     endif            ;;I8080
  221.     endif            ;;bytes gt 2
  222.     mvi    b,value
  223.         jrnz    err&errno
  224. ;;
  225.     endif            ;;bytes ne 0
  226.     endm
  227. ;
  228. ;  SETBYT will set register number errno to the value in
  229. ;    B if entered at err&errno, else it will reset the value
  230. ;    at register number errno.  This routine MUST follow the
  231. ;    last setbyt for that error number.
  232. ;
  233. finish    macro    errno
  234.     mvi    b,0        ;;set for zero
  235. err&errno:
  236.     lxi    h,30h+errno    ;;point to register number
  237.     dad    d
  238.     mov    m,b        ;;save the error code
  239. ;
  240.         endm
  241. ;
  242. ;  Environments
  243. ;
  244. origin:
  245. ;
  246.     if    extenv        ; if external environment ...
  247. ;
  248. ;  External Environment Definition
  249. ;
  250.     jmp    finderr
  251.     db    'Z3ENV'        ; this is an environment
  252.     db    1        ; class 1 environment (external)
  253. envloc:
  254.     dw    z3env        ; ptr to environment
  255. finderr:
  256.     lhld    envloc        ; HL pts to environment
  257.  
  258.     else            ; if internal environment ...
  259. ;
  260. ;  Internal Environment Definition
  261. ;
  262. envloc:
  263.     jmp    finderr
  264.     db    'Z3ENV'        ; this is an environment
  265.     MACLIB    SYSENV.LIB
  266.     SYSENV            ; define environment
  267. finderr:
  268.     lxi    h,envloc    ; HL pts to environment
  269.  
  270.     endif
  271.  
  272. ;
  273. ;  Beginning of FINDERR
  274. ;
  275.     lda    fcb+1        ;check for help request
  276.     cpi    '/'
  277.     jz    help
  278.     lxi    d,34        ;message address offset in environment
  279.     dad    d        ;point to location of message address
  280.     mov    a,m        ;get message address
  281.     inx    h
  282.     mov    h,m
  283.     mov    l,a        ;HL now points to the message buffer
  284.     ora    h        ;see if message buffers supported
  285.     rz            ;messages not supported, abort
  286.     xchg            ;save pointer to message buffer
  287.     irp    errno,<0,1,2,3,4,5,6,7,8,9>
  288. if fnderr&errno
  289.     setbyt    fatal&errno,bytesf&errno,errno,1
  290.     setbyt    warn&errno,bytesw&errno,errno,2
  291.     finish    errno
  292. endif
  293.     endm
  294. ;
  295.     ret
  296. ;
  297. ; Help Message
  298. ;
  299. help:
  300.     lxi    d,helpmsg
  301.     mvi    c,9        ;use BDOS print
  302.     jmp    bdos
  303. helpmsg:
  304.     db    'FINDERR '
  305.     db    (version/10)+'0','.',(version mod 10)+'0'
  306.     db    0dh,0ah,'Regs --'
  307.     regmsg
  308.     db    '$'
  309.  
  310.     end
  311.