Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: cycloid on November 26, 2003, 10:21:22 PM

Title: funcdef macro in phxass?
Post by: cycloid on November 26, 2003, 10:21:22 PM
those of you who are regulars around these parts will haave noticed that i'm attempting to get adoom to compile in gcc. i've gotten all the c files to compile with only a handfull of warnings (apart from it warning-ing when i compare pointer == NULL because NULL is an int!) but now i've turned to the assembly specific files, i've got phxass as gas doesnt like them one bit. and incidentally i'm using the 3.9 libs/headers (though still devving on a 3.1 system) ... however i'm stuck now because it demands a "funcdef" macro, someone on the comp.sys.amiga.programmer newsgroup suggested the following


amiga_draw.s first few lines of code:

 lvocnt  set     LIB_USERDEF

         MACRO   FUNCDEF
 _LVO\1  EQU     lvocnt
 lvocnt  SET     lvocnt-LIB_VECTSIZE
         ENDM


 INCLUDE "exec/types.i"
 INCLUDE "exec/exec_lib.i"
...

phxass output:

Pass1

 lvocnt SET LIB_USERDEF
23 Unknown directive
 in line 18 (= line 18 of amiga_draw.s)

In line 1 of macro FUNCDEF
 _LVO\1 equ lvocnt
23 Unknown directive
 in line 214 (= line 12 of include:exec/exec_lib.i)

In line 2 of macro FUNCDEF
 lvocnt set lvocnt-LIB_VECTSIZE
23 Unknown directive
 in line 215 (= line 12 of include:exec/exec_lib.i)

In line 1 of macro FUNCDEF
 _LVO\1 equ lvocnt
23 Unknown directive
 in line 217 (= line 13 of include:exec/exec_lib.i)

In line 2 of macro FUNCDEF
 lvocnt set lvocnt-LIB_VECTSIZE
23 Unknown directive
 in line 218 (= line 13 of include:exec/exec_lib.i)


... etc.


now i know bugger all about assembly. but it seems totally utterly stupid that i'd have to write my own when the rest of the libs, headers and autodocs are bundled together. so anyone know how to make it work?

notes:
1. there is not a funcdef.i include file in the ndk
2. there's an example funcdef macro in a provided header (libraries.i) but that doesnt work either
3. i really do know nothing about asm and just want the bastards to compile/link
edit: 4: the formatting here is out but i believe that the commands are correctly tabbed apart
Title: Re: funcdef macro in phxass?
Post by: Karlos on November 26, 2003, 10:29:56 PM
Dont waste your chuff dude :-) I think the asm you are using is using macro stuff not to PhxAss liking.

However, I dunno if this may help, but I have written asm (for use in C and C++ both) with PhxAss

A function definition in C compatible format is a label with a underscore prefix like so:

_

Now, in PhxAss, to make this externally visible (ie resolvable by the linker), you XREF it thus

    XREF _MyFunction

_MyFunction
    ; do stuff here
    ;...
    rts

Hope this helps...
Title: Re: funcdef macro in phxass?
Post by: cycloid on November 26, 2003, 10:32:24 PM
riiiiight, but the function stubs in lib headers such as exec/exec_libs.i are formatted thus:

   FUNCDEF   AllocMem
   FUNCDEF   AllocAbs
   FUNCDEF   FreeMem
   FUNCDEF   AvailMem
   FUNCDEF   AllocEntry
   FUNCDEF   FreeEntry
   FUNCDEF   Insert

etc. and knowing nothing about asm i've no idea what to do.
Title: Re: funcdef macro in phxass?
Post by: Karlos on November 26, 2003, 10:37:24 PM
At a rough guess the macro is maybe to do something like this:

    MACRO FUNCDEF
    XDEF _\1
    ENDM

What that would do is to simply generate

    XDEF _FunctionName

which is basically importing a name from outside the source, just as XDEF makes a name in the source externally visible.

But I am just guessing. All my asm stuff is optimising my own inner functions that virtually never use OS calls anyway...

-edit-

Heh, I should have read your first post more closely, the FUNCDEF macro is there.

I was close... :lol:

Anyway, the problem is no doubt with the SET directive. PhxAss uses the following instead

EQU

You could, as an experiment, before your include lines add the following

    MACRO SET
1\  EQU  \2
    ENDM

