INTRODUCTION

ESA is a code pre-processor that allows to enrich M68k assembly sources with inline constructions typical of higher-level languages like BASIC/C/Pascal (hence the name Extended-Syntax Assembly). It takes enriched sources and outputs standard MC68020 assembly sources.

For example, ESA compiles this snippet of code enriched with a "while" loop...

           while.s d0.b
            move.b    d0,-(a0)
            lsr.b     #1,d0
           ewhile
... into the following assembly code:
.0000000   tst.b      d0
           beq.s      .0000001
           move.b     d0,-(a0)
           lsr.b      #1,d0
           bra.s      .0000000
.0000001

More in detail, ESA offers:

leaving the programmer, at the same time, free to fiddle with registers, variables, etc. as per usual.

This more complex example gives a better idea - and there is even much more!

***************************************************************************
* INFO     Copies a string enclosed between two quotes.
* SYN      EndAdr = CpyQtdStr[SrcAdr,DstAdr]
*          d0.l               a0.l   a1.l
* IN       SrcAdr: pointer to source string
*          DstAdr: address of destination buffer
* OUT      EndAdr: pointer to the end of source string (0 = ERROR)
* WARN     Be careful: there is no check.
* NOTE     - The first character of the string is assumed to be the quote.
*          - The copied string gets NUL-terminated.
*          - Fails at the first LF or NUL.
***************************************************************************
ESA
           function CpyQtdStr[a0-a1],d1/a0-a1:d0.l

           move.b       (a0)+,d0           ;get quote

           repeat
            move.b      (a0)+,d1           ;get character
            switch.s d1.b                  ;act depending on character

            -> d0                          ;closing quote
             clr.b      (a0)               ;NUL-termination
             moveq.l    #0,d1              ;exit loop

            -> #0                          ;NUL
             suba.l     a0,a0              ;error

            -> #10                         ;LF
             moveq.l    #0,d1              ;exit loop
             suba.l     a0,a0              ;error

            def
             move.b     d1,(a1)+           ;copy character

            eswitch
           until.s ~d1.b

           efunc,a0                        ;return string end pointer
assembly
f0000000   movem.l      d1/a0-a1,-(sp)

           move.b       (a0)+,d0


.0000002
           move.b       (a0)+,d1


            cmp.b       d0,d1
           bne.s        .0000003
           clr.b        (a0)
           moveq.l      #0,d1

           bra.s        .0000004
.0000003   cmpi.b       #0,d1
           bne.s        .0000005
           suba.l       a0,a0

           bra.s        .0000004
.0000005   cmpi.b       #10,d1
           bne.s        .0000006
           moveq.l      #0,d1
           suba.l       a0,a0

           bra.s        .0000004
.0000006
           move.b       d1,(a1)+

.0000004
           tst.b        d1
           bne.s        .0000002

           move.l       a0,d0
f0000001   movem.l      (sp)+,d1/a0-a1
           rts



home