
Hello my friend,
Enclosed is a DISassembler I made from scratch,
 & some supporting programs listed below.

If you didn't unzip DIS.ZIP it to it's directory listings, try this.bat
from the c: root directory to make c:\dis\*.*
Then the path to the files match the .bat files enclosed.

@echo off
md dis
PKUNZIP -e -d -Jhrs dis.ZIP

DIS.com is 286 .com file disassembler for Fasm, that does some 386 code.
Designed so FASM reassembles the outfile immediately,
to exactly the same bytes, & it works like that quite often.
Else, some fixing is required and the EOL info below assists with that.

I suspect it will be a great tool for sizeCODERs, 256 byte contests, etc.
I made it to look at how the first computer programs were made in 1983.

So, Lets get it to do something useful.

DISassemble DISn.com using this command line string,
DIS DISn
& rename the  DISn.DIS  file to  zDISn.asm  then assemble it with FASM.
Compare the original file to the new file, byte for byte, like this: fc.exe
 FC DISn.com zDISn.com		;= same then
FCC DISn.com zDISn.com		;shows it's identical.(using my file CMP prog)
reports an exact copy of the original DISn.com & it's a miracle.
 (That it even works:) if you want to test multi outFILEs, do DIS
DIS DIS
rename DIS.DIS to xDIS.asm then FASM assembles the .asm
Each file includes the next file on the last line of the file.
Each file is about 28,000 bytes each so NC.exe can edit them.
That default size can be altered by editing DIS.com
FCV DIS.com xDIS.com
FCV File Compare Visual, shows the differences.
 F7 FIND gives an address that matches the .dis L####: labels. +100h

DIS.com is a handy little tool 4me. Instead of FC.exe finding the difference,
I DIS both .COM files & use FCV.com to FIND & see the .DIS file differences.
The FCV insert/delete keys finds the next difference in both files at the same
time, and shows it to you.
But to get DIS.com to be a great tool for you,
 you'll need a working understanding of it.
I have a quickie info readme.txt below. You may want to skim it,
go play with tools, & come back to reread this
 until you have working knowledge.
DIS.com has syntax help, type DIS
enter and press any key to get the next help page. ESC exits.
The source code has comments 4a better understanding?

WARNING, before you put a lot of time into fixing a.dis file
decide if you should first. To get a real usable .asm file
all the address have to be correct LABEL: type stuff.
 ALSO, DIS.com dumps out a lot of data quickly
and it will fill your hard drive full of crap you never use.
 So delete .dis files quickly knowing that you can always DIS it later.

Most all of my .com programs, can be viewed like a help file in an editor.
If there is no input, it gives you a syntax message.
Which most always says: PROGram inFile outName

Look in zDISn.asm or any DIS.com outFILE.DIS and you will find that
DIS.com can't tell the difference between an immediate # and a Label
since they both are numbers. So [$BABE] hex# can be changed to [LBABE]
then find and drop the Label for it. Once you have all the Labels working
you can alter the size by adding or removing code.  But without the
Labels working you can alter the code without changing size.
Like changing colors or KEY BOARD INPUT.
Think of it as a HEX dump that shows you the insructions,  code, & beyond.
Some times I, hijack 3 bytes to insert: JMP 2EOF
code I wrote, which does what i want, then does the 3 byte code I removed,
& jumps back. CALL EOF works also.

DIS.com EOL info starts at ;p### and ends with a Label for the NEXT LINE.
There are 2 characters in front of LABEL that can be changed to CRLF
& that drops it to the beginning of the next line where it's suspose to be.
(& that is how the label dropper works in DIS.com)
The Label hex # is it's exact location into the file, +100h .com file stuff.
So you always have a referance as to where code is. (4 labels, patch code,?)
FCV find difference gives an address to referance the Labels.

Each Line has an OP p###, a HEX dump, a character dump, & an address Label.
Which should be all the info you need to make a.DIS file assemble & work.

DIS.com does one line at a time, then checks buffers, so the last line
often has data disassembled as if it was an instruction.
That data wasn't in the original .com file.
Edit it out, so the .ASM doesn't make the extra chars.
This OOPs means that DIS.com doesn't have to ask, "AM I THERE YET"
after every byte processed to End Of inFILE.
So DIS.com is a lot smaller, faster, & simpler that way,
but you have a bit of editing to do sometimes.

