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


Forums > C64 Coding > Badass - New 6502 Assembler
2020-06-28 17:47
Sasq

Registered: Apr 2004
Posts: 132
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
 
... 75 posts hidden. Click here to view all posts....
 
2020-07-24 10:12
Sasq

Registered: Apr 2004
Posts: 132
Here is an example of indexed labels and unit testing, based
on a snippet from Trash that wanted this feature;

; constant D011VALUE == value in d011

D011VALUE = 0

!macro DrawRasterColors(row) {
    !if (row & 7) == (D011VALUE & 7) {
    ; 23 cycle macro
    col[row]:
        lda #0                  ;  2
        sta $d020               ;  6
        sta $d021               ; 10
        !rept 5 { nop }
        bit $ea                 ; 23
    } else {
    ;63 cycle macro
    col[row]:
        lda #0                  ;  2
        sta $d020               ;  6
        sta $d021               ; 10
        !rept 25 { nop }
        bit $ea                 ; 63
    }
}

!section "main", $c000

!rept 6*8 {
    DrawRasterColors(i + $40)
}

!test "bad" {
    DrawRasterColors(0)
}
!assert tests.bad.cycles == 23

!test "good" {
    DrawRasterColors(1)
}
!assert tests.good.cycles == 63

!test "modify" {
    lda #9
    sta col[$40]+1
    lda #8
    sta col[$41]+1
}
!assert tests.modify.ram[$c001] == 9
!assert tests.modify.ram[$c010] == 8
2020-07-25 08:41
Oswald

Registered: Apr 2002
Posts: 4628
indexed labels is nice, lot of guys need that when creating selfmodded speedcode with macros :)
2020-09-16 10:34
Raistlin

Registered: Mar 2007
Posts: 251
I was interested in trying out this assembler .. but .. trying to compile the source, I'm getting some problems..

On Windows, CMake is refusing to generate the compile_commands.json file ....

Anyone know what might be needed to get this compiling on Windows?
2020-09-17 21:12
Sasq

Registered: Apr 2004
Posts: 132
`compile_commands.json` are not needed for building, only for Intellisense features in editors such as Visual Studio Code.
2020-09-17 21:30
Sasq

Registered: Apr 2004
Posts: 132
The `dev` branch is where it's happening BTW.

The following is an example on how you can let the assembler "pre-render" sid register data for faster playback (like the Dane part in Edge of Disgrace):

    !script "../lua/sid.lua"

    data = load("../data/test.sid")
    sid = sid_parse(data)
    
    !section "music", sid.load
music:
    !fill sid.data

%{

    sid_data = nil

    function generate_data()

        map_bank_write(0xd4, 1, function(adr, val)
            if sid_data then
                table.insert(sid_data, adr - 0xd400)
                table.insert(sid_data, val)
            end
        end)

        start_run()
        init = sym("sid.init")
        play = sym("sid.play")
        set_a(0)
        call(init)
        sid_data[#sid_data - 1] = sid_data[#sid_data - 1] | 0x80
        for i=1,15*50 do
            l = #sid_data
            call(play)
            if l ~= #sid_data then
                sid_data[#sid_data - 1] = sid_data[#sid_data - 1] | 0x80
            else
                print("Silent frame")
            end
        end
    end

    function get_sid_data()
        sid_data = {}
        generate_data()
        result = sid_data
        sid_data = nil
        return result
    end
}%

    !text "SID"
sid_data:
    !fill get_sid_data()
2020-09-17 22:28
JackAsser

Registered: Jun 2002
Posts: 1746
Quote: The `dev` branch is where it's happening BTW.

The following is an example on how you can let the assembler "pre-render" sid register data for faster playback (like the Dane part in Edge of Disgrace):

    !script "../lua/sid.lua"

    data = load("../data/test.sid")
    sid = sid_parse(data)
    
    !section "music", sid.load
music:
    !fill sid.data

%{

    sid_data = nil

    function generate_data()

        map_bank_write(0xd4, 1, function(adr, val)
            if sid_data then
                table.insert(sid_data, adr - 0xd400)
                table.insert(sid_data, val)
            end
        end)

        start_run()
        init = sym("sid.init")
        play = sym("sid.play")
        set_a(0)
        call(init)
        sid_data[#sid_data - 1] = sid_data[#sid_data - 1] | 0x80
        for i=1,15*50 do
            l = #sid_data
            call(play)
            if l ~= #sid_data then
                sid_data[#sid_data - 1] = sid_data[#sid_data - 1] | 0x80
            else
                print("Silent frame")
            end
        end
    end

    function get_sid_data()
        sid_data = {}
        generate_data()
        result = sid_data
        sid_data = nil
        return result
    end
}%

    !text "SID"
sid_data:
    !fill get_sid_data()


Hehe, awesome!
2020-09-17 22:36
Mr. SID

Registered: Jan 2003
Posts: 378
Yeah, you can do stuff like that with k2asm and Python too. Some of it is useful and other things are masturbatory coding... :)
2020-09-17 22:40
Sasq

Registered: Apr 2004
Posts: 132
Does k2asm also contain an emulator?
Otherwise I can't see how it can do this.
2020-09-17 23:49
Mr. SID

Registered: Jan 2003
Posts: 378
No, but you can do pretty much anything in Python these days: https://github.com/docmarionum1/py65emu
2020-09-18 22:38
Compyx

Registered: Jan 2005
Posts: 590
Hot damn, there's PLA in play*. An actual mnemonic in a shitload of 'code'.
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 - 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
Jammer/TooMany
Black Beard/Abyss, A..
Dwangi/Fairlight
Facet/G★P
Tech/Upfront
Twilight/ExCeSs
V-12/Tropyx
Bieno/Commodore Plus
Mikael/Pretzel Logic
Remdy/Dentifrice
Flex/Artline Designs
GH/dSr/Focus/MSL/Too..
Guests online: 68
Top Demos
1 Coma Light 13  (9.6)
2 Uncensored  (9.6)
3 Memento Mori  (9.6)
4 Edge of Disgrace  (9.6)
5 Unboxed  (9.6)
6 Comaland 100%  (9.6)
7 Lunatico  (9.6)
8 The Shores of Reflec..  (9.5)
9 Rivalry  (9.5)
10 X Marks the Spot  (9.5)
Top onefile Demos
1 Copper Booze  (9.9)
2 Quadrants  (9.6)
3 Elite Code Mechanics  (9.6)
4 Square Booze  (9.6)
5 Hedge of Disgrace - ..  (9.6)
6 Dawnfall V1.1  (9.5)
7 Smile to the Sky  (9.5)
8 Daah, Those Acid Pil..  (9.5)
9 Crystal Gazer  (9.4)
10 Instinct  (9.4)
Top Groups
1 Booze Design  (9.4)
2 Censor Design  (9.4)
3 Oxyron  (9.3)
4 PriorArt  (9.3)
5 Triad  (9.3)
Top Webmasters
1 Morpheus  (9.9)
2 Perff  (9.6)
3 Slaygon  (9.5)
4 Sabbi  (9.2)
5 CreaMD  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2020
Page generated in: 0.154 sec.