English Amiga Board


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

 
 
Thread Tools
Old 13 February 2018, 15:45   #41
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,134
Quote:
Originally Posted by bebbo View Post
=> The configuration for elf sets something which causes this behaviour.

no clue what it might be.
Unlike a.out and hunk-format, ELF objects and linkers expect C-symbols without a leading underscore. Therefore you need to prepend the '%' prefix for CPU-register names to avoid conflicts in the name space.
phx is offline  
AdSense AdSense  
Old 13 February 2018, 20:42   #42
wawa
Registered User
 
Join Date: Aug 2007
Location: berlin/germany
Posts: 946
Post

Quote:
Originally Posted by phx View Post
Unlike a.out and hunk-format, ELF objects and linkers expect C-symbols without a leading underscore. Therefore you need to prepend the '%' prefix for CPU-register names to avoid conflicts in the name space.
yes, it seems to confirm what you wrote on a1k, and im certain you can tell.
the question is qhat would be the most flexible and minimal quickfix, without immediately starting to set amiga hunk as a format for m68k target, which can be exceeding abilities and motivation of remaining coders and introducing drawbacks im yet not aware of (gdb debugging?). (even though aros amiga-m68k nightly consists SOLELY of hunk binaries in the end)

so to reassure, would each and every register occurence in asm inline need to be consistently prepend with "%" even if the gas doesnt complain about it? what about existing "%"?
wawa is offline  
Old 14 February 2018, 01:56   #43
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,134
Quote:
Originally Posted by wawa View Post
most flexible and minimal quickfix, without immediately starting to set amiga hunk as a format for m68k target
If you want ELF objects, then there is not much you can do about it. Even if you can force the compiler to prefix symbols by underscores again and make the assembler accept register names without a leading '%', although emitting ELF format, you cannot link these objects with any other existing ELF objects or linker libraries, which don't use the same hacked compiler and assembler.

But I didn't quite understand what's so difficult to write the '%' in assembler inlines inside a C source. There must be no such restriction in pure assembler sources, BTW, which could also be assembled by different assemblers.


Quote:
(even though aros amiga-m68k nightly consists SOLELY of hunk binaries in the end)
And objects are usually ELF under AROS? Otherwise I would consider using a.out or hunk-format objects. The latter one would be the natural choice, when the executables are hunk-format as well.

Quote:
so to reassure, would each and every register occurence in asm inline need to be consistently prepend with "%"
Yes. Seems so. Although I'm only guessing here, without ever having seen your development tools (nor having the time or motivation to try them).

Quote:
even if the gas doesnt complain about it?
Caution! That doesn't mean it is correct. For example a "move.l a1,d0" could be interpreted by the assembler as a move from the symbol "a1" to the symbol "d0", not the registers, which is perfectly legal! Maybe the linker will then complain about missing symbols, if you're lucky...

Quote:
what about existing "%"?
I'm not sure what you mean. You probably have to escape existing "%" with "%%"?
phx is offline  
Old 14 February 2018, 13:26   #44
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,134
I was contacted by the Amiga-GCC guru, Gunther Nikl, and he told me that there are special conversion characters for inline assembler in GCC:

%/ : register prefix
%. : instruction size extension prefix
%# : immediate prefix

When reworking the inlines using the above rules everything should work with ELF and hunk-format. I haven't tried it, though.

Code:
struct _atomic_stack;
struct _atomic_item;

//static inline
void
_atomic_stack_push1(struct _atomic_stack* list, struct _atomic_item* item)
{
    __asm __volatile (
        "   move%.l %0,%/a0\n"
        "   move%.l %1,%/a1\n"
        "1: bset%.b %#0,4(%/a1)\n"
        "   bne%.b 1b\n"
        "2: move%.l (%/a1),(%/a0)\n"
        "   move%.l %/a0,(%/a1)\n"
        "   bclr%.b %#0,4(%/a1)\n"
        : /* no outputs */
        : "m" (item), "m" (list)
        : "a0", "a1", "cc", "memory"
    );
}


//static inline
void
_atomic_stack_push2(struct _atomic_stack* list, struct _atomic_item* item)
{
    __asm __volatile (
        "1: bset%.b %#0,4(%1)\n"
        "   bne%.b 1b\n"
        "2: move%.l (%1),(%0)\n"
        "   move%.l %0,(%1)\n"
        "   bclr%.b %#0,4(%1)\n"
        : /* no outputs */
        : "a" (item), "a" (list)
        : "cc", "memory"
    );
}
phx is offline  
Old 15 February 2018, 18:54   #45
wawa
Registered User
 
Join Date: Aug 2007
Location: berlin/germany
Posts: 946
many thx, phx! your input and gunters has been very vauable it seems

i have introduced your proposed changes to all inlines, except for instruction size extension prefix, which i thought can be omitted for starters, but maybe ill add that too.

now, the application still crashes, but it doesnt freeze the system any more. instead throws illegal instruction, which seems to prove that previous syntax wasnt producing the right binary.

now, i might still have made some typo somewhere, or there is some forthcoming issue somewhere else. ill proceed to debug this further in a while.
wawa 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
Inline ASM xArtx Coders. Asm / Hardware 10 27 July 2014 16:21
Tool to convert asm to gnu asm (gas) Asman Coders. Asm / Hardware 6 12 October 2013 12:45
XAMOS - new cross-platform rewrite of jAMOS Mequa News 24 14 December 2012 09:49
Storm C V4...using inline assembler NovaCoder Coders. General 11 26 February 2009 12:10
Syntax Error in IE. Fred the Fop project.EAB 2 04 October 2002 14:47

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 10:11.


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