EZAsm

Version 1.37 September 2001

By Joe Siebenmann

http://www.geocities.com/ezasm


What is EZAsm?
Addressing modes
Statement arguments
Optimizations
Variable declaration
Statement Information
Additional Information
Using EZAsm


Statements:

Addition  Subtraction
Multiplication  Division
And  OR  Exclusive-OR
Shift  Left/Right
Assignment
If Else Syntax
Compare
Bit Test

Errors
Contacting the author

------- NO LIABILITY FOR CONSEQUENTIAL DAMAGES -------

IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DAMAGES

WHATSOEVER ARISING OUT OF THE USE OF OR INABILITY TO USE

THIS PROGRAM.


What is EZAsm?

EZAsm originally was an assembly language development tool for the Amiga. After I discovered the Palm Computing(R) Platform I ported it over and made many enhancements. EZAsm frees you from most of the user-unfriendliness associated with assembly language programming allowing you to concentrate more on your program. It combines 680X0 assembly language with parts of C. The result is highly optimized code, with a much shorter development time! Here are some of its advantages:


Traditionally, assembly language applications have always had the smallest executable size and the highest performance. In the Pilot environment, application size and speed are very important. Small assembly applications are relatively easy to program. Medium sized applications can take a long time to develop, and large ones...?? Using EZAsm, small to medium sized applications should be easy to develop and, after breaking down complex code into simpler pieces, it should make even large application development manageable.

You need to be familiar with using Pila.exe, especially how it uses structure references.

Here are some links you might find useful ( sorry, some of these may be broken links ):


What's new for Version 1.37

New for Version 1.35

New for Version 1.34

New for Version 1.32

New for version 1.30

New for version 1.29

New for version 1.1x/.2x


Addressing Modes

					Operand Legends
                     Operand Type

    Mode       [A] [B] [C] [D] [E] [F]

Dn              *   *   *   -   *   -
An              *   -   *   -   -   -
(An)            *   *   *   *   *   *
(An)+           *   *   *   *   *   *
-(An)           *   *   *   *   *   *
d16(An)         *   *   *   *   *   *
d8(An,Xn)       *   *   *   *   *   *
16 bit addr     *   *   *   *   *   *
32 bit addr     *   *   *   *   *   *
d16(PC)         *   -   -   -   *   *
d8(PC,Xn)       *   -   -   -   *   *
immediate       *   -   -   -   *   -

bd(An,Xn)       *   *   *   *   *   *     68020/68030
([bd,An],Xn,od) *   *   *   *   *   *     68020/68030
([bd,An,Xn],od) *   *   *   *   *   *     68020/68030
bd(PC,Xn)       *   -   -   -   *   *     68020/68030
([bd,PC],Xn,od) *   -   -   -   *   *     68020/68030
([bd,PC,Xn],od) *   -   -   -   *   *     68020/68030

Global and local variables = d16(An)

Operand Legends,



<1-8>	1 - 8
<q>	( quick ) -128 - 127
<n>	any byte, word, or long size number

Dn	d0 - d7
An	a0 - a7

{B}	byte data size not allowed for An operands

bd	32 bit displacement
od	32 bit outer displacement

Xn      a0 - a7  d0 - d7

     Options:              Examples:

     size:  .w  .l         a2.w  a0.l
     scale: *1 *2 *4 *8    a1*2  a0.w*4  ( 68020/68030 )


Addition Subtraction

      OPERANDS           SIZES		Addressing modes
					Operand Legends

++
--

    [C] <op>            L,W,{B}   *

+=
-=
	
     Dn <op> [A]        L,W,B   		

     An <op> [A]        L,W       *

    [D] <op> Dn         L,W,B
	
    [B] <op> <n>        L,W,B		
	
    [C] <op> <1-8>      L,W,{B}   *	


Examples:

	Total ++	
	d1 += 10

Optional Args:

	l, w, b 

*	When appropriate, these are optimized by making the size word
	(.w) instead of long (.l) for "An" operands.  It uses fewer cycles,
	and the upper two bytes are correctly handled.


Multiplication Division

      OPERANDS         SIZES		Addressing modes
					Operand Legends

*=

    Dn *= [E]           W

    Dn *= ##            W   *


/=

    Dn /= [E]           W
	

Examples:

	d0 *= d1
	d2 /= 2

Optional Args:

	w,
	s ( signed  divs/muls )


