I have a .txt document with over 32,000 lines of commented machine code. It looks like this:
Display menu window
C0/000E: E220 SEP #$20
C0/0010: C210 REP #$10
C0/0012: 20640B JSR $0B64
C0/0015: 20750B JSR $0B75
C0/0018: C220 REP #$20
C0/001A: A90001 LDA #$0100
I need to convert the code as follows for compiling purposes:
; Display menu window
SEP #$20
REP #$10
JSR $0B64
JSR $0B75
REP #$20
LDA #$0100
Specifically, that means:
Any help would be greatly appreciated.
The Batch file below is a different approach that may run faster than other similar methods, but this largely depends on the size of the file:
@echo off
for /F "tokens=1-2*" %%a in ('findstr /N "^" test.txt') do (
for /F "tokens=1,2 delims=:/" %%d in ("%%a") do (
if "%%e" equ "C3" (
echo %%c
) else if "%%e" neq "" (
echo ; %%e %%b %%c
) else (
echo/
)
)
)
However, the fastest method is via a Batch-JScript hybrid script. Save the file below with .bat extension:
@set @Batch=1 /*
@cscript //nologo //E:JScript "%~F0" < test.txt
@goto :EOF & rem */
WScript.Stdout.Write(WScript.Stdin.ReadAll().replace
(/^C3\/.{15}|^(..)/gm,function(A){return A.length==2?"; "+A:""}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With