English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 11 March 2018, 10:07   #1
borchen
Registered User

 
Join Date: Jan 2016
Location: NL
Posts: 23
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
the problem is caused by the REPT 2 in the MACRO, when I replace it with REPT 1 all is fine.

Does any MACRO-guru have a clue why this is not working?
borchen is offline  
AdSense AdSense  
Old 11 March 2018, 11:33   #2
adolfo.pa
Registered User

 
Join Date: Aug 2017
Location: Spain
Posts: 27
Quote:
Originally Posted by borchen View Post
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
the problem is caused by the REPT 2 in the MACRO, when I replace it with REPT 1 all is fine.

Does any MACRO-guru have a clue why this is not working?
I'm definitely not a macro guru, but I think this is a bug. Also, I've noticed something very weird here. Try the following:

- 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
adolfo.pa is offline  
Old 11 March 2018, 12:58   #3
borchen
Registered User

 
Join Date: Jan 2016
Location: NL
Posts: 23
@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
Time to fetch my searchlight with the Scoopex-logo attached to it and point it at the clouds and let's hope @Photon sees it.
borchen is offline  
Old 11 March 2018, 14:55   #4
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,885
This seems to be an AsmTwo problem, your macro is fine.
StingRay is offline  
Old 11 March 2018, 14:57   #5
Galahad/FLT
Going nowhere

Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 44
Posts: 6,890
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
Galahad/FLT is offline  
Old 11 March 2018, 14:58   #6
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,885
Quote:
Originally Posted by Galahad/FLT View Post
Try pressing RETURN so that MACRO and WTF: are not on the same line.
Must be on the same line!

Quote:
Originally Posted by Galahad/FLT View Post
And your END statment is wrong, thats for signifying end of the source, try ENDM
It's not wrong, it's added automatically by AsmOne/Two etc. And he has properly terminated the macro with ENDM.
StingRay is offline  
Old 11 March 2018, 15:04   #7
Galahad/FLT
Going nowhere

Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 44
Posts: 6,890
Quote:
Originally Posted by StingRay View Post
Must be on the same line!



It's not wrong, it's added automatically by AsmOne/Two etc. And he has properly terminated the macro with ENDM.
How the fuck did i not see that?

Does ASMone/Two not like REPT macros within a macro?
Galahad/FLT is offline  
Old 11 March 2018, 15:40   #8
borchen
Registered User

 
Join Date: Jan 2016
Location: NL
Posts: 23
Quote:
Does ASMone/Two not like REPT macros within a macro?
A 'REPT 1' works fine inside the WTF:MACRO

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
and calling the MACRO with 'WTF 1'

It appears the REPT inside a MACRO is not properly terminated (the ENDR is gone?) when using it with a higher value than '1'.
borchen is offline  
Old 11 March 2018, 18:57   #9
LaBodilsen
Registered User

 
Join Date: Dec 2017
Location: Gandrup / Denmark
Posts: 58
Quote:
Originally Posted by borchen View Post
@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
Time to fetch my searchlight with the Scoopex-logo attached to it and point it at the clouds and let's hope @Photon sees it.
As others have confirmed, this code works fine, i testet it in Asm-Pro V1.17, and no errors show. So it must be a AsmTwo problem.
LaBodilsen is offline  
Old 13 March 2018, 18:31   #10
Photon
Moderator
Photon's Avatar
 
Join Date: Nov 2004
Location: Hult / Sweden
Posts: 4,515
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. It's targeted to be able to code a whole A500 demo on an A500 1.3 with 512k slowmem and up.
Photon is offline  
Old 14 March 2018, 07:51   #11
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,885
Quote:
Originally Posted by Galahad/FLT View Post
Does ASMone/Two not like REPT macros within a macro?
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
This should work as expected. And if any other value than 0 is required a second parameter for the macro could be added, e.g. WTF 2,16384.
StingRay is offline  
Old 14 March 2018, 21:48   #12
borchen
Registered User

 
Join Date: Jan 2016
Location: NL
Posts: 23
@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
This is part of an intro/crack made by demogroup Oracle for the game Arachnophobia, which I just tried to get running.

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.
borchen is offline  
Old 15 March 2018, 07:05   #13
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,885
Code:
; o - 8+4
	SETF	8,"STING POWAH"
	SETF	4
Haha, now this made me giggle. Guess who's the one responsible for your macro problems.

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?
StingRay is offline  
Old 15 March 2018, 22:35   #14
borchen
Registered User

 
Join Date: Jan 2016
Location: NL
Posts: 23
Quote:
Haha, now this made me giggle. Guess who's the one responsible for your macro problems.
No way. You must be kidding! Talk about coincidence

Quote:
Any particular reason you are using AsmTwo for that?
Yes: [ Show youtube player ]
borchen is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:55.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.07873 seconds with 15 queries