![]() |
![]() |
#1 |
Registered User
Join Date: Jan 2016
Location: NL
Posts: 32
|
REPT in MACRO
when using AsmTwo, the following piece of code gives a '** Unexpected End of File' error during Pass 1:
Code:
WTF: MACRO REPT 2 dc.w 0 ENDR ENDM Main: btst #6,$bfe001 bne.s Main rts Data: dc.w 0 dc.w 0 REPT 2 dc.w 0 ENDR WTF dc.w 0 END Does any MACRO-guru have a clue why this is not working? |
![]() |
![]() |
#2 | |
Registered User
Join Date: Aug 2017
Location: Spain
Posts: 30
|
Quote:
- Assemble your source as is. I get an "Unexpected EOF" pointing after the 'end' keyword. - Add a comment to the dc.w 0 inside the rept block (e.g. 'dc.w 0 ; foo'). I get the same error. - Remove the comment and assemble again. Note the error is slightly different (in my case there are two 'end' keywords) If I repeat the 'comment/assemble/remove comment' at different places (e.g. in the 'wtf' macro call, in between it and the end, etc.) I get different error messages which refer to things that no longer exist in the source. For example, if I add a '; foo' comment after the 'wtf' call and assemble I get an error message that does not include 'foo'. Now, I remove the comment, save the file and assemble, and the error message display the contents of the comment!. So, it looks like that using rept inside a macro definition causes some piece of code to reach for data that is out of bounds in some buffer (this would explain why data from a previous assembly shows up there). @Photon, I believe you are the author of AsmTwo, so maybe you can confirm if this is really a bug? Thanks! EDIT: I have no idea how to mention a user here :-( Using '@' doesn't seem to work? Let's hope Photon sees this message anyway |
|
![]() |
![]() |
#3 |
Registered User
Join Date: Jan 2016
Location: NL
Posts: 32
|
@adolfo.pa: thanks for confirming this (bug?)
Here's a slightly modified version to show what is going wrong: Code:
WTF: MACRO REPT \1 dc.w 0 ENDR ENDM Main: btst #6,$bfe001 bne.s Main rts Data: dc.w 0 dc.w 0 REPT 2 ; no problemo dc.w 0 ; ENDR ; WTF 1 ; works fine WTF 2 ; ** Unexpected End of File ; armageddon starts now! dc.w 0 END |
![]() |
![]() |
#4 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
This seems to be an AsmTwo problem, your macro is fine.
|
![]() |
![]() |
#5 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,016
|
Try pressing RETURN so that MACRO and WTF: are not on the same line.
And your END statment is wrong, thats for signifying end of the source, try ENDM |
![]() |
![]() |
#6 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
It's not wrong, it's added automatically by AsmOne/Two etc. And he has properly terminated the macro with ENDM. |
|
![]() |
![]() |
#7 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,016
|
|
![]() |
![]() |
#8 | |
Registered User
Join Date: Jan 2016
Location: NL
Posts: 32
|
Quote:
This problem also occurs with ASM-One v1.20; I just tested this. I get the same error when putting the ENDR in the WTF:MACRO in comment, e.g. Code:
; ENDR It appears the REPT inside a MACRO is not properly terminated (the ENDR is gone?) when using it with a higher value than '1'. |
|
![]() |
![]() |
#9 | |
Registered User
Join Date: Dec 2017
Location: Denmark
Posts: 179
|
Quote:
|
|
![]() |
![]() |
#10 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,652
|
I have been very wary about changing the assembly core stolen from Seka.
![]() In fact, it's 100% the same, and therefore, bugs that were there (and continued also to much later versions by others) are there. AsmTwo is in a way starting over, and not because older is better but because older is smaller. ![]() |
![]() |
![]() |
#11 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
At least older versions of ASM-One apparently have problems with REPT inside a macro. It works without problem in ASM-Pro V1.16d for example.
Workaround for this particular case: Code:
WTF: MACRO dcb.w \1,0 ENDM Main: btst #6,$bfe001 bne.s Main rts Data: dc.w 0 dc.w 0 REPT 2 dc.w 0 ENDR WTF 2 dc.w 0 |
![]() |
![]() |
#12 |
Registered User
Join Date: Jan 2016
Location: NL
Posts: 32
|
@StingRay
Thanks for the solution, but this particular case is not the original case... It's a simplified example, just to show the REPT-inside-a-MACRO bug in AsmOne/Two. The real case was this: Code:
SETF MACRO IFEQ NARG-2 .O SET 0 ENDC .O2 SET .O REPT \1-1 dc.w .O2*4,(.O2+1)*4 .O2 SET .O2+1 ENDR dc.w .O2*4,.O*4 .O SET .O+\1 ENDM ; o - 8+4 SETF 8,"STING POWAH" SETF 4 ; r - 12+4 SETF 12 SETF 4 ; a - 10+4 SETF 10 SETF 4 ; c - 16 SETF 16 ; l - 7 SETF 7 ; e - 14 SETF 14 I had to strip out a lot of code and recompile it many times to finally find what was causing this annoying problem...which I solved by replacing the SETF calls with the content of the MACRO and replacing the \1 with the numbers after the SETF; basically reversing the usage of the MACRO. The intro now compiles fine and runs! ![]() Thanks for all the time you guys put into this. This is a forum with people that actually know their stuff...which is refreshing. ![]() |
![]() |
![]() |
#13 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Code:
; o - 8+4 SETF 8,"STING POWAH" SETF 4 ![]() The source was made with ASM-Pro V1.16d, it can be assembled (!, not compiled :P) without any problems with that assembler. Any particular reason you are using AsmTwo for that? |
![]() |
![]() |
#14 | ||
Registered User
Join Date: Jan 2016
Location: NL
Posts: 32
|
Quote:
![]() ![]() ![]() Quote:
![]() |
||
![]() |
![]() |
#15 |
Registered User
Join Date: Jan 2024
Location: Zagreb / Croatia
Posts: 11
|
Just hit this same bug in the following assemblers:
Confirmed working:
|
![]() |
![]() |
#16 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,652
|
It was fixed somewhere in between Asm-One 1.20 and 1.49RC2. Had a look, but nothing had changed in AsmPro 1.17 in any relevant code portion.
A clue is that if you type as many ENDR as the REPT count (e.g. REPT2;ENDR;ENDR), it assembles but only generates the contents once. IOW it doesn't decrement the ENDR until 0, but keeps searching for ENDR until end of source. For now, the workaround is Code:
WTF: MACRO dc.w 0 ENDM Data: count: SET 5 REPT count WTF ENDR My tutorial series doesn't use REPT inside macros as far as I'm aware. ![]() |
![]() |
![]() |
#17 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,054
|
Did some poking, it looks like this is the problem...
ASSEM_CMDREPT: ... move.l 12(A7),(A0)+ ASSEM_CMDENDR: ... move.l (A0),12(A7) Both of these should be 16. There is an extra longword on the stack that has to be skipped, so that the REPT/ENDR handlers get the correct macro source line. Went through with debugger and that pointer seemed strange (it pointed to source line, not macro source line), changed them to 16 and hoped for the best. It went through, no crash and produced output was correct. |
![]() |
![]() |
#18 | |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,652
|
Quote:
|
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Metacomco Macro Assembler | drwhy | request.Apps | 5 | 12 December 2014 16:56 |
VBCC macro expansion | deadwood | Coders. C/C++ | 5 | 29 November 2014 19:15 |
REPT directive in vasm | phx | Coders. Asm / Hardware | 8 | 01 October 2014 21:48 |
WAITBLIT macro | phx | Coders. Asm / Hardware | 20 | 18 February 2014 14:22 |
Looking for Macro Paint | mr_a500 | request.Apps | 2 | 28 January 2006 18:20 |
|
|