home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_06 / PP58.ZIP / PP58.MSA / EASYRIDE.S < prev    next >
Text File  |  1990-11-07  |  3KB  |  123 lines

  1. * The Alien is such a generous chap, he's 'accidentally' left this piece of
  2. * source on here for all you Easyriders...
  3.  
  4.     opt    o+
  5. * Devpac source; set tabs to 13!
  6. * This will clean up an Easy Rider-produced source file...
  7. *
  8. * The colon after a label name becomes a tab.
  9. * The multiple spaces at the start of a line become a single tab.
  10. * The multiple spaces between the two halves of an instruction become a tab.
  11. * The trailing spaces on many lines are killed.
  12. *
  13. * On average, the cleaned up source file is 28% smaller than the original
  14. * Easy Rider source file!
  15. *
  16. * Before you can use some Easy Rider source files, you'll have to replace
  17. * the DS.W 1,0 sort of instructions with DCB.W 1,0's...
  18. * short word addressing is shown with .S instead of .W e.g. $43E.S...
  19. * EQUs referring anywhere are generally placed before the place they are
  20. * referring to, so need to be moved to stop Forward Reference errors...
  21. * EXGs involving data registers have the two register swapped around!!
  22.  
  23.     lea    originalfile(pc),a0
  24.     lea    cleanedupfile,a1
  25. next    move.b    (a0)+,d0
  26.     cmp.l    #cleanedupfile,a0
  27.     beq    end
  28.  
  29. * replace 's with "s - I prefer "s... also used for telling multiple space
  30. * replacer when to ignore multispaces, when within data statements.
  31.     cmp.b    #"'",d0
  32.     bne.s    notdata
  33.     eor.w    #-1,indata
  34.     move.b    #'"',(a1)+
  35.     bra.s    next
  36.  
  37. * replace label :'s with tabs
  38. notdata    cmp.b    #'L',d0
  39.     bne.s    notlabel
  40.     cmp.b    #':',4(a0)    L1234:
  41.     bne.s    notlabel         ^ is 4(a0)
  42.     move.b    d0,(a1)+
  43.     move.b    (a0)+,(a1)+
  44.     move.b    (a0)+,(a1)+
  45.     move.b    (a0)+,(a1)+
  46.     move.b    (a0)+,(a1)+
  47.     move.b    #9,(a1)+    tab
  48.     addq.l    #1,a0    skip the :
  49.     bra.s    next
  50.  
  51. * kill trailing spaces
  52. notlabel    cmp.b    #10,d0    last byte of a line is linefeed
  53.     bne.s    notlf
  54.     cmp.b    #32,-3(a0)    was there a trailing space
  55.     bne.s    notlf
  56.     move.b    #13,-2(a1)    move the CR,LF back one byte
  57.     move.b    d0,-1(a1)
  58.     bra.s    next
  59.  
  60. * replace multiple spaces with tabs
  61. notlf    tst.w    indata    are we within data statement
  62.     bmi.s    notspace    e.g. DC.B '    ', if so skip this lot
  63.     cmp.b    #32,d0
  64.     bne.s    notspace
  65.     cmp.b    #32,(a0)    multiple?
  66.     bne.s    singlespace
  67.     move.b    #9,(a1)+    tab it
  68. skipspaces    cmp.b    #32,(a0)+    skip remaining spaces
  69.     beq.s    skipspaces
  70.     subq.l    #1,a0
  71.     bra.s    next
  72.  
  73. * just a single space, might be the space between each instruction half
  74. * e.g. MOVEM.L D0-D7/A0-A6,-(A7)
  75. *     ^ here is a single space, but we want a tab
  76. singlespace    cmp.b    #'.',-3(a0)    check for the . in the instruction
  77.     bne.s    notspace
  78.     cmp.b    #'B',-2(a0)    .B?
  79.     beq.s    ishalf
  80.     cmp.b    #'W',-2(a0)    .W?
  81.     beq.s    ishalf
  82.     cmp.b    #'L',-2(a0)    .L?
  83.     bne.s    notspace
  84. ishalf    move.b    #9,(a1)+    quite likely so tab it
  85.     bra    next
  86.  
  87. * just copy a character over
  88. notspace    move.b    d0,(a1)+
  89.     bra    next
  90.  
  91.  
  92. * save the cleaned up file
  93. end    sub.l    #cleanedupfile,a1
  94.     move.l    a1,len+2
  95.     clr.w    -(sp)
  96.     pea    file(pc)
  97.     move.w    #$3c,-(sp)
  98.     trap    #1
  99.     addq.l    #8,sp
  100.     pea    cleanedupfile
  101. len    pea    0.l
  102.     move.w    d0,-(sp)
  103.     move.w    d0,d7
  104.     move.w    #$40,-(sp)
  105.     trap    #1
  106.     lea    12(sp),sp
  107.     move.w    d7,-(sp)
  108.     move.w    #$3e,-(sp)
  109.     trap    #1
  110.     addq.l    #4,sp
  111.  
  112.     clr.w    -(sp)
  113.     trap    #1
  114.  
  115.     data
  116. indata    dc.w    0
  117.  
  118. * this is the filename you want to save the fixed doc as:
  119. file    dc.b    "f:\TEST2.s",0
  120.  
  121. * this is the source file you want to clean up:
  122. originalfile    incbin    "f:\TEST.s"
  123. cleanedupfile