;ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
;Û                                                                           Û
;Û                             MEMORY PROCEDURES                             Û
;Û                                                                           Û
;Û                    These procedures are not optimized.                    Û
;Û                                                                           Û
;Û       NOTE: '@' - this char can use only with PROC/PROCS and MACRO.       Û
;Û                                                                           Û
;ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
;-----------------------------------------------------------------------------
; Copy memory.
; in: ((_from_)) - from.
;       ((_to_)) - to.
;   ((_length_)) - total length in bytes.
;-----------------------------------------------------------------------------
CopyMemory PROC ((_from_)),((_to_)),((_length_))
 ldx _to_+1
 lda _length_
 bne _copmem1_
 ldy _length_+1
 BNE _copmem1_
 rts
_copmem1_:
 cpx _from_+1
 bmi _copmem5_
 bne _copmem2_
 ldx _to_
 cpx _from_
 bmi _copmem5_
 beq _copmem5_

_copmem2_:     ;end
 lda _from_+1
 add _length_+1
 sta _from_+1

 lda _to_+1
 add _length_+1
 sta _to_+1

 ldy _length_
 beq _copmem4_
_copmem3_:
 DEY
 lda (_from_),y
 sta (_to_),y
 cpy #0
 bne _copmem3_
_copmem4_:
 dec _from_+1
 dec _to_+1
 lda _length_+1
 bne _copmem3_
 rts

_copmem5_: ;front
 ldy #0
_copmem6_:
 lda (_from_),y
 sta (_to_),y
 iny
 cpy _length_
 bmi _copmem6_
 lda _length_+1
 bne _copmem7_
 rts

_copmem7_: 
 lda _from_
 add _length_
 sta _from_
 lda _from_+1
 adc #0
 sta _from_+1

 lda _to_
 add _length_
 STA _to_
 lda _to_+1
 adc #0
 sta _to_+1
_copmem8_:
 ldy #0
_copmem9_:
 lda (_from_),y
 sta (_to_),y
 iny
 bne _copmem9_
 inc _from_+1
 inc _to_+1
 dec _length_+1
 bne _copmem8_
 rts
_from_=32    ;(2)
_to_=34      ;(2)
_length_=36  ;(2)
ENDP

