nesdev.com
http://forums.nesdev.com/

asm6 small patch (forcing ZP address as absolute)
http://forums.nesdev.com/viewtopic.php?f=2&t=17910
Page 1 of 1

Author:  morskoyzmey [ Thu Oct 11, 2018 1:41 pm ]
Post subject:  asm6 small patch (forcing ZP address as absolute)

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.

Author:  tepples [ Thu Oct 11, 2018 1:52 pm ]
Post subject:  Re: asm6 small patch (four-digits ZP address as absolute)

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.

Author:  tokumaru [ Thu Oct 11, 2018 5:23 pm ]
Post subject:  Re: asm6 small patch (four-digit ZP address as absolute)

Too bad this solution doesn't solve the problem for those who use labels, which's probably the vast majority of coders.

Author:  morskoyzmey [ Fri Oct 12, 2018 6:13 am ]
Post subject:  Re: asm6 small patch (four-digit ZP address as absolute)

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?

Author:  gauauu [ Fri Oct 12, 2018 7:11 am ]
Post subject:  Re: asm6 small patch (four-digit ZP address as absolute)

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.

Author:  tepples [ Fri Oct 12, 2018 8:48 am ]
Post subject:  Re: asm6 small patch (four-digit ZP address as absolute)

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?

Author:  tokumaru [ Fri Oct 12, 2018 9:37 am ]
Post subject:  Re: asm6 small patch (four-digit ZP address as absolute)

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.

Author:  koitsu [ Fri Oct 12, 2018 10:37 am ]
Post subject:  Re: asm6 small patch (four-digit ZP address as absolute)

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.

Author:  morskoyzmey [ Fri Oct 12, 2018 1:34 pm ]
Post subject:  Re: asm6 small patch (four-digit ZP address as absolute)

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.

Author:  lidnariq [ Fri Oct 12, 2018 1:50 pm ]
Post subject:  Re: asm6 small patch (four-digit ZP address as absolute)

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);
    }


Author:  morskoyzmey [ Fri Oct 12, 2018 2:18 pm ]
Post subject:  Re: asm6 small patch (four-digit ZP address as absolute)

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.

Author:  morskoyzmey [ Sun Oct 14, 2018 4:27 am ]
Post subject:  Re: asm6 small patch (forcing ZP address as absolute)

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?

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/