It is currently Tue Oct 16, 2018 9:58 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Thu Oct 11, 2018 1:41 pm 
Offline
User avatar

Joined: Sat Sep 15, 2018 2:59 pm
Posts: 12
Hey

Just wanted to share my asm6 patch

DIFF: on github

Love this assembler. But I met inconvenient behaviour. For disassembled code, such as:
Code:
sta $0092   ; $E88C:  8D 92 00

asm6 generates this:
Code:
85 92

I read few topics with ideas of new syntax to deal with ZP and absolute addressing, but I'm working with disassembled code and there are many such rows everywhere so...
I thought that it might be useful to someone.


Last edited by morskoyzmey on Sun Oct 14, 2018 4:19 am, edited 4 times in total.

Top
 Profile  
 
PostPosted: Thu Oct 11, 2018 1:52 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20657
Location: NE Indiana, USA (NTSC)
If an assembler already supports an address size prefix, as described for ca65 in the topic you linked, you could patch the disassembler to emit that. I guess the real problem is that ASM6 appears to lack an address size prefix at all, and you're proposing using the number of digits to fill that role. I'll let others weigh in on whether that's a good idea.


Top
 Profile  
 
PostPosted: Thu Oct 11, 2018 5:23 pm 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10892
Location: Rio de Janeiro - Brazil
Too bad this solution doesn't solve the problem for those who use labels, which's probably the vast majority of coders.


Top
 Profile  
 
PostPosted: Fri Oct 12, 2018 6:13 am 
Offline
User avatar

Joined: Sat Sep 15, 2018 2:59 pm
Posts: 12
tokumaru wrote:
Too bad this solution doesn't solve the problem for those who use labels, which's probably the vast majority of coders.

If it's yours code, then why you need to use absolute addressing for ZP?


Top
 Profile  
 
PostPosted: Fri Oct 12, 2018 7:11 am 
Offline
User avatar

Joined: Sat Jan 09, 2016 9:21 pm
Posts: 469
Location: Central Illinois, USA
morskoyzmey wrote:
tokumaru wrote:
Too bad this solution doesn't solve the problem for those who use labels, which's probably the vast majority of coders.

If it's yours code, then why you need to use absolute addressing for ZP?


Usually you wouldn't, but occasionally you want to force it to use the longer or slower addressing modes for timing or spacing tricks.

_________________
My games: http://www.bitethechili.com


Top
 Profile  
 
PostPosted: Fri Oct 12, 2018 8:48 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20657
Location: NE Indiana, USA (NTSC)
Or if you want to be really weird, use the end of zero page contiguously with the start of the stack page, such as $0080-$017F or the like. I seem to remember seeing one demo that did this. Or did it use the end of RAM contiguously with the first mirror of zero page, such as $07C0-$08BF?


Top
 Profile  
 
PostPosted: Fri Oct 12, 2018 9:37 am 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10892
Location: Rio de Janeiro - Brazil
tepples wrote:
Or did it use the end of RAM contiguously with the first mirror of zero page, such as $07C0-$08BF?

That wouldn't have been a problem. I've used mirrors to get around this problem a few times. On the NES, add $800 to access a mirror of ZP, on the Atari 2600, add $100.


Top
 Profile  
 
PostPosted: Fri Oct 12, 2018 10:37 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3629
Location: Mountain View, CA
So important to remember is the fact that the OP did this because the disassembler output a particular syntax that the assembler didn't interpret identically. I will say that I'm disappointed he/she didn't state what disassembler was used -- it matters.

However, I do not believe this is something that should be backported or imported into either official asm6 or forks (ex. asm6f). I'll explain my stance:

I'm making an assumption that this was accomplished based on length (number of characters/bytes representing the address, ex. 4 for $0092). I have to assume this because only the full source code was posted, not a diff, and I can't be arsed to download it and diff it myself.

How this was accomplished on other assemblers was through some form of operator prefix or suffix.

If someone wants to solve this long-term, I urge you -- almost to the point of forcing you -- to read my post in the linked thread. Take the time to look at the manuals of existing commercial assemblers and products. You will find there is generally a "common implementation model" (despite different letters/characters used), and *where* that's implemented also matters (hint: it's not based on operand value/length/size). Tepples in the same thread proposed a different syntax (re: a: prefix). I don't care what is chosen, but it needs to be implemented properly.

