| |
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.... |
| |
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
} |
| |
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). |
| |
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? |
| |
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. |
| |
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 thisbaseline: .float .39 ; kBps KERNAL LOAD throughput (1x speed) would be equivalent tobaseline: .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.) |
| |
Slammer
Registered: Feb 2004 Posts: 448 |
Quoting KrillSlammer: 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 thisbaseline: .float .39 ; kBps KERNAL LOAD throughput (1x speed) would be equivalent tobaseline: .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. |
| |
Krill
Registered: Apr 2002 Posts: 3083 |
Quoting SlammerWhat 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. |
| |
Slammer
Registered: Feb 2004 Posts: 448 |
Quoting KrillQuoting SlammerWhat 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. |
| |
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) |
| |
Krill
Registered: Apr 2002 Posts: 3083 |
Quoting SlammerOk, 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 SlammerGiving 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 SlammerIf 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 |