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

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [tools/] [zmac/] [test.neg.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 NEG variations
101
;
102
;==============================================================================
103
    org 100h
104
exec:
105
    ld  b,0
106
lp2:
107
    push bc
108
    ld  a,b
109
    ld  hl, text+0
110
    call tohex
111
 
112
    push bc
113
    pop  af
114
    neg
115
    push af
116
    pop bc
117
 
118
    ld  a,b
119
    ld  hl, text+6
120
    call tohex
121
    ld  a,c
122
    ld  hl, text+18
123
    call tohex
124
 
125
    exx
126
    ld  de,text
127
    ld  c,9
128
    call 5
129
    exx
130
 
131
    pop bc
132
    inc b
133
    ld  a,b
134
    or  a,a
135
    jnz lp2
136
die:
137
    jmp die
138
 
139
tohex:
140
    ; HL = Address to store a hex value
141
    ; A  = Hex value 00-FF
142
    push af
143
    and  a,0fh
144
    cmp  a,10
145
    jc   skip1
146
    add  a, 'A'-'9'-1
147
skip1:
148
    add  a, '0'
149
    inc  hl
150
    ld   (hl),a
151
    dec  hl
152
    pop  af
153
    rra
154
    rra
155
    rra
156
    rra
157
    and  a,0fh
158
    cmp  a,10
159
    jc   skip2
160
    add  a, 'A'-'9'-1
161
skip2:
162
    add  a, '0'
163
    ld   (hl),a
164
    ret
165
 
166
text:
167
    ;    01234567890123456789
168
    db  "00 -> 00  Flags = 00",13,10,'$'
169
end

powered by: WebSVN 2.1.0

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