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 / UTILITYS / PEEK22.ARC / PEEK22.MAC < prev    next >
Text File  |  1992-05-28  |  7KB  |  248 lines

  1.     title    'PEEK22.MAC: tpa module for PEEK22 RSX'
  2. ;
  3. ; Based upon PEEK.ASM,  copyright (C) 1983 : Ron Fowler, Fort Atkinson, WI
  4. ;
  5. ; This version has been modified to work with Jim Lopushinsky's SETRSX
  6. ; manager for CP/M 2.2.  It has been modified for use with M80, the
  7. ; Microsoft 8080/Z80 Macro-assembler. - Mark Howard 09/11/84
  8. ;
  9. ; This is the TPA module for the PEEK22 rsx.  It must be combined with
  10. ; PEEKBDOS V2.0 using DDT or ZSID, see the instructions below.  Syntax and
  11. ; usage information is contained in the companion module, PEEKBDOS.MAC.
  12. ; To generate PEEK22.COM, you must know the address of your BDOS.  INF,
  13. ; CCPLOC, or another similar utility can be used.  Also, PEEKBDOS.PRL
  14. ; has been provided for those users that don't have LINK.COM.
  15. ;
  16. ; To compile and link, do the following:
  17. ;
  18. ;     A>M80 =PEEK22                <= To compile this source
  19. ;    A>M80 =PEEKBDOS                <= To compile the RSX
  20. ;    A>LINK PEEKBDOS[OP]            <= Produces PEEKBDOS.PRL
  21. ;     A>L80 PEEK22,LOADRSX,PEEK22/N,/E    <= Produces PEEK22.COM
  22. ;    A>DDT PEEK22.COM            <= Now patch and overlay
  23. ;    DDT VERS 2.2                <= .COM file with RSX
  24. ;    NEXT  PC
  25. ;    0400 0100
  26. ;    -IPEEKBDOS.PRL                <= Load RSX .PRL file
  27. ;    -R300                    <= loads it to 400h
  28. ;    NEXT  PC
  29. ;    0780 0100
  30. ;    -S103                    <= Now patch your BDOS addr
  31. ;    0103 00 LL                <= LL = Lo byte
  32. ;    0104 00 HH                <= HH = Hi byte
  33. ;    0105 50 .                <= Period ends
  34. ;    -G0                    <= Warm boot
  35. ;    A>SAVE 7 PEEK22.COM            <= Save with RSX attached
  36. ;
  37. ;-----------------------------------------------------------------------------
  38. ;    
  39. ; equates
  40. ;
  41. bdos    equ    5        ;system entry point
  42. printf    equ    9        ;print console buffer funct #
  43. retvrs    equ    0ch        ;return version number
  44. rsxmgr    equ    59        ;"CALL RSX MANAGER" system call
  45. rsxf    equ    60        ;"CALL RSX" system call
  46. ;
  47. dfcb1    equ    5ch        ;default file control block 1
  48. dfcb2    equ    6ch        ;default file control block 2
  49. tpa    equ    100h        ;transient program area
  50. ;
  51. cr    equ    13        ;carriage-return code
  52. lf    equ    10        ;linefeed code
  53. ;
  54.     extrn    loadrs
  55. ;
  56.     aseg
  57. ;
  58.     org    100h
  59. ;
  60. ; This is the section of code that constitutes the major modification
  61. ; to the original PEEK.ASM module by Ron Fowler.  When using CP/M+,
  62. ; the PEEKBDOS RSX is bound to the PEEK.COM file using GENCOM, causing
  63. ; the PEEKBDOS to be automatically loaded by the CP/M+ CCP if not
  64. ; already present when PEEK is executed.  In that CP/M 2.2 does not
  65. ; support this capability, the RSX must be "manually" loaded by the
  66. ; program requiring it's services.  This is done via BDOS function 59,
  67. ; Call RSX Manager, supported by the RSX manager loaded by SETRSX.
  68. ;
  69.     jmp    start        ;jump around the data area
  70. ;
  71. bdoslc:    db    0        ;patch with BDOS (lo)
  72. bdospg:    db    0        ;patch with BDOS (hi)
  73. ;
  74. vmsg:    db    'PEEK22 v1.0 as of 11-Sept-84','$'
  75. ;
  76. ;
  77.     ds    48        ;local stack
  78. stack    equ    $
  79. ;
  80. ;    Program begins here
  81. ;
  82. start:    lxi    sp,stack    ;use our local stack
  83.     mvi    c,retvrs    ;check for correct version
  84.     call    bdos        ;
  85.     ani    0f0h        ;isolate major revision
  86.     cpi    020h        ;2.x ok
  87.     jnz    badvrs        ;
  88.     mov    a,h        ;check for MP/M
  89.     ora    a        ;
  90.     jnz    badvrs        ;
  91.     lxi    d,vmsg        ;print the version message
  92.     mvi    c,printf    ;
  93.     call    bdos        ;
  94.     lda    bdospg        ;check to see if 103H is patched
  95.     ora    a        ;
  96.     jz    notpat        ;if not, message and exit
  97.     lxi    d,mgrnam    ;check to see if RSX manager is loaded
  98.     call    chkrsx        ;
  99.     jz    nomgr        ;if not, message and exit
  100.     lxi    d,myname    ;check to see if our RSX is loaded
  101.     call    chkrsx        ;
  102.     jnz    proces        ;yes, go process a possible command line
  103.     lxi    h,0400h        ;point to the RSX
  104.     xra    a        ;relocation offset
  105.     call    loadrs        ;load it
  106.     jz    proces        ;RSX loaded OK, go process the command line
  107.     dcr    a        ;else check the error code
  108.     jz    notpb        ;either not a page boundary
  109.     jmp    nomem        ;or not enough memory
  110. ;
  111. ; parse any arguments from
  112. ; the command line, and pass them on to the rsx using function 60.
  113. ;
  114. proces:    lxi    h,dfcb1+1    ;get pointer to command line arg
  115.     mov    a,m        ;get optional "-" (for unix people)
  116.     cpi    '-'
  117.     jnz    nodash        ;jump if not there
  118.     inx    h        ;yep, advance past it
  119. nodash:    call    parse        ;parse first argument
  120.     call    parse        ;parse possible second argument
  121.     mov    a,m        ;shouldn't be a third
  122.     cpi    ' '        ;(ie, 3rd position should be blank)
  123.     jnz    synerr        ;if bad, jump
  124. sendit:    lxi    d,rsxpb        ;send to rsp
  125.     mvi    c,rsxf
  126.     call    bdos
  127.     jmp    0        ;all done, warm-boot
  128. ;
  129. ; parse an argument
  130. ;
  131. parse:    mov    a,m        ;fetch argument
  132.     inx    h        ;advance pointer
  133.     cpi    ' '        ;allow nulls
  134.     rz
  135.     cpi    'P'        ;pause-flag?
  136.     jnz    npars        ;jump if not
  137.     mvi    a,1        ;pause-flag
  138.     sta    args+1        ;where it goes
  139.     ret
  140. npars:    call    valid        ;validate
  141.     sta    args
  142.     ret
  143. ;
  144. valid:    cpi    'Q'        ;quit...
  145.     rz
  146.     cpi    'A'        ;out to aux
  147.     rz
  148.     cpi    'C'        ;out to con
  149.     rz
  150.     cpi    'L'        ;out to list
  151.     jnz    synerr        ;what then?
  152.     ret
  153. ;
  154. ; syntax error
  155. ;
  156. synerr:    lxi    d,synems    ;oops, bomb out
  157.     mvi    c,printf    ;print string function #
  158.     call    bdos
  159.     mvi    a,'Q'        ;insure removal of rsx
  160.     sta    args
  161.     jmp    sendit        ;go send, exit
  162. ;
  163. synems:    db    cr,lf,'Command Line Syntax Error',cr,lf,'$'
  164. ;
  165. ; check for an RSX in memory - nz = found
  166. ;
  167. chkrsx:    lhld    6        ;get current "BDOS" pointer
  168. ckbdos:    lda    bdospg        ;check vs. known BDOS location
  169.     cmp    h        ;
  170.     rz            ;return with z set if BDOS reached
  171.     mvi    l,0eh        ;else point to removal flag
  172.     mov    a,m        ;
  173.     ora    a        ;is this RSX active?
  174.     jnz    gonext        ;no - loop to the next
  175.     push    h        ;else save the RSX page pointer
  176.     mvi    l,10h        ;point to the name
  177.     mvi    b,8        ;characters to check
  178.     call    match        ;check for a match
  179.     pop    h        ;restore pointer
  180.     jnz    gonext        ;no match - loop to next
  181.     xra    a        ;else set NZ for found
  182.     dcr    a        ;
  183.     ret            ;
  184. gonext:    mvi    l,0bh        ;point to NEXT pointer (hi)
  185.     mov    h,m        ;HL has new page
  186.     jmp    ckbdos        ;go see if we reached BDOS
  187. ;
  188. match:    push    d        ;save the used registers
  189.     push    h        ;
  190.     inr    b        ;
  191. mtchlp:    dcr    b        ;decrement count
  192.     jz    mtchdn        ;we're done if 0
  193.     ldax    d        ;get a template byte
  194.     ani    07fh        ;(ascii)
  195.     mov    c,a        ;save in C
  196.     mov    a,m        ;get a compare byte
  197.     ani    07fh        ;(ascii)
  198.     cmp    c        ;compare
  199.     inx    h        ;bump pointers
  200.     inx    d        ;
  201.     jz    mtchlp        ;if match, check next
  202. mtchdn:    pop    h        ;quit on first mismatch
  203.     pop    d        ;
  204.     ret            ;
  205. ;
  206. ; error exits
  207. ;
  208. badvrs:    call    erxit        ;
  209.     db    7,'PEEK22 requires CP/M 2.x$'
  210. ;
  211. notpat:    call    erxit        ;
  212.     db    7,'BDOS address at 0103H is not patched.$'
  213. ;
  214. nomgr:    call    erxit        ;
  215.     db    7,'RSX manager not loaded.',cr,lf
  216.     db    'Use SETRSX to load.$'
  217. ;
  218. notpb:    call    erxit        ;
  219.     db    7,'RSX not on a page boundary.$'
  220. ;
  221. nomem:    call    erxit        ;
  222.     db    7,'Insufficient memory.$'
  223. ;
  224. erxit:    pop    d        ;get the message address
  225.     mvi    c,printf    ;
  226.     call    bdos        ;
  227.     rst    0        ;warm boot
  228. ;
  229. ; rsx parameter block
  230. ;
  231. rsxpb:    db    127        ;function # (we ignore)
  232.     db    2        ;2 parameters
  233.     dw    myname        ;parm1 = rsx name
  234.     dw    args        ;parm2 = command line arguments
  235. ;
  236. ; name of rsx
  237. ;
  238. myname: db    'PEEKBDOS'    ;name of RSX we're calling
  239. args:    db    'A',0ffh    ;output-device, pause-flag
  240. ;
  241. ; name of RSX manager
  242. ;
  243. mgrnam:    db    'RSX     '    ;
  244. ;
  245. prgend    equ    $
  246. ;
  247.     end
  248.