dasm-assembler / dasm-assembler/dasm
Variable number of arguments for a macro
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 257
- Forks
- 55
- PR merge metrics
- No merged PRs in 30d
Description
From the manual:
Macros are instantiated by using the macro’s name (case-insensitive),
followed by an optional list of arguments. The body of the macro definition
can refer to arguments passed with the format “{#}”, where # is replaced by
the argument number. The first argument passed to a macro is therefore {1}.
{0} represents an exact substitution of the entire instantiation line.
If a macro is instantiated with more arguments than the used ones, there is no problem, but if you try to use an argument that it was not provided, DASM raises an exception.
It could be nice a way to check for the number of arguments, for instance {N}, allowing to write macros like this:
macro addwords
clc
lda {1}
adc {2}
if {n} = 3
sta {3}
lda {1}+1
adc {2}+1
sta {3}+1
else
sta {1}
lda {1}+1
adc {2}+1
sta {1}+1
endif
endm
addwords $80,$82,$84 ; Result in $84
addwords $80,$82 ; Result in $80
NOTE: currently, {N} returns the same as {0}, i.e. the placeholder is replaced by the full list of arguments. Bug?
NOTE2: if the condition expression is a comma separated list of argments, the IF is evaluated as "true". Bug?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no source files or tests. Start by locating macro argument substitution for {0}, {1}, and {N}, then inspect how IF expressions handle comma-separated arguments. Done means macros can branch on their argument count and the documented two- and three-argument examples assemble correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100