might work...
Title: Re: funcdef macro in phxass?
Post by: Karlos on November 26, 2003, 11:02:35 PM
What we need is Frank Willie to step in, give us a big fat slap and then say "You do it like this.."

Incidentally, I don't wish to be the harbringer of doom but are you quite sure that even if you do assemble these sources ok that the object format exported by PhxAss will be linkable with gcc?

I've never actually tried...
Title: Re: funcdef macro in phxass?
Post by: xeron on November 26, 2003, 11:14:40 PM
Get rid of the other FUNCDEF macros you've been told, and stick this at the top:


funcoffptr  SET   -30
FUNCDEF     macro
_LVO\1      EQU   funcoffptr
funcoffptr  SET   funcoffptr-6
            endm

Title: Re: funcdef macro in phxass?
Post by: cycloid on November 27, 2003, 01:20:05 AM
nope that macro kicks off with

funcoffptr   SET   -30
unknown directive


and the rest is pretty much the same as the previous outputs

KARLOS: your first mini macro doesnt put out any errors but bizzarley i'm getting random errors like

SCREENWIDTH   EQU   320
unknown directive

_init_r_draw
unknown directive


it could all be fubar

edit: it was fubar, quite a lot of the tabbing was out, once i fixed it all it got through pass1 OK. then when it got to pass2 i got a billion "undefined xdef: _anything" errors which i hope are linker errors, seen as it's got nothing to link it to yet!
Title: Re: funcdef macro in phxass?
Post by: Karlos on November 27, 2003, 01:46:04 AM
That is pretty odd.

Which macro do you mean? The SET one? Using EQU to equate a name with a value is pretty normal and I can verify it works in PhxAss here - I use it all the time.

As it goes, the FUNCDEF one I was guessing the nature of was wrong anyway (your first post has its actual definition) - I was close but forgot about the LVO naming thing used by amiga shared libs.

The XDEF _FuncName thing is pretty standard for normal C accessible function name definitions tho.
Title: Re: funcdef macro in phxass?
Post by: cycloid on November 27, 2003, 01:51:05 AM
riiight, so if i do

      MACRO   FUNCDEF
_LVO\1       EQU   FUNC_CNT
FUNC_CNT    EQU   FUNC_CNT-6
FUNC_CNT    EQU   LIB_USERDEF
       ENDM

then i get a lot of "undefined symbol" errors, i think pertaining to "FUNC_CNT"


edit:

is it me not knowing anything about asm and what's supposed to be happening but surely if you do

var set var-6

then

var equ something

the first step is totally pointledd?
Title: Re: funcdef macro in phxass?
Post by: Karlos on November 27, 2003, 01:58:43 AM
things to note

Directives like MACRO / ENDM / EQU / XDEF etc need to be indented by at least 1 tab space to be recognised as directives by the assembler.

ie

MACRO SET
\1EQU \2
ENDM

If the directive is not tabbed, the assembler assumes its a label name instead. All kinds of arcane crapness can occur then...
Title: Re: funcdef macro in phxass?
Post by: itix on November 27, 2003, 02:03:01 AM
Are you sure you invoked PhxAss correctly? I can't imagine any other
reason.
Title: Re: funcdef macro in phxass?
Post by: cycloid on November 27, 2003, 02:08:41 AM
it wont let me do the set macro as apparently it already exists, it must be a proper internal thing as it's no where in my sources.

her we go then:

\tMACRO\tFUNCDEF
_LVO\1\tEQU\tFUNC_CNT
FUNC_CNT\tSET\tFUNC_CNT-6
FUNC_CNT\tEQU\tLIB_USERDEF
\tENDM

this version gives only one error for each invokation "variable declared twice" (i think) for the func_cnt set func_cnt-6 line

Title: Re: funcdef macro in phxass?
Post by: Karlos on November 27, 2003, 02:18:08 AM
Most likely SET is already an alternative for EQU then.

-edit-

