git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/libc/asm/mos6502/memcpy.s

      1 ;-------------------------------------------------------------------------
      2 ;   memcpy.s - standarc C library
      3 ;
      4 ;   Copyright (C) 2003, Ullrich von Bassewitz
      5 ;   Copyright (C) 2009, Christian Krueger
      6 ;   Copyright (C) 2022-2023, Gabriele Gorla
      7 ;
      8 ;   This library is free software; you can redistribute it and/or modify it
      9 ;   under the terms of the GNU General Public License as published by the
     10 ;   Free Software Foundation; either version 2, or (at your option) any
     11 ;   later version.
     12 ;
     13 ;   This library is distributed in the hope that it will be useful,
     14 ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 ;   GNU General Public License for more details.
     17 ;
     18 ;   You should have received a copy of the GNU General Public License
     19 ;   along with this library; see the file COPYING. If not, write to the
     20 ;   Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
     21 ;   MA 02110-1301, USA.
     22 ;
     23 ;   As a special exception, if you link this library with other files,
     24 ;   some of which are compiled with SDCC, to produce an executable,
     25 ;   this library does not by itself cause the resulting executable to
     26 ;   be covered by the GNU General Public License. This exception does
     27 ;   not however invalidate any other reasons why the executable file
     28 ;   might be covered by the GNU General Public License.
     29 ;-------------------------------------------------------------------------
     30 
     31 ;	.module __memcpy
     32 
     33 ;--------------------------------------------------------
     34 ; exported symbols
     35 ;--------------------------------------------------------
     36 	.globl ___memcpy_PARM_2
     37 	.globl ___memcpy_PARM_3
     38 	.globl ___memcpy
     39 	.globl _memcpy_PARM_2
     40 	.globl _memcpy_PARM_3
     41 	.globl _memcpy
     42 
     43 ;--------------------------------------------------------
     44 ; overlayable function parameters in zero page
     45 ;--------------------------------------------------------
     46 	.area	OSEG    (PAG, OVR)
     47 _memcpy_PARM_2:
     48 ___memcpy_PARM_2:
     49 	.ds 2
     50 _memcpy_PARM_3:
     51 ___memcpy_PARM_3:
     52 	.ds 2
     53 
     54 ;--------------------------------------------------------
     55 ; local aliases
     56 ;--------------------------------------------------------
     57 	.define save  "REGTEMP+0"
     58 	.define dst   "DPTR"
     59 	.define src   "___memcpy_PARM_2"
     60 	.define count "___memcpy_PARM_3"
     61 
     62 ;--------------------------------------------------------
     63 ; code
     64 ;--------------------------------------------------------
     65 	.area _CODE
     66 
     67 _memcpy:
     68 ___memcpy:
     69 	sta	*save+0
     70 	stx	*save+1
     71 	sta	*dst+0
     72 	stx	*dst+1
     73 
     74 	ldy	#0
     75 	ldx	*count+1
     76 	beq	00002$
     77 00001$:
     78 	lda	[src],y
     79 	sta	[dst],y
     80 	iny
     81 	lda	[src],y
     82 	sta	[dst],y
     83 	iny
     84 	bne	00001$
     85 	inc	*src+1
     86 	inc	*dst+1
     87 	dex
     88 	bne	00001$
     89 00002$:
     90 	ldx	*count+0
     91 	beq	00004$
     92 00003$:
     93 	lda	[src],y
     94 	sta	[dst],y
     95 	iny
     96 	dex
     97 	bne	00003$
     98 00004$:
     99 	lda	*save+0
    100 	ldx	*save+1
    101 	rts

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.