home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / code / asm_byte.sit < prev    next >
Encoding:
Text File  |  1988-05-14  |  4.0 KB  |  92 lines

  1. 11-May-88 21:20:33-MDT,4172;000000000000
  2. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  3. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Wed, 11 May 88 21:20:25 MDT
  4. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  5.     id AA03049; Wed, 11 May 88 21:20:57 MDT
  6. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  7.     id AA29197; Wed, 11 May 88 21:20:54 MDT
  8. Date: Wed, 11 May 88 21:20:54 MDT
  9. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  10. Message-Id: <8805120320.AA29197@sunset.utah.edu>
  11. To: rthum@simtel20.arpa
  12. Subject: ByteXfer.asm
  13.  
  14. ;-----------------------------------------------------------------------------------
  15. ;
  16. ;     Procedure ByteTfr(SrcPtr,SrcStart,DstPtr,DstStart,NumBytes);
  17. ;              Ptr     Int      Ptr     Int      Int
  18. ;
  19. ; This takes any set of bytes from one memory location and copies it to another.
  20. ; It also takes into consideration transfers of data within the same block so as
  21. ;  to not replicate the same item through the block.
  22. ;
  23. ;  Written July 10, 1985 by Joseph F. Buchanan - University of Utah Computer Center
  24. ;-----------------------------------------------------------------------------------
  25. ;
  26. XDEF        ByteTfr
  27. ByteTfr
  28.                 LINK    a6,#0            ; set frame pointer
  29.                 Move.W  8(a6),d2        ; get number of bytes to move
  30.                 Move.W  10(a6),d1       ;Get offset
  31.                 Move.L  12(a6),a1       ;get the Destination Pointer
  32.                 Move.W  16(a6),d0       ;Get offset
  33.                 Move.L  18(a6),a0       ;get the Source Pointer
  34.                 add.w   d0,a0            ; get real address of source+offset
  35.                 add.w   d1,a1            ; get real address of dest+offset
  36.                 subq.w  #1,d2            ; make relative o
  37.                 move.l  a0,d0
  38.                 sub.l   a1,d0            ; see if before source block
  39.                 BGE.s   @3            ; dest begins before src
  40.                 move.l  a0,d0
  41.                 add.l   d2,d0            ; get real address of end of src block
  42.                 sub.l   a1,d0            ; see if after source block
  43.                 BLT.s   @3            ; dest begins after src
  44.                 add.l   d2,a0            ; set start pt of src to past end of block
  45.                 addq.l  #1,a0
  46.                 add.l   d2,a1            ; set start pt of dst to past end of block
  47.                 addq.l  #1,a1
  48. @1
  49.                 move.b  -(a0),d0        ; take a byte
  50.                 move.b  d0,-(a1)        ; give a byte
  51.                 dbra    d2,@1
  52.                 BRA.s   @4
  53. @3
  54.                 move.b  (a0)+,d0        ; take a byte
  55.                 move.b  d0,(a1)+        ; give a byte
  56.                 dbra    d2,@3
  57. @4
  58.                 unlk    a6            ; restore frame pointer
  59.                 move.l  (SP)+,a1        ; get return address
  60.                 add.w   #14,SP            ; pop parameters off stack
  61.                 JMP     (a1)            ; return
  62.  
  63. ;-----------------------------------------------------------------------------------
  64. ;
  65. ;     Procedure BlkStore(Ptr,Start,NumBytes,value);
  66. ;             Ptr  Int   Int         Int
  67. ;
  68. ; This takes the value in the lower half of the value integer and fills the
  69. ; memory area pointed to with that value from the start through NumBytes.
  70. ;
  71. ; Written July 15, 1985 by Joseph F. Buchanan - University of Utah Computer Center
  72. ;-----------------------------------------------------------------------------------
  73. ;
  74. XDEF        BlkStore
  75. BlkStore
  76.                 LINK    a6,#0            ; set frame pointer
  77.                 Move.W  8(a6),d2        ; get value
  78.                 Move.W  10(a6),d1       ; get number of bytes to clobber
  79.                 Move.W  12(a6),d0       ; Get offset
  80.                 Move.L  14(a6),a0       ; get the Pointer
  81.                 add.w   d0,a0            ; get real address of buffer+offset
  82.                 subq.w  #1,d1            ; make relative 0
  83. @5
  84.                 move.b  d2,(a0)+        ; give a byte
  85.                 dbra    d1,@5
  86.                 unlk    a6            ; restore frame pointer
  87.                 move.l  (SP)+,a1        ; get return address
  88.                 add.w   #10,SP            ; pop parameters off stack
  89.                 JMP     (a1)            ; return
  90.  
  91.                 END
  92.