6502 Windows-based disassembler

Questions, bug reports, features requests, ... about the Oric Software Development Kit. Please indicate clearly in the title the related element (OSDK for generic questions, PictConv, FilePack, XA, Euphoric, etc...) to make it easy to locate messages.

User avatar
Symoon
Archivist
Posts: 2310
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

6502 Windows-based disassembler

Post by Symoon »

Hi,

For a while, I've been using Sadasm under Windows to disassemble Oric 6502 code. Very easy - all I need is to read the code, and use it as a text file for articles.

But Fabrice detected a bug in it: it translates 6C by a wrong type of JMP instruction. :shock: :cry:

So my question is: who is using a 6502 disassembler under Windows, and which one is it ?

Thanks !
Simon
User avatar
waskol
Flight Lieutenant
Posts: 415
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

hmm, I think I have something for you, I need to search into my files this evening
...
User avatar
waskol
Flight Lieutenant
Posts: 415
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

Yes I found some code in order to build a 6502 disassembler :wink:
I have 3 questions :
1) Do you read your code from a raw binary file or a tap file ?
2) do you need a kind of DATA-->disasm ?
3) instruction 6C should disasm into JMP $(XXXX), that's it ?


:wink:


I can't find Sadasm in order to try it and see what it deals with
mmu_man
Flight Lieutenant
Posts: 322
Joined: Thu Sep 21, 2006 7:45 pm
Location: 26000 Valence, FRANCE
Contact:

Post by mmu_man »

I use da65 in BeOS :P
User avatar
Symoon
Archivist
Posts: 2310
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Post by Symoon »

You will find Sadasm here:
http://mercenarysite.free.fr/oric/sadasm1b.zip

It requires a file that beging with 2 bytes holding the start address, then the data.
I wouldn't mind if there was an option to read from TAP files :p

Here's what Fbrice told about it:
au fait, change de désassembleur... il décode 6C par un JMP absolu,Y au lieu d'un JMP indirect
Example:

Code: Select all

0100  6C 12 34       JMP $3412,Y
And, who knows, maybe other errors ?

Cheers
User avatar
waskol
Flight Lieutenant
Posts: 415
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

OK some good news... :P

My Oric 6502A disassembler is almost finished 8)

For the moment it can disass a machine code program for a tap file, I want to include also :
- Oric rom files
- Euphoric dumps (if I can !!!)
- raw binary files (straight data)
- your files

The only thing, for the sake of simplicity, I limit the use to 64K files max... wich corresponds to the Oric RAM size.

