Welcome, Guest. Please login or register.

Author Topic: funcdef macro in phxass?  (Read 7594 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
funcdef macro in phxass?
« 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
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: funcdef macro in phxass?
« Reply #1 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...
int p; // A
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: funcdef macro in phxass?
« Reply #2 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.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: funcdef macro in phxass?
« Reply #3 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...
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: funcdef macro in phxass?
« Reply #4 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...
int p; // A
 

Offline xeron

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 2533
    • Show only replies by xeron
    • http://www.petergordon.org.uk
Re: funcdef macro in phxass?
« Reply #5 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

Playstation Network ID: xeron6
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: funcdef macro in phxass?
« Reply #6 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!
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: funcdef macro in phxass?
« Reply #7 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.
int p; // A
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: funcdef macro in phxass?
« Reply #8 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?
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: funcdef macro in phxass?
« Reply #9 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...
int p; // A
 

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show only replies by itix
Re: funcdef macro in phxass?
« Reply #10 on: November 27, 2003, 02:03:01 AM »
Are you sure you invoked PhxAss correctly? I can't imagine any other
reason.
My Amigas: A500, Mac Mini and PowerBook
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: funcdef macro in phxass?
« Reply #11 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

 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: funcdef macro in phxass?
« Reply #12 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.
int p; // A
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: funcdef macro in phxass?
« Reply #13 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!? :-(
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: funcdef macro in phxass?
« Reply #14 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.