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/z80/memcpy.s

      1     .ez80
      2 
      3     .area   _CODE
      4 
      5     .globl _memcpy
      6     .globl ___memcpy
      7 
      8 ; The Z80 has the ldir instruction, but the chain of ldi is faster.
      9 _memcpy:
     10 ___memcpy:    
     11     ex de, hl
     12     pop af
     13     pop bc
     14     push af
     15 
     16     ld a, c
     17     or b
     18     ret z
     19     
     20     push de
     21 
     22     ld a, c
     23     add a
     24     neg
     25     and #31
     26     
     27     add #<1$
     28     ld iyl, a
     29     adc #>1$
     30     sub iyl
     31     ld iyh, a
     32     xor a
     33     jp (iy)
     34 1$:
     35     .rept 16
     36         ldi
     37     .endm
     38     jp pe, 1$
     39     pop de
     40     ret

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