English Amiga Board


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

 
 
Thread Tools
Old 05 April 2013, 03:12   #1
Den
Registered User

 
Join Date: Apr 2012
Location: Velaux / France
Age: 53
Posts: 16
vasm and word alignment

Hello,

I wanted to set up a comfy toolset to try and code some Amiga asm, so I tried vasm.

I found a topaz scroller source, vasm ran without errors, resulting file worked fine in winUAE.

I changed the text a bit, vasm ran without errors, but resulting file crashed in winUAE.

Original code looked like this:
Code:
	DC.B	'this is the scrolling text    ',0,0
INTER:
	MOVEM.L	D0-D7/A0-A6,-(A7)	; Put registers on stack
I then tried to assemble the modified source with ASM-One in winUAE, and it failed with a "** Word at ODD address" error. I added an EVEN directive after the DC.B and everything ran fine again.

This might not be the best coding example in the world, I understand the second trailing zero after the text was meant to align the following instruction, and that an EVEN directive would have been a wiser choice.

Still I'm wondering why vasm didn't fail assembling that file. I tried with and without the -devpac option and found nothing (that made sense to me at least ) in the options list.

So I would like to know if there's a way to tell vasm to break (and warn) on this kind of errors.

for what it's worth, here's the command line I used to run vasm (with and without -devpac):

Quote:
vasmm68k_mot -Fhunkexe -devpac -o exefilename -nosym source.s
Thanks for reading
Den
Den is offline  
Old 05 April 2013, 05:39   #2
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,265
Instructions are auto aligned on 2 bytes by default, so the code ends up on the correct address, but if an instruction is auto aligned then vasm will resolve a label on the line above to a different address than if the label and instruction are on the same line, that could probably be the source of your error.

In these examples, "Label" will have different address values:
Code:
       move.l  #Label, d0
       dc.b    0
Label
       rts

----------------------

       move.l  #Label, d0
       dc.b    0
Label  rts
Now that I think of it this has to be unintentional, so I'll send Frank a bug report about it.

Last edited by Leffmann; 05 April 2013 at 05:48.
Leffmann is offline  
Old 05 April 2013, 07:45   #3
Den
Registered User

 
Join Date: Apr 2012
Location: Velaux / France
Age: 53
Posts: 16
Thanks for your answer, Leffmann.

You nailed it. I just tested again without the EVEN directive, with the label on the same line as the movem, both with X chars and X-1 chars in the preceding dc.b and it indeed worked in both cases

I agree this is not a "desired" behaviour and that the label should be updated when the instruction that immediately follows it is auto-aligned, be it on the same line, or even 10 (empty) lines below.

Also, I think it would be nice to be able to disable that auto-alignment feature and have vasm output an 'odd alignment' error so as to have the opportunity to see what has been overlooked and manually add an EVEN or an ALIGN directive where needed. Not a vital feature by any means though

