@database PhxMacros.guide
@author "Richard Körber"
@(c) "1996 Richard Körber - all rights reserved"
@$VER: phxmacros.guide V1.3 (21.10.96) [English]
@wordwrap
@width 80
@Node Main "PhxMacros: Table Of Contents"

                        _                _ _    _
                       |_)|_ \\/  |\\/| /|/ |_)/\\(_
                       |  | )/\\  |  |/-|\\_| \\\\/ _)


                         == TABLE OF CONTENTS ==

                @{" General Notes                    " link General}
                @{" Copyright                        " link Copyright}

                @{" Meta Instructions                " link Meta}
                @{" Assembler Compatibility          " link AsmCompat}
                @{" Data Definitions                 " link DataDef}
                @{" String Operation                 " link StringOp}
                @{" Miscellaneous Macros             " link Misc}

                @{" History                          " link History}

    © 1996 Richard Körber -- all rights reserved
    PhxAss is © 1991-96 by Frank Wille

@EndNode
@Node General "PhxMacros: General Notes"

 GENERAL NOTES
***************

· This macro library REQUIRES some special abilities of PhxAss
  Version 4.33 or higher, for full functionality. Some macros may
  cause trouble or produce errors on other assemblers or older
  PhxAss versions.


· The "peek" macro has been renamed to "top" ("peekm" is now called
  "topm"). The new name is commonly used in the computer world for
  this purpose. Please fix your sources if you've used this macro.

@EndNode
@Node Copyright "PhxMacros: Copyright"

PhxMacros are © 1996 by Richard Körber. All Rights Reserved.

This Macro collection is FreeWare!

This archive may be distributed freely as long as the archive  remains
complete  and unchanged. You are allowed to charge a maximum fee of DM
8 (or equivalent)  to  cover  all  costs  including  media.  Otherwise
written  permission  from  the  author is required. The package may be
compressed by the usual (and free)  programs  (like  lha,  lzh,  lzx).
Single files of the package must not be compressed!

I allow the Fred Fish library and AmiNet to include  this  package  on
their  CDs.  Permission is also granted to Frank Wille to include this
package in his PhxAss package.

The archive consists of the following files:

· PhxMacros.i                   The macro library
· PhxMacros.guide               This guide file

Usage for fascist or military purposes is FORBIDDEN!

You use this package "as is" and at your own risk. The author (Richard
Körber)  is not responsible for any damage, including (but not limited
to) hard- or software damages or data loss.

Please delete this archive and all related files *NOW* if  you do  not
agree with these copyright notes.


For questions, bug reports, suggestions and all that jazz, please get
in contact with me via E-Mail:

        shred@chessy.aworld.de

