Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in 
CSDb User Forums


Forums > C64 Coding > Passing immediate or absolute value to macro in ACME?
2017-07-27 20:51
Bago Zonde

Registered: Dec 2010
Posts: 28
Passing immediate or absolute value to macro in ACME?

I've posted this topic on Lemon64 forum already, but actually I should try here first so sorry for my mistake, I'm going to burn in hell afterwards!

Could you tell me guys, is it possible to pass the immediate or absolute value to macro in ACME?

In 64tass you can do:

myMacro #11 
myMacro 11 

myMacro .macro value 
   lda \value 
.endm


Which will load #11 to accumulator in first case, and value under $0011 in the second case.

I tried to do something similar with macros in ACME (0.91 then I've found 0.96 version, heh) but it doesn't work as expected. I tried to pass by reference using tilda (~) and some other variants, but no luck. I haven't investigated it thoroughly though, just played a little bit. I can create separate macros, but then I will end up with not that clear macros set.

I don't want that someone will feel I'm an ignorant asking so basic question, but the thing is that 64tass is my cross-assembler of choice and I don't have good knowledge about ACME. The reason I've picked up ACME is that I work on cross-assembler-wide c64unit test framework which supports 64tass, Kick Assembler and DASM already. I've learned basics of Kick Assembler and DASM the hard way for this purpose as I came from 64tass world ;) and I think I just don't have more steam to investigate all tweaks of another cross-assembler, which is ACME in this case :D.

The repo is here: https://bitbucket.org/Commocore/c64unit but I haven't announced it yet officially (I just put some note: http://commocore.com/news/c64unit-beta-is-coming) as far as there is a lack of some functionality still. I'm going to release beta version soon, so please help me in any case, I hope to get a feedback regarding proposed solutions for each cross-assembler, and to get some ideas how this framework can be used for testing purposes on your lovely C64.

www.commocore.com
2017-07-27 22:44
soci

Registered: Sep 2003
Posts: 385
!macro can pass the following things:

- A value of an expression (integer or float).
- A label reference.

So a "#" will not go through.

Possible workaround:
!macro myMacro .immediate, .param {
 !if .immediate {
  lda #.param
 } else {
  lda .param
 }
}

+myMacro 0, 100 ; lda 100
+myMacro 1, 100 ; lda #100
2017-07-29 09:17
Bago Zonde

Registered: Dec 2010
Posts: 28
@soci
Parameterizing is a very good workaround indeed. And it would work perfectly to pass only two parameters to macro. But, this was just an example to show the problem, and for the "real world" example I have 3 parameters in macro already.

I overcame the same issue with Kick Assembler, where I used CmdArgument() to pass AT_IMMEDIATE, or AT_ABSOLUTE which seems to be a nice feature, but then I have something like this in Kick Assembler:

assertGreaterOrEqual(CmdArgument(AT_IMMEDIATE, 50), CmdArgument(AT_ABSOLUTE, result), "i say that 50 isn't >= than actual")


...compared to exactly the same equivalent in 64tass:

assertGreaterOrEqual #50, result, "i say that 50 isn't >= than actual"


Well... not that bad, but Kick Assembler version doesn't seem to be user friendly :).

After playing a little bit with different cross-assemblers and thanks to your help with realizing about constraints here, I did one step back to think about the design and see all usages.

Eventually I don't know if I'm going the right direction, but it seems that passing absolute value as an expected makes no sense. So far, I found only one example where it can be useful: https://bitbucket.org/Commocore/c64unit-examples/src/dd8370a2ae..

Well... To solve it I can create custom assertion to check stack pointer, or introduce absolute assertions, like the equivalent of immediate assertion for assertEqualToX:

assertAbsoluteEqualToX(stackPointer, "stack pointer not equal")

stackPointer:
    .byte 0


Maybe this set of absolute macros can introduce more flexibility for tests, though DASM and 64tass doesn't need them :).
I thought the design part of making this framework will be slightly easier, but at the end something still easy to resolve :).
2017-07-30 19:12
Bago Zonde

Registered: Dec 2010
Posts: 28
I've resolved this issue by creating two sets of functions, for immediate and absolute usage, e.g.:

+assertEqual 10, result
+assertAbsoluteEqual addressMemory, result


I also dropped CmdArgument in KickAssembler and introduced the same idea. Simplified!

