cscg22-gearboy

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

memcmp.s (636B)


      1        .module strcmp
      2
      3        .area   _HOME
      4
      5; int memcmp(const void *buf1, const void *buf2, size_t count)
      6_memcmp::
      7        pop hl
      8        pop de
      9        pop bc
     10        ex (sp), hl
     11        ex de, hl
     12
     13        inc     d
     14        inc     e
     15        jr      3$
     16
     171$:     
     18        ld      a,(bc)
     19        sub     (hl)            ; s1[i]==s2[i]?
     20        jr      nz, 2$          ; -> Different
     21        
     22        inc     bc
     23        inc     hl
     243$:
     25        dec     e
     26        jr      nz, 1$
     27        dec     d
     28        jr      nz, 1$
     29
     30        ld      hl, #0
     31        ret
     32
     332$:
     34        ld      hl,#1
     35        ret     c
     36
     37        ld      hl,#-1
     38        ret