home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / make.arc / MAKE.ASM next >
Encoding:
Assembly Source File  |  1990-11-01  |  5.1 KB  |  211 lines

  1.         title    'MAKE Utility for CP/M Plus'
  2.  
  3. ; Purpose : emulate a Microsoft-type MAKE for CP/M Plus
  4. ; Author  : Wolfgang Muees, Hagenring 22, D-3300 Braunschweig
  5. ; Version : July 13, 1989
  6.  
  7. BDOS        equ    5        ; link to BDOS
  8. REMOVE$OFFSET    equ    8        ; remove flag   - start of RSX
  9. NAME$OFFSET    equ    10        ; start of name - start of RSX
  10. VERBOSE$OFFSET    equ    21        ; verbose flag  - start of RSX
  11. NCOM1$OFFSET    equ    24        ; next command  - start of RSX
  12. NCOM2$OFFSET    equ    28        ; next com.page - start of RSX
  13. PARSE$OFFSET    equ    29        ; parse mkfile  - start of RSX
  14. OPEN$OFFSET    equ    32        ; open makefile - start of RSX
  15.  
  16. WBOOT        equ    0        ; return to CCP
  17. PRINTS        equ    9        ; print string
  18. RETVER        equ    12        ; return version number
  19. GSSCB        equ    49        ; get/set system control block
  20. SETPRC        equ    108        ; set program return code
  21. COMLINE        equ    80H        ; byte count of command line
  22.  
  23. FALSE        equ    0
  24. TRUE        equ    not FALSE    ; boolean constants
  25.  
  26.         cseg
  27. TPA:        jmp    start
  28.         db    'CP/M Plus MAKE utility by W.Muees '
  29.         db    'Version 890713'
  30.  
  31. start:        mvi    c,RETVER    ; test for CP/M Plus
  32.         call    BDOS
  33.         mvi    a,2FH        ; must be >= 30H
  34.         cmp    l
  35.         jnc    wrong$version
  36.  
  37.         lda    COMLINE        ; call without parameter ?
  38.         ora    a
  39.         jz    give$help
  40.  
  41.         lhld    BDOS+1        ; get address of RSX
  42.         lxi    d,NAME$OFFSET
  43.         dad    d        ; HL -> name field of RSX
  44.         lxi    d,test$name
  45.         mvi    b,8        ; test name field
  46. test$loop:    ldax    d
  47.         cmp    m
  48.         jnz    wrong$rsx
  49.         inx    d
  50.         inx    h
  51.         dcr    b
  52.         jnz    test$loop
  53.  
  54. test$verbose:    lxi    h,COMLINE    ; here is byte count of command tail
  55.         mov    e,m        ; DE := length of command tail
  56.         mvi    d,0
  57.         dad    d        ; HL points to last char of command tail
  58.  
  59. verbose$skip:    mov    a,m        ; trailing spaces/tabs?
  60.         cpi    ' '+1
  61.         jnc    verbose$test
  62.         dcx    h        ; test preceeding char
  63.         dcr    e        ; character count
  64.         jnz    verbose$skip
  65.         jmp    give$help    ; missing file name
  66.  
  67. verbose$test:    cpi    'V'        ; /v option ?
  68.         jnz    parse$name
  69.         dcx    h
  70.         mov    a,m
  71.         cpi    '/'
  72.         jnz    parse$name
  73.  
  74. verbose$set:    mvi    m,0        ; delete /v from command tail
  75.  
  76.         lhld    BDOS+1        ; set verbose flag in RSX
  77.         lxi    d,VERBOSE$OFFSET
  78.         dad    d
  79.         mvi    m,TRUE
  80.  
  81. parse$name:    call    parse$make    ; parse file name of make file
  82.         ora    a        ; error ?
  83.         jnz    open$error
  84.  
  85.         call    open$make    ; open make file
  86.         ora    a        ; error ?
  87.         jnz    open$error
  88.  
  89. lock$rsx:    lhld    BDOS+1        ; install MAKERSX RSX permanent
  90.         lxi    d,REMOVE$OFFSET
  91.         dad    d
  92.         mvi    m,0
  93.  
  94.         lxi    d,pb$get1    ; get address of next command waiting
  95.         mvi    c,GSSCB
  96.         call    BDOS
  97.         push    h
  98.  
  99.         lhld    BDOS+1        ; store address into rsx
  100.         lxi    d,NCOM1$OFFSET
  101.         dad    d
  102.         pop    d
  103.         mov    m,e
  104.         inx    h
  105.         mov    m,d
  106.  
  107.         lxi    d,pb$get2    ; and page of command RSX
  108.         mvi    c,GSSCB
  109.         call    BDOS
  110.  
  111.         lhld    BDOS+1        ; store page into rsx
  112.         lxi    d,NCOM2$OFFSET
  113.         dad    d
  114.         mov    m,a
  115.         
  116.         lxi    d,pb$set1    ; clear SCB variables for multiple commands
  117.         mvi    c,GSSCB
  118.         call    BDOS
  119.         lxi    d,pb$set2
  120.         mvi    c,GSSCB
  121.         call    BDOS
  122.  
  123. exit:        mvi    c,WBOOT        ; exit to CCP
  124.         jmp    BDOS
  125.  
  126. open$error:    mvi    c,PRINTS    ; print error string
  127.         lxi    d,open$msg
  128.         call    BDOS
  129.  
  130. error$exit:    mvi    c,SETPRC    ; set program return code = failed
  131.         lxi    d,0FF00H
  132.         call    BDOS
  133.         jmp    exit
  134.  
  135. wrong$rsx:    mvi    c,PRINTS    ; print error string
  136.         lxi    d,wrong$msg
  137.         call    BDOS
  138.         jmp    error$exit
  139.  
  140. wrong$version:    mvi    c,PRINTS    ; print error string
  141.         lxi    d,version$msg
  142.         call    BDOS
  143.         jmp    error$exit
  144.  
  145. give$help:    mvi    c,PRINTS    ; print help string
  146.         lxi    d,help$msg
  147.         call    BDOS
  148.         jmp    error$exit
  149.  
  150.         cseg
  151. parse$make:    lhld    BDOS+1        ; call parse routine in RSX
  152.         lxi    d,PARSE$OFFSET
  153.         dad    d
  154.         pchl
  155.         
  156.         cseg
  157. open$make:    lhld    BDOS+1        ; call open routine in RSX
  158.         lxi    d,OPEN$OFFSET
  159.         dad    d
  160.         pchl
  161.  
  162.         dseg
  163. pb$get1:    db    15h        ; address of next command waiting
  164.         db    0
  165.  
  166. pb$get2:    db    12h        ; page of command RSX
  167.         db    0
  168.  
  169. pb$set1:    db    15h        ; set this address to 0
  170.         db    0FEh
  171.         dw    0
  172.  
  173. pb$set2:    db    12h        ; dito with page
  174.         db    0FFh
  175.         db    0
  176.  
  177.         dseg
  178. wrong$msg:    db    'RSX '
  179. test$name:    db    'MAKERSX '    ; name of make RSX
  180.         db    ' not found',13,10,7,'$'
  181. open$msg:    db    'failed to open make file',13,10,7,'$'
  182. version$msg:    db    'MAKE requires CP/M 3.0 or later',13,10,'$'
  183.  
  184. help$msg:    db    'MAKE maintenance utility for CP/M Plus,'
  185.         db    ' (c) Wolfgang Muees 890713',13,10
  186.         db    'This program uses update/create date&time'
  187.         db    ' stamping to conditionaly',13,10
  188.         db    'execute CCP command lines.      USAGE : MAKE <filename>{/v}',13,10
  189.         db    'The /v (verbose) option lists the contents of <filename> while',13,10
  190.         db    'executing. All <filename>s may contain'
  191.         db    ' user numbers and passwords.',13,10
  192.         db    13,10
  193.         db    'Format of make (text)file entry:',13,10
  194.         db    '<object> : <list of source files>',13,10
  195.         db    ' <indent>  <command 1>',13,10
  196.         db    ' <indent>  <command 2>...',13,10
  197.         db    '<0 or more empty lines until next entry>',13,10
  198.         db    13,10
  199.         db    'Split <list of source files> with ''\'' on multiple lines',13,10
  200.         db    'Use comment lines (with leading '';'') freely.',13,10
  201.         db    13,10
  202.         db    'MAKE executes <list of commands> if it didn''t find <object>',13,10
  203.         db    'or if any <source file> is younger than <object>.',13,10
  204.         db    'If MAKE didn''t find a <source file>,'
  205.         db    ' search is continued through',13,10
  206.         db    'the CP/M Plus Drive Search Chain.'
  207.         db    ' So you can split your project',13,10
  208.         db    'over four drives.',13,10,'$'
  209.  
  210.         end    TPA
  211.