home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hall of Fame
/
HallofFameCDROM.cdr
/
prog4
/
assm.lzh
/
COM2ASM.BAS
< prev
next >
Wrap
BASIC Source File
|
1983-06-18
|
3KB
|
54 lines
10 'COM2ASM.BAS COPYRIGHT 1983 BY RICH WINKEL
20 'THIS PROGRAM IS NOT TO BE SOLD. FOR FREE DISTRIBUTION ONLY.
30 DEFINT A-Z:DIM LIN$(999),JMP$(50) 'ARRAY OF REFERENCED HEX ADDRESSES
40 GOSUB 490
50 INPUT "Enter name of input file: ";INFILE$
60 INPUT "Enter name of output file: ";OUTFILE$
70 OPEN INFILE$ FOR INPUT AS #1
80 OPEN OUTFILE$ FOR OUTPUT AS #2:PRINT #2,".RADIX 16"
90 IF EOF(1) THEN 160
100 LINE INPUT #1,A$:IF LEN(A$)<28 THEN 90 ELSE J$=MID$(A$,25,4)
110 FOR I=1 TO JMPNUM:IF J$<>JMP$(I) THEN NEXT:GOTO 90
120 IF MID$(A$,33,1)="[" THEN 90 'IF INDIRECT ADDRESSING, SKIP IT
130 IF MID$(A$,33,3)="FAR" THEN 90
140 IF MID$(A$,37,1)=":" THEN 90 'IF INTER-SEGMENT JUMP, SKIP
150 LIN=LIN+1:LIN$(LIN)=MID$(A$,33,4):GOTO 90 'OTHERWISE, SAVE THE REFERENCE
160 CLOSE #1:OPEN INFILE$ FOR INPUT AS #1 'RE-POSITION READ POINTER
170 PRINT "Sorting . ." 'super shell sort (byte may '83)
180 D=2^INT(LOG(LIN)/LOG(2))-1 'SORT REFERENCED ADDRESSES
190 FOR I=1 TO LIN-D
200 IF LIN$(I)<=LIN$(I+D) THEN 260 ELSE T$=LIN$(I+D):LIN$(I+D)=LIN$(I)
210 IF I<=D THEN LIN$(I)=T$:GOTO 260
220 FOR J=I-D TO 1 STEP -D
230 IF T$>=LIN$(J) THEN 250 ELSE LIN$(J+D)=LIN$(J)
240 NEXT J
250 LIN$(J+D)=T$
260 NEXT I
270 D=INT(D/2):IF D>0 THEN 190 ELSE I=1
280 IF I=LIN THEN 310 'ARRAY IS SORTED, NOW GET RID OF DUPLICATES
290 IF LIN$(I)=LIN$(I+1) THEN FOR J=I TO LIN:LIN$(J)=LIN$(J+1):NEXT:LIN=LIN-1 ELSE I=I+1
300 GOTO 280
310 L=1 'NOW GO BACK THRU FILE AND PLUG IN LABELS FOR ADDRESSES
320 IF EOF(1) THEN CLOSE:END
330 LINE INPUT #1,A$:IF LEN(A$)<28 THEN 320
340 IF MID$(A$,6,4)<>LIN$(L) THEN MID$(A$,6,4)=" ":GOTO 380 'CHECK ADDRESS
350 L$=STR$(L):L$="L"+RIGHT$(L$,LEN(L$)-1) 'IF REFERENCED, REPLACE WITH LABEL
360 L$=L$+":"+STRING$(4-LEN(L$)," ")
370 MID$(A$,6,5)=L$:L=L+1
380 J$=MID$(A$,25,4):FOR I=1 TO JMPNUM:IF J$<>JMP$(I) THEN NEXT:GOTO 450
390 IF MID$(A$,33,1)="[" THEN 450
400 IF MID$(A$,33,3)="FAR" THEN 450
410 IF MID$(A$,37,1)=":" THEN 450
420 REF$=MID$(A$,33,4):FOR I=1 TO LIN:IF REF$<>LIN$(I) THEN NEXT
430 L$=STR$(I):L$="L"+RIGHT$(L$,LEN(L$)-1) 'REPLACE ADDRESS WITH PROPER LABEL
440 MID$(A$,33,4)=L$+STRING$(4-LEN(L$)," ")
450 A$=MID$(A$,6,5)+" "+RIGHT$(A$,LEN(A$)-23) 'GET RID OF SEG & OP CODE
460 FOR I=LEN(A$) TO 2 STEP -1:IF MID$(A$,I,1)=" " THEN NEXT
470 A$=LEFT$(A$,I) 'CHOP OFF TRAILING BLANKS
480 PRINT A$:PRINT #2,A$:GOTO 320
490 JMPNUM=33:FOR I=1 TO JMPNUM:READ JMP$(I):NEXT:RETURN
500 DATA "JMP ",JMPS,CALL,"JA ",JNBE,"JAE ","JNB ","JB ",JNAE,"JBE ","JNA ",JCXZ
510 DATA "JE ","JZ ","JG ",JNLE,"JGE ","JNL ","JL ",JNGE,"JLE ","JNG "
520 DATA "JNE ","JNZ ","JNO ","JNP ","JPO ","JNS ","JO ","JP ","JPE ","JS "
530 DATA LOOP