Quick Disassembler

by Ata Atun

 

Issue 21

May/Jun 86

Next Article >>

<< Prev Article

 

 

When I started to learn Machine Code, I desperately needed a DISASSEMBLER to investigate and study the Machine Code Programs written by the Advanced ATARI users. The only Disassembler program I could find, wasn't a very helpful and detailing one, but I had to manage with it till I reached a certain knowledge level. I then felt I had to design a better and more detailing program, and now I believe that the DISASSEMBLER program below is a very good one for Machine Code beginners and advanced programmers. It is fast and can detail Addressing Modes, and can address the backward and forward branches.

Before running the Program please save it to Disk as "D:DIS.ASM" or to cassette and then RUN it.

Structure of Disassembler Program

A)

Strings and Variables

M$

 

DIMensioned (1024) originating from 255 possibilities in a 6502 Machine Code System Byte. (255*4+4=1024) Adding 4 to multiplication 255*4, is the last 4 locations of 255th place.
LCT$ DIMensioned (256) based on same reason explained above. Since 0th place can not be called in a String, for 255 possibilities LCT$ is DIMensioned to 256 places to be used as LCT$(1,256) instead of LCT$(0,255).
TR$  Transfer String to be used in specific location transfer from M$.
LOC1 Content of Main ADDRESS, 1st location.
LOC2  Content of 2nd location.
LOC3 Content of 3rd location.
LOC4 Used in Branches. Backward branching.
LOC5  Used in Branches. Forward branching.
ADRS Main Address with MNEmonic.

B)

Contents of Strings

M$

 

Consisted of 255 main MNEmonics, each 4 locations long. First 3 locations hold the Mnemonic. 4th location classifies the Mnemonic.

"#" Immediate
" " (Void) Absolute or Zero Page

"a" Absolute or Zero Page
"b" Absolute,Y
"c" (indirect,X)
"d" (Indirect),Y

 

LCT$

 

Total of 256 codes that classifies each Addressing mode in detail, separates Absolute and Zero Page, branching Mnemonics, Implied and Relative addresses.

"1" 1 byte long, Implied or Relative
"2" 2 bytes long, Zero Page
"3" 3 bytes long, Absolute.
"4" Branchers, 1 byte long, Relative.
"5" No MNEmonic, 1 byte long.
"6" JMP (Arg), Implied, 1 byte long, location 108 only.

Combination of M$ and LCT$ specifies Addressing Mode very clearly. For example: Void " " in 4th place of M$ with 2 code in LCT$, specifies a ZERO PAGE, 2 BYTE LONG ADDRESSING MODE.

How The Program Flows

Up to 130 DIMensioning, Opening a Channel and text Graphic plus screen and border colour.
GOSUB 800 This section holds M$ and LCT$. I could keep these values in DATA and use READ-DATA-POKE combination but this routine is boring when you hurry for a quick start
130-200 Head line, start Address, End Address and check address.
200-210  Start of 20 line per screen Disassembling.
220-280 Content of ADRS. Locates exact place in M$. Get the 4 place long string. Get the classifying Code from LCT$ string, exactly the same location. Print address and content of Address.
290 According to the value of TR, GOTO to the matching section.
400-450 1 byte long Mode section. Determines the exact Addressing Mode, Implied or BRK-Implied
450-500 2 byte long Mode section. Determines Zero Page or Absolute.
500-550 3 byte long Mode Section. Determines Absolute or Absolute,X.
550-600 Branching Modes only. Determines forward branch or Backward branch.
600-650  1 byte long but No MNEmonics, abbreviated as "? " in M$ string.
650-700  JMP(Arg), Implied Mode only, which is a special jump.
700-760  Final check and request to continue. If END of address reached, stops the execution.
1000  Gosub section for Determining very quickly the Addressing Modes.

 

top