'=========================================================================== ' Subject: DEBUG ASM CONVERTER Date: 07-29-96 (17:10) ' Author: Daniel Garlans Code: QB, QBasic, PDS ' Origin: garlans@usa.pipeline.com Packet: ASMCODE.ABC '=========================================================================== 'DEBUG ASM Converter Version 1.0a Rewrite 1 'Written by: White Shade of DuoTech '(Real Name: Daniel Garlans) 'This program is freeware. 'You may use this code any way you like, just give me credit =] 'Information on conversion from a FAQ by Ian Muskgrave (sorry if I misspelled) 'My E-Mail Address: garlans@usa.pipeline.com 'This converts DEBUG-ASM (debug < name.dbg > out.asm) into CALL ABSOLUTE strings 'and saves them and code for use into an out file. 'This is rewrite 1 because my first version was written at about 9:30 to 10:30 pm 'and I was tired and so it was huge, messy and wasn't working, so the next day 'I wrote it entirely from scratch :) 'Absolutly needed in the file to convert from: '-U in a line to show where the HEX Code output started and -Q in a line to 'show what line the output ends on. Format of a converted line in result file: 'ASM$=ASM$+whatevertoadd 'offset = xxxx:xxxx hex code:whateverthehexis 'the ASM$ can be changed to whatever. 'Sub Cp prints t$ in the center of row l! in 80 column text mode. 'Have fun with this :) It's fully commented. 'you can do whatever you want with it... 'THINGS 2 KNOW: No error handling...Still some optimizing to do...quite fast... 'can convert something like a 16k file (I don't have anything that big to test with) DECLARE SUB Cp (t$, l!) CLS 'print a headline :) COLOR 15, 1 'set background to dark blue, foreground to bright white LOCATE 1, 1: PRINT STRING$(80, " ") 'make first line be all dark blue CALL Cp("DebugASM Converter 1.0a", 1) 'use Cp to write the text to the center COLOR 7, 0 'make colors normal INPUT "File to Convert:"; a$: file$ = UCASE$(a$) 'get filename and make it uppercase INPUT "File to write to:"; a$: outfile$ = UCASE$(a$)'get output name and make it uppercase INPUT "String to write to:"; a$: cnme$ = UCASE$(a$)'get string name in output file and make it uppercase PRINT " Converting: " + file$ 'display info PRINT " Saving output to: " + outfile$ 'ditto PRINT " Converted Code String: " + cnme$ 'ditto OPEN file$ FOR INPUT AS #1 'Open Files OPEN outfile$ FOR OUTPUT AS #2 'Open Files st = 0 'start pos... if still 0 after next block, error :) en = 0'end pos...ditto PRINT "Finding start of hex code values"; DO WHILE NOT EOF(1) 'Loop until end of the file LINE INPUT #1, a$ 'get a line (commas etc allowed) c$ = UCASE$(a$) 'convert to uppercase IF INSTR(c$, "-U") THEN 'Is -U in it? (indicates start of hex code) st = v + 1 'If it is, make the start equal the next line in file END IF IF INSTR(c$, "-Q") THEN 'Is -Q in it? (indicates end of hex code) en = v 'If so, make end equal this line END IF PRINT "."; 'Display a dot to show that the proggy is working :) v = v + 1 'Increase current-line counter LOOP 'duh :) PRINT 'go to next line (because of the 'print ".";') SEEK 1, 1 'Set current position in input file to first character (it was at the end) 'DIM lne$(1 TO v) 'Actually, This isn't needed...wonder what I was thinking.... :) IF st = 0 OR en = 0 THEN 'Wait! If the start and end positions are STILL zero now, the program failed. PRINT "Error, -U or -Q not found. Unable to convert." CLOSE 'close files END 'duhh :) END IF PRINT "Moving to start of HEX code at line "; st FOR a = 1 TO st 'loop until start line LINE INPUT #1, temp$ 'so the file pos is moved. NEXT a lnt = en - st 'amount of lines between -U and -Q PRINT "Converting & Saving..." FOR a = 1 TO lnt 'loop for the lines between -U and -Q LINE INPUT #1, a$ 'get the line to work on a$ = UCASE$(a$) 'make uppercase (for neatness in output) IF LEN(a$) > 0 THEN 'so it doesn't try to convert a blank line :) offse$ = LEFT$(a$, 9) 'Get Offset (always first 9 letters xxxx:xxxx) toconv$ = MID$(a$, 11, 6) 'get the HEX Code to convert toconv$ = RTRIM$(toconv$) 'trim spaces from end toconv$ = LTRIM$(toconv$) ' " " " start 'dn = LEN(tonconv$) 'get length...whoops this isn't needed because... SELECT CASE LEN(toconv$) 'select case with the length of this :) CASE 2 'maybe like CB (retf) fin$ = "CHR$(&H" + toconv$ + ")" 'Make the output string.. CASE 4 'maybe like CD33 (int 33h) one$ = LEFT$(toconv$, 2) 'get first two letters two$ = RIGHT$(toconv$, 2) 'get last two letters fin$ = "chr$(&H" + one$ + ") + chr$(&H" + two$ + ")" 'make output string CASE 6 'maybe like B80100 (mov ax,0001) one$ = LEFT$(toconv$, 2) 'get first two two$ = MID$(toconv$, 3, 2) 'get last two fin$ = "chr$(&H" + one$ + ") + chr$(&H" + two$ + ")" 'make output string CASE ELSE 'Prolly an error PRINT "Warning: Unknown hex string, cannot convert." fin$ = "" 'make output string be nothing. END SELECT IF LEN(fin$) <> 0 THEN 'do this only if the output string is more than nothing (see in CASE ELSE it sets FIN$ to nothing?) v$ = cnme$ + "=" + cnme$ + "+" + fin$ + " 'Offset=" + offse$ + " Hex Command= " + toconv$ 'Assemble output string (see opening comments) PRINT #2, v$ 'write final final output string to the output file END IF END IF NEXT a PRINT "Writing info for code use..." 'next four lines write commented out code for the use of the converted code. PRINT #2, "'These next commented lines are for using the converted code." PRINT #2, "'DEF SEG=VARSEG(" + cnme$ + ")" PRINT #2, "'theoff%=SADD(" + cnme$ + ")" PRINT #2, "'CALL ABSOLUTE(theoff%)" CLOSE 'close all file handles PRINT "Conversion of Debug-Asm complete."' " + file$ + " to " + outfile$ + " in " + cnme$ 'give a little info PRINT "Coding by: White Shade of DuoTech" 'More info PRINT "This program is Freeware and may be freely distributed." 'and a little more.. END 'Terminate program :) SUB Cp (t$, l) v = 40 - (LEN(t$) / 2) LOCATE l, v PRINT t$ END SUB