English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 03 November 2009, 19:16   #1
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,567
using the '*'-symbol in assembler - what do you expect?

Hi,

as there are some 68k assembler coders on this board I would like to ask what output you expect to be generated, when assembling the following source:
Code:
        dc.l    *+4
x:      dc.l    *,*
There seem to be two variants:
1. All three pointers will refer to x. Generated by: A68k, Devpac.
2. First two refer to x, but the last pointer refers to x+4. Generated by: Barfly, PhxAss, SNMA.

I would like to make it right in vasm, but I'm unsure which solution *is* the right one?
phx is offline  
Old 03 November 2009, 21:13   #2
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Hi again Frank

I've never used the *,* construct but having * refer to the beginning of the line seems more intuitive to me and that's what I would expect initially, but now that I see your example the latter case with the exact address seems more correct. I'm split about this.

I checked with ASM-One and it also generates the exact address.
Leffmann is offline  
Old 04 November 2009, 02:38   #3
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,747
* is the address of the memory location where it is invoked.

In your example, the first line stores the address X in a longword, since it is invoked at a longword before x and adds 4 to it.

The second line stores the address X in a longword followed by address X+4 in a longword. (Since a longword is 4 bytes.)


Another example, both

bra.s *

and

loop: bra.s loop

results in an endless loop - but no label is necessary for the first one. Use it in macros or wherever you want to avoid double symbol errors.
Photon is offline  
Old 04 November 2009, 02:48   #4
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,747
If your assembler generates something else, it hasn't implemented the * directive correctly - even though assemblers for fixed-instruction-size CPUs might correctly make it point to "the next instruction" or similar.

Normally it's used only to counter this double symbol error in code, but it should be safe to use for any address calculation that each assembler supports. [Edit: in your example, making the dc.l *,* into two dc.l * lines should give the same behavior on all* assemblers]

It comes from late 1970s "assemblers on the computer that runs the program", where only the first three letters of each label were stored to save precious RAM, and double symbol errors therefore were common.

Last edited by Photon; 04 November 2009 at 02:59.
Photon is offline  
Old 04 November 2009, 09:26   #5
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
Quote:
Originally Posted by phx View Post
Code:
        dc.l    *+4
x:      dc.l    *,*
dc.l *,* should refer to x and x+4 since * is current address. I never needed to use that though. But it is the "right" solution for me, i.e. it makes sense and it's what I would expect.
StingRay is offline  
Old 04 November 2009, 09:37   #6
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,567
Quote:
Originally Posted by Photon View Post
If your assembler generates something else, it hasn't implemented the * directive correctly
At the moment vasm behaves like PhxAss and AsmOne, and will generate "dc.l x,x+4" for "x: dc.l *,*". I always thought it is more logical, because splitting a "dc.l *,*" into two seprate dc.ls should generate the same code.

But I got very confused when I saw the output of Devpac, as I trust Devpac as the reference assembler for everything.

Hmm...ok, even the GNU-assembler seems to prefer the PhxAss-method, so I think I will keep it like that.
phx is offline  
Old 04 November 2009, 09:44   #7
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
Quote:
Originally Posted by phx View Post
I always thought it is more logical, because splitting a "dc.l *,*" into two seprate dc.ls should generate the same code.
Exactly what I think too! Also, keep in mind that Devpac has bugs too, i.e. it's not 100% either (then again, no Assembler is I guess).
However, if you can't decide how to handle it, how about having some kind of flag/directive so the user can decide which code should be generated?
StingRay is offline  
Old 04 November 2009, 12:03   #8
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,567
Quote:
Originally Posted by StingRay View Post
However, if you can't decide how to handle it, how about having some kind of flag/directive so the user can decide which code should be generated?
I'm thinking about it. There is already a -devpac flag for best Devpac-compatibility.
phx is offline  
Old 05 November 2009, 17:00   #9
mosfet
Registered User
 
mosfet's Avatar
 
Join Date: Oct 2009
Location: UK
Posts: 41
Devpac is at least being consistent with its own definition of '*', which is "the value of the program counter at the start of the instruction or directive", with both longs on the second line belonging to the same dc directive. It's probably the easier way to implement too.

But the second way is more logical. Putting multiple values on one line is a formatting decision and should be equivalent to separate directives. Formatting shouldn't hide nasty surprises like that.
mosfet is offline  
Old 16 November 2009, 18:49   #10
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,747
Agree.

ps. Being consistent with one's own definitions is not very hard, hehe The opposite is in fact a good definition of the word "bug".
Photon is offline  
Old 02 December 2009, 09:10   #11
dalton
tulou
 
dalton's Avatar
 
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
the dc.l *,* situation seems very hypothetical.. If I wrote something like that I'd definitely disassemble to confirm the result.

Generally, I would expect * to be the address of the current row in the code.
dalton is offline  
Old 02 December 2009, 12:56   #12
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,747
Huh. Well, I'm glad most assemblers got it right tho.
Photon 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
AsmOne: Undefined symbol copse Coders. Asm / Hardware 2 02 April 2012 01:41
Undefined symbol bsr.b init_bitmaps VoltureX Coders. General 12 13 November 2011 16:11
IDE-FIX / Express - What to expect? illy5603 support.Hardware 19 18 August 2009 18:46
OS 3.9 Euro Symbol and Unarc fc.studio support.Apps 1 01 January 2008 12:08
How much should I expect to pay for... Enverex MarketPlace 4 04 March 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 21:23.

Top

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