home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.whtech.com
/
ftp.whtech.com.tar
/
ftp.whtech.com
/
Geneve
/
9640news
/
CAT17
/
DSSSMBLR.ARK
< prev
next >
Wrap
Text File
|
2006-10-19
|
6KB
|
119 lines
?
FAST FORTH DISASSEMBLER
=======================
(Excerpted from Network-99 Newletter 1#5 by permission of the Author
Briand Sanderson. For a subscription write to Briand Sanderson, c/o LTC
M. C. Sanderson, Hdq. 2nd/33rd Armor, P.O. Box 4356, APO NY 09045. The
newsletter is a monthly and costs $10 per year.)
Briand has written the first half of a super-fast FORTH disassembler. He
has two versions of the first part which gives the disassemble listing of
the address, its contents, text and the opcode. In the second installment
in the next Network-99 Newsletter he will be adding the operands to the
diassembled code. The first version below is four screens long but turns
out to be about 15% faster, according to Briand, than the second which takes
up only two screens. Both are blindingly fast!
( FORTH DISASSEMBLER VERSION 1.1 NETWORK-99 NEWLETTER 1#4 PG1 )
BASE->R HEX
: FORMAT ( HEX --- FORMAT ) DUP 0 < IF 1 ELSE DUP 200 < IF 0
ELSE DUP 340 < IF 8 ELSE DUP 400 < IF 7
ELSE DUP 800 < IF 6 ELSE DUP 1000 < IF 5
ELSE DUP 2000 < IF 2 ELSE DUP 2C00 < IF 3 ELSE DUP 3000 < IF 9
ELSE DUP 3800 < IF 4 ELSE DUP 4000 < IF 9 ELSE 1 THEN THEN
THEN THEN THEN THEN THEN THEN THEN THEN THEN SWAP DROP ;
: FM1 DUP 0 1000 M/ SWAP DROP CASE 4 OF ." SZC " ENDOF 5
OF ." SZCB " ENDOF 6 OF ." S " ENDOF 7 OF ." SB " ENDOF 8
OF ." C " ENDOF 9 OF ." CB " ENDOF A OF ." A " ENDOF B
OF ." AB " ENDOF C OF ." MOV " ENDOF D OF ." MOVB " ENDOF E
OF ." SOC " ENDOF F OF ." SOCB " ENDOF ENDCASE ;
: FM9 DUP 100 / 4 / CASE B OF ." XOP " ENDOF E OF ." MPY "
ENDOF F OF ." DIV " ENDOF ENDCASE ;
-->
( FORTH DISASSEMBLER V1.1 PG2 )
: FM2 DUP 100 / CASE 10 OF DUP
1000 = IF ." NOP " ELSE ." JMP "
THEN ENDOF 11 OF ." JLT " ENDOF 12 OF ." JLE " ENDOF
13 OF ." JEQ " ENDOF 14 OF ." JHE " ENDOF 15 OF ." JGT "
ENDOF 16 OF ." JNE " ENDOF 17 OF ." JNC " ENDOF 18 OF
." JOC " ENDOF 19 OF ." JNO " ENDOF 1A OF ." JL " ENDOF
1B OF ." JH " ENDOF 1C OF ." JOP " ENDOF 1D OF ." SBO "
ENDOF 1E OF ." SBZ " ENDOF 1F OF ." TB " ENDOF ENDCASE ;
: FM4 DUP 100 / 4 / CASE C OF ." LDCR " ENDOF D OF ." STCR "
ENDOF ENDCASE ;
: FM5 DUP 100 / CASE 8 OF ." SRA " ENDOF 9 OF ." SRL " ENDOF A
OF ." SLA " ENDOF B OF ." SRC " ENDOF ENDCASE ;
: FM7 DUP 10 / 2 / CASE 1A OF ." IDLE " ENDOF 1B OF ." RSET "
ENDOF 1C OF ." RTWP " ENDOF 1D OF ." CKON " ENDOF 1E OF
." CKOF " ENDOF 1F OF ." LREX " ENDOF ENDCASE ; -->
( FORTH DISASSEMBLER V1.1 PG3 )
: FM6 DUP 10 / 4 / CASE 10 OF ." BLWP " ENDOF 11 OF ." B "
ENDOF 12 OF ." X " ENDOF 13 OF
." CLR " ENDOF 14 OF ." NEG " ENDOF 15 OF ." INV " ENDOF 16
OF ." INC " ENDOF 17 OF ." INCT " ENDOF 18 OF ." DEC " ENDOF
19 OF ." DECI " ENDOF 1A OF ." BL " ENDOF 1B OF ." SWPB "
ENDOF 1C OF ." SETO " ENDOF 1D OF ." ABS " ENDOF ENDCASE ;
: FM8 DUP 10 / 2 / CASE 10 OF ." LI " ENDOF 11 OF
." AI " ENDOF 12 OF ." ANDI " ENDOF 13 OF ." ORI " ENDOF
14 OF ." CI " ENDOF 15 OF ." STWP " ENDOF 16 OF ." STST "
ENDOF 17 OF ." LWPI " ENDOF 18 OF ." LIMI " ENDOF ENDCASE ;
: FM3 DUP 100 / 4 / CASE 8 OF ." COC " ENDOF 9 OF ." CZC "
ENDOF A OF ." XOR " ENDOF ENDCASE ;
-->
( FORTH DISASSEMBLER V1.1 PG4 )
: (DASSM) ( HEX FORMAT --- OPCODE/OPERAND ) CASE 0 OF ." ---- "
ENDOF 1 OF FM1 ENDOF 2 OF FM2 ENDOF 3 OF FM3 ENDOF 4
OF FM4 ENDOF 5 OF FM5 ENDOF 6 OF FM6 ENDOF 7 OF FM7 ENDOF 8 OF
FM8 ENDOF 9 OF FM9 ENDOF ENDCASE DROP ;
: TXT DUP 20 < IF ." ." DROP ELSE DUP 7E > IF ." ." DROP ELSE
EMIT THEN THEN ;
: (TEXT) ( HEX --- ) 100 /MOD TXT TXT ;
: DASSM ( LOW HIGH --- ) BASE @ >R CLS 0 0 GOTOXY
." ADDR DATA TX OPCODE/OPERAND"
CR 28 SCRN_START ! 2+ SWAP HEX DO I DUP 4 U.R SPACE @ DUP DUP
DUP 4 U.R SPACE (TEXT) SPACE FORMAT (DASSM) CR PAUSE IF
LEAVE THEN 2 +LOOP 0 SCRN_START ! R> BASE ! ;
R->BASE
( FORTH DISASSEMBLER VERSION 1.2 NETWORK-99 NEWSLETTER 1#5 )
0 VARIABLE M 270 ALLOT
M !" LI AI ANDIORI CI STWPSTSTLWPILIMIIDLERSETRTWPCKONCKOF
LREXBLWPB X CLR NEG INV INC INCTDEC DECTBL SWPBSETOABS SRA
SRL SLA SRC JMP JLT JLE JEQ JHE JGT JNE JNC JOC JNO JL JH JOP
SBO SBZ TB COC CZC XOR XOP LDCRSTCRMPY DIV SZC SZCBS SB C
" M 248 + !" CB A AB MOV MOVBSOC SOCB"
: MNEM 4 * M + 4 TYPE SPACE ;
HEX 00 VARIABLE OP 00 , 200 , 220 , 240 , 260 , 280 , 2A0 , 2C0
, 2E0 , 300 , 340 , 360 , 380 , 3A0 , 3C0 , 400 , 440 ,
480 , 4C0 , 500 , 540 , 580 , 5C0 , 600 , 640 , 680 , 6C0 ,
700 , 740 , 800 , 900 , A00 , B00 , 1000 , 1100 , 1200 , 1300 ,
1400 , 1500 , 1600 , 1700 , 1800 , 1900 , 1A00 , 1B00 , 1C00 ,
1D00 , 1E00 , 1F00 , 2000 , 2400 , 2800 , 2C00 , 3000 , 3400 ,
3800 , 3C00 , 4000 , 5000 , 6000 , 7000 , 8000 , 9000 , A000 ,
B000 , C000 , D000 , E000 , F000 , DECIMAL BASE->R -->
: D< DMINUS D+ SWAP DROP 0< ; 0 VARIABLE LOW 0 VARIABLE HIGH
: 2DUP OVER OVER ;
: (MNM) ( DATA --- INDX ) 68 0 DO 2DUP I 2 * 4 + OP + @ 0 D< IF
I LEAVE ELSE I 67 = IF 68 LEAVE THEN THEN LOOP ;
: MNM ( DATA --- ) 0 (MNM) DUP 0= IF ." ----" DROP ELSE 1-
MNEM THEN DROP DROP ; HEX
: TXT DUP 20 < IF ." ." DROP ELSE DUP 7E > IF ." ." DROP ELSE
EMIT THEN THEN ;
: (TEXT) ( HEX --- ) 100 /MOD TXT TXT ;
: (DASSM) ( ADDR --- ) DUP 4 U.R SPACE @ DUP DUP 4 U.R SPACE
(TEXT) SPACE MNM CR ;
: DASSM ( LOW HIGH --- ) HIGH ! LOW ! BASE @ >R CLS 0 0 GOTOXY
." ADDR DATA TX MNM OPERANDS" CR 28 SCRN_START !
HEX BEGIN LOW @ (DASSM) PAUSE IF HIGH @ LOW ! THEN 2 LOW +!
HIGH @ 0 LOW @ 0 D< UNTIL 0 SCRN_START ! R> BASE ! ;
( END VERSION 1.2 NETWORK-99 NEWSLETTER 1#5 ) R->BASE
Download complete. Turn off Capture File.