I made DIS.com for me, and it appears good enough to share.
So it's a work in progress, that still has some BUGs.
My comments are left in, so I can pick up fixing where i left off,
after I've forgotten most everything about it.
So they probably don't make any sense to you, UNTIL you follow the code,
then they make some sense, & that's how I do it.

A correct comment, is wrong when the code get changed,
but the comment is not updated. There is a lot of that, but
it's a work in progress and it gets fixed, when it gets fixed,
but not before ;)  So you can expect some incorrect comments & beyond.
Most people strip the comments or just don't post the source code is easier,
and they don't look so stupid.  I'm comfortable with what I am.
But I did try to clean it up a little for you.

Most programs have input switches, but DIS.com uses an alterable DEFAULT MENU.
Load DIS.com into an editor and you can see your choices.
Get it set the way you like, and you don't need to remember a dozen switches
ever time you go to use it.  Then I make 2 copies,
one with, TEXT =on &
one with, tEXT =off.
So I can use the off version as a PATCH CODE source2 fix the TEXT =on version.
Future versions will have input switchs that over ride default settings.
Some of the DEFAULT options were put in for debugging or old versions that
don't exist anymore.  IT IS A WORK IN PROGRESS. The important defaults are:
decimal, TEXT, UPPER, & sPACE.

Keep in mind, that I made this for me, and I'm sharing.
This isn't a professional disassembler designed to make money.
If it's broke, FIX IT, & send me a copy :)

The Decimal Dump default option screws up on BIG inFILEs like: DIS DIS.com
 fails to reassemble. (It's got a BUG I haven't found yet.)
Find BIG BUFFERS (times DB ?) code is off by one some times,
 I tried it every different way & it always finds a way to be off by 1.
 So if outFILE.asm doesn't assemble to the EXACT SAME CODE,
 string search for TIMES and you probably have the offender in sight.

An .asm assembled with FASM & run through DIS.com will have code/sizeDIF
Decimal Dumps, but most are not needed, & can be removed & still FCC = same.
They are there to cover the OOPs from other assemblers that stop FCC = same.
Since getting FCC = same is the first needed step, they must be left in, or
finding & fixing the DIF Lines manually, = WORK & stops quick progress.
As DIS.com evolves, I could probably remove or change, some of them.
So after a DIS, "if it's a keeper", I will try bypassing some DIFF DDumps,
to see if FCC = same?  Which shows it was a FASM assemble job or not, if
it assembles to be FCC identical.

I don't use lot of instructions or assemblers,
 so I'm not good enough to get everything right.
If you find an oops or make a fix you should share it in the FASM DOS forum
 where DIS.com was posted so we can enjoy the improvements also.
Just post the altered files in a zip &
 we can FCV.com see the improvements our selves.
I started to add 386 code and found that many of the instruction conflict
 with 286 code, so i kinda left DIS.com a 286 tool, (for sizeCODErs)
 that does some commonly used 386 codes, that don't conflict with 286 codes.

Note, in FCV.asm [BITs] bit 6 can be changed to 0 and the current page will
be left on the screen for SG.com Screen Grabber to write to an outFile.
Makes it easy to grab code, edit & DIS.com it.

DIS.com input is a bit forgiving.
 If extension is omitted .com is added.
 if there is a space after the file name, it's removed.
Norton Commander by John Socha CTRL+J or ^+enter key
 will copy paste the highlighted name into the command line,
 if the cursor has a space infront of it & then it leaves a space after it.

The DIS.asm code idea was:
 Use jump tables to have a PROC for every instruction possible. 0-255
 That way each instruction can be tailor made to output what you want,
 AND you can add any instruction at any time, in any way.
 So if others invent new code, you can update DIS.com to pick it apart.
 Meaning, no one can do secret crap, without being exposed.

The dumb looking programming style of duplicate code that many will reject
 is actually VERY FAST assembly language and it is not very big,
 AND 1/3? of DIS.com size is extra help text.  THEN,
 when was the last time you got a FREE disassembler that would reassemble
 with Fasm immediately to EXACTLY THE SAME BYTEs ?  When would that be?
 So maybe DIS.com is not so dumb after all.

if DIS.com dumps out gibberish code with lots of mt_OP + illegal messages,
it's probably 386 code and you should use Candyman's QDD32.exe found in
the FASM DOS forum.  Run the outFILE through DISn.com to get the same
format as DIS.com outFILES.  They can be used as patch code to fix each other
.ASMs by lineing up the EOL LABELS & copy/paste using E16.com by Douglas Herr
which Loads 2 Large files, & SWAPS them to view/edit copy/paste.
DIS.com has text and big buffers for QDD32.exe out files, and
QDD32.exe has 386 code for DIS.com out files.