*	This optimization results in code that's larger then
	"mulu" or "muls", but will execute much faster.  Not all numbers
	can be optimized.  If the number doesn't work, "mulu"
	or "muls" will be used.

	( where ## is a word or byte length number )

And OR Exclusive-OR


      OPERANDS          SIZES		Addressing modes
					Operand Legends

&=
|=

     Dn <op> [E]        L,W,B

    [B] <op> <n>        L,W,B	
	
    [D] <op> Dn         L,W,B

^=

    [B] <op> Dn         L,W,B	
	
    [B] <op> <n>        L,W,B


Examples:

	Mask &= %11010000
	Flags |= $f0

Optional Args:

	l, w, b 


Shift Left/Right

      OPERANDS          SIZES		Addressing modes
					Operand Legends

<<
>>

     Dn <op> Dn         L,W,B
	
     Dn <op> 1-31       L,W,B    *

    [D] <op> 1          W


Examples:

	d2 << d0
	d1 >> 4

Optional Args:

	l, w, b,
	a = Preserves the sign bit by use of "asr" and "ext.l".
	    Use only with right shifts ( ">>" ).

*	Normally you're limited to shifting 1-8, or using a
	data register to hold higher shift values.  This
	optimized version is faster, and saves using a data register!


Assignment

      OPERANDS           SIZES		Addressing modes
					Operand Legends
=	

    [B] = [A]           L,W,{B}
	
     An = [A]           L,W
	

Examples:

	temp = Total
	(a1)+ = 0 w

Optional Args:

	l, w, b 


If Else Syntax


Compare and Bit test statements use this syntax:


    operand <op> operand label



    operand <op> operand {
        .
        .
    }



    operand <op> operand {
        .
        .
	
    } else {
        .
        .
    }



Compare
      OPERANDS           SIZES		Addressing modes
					Brace syntax
					Operand Legends
>=
<=
!=
>
<
=

     Dn <op> [A]        L,W,{B}
	
     An <op> [A]        L,W
	
    [B] <op> <n>        L,W,B
	
  (An)+ <op> (An)+      L,W,B


Examples:

	Total >= 100 Over

	pBitmapHnd != 0 {
		MemHandleUnlock( pBitmapHnd )
	}


Optional Args:

	l, w, b,
	s ( signed )


Bit Test

      OPERANDS        SIZES		Addressing modes
					Brace syntax
					Operand Legends
=
!=


   Dn:0-31 <op> 0-1     L
	
     Dn:Dn <op> 0-1     L
	
	
   [F]:0-7 <op> 0-1     B	
	
    [F]:Dn <op> 0-1     B


Examples:

	d1:0 != 1 EvenRtn

	($bfe001):6 = 0 LMBDown

	d2:d0 = 1 {
		rts
	}


Optional Args:  ( ignored )
	
Rules:

Statement Arguments


    b   forces operation to be byte

    w     "       "        "   word

    l     "       "        "   long

    a   preserves sign bit     ( >> )

    s   signed                 ( *=, /=, compares )


( it's OK to use multiple arguments ( "w s" etc. ))

Also, see note in Statement Information



Save / Restore Register string

Saves registers you request at the start of a procedure and restores them before exiting. Yet another time saving feature.. :)

Usage:		SAVER  register list

Example:	SAVER d2-d4/a1-a3

Use at the top of your procedure or immediately following your variable declarations.
Will generate these statements:

	movem.l	d2-d4/a1-a3,-(a7)

	.
	.

	movem.l	(a7)+,d2-d4/a1-a3


Using Functions

        EvtGetEvent(&evt #evtWaitForever.w)
                        ^
                        | space required


        err = DmDatabaseInfo( 0 CurrDBID &name &attR 0 &crDate
                0 0 0 0 0 &typeR &creatorR )


        a3 = FrmInitForm( EventType.data+frmLoad.formID(a0) )

Arguments:

		\b	backspace
		\f	form feed
		\n	newline
		\r	carriage return
		\t	horizontal tab
		\v	vertical tab
		\\	backslash
		\"	double quote
		\'	single quote
		\nnn	octal character value
		\xnn	hex character value

Using HostControl Tracing functions and Palm Reporter

EZAsm now supports HostControl Tracing functions, which when used with the Palm Reporter, make debugging a lot nicer. The Palm Reporter is a Trace utility used with the Emulator. These functions send debugging information in real-time to the Reporter window. Reporter is available on Palm's Emulator page:

Palm Reporter

Tips on using Palm Reporter



Using the functions


Example:
appErrorClass  equ  $8000



        HostTraceInit()

        HostTraceOutputTL(#appErrorClass "Starting...")

        HostTraceOutputTL(#appErrorClass "(a3): %lx" (a3).l)
                                                          ^
                                                          | size required *

        HostTraceClose()



Using EZAsm




Optimizations

EZAsm's output can't beat hand optimized code, but in many cases it will come close.
I've looked at the disassembled output of many 'hand coded' assembly programs and almost every one could benefit from being run through EZAsm, with a little re-coding.. ;) ( EZAsm doesn't try to optimize hard-coded assembly statements ) I've thrown in almost every trick in the book and then some! ;) If you haven't guessed by now, I'm crazy about optimizing, I've tried to squeeze every last cycle and/or use the least amount of bytes. The best part is you don't have to think about it!


Statement Information

Additional Information

err	equ	-24
... error: Symbol value differs between first and second pass

BYTE	evt[EventType]

	evt.eType.w != #appStopEvent ...


Variable Declaration


LONG	foo bar
WORD    DMASave
BYTE8	Buf[20]
BYTE	evt[EventType]


Errors

"Illegal argument"

The argument found was not valid for the operator. See the list of Addressing Modes for the operator. It must be lower case, and be separated from the operands by at least a space or a tab.

"Illegal operand"

One, or both, of the operands are: not valid for the operator, have an invalid number, or byte size was specified for an "An" operand ( {B} ). In most cases it's looking for "Dn" or "An" as an operand. ( look under Addressing Modes for a valid combination )

"Illegal size"

The size argument you specified is not valid for the operator.

"Needs size argument"

It doesn't have enough size information about the operands to calculate an instruction size. You need to add an l, w, or b size argument.

"Label not found"

No matching label was found.

"Brace mismatch"

Checks are made when a closing brace ( "}" ) is hit, and when the end of source is reached. If the brace stack is "messed up" at that time, an error is given.

"Function not found"

No API function or procedure matching your function name was found. Check case and spelling of function name. Check the "funcs" data file for supported function names.


Contacting the author

Try using EZAsm, I don't think you'll want to go back to "ordinary" assembly language programming. ;)

Your feedback is very important, if you have any suggestions for improvements, found bugs, or just want to say "Hay!", please send a message, I'd like to hear from you! Really! ;)

Enjoy!

You can reach me at:

joe131@excite.com

Joe Siebenmann
2204 Pimmit Run Lane  #1
Falls Church, VA  22043
( USA )