cscg22-gearboy

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

bdos_gets.s (672B)


      1        .include        "global.s"
      2
      3        .title  "gets"
      4        .module gets
      5
      6        .area   _CODE
      7
      8_gets::
      9        pop hl
     10        pop de
     11        push de
     12        push hl
     13        push de
     14        ld c, #63               ; limit input to 64 bytes including trailing zero
     15                                ; that match with internal buffer in scanf()
     161$:
     17        push bc
     18        push de
     19        CALL_BDOS #_CONIN
     20        pop de
     21        pop bc
     22	cp #0x0d                ; CR
     23        jp z, 2$
     24        cp #0x05                ; EOF
     25        jp z, 2$
     26        ld (de), a
     27        inc de
     28        dec c
     29        jp nz, 1$
     302$:
     31        xor a
     32        ld (de), a
     33        pop hl
     34        ret