next up previous contents

[ENGN3213 Home]

A First Example

The following assembly program is adapted from clab52s.s/clab70s.s. Download the file hlab61s.s:

/*    hlab61s.s   - m68k-coff-as COLDFIRE version of clab52s.s/clab70s.s  */

      .text
      .even
      .global  main
main:                        /* start of main program */
      clr.l    sum           /* clear variable sum */
      move.l   count,%d0     /* load count value */
loop: add.l   %d0,sum        /* add d0 to sum */
      sub.l    #1,%d0        /* decrement counter */
      bne      loop          /* loop if counter not zero */
      move.l   sum,%d7
      rts                    /* return to caller */	
sum:	.space 4
count:  .long 25

This is very similar to clab70s.s for the 68000, except that certain .w versions of instructions are not supported for the Coldfire. So this program now works with 32 bit integers.



ANU Engineering - ENGN3213