next up previous contents

[ENGN3213 Home]

Assembly Code and Directives

Download the assembly program clab52s.s:

*                               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).

Exercises:

1.
Load the program.

2.
Describe what it does.

3.
Write down the hex addresses of all labels, and list their values (in hex). Be sure to determine the size and number of locations (bytes) used for the variable and constant.

4.
Run the program.

5.
Describe what it does.

6.
Single-step through the program and work out how to use breakpoints.

7.
Write an assembly language program for the code given first in section 6.6. Use directives to set up reset values for PC and SP. Assemble and run it and verify correctness of your code.

8.
Write an assembly language program to add the numbers between two given values LOWERNO and UPPERNO inclusive. Use directives to set up reset values for PC and SP. Assemble and run it and verify correctness of your code.


next up previous contents

[ENGN3213 Home]

ANU Engineering - ENGN3213