What assembly syntax is good to support in an assembler?
-
JustClaire
- Posts: 18
- Joined: 27 Feb 2020
What assembly syntax is good to support in an assembler?
Hello
I am currently in the process of making an assembler for the 6502 family and i do have a working in-dev version of it (only 6502 and 65C02 w/o Rockwell as of now tho).
And i am thinking of what syntax to support with it. For example some assemblers use ':' for labels whereas others dont.
What syntax do you think is more popular and does it even matter?
Also, what directives do you think are most useful to have? (apart from obvious things such as macros, labels & simple data)
I am currently in the process of making an assembler for the 6502 family and i do have a working in-dev version of it (only 6502 and 65C02 w/o Rockwell as of now tho).
And i am thinking of what syntax to support with it. For example some assemblers use ':' for labels whereas others dont.
What syntax do you think is more popular and does it even matter?
Also, what directives do you think are most useful to have? (apart from obvious things such as macros, labels & simple data)
Re: What assembly syntax is good to support in an assembler?
JustClaire wrote:
Hello
I am currently in the process of making an assembler for the 6502 family and i do have a working in-dev version of it (only 6502 and 65C02 w/o Rockwell as of now tho).
And i am thinking of what syntax to support with it. For example some assemblers use ':' for labels whereas others dont.
What syntax do you think is more popular and does it even matter?
Also, what directives do you think are most useful to have? (apart from obvious things such as macros, labels & simple data)
I am currently in the process of making an assembler for the 6502 family and i do have a working in-dev version of it (only 6502 and 65C02 w/o Rockwell as of now tho).
And i am thinking of what syntax to support with it. For example some assemblers use ':' for labels whereas others dont.
What syntax do you think is more popular and does it even matter?
Also, what directives do you think are most useful to have? (apart from obvious things such as macros, labels & simple data)
I use as65 from the cc65 suite and my own assembler (a work in progress) is more or less compatible with that.
as65 defaults to needing :'s but there is a flag to make them optional, so it can assemble source designed for a different assembler. (Also see "Postel's Law")
As for directives - conditional assembly and include another file along with the ones you mentioned. I use a 'repeat' construct in some of my code to unwind a loop too, so that's handy for me, but for you? ....
There might be a 'but' or 'however' though and that's if you expect others to use it. That's a hard sell in my book, (e.g. will it run on MS Win, Linux, Mac, C64, X16, my Ruby system, and other comments along those lines are what you'll get), so I'd save yourself the stress and just do it your way.
-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
-
JustClaire
- Posts: 18
- Joined: 27 Feb 2020
Re: What assembly syntax is good to support in an assembler?
drogon wrote:
as65 defaults to needing :'s but there is a flag to make them optional, so it can assemble source designed for a different assembler. (Also see "Postel's Law")
drogon wrote:
As for directives - conditional assembly and include another file along with the ones you mentioned. I use a 'repeat' construct in some of my code to unwind a loop too, so that's handy for me, but for you? ....
There might be a 'but' or 'however' though and that's if you expect others to use it. That's a hard sell in my book, (e.g. will it run on MS Win, Linux, Mac, C64, X16, my Ruby system, and other comments along those lines are what you'll get), so I'd save yourself the stress and just do it your way.
There might be a 'but' or 'however' though and that's if you expect others to use it. That's a hard sell in my book, (e.g. will it run on MS Win, Linux, Mac, C64, X16, my Ruby system, and other comments along those lines are what you'll get), so I'd save yourself the stress and just do it your way.
As for others using it, it is my hobby project but i am going to release it on github when i feel like it is in a presentable form so that if somebody would want to use it that would be nice. Its not my target though, im mostly making it as an exercise.
As for compatibility, i plan for it to be compiled for windows, linux & mac, it wouldn't be compatible with older systems tho because it relies on "modern"-ish C and flex & bison for parsing.
Re: What assembly syntax is good to support in an assembler?
Personally I tend to use ca65, which also has some mode flags for slight syntax variation.
In the land of Acorn and the BBC Micro, there's BeebAsm which implements something like the assembler-embedded-in-Basic which the Beeb offers, so you get Basic programming and expression evaluation to add something a bit like macros.
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.
Instead of the familiar 3 letter opcodes, which form into a nice orderly column, you get a mix of lengths because the addressing mode is appended, which actually adds form and structure, making it easier to see what's going on. There's also a really minimal syntax for conditional assembly:
The conditional syntax is an IF THEN, but also there's an ELSE form:
(I'm guessing CLR is a synonym for STZ, and / is a bitwise negation.)
Examples from the MASM sources themselves - it seems MASM is written in MASM.
In the land of Acorn and the BBC Micro, there's BeebAsm which implements something like the assembler-embedded-in-Basic which the Beeb offers, so you get Basic programming and expression evaluation to add something a bit like macros.
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.
Instead of the familiar 3 letter opcodes, which form into a nice orderly column, you get a mix of lengths because the addressing mode is appended, which actually adds form and structure, making it easier to see what's going on. There's also a really minimal syntax for conditional assembly:
Code: Select all
LDAIM &FF
JSR OSBPUT
LDXIM -FILLEN
SRCL03
LDAZX CURFILE+FILLEN
JSR OSBPUT
INX
BNE SRCL03 ;Output the filename
SRCL05
[ $TURBO
LDAIM /SYMSHI
STA XSYMPT
]
RTSCode: Select all
[ :LSB:TEXT /= 0
LDAIM TEXT
STA LOADAD
|
CLR LOADAD
]
LDAIM /TEXT
Examples from the MASM sources themselves - it seems MASM is written in MASM.
Re: What assembly syntax is good to support in an assembler?
JustClaire wrote:
I do have conditional assembly & file include directives supported yeah) I also implemented "regions" to separate label/macro lookup.
Also un-named labels:
Code: Select all
inc ptr+0
bne :+
inc ptr+1
:
and so on ...
The trouble is... it would just end up looking like my (currently) favourite assembler
-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
Re: What assembly syntax is good to support in an assembler?
Some sort of local labels can be useful, especially for very short jumps out of loops or back to the head, things which barely need a name, but have to have a label.
There will certainly be a variety of opinions, and every practising assembly coder is likely to have settled on a preference. (All the same, I'm supportive of a new project, to see what it might bring.)
There will certainly be a variety of opinions, and every practising assembly coder is likely to have settled on a preference. (All the same, I'm supportive of a new project, to see what it might bring.)
Re: What assembly syntax is good to support in an assembler?
BigEd wrote:
Instead of the familiar 3 letter opcodes, which form into a nice orderly column, you get a mix of lengths because the addressing mode is appended, which actually adds form and structure, making it easier to see what's going on.
In my opinion, the place where an assembler really shines is it's macro system. as65 and macro assembler AS are both good in this regard, though I've tried to do things with both where the macros weren't sophisticated enough. For one project, I switched to NASM, an x86 assembler, for the macro functionality then assembled the result with a 6502 assembler. It might be worth it to compare the different macro systems (they vary a lot) and see how you would like your macros to work.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: What assembly syntax is good to support in an assembler?
JustClaire wrote:
For example some assemblers use ':' for labels whereas others don't.
Druzyek wrote:
In my opinion, the place where an assembler really shines is its macro system.
JustClaire wrote:
Also, what directives do you think are most useful to have? (apart from obvious things such as macros, labels & simple data)
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
-
JustClaire
- Posts: 18
- Joined: 27 Feb 2020
Re: What assembly syntax is good to support in an assembler?
GARTHWILSON wrote:
I have a list of requests for assembler writers at http://wilsonminesco.com/AssyDefense/as ... uests.html .
Also, what do you think is the better way to treat indirect addressing syntax?
I currently do not allow bracketed expressions as the operand for indirect addressing, as it would be very confusing to distinguish between
Code: Select all
JMP (offset_label + $)Code: Select all
offset_label + $Code: Select all
JMP (offset_label + $)Code: Select all
(offset_label + $)Currently the assembler would expect any indirect addressed instruction (indirect only, indirect indexed and indexed indirect dont count) to not have any brackets in the expression.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: What assembly syntax is good to support in an assembler?
The C32 assembler I use uses { and } for grouping things. What you show however does not need any grouping. JMP offset_label + $ is perfectly valid in all the assemblers I've used, and they don't need ( ) unless you want it indirect.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
-
JustClaire
- Posts: 18
- Joined: 27 Feb 2020
Re: What assembly syntax is good to support in an assembler?
GARTHWILSON wrote:
What you show however does not need any grouping.
Using other brackets for me would be problematic though, as my current syntax uses {} to explicitly specify bit width of a value.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: What assembly syntax is good to support in an assembler?
JustClaire wrote:
GARTHWILSON wrote:
What you show however does not need any grouping.
Using other brackets for me would be problematic though, as my current syntax uses {} to explicitly specify bit width of a value.
Some (many? most?) assemblers do that with the "<". So for example, for the C32 assembler I use, if I'm programming for the 65816 and have the index registers in 8-bit mode and want an 8-bit LDX immediate, I might say LDX #<$1F, because without the "<", it would lay down a 16-bit operand.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
-
JustClaire
- Posts: 18
- Joined: 27 Feb 2020
Re: What assembly syntax is good to support in an assembler?
GARTHWILSON wrote:
Some (many? most?) assemblers do that with the "<". So for example, for the C32 assembler I use, if I'm programming for the 65816 and have the index registers in 8-bit mode and want an 8-bit LDX immediate, I might say LDX #<$1F, because without the "<", it would lay down a 16-bit operand.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: What assembly syntax is good to support in an assembler?
C32 does shifts with << and >>. If there's any chance of confusing < for a "less than," you could put it in the brackets, like 2*{<foobar} (although that one should be clear without the brackets). I'll scan and post the list of operators. I've never found any problem with them (even if I'm not fond of some of them).
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: What assembly syntax is good to support in an assembler?
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?