FASMG-based 6502 assembler
FASMG-based 6502 assembler
I've been using FASM (x86) and FASMARM for well over a decade, and mostly enjoying it for its very flexible (though quirky) macro system.
FASMG came out more recently as a universal assembler engine, where you can build your own assembler for any architecture with macros. I just rediscovered it and coded up a J1 CPU assembler in a page of code (though crumby as I haven't really figured out how to do it well)
I just came across a 6502 assembler someone put together https://board.flatassembler.net/topic.php?t=18136
Haven't used it yet, but probably will give it a try, as every 6502 assembler I've used has some awful quirk that drives me crazy.
FASMG came out more recently as a universal assembler engine, where you can build your own assembler for any architecture with macros. I just rediscovered it and coded up a J1 CPU assembler in a page of code (though crumby as I haven't really figured out how to do it well)
I just came across a 6502 assembler someone put together https://board.flatassembler.net/topic.php?t=18136
Haven't used it yet, but probably will give it a try, as every 6502 assembler I've used has some awful quirk that drives me crazy.
- BigDumbDinosaur
- Posts: 9426
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: FASMG-based 6502 assembler
Just what the world needs: yet another 6502 cross-assembler.
What I’d like to see is a portable, syntactically-compliant¹ assembler that can be hosted on a 6502-powered contraption like what we build around here. Conjuring an assembler that runs in a high-level language on a Linux or Windows box has been done over and over and over and...over again. Accomplishing the same in pure 6502 assembly language, with it written so it can be tailored to the available I/O of a 6502 homebrew machine like Daryl’s SBC series or Flooby’s Pocket PC unit...now that would be an achievement and worth some major bragging rights!
————————————————————
¹“Syntactically-compliant” means it implements the 6502 assembly language as defined by MOS Technology and WDC—alternate syntax would be okay as long as the MOS/WDC standard is primary.
What I’d like to see is a portable, syntactically-compliant¹ assembler that can be hosted on a 6502-powered contraption like what we build around here. Conjuring an assembler that runs in a high-level language on a Linux or Windows box has been done over and over and over and...over again. Accomplishing the same in pure 6502 assembly language, with it written so it can be tailored to the available I/O of a 6502 homebrew machine like Daryl’s SBC series or Flooby’s Pocket PC unit...now that would be an achievement and worth some major bragging rights!
————————————————————
¹“Syntactically-compliant” means it implements the 6502 assembly language as defined by MOS Technology and WDC—alternate syntax would be okay as long as the MOS/WDC standard is primary.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: FASMG-based 6502 assembler
Yeah, I know.
Although I still can't find a workflow/tools that I actually enjoy.
We've gotten spoiled... Back in the day I'd feel happy to have _an_ assembler, and figure out all the tricks of how to use it like a real hacker. Now I download one thing after another, and abandon it after not liking some or other feature. Or worse yet, have a dozen projects each using slightly different syntax, and be unable to pick up where I left off
One thing fasmg has going for it is that it is pretty easy to change the syntax to your liking. And strong macro processing
Although I still can't find a workflow/tools that I actually enjoy.
We've gotten spoiled... Back in the day I'd feel happy to have _an_ assembler, and figure out all the tricks of how to use it like a real hacker. Now I download one thing after another, and abandon it after not liking some or other feature. Or worse yet, have a dozen projects each using slightly different syntax, and be unable to pick up where I left off
One thing fasmg has going for it is that it is pretty easy to change the syntax to your liking. And strong macro processing
- BigDumbDinosaur
- Posts: 9426
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: FASMG-based 6502 assembler
enso1 wrote:
Yeah, I know.
Although I still can't find a workflow/tools that I actually enjoy.
Although I still can't find a workflow/tools that I actually enjoy.
I’ve settled on the Kowalski package, despite it being a Windows-only environment. Ever since Daryl enhanced it to work with the 65C816, it has become as good as anything else available and can plow through 30,000 lines of source code in literally an eyeblink. It would be cool if I could develop an assembler that I could host on my POC unit. That’s a major undertaking, however, and time in general is getting short for me.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: FASMG-based 6502 assembler
BigDumbDinosaur wrote:
What I’d like to see is a portable, syntactically-compliant¹ assembler that can be hosted on a 6502-powered contraption like what we build around here.
What kind of editing workflow do you use on your 6502 systems? I guess it would be enough to assemble from a big string in memory somewhere to whatever target address? Then you could use remote editor or some local system like forth screens or whatever?
[edit]
A couple of times I've wished that the cross assembler (c65, 64tass etc) could run 6502 code as part of the assembly process, e.g. to calculate a hash or populate a data table. Perhaps allowing native code callouts would be a simple/powerful alternative to traditional assembler macros, keeping the assembler itself simple?
- BigDumbDinosaur
- Posts: 9426
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: FASMG-based 6502 assembler
pdragon wrote:
BigDumbDinosaur wrote:
What I’d like to see is a portable, syntactically-compliant¹ assembler that can be hosted on a 6502-powered contraption like what we build around here.
What I’m referring to when I say “portable assembler” is software that has no specific operating system and/or hardware dependencies (other than a 6502/65C02/65C816), with just some I/O calls to read source code, write object code and if desired, diagnostic files (e.g., a listing). Optionally, there would be a way for the assembler to write to the console if a gross error arises during assembly and no other means of communicating that to the user is available.
Quote:
What kind of editing workflow do you use on your 6502 systems?
I do all my work in the Kowalski editor/assembler/simulator, as greatly extended by Daryl (8Bit). With it now capable of simulating the 65C816 in native mode, I can test algorithms without having to try running them on POC V1.3 and risking a crash.
Quote:
I guess it would be enough to assemble from a big string in memory somewhere to whatever target address? Then you could use remote editor or some local system like forth screens or whatever?
My thinking is that of being able to edit and assemble on the 6502 machine, not using another machine to do any of the work. An obvious prerequisite of a self-hosted development environment is the existence of some sort of local operating system with filesystem support, as well as some sort of “human interface.”
Quote:
A couple of times I've wished that the cross assembler (c65, 64tass etc) could run 6502 code as part of the assembly process, e.g. to calculate a hash or populate a data table. Perhaps allowing native code callouts would be a simple/powerful alternative to traditional assembler macros, keeping the assembler itself simple?
Macros were originally devised to automate repetitive code sequences; use of conditional assembly directives is often part of writing a macro. What you are wanting, e.g., calculating a hash, is something that would have to be implemented, I’d think, with a series of algebraic expressions and assembly-time variables (which are not symbols in the usual sense), possibly called from within a macro. The ability to do so would, of course, be dependent on the assembler’s ability to do more than simple left-to-right arithmetic, as well as store intermediate and/or final results into variables for subsequent use by later statements.
In the Kowalski assembler, I have developed assembly-time code that is able to calculate stack frame structures, build data tables from some constants defined early in the source code, etc.. Typical data tables are things such as pointers into various structures, or vectors for directing program execution in a fashion like that of the ON - GOTO statement in BASIC. The Kowalski assembler supports the usual four-function math, plus a set of Boolean expressions, assembly-time variables, and so forth. I’d expect that more-complex math could be carried out with the basics combined with .REPEAT loops and conditional statements. I’ve not gotten to where I’ve had to get that fancy, but there may come a time...
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: FASMG-based 6502 assembler
Quote:
A couple of times I've wished that the cross assembler (c65, 64tass etc) could run 6502 code as part of the assembly process, e.g. to calculate a hash or populate a data table. Perhaps allowing native code callouts would be a simple/powerful alternative to traditional assembler macros, keeping the assembler itself simple?
BDD, is https://github.com/jdimeglio/6502-Simulator the place to get Kowalski with all the goodies?
I am not looking forward to yet another layer of dealing with windows emulation, but...
- BigDumbDinosaur
- Posts: 9426
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: FASMG-based 6502 assembler
enso1 wrote:
BDD, is https://github.com/jdimeglio/6502-Simulator the place to get Kowalski with all the goodies?
Actually, that is an older, “unofficial” version. The most-recent “official” version, and the one I am currently running, is right here. Daryl’s (8Bit) Kowalski web page is at https://sbc.rictor.org/kowalski.html. Scroll to the bottom to see links to the available versions, including source code. Also note that we have a running topic here on the Kowalski package.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: FASMG-based 6502 assembler
BigDumbDinosaur wrote:
My thinking is that of being able to edit and assemble on the 6502 machine, not using another machine to do any of the work. An obvious prerequisite of a self-hosted development environment is the existence of some sort of local operating system with filesystem support, as well as some sort of “human interface.”
As a complete system, it's only become practical with an external video memory space and external storage: I'm using (planning) a pi pico for the video and IO and a FAT16 compact flash card in 6502 memory space. Because of the way the video works, diverting to serial IO is easy; the file system allows me to use multiple files both as source and as temporary files if required, as well as a destination for the final executable.
There are of course a lot of assumptions behind that system; I'm currently building and testing them as I go before I stick them all together... it'll take a while, but I've still got a few years left in me
Neil
Re: FASMG-based 6502 assembler
One idea I've been toying with for decades is a hybrid approach: cross-assembling directly into the target 6502 system running a small monitor, interactively. Interaction feels like a forth, but assembly, but you can assemble bits and pieces and run things to test them. I had something like that running on an Apple ][ maybe 20 years ago.
Re: FASMG-based 6502 assembler
The Apple II comes with a built-in mini assembler... F666G to make it work. It was part of the original Integer Basic ROM set, or loaded from disc with the Apple II+ systems which came with the Applesoft Basic ROM set.
It was literally one line at a time with no source code storage or editing.
Latterly I used the TED II+ assembler on the Apple II for many projects. It had a built-in editor and assembler and supported Sweet 16 too, but I really don't remember if it allowed separate assembly or linkage.
After that; BBC Basic has a built in assembler. It's quirky, but it lets you use BASIC subroutines/functions as a macro. I understand there is now a standalone BeebAsm program which more or less emulates it.
In the BBC Micro world I also used a relocatable assembler that was part of the Acornsoft BCPL package - sadly the sources to it are lost along with all the other Acornsoft stuff, but I have made a start to write one in BCPL under my 65816 BCPL system although I may not finish it as I'm currently happy enough with ca65 for 6502/65C02/65C816 and Sweet 16 work.
-Gordon
It was literally one line at a time with no source code storage or editing.
Latterly I used the TED II+ assembler on the Apple II for many projects. It had a built-in editor and assembler and supported Sweet 16 too, but I really don't remember if it allowed separate assembly or linkage.
After that; BBC Basic has a built in assembler. It's quirky, but it lets you use BASIC subroutines/functions as a macro. I understand there is now a standalone BeebAsm program which more or less emulates it.
In the BBC Micro world I also used a relocatable assembler that was part of the Acornsoft BCPL package - sadly the sources to it are lost along with all the other Acornsoft stuff, but I have made a start to write one in BCPL under my 65816 BCPL system although I may not finish it as I'm currently happy enough with ca65 for 6502/65C02/65C816 and Sweet 16 work.
-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: FASMG-based 6502 assembler
Anyway, the reason I posted is that fasmg makes it easy (or at least possible) to create an assembler with a syntax you like, and even add fairly complicated logic to the assembler. I've used the old, less capable fasm macros (on x86) to build pretty complicated external dictionaries for Forth-like systems, and create relocation bitmaps. etc.
Not that we need a new assembler, but it can be useful to do things otherwise not possible without a lot of work reinventing the wheel.
Not that we need a new assembler, but it can be useful to do things otherwise not possible without a lot of work reinventing the wheel.
- BigDumbDinosaur
- Posts: 9426
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: FASMG-based 6502 assembler
barnacle wrote:
BigDumbDinosaur wrote:
My thinking is that of being able to edit and assemble on the 6502 machine, not using another machine to do any of the work. An obvious prerequisite of a self-hosted development environment is the existence of some sort of local operating system with filesystem support, as well as some sort of “human interface.”
In other words, your Neolithic’s design isn’t set in stone.
Quote:
it'll take a while, but I've still got a few years left in me 
Probably a lot more years than have I.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: FASMG-based 6502 assembler
Whereas I had my fortieth birthday this year. Though my colleagues at the office were unkind enough to point out that hex is not the usual way of counting birthdays. 
Neil
p.s. you know me: nothing is ever set in stone. Except my delight in puns...
Neil
p.s. you know me: nothing is ever set in stone. Except my delight in puns...
- BigDumbDinosaur
- Posts: 9426
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: FASMG-based 6502 assembler
barnacle wrote:
Whereas I had my fortieth birthday this year. Though my colleagues at the office were unkind enough to point out that hex is not the usual way of counting birthdays. 
Give your colleagues your age in binary and see how they react to that.
Quote:
p.s. you know me: nothing is ever set in stone. Except my delight in puns...
Radical Brad having made some posts about his Skycycle reminded me that the reason a bicycle can’t stand up by itself is because it’s too tired.
x86? We ain't got no x86. We don't NEED no stinking x86!