Here is an example of desassembly of a tap (this is the osdk sample called "256 bytes demo) :

Code: Select all

0600: JSR $EC33
0603: LDA #00
0605: LDX #07
0607: STA $02DF, X
060A: DEX
060B: BNE FA
060D: LDA #1A
060F: STA $BFDF
0612: SEI
0613: LDA #00
0615: STA $51
0617: STA $52
0619: LDA #80
061B: STA $53
061D: LDA #BB
061F: STA $54
0621: LDX #1C
0623: LDY #27
0625: LDA $51
0627: BNE 02
0629: LDA #0C
062B: SEC
062C: SBC #03
062E: STA $51
0630: CLC
0631: LDA #40
0633: ADC 51
0635: ADC 52
0637: STA ($53), Y
0639: DEY
063A: BNE E9
063C: STY $51
063E: LDA #04
0640: STA ($53), Y
0642: CLC
0643: LDA $52
0645: ADC #01
0647: CMP #03
0649: BNE 02
064B: LDA #00
064D: STA $52
064F: JSR $06DE
0652: DEX
0653: BNE CE
0655: LDA #01
0657: STA $02E3
065A: LDX $50
065C: INX
065D: TXA
065E: AND #0F
0660: STA $50
0662: LDX #02
0664: STX $51
0666: LDA $06E9, X
0669: STA $0219
066C: STA $021A
066F: LDX $50
0671: INX
0672: STX $02E1
0675: JSR $F37F
0678: LDX $51
067A: DEX
067B: BNE E7
067D: INC $0213
0680: LDA #00
0682: STA $53
0684: LDA #A0
0686: STA $54
0688: LDA #00
068A: STA $57
068C: LDA #B6
068E: STA $58
0690: LDX #04
0692: STX $51
0694: LDX #18
0696: CLC
0697: LDA $53
0699: ADC #C0
069B: STA $55
069D: LDA $54
069F: ADC #03
06A1: STA $56
06A3: LDY #04
06A5: LDA ($53), Y
06A7: ORA ($55), Y
06A9: LDY #00
06AB: ORA ($53), Y
06AD: ORA ($55), Y
06AF: STA ($57), Y
06B1: LDA #40
06B3: STA ($53), Y
06B5: STA ($55), Y
06B7: LDY #04
06B9: STA ($53), Y
06BB: STA ($55), Y
06BD: JSR $06DE
06C0: INC $57
06C2: BNE 02
06C4: INC $58
06C6: DEX
06C7: BNE CD
06C9: CLC
06CA: LDA $53
06CC: ADC #41
06CE: STA $53
06D0: LDA $54
06D2: ADC #FC
06D4: STA $54
06D6: LDX $51
06D8: DEX
06D9: BNE B7
06DB: JMP $065A
06DE: CLC
06DF: LDA $53
06E1: ADC #28
06E3: STA $53
06E5: BCC 02
06E7: INC $54
06E9: RTS
06EA: TSB
06EB: CLC
This seems to be correct but I am not a specialist !
User avatar
waskol
Flight Lieutenant
Posts: 415
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

Argll, no more gas for cooking !!! I must go and buy a bottle... and it's not close to here...

Symoon, you will have to wait a little bit...

give a try with it here :
http://www.steekr.com/index.php?m=c9ae7 ... 2cec3ca67d
User avatar
Symoon
Archivist
Posts: 2310
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Post by Symoon »

This looks like a very nice tool :)
Thanks !

Would it be possible to have the op-codes values between the address and the mnemonic, just like in the line I pasted on a previous post ?
This is important to me because:
1- I'm rather patching existing programs than coding, which means I have to be able to locate the piece of code I'm reading among a hex-edited file
2- I have never really learnt the mnemonics, and it would take me ages to re-translate them into op-codes, or to translate the memory address into the file, to finally find where I have to patch.

I know I'm demanding much ;-)
In the meantime, I'll check Sadasm for other bugs.
User avatar
waskol
Flight Lieutenant
Posts: 415
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

Symoon wrote:This looks like a very nice tool :)
Thanks !

Would it be possible to have the op-codes values between the address and the mnemonic, just like in the line I pasted on a previous post ?
This is important to me because:
1- I'm rather patching existing programs than coding, which means I have to be able to locate the piece of code I'm reading among a hex-edited file
2- I have never really learnt the mnemonics, and it would take me ages to re-translate them into op-codes, or to translate the memory address into the file, to finally find where I have to patch.

I know I'm demanding much ;-)
In the meantime, I'll check Sadasm for other bugs.
Yes I can do it and will do it :wink: :wink:
User avatar
waskol
Flight Lieutenant
Posts: 415
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

hmm, I have ywo questions to assembly specialists.

If you have a look to the output of my dissassembler :

Code: Select all

0605: LDX #07
0607: STA $02DF, X <--1st question here
060A: DEX
060B: BNE FA <-- second question here
And to the original listing :

Code: Select all

loop
	sta $2e0-1,x <--1st question here
	dex 
	bne loop <--2nd question here
    .)
For the first question :
DBug has coded "sta $2e0-1,x" and I obtain "STA $02DF, X"
So, on one hand, I have 0-1 , on the other hand I have DF, and in the "compiled" file the byte value is $DF : is this normal ? where did the 0-1 went ? :shock:

For the second question, just tell me if I understood, is $FA a negative number that equals to -7 ? i.e. a kind of jump to a relative address ?
User avatar
waskol
Flight Lieutenant
Posts: 415
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

Symoon, when you say patching, I understand that you need to edit and modify the file ???

That will be very difficult to me to provide something other than a viewer (you will have to play with a hexeditor hombre !), I mean you will not be able to edit or modify any file.

BUT, the first feature I can propose you, is to have the possibility to have a certain kind of output ... :P

Like this sample :

