| |
Hypnosis
Registered: Mar 2015 Posts: 36 |
Assembler with dynamic symbol creation
I have read some documentation for an assembler that allowed labels or symbols to be created dynamically, basically by concatenating strings. Which assembler was that? |
|
... 15 posts hidden. Click here to view all posts.... |
| |
doynax Account closed
Registered: Oct 2004 Posts: 212 |
Quoting CompyxWhy would you want to do that? Usually when I run into this, my "you're doing it wrong" alarm goes off. The main place I am using it as a handy way of forwarding metadata and type information to external tools, sort of like C++ name mangling. For instance to encode breakpoints/watchpoints for VICE by running a post-processing script on the label list to transcribe magic labels into monitor commands.
Quoting Oswaldprobaby some complicated speedcode, where writing native generator would take less time than macroing the shit out of it. Indeed but also note that CA65 has scopes which often can achieve the same ends in a cleaner way, at least when operating within a single compilation unit. |
| |
Compyx
Registered: Jan 2005 Posts: 631 |
Quoting doynax Quoting CompyxWhy would you want to do that? Usually when I run into this, my "you're doing it wrong" alarm goes off. The main place I am using it as a handy way of forwarding metadata and type information to external tools, sort of like C++ name mangling. For instance to encode breakpoints/watchpoints for VICE by running a post-processing script on the label list to transcribe magic labels into monitor commands.[/quote[
I stand corrected, that does indeed sound like a valid use case.
Quoting doynax
Quoting Oswaldprobaby some complicated speedcode, where writing native generator would take less time than macroing the shit out of it. Indeed but also note that CA65 has scopes which often can achieve the same ends in a cleaner way, at least when operating within a single compilation unit.
Speedcode was my first guess, but then again, when generating speedcode, you already all you need to know about entry points or whatever and just 'poke' that in other (speed)code.
I'm kind of surprised CA65 doesn't handle scopes spread over various translation units. But since it's part of a C compiler, it makes sense, C having only a couple of namespaces/scopes. |
| |
Hypnosis
Registered: Mar 2015 Posts: 36 |
Quoting CompyxWhy would you want to do that? Usually when I run into this, my "you're doing it wrong" alarm goes off.
I think the general case is a meta programming loop with some code that has to match and reference things in another loop. I can see if I can dig up my latest exact use case. |
| |
Trash
Registered: Jan 2002 Posts: 122 |
Sometimes you have speedcode that havn't got a fixed size (and the size-changes may not be cyclic), then it is nice to be able to generate labels when generating it in order to access them from another set of speedcode. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
Quote: Sometimes you have speedcode that havn't got a fixed size (and the size-changes may not be cyclic), then it is nice to be able to generate labels when generating it in order to access them from another set of speedcode.
just store the "labels" into a table while generating speedcode A, then read the table while generating speedcode B that is referencing A. I do this all the time, and not much code in native 6510 either. |
| |
Count Zero
Registered: Jan 2003 Posts: 1932 |
AFAIR Dreamass supports that as well. |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
Quoting doynaxIndeed but also note that CA65 has scopes which often can achieve the same ends in a cleaner way, at least when operating within a single compilation unit. Doynax got a good point. Doing things with scopes often gives cleaner solutions. |
| |
Hypnosis
Registered: Mar 2015 Posts: 36 |
Quoting doynaxIndeed but also note that CA65 has scopes which often can achieve the same ends in a cleaner way, at least when operating within a single compilation unit.
How would scopes solve the problem? |
| |
Hypnosis
Registered: Mar 2015 Posts: 36 |
Creating a meta-list of addresses where the data is defined and read from the list where addresses should be used would work for my simple case. Does assemblers handle this without requiring data and code to be defined in a certain source code order? I think Kickassembler does. How about the others? |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
I don't know the functionality of CA65, but in general the solutions I have seen involving scoping seem better than those where you generate numbered labels to one big global scope. Scoping is also better than putting labels into a list yourself. In KickAss the scoping solution works well for accessing labels in executed macro calls, and I'am planning to expand the functionality to loops as well. So accessing the label of one loop from another could look like this:
.const count=25
loop1: .for(var i=0; i<count; i++) {
lda #i
sta loop2[i].color+1
}
loop2: .for(var i=0; i<count; i++) {
color: lda #0
sta $d020
}
Today you have to put your labels in a list yourself, but I find the above better.
Edit: Scoping solution = you access the scope instance of a given iteration of the loop |
Previous - 1 | 2 | 3 - Next |