As for disassemblers and their output: hopefully everyone is now starting to see why this matters so much. The state of 6502 disassemblers is pretty messy: I've tried several in the past few months and I roll my eyes at pretty much all of them in one way or another -- to the point where I don't even bother reassembling anything (like I usually do) because it's going to be a PITA due to the ridiculous variance of behaviours of each assembler. It wasn't like this in the early and late 90s, for whatever reason. The one I found to be most helpful but also kinda not helpful was disasm6, since it was designed to output code that worked with asm6, but there's annoyances with disasm6 too.


Top
 Profile  
 
PostPosted: Fri Oct 12, 2018 1:34 pm 
Offline
User avatar

Joined: Sat Sep 15, 2018 2:59 pm
Posts: 12
koitsu wrote:
So important to remember is the fact that the OP did this because the disassembler output a particular syntax that the assembler didn't interpret identically. I will say that I'm disappointed he/she didn't state what disassembler was used -- it matters.

He :beer: . I used clever-disasm from nescom-1.2.0.

koitsu wrote:
I'm making an assumption that this was accomplished based on length (number of characters/bytes representing the address, ex. 4 for $0092). I have to assume this because only the full source code was posted, not a diff, and I can't be arsed to download it and diff it myself.

First link in my first post is a link to the diff on github. :)

koitsu wrote:
How this was accomplished on other assemblers was through some form of operator prefix or suffix.

The problem is that disassembler is using such syntax, not another. And for me it looks logic to modify asm6, because I don't see alternatives.

There is a code in ROM 8D 92 00, disassembler produces from it some readable text, and assembler should produce the same code from it. But asm6 can't do it in any way.


Top
 Profile  
 
PostPosted: Fri Oct 12, 2018 1:50 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7648
Location: Seattle
Clever-disasm is meant to be used with xa65 and/or nescom ... of course, it doesn't generate the correct marker for that either ( " lda !$f0 would use 16-bit address instead of direct page. " )

It'd be better to modify clever.cc to have it emit the correct markup instead. Lines 1710-1719:
Code:
    void PrintRAMaddress(unsigned addr, unsigned bytes) const
    {
        auto i = RAMaddressNames.find(addr);
 /* ----> here print extra marker if addr <= 0x100 and bytes == 2 <---- */
        if(i != RAMaddressNames.end())
        {
            printf("%s", i->second.c_str());
            return;
        }
        printf("$%0*X", bytes*2, addr);
    }



Top
 Profile  
 
PostPosted: Fri Oct 12, 2018 2:18 pm 
Offline
User avatar

Joined: Sat Sep 15, 2018 2:59 pm
Posts: 12
lidnariq wrote:
Clever-disasm is meant to be used with xa65 and/or nescom ... of course, it doesn't generate the correct marker for that either ( " lda !$f0 would use 16-bit address instead of direct page. " )

It'd be better to modify clever.cc to have it emit the correct markup instead. Lines 1710-1719:
Code:
    void PrintRAMaddress(unsigned addr, unsigned bytes) const
    {
        auto i = RAMaddressNames.find(addr);
 /* ----> here print extra marker if addr <= 0x100 and bytes == 2 <---- */
        if(i != RAMaddressNames.end())
        {
            printf("%s", i->second.c_str());
            return;
        }
        printf("$%0*X", bytes*2, addr);
    }



But what I supposed to do with that extra marker? To modify asm6 to support it? :D

BTW I've modified clever-disasm to make its output valid for asm6, except that asm6 understands it in its own way.


Top
 Profile  
 
PostPosted: Sun Oct 14, 2018 4:27 am 
Offline
User avatar

Joined: Sat Sep 15, 2018 2:59 pm
Posts: 12
UPDATE.

Added support for " * " prefix as suggested for "!" mark. I didn't come up with another suitable symbol.
As you know "!" is an unary operator in expressions and I have not found a good workaround.
Also @ would be good, but it's for local labels.

Link to latest DIFF

Any suggestions?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group