Posted: Sat Dec 6, 1986 3:14 PM PST Msg: LGIG-2500-1353 From: CHHU To: chhu Subj: to John from Maynard Dear John, Appended hereto is a Basic program to produce a table of symbols/labels and the instruction line which branches to the label. Before explaining it though, I would like to voice some concern over the truth of the symbol table produced by the Assembler in the listing file. Looking at my listing file for RPNLEX, the Symbol Table shows RPN01 at 00123, SLEEP at 01730, and STMSOD at 00642, for just three examples. Well, these equates just aren't true! What do you think gives here? Anyway, I called my program XLIST. It works on a listing file created in ram by the Assembler, and it chews it up so I recommend saving the original listing file before using this. What happens is this. The first pass through the file deletes all lines other than those which contain object code and preserves the symbol table. It also deletes all lines which do not branch, except for GOYES, which is too complicated and therefore not supported here. I hpoe that's not too much of a disaster. The second pass calculates the absolute address of the branch and writes it to the file as a fourth field, after the object code. The third phase reads each record once for each symbol employed, and prints matches. Printed output consists of: Symbol, Assembled Hex Address :: and a list of the hex addresses of the lines which effected the branch. After a Form Feed, the text file is PLISTed. Anything from the original listing file beyond the 18th character is ignored, and retained. The absolute address of the branch is written to characters 20-24. The big problem it seems to me is creating the original listing file. For instance, my 71 has one of the 32k modules, and not enough room for both source and listing for RPNLEX. Since a listing can't be made to the disk, the source can reside there, but the 9114 runs out of juice before the assembly is finished; this fresh after an eight hour nap. So anyway, here you go. 0010 ! Program XLIST 0012 ! reads Assembler Listing file and prints a table of symbols and the 0014 ! assembled line which branched to that label. 0016 ! Output shows symbol name and assembled hex address followed by ' :: ' 0018 ! Following this is a list of the assembled hex address which branched 0020 ! to that label. 0022 ! Some symbols are variable locations and other equates which are not 0024 ! branched to. 0026 ! All branches except GOYES are supported. 0028 ! Program demolishes the original Listing file and leaves a text file 0030 ! of the same name which contains only (almost) those original listing fil e 0032 ! lines which contain branches other than GOYES; and retains the entire 0034 ! symbol table. 0036 ! This text file is further modified from the original listing file by the 0038 ! inclusion of the calculated absolute branch address in a field immediate ly 0040 ! following the object code. 0042 ! 0044 ! REV$ and RTRIM$ used 0046 ! 0090 ! 0092 ! By Maynard Riley [1442] 0094 ! Ver 1.0 Date: 861206 0096 ! 0100 FORTHX "LISTING" @ F$=FORTH$ 0110 DIM A$[96] @ INTEGER F,N 0120 INPUT 'Listing File :',F$;F$ 0130 ASSIGN #1 TO F$ 0140 J=FILESZR(F$) 0150 ON ERROR GOTO 350 0160 N=0 0170 FOR I=0 TO FILESZR(F$)-1 0180 READ #1,I;A$ 0190 DISP A$ 0200 B$=A$[12,12] 0210 IF B$=" " THEN 330 0220 IF A$[1,5]="Forth" THEN 330 0230 IF LEN(A$)<12 THEN 330 0240 IF A$[1,1]=" " THEN 330 0250 IF A$[8,8]=" " THEN N=N+1 @ GOTO 340 0260 IF B$<"4" OR B$>"8" THEN 330 0270 C$=RTRIM$(A$[12,18]) 0280 IF B$<"6" AND LEN(C$)#3 THEN 330 0290 IF B$="6" AND LEN(C$)#4 THEN 330 0300 IF B$="7" AND LEN(C$)#4 THEN 330 0310 IF B$="8" AND LEN(C$)<6 THEN 330 0320 GOTO 340 0330 DELETE #1,I @ I=I-1 0340 NEXT I 0350 OFF ERROR 0360 F=I-N ! Record Number of First Symbol 0370 ! I is last record/line in text file 0380 ! N is number of symbols 0390 FOR I=0 TO F-1 0400 D=1 0410 READ #1,I;A$ 0420 B$=A$[12,12] 0430 IF B$="7" THEN D=4 0440 IF B$#"8" THEN 490 0450 IF A$[13,13]="D" THEN C$=REV$(A$[14,18]) @ GOTO 560 0460 IF A$[13,13]="F" THEN C$=REV$(A$[14,18]) @ GOTO 560 0470 IF A$[13,13]="E" THEN D=4 0480 C$=A$[14,17] @ GOTO 'CONV' 0490 C$=RTRIM$(A$[13,15]) 0500 'CONV': 0510 C$=REV$(C$) 0520 IF C$[1,1]<"8" THEN C=HTD(C$) @ GOTO 540 0530 C=-1*2^(LEN(C$)*4)+HTD(C$) 0540 C=C+D 0550 C$=DTH$(HTD(A$[6,10])+C) 0560 A$[20,24]=C$ 0570 REPLACE #1,I;A$ 0580 NEXT I 0590 FOR I=F TO F+N-1 0600 READ #1,I;A$ 0610 C$=A$[9,13] 0620 PRINT A$[1,15];" :: "; 0630 FOR J=0 TO F-1 0640 READ #1,J;A$ 0650 IF A$[20,24]=C$ THEN PRINT A$[5,11]; 0660 NEXT J 0670 PRINT 0680 NEXT I 0690 ASSIGN #1 TO * 0700 PRINT CHR$(12) 0710 PLIST F$