home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Supremacy 2
/
Supremacy-2.iso
/
Pompey
/
PP_058.MSA
/
EASYRIDE.S
< prev
next >
Wrap
Text File
|
1990-11-07
|
3KB
|
123 lines
* The Alien is such a generous chap, he's 'accidentally' left this piece of
* source on here for all you Easyriders...
opt o+
* Devpac source; set tabs to 13!
* This will clean up an Easy Rider-produced source file...
*
* The colon after a label name becomes a tab.
* The multiple spaces at the start of a line become a single tab.
* The multiple spaces between the two halves of an instruction become a tab.
* The trailing spaces on many lines are killed.
*
* On average, the cleaned up source file is 28% smaller than the original
* Easy Rider source file!
*
* Before you can use some Easy Rider source files, you'll have to replace
* the DS.W 1,0 sort of instructions with DCB.W 1,0's...
* short word addressing is shown with .S instead of .W e.g. $43E.S...
* EQUs referring anywhere are generally placed before the place they are
* referring to, so need to be moved to stop Forward Reference errors...
* EXGs involving data registers have the two register swapped around!!
lea originalfile(pc),a0
lea cleanedupfile,a1
next move.b (a0)+,d0
cmp.l #cleanedupfile,a0
beq end
* replace 's with "s - I prefer "s... also used for telling multiple space
* replacer when to ignore multispaces, when within data statements.
cmp.b #"'",d0
bne.s notdata
eor.w #-1,indata
move.b #'"',(a1)+
bra.s next
* replace label :'s with tabs
notdata cmp.b #'L',d0
bne.s notlabel
cmp.b #':',4(a0) L1234:
bne.s notlabel ^ is 4(a0)
move.b d0,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b #9,(a1)+ tab
addq.l #1,a0 skip the :
bra.s next
* kill trailing spaces
notlabel cmp.b #10,d0 last byte of a line is linefeed
bne.s notlf
cmp.b #32,-3(a0) was there a trailing space
bne.s notlf
move.b #13,-2(a1) move the CR,LF back one byte
move.b d0,-1(a1)
bra.s next
* replace multiple spaces with tabs
notlf tst.w indata are we within data statement
bmi.s notspace e.g. DC.B ' ', if so skip this lot
cmp.b #32,d0
bne.s notspace
cmp.b #32,(a0) multiple?
bne.s singlespace
move.b #9,(a1)+ tab it
skipspaces cmp.b #32,(a0)+ skip remaining spaces
beq.s skipspaces
subq.l #1,a0
bra.s next
* just a single space, might be the space between each instruction half
* e.g. MOVEM.L D0-D7/A0-A6,-(A7)
* ^ here is a single space, but we want a tab
singlespace cmp.b #'.',-3(a0) check for the . in the instruction
bne.s notspace
cmp.b #'B',-2(a0) .B?
beq.s ishalf
cmp.b #'W',-2(a0) .W?
beq.s ishalf
cmp.b #'L',-2(a0) .L?
bne.s notspace
ishalf move.b #9,(a1)+ quite likely so tab it
bra next
* just copy a character over
notspace move.b d0,(a1)+
bra next
* save the cleaned up file
end sub.l #cleanedupfile,a1
move.l a1,len+2
clr.w -(sp)
pea file(pc)
move.w #$3c,-(sp)
trap #1
addq.l #8,sp
pea cleanedupfile
len pea 0.l
move.w d0,-(sp)
move.w d0,d7
move.w #$40,-(sp)
trap #1
lea 12(sp),sp
move.w d7,-(sp)
move.w #$3e,-(sp)
trap #1
addq.l #4,sp
clr.w -(sp)
trap #1
data
indata dc.w 0
* this is the filename you want to save the fixed doc as:
file dc.b "f:\TEST2.s",0
* this is the source file you want to clean up:
originalfile incbin "f:\TEST.s"
cleanedupfile