cmu.s 489 B

1234567891011121314151617181920212223242526272829
  1. .define .cmu
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! on entry d0: # bytes of 1 block
  8. ! on exit d0: result
  9. .cmu:
  10. move.l (sp)+, d2 ! return address
  11. move.l sp, a0 ! address of top block
  12. lea 0(sp, d0.l), a1 ! address of lower block
  13. move.l d0, d1
  14. asr.l #2, d0
  15. 1:
  16. cmp.l (a0)+, (a1)+
  17. bne 2f
  18. sub.l #1, d0
  19. bne 1b ! note: on equal carry is set
  20. 2:
  21. bcc 3f
  22. neg.l d0 ! less
  23. 3:
  24. asl.l #1, d1
  25. add.l d1, sp ! new sp; two blocks popped
  26. move.l d2, -(sp)
  27. rts
  28. .align 2