zben@umd5.UUCP (08/08/85)
Sorry about the delay, took a few days to locate a good Kermit to get it transfered up. BTW I used the SERDAC version of the MACC implementation. Run the program, give it the start and end addresses (IN HEX!!!) of the range you want to disassemble, and a file name to which it will write a data file containing the disassembled code. It uses a short patch at $300, so it will not disassemble code at $300 without modification. The patch is position-independant, so you could relocate it to $8000 or something if you need to disassemble code at $300. As stated before, I used it to freak code from DOS, so the address problems never came up. This could probably be done much simpler by planting a CSWL hook that just saves and restores X and Y, but I didn't think about that until after I had written the program. I apologize to C and every other systems implementation language I have ever cursed. Systems programming in Applesoft Basic is really like pulling teeth! ----------------------------------------------------- 1 REM ARKABLE PROGRAM 2 REM TO DISASSEMBLE 3 REM PROGRAMS FROM CORE 4 REM TO A TEXT FILE! 5 REM YOU GIVE IT START 6 REM AND END ADDRESSES 7 REM AND THE NAME OF THE 8 REM FILE IT PUTS IT IN. 9 REM 100 REM 101 REM POKE ASSEMBLY INTO 102 REM LOW-CORE ($300) 103 REM 110 GOSUB 7000 200 REM 201 REM GET START ADDRESS 202 REM 210 INPUT "FROM: ";H$ 220 GOSUB 6000 230 IF D > = 0 GOTO 260 240 PRINT "OOPS!" 250 GOTO 210 260 LET F = D 270 LET B1 = INT (F / 256) 280 LET B2 = F - 256 * B1 290 POKE 58,B2: POKE 59,B1 300 REM 301 REM GET END ADDRESS 302 REM 310 INPUT " TO : ";H$ 320 GOSUB 6000 330 IF D > = 0 GOTO 360 340 PRINT "OOPS!" 350 GOTO 310 360 LET T = D 370 IF T > = F GOTO 400 380 PRINT "WILL NEVER GET THERE!" 390 GOTO 310 400 REM 401 REM GET FILENAME 402 REM IF NONE THEN 403 REM OUTPUT TO SCREEN 404 REM 410 INPUT "FILE: ";F$ 420 IF LEN (F$) = 0 GOTO 500 430 ONERR GOTO 450 440 PRINT CHR$ (4);"DELETE ";F$ 450 POKE 216,0 470 PRINT CHR$ (4);"OPEN ";F$ 480 PRINT CHR$ (4);"WRITE ";F$ 500 REM 501 REM DO THE DISASSEMBLY. 502 REM 510 GOSUB 8000 520 FOR I = 512 TO 511 + PEEK (6) 530 PRINT CHR$ ( PEEK (I)); 540 NEXT I 550 LET F = 256 * PEEK (59) + PEEK (58) 560 IF F < = T GOTO 510 600 REM 601 REM IF OUTPUT TO FILE 602 REM THEN CLOSE FILE 603 REM 610 PRINT CHR$ (13) 620 IF LEN (F$) = 0 GOTO 9999 630 PRINT CHR$ (4);"CLOSE ";F$ 640 GOTO 9999 6000 REM 6001 REM HEX TO DEC CONVERT. 6002 REM 6010 LET D = 0 6020 FOR I = 1 TO LEN (H$) 6030 LET H = ASC ( MID$ (H$,I,1)) - 48 6040 IF H > = 0 AND H < = 9 GOTO 6070 6050 LET H = H - 7 6060 IF H < 10 OR H > 15 GOTO 6200 6070 LET D = 16 * D + H 6080 NEXT I 6090 RETURN 6200 REM 6201 REM HEX NUMBER ERROR. 6202 REM 6210 LET D = - 1 6220 RETURN 7000 REM 7001 REM POKE ASSEMBLY ROUTINE 7002 REM USED BY BELOW. 7003 REM 7010 FOR I = 768 TO 785 7020 READ B 7030 POKE I,B 7040 NEXT I 7050 RETURN 7100 REM 7101 REM LISTING OF ASSEMBLY 7102 REM ROUTINE USED TO CALL 7103 REM MONITOR DISASSEMBLER. 7104 REM 7110 REM ORG $300 7111 REM PTR EQU $6 7112 REM YSV EQU $7 7113 REM BUF EQU $200 7114 REM LIST2 EQU $FE63 7115 REM * 7116 REM * CALL DISASSEMBLER. 7117 REM * 7118 REM DOIT LDA #1 7119 REM JSR LIST2 7120 REM RTS 7121 REM * 7122 REM * INTERCEPT ROUTINE. 7123 REM * 7124 REM ZAP STY YSV 7125 REM LDY PTR 7126 REM STA BUF,Y 7127 REM LDY YSV 7128 REM INC PTR 7129 REM RTS 7200 REM 7201 REM THIS IS THE CODE 7202 REM FOR ABOVE THAT 7203 REM WE POKE INTO CORE. 7204 REM 7220 DATA 169,001,032,099 7230 DATA 254,096,132,007 7240 DATA 164,006,153,000 7250 DATA 002,164,007,230 7260 DATA 006,096 8000 REM 8001 REM DISASSEMBLE PROGRAM 8002 REM FROM MEMORY. 8003 REM 8030 LET S1 = PEEK (54) 8040 LET S2 = PEEK (55) 8050 POKE 54,6: POKE 55,3 8060 POKE 6,0 8070 CALL 768 8080 POKE 54,S1: POKE 55,S2 8090 RETURN 9999 END -- Ben Cranston ...{seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben zben@umd2.ARPA