DECLARE FUNCTION clean$ (a$)
OPEN "debug22.txt" FOR INPUT AS #1
OPEN "z.txt" FOR OUTPUT AS #3
REM copy out the text..
OPEN "d.txt" FOR OUTPUT AS #2
DO
LINE INPUT #1, a$
IF a$ = "" THEN GOTO again2
line$ = MID$(a$, 5, 4)
PRINT #2, "u " + line$
again2:
LOOP UNTIL EOF(1)
CLOSE #2
SHELL "debug file2.txt <d.txt >t.txt"

OPEN "t.txt" FOR INPUT AS #2
SEEK #1, 1
DO
LINE INPUT #1, a$
IF a$ = "" THEN GOTO again

again3:
LINE INPUT #2, b$
IF LEFT$(b$, 2) <> "=u" AND LEFT$(b$, 2) <> "-u" THEN GOTO again3
LINE INPUT #2, b$
IF LEN(b$) <= 25 THEN LINE INPUT #2, b$

a1$ = RIGHT$(a$, LEN(a$) - 9)
b1$ = RIGHT$(b$, LEN(b$) - 24)
cpx$ = MID$(a$, 5, 5)
'PRINT a1$, b1$
'STOP
a$ = clean$(a1$)
b$ = clean$(b1$)


'FOR a = 1 TO LEN(b$)
'IF MID$(b$, a, 1) = CHR$(9) THEN MID$(b$, a, 1) = " "
'NEXT a

IF LEN(a1$) <= 30 THEN sp$ = SPACE$(30 - LEN(a1$))
IF LEN(a1$) > 30 THEN sp$ = CHR$(13) + CHR$(10) + SPACE$(30)


IF a$ <> b$ THEN PRINT #3, cpx$; a1$; sp$; b1$
'STOP

'PRINT a$, b$
'STOP
again:
LOOP UNTIL EOF(1)


CLOSE #3
CLOSE #1

SYSTEM

FUNCTION clean$ (b$)
a$ = b$
REM this part is what makes it all tick :)
REM first part.. strip all information that it needs...
IF LEFT$(a$, 1) = " " THEN
FOR a = 1 TO LEN(a$)
IF MID$(a$, a, 1) <> " " THEN a$ = RIGHT$(a$, LEN(a$) - (a - 1)): GOTO exxxx
NEXT a
exxxx:
END IF
of = 0
tp = 0
rep = 0
restart:
FOR a = 1 TO LEN(a$)

IF MID$(a$, a, 4) = "NEAR" THEN
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 3))
GOTO restart
END IF
IF MID$(a$, a, 3) = "FAR" THEN
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 2))
GOTO restart
END IF
IF MID$(a$, a, 5) = "SHORT" THEN
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 4))
GOTO restart
END IF

IF MID$(a$, a, 3) = "PTR" THEN
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 2))
END IF

IF MID$(a$, a, 4) = "BYTE" THEN
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 3))
GOTO restart
END IF
IF MID$(a$, a, 4) = "WORD" THEN
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 3))
GOTO restart
END IF

IF MID$(a$, a, 4) = "QUAD" THEN
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 3))
GOTO restart
END IF
IF MID$(a$, a, 5) = "DWORD" THEN
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 4))
GOTO restart
END IF

REM 4?
IF MID$(a$, a, 4) = "REP " THEN
rep$ = "REP "
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 3))
GOTO restart
END IF

IF MID$(a$, a, 5) = "REPZ " THEN
rep$ = "REPZ "
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 4))
GOTO restart
END IF

IF MID$(a$, a, 6) = "REPNZ " THEN
rep$ = "REPNZ "
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 7))
GOTO restart
END IF


IF MID$(a$, a, 5) = "REPE " THEN
rep$ = "REPE "
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 4))
GOTO restart
END IF

IF MID$(a$, a, 6) = "REPNE " THEN
rep$ = "REPNE "
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 5))
GOTO restart
END IF

IF MID$(a$, a, 5) = "LOCK " THEN
rep$ = "LOCK "
a$ = LEFT$(a$, a - 1) + RIGHT$(a$, LEN(a$) - (a + 4))
GOTO restart
END IF
NEXT a

REM TURN 0's INTO SPACES, UNLESS THEY HAVE A USE
REM now remove all, but one space.. (the first seporator from instruction
REM and others..) (except for within double quotes)

REM clear items used...
blah:
sp = 0
c$ = ""
'STOP
FOR a = 1 TO LEN(a$)

IF MID$(a$, a, 1) = "0" AND zz = 0 THEN
IF za > 0 THEN MID$(c$, za, 1) = " "
za = LEN(c$) + 1
END IF

IF VAL(MID$(a$, a, 1)) > 0 AND zz = 0 THEN
IF za > 0 THEN MID$(c$, za, 1) = " "
zz = 1
END IF
IF MID$(a$, a, 1) = CHR$(9) THEN MID$(a$, a, 1) = " "
IF MID$(a$, a, 1) = "H" AND MID$(a$, a + 1, 1) = "]" THEN MID$(a$, a, 1) = " "
IF MID$(a$, a, 1) <> " " THEN c$ = c$ + MID$(a$, a, 1)
IF MID$(a$, a, 1) = " " AND sp = 0 THEN c$ = c$ + " ": sp = 1: spx = a + 1
IF MID$(a$, a, 1) = " " AND sp = 5 THEN c$ = c$ + MID$(a$, a, 1)
IF MID$(a$, a, 1) = CHR$(34) AND sp = 1 THEN sp = 5: GOTO spaces
IF MID$(a$, a, 1) = CHR$(34) AND sp = 5 THEN sp = 1

IF MID$(a$, a, 1) = "," THEN
zz = 0: za = 0
IF MID$(a$, a + 1, 1) = "+" OR MID$(a$, a + 1) = "-" THEN MID$(a$, a + 1, 1) = " "
END IF

IF MID$(a$, a, 1) = ";" AND sp <= 1 THEN a = LEN(a$)
spaces:
NEXT a

IF MID$(c$, LEN(c$), 1) = "H" THEN MID$(c$, LEN(c$), 1) = " "

sp = 0
a$ = c$
c$ = ""
'STOP
FOR a = 1 TO LEN(a$)

IF MID$(a$, a, 1) <> " " THEN c$ = c$ + MID$(a$, a, 1)
IF MID$(a$, a, 1) = " " AND sp = 0 THEN c$ = c$ + " ": sp = 1: spx = a + 1
IF MID$(a$, a, 1) = " " AND sp = 5 THEN c$ = c$ + MID$(a$, a, 1)
IF MID$(a$, a, 1) = CHR$(34) AND sp = 1 THEN sp = 5: GOTO spaces1
IF MID$(a$, a, 1) = CHR$(34) AND sp = 5 THEN sp = 1
IF MID$(a$, a, 1) = ";" AND sp <= 1 THEN a = LEN(a$)
spaces1:
NEXT a



'PRINT rep$ + c$ + "{X}"
'STOP
clean$ = rep$ + c$
END FUNCTION

