;
; Z88 Runtime library
;
; Moved from z88_crt0.asm 

                XLIB     l_case




; case jump


.l_case   
        ex de,hl       ;switch value to DE
        pop   hl    ;get table address
.l_case1
        call    l_case4
        ld a,e
        cp c     ;equal to switch value .
        jr nz,l_case2   ;no
        ld a,d
        cp    b     ;equal to switch value .
        jr nz,l_case2   ;no
        call l_case4
        jr z,l_case3 ;end of table, go to default

        push    bc
        ret         ;case jump

.l_case2  
        call    l_case4
        jr nz,l_case1   ;next case
.l_case3  
        dec   hl
        dec   hl
        dec   hl
        ld d,(hl)
        dec   hl
        ld e,(hl)
        ex de,hl
        jp   (hl)            ;default jump
.l_case4  
        ld c,(hl)
        inc   hl
        ld b,(hl)
        inc   hl
        ld a,c
        or b
        ret
