31 March 2021, 16:02 | #1 |
Mostly Harmless
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,109
|
vasm - symbols in label names?
I have some unrolled loops that look a bit like this, with the loop body in a macro 'TDMR1COL'.
Code:
move.l .td_mr1_jt(pc,d5.w),a5 jmp (a5) .td_mr1_jt: dc.l .td_mr1_1 dc.l .td_mr1_2 dc.l .td_mr1_3 dc.l .td_mr1_4 dc.l .td_mr1_5 dc.l .td_mr1_6 dc.l .td_mr1_7 dc.l .td_mr1_8 TDMR1COL: MACRO .td_mr1_\1: ... ENDM TDMR1COL 8 TDMR1COL 7 TDMR1COL 6 TDMR1COL 5 TDMR1COL 4 TDMR1COL 3 TDMR1COL 2 TDMR1COL 1 Is there a way to set up something like this with a REPT (or two) in vasm? I can't see a way to construct the .td_mr1_X labels automatically by including a symbol generated from the repeat count in a label name, either a REPTN or a SET-value. |
31 March 2021, 16:39 | #2 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,410
|
I'd be really interested in knowing if this is possible as well. I've not found any way to do it, but that doesn't mean it can't be done
|
31 March 2021, 21:21 | #3 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
It is possible, although not in a very elegant way. If you look into the mot-syntax documentation you see that the special macro argument
\<symbolname>is supported (same syntax as Devpac?). It will insert the current decimal value of the absolute symbol with that name. So you can solve the problem by defining a helper-macro, like Code:
TDMR1COL_REPTN macro CNT set 8-REPTN TDMR1COL \<CNT> endm Code:
rept 8 TDMR1COL_REPTN endr |
31 March 2021, 21:29 | #4 |
Registered User
Join Date: Sep 2019
Location: Leicester / England
Posts: 201
|
This is pretty much what I used to do in Devpac.
I've put some tabs in your code and added an 'rts' into your macro: Code:
moveq #4,d5 ; Just so this is within the table. move.l .td_mr1_jt(pc,d5.w),a5 jmp (a5) .td_mr1_jt: dc.l .td_mr1_1 dc.l .td_mr1_2 dc.l .td_mr1_3 dc.l .td_mr1_4 dc.l .td_mr1_5 dc.l .td_mr1_6 dc.l .td_mr1_7 dc.l .td_mr1_8 TDMR1COL MACRO .td_mr1_\1: rts ENDM TDMR1COL 8 TDMR1COL 7 TDMR1COL 6 TDMR1COL 5 TDMR1COL 4 TDMR1COL 3 TDMR1COL 2 TDMR1COL 1 Code:
vasmm68k_mot -devpac -Fhunkexe test.s -o test And get the following result: Code:
vasm 1.8j (c) in 2002-2020 Volker Barthelmann vasm M68k/CPU32/ColdFire cpu backend 2.3n (c) 2002-2020 Frank Wille vasm motorola syntax module 3.14c (c) 2002-2020 Frank Wille vasm hunk format output module 2.13 (c) 2002-2020 Frank Wille CODE(acrx2): 56 bytes |
01 April 2021, 09:10 | #5 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,410
|
Ah, of course!
For some reason I thought REPTN couldn't be used as a macro argument Good to know it can. |
01 April 2021, 11:29 | #6 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
So when you call the original macro as TDMR1COL REPTN, you will get eight times the same label .td_mr1_REPTN:as REPTN is regarded being part of the label name. Therefore you have to use \<symbol>within the macro to make the parser insert the current symbol's value instead. It has nothing to do with any argument given to the macro. EDIT: Maybe I confused you by designating \<symbol>as "special macro argument", like all other codes starting with '\' within a macro. These escape codes always insert some text, but only in some cases this text will be directly taken from an argument given to the macro. Refer to the documentation. Last edited by phx; 01 April 2021 at 11:36. Reason: Special macro argument |
|
01 April 2021, 11:34 | #7 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,410
|
I see, I misread that macro.
So, am I then correct in saying that the workaround is that you set a symbol to a value based on REPTN in a macro and then you expand that symbol in the same macro? |
01 April 2021, 11:41 | #8 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
EDIT: Within \<REPTN>of course... Last edited by phx; 01 April 2021 at 11:42. Reason: \<symbol> |
|
02 April 2021, 12:31 | #9 |
Mostly Harmless
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,109
|
Thanks, a clever trick. I have other loops like this with 24 and more iterations so it will be nice to tidy those up!
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
VASM: Access to a local label | litwr | Coders. Language | 4 | 23 October 2020 15:54 |
VASM - not getting debug symbols | mcgeezer | Coders. Asm / Hardware | 3 | 09 August 2018 11:09 |
Matching device names with volume names. | Thorham | Coders. System | 2 | 27 July 2015 12:20 |
User Symbols in ReSource | selco | Coders. General | 3 | 11 April 2015 21:26 |
SAS/C: Undefined symbols | Yesideez | Coders. C/C++ | 14 | 13 February 2014 16:36 |
|
|