And finally, if Frank (I guess it's phx?) reads these lines, thanks a lot for the work you put into vasm!
Den is offline  
Old 05 April 2013, 10:28   #4
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,008
Quote:
Originally Posted by Den View Post
I agree this is not a "desired" behaviour and that the label should be updated when the instruction that immediately follows it is auto-aligned, be it on the same line, or even 10 (empty) lines below.
I tend to disagree.

This behaviour is intended. You can never say whether an alone-standing label belongs to the source above or below it. Example:
Code:
strstart:
        dc.b    "abc"
strend:
        rts
The instruction is auto-aligned. But aligning strend would be fatal, because it is used to calculate the string length.

The behaviour of vasm in this respect is absolutely identical to Devpac and AsmOne/AsmPro. All these assemblers will only align labels which are following the aligned instruction or reside on the same line. So there is no reason to change it.

Quote:
Also, I think it would be nice to be able to disable that auto-alignment feature and have vasm output an 'odd alignment' error so as to have the opportunity to see what has been overlooked
It makes no sense to assemble instructions at an odd address, but I agree that a warning about auto-aligned instructions could be helpful. I changed that (will be in tomorrows source snapshot).

So your example (with an odd string length) would look like this now:
Code:
vasm 1.6b (c) in 2002-2013 Volker Barthelmann
vasm M68k/CPU32/ColdFire cpu backend 1.3d (c) 2002-2013 Frank Wille
vasm motorola syntax module 3.4 (c) 2002-2013 Frank Wille
vasm test output module 1.0 (c) 2002 Volker Barthelmann

warning 51 in line 3 of "source.s": instruction had been auto-aligned
>       MOVEM.L D0-D7/A0-A6,-(A7)       ; Put registers on stack
Hope this helps.
Warnings can be disabled as usual, with -w. Or specifically for this new warning: -nowarn=51.
phx is offline  
Old 05 April 2013, 10:58   #5
Den
Registered User

 
Join Date: Apr 2012
Location: Velaux / France
Age: 53
Posts: 16
I can see the problem with labels used to calculate a length, which I had overlooked.
Oh well, I'll just learn to put labels were they need to be and use more tabs if I need to fit longer names

Quote:
Originally Posted by phx View Post
So your example (with an odd string length) would look like this now:
Code:
warning 51 in line 3 of "source.s": instruction had been auto-aligned
>       MOVEM.L D0-D7/A0-A6,-(A7)       ; Put registers on stack
Hope this helps.
If I may, I think "has been auto-aligned" would be even better
This is a perfect addition, it obviously makes no sense to assemble instructions at odd addresses and this warning gives all the necessary info if one wants to go and manually align stuff in the source

Thanks again!
Den is offline  
Old 05 April 2013, 11:14   #6
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,008
Quote:
Originally Posted by Den View Post
Oh well, I'll just learn to put labels were they need to be and use more tabs if I need to fit longer names
I would rather use proper alignment directives.

Quote:
If I may, I think "has been auto-aligned" would be even better
Hmm.. we're both no native speakers, but you may be right. "had" sounds like it was aligned in the past, but now it is no longer?
Changed that.
phx is offline  
Old 06 April 2013, 09:51   #7
Den
Registered User

 
Join Date: Apr 2012
Location: Velaux / France
Age: 53
Posts: 16
Just compiled latest source snapshot:

Code:
warning 51 in line 163 of "ScrollExample.S": instruction has been auto-aligned
>	MOVEM.L	D0-D7/A0-A6,-(A7)	; Put registers on stack
Works perfectly, thanks again
Den is offline  
Old 06 April 2013, 17:22   #8
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,265
A warning message like this was probably the best solution. Thanks for a quick patch as always.
Leffmann is offline  
Old 07 February 2014, 07:07   #9
xxxxx
Registered User
 
Join Date: Jan 2012
Location: N/A
Posts: 38
Hey, sorry to resurrect an old thread. I really like the warning idea, but I would have liked it to trigger in more cases. So I have (experimentally) moved it up so it triggers for anything that adds data (other than CNOP/ODD/EVEN/ALIGN), rather than just for type INSTRUCTION. I did this by
1. moving the error up above the "if (p->type == RORG&&rorg_pc == 0)"
2. adding an extra parameter to sblock named is_alignment, and have do_alignment pass TRUE while everything else allocating a space atom sets it to FALSE
3. changing the check to:
if (sec->pc != oldpc && (p->type != SPACE || p->content.sb->is_alignment == FALSE))
general_error(50); /* instruction had been auto-aligned */

Feel free to use this if you want. it seems to work well for me.
xxxxx is offline  
Old 07 February 2014, 11:25   #10
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,008
In default vasm mode there is only auto-alignment for instructions. Maybe you are thinking about the Devpac-compatibility mode, where data would be auto-aligned too?

Yes, your modification could be useful in that case, but I would add another warning message, as "instruction has be auto-aligned" doesn't really fit for data.

It is also not necessary to add the is_alignment flag to sblock, because an unaligned sblock will always have align=1. So the change now looks like this:
Code:
+++ vasm.c      7 Feb 2014 10:22:22 -0000
@@ -258,6 +258,12 @@
       }
       if(p->changes>MAXSIZECHANGES)
         sec->flags|=RESOLVE_WARN;
+      if(sec->pc!=oldpc&&(p->type!=SPACE||p->align==1)){
+        if (p->type==INSTRUCTION)
+          general_error(50);  /* instruction has been auto-aligned */
+        else
+          general_error(57);  /* data has been auto-aligned */
+      }
       if(p->type==RORG&&rorg_pc==0){
         rorg_pc=*p->content.rorg;
         org_pc=sec->pc;
@@ -273,8 +279,6 @@
       }
       else if(p->type==INSTRUCTION){
         dblock *db;
-        if(sec->pc!=oldpc)
-          general_error(50);  /* instruction had been auto-aligned */
         cur_listing=p->list;
         db=eval_instruction(p->content.inst,sec,sec->pc);
         if(pic_check)
Commited that for the next version. Thanks for your contribution.
phx is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Latest Win32 VASM Build? bodhi Coders. Asm / Hardware 89 25 August 2017 01:27
Help linking VASM object code clenched Coders. Asm / Hardware 2 24 May 2013 22:32
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
X-Word BippyM EAB's competition 11 14 July 2004 20:26

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 06:36.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.10915 seconds with 13 queries