OpenCores
URL https://opencores.org/ocsvn/tv80/tv80/trunk

Subversion Repositories tv80

[/] [tv80/] [trunk/] [tests/] [otir.ast] - Blame information for rev 99

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 ghutchis
; basic test of OTIR block-transfer instruction
2
;
3
; initializes a memory region and then transfers that region
4
; to an accumulator
5
 
6
    .module otir
7
 
8
;--------------------------------------------------------
9
; special function registers
10
;--------------------------------------------------------
11
_sim_ctl_port   =       0x0080
12
_msg_port       =       0x0081
13
_timeout_port   =       0x0082
14
_max_timeout_low        =       0x0083
15
_max_timeout_high       =       0x0084
16
_intr_cntdwn    =       0x0090
17
_cksum_value    =       0x0091
18
_cksum_accum    =       0x0092
19
_inc_on_read    =       0x0093
20
 
21
    .area INIT (ABS)
22
    .org  0
23
 
24
    jp      init
25
 
26
 
27
init:
28
    ld      sp, #0xffff
29
 
30
    ;; initialize dbuf memory area with regular pattern
31
    ;; pattern starts with 1 and increments
32
 
33
    ld      hl, #dbuf
34
    ld      b, #255
35
    ld      c, #1
36
 
37
dbuf_init:
38
    ld      (hl), c
39
    inc     hl
40
    inc     c
41
    djnz    dbuf_init
42
 
43
    call    reset_timeout
44
    ld      b, #16
45
    call    xfer_test
46
 
47
    call    reset_timeout
48
    ld      b, #63
49
    call    xfer_test
50
 
51
    call    reset_timeout
52
    ld      b, #127
53
    call    xfer_test
54
 
55
    call    reset_timeout
56
    ld      b, #128
57
    call    xfer_test
58
 
59
    call    reset_timeout
60
    ld      b, #254
61
    call    xfer_test
62
 
63
    call    reset_timeout
64
    ld      b, #255
65
    call    xfer_test
66
 
67
    ;; finish simulation with test passed
68
    ld      a, #1
69
    out     (_sim_ctl_port), a
70
    ret
71
 
72
    ;; test sending X amount of data from the buffer to the
73
    ;; accumulator.  Amount of data to transfer is in B.
74
    ;; After tranferring data to checksummer, perform
75
    ;; checksum and compare
76
xfer_test:
77
    push    bc
78
    ld      hl, #dbuf
79
    ld      a, #0
80
    out     (_cksum_value), a
81
 
82
    ld      c, #_cksum_accum
83
    otir
84
 
85
    ;; do checksum over same region
86
    pop     bc
87
    ld      hl, #dbuf
88
    ld      a, #0
89
 
90
xfer_test_cksum:
91
    add     a, (hl)
92
    inc     hl
93
    djnz    xfer_test_cksum
94
 
95
    ;; store calc'ed checksum in D and read out cksum register
96
    ld      d, a
97
    in      a, (_cksum_value)
98
 
99
    ;; compare two values and fail test if not equal
100
    cp      d
101
    jp      nz, xfer_fail
102
    ret
103
 
104
xfer_fail:
105
    ld      a, #2
106
    out     (_sim_ctl_port), a
107
    ret
108
 
109
reset_timeout:
110
    ld      a, #2
111
    out     (_timeout_port), a
112
    ret
113
 
114
    .org    0x8000
115
 
116
dbuf:
117
    .ds     256
118
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.