| |
Sasq
Registered: Apr 2004 Posts: 155 |
Badass - New 6502 Assembler
The last couple of months I've created a new 6502 Assembler called bass (or Badass).
The basic idea is for it to be as advanced as Kickassembler, but with a less complex, more unified syntax.
And it also has unit tests in an internal emulator.
You can find it at https://github.com/sasq64/bass
I've started a tutorial here: http://apone.org/bass/part1.html
Here is an example C64 source http://apone.org/bass/example.asm.html |
|
... 106 posts hidden. Click here to view all posts.... |
| |
Sasq
Registered: Apr 2004 Posts: 155 |
I really wanted dots for local labels, as it naturally appends to the last non local label;
copy:
nop
.loop
dex
beq .loop
Here “.loop” just becomes “copy.loop” |
| |
Frantic
Registered: Mar 2003 Posts: 1626 |
@sasq: I'm with you there. Also, I've been using ACME for a whole bunch of years, so the ! notation comes quite naturally by now. :)
Speaking of dots at the start of local labels: It is nice if the assembler can spit out all the labels to a file which is compatible with the VICE command line parameter "-moncommands", e.g. something that looks like:
al C:1004 .PL_SP1_chn01
al C:1022 .PL_SP2_chn01
al C:103f .PL_SETPARAMFLAG_chn01
al C:1043 .PL_PARAM_chn01
al C:1048 .PL_SETNOTEFLAG_chn01
al C:104c .PL_NOTE_chn01
al C:1057 .PL_SP1_chn02
al C:1075 .PL_SP2_chn02
al C:1092 .PL_SETPARAMFLAG_chn02
al C:1096 .PL_PARAM_chn02
al C:109b .PL_SETNOTEFLAG_chn02
al C:109f .PL_NOTE_chn02
al C:10aa .PL_SP1_chn03
al C:10c8 .PL_SP2_chn03
al C:10e5 .PL_SETPARAMFLAG_chn03
al C:10e9 .PL_PARAM_chn03
al C:10ee .PL_SETNOTEFLAG_chn03
Note that all labels have a dot at their beginning here, even if those are not local labels in the original ACME source code. |
| |
oziphantom
Registered: Oct 2014 Posts: 478 |
Quoting OswaldOziphantom's example could be a simple .if PAL then PALIRQ .else NTSCIRQ fex. and the routine needed to be referenced by other code could just use a label.
Please tell me how you can use an if/else to handle the case of having PAL And NTSC stored in ROM in a cart that copies the right version into RAM as the game boots depending upon which hardware it is plugged in to. And how you would have just a label to handle reference by other code. |
| |
Oswald
Registered: Apr 2002 Posts: 5007 |
Ozi, my bad I made wrong assumptions what you are doing there. anyway 6 "." directives seems a lot for some irq assembly...
Sasq, why "." cant e used for directives and label hierarhy too? an algorithm can differentiate if its a . infront of a keyword or after a label? |
| |
chatGPZ
Registered: Dec 2001 Posts: 11088 |
one reason: to do that, you must know all and every keyword that you will ever use in advance, our your sources will randomly break in the future. it also makes the parser much easier and less messy to do. and its more consistent too. |
| |
Sasq
Registered: Apr 2004 Posts: 155 |
I can add a '--dot-meta' option that would
* Change prefix of meta to dot
* Require that you not put any meta commands or opcodes in the first column
* Require that you _do_ put assignments in the first column
.local_symbol = 3
.print .local_symbol
lda #.local_symbol
beq .skip
.skip
rts
... but I don't really like it :) |
| |
Sasq
Registered: Apr 2004 Posts: 155 |
This is how it's starting to work now. Needs tweaking for sure but will give a lot of possibilities.
!section "ZP", start=$00, size=$100, flags=NoStore
!section "RAM", start=$801, size=$9f00-$0801, flags=NoStore
;!section "HIRAM", start=$a000, size=$2000, NoStore
!memory "HIRAM",$a000,$2000
!section "DATA", in="RAM", flags=NoStore
!section "main", in="RAM", flags=First {
!section "ZP" {
var0: !ds 1
}
start:
sei
!section "sine" in="DATA" {
sine: !rept 256 { !byte sin(i) }
}
lda sine,x
sta var0
}
; Put pointer to given string or array in XY
!macro xyptr(a) {
!section "DATA" {
.local
!fill a
}
ldx #>.local
ldy #<.local
}
!section "extra", in="HIRAM" {
}
!section "other", in="HIRAM" {
}
Sections
!section <args...> [ { <statements> } ]
Arguments can be positional or named. The arguments are in order:
name - Name of the section to open up or create
start - Start address of the section (load address)
pc - Initial Program counter for this section (runtime address)
flags - Flags for the section
in - Parent section for this section
size - Fixed size of this section
fill - Fill char for this section if not filled up to _size_
If _name_ is not provided, an anonymous section is created.
If _start_ is provided, this creates a new section. It is an error
if a section with this name already exists.
If _start_ is not provided, _name_ must exist or this must be a child
section.
if _pc_ is not provided, it defaults to _start_.
Flags
NoStore: means this section will not be saved.
ReadOnly: means it will be located in ROM
First: means this section should come first in its parent
if _in_ is specified, this section is a child section.
A child section can not be reopened, and does not need to be named.
A child section will start at it's parents start, and will increase
it's parent pc to it's size.
A parent section should not have a different load and runtime address
The parent of a child section _must_ be a NoStore section.
Opening up an existing section and creating a child section is similar,
except in the latter case a new section is created.
`!memory <name> <start> <size>`
Short hand to create a NoStore section that can be the parent of other sections |
| |
JackAsser
Registered: Jun 2002 Posts: 1987 |
Yeah, that feels like a nice approach. With that you could also include the section definitions externally and thus have a structure similar to ca65's link-files. |
| |
Sasq
Registered: Apr 2004 Posts: 155 |
Ok now this:
Sections form a tree. Only leaf sections may contain data.
You can not "open up" sections, only add a section to a
parent section.
Root sections usually have fixed size and fixed start.
After an assembly pass, go through the tree and place all sections sequentially in their parent.
Now all sections will have a fixed start address.
If any section was moved, we need to do another pass.
; Root sections
!section "RAM" start=$0000 size=64*1024 NoStore
!section "ZP" start=$00 size=256 NoStore
; Non-leaf section
!section "text" in="RAM" NoStore Last
; Leaf section
!section "code" in="RAM", start=$801 {
; Basic start and such
; Another leaf section, defined recursively
!section in="text" {
name: !text "name"
}
lda name,x
}
|
| |
JackAsser
Registered: Jun 2002 Posts: 1987 |
What does NoStore mean in a parent section actually? |
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 - Next |