![]() |
![]() |
#1 |
Natteravn
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 *,* 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? ![]() |
![]() |
![]() |
#2 |
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. |
![]() |
![]() |
#3 |
Moderator
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. |
![]() |
![]() |
#4 |
Moderator
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. |
![]() |
![]() |
#5 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
|
|
![]() |
![]() |
#6 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,567
|
Quote:
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. |
|
![]() |
![]() |
#7 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
|
Quote:
![]() 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? |
|
![]() |
![]() |
#8 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,567
|
|
![]() |
![]() |
#9 |
Registered User
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. |
![]() |
![]() |
#10 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,747
|
Agree.
ps. Being consistent with one's own definitions is not very hard, hehe ![]() ![]() |
![]() |
![]() |
#11 |
tulou
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. |
![]() |
![]() |
#12 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,747
|
Huh. Well, I'm glad most assemblers got it right tho.
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
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 |
|
|