6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Sep 22, 2024 11:28 am

All times are UTC




Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
PostPosted: Thu Oct 22, 2020 4:11 am 
Offline
User avatar

Joined: Mon May 12, 2014 6:18 pm
Posts: 365
Quote:
I currently do not allow bracketed expressions as the operand for indirect addressing, as it would be very confusing to distinguish between
Quote:
The C32 assembler I use uses { and } for grouping things.
The way I solved this was to do pattern matching before evaluation. The pattern is formed by leaving any top level parenthesis in place and marking anything that is a lower level parenthesis or part of an expression with a *. For example:

LDA foo,Y => LDA *,Y
LDA foo+bar,Y => LDA *,Y
LDA (foo+bar)+baz,Y => LDA (*)*,Y
LDA (foo+bar),Y => LDA (*),Y
LDA (foo+(bar+(baz))),Y => LDA (*),Y

Since the last two match the "(*),Y" pattern, I know they are indirect addressing. Since the others don't match any of the patterns I'm looking for, it's safe to assume they are not indirect even though they have parenthesis. This solves the problem with JMP direct/indirect and doesn't require { and }.


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 22, 2020 10:22 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
In my assembler I check for parantheses that are part of the addressing mode before attempting to evalulate the expression. You can use unary plus to force the parentheses to be part of the expression like this:
Code:
00:0000' 6C????            :         JMP     (LABA+6)
00:0003' 4C????            :         JMP     +(LABA+6)

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 26, 2020 8:43 pm 
Offline

Joined: Mon May 01, 2017 7:13 am
Posts: 83
Personally, I've never understood the need to redesign assembler syntaxes. Every programmer seems to feel the need to design a novel syntax, instead of learning the previous. So there is a different assembly syntax for everyone who's written an assembler.

Personally, instead of writing yet another novel one, I'd suggest focusing on making your assembler accept as many existing formats as you can. Interoperability is a huge barrier to adoption.


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 27, 2020 2:06 am 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 890
BigEd wrote:
But but but, can I go right against the flow and the probable consensus here? I came across the assembler syntax used by Acorn back in the day, and it's unusual but I think it just might be great.


To go even more against the flow and the probable consensus here, I prefer the assembler syntax introduced by Bill Ragsdale, with enhancements, even for stand alone assembly language programs.
That said, I would agree with drogon. It's your assembler, use a syntax you're most comfortable with. I wouldn't be too concerned with supporting the syntax of other assemblers, or adoption of your assembler, just yet. I recommend honing your assembler, make it most useful for you.
I would definitely read Garth Wilson's list of requests for assembler writers but balance that with what YOU want from your assembler.
You can always add support for the syntax of other assemblers as time and inclination allow.


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 27, 2020 5:00 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
johnwbyrd wrote:
Personally, I've never understood the need to redesign assembler syntaxes. Every programmer seems to feel the need to design a novel syntax, instead of learning the previous. So there is a different assembly syntax for everyone who's written an assembler.

Personally, instead of writing yet another novel one, I'd suggest focusing on making your assembler accept as many existing formats as you can. Interoperability is a huge barrier to adoption.

I have to agree with you. I too fail to understand the compulsion to mess around with language syntax and create yet another assembler that no one will use because of source code incompatibility. Just imagine if other languages were like this. Imagine what C or FORTRAN or COBOL would have been like if everyone who wrote a compiler decided to come up with a new language syntax.

What is wrong with sticking to the MOS Technology 6502 assembly language standard under which countless millions of lines of code were written? As someone once noted, "Standards are so important everyone must have one." That's what is being promoted when yet another assembler with a strange syntax comes into being.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 27, 2020 6:04 am 
Offline
User avatar

Joined: Wed Jul 01, 2020 6:15 pm
Posts: 79
Location: Germany
Druzyek wrote:
LDA (foo+bar)+baz,Y => LDA (*)*,Y
I understand your other examples, but I don't get this one.
Which addressing mode do you mean there?


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 27, 2020 7:23 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
(Sometimes one of us will find a project holds no great interest, or find we can't agree with the motivation or with the destination: in such cases it's best not to comment. It will be a matter of taste, and the conversation flows better if it's left to those people who do find it interesting. If that turns out to be no-one, so be it - but that's rarely the case.)


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 27, 2020 8:10 am 
Offline
User avatar

Joined: Wed Jul 01, 2020 6:15 pm
Posts: 79
Location: Germany
BigEd wrote:
(Sometimes one of us will find a project holds no great interest, or find we can't agree with the motivation or with the destination: in such cases it's best not to comment. It will be a matter of taste, and the conversation flows better if it's left to those people who do find it interesting. If that turns out to be no-one, so be it - but that's rarely the case.)
Hmm... Not sure whether you were referring to my post just above? While I am indeed not planning to write an assembler anytime soon, I am genuinely interested in the syntax question I asked, and was wondering whether there maybe is an undocumented addressing mode for the 6502. If it's a stupid question, could someone help me out anyway please?


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 27, 2020 8:15 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
No, your query was not one of the remarks which prompted my comment. Sorry for the ambiguity.


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 30, 2020 12:29 am 
Offline

Joined: Mon May 01, 2017 7:13 am
Posts: 83
BigEd wrote:
(Sometimes one of us will find a project holds no great interest, or find we can't agree with the motivation or with the destination: in such cases it's best not to comment. It will be a matter of taste, and the conversation flows better if it's left to those people who do find it interesting. If that turns out to be no-one, so be it - but that's rarely the case.)


