Author Topic: Macro fails, but script works?  (Read 3062 times)

0 Members and 1 Guest are viewing this topic.

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Macro fails, but script works?
« on: June 28, 2011, 11:18:23 am »
This... is odd, I'm using AppDev (DWedit ?) for creating apps, but it's crashing when changing a certain macro.
This still works fine:
Code: [Select]
#define N1_R1 CALL Something1
#defcont \ CALL New1
#define N2_R1 CALL Something1
#defcont \ CALL New2
#define N3_R1 CALL Something1
#defcont \ CALL New3
#define N4_R1 CALL Something1
#defcont \ CALL New4
But as soon as I add one more:
Code: [Select]
(...)
#define N4_R1 CALL Something1
#defcont \ CALL New4
#define N5_R1 CALL Something1
#defcont \ CALL New5
It crashes. It's not the "New5" thingy, since it does the same for 6 and up, and when removing one earlier macro it does work fine with "5" and up. Now, this could indicate that the maximum number of macro's has been reached, however this is not the case. It can hold up to 1000 macros, and it's still far from. Plus, when adding many other macros it still works like a charm.
And what's even weirder, when using the macro to run a CALL containing both lines, line this:
Code: [Select]
#define N6_R1 CALL DoBoth
(...)
DoBoth:
     CALL     Something1
     CALL     New6
ret
it works fine again. Can go all the way from 1-w/e with that. (Though I guess it's faster and shorter to use the two CALLs in a row, rather than making a small routing doing both CALLs, right?). It's not the scripts which are being called either - with any other macro substituting for those it works fine. Am I missing something?

Thanks in advance!
« Last Edit: June 30, 2011, 03:45:27 am by Jerros »


79% of all statistics are made up randomly.

Offline BuckeyeDude

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 283
  • Rating: +42/-0
    • View Profile
Re: Macro fails, but script works?
« Reply #1 on: June 30, 2011, 07:19:00 am »
My guess is its a bug in TASM. One thing to check would be stupid things like your line ending, making sure you're not redefining something, etc. How #defines work are whatever text is within the define is essentially copied and replaced whenever you use it.  Also I'm obligated to pimp SPASM as a compatible TASM-replacement, especially if you want to be able to do more with macros.

You're correct doing call x \ call x is faster as it removes the 17 or whatever clocks of doing the other call, but if you're calling any of these a lot then your DoBoth will save you some space (3 bytes per call assuming you have more than 2 calls). My reccomendation would be to go with your original macros unless you're really pressed for space, which I highly doubt you are.

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Re: Macro fails, but script works?
« Reply #2 on: June 30, 2011, 01:01:26 pm »
Thank you, I'll check out SPASM then, though AppDev worked fine... or at least it used to. ><
So it's faster/less bytes to do:
Code: [Select]
     CALL     Meh1
     CALL     Meh2
than:
Code: [Select]
(...)
     CALL     LAbel
(...)

LAbel:
     CALL     Meh1
     CALL     Meh2
ret
when needing to use Meh1 --> Meh2 in a row a couple of times?

As for the space issue, the app is already 5 pages big, and wel... as usual, the smaller the better. :P Though if the other way's better then I'll stick to that.
« Last Edit: June 30, 2011, 01:04:44 pm by Jerros »


79% of all statistics are made up randomly.

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: Macro fails, but script works?
« Reply #3 on: July 11, 2011, 02:47:50 am »
With tasm, the content of a macro definition cannot exceed 511 characters (useless spaces|tabs included).
If you have a little more characters, tasm will output a typical error message.
If you have a lot more characters, tasm will simply crash (not handled at all).

In the case you have lots of identical contiguous bytes|words to declare, the .fill directive can help.