Other gibberish versions could be a letter to Gramma ran through DIS.com
with text turned off, then EOL info stripped away with DDISS.com & sent as
a decrypted file.  Put the .50 cents under the garbage can or your cat will
get a bad hair cut. (Would be the message you get after assembly ;-)

I wanted to look into the first programs made for the x86 platform and
DIS is DAT thing DAT do DIS 4 me.
I couldn't get any one else's free crap to assemble anything, EVER.

x86 OP code processed by DIS.com follows the following rules:
First byte is OPcode 0=255 used to index a PROC address jump table,
then jumps to the PROC that writes the line,
Many are one byte, one word, type instructions, that just get printed,
using LINEs.inc 0-255 pre_written lines addressed by an adr jump table also.

The PROC recieves, SI aimed at the pre_written instruction, &
 DL = the OP code BYTE, & the following byte in
 DH = the extension code BYTE,
which supplys info needed to process complicated instructions.
It breaks down to bits 76 gives 0-3 = 4 types of 64 each.  64*4=256
bits 543 = 0-7 as does bits 210 = 0-7 = 8 each
so there are 8 different REGs in 3 different strings, (AX-DI AL-BH ES-GS)
& those #s choose which ones get printed on the line. (word, byte, seg  )
It is not much more complicated than that. But,

there is bit 0  in the OPcode byte indicates a WORD or a BYTE instruction.
and bit 1 indicates direction, src,dest or dest,src get bits 543,210
but, i didn't bother to use bit 1.

6 bytes max per line is what I've found to be basically true ?
i tried to stick to output that was EXACTLY LIKE the input.
So REP is a prefix, but it is also a seperate instruction,
so it gets it's own line, as do other prefixes CS: DS: ES: GS: FS:
386 = 0x66, or Dword over_ride = 0x67, or WAIT for FPU, & beyond?
it makes it easier to understand, when its shown to be how it actually is,
& I can program the same way if I want.
It is what it is, get over it. (i keep telling myself)

I find myself using a double DIS a lot, instead of FC.exe on .COM files.
DIS both .COM files, then FCV.com checks both .DIS files.
You get to see exactly what the differances are and where.
The DIS is quick, they delete quick, and i'm moving on.
To check the truth of that, make a renamed copy of a.com
and edit/add a byte at the beginning, then DIS both.com files.
 FC ORG.com NEW.com	;reports the 1 byte difference on every line, in HEX.
FCC ORG.com NEW.com	;reports DIFF, chars show offset, page1 stays visable.
FCV ORG.com NEW.com	;show the DIFF, then you adjust the offset,
& the DELETE key searches to EOF to show they are the same.
That is so much better.

I'm old and just about dead, so here is the source code,
and you can take it from here.

i threw in some of the programs that i use along with DIS.com
to help make it all happen for you also.
They all get an inFILE, alter it, & write it to outFILE.
Which gives you a backup as your file evolves to be what you wanted.

DIS.COM		DISassembler for FASM
DDISS.COM	DIS.com outFILE stripper
DDUMP.COM	Decimal Dump makes code patches for DIS.com outFILEs
DISN.COM	Converts NASM & Candyman's QDD32 outFILEs to .DIS type files.
FCOPY.COM	Copys the exact code of many files to one outFILE
FCV.COM		Visual File Compare 2 FILEs to find/see the differance.
README.TXT	Ramblings of an old man.
ST2.COM		Toggles .asm files FPU instructions ST# to ST(#) & back.

\SRC\*.com	More programs +src code in support of DIS package here.
ASMSPACE ;changes bloatware.asm code to a TABed outfile & cleans up EOL.
BDUMP	; a 4 byte Binary dump line, has a 4 byte Decimal dump after it.
	; Useful for making small bit maps from raw code, as patch code.
