26 August 2014, 15:23 | #1 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
REPT directive in vasm
I'm thinking about rewriting the REPT directive and I'm interested in your opinion about it.
Currently REPT works on the parser level in vasm. This has the advantage that you can put absolutely everything between REPT and ENDR. The disadvantage is that the number of repetitions must evaluate as a constant in the first pass (label1-label2 is not a constant here). Devpac allows REPT with label1-label2, as long as these labels are defined on top of the directive. With some effort I could make any variable expression work with REPT (even when defined after the repeat-block). But the disadvantage would be that the repeat-blocks could no longer cross section boundaries. For example this would become impossible, which currently works: Code:
rept 10 code move.b (a0)+,(a1)+ data dc.b 1,2,3,4 endr |
26 August 2014, 19:31 | #2 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
I've never needed either of the two cases, but being able to do "label1-label2" seems to me like it could be more useful, whereas the latter case with section statements less so and seems very rare, so I think it would be an improvement.
|
27 August 2014, 01:10 | #3 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Ok, thanks. So I should work on this improvement now.
|
27 August 2014, 17:13 | #4 |
Registered User
Join Date: Sep 2008
Location: Germany
Age: 49
Posts: 137
|
Never had a case where I had to put a 'section' statement between REPT/ENDR. I see an advantage in having label arithmetic between REPT/ENDR blocks.
|
01 September 2014, 16:24 | #5 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Ok. After several days of work I have to admit that I failed. My new idea didn't cover all the functioniality of the current implementation.
This works nicely now: Code:
rept end-start bsr start endr start move.l #0,d0 end rts But the price is too high. Changing symbols with SET or accessing the next macro macro argument with \+ no longer works correctly inside a rept-block. So the following code would generates four bytes with 1: Code:
x set 0 rept 4 x set x+1 dc.b x endr Last edited by phx; 01 October 2014 at 19:44. Reason: The first x was missing in the second example |
02 September 2014, 12:07 | #6 |
Registered User
Join Date: Sep 2008
Location: Germany
Age: 49
Posts: 137
|
anyway, thanks for your efforts
|
01 October 2014, 13:17 | #7 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
|
(Side note: Second example is missing the first letter which should be x. Right?)
You do need this set thing, so supporting that is the right thing to do, even if there's a @\ variable (in Asm-One). I don't know how many assemblers support it, but it returns the string "0000" the first time, "0001" the second time, and so on (16 bit counter, hex format so you can put "$" before it and use for calculations). Check so that local variables (.x) works with set in REPT. At least I always use local variables for my REPT statements. |
01 October 2014, 20:09 | #8 | |||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
Quote:
Quote:
Devpac: _001 .. _999 PhxAss: _0001 .. _9999 vasm: _000001 .. _999999 Barfly: _0001 .. _9999 All of them precede the string by an underscore, which allows using \@ directly as a label. Quote:
|
|||||
01 October 2014, 21:48 | #9 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
|
Correction: Asm-One's \@ starts counting at 0001. I was at work, so I was unable to check.
Also, it seems only version 1.02+ corrected the reverse digits order. Asm-One 1.20 has limited support, reverse digits, only for labels and PRINTV (inside quotes, no less!) and then it gets unsupported for anything but labels upto latest AsmPro... So I guess having a f* counter but not supporting it for anything but labels was the way of the future. Anyway, here's a test macro if anyone wants to report some Asm-One version that does support it properly like 1.02+: Code:
ROCKETSCIENCE: MACRO dc.w $\@ ENDM ITSNOT: REPT 42 ROCKETSCIENCE ENDR |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
vasm question | marduk_kurios | Coders. Asm / Hardware | 7 | 14 February 2014 20:06 |
vasm fsincos | dalton | Coders. Asm / Hardware | 4 | 03 September 2012 10:35 |
vasm 1.5 RFC | phx | Coders. General | 30 | 11 December 2010 02:08 |
AsmOne even directive...? | pmc | Coders. General | 30 | 04 December 2009 09:33 |
Invalid Directive | Kimmo | support.WinUAE | 1 | 23 July 2004 11:23 |
|
|