CPU-Z80-Disassembler

 view release on metacpan or  search on metacpan

t/data/zx48_benchmark.asm  view on Meta::CPAN

        ld b, a                 ; and B, the syntax dimension counter (256)
        bit 7, c                ; checking syntax ?
        jr nz, SV_COUNT         ; forward to SV-COUNT if so.

; runtime evaluation.

        bit 7, (hl)             ; will be reset if a simple string.
        jr nz, SV_ARRAYS        ; forward to SV-ARRAYS otherwise

        inc a                   ; set A to 1, simple string.

;; SV-SIMPLE$

SV_SIMPLE_:
        inc hl                  ; address length low
        ldi bc, (hl)            ; place in C
                                ; address length high
                                ; place in B
                                ; address start of string
        ex de, hl               ; DE = start now.
        call STK_STO__          ; routine STK-STO-$ stacks string parameters
                                ; DE start in variables area,
                                ; BC length, A=1 simple string

; the only thing now is to consider if a slice is required.

        rst $18                 ; GET-CHAR puts character at CH_ADD in A
        jp SV_SLICE_            ; jump forward to SV-SLICE? to test for '('


; --------------------------------------------------------

; the branch was here with string and numeric arrays in runtime.

;; SV-ARRAYS

SV_ARRAYS:
        inc hl                  ; step past
        inc hl                  ; the total length
        inc hl                  ; to address Number of dimensions.
        ld b, (hl)              ; transfer to B overwriting zero.
        bit 6, c                ; a numeric array ?
        jr z, SV_PTR            ; forward to SV-PTR with numeric arrays

        dec b                   ; ignore the final element of a string array
                                ; the fixed string size.

        jr z, SV_SIMPLE_        ; back to SV-SIMPLE$ if result is zero as has
                                ; been created with DIM a$(10) for instance
                                ; and can be treated as a simple string.

; proceed with multi-dimensioned string arrays in runtime.

        ex de, hl               ; save pointer to dimensions in DE

        rst $18                 ; GET-CHAR looks at the BASIC line
        cp $28                  ; is character '(' ?
        jr nz, REPORT_3         ; to REPORT-3 if not
                                ; 'Subscript wrong'

        ex de, hl               ; dimensions pointer to HL to synchronize
                                ; with next instruction.

; runtime numeric arrays path rejoins here.

;; SV-PTR

SV_PTR:
        ex de, hl               ; save dimension pointer in DE
        jr SV_COUNT             ; forward to SV-COUNT with true no of dims
                                ; in B. As there is no initial comma the
                                ; loop is entered at the midpoint.


; ----------------------------------------------------------
; the dimension counting loop which is entered at mid-point.

;; SV-COMMA

SV_COMMA:
        push hl                 ; save counter

        rst $18                 ; GET-CHAR

        pop hl                  ; pop counter
        cp $2C                  ; is character ',' ?
        jr z, SV_LOOP           ; forward to SV-LOOP if so

; in runtime the variable definition indicates a comma should appear here

        bit 7, c                ; checking syntax ?
        jr z, REPORT_3          ; forward to REPORT-3 if not
                                ; 'Subscript error'

; proceed if checking syntax of an array?

        bit 6, c                ; array of strings
        jr nz, SV_CLOSE         ; forward to SV-CLOSE if so

; an array of numbers.

        cp $29                  ; is character ')' ?
        jr nz, SV_RPT_C         ; forward to SV-RPT-C if not
                                ; 'Nonsense in BASIC'

        rst $20                 ; NEXT-CHAR moves CH-ADD past the statement
        ret                     ; return ->


; ---

; the branch was here with an array of strings.

;; SV-CLOSE

SV_CLOSE:
        cp $29                  ; as above ')' could follow the expression
        jr z, SV_DIM            ; forward to SV-DIM if so

        cp $CC                  ; is it 'TO' ?
        jr nz, SV_RPT_C         ; to SV-RPT-C with anything else



( run in 1.042 second using v1.01-cache-2.11-cpan-39bf76dae61 )