If this E-Mail address should trouble, you can also try to reach me at:

        rkoerber@tfh.dssd.sub.org       (international)
        shred@eratosth.dssd.sub.org     (Germany only!)



    PhxAss is © Frank Wille (e.g. AmiNet)

    AmigaGuide is © Commodore-Amiga. (e.g. Fish Disk #920)

@EndNode
@Node Meta "PhxMacros: Meta Instructions"

 META INSTRUCTIONS
*******************

Meta instructions (also called Pseudo Commands) behave like real 680x0
instructions, yet they are emulated by a macro.


inc.? <ea>      Increments the <ea> by one.

                Examples:       inc.b   d0
                                inc     (a0)


dec.? <ea>      Decrements the <ea> by one.

                Examples:       dec.b   d0
                                dec     (a0)


push.? <ea>     Pushes the <ea> to the stack. !!! Only .w or .l allowed !!!

                Examples:       push    d0
                                push.l  (4,a0)


top.? <ea>      Read the top entry of the stack, without removing.

                Examples:       peek    d0
                                peek.l  (a4)


pop.? <ea>      Pops from the stack. !!! Only .w or .l allowed !!!

                Examples:       pop     d0
                                pop.l   (a3)


pushm.? <set>   Pushes the register set to the stack. !!! Only .w or .l !!!

                Example:        pushm.l d0-d3/a0-a3


topm.? <set>    Read the top register set of the stack, without removing.

                Example:        peekm.l d0-d3


popm.? <set>    Pops a register set from the stack. !!! Only .w or .l !!!

                Example:        popm.l  d0-d3/a0-a3


store           Stores the registers d0-d7 and a0-a6 on the stack.


recall          Restores the registers d0-d7 and a0-a6 from the stack.


r<cc>           Conditional rts. You may use all the standard condition
                codes.

                Examples:       req
                                rvs


bsr<cc>.? <a>   Conditional branch to subroutine. You may use all the
                standard condition codes. Branch optimizer works here
                as usual.

                Examples:       bsreq.b near_eq
                                bsrvs   vs_error
                                bsrhi.l far_hi     ; 68020+ only


flip.? <data>   Flips the data register <data> between big endian and
                little endian. Only .w or .l allowed.

                Examples:       flip.l  d0
                                flip    d3


extbl <data>    Sign extends the data register <data> from byte to
                longword. The extb.l instruction will be used by this
                macro if MACHINE 68020 or higher is set.

                Example:        extbl   d0

@EndNode
@Node AsmCompat "PhxMacros: Assembler Compatibility"

 ASSEMBLER COMPATIBILITY
*************************

These Macros provide compatibility to other assembler, like Seka,
DevPac or AsmOne. Please note that they are obsoleted. Don't use
them in new code!


align <val>     Aligns the address counter to a multiple of <val>.
                (Seka, DevPac, AsmOne)

                Example:        align   4       ;Align to long word


odd             Opposite of 'even': aligns to an odd address.
                (Seka, DevPac, AsmOne)


pushem.? <set>  Pushes the register set to the stack. !!! Only .w or .l !!!
                (DevPac)

                Example:        pushm.l d0-d3/a0-a3


popem.? <set>   Pops a register set from the stack. !!! Only .w or .l !!!
                (DevPac)

                Example:        popm.l  d0-d3/a0-a3

@EndNode
@Node DataDef "PhxMacros: Data Definitions"

 DATA DEFINITIONS
******************

The following macros will define strings or data in the DATA section.
Note that all strings will automatically be 0 terminated.


leastr <string>,<adr>
                The string <string> is created in the DATA section. A
                pointer to this string is provided in the address register
                <adr>.

                Example:        leastr  "dos.library",a1


peastr <string>  The string <string> is created in the DATA section. A
                pointer to this string is provided on the stack. This is
                useful for e.g. taglist construction on stack.

                Example:        peastr  "TestWindow"
                                pea     WA_Title


defstr <label>,<str>
                Defines the string <str> in the DATA section and references
                it by <label>.

                Example:        defstr  dosname,"dos.library"


def.? <label>[,<label>...]
                Defines label with the size ? and value 0 in the BSS section.

                Examples:       def.l   sysbase,dosbase,gfxbase
                                def.b   flag1,flag2,flag3

@EndNode
@Node StringOp "PhxMacros: String Operation"

 STRING OPERATION
******************

String operation macros provide instruction for easy string handling.
Important: the default size of this macros is WORD !

copy.? <src>,<dest>
                Copies the string from source to destination. The copy
                process is terminated after 0 has been copied. None of
                the provided registers will be stored!

                Examples:       copy.b  (a0)+,(a1)+
                                copy.l  (a0)+,-(sp)


strln.? <str>,<lenreg>
                Finds out the string length of the string provided by
                the address register <str>. The length is returned in
                the address/data register <lenreg>. Except for the
                <lenreg>, no registers will change its contents. The
                length includes the termination.

                Examples:       leastr  "Teststring",a0
                                strln.b a0,d0   ;Length is in d0
                                strln.l a1,d0   ;Number of e.g. tags

@EndNode
@Node Misc "PhxMacros: Miscellaneous Macros"

 MISCELLANEOUS MACROS
**********************

These are frequently used macros for miscellaneous purposes.


proc <name>,<set>
                Defines a procedure header. The procedure is called
                <name> and stores the register set <set> on the stack.

xproc <name>,<set>
                Like proc, but the procedure name is referenced using
                XDEF <name>.

endp <name>     Terminates a procedure. The register set is restored,
                and the procedure returnes by ret instruction.

                Example:        proc    testprog , d1-d3/a0-a3
                                ; your procedure
                                endp    testprog


args <arg>[,<arg>...]
                Pass a list of arguments to the stack. All arguments
                will be longwords! After this operation, the stack
                pointer points to the first provided parameter.

margs <arg>[,<arg>...]
                Puts more arguments to the stack. Note that even though
                the parameters seem to be in right order (in fact, the
                macro reads them from the right to the left), you have
                to pass the last parameter list first, using "args",
                and then use "margs" in backward order.

unargs          Removes the parameters provided by "args" and "margs"
                from the stack. The "unargs" macro always refers to the
                last "margs" macro calls up to the first previous "args"
                macro call. IMPORTANT: Do not nest "args" and "unargs"
                calls! Always use "unargs" *below* the appropriate "args"
                and "margs"!

                Example:        args    #TAG_DONE       ; Note that they
                                margs   #WA_InnerHeight,d1 ; are upside down!
                                margs   #WA_InnerWidth,d0
                                move.l  sp,a1           ; Parameters in A1
                                ; use the args
                                unargs

@EndNode
@Node History "PhxMacros: History"

 HISTORY
*********

V1.3 (21.10.96)
        - Renamed "peek" and "peekm" to "top" and "topm".
        - Reviewed the corrections from Frank Wille.
        - Now uses the "def2" macro from Frank as "def" macro.
        - Added "args", "margs", and "unargs".

V1.2 (14.10.96) [by Frank Wille]
        - Removed IFCPU macro.
        - Fixed ODD macro.
        - Fixed FLIP macro.
        - Fixed EXTBL macro.
        - Added "def2" macro as improvement for "def".

V1.1 ( 9. 9.96)
        - Added conditional bsr and conditional rts.
        - Added "proc", "xproc" and "endp".
        - Added "pushem" and "popem" for assembler compatibility.
        - Added "copy" and "strlen".

V1.0 ( 28. 8.96)
        - First internal release.

@EndNode

