OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [tools/] [zmac/] [test.daa.asm] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gdevic
;==============================================================================
2
; Test code for the A-Z80 CPU
3
;==============================================================================
4
    org 0
5
start:
6
    jmp boot
7
 
8
    ; BDOS entry point for various functions
9
    ; We implement subfunctions:
10
    ;  C=2  Print a character given in E
11
    ;  C=9  Print a string pointed to by DE; string ends with '$'
12
    org 5
13
    ld  a,c
14
    cp  a,2
15
    jz  bdos_ascii
16
    cp  a,9
17
    jz  bdos_msg
18
    ret
19
 
20
bdos_ascii:
21
    ld  bc,10*256   ; Port to check for busy
22
    in  a,(c)       ; Poll until the port is not busy
23
    bit 0,a
24
    jnz bdos_ascii
25
    ld  bc,8*256    ; Port to write a character out
26
    out (c),e
27
    ret
28
 
29
bdos_msg:
30
    push de
31
    pop hl
32
lp0:
33
    ld  e,(hl)
34
    ld  a,e
35
    cp  a,'$'
36
    ret z
37
    call bdos_ascii
38
    inc hl
39
    jmp lp0
40
 
41
;---------------------------------------------------------------------
42
; RST38 (also INT M0)  handler
43
;---------------------------------------------------------------------
44
    org 038h
45
    push de
46
    ld  de,int_msg
47
int_common:
48
    push af
49
    push bc
50
    push hl
51
    ld  c,9
52
    call 5
53
    pop hl
54
    pop bc
55
    pop af
56
    pop de
57
    ei
58
    reti
59
int_msg:
60
    db  "_INT_",'$'
61
 
62
;---------------------------------------------------------------------
63
; NMI handler
64
;---------------------------------------------------------------------
65
    org 066h
66
    push af
67
    push bc
68
    push de
69
    push hl
70
    ld  de,nmi_msg
71
    ld  c,9
72
    call 5
73
    pop hl
74
    pop de
75
    pop bc
76
    pop af
77
    retn
78
nmi_msg:
79
    db  "_NMI_",'$'
80
 
81
;---------------------------------------------------------------------
82
; IM2 vector address and the handler (to push 0x80 by the IORQ)
83
;---------------------------------------------------------------------
84
    org 080h
85
    dw  im2_handler
86
im2_handler:
87
    push de
88
    ld  de,int_im2_msg
89
    jmp int_common
90
int_im2_msg:
91
    db  "_IM2_",'$'
92
boot:
93
    ; Set the stack pointer
94
    ld  sp, 16384    ; 16 Kb of RAM
95
    ; Jump into the executable at 100h
96
    jmp 100h
97
 
98
;==============================================================================
99
;
100
; Dumps DAA variations
101
;
102
;==============================================================================
103
    org 100h
104
exec:
105
    ld  hl, flag_f
106
lp1:
107
    ld  a, (hl)
108
    cp  a, 0ffh
109
die:jz  die
110
    push hl
111
    ld  c,a
112
    ld  b,0
113
lp2:
114
    push bc
115
    ld  a,c
116
    ld  hl, text+2
117
    call tohex
118
    ld  a,b
119
    ld  hl, text+7
120
    call tohex
121
 
122
    push bc
123
    pop  af
124
    daa
125
    push af
126
    pop bc
127
 
128
    ld  a,b
129
    ld  hl, text+13
130
    call tohex
131
    ld  a,c
132
    ld  hl, text+18
133
    call tohex
134
 
135
    exx
136
    ld  de,text
137
    ld  c,9
138
    call 5
139
    exx
140
 
141
    pop bc
142
    inc b
143
    ld  a,b
144
    or  a,a
145
    jnz lp2
146
 
147
    pop  hl
148
    inc  hl
149
    jmp  lp1
150
 
151
tohex:
152
    ; HL = Address to store a hex value
153
    ; A  = Hex value 00-FF
154
    push af
155
    and  a,0fh
156
    cmp  a,10
157
    jc   skip1
158
    add  a, 'A'-'9'-1
159
skip1:
160
    add  a, '0'
161
    inc  hl
162
    ld   (hl),a
163
    dec  hl
164
    pop  af
165
    rra
166
    rra
167
    rra
168
    rra
169
    and  a,0fh
170
    cmp  a,10
171
    jc   skip2
172
    add  a, 'A'-'9'-1
173
skip2:
174
    add  a, '0'
175
    ld   (hl),a
176
    ret
177
 
178
flag_f:
179
    db  00h, 01h, 10h, 11h, 02h, 03h, 12h, 13h, 0ffh
180
text:
181
    ;    01234567890123456789
182
    db  "F:00 A:00 -> 00 F:00",13,10,'$'
183
end

powered by: WebSVN 2.1.0

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