It's bad that I cannot pass string in macro for ACME though...

Thanks for a suggestion!
2017-07-30 19:40
Copyfault

Registered: Dec 2001
Posts: 238
With Kickass you might try ".pseudocommand", which is a special macro for use with different opcode-alike arguments.

With ACME I don't know... the most elegant way is very much as you did it with different macros for different adressing modes. Another point for the ACME wish list ;)
2017-10-28 09:58
Han

Registered: Apr 2017
Posts: 8
Quoting Bago Zonde
I overcame the same issue with Kick Assembler, where I used CmdArgument() to pass AT_IMMEDIATE, or AT_ABSOLUTE which seems to be a nice feature, but then I have something like this in Kick Assembler:
assertGreaterOrEqual(CmdArgument(AT_IMMEDIATE, 50), CmdArgument(AT_ABSOLUTE, result), "i say that 50 isn't >= than actual")

How about packing the CmdArgument-Expression into functions to make it more readable:
.function ARGIMM(value) { .return CmdArgument(AT_IMMEDIATE, value) }
.function ARGABS(value) { .return CmdArgument(AT_ABSOLUTE, value) }
That reduces your call to
assertGreaterOrEqual(ARGIMM(50), ARGABS(result))
2017-10-28 10:42
TWW

Registered: Jul 2009
Posts: 433
Quoting Bago Zonde
@soci
Well... not that bad, but Kick Assembler version doesn't seem to be user friendly :).


Coding isn't supposed to be user friendly ;-)
2018-01-02 20:52
Bago Zonde

Registered: Dec 2010
Posts: 28
Quoting Han

How about packing the CmdArgument-Expression into functions to make it more readable:
.function ARGIMM(value) { .return CmdArgument(AT_IMMEDIATE, value) }
.function ARGABS(value) { .return CmdArgument(AT_ABSOLUTE, value) }

That reduces your call to
assertGreaterOrEqual(ARGIMM(50), ARGABS(result))


I dropped CmdArgument() as I've found that values are treated as immediate, and any variable names as absolutes. Easy!
Other thing is that from the use case perspective, the most common and natural way is just to pass immediate value as the first argument but still, both will work just this way, no need for CmdArgument:

assertGreaterOrEqual(11, myRegister, "") // pass immediate value of #11 

assertGreaterOrEqual(calculatedSomewhere, myRegister, "") // pass value under calculatedSomewhere register 


So, most likely I would use the first one, as in testing world, most often you're not going to pass absolute, calculated on run-time variables, but rather you're just expecting particular values you already know ("expecting"). This is what I've noticed by wrapping my head around ;). But well, both options are available up to the needs. You'll find some details here: https://bitbucket.org/Commocore/c64unit#markdown-header-532-fun..

After fully covered 64tass, ACME, DASM and KickAssembler, I think that xa65 & ca65 is the next one. I haven't look what's there really. Any other cross-assembler support suggestions?

www.commocore.com
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Andy/AEG Soft
saimo
Pad/Atlantis
Tom-Cat/Nostalgia
Danzig/Guilty
psych858o/MSL/Elysiu..
Poison/Singular Crew
Guests online: 47
Top Demos
1 Uncensored  (9.7)
2 Comaland 100%  (9.7)
3 Edge of Disgrace  (9.7)
4 Coma Light 13  (9.6)
5 The Shores of Reflec..  (9.6)
6 Wonderland XII  (9.6)
7 We Come in Peace  (9.6)
8 Lunatico  (9.6)
9 Incoherent Nightmare  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 FMX Music Demo  (9.5)
2 Pandemoniac Part 2 o..  (9.5)
3 Daah, Those Acid Pil..  (9.5)
4 Dawnfall V1.1  (9.5)
5 Treu Love [reu]  (9.5)
6 In Memoriam BHF  (9.5)
7 Merry Xmas 2017  (9.4)
8 Dawnfall  (9.4)
9 SWiRL  (9.4)
10 Synthesis  (9.4)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Finnish Gold  (9.4)
5 Crest  (9.3)
Top Original Suppliers
1 hedning  (9.7)
2 Derbyshire Ram  (9.3)
3 Jazzcat  (9.1)
4 Irata  (9.0)
5 Fungus  (9.0)

Home - Disclaimer
Copyright © No Name 2001-2018
Page generated in: 0.059 sec.