Page 1 of 1
asm6 small patch (forcing ZP address as absolute)
Posted: Thu Oct 11, 2018 1:41 pm
by morskoyzmey
Hey
Just wanted to share my asm6 patch
DIFF:
on github
Love this assembler. But I met inconvenient behaviour. For disassembled code, such as:
asm6 generates this:
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.
Re: asm6 small patch (four-digits ZP address as absolute)
Posted: Thu Oct 11, 2018 1:52 pm
by tepples
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.
Re: asm6 small patch (four-digit ZP address as absolute)
Posted: Thu Oct 11, 2018 5:23 pm
by tokumaru
Too bad this solution doesn't solve the problem for those who use labels, which's probably the vast majority of coders.
Re: asm6 small patch (four-digit ZP address as absolute)
Posted: Fri Oct 12, 2018 6:13 am
by morskoyzmey
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?
Re: asm6 small patch (four-digit ZP address as absolute)
Posted: Fri Oct 12, 2018 7:11 am
by gauauu
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.
Re: asm6 small patch (four-digit ZP address as absolute)
Posted: Fri Oct 12, 2018 8:48 am
by tepples
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?
Re: asm6 small patch (four-digit ZP address as absolute)
Posted: Fri Oct 12, 2018 9:37 am
by tokumaru
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.
Re: asm6 small patch (four-digit ZP address as absolute)
Posted: Fri Oct 12, 2018 10:37 am
by koitsu
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.
Re: asm6 small patch (four-digit ZP address as absolute)
Posted: Fri Oct 12, 2018 1:34 pm
by morskoyzmey
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

. 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.
Re: asm6 small patch (four-digit ZP address as absolute)
Posted: Fri Oct 12, 2018 1:50 pm
by lidnariq
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: Select all
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);
}
[/size]
Re: asm6 small patch (four-digit ZP address as absolute)
Posted: Fri Oct 12, 2018 2:18 pm
by morskoyzmey
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: Select all
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);
}
[/size]
But what I supposed to do with that extra marker? To modify asm6 to support it?
BTW I've modified clever-disasm to make its output valid for asm6, except that asm6 understands it in its own way.
Re: asm6 small patch (forcing ZP address as absolute)
Posted: Sun Oct 14, 2018 4:27 am
by morskoyzmey
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?
Re: asm6 small patch (forcing ZP address as absolute)
Posted: Tue Feb 05, 2019 7:42 pm
by koitsu
I just posted a reply on GitHub discussing this subject in detail, covering the syntax variances and similarities of 21 different assemblers WRT this specific ordeal:
https://github.com/freem/asm6f/issues/2 ... -460882018
This is why I disagree with use of asterisk as the character. Let us not make a bigger mess.