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 > Kick Assembler Thread 2
2009-07-21 17:20
Slammer

Registered: Feb 2004
Posts: 448
Kick Assembler Thread 2

The previous thread took a little long to load, so this is a new fresh one..
 
... 646 posts hidden. Click here to view all posts....
 
2025-06-03 22:11
Slammer

Registered: Feb 2004
Posts: 448
Quoting cobbpg

In a bit similar vein, another thing that came up recently was the desire to implement segment modifiers as functions inside the scripting language instead of having to make a Java plugin. This would make it easy to spit out assembled structures in particular custom formats without having to implement and/or invoke external tools (e.g. cartconv).


I have started doing script segment modifiers. As i use segmentmodifiers for something different, and rarely uses cartconv etc, it would be nice with some input of which kind of formats people want supported before the first version is out. So this is your chance to influence the design.

Current POC looks like this:
//------------------------------------------------------
// Use
//------------------------------------------------------

    .segmentout[modify="AddMoveData", segments="Player,Music,Test"] 
data:

//------------------------------------------------------
// The modifier 
// (a macro with an auto included segment variable)
//------------------------------------------------------

.segmentmodifier AddMoveData() {
    .var blocks = segment.getMemoryBlocks()
    .foreach (block in blocks) {
        .fill block.bytes
        .word block.bytes.size()-1
        .word block.start+block.bytes.size()-1
    }
    .byte blocks.size()	
}

//------------------------------------------------------
// Some data to modify
//------------------------------------------------------

.segment Test [start=$5000]
.byte 1,2,3,4,5


.segment Music [sidFiles="data/music.sid"]


.segment Player[start = $8000]
player: {
    sei
    lda #0
    tax
    tay
    jsr $1000
	
l:  lda #$f0
    cmp $d012
    bne *-3
    inc $d020
    jsr $1003
    dec $d020
    jmp l
}
2025-06-04 07:56
TWW

Registered: Jul 2009
Posts: 555
2 things;

#1: Absolutely love this. Things which pops to mind;
- swapped bit structure (like #$ab is written to a disk file segment as #$37 (example only))
- Converted binary of a image packed to a disk file
- Protected data which require a key to decipher

#2: Did I hear version?? In that case would it be possible to allow one or two additional passes to resolve labels (if that indeed would fix the issue)?

No-sense Example:
    .if (TestLabel == $1000) {
        lda #$00
        sta $d020
    } else {
        lda #$00
        sta $d020
        sta $d021
    }

TestLabel:



This would for example allow pseudocommands automatically select long branches (forwards) for example or make "optimizations" where an immediate value passed to a mov16 command which has the same hi and lo byte be optimized (and there were other usecases as well but can't remeber of the top of my head).
2025-06-04 19:55
cobbpg

Registered: Jan 2022
Posts: 45
Quoting Slammer
.segmentmodifier AddMoveData() {
    .var blocks = segment.getMemoryBlocks()
    .foreach (block in blocks) {
        .fill block.bytes
        .word block.bytes.size()-1
        .word block.start+block.bytes.size()-1
    }
    .byte blocks.size()	
}


This looks good to me as is! I don't think there's need for anything more specific, since getting access to the raw data provides all the flexibility one needs.

Is block.bytes the same type of object you get from e.g. LoadBinary? Also, what's that single-argument .fill directive? I don't think I've seen that kind of usage mentioned anywhere. Is that .foreach a new general looping construct?
2025-06-05 07:48
Slammer

Registered: Feb 2004
Posts: 448
Quoting cobbpg


This looks good to me as is! I don't think there's need for anything more specific, since getting access to the raw data provides all the flexibility one needs.

Is block.bytes the same type of object you get from e.g. LoadBinary? Also, what's that single-argument .fill directive? I don't think I've seen that kind of usage mentioned anywhere. Is that .foreach a new general looping construct?


block.bytes is simply a list - like the one you create by 'List()'.

.foreach and .fill: One of the upcomming features are iterators (which lists support.). The new .foreach directive iterates through one (or multiple) 'iterables' and has support for easy filtering and enumeration. The POC shows the simple standard use, but you can du stuff like '.foreach (p in persons if p.age>27) { ... }' and thats the reason we don't follow the java-syntax this time. The .fill directives now assumes its an iterator if only one argument is given.
2025-06-05 08:29
Krill

Registered: Apr 2002
Posts: 3083
Slammer: One thing i miss in my two go-to assemblers 64tass and ca65, and which i haven't seen in any other 6502 assembler so far, is... *drumrolls*

a .float directive emitting BASIC 5-byte floats.

Like this
baseline:   .float .39 ; kBps KERNAL LOAD throughput (1x speed)
would be equivalent to
baseline:   .byte $7f,$47,$de,$23,$10
but a lot more convenient for the user. I reckon this would not be terribly hard to add? =) (Planning to pester Soci about this.)
2025-06-05 12:24
Slammer

Registered: Feb 2004
Posts: 448
Quoting Krill
Slammer: One thing i miss in my two go-to assemblers 64tass and ca65, and which i haven't seen in any other 6502 assembler so far, is... *drumrolls*

a .float directive emitting BASIC 5-byte floats.

Like this
baseline:   .float .39 ; kBps KERNAL LOAD throughput (1x speed)
would be equivalent to
baseline:   .byte $7f,$47,$de,$23,$10
but a lot more convenient for the user. I reckon this would not be terribly hard to add? =) (Planning to pester Soci about this.)


