|
|
1.1 ! root 1: .data ! 2: .asciz "@(#)movc.s 1.1 86/02/03 Copyr 1984 Sun Micro" ! 3: .even ! 4: .text ! 5: ! 6: | Copyright (c) 1984 by Sun Microsystems, Inc. ! 7: ! 8: #include "../machine/asm_linkage.h" ! 9: ! 10: | Copy a block of storage - must not overlap ( from + len <= to) ! 11: | Usage: bcopy(from, to, count) ! 12: ENTRY(bcopy) ! 13: movl sp@(4),a0 | from ! 14: movl sp@(8),a1 | to ! 15: movl sp@(12),d0 | get count ! 16: jle ret | return if not positive ! 17: | If from address odd, move one byte to ! 18: | try to make things even ! 19: movw a0,d1 | from ! 20: btst #0,d1 | test for odd bit in from ! 21: jeq 1$ | even, skip ! 22: movb a0@+,a1@+ | move a byte ! 23: subql #1,d0 | adjust count ! 24: | If to address is odd now, we have to do byte moves ! 25: 1$: movl a1,d1 | low bit one if mutual oddness ! 26: btst #0,d1 | test low bit ! 27: jne bytes | do it slow and easy ! 28: | The addresses are now both even ! 29: | Now move longs ! 30: movl d0,d1 | save count ! 31: lsrl #2,d0 | get # longs ! 32: jra 3$ | enter long move loop ! 33: | The following loop runs in loop mode on 68010 ! 34: 2$: movl a0@+,a1@+ | move a long ! 35: 3$: dbra d0,2$ | decr, br if >= 0 ! 36: | Now up to 3 bytes remain to be moved ! 37: movl d1,d0 | restore count ! 38: andl #3,d0 | mod sizeof long ! 39: jra bytes | go do bytes ! 40: ! 41: | Here if we have to move byte-by-byte because ! 42: | the pointers didn't line up. 68010 loop mode is used. ! 43: bloop: movb a0@+,a1@+ | loop mode byte moves ! 44: bytes: dbra d0,bloop ! 45: ret: rts ! 46: ! 47: | Block copy with possibly overlapped operands ! 48: ENTRY(ovbcopy) ! 49: movl sp@(4),a0 | from ! 50: movl sp@(8),a1 | to ! 51: movl sp@(12),d0 | get count ! 52: jle ret | return if not positive ! 53: cmpl a0,a1 | check direction of copy ! 54: jgt bwd | do it backwards ! 55: | Here if from > to - copy bytes forward ! 56: jra 2$ ! 57: | Loop mode byte copy ! 58: 1$: movb a0@+,a1@+ ! 59: 2$: dbra d0,1$ ! 60: rts ! 61: | Here if from < to - copy bytes backwards ! 62: bwd: addl d0,a0 | get end of from area ! 63: addl d0,a1 | get end of to area ! 64: jra 2$ | enter loop ! 65: | Loop mode byte copy ! 66: 1$: movb a0@-,a1@- ! 67: 2$: dbra d0,1$ ! 68: rts ! 69: ! 70: ! 71: | Zero block of storage ! 72: | Usage: bzero(addr, length) ! 73: ENTRY2(bzero,blkclr) ! 74: movl sp@(4),a1 | address ! 75: movl sp@(8),d0 | length ! 76: clrl d1 | use zero register to avoid clr fetches ! 77: btst #0,sp@(7) | odd address? ! 78: jeq 1$ | no, skip ! 79: movb d1,a1@+ | do one byte ! 80: subql #1,d0 | to adjust to even address ! 81: 1$: movl d0,a0 | save possibly adjusted count ! 82: lsrl #2,d0 | get count of longs ! 83: jra 3$ | go to loop test ! 84: | Here is the fast inner loop - loop mode on 68010 ! 85: 2$: movl d1,a1@+ | store long ! 86: 3$: dbra d0,2$ | decr count; br until done ! 87: | Now up to 3 bytes remain to be cleared ! 88: movl a0,d0 | restore count ! 89: btst #1,d0 | need a short word? ! 90: jeq 4$ | no, skip ! 91: movw d1,a1@+ | do a short ! 92: 4$: btst #0,d0 | need another byte ! 93: jeq 5$ | no, skip ! 94: movb d1,a1@+ | do a byte ! 95: 5$: rts | all done
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.