Multijointed Monster Maker Posted March 9, 2010 Share Posted March 9, 2010 For you other programmers on this website, how long did it take you before you found out what a macro was? I've been programming over a year, and gotten almost nowhere, until I learned how to use macros. Now I'm using almost all my code is macros and it's taking me far less time to program. Quote Link to comment Share on other sites More sharing options...
Sub(Function(:)) Posted March 9, 2010 Share Posted March 9, 2010 I found out quite quickly. I was programming Z80 at the time and wrote a macro to add an offset to the contents of HL register pair, as I remember. Sort of indirect indexing. However my epiphany was the "linker". This allows me to write and build subroutines and libraries of code then reuse the code later as a binary (no need to reassemble) Oh yes and "makefiles" really cool stuff. It was 20, and some, years ago now Quote Link to comment Share on other sites More sharing options...
TMR Posted March 12, 2010 Share Posted March 12, 2010 A quarter of a century writing 6502 and i've never used macros. Quote Link to comment Share on other sites More sharing options...
Multijointed Monster Maker Posted March 12, 2010 Author Share Posted March 12, 2010 A quarter of a century writing 6502 and i've never used macros. What systems have you programmed before? I find Super Nintendo to be very tedious to program without using macros. Quote Link to comment Share on other sites More sharing options...
TMR Posted March 13, 2010 Share Posted March 13, 2010 A quarter of a century writing 6502 and i've never used macros. What systems have you programmed before? I find Super Nintendo to be very tedious to program without using macros. Code released for VIC 20, C64, Plus/4, PET, C64DTV and Atari 8-bit series, almost complete code on Atari 2600 and NES and some experimentation on the BBC Micro and a couple of others. Quote Link to comment Share on other sites More sharing options...
Rybags Posted March 13, 2010 Share Posted March 13, 2010 I don't use them a great deal. They can potentially lead to lazy, unnecessarily bloated code. Quote Link to comment Share on other sites More sharing options...
PeteD Posted April 27, 2010 Share Posted April 27, 2010 I love macros But not to the point that some people use them that makes code unreadable. I don't use them much on 8bit stuff because it's unlikely I'll be doing big swathes of repeated code. I say keep them simple just to save repetitive typing and make source code easier to read. Some people go insane and have crazy formulaic ones and you have no clue looking at the code that calls the macro wtf is supposed to be happening. Pete Quote Link to comment Share on other sites More sharing options...
JamesD Posted April 28, 2010 Share Posted April 28, 2010 I love using macros in an editor but not so much for coding. The more advance the CPU the less you have to gain from macros. They would be much more useful on a 6502 than a 68000 for example. A small number of special purpose registers and the need for a lot of repeated functions (16 bit add for example) makes the 6502 a very good target for macros. But you don't need a macro to do the same thing on a 68000... or even a 6809 or 6803. The use of macros *can* leave to bloated code if you over use them because they tend to be general purpose and a routine directly targeted at a specific piece of code may not require all the instructions in a macro. But that does not have to be the case. There are several reasons *I* avoid using macros. Macro support from one assembler to the next varies a lot and I usually have to switch assemblers based on a project. I don't get to choose the tools I have to use at work. I haven't been doing enough hobby stuff on any one machine to really get used to the quirks of a specific assembler. It usually takes longer to write a good macro than to cut an paste an existing piece of code. Code is usually easier to follow without macros. There are some govt standards that don't allow their use. It's better for me that I don't get in the habit of using them. But then there are some projects where they want you to use macros or templates. Templates don't really apply to assembly but they a really good example of just how powerful macros can be. Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted April 28, 2010 Share Posted April 28, 2010 I mainly use them for generating data tables. In my mind it makes the code look neater. It also means that if you change something in the table, reorder it or add an element its much easier to make changes. Quote Link to comment Share on other sites More sharing options...
roland p Posted April 28, 2010 Share Posted April 28, 2010 The more I get used to assembly the less I use them. But there are just cases where they are really useful. Like a sleep macro, or the macros that insert code for handling the tv synchronisation signals (2600 stuff). Quote Link to comment Share on other sites More sharing options...
Gorf Posted June 27, 2010 Share Posted June 27, 2010 (edited) I dont make use of them and really did not use them until the Jag risc chips. There are a few reasons why I used them. One was to make a psuedo JSR and RTS instruction, which I dont use anymore and the only ones I actually use now are simply to make padding GPU main RAM code modules between code pages look neater. Outside of this though, there is no real good use for them that I have found. Your mileage may vary. Edited June 27, 2010 by Gorf Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted September 17, 2010 Share Posted September 17, 2010 I'm with GroovyBee/roland p; I use them in a limited fashion for some data tables and for a very few other things (SLEEP, CLEAN_START). I think too many macros makes the code very difficult to read; for the 2600, also, where you frequently need to optimize and rearrange data at a byte level, macros are too blunt. Quote Link to comment Share on other sites More sharing options...
intvnut Posted September 27, 2010 Share Posted September 27, 2010 I'm with GroovyBee/roland p; I use them in a limited fashion for some data tables and for a very few other things (SLEEP, CLEAN_START). I think too many macros makes the code very difficult to read; for the 2600, also, where you frequently need to optimize and rearrange data at a byte level, macros are too blunt. I'll chime in in this direction also. I mainly use macros for data tables and other data-related stuff. I rarely (but not never) use them for code. Macros hide too much of what the code is doing, which can lead to inefficiency or strange surprises. They do make sense in a few places to eliminate some tedium, but only a few. For data, they insulate the data encoding from what's being encoded, allowing you to quickly change the encoding if necessary. When I wrote Space Patrol, I ended up re-encoding several data structures multiple times until I got things the way I wanted them. Because I hid the encoding behind a macro, I just had to update the affected macros. The data tables stayed put. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.