|
|
1.1 ! root 1: .data ! 2: .asciz "@(#)ocsum.s 4.4 83/08/16 Copyr 1983 Sun Micro" ! 3: .even ! 4: .text ! 5: ! 6: | Copyright (c) 1983 by Sun Microsystems, Inc. ! 7: ! 8: | Do a 16 bit one's complement sum of a given number of words ! 9: | The word pointer may not be odd ! 10: .globl _ocsum ! 11: _ocsum: ! 12: movl sp@(4),a0 | get ptr ! 13: movl sp@(8),d0 | get word count ! 14: movl d2,sp@- | save a reg ! 15: movl d0,d2 | save the count ! 16: lsrl #1,d0 | make d0 longs ! 17: movl #0,d1 | zero accumulator ! 18: jra 1$ | into loop ! 19: | Here we run in 68010 loop mode until we get a carry ! 20: 2$: addl a0@+,d1 | add in long ! 21: 1$: dbcs d0,2$ | continue until carry or done ! 22: jcc 3$ | if no carry, we're done ! 23: addql #1,d1 | add in carry ! 24: jra 1$ | and go back to test for carry again ! 25: 3$: btst #0,d2 | another short? ! 26: jeq ret | no, go away ! 27: movl #0,d0 | must do unsigned add ! 28: movw a0@,d0 | get the short ! 29: addl d0,d1 | add it in ! 30: jcc ret ! 31: addql #1,d1 ! 32: | Now add in high word to low word as above ! 33: ret: ! 34: movl d1,d0 ! 35: lsrl #8,d0 | get high word in d0 ! 36: lsrl #8,d0 | and clear high do as well ! 37: andl #0xFFFF,d1 | clear high d1 ! 38: addw d1,d0 | add in just the low word ! 39: movl #0,d1 | doesn't clear x bit ! 40: addxw d1,d0 | add in final carry ! 41: movl sp@+,d2 | restore reg ! 42: rts | all done
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.