Assembly subroutines vs macros as reusable building blocks

64 views
Skip to first unread message

Paolo Amoroso

unread,
Nov 26, 2021, 9:21:48 AM11/26/21
to
I'm reading the CP/M Assembly development books "CP/M Assembly Language Programming" by Ken Barbier and "Mastering CP/M" by Alan Miller, which are interesting also for their their different approaches to reusable code building blocks. Barbier builds a library of subroutines, Miller focuses on macros.

Back in the day, what building blocks were more common or recommended, macros or subroutines? What were the best practices?

Douglas Miller

unread,
Nov 26, 2021, 10:29:42 AM11/26/21
to
Some reasons that I would shy away from macros were that the DRI assemblers did not cleanly show the macros in the listing file (I think "$*MACRO" got close, but was still messy), Macros inline the code so can lead to unexpectedly large binaries, and the DRI macro facility was never quite as robust as I wanted. But, I did use macros plenty, and certainly leveraged the Z80.LIB macros extensively. It's my opinion that macros have a place, as do subroutines, and so it's just a matter of picking the right approach for the situation. There are even hybrid approaches, where macros "soften" the function calls but subroutines avoid code bloat (a macro handles/hides the setup for the subroutine call, but there is still a subroutine library required) - more akin to a high-level-language.
Reply all
Reply to author
Forward
0 new messages