cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

_memcmp.s (825B)


      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
     241$:     
     25        ld      a,(de)
     26        sub     (hl)            ; s1[i]==s2[i]?
     27        jr      nz, 2$          ; -> Different
     28        
     29        inc     de
     30        inc     hl
     313$:
     32        dec     c
     33        jr      nz, 1$
     34        dec     b
     35        jr      nz, 1$
     36
     37        ld      de, #0
     38        ret
     39
     402$:
     41        ld      de,#1
     42        ret     c
     43
     44        ld      de,#-1
     45        ret