What do you need it for? (Usecases?)

My impression is that Soci is good at what he is doing. If you manage to convince him I'm sure you will have it in no time.
2025-06-05 14:29
Krill

Registered: Apr 2002
Posts: 3083
Quoting Slammer
What do you need it for? (Usecases?)
Working with the ROM float routines, ofc.

Came in handy with data throughput calculation with Transwarp, some precalc stuff in Artefacts, and lately, on 80-column PET, calculating FPS from cyclecount between VSYNC signals, e.g.
2025-06-05 17:05
Slammer

Registered: Feb 2004
Posts: 448
Quoting Krill
Quoting Slammer
What do you need it for? (Usecases?)
Working with the ROM float routines, ofc.

Came in handy with data throughput calculation with Transwarp, some precalc stuff in Artefacts, and lately, on 80-column PET, calculating FPS from cyclecount between VSYNC signals, e.g.


Ok, What I was trying to figure out is if it was a one time occurance. Giving it a .float directive feels wrong (Like mixes two worlds) but I guess thats a matter of taste. If someone needed it in Kick Assembler I think I would make a getExponentBits(d) and getMantissaBits(d) and then it would be possible to make a macro that produced any float format you like. A name like BasicFloat(f) would be in line with BasicUpstart() and people could handle cornercases if any (nan? Inf?) like they want.
2025-06-05 21:27
Slammer

Registered: Feb 2004
Posts: 448
Quoting TWW


#2: Did I hear version?? In that case would it be possible to allow one or two additional passes to resolve labels (if that indeed would fix the issue)?

No-sense Example:
    .if (TestLabel == $1000) {
        lda #$00
        sta $d020
    } else {
        lda #$00
        sta $d020
        sta $d021
    }

TestLabel:



This would for example allow pseudocommands automatically select long branches (forwards) for example or make "optimizations" where an immediate value passed to a mov16 command which has the same hi and lo byte be optimized (and there were other usecases as well but can't remeber of the top of my head).



This one is complicated. I don't think the general case gonna happend anytime soon. There is the classic problem of, what will you do here:
	*=$1000-8
    .if (TestLabel == $1000) {
        lda #$00
        sta $d020
    } else {
        lda #$00
        sta $d020
        sta $d021
    }

TestLabel:


You could try one of the possibilities and then adjust back and forth, and then let the progress detection catch it and make a 'no progress error', but these are rather confusing since 'Why wasn't there any progress?'. A second reason is that the switching back and forth works poorly together with the caching mechanism (Results from previous passes are reused in later passes so heavy calculation are only done once and not once pr pass)

However I have given some thoughts to supporting specialized cases (You mentioned the branch distance problem)
2025-06-07 11:23
Krill

Registered: Apr 2002
Posts: 3083
Quoting Slammer
Ok, What I was trying to figure out is if it was a one time occurance.
Certainly not one-time in my world (if so, it wouldn't have occured to me to bring this up here :D).
Float computations keep popping up in instrumentation and small demos (anything <= 4 KB).

Quoting Slammer
Giving it a .float directive feels wrong (Like mixes two worlds) but I guess thats a matter of taste.
There is the .dword directive, and 32-bit integers arguably aren't native to the architecture either.

40-bit float math comes readily available with the BASIC ROMs of all 6502-based Commodore computers (and quite a few other 8-bit machines running Microsoft BASIC, too).

Quoting Slammer
If someone needed it in Kick Assembler I think I would make a getExponentBits(d) and getMantissaBits(d) and then it would be possible to make a macro that produced any float format you like.
I assumed macros to be a possibility already, but they're rather cumbersome for something that is quite native to the platform (not its CPU architecture) and should, imho, be expressible with a first-class directive.

But yeah, with macros and functions doing the job, it remains a mere nice-to-have.
Previous - 1 | ... | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 - 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
MWR/Visdom
iceout/Avatar/HF
Guests online: 342
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 Logo Graphicians
1 t0m3000  (10)
2 Sander  (9.8)
3 Shine  (9.5)
4 Mermaid  (9.5)
5 Pal  (9.4)

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