| |
Sasq
Registered: Apr 2004 Posts: 157 |
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: 157 |
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: 157 |
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: 2038 |
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: 157 |
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: 2038 |
What does NoStore mean in a parent section actually? |
| |
Sasq
Registered: Apr 2004 Posts: 157 |
Well NoStore should be implied in any non-leaf section now.
It means it will not be any data in the section. |
| |
JackAsser
Registered: Jun 2002 Posts: 2038 |
Quote: Well NoStore should be implied in any non-leaf section now.
It means it will not be any data in the section.
Yup, I guessed as much. You really need output directives to root sections also, i.e. to what file they should be emitted. |
| |
Sasq
Registered: Apr 2004 Posts: 157 |
Sure, that already works. Although I need to allow file ouput section to overlap I guess. |
| |
Sasq
Registered: Apr 2004 Posts: 157 |
Here is the new Section documentation (and other meta commands):
https://github.com/sasq64/bass/blob/new-sections/docs/META.md |
| |
Sasq
Registered: Apr 2004 Posts: 157 |
Beta4 update. Changes include:
* Indexed labels, for accessing labels inside macros and rept statements
* New section system, child sections etc
* Unicode strings
* !check for runtime asserts in 6502 code
* Better error reporting
https://github.com/sasq64/bass/releases |
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 - Next |