New 65XX Assembler on the block
-
backspace119
- Posts: 346
- Joined: 25 Jan 2019
- Location: Knoxville, TN
New 65XX Assembler on the block
Hello all, I'd like to present to you a project I've been working on for about a week now, and I believe it is finally ready for first usage testing.
It's called BSFOTA: Backspace Sixty Five O Two Assembler.
I built this assembler out of frustration trying to use other ones that are available, since most do not work on modern operating systems or have quirks that make them odd to use. The ultimate goals of this program are:
-Portability
-Compatibility
-No nonsense
-Ease of use
The assembler, as it presently stands, is fairly lenient on most syntax when it comes to math and numbers, although there are still "quirks" to the design that I will be working out as I go, to fulfill the "No nonsense" goal of the design. The program comes with a man page accessed by -man that has information on most of the quirks, but I'll list a few here (one of which I know isn't in that file explicitly)
First, the one not included in the file. I did not support octal notation yet, but it's very easy to add, and is the next thing I'm working on
INA must be used for incrementing A, other syntaxes are not allowed. This is to allow A to be used as a var name, in macros for instance.
Not many directives are supported yet, although the necessary ones are, they are: .ORG .x8 .x16 .m8 .m16
There is no "follow along" support yet for managing data widths for immediate and indexed data. This was planned from the beginning, and a system is in place to keep track of P, but it is not being used presently, since it can get rather messy in certain scenarios. It will be added as an optional feature later, I wanted something that was offered the user full control over what gets laid out and when.
Advanced Macro support is not implemented yet. By this I mean "IF, UNTIL, REPEAT, etc". However, conditional compilation by using IFMA keyword is implemented and available for use.
There are a few other quirks but you can read the man page for all of them. On to some of the design.
The program is written in Java, targeting Java SE 8, which is currently the standard LTS release, Java 11 is the next LTS, and it should be compatible with 11 as well.
The jar binaries I will be releasing are executable, no need to point java to the class it needs to start at. Simply open a command window, and type "java -jar <name-of-jar>" in the same folder as where the jar is located. If java is not in your PATH on windows you may need to get it. The program should run fine on either x86 or x86_64 java. It should probably run fine on OpenJDK as well, and any ARM revisions of java out there.
The program was built to mimic many Linux programs as far as switch design. -i is for input file, -o is for output file, and other switches are as short as possible while being unique to what they do. Running the program without any arguments will show the help page, or -h can be used to get to the help page. -man can be used to get to the manual page (which needs expanding).
The project is released under GPL v2, it is FOSS and I plan to keep it that way. I forsee this assembler as being the assembler for the future, where others may die off or become incompatible, this one should remain compatible for many years to come, and if it becomes incompatible, the source is available and can be modified to make it compatible.
This is the first assembler I've built for a real processor. I've built assemblers for some custom scripting languages that worked off opcodes and operands before, but this is definitely still new to me. Because of this, I urge caution on using it, you should verify the code it outputs against a known working assembler, and please let me know if it is making errors.
You can find the git repo here I've added wiki and issue tracking to the repo so the community can help improve this project.
Please feel free to give any suggestions for changes or features or anything really. This is a passion project for me, and I really do want it to be as useful as possible.
I'll use this thread as the main discussion area for this, and I will attempt to post any updates here as well.
It's called BSFOTA: Backspace Sixty Five O Two Assembler.
I built this assembler out of frustration trying to use other ones that are available, since most do not work on modern operating systems or have quirks that make them odd to use. The ultimate goals of this program are:
-Portability
-Compatibility
-No nonsense
-Ease of use
The assembler, as it presently stands, is fairly lenient on most syntax when it comes to math and numbers, although there are still "quirks" to the design that I will be working out as I go, to fulfill the "No nonsense" goal of the design. The program comes with a man page accessed by -man that has information on most of the quirks, but I'll list a few here (one of which I know isn't in that file explicitly)
First, the one not included in the file. I did not support octal notation yet, but it's very easy to add, and is the next thing I'm working on
INA must be used for incrementing A, other syntaxes are not allowed. This is to allow A to be used as a var name, in macros for instance.
Not many directives are supported yet, although the necessary ones are, they are: .ORG .x8 .x16 .m8 .m16
There is no "follow along" support yet for managing data widths for immediate and indexed data. This was planned from the beginning, and a system is in place to keep track of P, but it is not being used presently, since it can get rather messy in certain scenarios. It will be added as an optional feature later, I wanted something that was offered the user full control over what gets laid out and when.
Advanced Macro support is not implemented yet. By this I mean "IF, UNTIL, REPEAT, etc". However, conditional compilation by using IFMA keyword is implemented and available for use.
There are a few other quirks but you can read the man page for all of them. On to some of the design.
The program is written in Java, targeting Java SE 8, which is currently the standard LTS release, Java 11 is the next LTS, and it should be compatible with 11 as well.
The jar binaries I will be releasing are executable, no need to point java to the class it needs to start at. Simply open a command window, and type "java -jar <name-of-jar>" in the same folder as where the jar is located. If java is not in your PATH on windows you may need to get it. The program should run fine on either x86 or x86_64 java. It should probably run fine on OpenJDK as well, and any ARM revisions of java out there.
The program was built to mimic many Linux programs as far as switch design. -i is for input file, -o is for output file, and other switches are as short as possible while being unique to what they do. Running the program without any arguments will show the help page, or -h can be used to get to the help page. -man can be used to get to the manual page (which needs expanding).
The project is released under GPL v2, it is FOSS and I plan to keep it that way. I forsee this assembler as being the assembler for the future, where others may die off or become incompatible, this one should remain compatible for many years to come, and if it becomes incompatible, the source is available and can be modified to make it compatible.
This is the first assembler I've built for a real processor. I've built assemblers for some custom scripting languages that worked off opcodes and operands before, but this is definitely still new to me. Because of this, I urge caution on using it, you should verify the code it outputs against a known working assembler, and please let me know if it is making errors.
You can find the git repo here I've added wiki and issue tracking to the repo so the community can help improve this project.
Please feel free to give any suggestions for changes or features or anything really. This is a passion project for me, and I really do want it to be as useful as possible.
I'll use this thread as the main discussion area for this, and I will attempt to post any updates here as well.
-
backspace119
- Posts: 346
- Joined: 25 Jan 2019
- Location: Knoxville, TN
Re: New 65XX Assembler on the block
New version 0.0.2
Octal notation numbers are now supported format is o123 or 123O (case insensitive)
Octal notation numbers are now supported format is o123 or 123O (case insensitive)
Re: New 65XX Assembler on the block
backspace119 wrote:
I built this assembler out of frustration trying to use other ones that are available, since most do not work on modern operating systems or have quirks that make them odd to use.
I wrote my own assembler as well, in Java, but ca65 is much more capable, and not quirky. The fact that it supports a full development suite of tools, notably object modules, a linker, and a librarian, makes it even better.
The hard part about ca65 is getting your memory layout figured out, and folks here can help with that.
-
backspace119
- Posts: 346
- Joined: 25 Jan 2019
- Location: Knoxville, TN
Re: New 65XX Assembler on the block
whartung wrote:
backspace119 wrote:
I built this assembler out of frustration trying to use other ones that are available, since most do not work on modern operating systems or have quirks that make them odd to use.
I wrote my own assembler as well, in Java, but ca65 is much more capable, and not quirky. The fact that it supports a full development suite of tools, notably object modules, a linker, and a librarian, makes it even better.
The hard part about ca65 is getting your memory layout figured out, and folks here can help with that.
I'll definitely take a look at ca65 soon to get into more complex programs.
EDIT: I see that ca65 supports straight assembly too....not sure why I didn't find this listed on the page about assemblers, or maybe I over looked it. I sorted them by searching for 65816 or 65c816 to only get the ones that were capable of assembling for this cpu. At any rate, I'm still having a lot of fun with making this, but maybe it's more something that's only useful as a learning experience to me.
Re: New 65XX Assembler on the block
backspace119 wrote:
EDIT: I see that ca65 supports straight assembly too....not sure why I didn't find this listed on the page about assemblers, or maybe I over looked it. I sorted them by searching for 65816 or 65c816 to only get the ones that were capable of assembling for this cpu. At any rate, I'm still having a lot of fun with making this, but maybe it's more something that's only useful as a learning experience to me.
I inadvertently got the older one originally - which worked well, except for an obscure Sweet16 operation.
-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/
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
Re: New 65XX Assembler on the block
Typo in Assembler.java line 19 'OCATL_PATTERN'.
Checking for direct page addresses with expressions like ...
... doesn't really work for the '816 as the direct page does not have to be at $0000.
My Java based cross platform relocating macro assembler is here https://github.com/andrew-jacobs/dev65
Checking for direct page addresses with expressions like ...
Code: Select all
if(replaceHex(line) > 0xFF)
{
return standard2(0x84,line);
}else {
return standard3(0x8C,line);
}
My Java based cross platform relocating macro assembler is here https://github.com/andrew-jacobs/dev65
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
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
Re: New 65XX Assembler on the block
Great project - thanks for open-sourcing it!
Because the '816 is so stateful, it's probably best to have both
- directives to say what the state is (or should be!)
- heuristics to follow state changes
As for adding octal - is binary already in there?
Because the '816 is so stateful, it's probably best to have both
- directives to say what the state is (or should be!)
- heuristics to follow state changes
As for adding octal - is binary already in there?
-
backspace119
- Posts: 346
- Joined: 25 Jan 2019
- Location: Knoxville, TN
Re: New 65XX Assembler on the block
BitWise wrote:
Typo in Assembler.java line 19 'OCATL_PATTERN'.
Checking for direct page addresses with expressions like ...
... doesn't really work for the '816 as the direct page does not have to be at $0000.
My Java based cross platform relocating macro assembler is here https://github.com/andrew-jacobs/dev65
Checking for direct page addresses with expressions like ...
Code: Select all
if(replaceHex(line) > 0xFF)
{
return standard2(0x84,line);
}else {
return standard3(0x8C,line);
}
My Java based cross platform relocating macro assembler is here https://github.com/andrew-jacobs/dev65
If it's definitely wrong than I can look further into it, but I actually came back here to report that I've run a few programs assembled from it and it seems to work quite well. (I've not released my latest code yet, there's a few extras that are still very much WIP, such as the serial link to an arduino programmer I built in when using the -w switch)
I'm going to try out some more complex programs with it, and see how it does, but I just got the emulation light to dim with this program compiled through my assembler:
Code: Select all
.m8
.x8
ST:
SEI
CLC
XCE
LDA #$FF
STA $00
LDA #$00
LOOP:
INA
CMP $00
BEQ CONT
BRA LOOP
CONT:
SEC
XCE
LDA #$00
L2:
INA
CMP $00
BEQ RET
BRA L2
RET:
BRA ST
-
backspace119
- Posts: 346
- Joined: 25 Jan 2019
- Location: Knoxville, TN
Re: New 65XX Assembler on the block
BigEd wrote:
Great project - thanks for open-sourcing it!
Because the '816 is so stateful, it's probably best to have both
- directives to say what the state is (or should be!)
- heuristics to follow state changes
As for adding octal - is binary already in there?
Because the '816 is so stateful, it's probably best to have both
- directives to say what the state is (or should be!)
- heuristics to follow state changes
As for adding octal - is binary already in there?
Thanks for the compliment, and I wouldn't dream of not open sourcing something like this, this is a really cool hobby and the easier it is for people to get into, the better.
EDIT:
about your other points that I forgot to address
I'm working on a follow along heuristics system, and I'm also working on more directives, presently, only the ones listed exist though.
-
backspace119
- Posts: 346
- Joined: 25 Jan 2019
- Location: Knoxville, TN
Re: New 65XX Assembler on the block
drogon wrote:
backspace119 wrote:
EDIT: I see that ca65 supports straight assembly too....not sure why I didn't find this listed on the page about assemblers, or maybe I over looked it. I sorted them by searching for 65816 or 65c816 to only get the ones that were capable of assembling for this cpu. At any rate, I'm still having a lot of fun with making this, but maybe it's more something that's only useful as a learning experience to me.
I inadvertently got the older one originally - which worked well, except for an obscure Sweet16 operation.
-Gordon
-
backspace119
- Posts: 346
- Joined: 25 Jan 2019
- Location: Knoxville, TN
Re: New 65XX Assembler on the block
And I just found out why certain programs weren't working.
I made a dumb mistake and was treating JSR like BRL, with relative addressing.
Now that that's fixed, my emulation mode light blinks with this program compiled with my assembler:
To give you a sample of the side by side output, here's what it generated:
EDIT: unfortunately a limitation of side by side output currently is that it outputs lines with numbers parsed to decimal, and it also gets rid of a few things. I'm working on getting it to be a true side by side.
I made a dumb mistake and was treating JSR like BRL, with relative addressing.
Now that that's fixed, my emulation mode light blinks with this program compiled with my assembler:
Code: Select all
.m8
.x8
ST:
SEI
CLC
XCE
JSR WASTETIME
SEC
XCE
JSR WASTETIME
BRA ST
WASTETIME:
LDA #$FF
STA $00
LDA #$00
STA $01
LOOP:
INA
CMP $00
BEQ NXT
BRA LOOP
NXT:
INC $01
CMP $01
BEQ RET
BRA LOOP
RET:
RTS
Code: Select all
ST
C000 78 SEI
C001 18 CLC
C002 FB XCE
C003 200DC0 JSR WASTETIME
C006 38 SEC
C007 FB XCE
C008 200DC0 JSR WASTETIME
C00B 80F3 BRA ST
WASTETIME
C00D A9FF LDA #255
C00F 8500 STA 0
C011 A900 LDA #0
C013 8501 STA 1
LOOP
C015 1A INA
C016 C500 CMP 0
C018 F002 BEQ NXT
C01A 80F9 BRA LOOP
NXT
C01C E601 INC 1
C01E C501 CMP 1
C020 F002 BEQ RET
C022 80F1 BRA LOOP
RET
C024 60 RTS
-
backspace119
- Posts: 346
- Joined: 25 Jan 2019
- Location: Knoxville, TN
Re: New 65XX Assembler on the block
I have now successfully run a sort of complicated program through it, found out the reason it wasn't working was I mixed up 8D and 8F (STA abs and STA long). I'm so close to having this do something cool, I can feel it.
EDIT: sort of wrong thread, but related to my assembler, so w/e
EDIT: sort of wrong thread, but related to my assembler, so w/e
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
Re: New 65XX Assembler on the block
backspace119 wrote:
I'm actually checking for direct addressing mode, I was following the syntax found here
Code: Select all
; These routines expect the caller to have set $DF00 as the direct page address
; so that direct-page instructions are used to access hardware registers.
00000020 = SPI_SCK .equ 1<<5
00000040 = SPI_MOSI .equ 1<<6
00000080 = SPI_MISO .equ 1<<7
.dpage $df00
.longa ?
.longi ?
SpiInit:
00:F177 08 : php
short_a
+ .longa off
00:F178 E220 + sep #$20 ; Make A register 8-bit
00:F17A A920 : lda #SPI_SCK ; Set SCK as lo output
00:F17C 0424 : tsb PDD4
00:F17E 1420 : trb PD4
00:F180 A940 : lda #SPI_MOSI ; Set MOSI as an output
00:F182 0424 : tsb PDD4
00:F184 A980 : lda #SPI_MISO ; Set MISO as an input
00:F186 1424 : trb PDD4
00:F188 28 : plp
00:F189 60 : rts
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
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
Re: New 65XX Assembler on the block
BitWise wrote:
On the '816 the direct page is can start at any address in bank 0 so you can have code like this ...
Code: Select all
; These routines expect the caller to have set $DF00 as the direct page address
; so that direct-page instructions are used to access hardware registers.
00000020 = SPI_SCK .equ 1<<5
00000040 = SPI_MOSI .equ 1<<6
00000080 = SPI_MISO .equ 1<<7
.dpage $df00
- BitWise
- In Memoriam
- Posts: 996
- Joined: 02 Mar 2004
- Location: Berkshire, UK
- Contact:
Re: New 65XX Assembler on the block
The .dpage directive tells the assembler where the application will set the direct page at execution time so it can determine if a direct page address can be used. By default the assembler assumes the direct page will be at $0000 as it is on the 6502 and 65C02.
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
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