home *** CD-ROM | disk | FTP | other *** search
- * test.sa - test file for as68... bubble sort
- * (from example 5-4 of Leo Scanlon's "The 68000: Principles and Programming")
- *
- ORG $4000
-
- sort nop first part of program
- link a3,#-20 try the link instruction
- movem.l d0-d3/a0/a1,-(sp)
- clr.b temp1 exchange flag = 0
- move (a0)+,d3 load word count to d3
- loop move.l a0,a1 load elt. addr. into a1
- subq #1,d3 decrement word count
- move d3,d0 and load it into counter
- comp move (a1)+,d2 fetch word to d2
- cmp (a1),d2 is next .gt. this?
- bls.s decctr yes, continue
- move (a1),-2(a1) else no - exchange these two
- move d2,(a1)
- tas temp1 turnn on exchange flag
- decctr dbf d0,comp end?
- not.b temp1 yes - exchange is over
- bpl.s loop if so, start over
- movem.l (sp)+,d0-d3/a0/a1 restore scratch
- done rts exit
-
- temp dc.l 1234
- temp1 dc.w 9876
- dc.b 12
- dc.b 15
- dc.b 'Hello there ASCII text! How''s things?'
- ds.w 0
- dc.w 100
-
- END
-