• Assembly subroutines vs macros as reusable building blocks

    From Paolo Amoroso@21:1/5 to All on Fri Nov 26 06:21:47 2021
    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?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Douglas Miller@21:1/5 to All on Fri Nov 26 07:29:41 2021
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)