CPU-Z80-Disassembler

 view release on metacpan or  search on metacpan

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

                                ; state byte. Bit 7 can be lost.

        xor l                   ; compare type in A with first byte in L.
        ret nz                  ; return if no match e.g. CODE vs. DATA.

;   continue when data type matches.

        ld a, c                 ; fetch byte with stored carry
        rra                     ; rotate it to carry flag again
        ld c, a                 ; restore long-term port state.

        inc de                  ; increment length ??
        jr LD_DEC               ; forward to LD-DEC.
                                ; but why not to location after ?


; ---
;   for verification the byte read from tape is compared with that in memory.

;; LD-VERIFY

LD_VERIFY:
        ld a, (ix)              ; fetch byte from memory.
        xor l                   ; compare with that on tape
        ret nz                  ; return if not zero.

;; LD-NEXT

LD_NEXT:
        inc ix                  ; increment byte pointer.

;; LD-DEC

LD_DEC:
        dec de                  ; decrement length.
        ex af, af'              ; store the flags.
        ld b, $B2               ; timing.

;   when starting to read 8 bits the receiving byte is marked with bit at right.
;   when this is rotated out again then 8 bits have been read.

;; LD-MARKER

LD_MARKER:
        ld l, $01               ; initialize as %00000001

;; LD-8-BITS

LD_8_BITS:
        call LD_EDGE_2          ; routine LD-EDGE-2 increments B relative to
                                ; gap between 2 edges.
        ret nc                  ; return with time-out.

        ld a, $CB               ; the comparison byte.
        cp b                    ; compare to incremented value of B.
                                ; if B is higher then bit on tape was set.
                                ; if <= then bit on tape is reset.

        rl l                    ; rotate the carry bit into L.

        ld b, $B0               ; reset the B timer byte.
        jp nc, LD_8_BITS        ; JUMP back to LD-8-BITS

;   when carry set then marker bit has been passed out and byte is complete.

        ld a, h                 ; fetch the running parity byte.
        xor l                   ; include the new byte.
        ld h, a                 ; and store back in parity register.

        ld a, d                 ; check length of
        or e                    ; expected bytes.
        jr nz, LD_LOOP          ; back to LD-LOOP
                                ; while there are more.

;   when all bytes loaded then parity byte should be zero.

        ld a, h                 ; fetch parity byte.
        cp $01                  ; set carry if zero.
        ret                     ; return
                                ; in no carry then error as checksum disagrees.


; -------------------------
; Check signal being loaded
; -------------------------
;   An edge is a transition from one mic state to another.
;   More specifically a change in bit 6 of value input from port $FE.
;   Graphically it is a change of border colour, say, blue to yellow.
;   The first entry point looks for two adjacent edges. The second entry point
;   is used to find a single edge.
;   The B register holds a count, up to 256, within which the edge (or edges) 
;   must be found. The gap between two edges will be more for a '1' than a '0'
;   so the value of B denotes the state of the bit (two edges) read from tape.

; ->

;; LD-EDGE-2

LD_EDGE_2:
        call LD_EDGE_1          ; call routine LD-EDGE-1 below.
        ret nc                  ; return if space pressed or time-out.
                                ; else continue and look for another adjacent
                                ; edge which together represent a bit on the
                                ; tape.

; -> 
;   this entry point is used to find a single edge from above but also 
;   when detecting a read-in signal on the tape.

;; LD-EDGE-1

LD_EDGE_1:
        ld a, $16               ; a delay value of twenty two.

;; LD-DELAY

LD_DELAY:
        dec a                   ; decrement counter
        jr nz, LD_DELAY         ; loop back to LD-DELAY 22 times.

        and a                   ; clear carry.



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