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 22:51
Bago Zonde

Registered: Dec 2010
Posts: 23
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 

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.

2017-07-28 00:44

Registered: Sep 2003
Posts: 363
!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 11:17
Bago Zonde

Registered: Dec 2010
Posts: 23
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")

    .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 21:12
Bago Zonde

Registered: Dec 2010
Posts: 23
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 21:40

Registered: Dec 2001
Posts: 208
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 ;)
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
Users Online
Knut Clausen/SHAPE
Mch/Genesis Project
Digger/Elysium 🇵🇱..
Guests online: 69
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 Coma Light 13  (9.6)
4 The Shores of Reflec..  (9.6)
5 Lunatico  (9.6)
6 Quad Core 100%  (9.5)
7 Comaland 100%  (9.5)
8 Incoherent Nightmare  (9.5)
9 Wonderland XII  (9.5)
10 Comaland  (9.5)
Top onefile Demos
1 Pandemoniac Part 2 o..  (9.6)
2 Synthesis  (9.6)
3 Dawnfall V1.1  (9.5)
4 Daah, Those Acid Pil..  (9.5)
5 Field Sort  (9.4)
6 Treu Love [reu]  (9.4)
7 Dawnfall  (9.3)
8 Globe 2016 [reu]  (9.3)
9 KAOS 64  (9.3)
10 Hardware Accelerated..  (9.2)
Top Groups
1 Booze Design  (9.4)
2 Censor Design  (9.4)
3 Oxyron  (9.4)
4 Crest  (9.3)
5 Finnish Gold  (9.3)
Top Logo Graphicians
1 Pal  (9.5)
2 Yazoo  (9.3)
3 Mermaid  (9.2)
4 Elko  (9.2)
5 Jailbird  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2017
Page generated in: 0.328 sec.