home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib25.zoo / purec / unixname / unixname.s next >
Text File  |  1992-04-03  |  4KB  |  114 lines

  1. ;{{{}}}
  2. ;{{{  about this file
  3. ; Author: Michael Schwingen
  4. ;         Kranichstra₧e 10
  5. ;         5042 Erftstadt
  6. ; purpose:
  7. ; Unixname installes itself resident in the GEMDOS trap vector and converts
  8. ; all '/'s in filenames to TOS-like '\'.
  9. ; Assembler: DevpacST 2.0
  10. ;}}}
  11. ;{{{  List of GEMDOS-functions and address of filename on stack
  12. ; 57 (Dcreate)  : 8(SP)
  13. ; 58 (Ddelete)  : 8(SP)
  14. ; 59 (Dsetpath) : 8(SP)
  15. ; 60 (Fcreate)  : 8(SP)
  16. ; 61 (Fopen)    : 8(SP)
  17. ; 65 (Fdelete)  : 8(SP)
  18. ; 67 (Fattrib)  : 8(SP)
  19. ; 75 (Pexec)    : 10(SP) - 8(SP) = mode, changes only if 0/3 !
  20. ; 78 (Fsfirst)  : 8(SP)
  21. ; 86 (Frename)  : 10(SP),14(SP)
  22. ;}}}
  23.  
  24.               opt o+
  25.  
  26. start:        bra     init
  27.  
  28. ;{{{  new trap#1 handler
  29.               DC.B "XBRAUn*x"
  30. oldvec:       DC.L 0
  31. new_vec:      move.w  (sp),d0         ; get SR
  32.               lea     6(sp),a0
  33.               btst    #$0D,d0         ; SUPER-mode ?
  34.               bne.s   .new2           ; yes
  35.               move    usp,a0          ; no, parameters are on userstack
  36. .new2:        move.w  (a0),d0         ; get GEMDOS Opcode
  37.               cmp.w   #57,d0          ; Dcreate() ?
  38.               beq     func_type1
  39.               cmp.w   #58,d0          ; Ddelete() ?
  40.               beq     func_type1
  41.               cmp.w   #59,d0          ; Dsetpath() ?
  42.               beq     func_type1
  43.               cmp.w   #60,d0          ; Fcreate() ?
  44.               beq     func_type1
  45.               cmp.w   #61,d0          ; Fopen() ?
  46.               beq     func_type1
  47.               cmp.w   #65,d0          ; Fdelete() ?
  48.               beq     func_type1
  49.               cmp.w   #67,d0          ; Fattrib() ?
  50.               beq     func_type1
  51.               cmp.w   #75,d0          ; Pexec() ?
  52.               beq     func_pexec
  53.               cmp.w   #78,d0          ; Fsfirst() ?
  54.               beq     func_type1
  55.               cmp.w   #86,d0          ; Frename() ?
  56.               beq     func_frename
  57. old_vec:      movea.l oldvec,a0
  58.               jmp     (a0)
  59. func_type1:   movea.l 2(a0),a0        ; ptr to filename
  60. func1_1:      bsr     convert_name
  61.               bra.s   old_vec
  62. func_pexec:   move.w  2(a0),d0        ; mode: 0/3 = filename at 4(a0)
  63.               cmp.w   #0,d0
  64.               beq.s   .pexec2
  65.               cmp.w   #3,d0
  66.               bne.s   old_vec
  67. .pexec2:      movea.l 4(a0),a0
  68.               bra.s   func1_1
  69. func_frename: move.l  a0,-(sp)
  70.               movea.l 8(a0),a0
  71.               bsr     convert_name
  72.               movea.l (sp)+,a0
  73.               bra.s   func_pexec
  74. ;}}}
  75. ;{{{  convert_name: convert '/' -> '\'  at (a0)+
  76. convert_name:
  77.               move.b  (a0),d0
  78.               beq     .convend
  79.               cmp.b   #"/",d0
  80.               bne     .convnext
  81.               move.b  #"\",(a0)
  82. .convnext:    addq.l  #1,a0
  83.               bra.s   convert_name
  84. .convend:     rts
  85. ;}}}
  86.  
  87. res_len       EQU *-start
  88. ; everything after this point does not stay resident in memory
  89.  
  90. ;{{{  install resident part
  91. init:         pea     new_vec(pc)
  92.               move.l  #$050021,-(sp)  ; Setexc(33,...)
  93.               trap    #13
  94.               addq.l  #8,sp
  95.               move.l  d0,oldvec
  96.  
  97.               lea     inst_txt(pc),a0
  98.               bsr     Cconws
  99.  
  100.               clr.w   -(sp)           ; Ret.-Code
  101.               move.l  #256+res_len,-(sp)
  102.               move.w  #49,-(sp)       ; Ptermres()
  103.               trap    #1
  104. ;}}}
  105. ;{{{  Cconws: print text
  106. Cconws:       move.l  a0,-(sp)
  107.               move.w  #9,-(sp)
  108.               trap    #1              ; Cconws
  109.               addq.l  #6,sp
  110.               rts
  111. ;}}}
  112.  
  113. inst_txt:     DC.B 13,10,"Un*xName V1.0 ╜ 1991 by Michael Schwingen installed.",13,10,0
  114.