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 / CPM / CPM68K / SD68K.LBR / MAKEFCB.S < prev    next >
Text File  |  2000-06-30  |  3KB  |  113 lines

  1. ****    makefcb -- make file control block
  2. **
  3. **    Function:
  4. **        Convert text string into FCB.
  5. **    Inputs:  D0.l == pointer to text string
  6. **         D1.l == pointer to FCB
  7. **    Outputs: D0.l == points to delimiter after file name
  8. **    Registers affected: D0.l, D1.l (if error), (FCB buffer)
  9. **    Routines called: CAPS
  10. **    Special error conditions: D1.l=0 implies error, then D0.l
  11. **        points to bad character.
  12. *
  13. **            last mod: 14feb85 jmk /fix eol check/
  14. *
  15. *
  16.     .globl    makefcb
  17.     .globl    caps
  18.     .text
  19. makefcb:
  20.     movem.l    a0-a2,-(a7)
  21.     move.l    d1,a2
  22.     move.l    d1,a1
  23.     move.l    d0,a0
  24.     moveq    #7,d0
  25. mkf1:    clr    (a1)+        * clear FCB
  26.     dbra    d0,mkf1
  27.     move.l    d1,a1
  28.     move.l    #'    ',(a1)
  29.     move.l    #'    ',4(a1)
  30.     move.l    #'    ',8(a1)
  31.     clr.b    (a1)
  32. *
  33.     cmpi.b    #':',1(a0)
  34.     bne    mkf3        * if not disk drive #
  35.     move.b    (a0),d1        * get drive letter
  36.     jsr    caps
  37.     subi.b    #$40,d1        * convert to drive # (1-16)
  38.     move.b    d1,(a1)
  39.     addq.l    #2,a0
  40.     cmpi.b    #' ',(a0)
  41.     bgt    mkf3        * more to file name
  42.     addq    #1,a0        * ptr to after delimiter
  43.     addq    #1,a1        * ptr to name in FCB
  44.     move    #10,d1        * special case of 'd:' with
  45. mkf2:    move.b    #'?',(a1)+    * no file name, must fill FCB
  46.     dbra    d1,mkf2        * with '?' wild cards
  47.     bra    mkx
  48. *
  49. mkf3:    addq.l    #1,a1        * start of file name
  50.     moveq    #7,d0
  51. mkf4:    move.b    (a0)+,d1    * get char. of name
  52.     jsr    caps
  53.     cmpi.b    #'0',d1
  54.     blt    mkf5        * if delimiter
  55. mkf4x:    move.b    d1,(a1)+
  56.     dbra    d0,mkf4        * pick up to 8 chars.
  57.     move.b    (a0)+,d1
  58.     bra    mkf6        * better be . or delimiter
  59. *
  60. mkf5:    cmpi.b    #'*',d1
  61.     beq    mkf7        * wild card
  62.     cmpi.b    #'?',d1
  63.     beq    mkf4x        * treat ? as part of name
  64. mkf6:    cmpi.b    #'.',d1
  65.     beq    mkf8        * end of fname
  66.     cmpi.b    #' ',d1
  67.     bgt    mkerr        * to many chars in fname
  68.     bra    mkx        * finished
  69. *
  70. mkf7:                * found '*' wild card
  71.     move.b    #'?',(a1)+    * file name with ? chars
  72.     dbra    d0,mkf7
  73.     move.b    (a0)+,d1
  74.     bra    mkf6        * better be . or delimiter
  75. *
  76. mkf8:    move.l    a2,a1        * now for file type
  77.     add    #9,a1        * point to extension in fcb
  78.     moveq    #2,d0
  79. mkf9:    move.b    (a0)+,d1    * get char
  80.     jsr    caps
  81.     cmpi.b    #'0',d1
  82.     blt    mkf10        * if delimiter of some type
  83. mkf9x:    move.b    d1,(a1)+
  84.     dbra    d0,mkf9        * loop for up to 3 chars
  85. mkf9y:    move.b    (a0)+,d1
  86.     cmpi.b    #' ',d1
  87.     bgt    mkerr        * extension too long
  88.     bra    mkx
  89. *
  90. mkf10:    cmpi.b    #'?',d1
  91.     beq    mkf9x        * treat ? as part of type
  92.     cmpi.b    #'*',d1
  93.     bne    mkf12        * if not wild card
  94. mkf11:    move.b    #'?',(a1)+    * fill with '?'
  95.     dbra    d0,mkf11
  96.     bra    mkf9y        * better end here
  97. *
  98. mkf12:    cmpi.b    #0,d1
  99.     beq    mkx        * if end of cmd line
  100.     cmpi.b    #' ',d1
  101.     beq    mkx        * the end
  102. *
  103. mkerr:    clr.l    d1        * indicate error
  104.     bra    mkx1
  105. *
  106. mkx:    move.l    a2,d1        * normal exit
  107. mkx1:    subq    #1,a0
  108.     move.l    a0,d0
  109.     movem.l    (a7)+,a0-a2
  110.     rts
  111. *
  112.     .end
  113.