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/sm83/_memcmp.s

      1         .module strcmp
      2 
      3         .area   _HOME
      4 
      5 ; int memcmp(const void *buf1, const void *buf2, size_t count)
      6 _memcmp::
      7         lda     hl,7(sp)
      8         ld      a,(hl-)
      9         ld      b, a
     10         ld      a,(hl-)
     11         ld      c, a
     12         ld      a,(hl-)
     13         ld      d, a
     14         ld      a,(hl-)
     15         ld      e, a
     16         ld      a,(hl-)
     17         ld      l,(hl)
     18         ld      h,a
     19 
     20         inc     b
     21         inc     c
     22         jr      3$
     23 
     24 1$:     
     25         ld      a,(de)
     26         sub     (hl)            ; s1[i]==s2[i]?
     27         jr      nz, 2$          ; -> Different
     28         
     29         inc     de
     30         inc     hl
     31 3$:
     32         dec     c
     33         jr      nz, 1$
     34         dec     b
     35         jr      nz, 1$
     36 
     37         ld      de, #0
     38         ret
     39 
     40 2$:
     41         ld      de,#1
     42         ret     c
     43 
     44         ld      de,#-1
     45         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.