N2TheRed wrote:
Placeholders in assembly: How is it done?
C#Code:
SomeMethod("Point A[{0},{1}], B[{2},{3}]", a.x, a.y, b.x, b.y)
If you wanted a function that takes a string with placeholders and some data and have it build a new string, would that be complicated?
I would inline the string, and use a macro to put the string and the command all on one line, like this:
Code:
SomeMethod "'Point A[{0},{1}], B[{2},{3}]', a.x, a.y, b.x, b.y"
as discussed about a quarter of they way down the 6502 stacks treatise
page on inlining data, and then have a parser routine like Ed suggested. Actually, you might be able to have the assembler itself do most of the parsing in the macro, rather than burdening the processor so much at run time. You might have to modify the quotes method slightly to work with most macro assemblers, but it could be done. A super long macro definition doesn't necessarily lay down much machine code, if a lot of the macro is tests and decisions made at assembly time, and conditional assembly whose conditions aren't met in the particular invocation.
Macros allow raising the level of the language a lot, and we can make it imitate, to some extent, the way something would be done in a HHL. In many cases, trying to do a direct translation doesn't work nearly as well as taking a different approach to the problem though, an approach that suits the particular processor better. A really smart macro might be able to do some of this—but there are limits.