cscg22-gearboy

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

_memset.s (985B)


      1        .module memset
      2
      3        .area   _HOME
      4
      5; void *memset (void *s, int c, size_t n)
      6_memset::
      7        lda     hl,7(sp)
      8        ld      a,(hl-)
      9        ld      d, a
     10        ld      a,(hl-)
     11        ld      e, a
     12        or      d
     13        jr      z,6$
     14        
     15        dec     hl
     16        ld      a,(hl-)
     17        push    af
     18        ld      a,(hl-)
     19        ld      l,(hl)
     20        ld      h,a
     21        pop     af
     22        
     23        srl     d
     24        rr      e
     25        jr      nc,4$
     26        ld      (hl+),a
     274$:     
     28        srl     d
     29        rr      e
     30        jr      nc,5$
     31        ld      (hl+),a
     32        ld      (hl+),a
     335$:             
     34        inc     d
     35        inc     e
     36        jr      2$
     371$:     
     38        ld      (hl+),a
     39        ld      (hl+),a
     40        ld      (hl+),a
     41        ld      (hl+),a
     422$:
     43        dec     e
     44        jr      nz,1$
     45        dec     d
     46        jr      nz,1$
     476$:
     48        lda     hl,2(sp)
     49        ld      a,(hl+)
     50        ld      e,a
     51        ld      d,(hl)
     52        ret