Jump to content
IGNORED

Macros (I wish I new about them sooner on)


Recommended Posts

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 :sad:

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...

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 by Gorf
Link to comment
Share on other sites

  • 2 months later...

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.

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...