Then let me restate as some questions.

Who are you writing this assembler for? Yourself, or for others?

If for others, then which others?

If for yourself, are you writing it for fun or for a specific use?


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 30, 2020 8:53 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
I think the landscape of 6502 assembler syntax is quite varied - maybe no more so than, say, the landscape of z80 assemblers, but I don't know much about that. I think my preference is for the approach taken by ca65, the assembler in the cc65 package, which allows various options, for example about how labels should be done. But even so, I don't suppose anyone would try to construct a universal assembler, with all possible variations supported - so it's bound to be the case that someone's preference won't be satisfied.

However, it seems like a good idea to canvas which ideas are out there, and see how they appeal to one's own sensibilities. It's not possible to judge popularity from a straw poll, and you will get some idea of strength of feeling, but of course that doesn't always coincide with one's own judgement.


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 30, 2020 12:59 pm 
Offline
User avatar

Joined: Mon May 12, 2014 6:18 pm
Posts: 365
65f02 wrote:
Druzyek wrote:
LDA (foo+bar)+baz,Y => LDA (*)*,Y
I understand your other examples, but I don't get this one.
Which addressing mode do you mean there?
There is no addressing mode like that, so the assembler knows that this will be a direct instead of an indirect mode since it doesn't match "(*),Y". Any arbitrary pattern that doesn't match the ones the assembler knows is assumed to be a direct address. It's safe to assume that "LDA (*)*(*)*(*)*(*),Y" for example is direct addressing since it also doesn't match any patterns.

Quote:
(Sometimes one of us will find a project holds no great interest, or find we can't agree with the motivation or with the destination: in such cases it's best not to comment. It will be a matter of taste, and the conversation flows better if it's left to those people who do find it interesting. If that turns out to be no-one, so be it - but that's rarely the case.)
I really disagree with you there. If I had started this thread, it would be a disservice to let me spend months of time on a project without letting me know the downside of inventing my own syntax. It's not obvious at the outset that it's probably a bad idea. I think it's helpful to warn people of the pitfalls. They'll either appreciate the heads up or take it in stride and go ahead with their project anyway, which is fine if they understand what they're getting into. Holding back negative but potentially useful criticism for someone asking for opinions is not helpful.


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 30, 2020 9:33 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
BigEd wrote:
(Sometimes one of us will find a project holds no great interest, or find we can't agree with the motivation or with the destination: in such cases it's best not to comment. It will be a matter of taste, and the conversation flows better if it's left to those people who do find it interesting. If that turns out to be no-one, so be it - but that's rarely the case.)

A deceased member of our model railroad club, who was a retired aerospace engineer, once opined you know you've got a good design when no one can shoot any holes in it (an interesting observation, given what he and his colleagues were designing). So contrary to your opinion, failure to speak up when a flaw in reasoning or execution is noted is doing a disservice.

As for interest, clearly anyone reading this topic and commenting has some interest. I'm sorry if you have a problem with comments made by those who disagree with the premise put forth by the OP of this topic, but that's how open forums work.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 31, 2020 4:50 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 727
Location: Tokyo, Japan
One of the features I use and value most in the macroassembler AS is named local labels. Any label that starts with a period is considered local to the scope between the two nearest global labels. I find things like JMP .loop and BEQ .exit to be a lot more readable and reliable than using the equivalant + and - local label syntax.

I find this to be orthogonal to larger-scale .proc scoping, which is also quite useful in larger programs.

GARTHWILSON wrote:
Ones that don't use the colon generally require labels to start in column1. I'd say do not require labels to start in column 1.... Using a colon after a label is good practice anyway, even when it's not required, because if you do a search for the label, you can put the colon in the search term and it will take you right to it, rather than wasting your time by first turning up a lot of references to the label.

Actually, that's not an issue where the label must start in column 1 because you can just anchor your search to the beginning of the line. The point about indentation is a reasonable one, though.

As for the whole brouhaha about whether one should ever consider a new assembler syntax, while it's reasonable to point out the downsides of a new syntax, starting out your comment with "I don't understand why someone would..." is saying essentially "I am ignorant as to why someone would...." To me, unless that's preceeding a request for explanation to dispel that ignorance, that comes across as the poster being either unintelligent or too lazy to think about why someone would want to do this. Consider what your reaction would be to, "I don't understand why in this day and age someone would design a new system based around a 6502 processor."

_________________
Curt J. Sampson - github.com/0cjs


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 31, 2020 9:13 am 
Offline

Joined: Tue Sep 03, 2002 12:58 pm
Posts: 325
cjs wrote:
One of the features I use and value most in the macroassembler AS is named local labels. Any label that starts with a period is considered local to the scope between the two nearest global labels. I find things like JMP .loop and BEQ .exit to be a lot more readable and reliable than using the equivalant + and - local label syntax.

I like that one. For my assembler, I'm toying with the idea of introducing nested scopes, with C-style { } or Pascal-ish .begin and .end. Symbols defined inside a scope are only visible within that scope. But I haven't implemented it yet, and have no experience with how usable (or unusable) it will be. If it doesn't work out, your suggestion is my next best choice. It won't allow nesting, but it's more readable than anything else I've seen.
I might use : instead of . though. Words starting with . are always directives to me.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 43 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: