'160115 Added Better support for Multiple Temp Macros (Temp_Mack1, Temp_Mack2 etc)
'160624 Removed black lines at top of certain macro's
_TITLE "Macro Flatten to Assembly File -- REV 160624" '
x1
= LEN(aCommand
) 'we need to strip it out, so get SIZE of stringIF x1
> 0 THEN 'IF called by multi-edit, a command will have the entire path and file DO WHILE x1
<> 0 'This routine will back through the characters, looking for the first IF MID$(aCommand
, x1
, 1) <> "\" THEN 'back slash. The characters preceeding the back slash is the file name x1 = x1 - 1
aFile1
= MID$(aCommand
, x1
+ 1)'-----------------------------------------------------------------
' aCommand = "trolling"
'aCommand = "c:\mplabfls\active\" + aFile1 + "\" + aFile1
aCommand = ".\J13Gps4G"
x1 = x2
x2 = x2 - 1
'x2 and x1 ok
aPath
= LEFT$(aCommand
, x2
)aFile
= MID$(aCommand
, x2
+ 1, x1
- x2
)
aSource = aPath + aFile + ".LST"
PRINT "Source--->"; aSource
aDest = aPath + "combo.asm"
aReverse = aPath + "Rev0p0.asm"
PRINT "Dest----->"; aDest
aFind = " list"
'----------------------------------------
'----------------------------------------
aIn = aNext
aNext = ""
'----------------------------------------
x1
= INSTR(aIn
, "include") x2
= INSTR(aIn
, "syscon") aIn
= MID$(aIn
, x1
) 'get include line less line number aIn = ""
'----------------------------------------
aIn = ""
'----------------------------------------
aIn = ""
'----------------------------------------
aIn = ""
'----------------------------------------
' ELSE
' CLOSE 1
' print "Closed 1"
' END
'----------------------------------------
aIn
= aIn
+ MID$(aNext
, 29) 'fix the line aNext = ""
'----------------------------------------
IF (INSTR(MID$(aIn
, 23, 5), "0") = 1) OR (xMacro
= 5) THEN 'macro and valid assembly lines only pass this point IF (xMacro
= 5) THEN 'Macro Lines are processed here x1 = 1: aSpace = ""
aSpace = aSpace + " "
x1 = x1 + 1
aSpace = aSpace + " " 'add 1 for comment character
IF MID$(aIn
, 3, 1) <> " " THEN 'only display the macro if code generated in macro PRINT #2, aSpace
+ aMacro
aSaved = ""
IF (MID$(aIn
, 3, 1) <> " ") THEN 'OR (INSTR(aIn, "local") > 0) PRINT #2, aSpace
+ aMacro
ELSE 'assembly lines are processed ';----------------------------------------------Process Local Macro's if any
aFile1 = aPath + aFile1 + "0p0.ASM"
'KILL aFile1
'NAME aDest AS aFile1
' system
'----------------------------------------------Subroutines
MakeMacroString:
x1 = 1
x1 = x1 + 1
aMacro
= " " + MID$(aMacro
, x1
)'----------------------------------------------Process temp labels
aMacro = "" 'delete local macros
xTempLabel = xTempLabel + 1
aTempLabel
= "_" + MID$(STR$(xTempLabel
), 2) x1
= INSTR(aMacro
, "Mac_Temp") x2
= INSTR(aMacro
, "Mac_Temp:") x4
= INSTR(aMacro
, "goto Mac_Temp") x5
= INSTR(aMacro
, "bra Mac_Temp") x6
= INSTR(aMacro
, "bnz Mac_Temp") x7
= INSTR(aMacro
, "set Mac_Temp") IF x3
< x1
THEN 'strip any label present and add new one aMacro
= LEFT$(aMacro
, x3
- 1) + aTempLabel
+ MID$(aMacro
, x1
) ELSEIF x2
> 0 THEN 'install new label on numberless labels aMacro
= LEFT$(aMacro
, x2
- 1) + aTempLabel
+ MID$(aMacro
, x2
) ELSEIF (x4
> 0) OR (x5
> 0) OR (x6
> 0) OR (x7
> 0) THEN 'INstall lable on forward defined labels aMacro
= LEFT$(aMacro
, x1
- 1) + aTempLabel
+ MID$(aMacro
, x1
) aMacro
= aTempLabel
+ LEFT$(aMacro
, x2a
) aMacro
= LEFT$(aMacro
, x8
- 1) + MID$(aMacro
, x8
+ 2)
'-----------------------------------------------------------------------------------------------