next up previous contents index

[ENGN3213 Home]

Assembly Example

  The following example comes from CLAB5:

*                               clab52s.s
        ORG     $0 
        DC.L    $8000           Stack pointer value after a reset
        DC.L    START           Program counter value after a reset


        ORG     $2000           Start at location 2000 Hex

START   CLR.W   SUM             Clear variable SUM
        MOVE.W  COUNT,D0        Load COUNT value
LOOP    ADD.W   D0,SUM          ADD D0 to SUM
        SUB.W   #1,D0           Decrement counter
        BNE     LOOP            Loop if counter not zero
        MOVE.W  SUM,D7          copy sum to D7
        BREAK                   Tell the simulator to BREAK if we're running

SUM     DS.W    1               Reserve one word for SUM
COUNT   DC.W    25              Initial value for COUNT

This file contains a mixture of assembly language code and assembler directives.   The assembly language is standard Motorola 68000, as described in Motorola documentation and in the text (Clements, Chapter 2). Assembler directives and syntax vary from assembler to assembler, and the ones used here are similar to the textbook (Clements, pp 15).

The syntax used here applies to the 68kasm assembler used in CLABS 5 and 6. The user manual for 68kasm is given in the lab manual. A different syntax will be used for the GCC cross development system, which includes the m68k-coff-as assembler; these will be used in CLAB7 and HLABS6-9. Some aspects of the m68k-coff-as syntax are included as part of the lab manual.


next up previous contents index

[ENGN3213 Home]

ANU Engineering - ENGN3213