Code: Select all

1 REM MACHINE CODE DATA
10 DATA #20,#33,#EC:REM JSR $EC33
20 DATA #A9,#00    :REM LDA #00
30 DATA #A2,#07    :REM LDX #07
40 DATA #9D,#DF,#02:REM STA $02DF, X
50 DATA #CA        :REM DEX
60 DATA #D0,#FA     :REM BNE FA
70 FOR I=#0600 TO #060C:READ A:POKE(I,A):NEXT
So that you can recompile and recreate a tap file...

The second feature is to have this kind of output :

Code: Select all

0B3F:0600: 20 33 EC          JSR $EC33
the first value (0B3F) would be the location of the first byte (the byte with value 20) in the file you provided in the disassembler, so that you can locate it very quickly in an hexeditor.

Do you think it's worth it ?
User avatar
Symoon
Archivist
Posts: 2310
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Post by Symoon »

waskol wrote:For the second question, just tell me if I understood, is $FA a negative number that equals to -7 ? i.e. a kind of jump to a relative address ?
Yes, it means "go back 7 bytes before". This value includes the bytes of instruction itself, ie you have to start counting backwards the amount of bytes from the very end of the branch instruction.
Sorry for the rest I'm not specialist enough ;)
User avatar
Symoon
Archivist
Posts: 2310
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Post by Symoon »

Waskol, that's all good news :)
waskol wrote:Symoon, when you say patching, I understand that you need to edit and modify the file ???
Yes but don't worry for that, I'm using a hex editor :).
waskol wrote: Like this sample :

Code: Select all

1 REM MACHINE CODE DATA
10 DATA #20,#33,#EC:REM JSR $EC33
20 DATA #A9,#00    :REM LDA #00
30 DATA #A2,#07    :REM LDX #07
40 DATA #9D,#DF,#02:REM STA $02DF, X
50 DATA #CA        :REM DEX
60 DATA #D0,#FA     :REM BNE FA
70 FOR I=#0600 TO #060C:READ A:POKE(I,A):NEXT
So that you can recompile and recreate a tap file...
Well, for my very personnal use, for the moment, I don't think I need such an option... But I think some may find it very interesting - and maybe including me some day!
waskol wrote:The second feature is to have this kind of output :

Code: Select all

0B3F:0600: 20 33 EC          JSR $EC33
the first value (0B3F) would be the location of the first byte (the byte with value 20) in the file you provided in the disassembler, so that you can locate it very quickly in an hexeditor.

Do you think it's worth it ?
That's very intersting ! Could the 0B3F thing be switchable ?
I mean, I do really find it useful, as sometimes I'm editing multi-part TAP files.
But I'm also using the disassembler to copy/paste code for articles, and the 0B3F thing then might be pointless. It's quite easy to remove with Word or other text editors, but if it can be implemented as an option, then it's even better ;-)
Anyway if I have to choose, go for it with the file position too :)
User avatar
Chema
Game master
Posts: 3020
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema »

waskol wrote:DBug has coded "sta $2e0-1,x" and I obtain "STA $02DF, X"
So, on one hand, I have 0-1 , on the other hand I have DF, and in the "compiled" file the byte value is $DF : is this normal ? where did the 0-1 went ? :shock:
You probably have an answer by now, but what Dbug is doing here is some hex math that is solved by the assembler.

($2eb0) - 1 = $2df

So the assembler directly interprets this as sta $2df,x and generates the code you see...

You can also do this with labels and is a typical way of improvinig performance while accessing tables (adding or substracting fixed quantities to the table start address or label), instead of

Code: Select all

; Access first field
lda table,x

...

; Access second field
inx
lda table,x
You just do

Code: Select all

; Access first field
lda table,x
...
; Access second field
lda table+1,x
Cheers[/code]
User avatar
waskol
Flight Lieutenant
Posts: 415
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

OOOOOOOOOOOOKKKKKKKKKKKKKKKKKKAAAAYYYYYYYYYYYYYY :lol:

$DF=$E0 - 1 , I've been blind... :lol:

I don't know why I was reading it like this :
$2E(0-1) instead of ($2E0)-1 !!!

Estupido que soy !
Post Reply