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, 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 
     40 ;--------------------------------------------------------
     41 ; overlayable function paramters in zero page
     42 ;--------------------------------------------------------
     43 	.area	OSEG    (PAG, OVR)
     44 ___memcpy_PARM_2:
     45 	.ds 2
     46 ___memcpy_PARM_3:
     47 	.ds 2
     48 
     49 ;--------------------------------------------------------
     50 ; local aliases
     51 ;--------------------------------------------------------
     52 	.define save  "___SDCC_m6502_ret0"
     53 	.define dst   "___SDCC_m6502_ret2"
     54 	.define src   "___memcpy_PARM_2"
     55 	.define count "___memcpy_PARM_3"
     56 	
     57 ;--------------------------------------------------------
     58 ; code
     59 ;--------------------------------------------------------
     60 	.area _CODE
     61 
     62 ___memcpy:
     63 	sta	*save+0
     64 	stx	*save+1
     65 	sta	*dst+0
     66 	stx	*dst+1
     67 
     68 	ldy	#0
     69 	ldx	*count+1
     70 	beq	L2
     71 L1:
     72 	lda	[*src],y
     73 	sta	[*dst],y
     74 	iny
     75 	lda	[*src],y
     76 	sta	[*dst],y
     77 	iny
     78 	bne	L1
     79 	inc	*src+1
     80 	inc	*dst+1
     81 	dex
     82 	bne	L1
     83 L2:
     84 	ldx	*count+0
     85 	beq	done
     86 L3:
     87 	lda	[*src],y
     88 	sta	[*dst],y
     89 	iny
     90 	dex
     91 	bne	L3
     92 done:
     93 	lda	*save+0
     94 	ldx	*save+1
     95 	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.