Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Badass - New 6502 Assembler
2020-06-28 17:47
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....
 
2020-07-01 13:44
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 :)
2020-07-01 19:12
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
2020-07-01 19:38
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.
2020-07-02 13:56
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
}

2020-07-02 14:41
JackAsser

Registered: Jun 2002
Posts: 2038
What does NoStore mean in a parent section actually?
2020-07-02 14:57
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.
2020-07-03 08:53
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.
2020-07-03 11:03
Sasq

Registered: Apr 2004
Posts: 157
Sure, that already works. Although I need to allow file ouput section to overlap I guess.
2020-07-03 12:10
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
2020-07-23 22:59
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
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Acidchild/Padua
sachy/BOOM!
zscs
Brataccas/HF
Fred/Channel 4
Guests online: 240
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Codeboys & Endians  (9.7)
4 Mojo  (9.6)
5 Coma Light 13  (9.6)
6 Edge of Disgrace  (9.6)
7 Signal Carnival  (9.6)
8 Wonderland XIV  (9.5)
9 Uncensored  (9.5)
10 Comaland 100%  (9.5)
Top onefile Demos
1 Nine  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.5)
6 Scan and Spin  (9.5)
7 Onscreen 5k  (9.5)
8 Grey  (9.5)
9 Dawnfall V1.1  (9.5)
10 Rainbow Connection  (9.5)
Top Groups
1 Artline Designs  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Performers  (9.3)
5 Censor Design  (9.3)
Top Webmasters
1 Slaygon  (9.7)
2 Perff  (9.6)
3 Sabbi  (9.5)
4 Morpheus  (9.4)
5 CreaMD  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.047 sec.