carlsson Posted August 31, 2021 Share Posted August 31, 2021 I have an application where I want to use macros to generate music. As long as I only need one note at a time, it is quite straightforward: mac c .byte 1+({1}-1)*12 endm mac c# .byte 2+({1}-1)*12 endm mac d .byte 3+({1}-1)*12 endm mac d# .byte 4+({1}-1)*12 endm mac e .byte 5+({1}-1)*12 endm mac f .byte 6+({1}-1)*12 endm mac f# .byte 7+({1}-1)*12 endm mac g .byte 8+({1}-1)*12 endm mac g# .byte 9+({1}-1)*12 endm mac a .byte 10+({1}-1)*12 endm mac a# .byte 11+({1}-1)*12 endm mac h .byte 12+({1}-1)*12 endm mac b .byte 12+({1}-1)*12 endm mac quiet .byte 0 endm However I want to generate two channels of music at the same row, i.e. A 3, E 4. With the above definitions, the macro for A is called, it consumes the 3 as its {1} parameter and leaves the rest. I also tried to write a macro so I could use something like NOTE(A 3),NOTE(E 4) but that didn't assemble, or at least my naive way of implementing it was not enough: mac note {1} {2} endm Temporarily, I solved this problem by replacing every comma with newline and a few extra tab stops so it is one macro per line. It doesn't look pretty or easy to read, but at least it assembles. I'm using DASM 2.20.10 from 2004, perhaps there is a newer version that has more advanced handling of arguments? I kind of remember I used to hack DASM before so one could call a macro with fewer arguments than it expects and zero the rest, but that is not quite what I want anyway. Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted August 31, 2021 Share Posted August 31, 2021 You are missing a ".byte" and the comma between the values. Link to comment Share on other sites More sharing options...
carlsson Posted August 31, 2021 Author Share Posted August 31, 2021 (edited) Close, but no cigar. But thank you for leading me onto the correct path. This solution works as I expect it: mac note {1} {2} endm called with the following syntax in the music data: note A 3 , E 4 Edited August 31, 2021 by carlsson 2 Link to comment Share on other sites More sharing options...
Recommended Posts