DDUMP	; Decimal Dump 16 bytes per Line. FASM assembles.
DELCOL	; DELete COLumns in a file.
FCC	; File Compare +Characters. Shows 1 page of errors or > all2file.txt
FDTGET	; GET File Date & Time > to a file.bat you can alter.
FDTSET	; file.bat resets the Date & Time
MATH	; Does simple word size math, input & output = hex binary decimal
PALSTD	; Restores the standard 256 RGB color palette. sizeCODE screws it up.
PREFIX	; Attach a prefix to every Line of inFile & write it to outFile.
SUFFIX	; Attach a suffix to every Line of inFile & write it to outFile.
REGS	; Shows the REGister values at the start of REGS.com (4 SizeCoders)
SG	; Screen Grabber, saves Vmode3 Page0 to an outFile. Use with FCV.com
SORTB	; My Bubble sorter.
SORTI	; My Insert sorter, & it's fast.
SSTR	; Finds "string" in any file in the directory.
STR	; String search a DIR /B C:\*.* > DIR.TXT to find files instantly.
STRNOT	; Removes Lines that have string in it. remove NOP Lines from.dis files
STRDEL	; Removes a string in any line. Removes OFFSET PTR from Tasm code.
STRPUT	; Adds a String to inFile every where you put a ~ unique character.
TO	; Convert TO values, char,dec,hex,bin of any input type byte/word.
TTYPE	; Types a file to outFile & replaces %1 - %9 with input word, 1-9.

PNUM.bat ;Makes an .asm file that has an incremented EXTension code byte in
	;binary. NOP filler follows. It is the system I used to find OPcode
	;names & values. A p### assembled shows every possible instruction
	;when p###.com is run through DEBUG.exe nDISasm.exe QDD32.exe
	;or debuggers like insight.com or TD.exe
That is how I find out what is what and who is wrong again.
Debug.exe has no FPU code.  They all dump out ESC as an instruction, but
there is no ESC instruction. Even Intel wasn't right all the time,
is about what I've discovered.

Some of these programs had last minute alterations that went un_tested
so I expect some mistakes.  Report them & I'll fix it.

PS, i would appreciate it if you didn't shit on my post again.
if you have a problem with me, or anything I'm doing, please
PM Private Message me on the FASM DOS forum & I will try to make it right.

Note, I am no more responsible for what my government does than you are yours.
I can't control my government, any more than you can control your government.
If people around the world work together toward common & worth while goals,
we would all be better off.  So I'm not willing to fight the Russian/Ukraine
war here with those who don't like Americans. Control thy self or no one will.
People who live free can help you become free, for your own good,
 don't destroy them. People who are not free, can help you become like them.

Now that has been said, ALL MY SOFTWARE comes with one restriction:
You are not authorized to use my software in any way shape or form,
with bad intent.  First do no harm, is the basic civility rule.

Other wise, it's free ware dude......

You should, do unto others, NOTHING,
 without their concent. Because,
the world is only as harsh + as cruel as we choose to make it on our selves,
 + normal living of course.

I hope this package helps some one, some where, some how.

Sincerely, Bitdog for you my friend.

PS #2, disassemblers have been out since DEBUG.EXE in 1983
 So I expect that my software will be disassembled & exposed, at will,
  by others, and I'm not going to get upset about it.
   I suggest that you do the same.

PS #3, this old DOS style code is almost useless without an old DOS computer
and they are few and far between.  But one can run this stuff in a DOS BOX
and port the code they like to their favorite OS or their program,
it's freeware dude.  I pass it on cuz I won't live forever, & now it's yours
to carry the torch.

I did garbage dump salvaging for 30 years.
Companys would throw out all their computers every 5 years and upgrade.
I would get 10 computers at a time, for free. Many dual core. Even an Icore7.
My friend went to buisness machine school and was trained to build computers.
I learned what I could onLine & he would answer my questions when I was stuck.
I got so I could build a usable computer every evening, as a hobby.
I gave away 30+ internet computers to friends & the needy,
and got a lifetime supply of DOS computers.
So I kinda live in a different world than others do.
I have a life time supply of the worlds best DOS computers. 3.2 ghz Northwoods.
I can program in a DOS environment for any OS, &
test it on another computer booted to a DVD,
without the blue screen of death affecting my ANYTHING.
Modern virus crap doesn't affect my system.

I will get FREE_DOS next and try to port my stuff over there.
It seems to be a good OS for size coders who make the 256byte.com miracles.

If you have a problem with me, or anything I'm doing,
figgure out what that is, remove the cuss words and Email me at,
bitdog2u@gmail.com
like problem solving adults do,
or you can PM Private Message Bitdog at the flatassembler forum,
 & I will try to get a reasonable solution for us.

If you have constructive critism or any improvements, suggestions, Email me.
Post questions & yack at the fasm DOS forum. flatassembler.com

