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 > Assembler with dynamic symbol creation
2016-06-12 06:19
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?
2016-06-12 07:27
doynax
Account closed

Registered: Oct 2004
Posts: 212
CA65 supports this, as do a few others I expect. If push comes to shove you can always do ad-hoc meta-programming or preprocessing by adding external tools to the build process.

In CA65 the syntax is something along these lines:
	.mac smc_store name
ident(.concat(.string(name), "_value")) := *+1
	lda #$00
ident(.concat(.string(name), "_addr")) := *+1
	sta a:$0000
	.endmac
2016-06-12 08:29
Hypnosis

Registered: Mar 2015
Posts: 36
Ah, there it is. Thanks!
2016-06-12 17:08
Compyx

Registered: Jan 2005
Posts: 631
Why would you want to do that? Usually when I run into this, my "you're doing it wrong" alarm goes off.

There might be a valid use for this, but I'm not seeing it.
2016-06-12 17:47
Oswald

Registered: Apr 2002
Posts: 5094
probaby some complicated speedcode, where writing native generator would take less time than macroing the shit out of it.
2016-06-12 18:37
MagerValp

Registered: Dec 2001
Posts: 1078
For example if you want a small DSL for writing display lists, like this one here: https://twitter.com/MagerValp/status/741681367516340224
2016-06-12 18:44
doynax
Account closed

Registered: Oct 2004
Posts: 212
Quoting Compyx
Why 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 Oswald
probaby 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.
2016-06-12 21:13
Compyx

Registered: Jan 2005
Posts: 631
Quoting doynax
Quoting Compyx
Why 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 Oswald
probaby 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.
2016-06-13 05:25
Hypnosis

Registered: Mar 2015
Posts: 36
Quoting Compyx
Why 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.
2016-06-13 06:51
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.
2016-06-13 09:39
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.
 
... 15 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 | 3 - 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
csabanw
Metal Maniac/Dual Crew
Xiny6581/Dees Produc..
Jazzcat/Onslaught
Operator Teleksu
algorithm
El Jefe/Slackers^sidD
Dan
MWR/Visdom
McGurk/Coma
Morpheus/IPC+C64.COM
E$G/HF ⭐ 7
Guests online: 102
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 No Listen  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Graphicians
1 Mirage  (9.8)
2 Archmage  (9.7)
3 Pal  (9.6)
4 Carrion  (9.6)
5 Sulevi  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.053 sec.