Do you have the PhxAss docs by the way? The guide explains all the syntax and directive stuff in there somewhere.
Title: Re: funcdef macro in phxass?
Post by: cycloid on November 27, 2003, 02:22:52 AM
i have a phxass.guide and none of it appears to be in a language i understand! why wont it just work!? :-(
Title: Re: funcdef macro in phxass?
Post by: cycloid on November 27, 2003, 03:16:59 AM
from comp.sys.amiga.programmer

>         INCLUDE "exec/types.i"
>         INCLUDE "exec/libraries.i"
>
> lvocnt  SET     LIB_USERDEF
>
>         MACRO   FUNCDEF
> _LVO\1  EQU     lvocnt
> lvocnt  SET     lvocnt-LIB_VECTSIZE
>         ENDM
>
>         INCLUDE "exec/exec_lib.i"

this one appears to work , the files all compile, now i've *just* got to figure out how hunk2gcc works!


edit: right i've think i've got hunk2gcc working (there's hunk2aout too, but it spams out a load of text and bungs out files with random names.

so i've finally got all my .o files in one place and....

it thinks about linking them and then exits with the same error a million times in a row it says something about "aoutx.h" basically.


Title: Re: funcdef macro in phxass?
Post by: xeron on November 27, 2003, 09:55:06 AM
Make sure you have the latest PhxAss, since I use that macro in loads of my old programs and it works 100% fine.

Edit: Oh wait, you found a solution anyway.
Title: Re: funcdef macro in phxass?
Post by: cycloid on November 27, 2003, 09:54:43 PM
right i've got the entire think to link, at least i think there are no undefined/missing symbols etc. but it wont link because i get a billion "ld: bfd assertion fail" errors? is it a buggy version of ld (gg330) or should i be using a different linker?
Title: Re: funcdef macro in phxass?
Post by: Dietmar on November 27, 2003, 10:21:19 PM
>is it a buggy version of ld (gg330) or should i be using a different linker?

Are you using g++ from the GoldED trial? There is a known issue with the last trial version (6/11), gcc 3.3, c++ and the location of certain libraries. To make sure that you are not affected, compile with gcc 2.95.3 which is incuded, too.
Title: Re: funcdef macro in phxass?
Post by: cycloid on November 27, 2003, 10:37:57 PM
nope, 295 yields the exact same error
Title: Re: funcdef macro in phxass?
Post by: Karlos on November 28, 2003, 06:21:34 AM
Blimey dude, this thing really is doing it's level best to get on yer tits by the sound of it :-(
Title: Re: funcdef macro in phxass?
Post by: Dietmar on November 28, 2003, 11:00:30 PM
>nope, 295 yields the exact same error

Then I can't help you with that specific problem. But I'd recommend to fix the g++ 3.3 installation anyway or you might see other linker errors with C++ (if you are still using the gcc devkits installation, that is) .  Download fix here (http://home.arcor.de/dtmrelrt/projects/golded/files/sp1.lzx).
Title: Re: funcdef macro in phxass?
Post by: cycloid on November 29, 2003, 12:44:40 AM
what? eh? it wants golded. i already deleted it, do i have to reinstall the golded thing to get the gcc things., what are the files? cant you just la up the different ones, i assume they're bins


Title: Re: funcdef macro in phxass?
Post by: cycloid on November 29, 2003, 01:13:38 AM
i'm wandering now if it's a problem with the files hunk2aout is generating as the actual "error" that ld puts out is "unsupported reloc: -1"after all the "bfd assertion fail" reports, and the number of those looks like it might correspond to the number of relocs that hunk2aout reports.

edit: i tried a hunk2aout from 1998 and that does the same as the one i was using before (1999)

edit 2: this
http://www.freelists.org/archives/yamos-dev/11-2002/msg00016.html
is the only thing on the whole internet that i've found that mirrors my problem. yet i'm not debugging as that link suggests.
Title: Re: funcdef macro in phxass?
Post by: Dietmar on November 29, 2003, 02:30:41 AM
>what? eh? it wants golded. i already deleted it, do i have to reinstall the golded thing to get the gcc things, what are the files?

The golded thing is called an editor. You can fix the problem manually by installing the gcc thing (libstdc++.a) from the service pack but you will have to look up how and where yourself in the install thing. That's the price for deleting golded :)
Title: Re: funcdef macro in phxass?
Post by: cycloid on November 29, 2003, 03:08:12 AM
yeah golded shmolded. i found the offending lib file anyway so it's ok. doesnt help me out though :-(
Title: Re: funcdef macro in phxass?
Post by: NovaCoder on December 23, 2010, 03:34:56 AM
funcdef.i

Code: [Select]

FUNCDEF     MACRO    *function
_LVO\1      EQU      FUNC_CNT
FUNC_CNT    SET      FUNC_CNT-6
            ENDM
FUNC_CNT    SET      5*-6