Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Brizio ! (Registered 2017-08-20) 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: 21
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-28 00:44
soci

Registered: Sep 2003
Posts: 357
!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: 21
@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 21:12
Bago Zonde

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

Registered: Dec 2001
Posts: 203
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
Advanced
Users Online
Rebok
c0zmo/BLiSS
MetalSoftwareService
TWW/Creators
aNdy/AL/Cosine
Dwangi/Fairlight
Nucleus/Desire
Harpoon
Guests online: 50
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 Comaland 100%  (9.5)
7 Incoherent Nightmare  (9.5)
8 Wonderland XII  (9.5)
9 Comaland  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 Veterans of Style  (9.5)
2 Dawnfall V1.1  (9.5)
3 Daah, Those Acid Pil..  (9.5)
4 Treu Love [reu]  (9.4)
5 Dawnfall  (9.3)
6 SidRok  (9.3)
7 F1 Evolution  (9.3)
8 One-Der  (9.2)
9 Tunnel Vision  (9.2)
10 Game of Thrones [2sid]  (9.1)
Top Groups
1 Pond  (10)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Oxyron  (9.4)
5 Crest  (9.3)
Top Fullscreen Graphicians
1 Veto  (9.8)
2 Joe  (9.8)
3 Mirage  (9.7)
4 Jailbird  (9.6)
5 Hein  (9.5)

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