Skip to content

Commit 5cac764

Browse files
committed
tests: add SGN tests for zxnext arch
1 parent 0b30ec5 commit 5cac764

16 files changed

Lines changed: 506 additions & 0 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
org 32768
2+
.core.__START_PROGRAM:
3+
di
4+
push iy
5+
ld iy, 0x5C3A ; ZX Spectrum ROM variables address
6+
ld (.core.__CALL_BACK__), sp
7+
ei
8+
jp .core.__MAIN_PROGRAM__
9+
.core.__CALL_BACK__:
10+
DEFW 0
11+
.core.ZXBASIC_USER_DATA:
12+
; Defines USER DATA Length in bytes
13+
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
14+
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
15+
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
16+
_y:
17+
DEFB 81h
18+
DEFB 00h
19+
DEFB 00h
20+
DEFB 00h
21+
DEFB 00h
22+
.core.ZXBASIC_USER_DATA_END:
23+
.core.__MAIN_PROGRAM__:
24+
ld a, (_y)
25+
ld de, (_y + 1)
26+
ld bc, (_y + 3)
27+
call .core.__SGNF
28+
ld (0), a
29+
ld hl, 0
30+
ld b, h
31+
ld c, l
32+
.core.__END_PROGRAM:
33+
di
34+
ld hl, (.core.__CALL_BACK__)
35+
ld sp, hl
36+
pop iy
37+
ei
38+
ret
39+
;; --- end of user code ---
40+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/sgnf.asm"
41+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/sgn.asm"
42+
; Returns SGN (SIGN) for 32, 16 and 8 bits signed integers, Fixed and FLOAT
43+
push namespace core
44+
PROC
45+
LOCAL __ENDSGN
46+
__SGNF:
47+
or b
48+
or c
49+
or d
50+
or e
51+
ret z
52+
ld a, e
53+
jr __ENDSGN
54+
__SGNF16:
55+
__SGNI32:
56+
ld a, h
57+
or l
58+
or e
59+
or d
60+
ret z
61+
ld a, d
62+
jr __ENDSGN
63+
__SGNI16:
64+
ld a, h
65+
or l
66+
ret z
67+
ld a, h
68+
__ENDSGN:
69+
or a
70+
ld a, 1
71+
ret p
72+
neg
73+
ret
74+
ENDP
75+
pop namespace
76+
#line 2 "/zxbasic/src/lib/arch/zxnext/runtime/sgnf.asm"
77+
#line 18 "arch/zxnext/sgnf.bas"
78+
END
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dim y as Float=1
2+
poke 0, sgn y
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
org 32768
2+
.core.__START_PROGRAM:
3+
di
4+
push iy
5+
ld iy, 0x5C3A ; ZX Spectrum ROM variables address
6+
ld (.core.__CALL_BACK__), sp
7+
ei
8+
jp .core.__MAIN_PROGRAM__
9+
.core.__CALL_BACK__:
10+
DEFW 0
11+
.core.ZXBASIC_USER_DATA:
12+
; Defines USER DATA Length in bytes
13+
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
14+
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
15+
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
16+
_y:
17+
DEFB 00h
18+
DEFB 00h
19+
DEFB 01h
20+
DEFB 00h
21+
.core.ZXBASIC_USER_DATA_END:
22+
.core.__MAIN_PROGRAM__:
23+
ld hl, (_y)
24+
ld de, (_y + 2)
25+
call .core.__SGNF16
26+
ld (0), a
27+
ld hl, 0
28+
ld b, h
29+
ld c, l
30+
.core.__END_PROGRAM:
31+
di
32+
ld hl, (.core.__CALL_BACK__)
33+
ld sp, hl
34+
pop iy
35+
ei
36+
ret
37+
;; --- end of user code ---
38+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/sgnf16.asm"
39+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/sgn.asm"
40+
; Returns SGN (SIGN) for 32, 16 and 8 bits signed integers, Fixed and FLOAT
41+
push namespace core
42+
PROC
43+
LOCAL __ENDSGN
44+
__SGNF:
45+
or b
46+
or c
47+
or d
48+
or e
49+
ret z
50+
ld a, e
51+
jr __ENDSGN
52+
__SGNF16:
53+
__SGNI32:
54+
ld a, h
55+
or l
56+
or e
57+
or d
58+
ret z
59+
ld a, d
60+
jr __ENDSGN
61+
__SGNI16:
62+
ld a, h
63+
or l
64+
ret z
65+
ld a, h
66+
__ENDSGN:
67+
or a
68+
ld a, 1
69+
ret p
70+
neg
71+
ret
72+
ENDP
73+
pop namespace
74+
#line 2 "/zxbasic/src/lib/arch/zxnext/runtime/sgnf16.asm"
75+
#line 17 "arch/zxnext/sgnf16.bas"
76+
END
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dim y as Fixed=1
2+
poke 0, sgn y
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
org 32768
2+
.core.__START_PROGRAM:
3+
di
4+
push iy
5+
ld iy, 0x5C3A ; ZX Spectrum ROM variables address
6+
ld (.core.__CALL_BACK__), sp
7+
ei
8+
jp .core.__MAIN_PROGRAM__
9+
.core.__CALL_BACK__:
10+
DEFW 0
11+
.core.ZXBASIC_USER_DATA:
12+
; Defines USER DATA Length in bytes
13+
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
14+
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
15+
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
16+
_y:
17+
DEFB 01h
18+
DEFB 00h
19+
.core.ZXBASIC_USER_DATA_END:
20+
.core.__MAIN_PROGRAM__:
21+
ld hl, (_y)
22+
call .core.__SGNI16
23+
ld (0), a
24+
ld hl, 0
25+
ld b, h
26+
ld c, l
27+
.core.__END_PROGRAM:
28+
di
29+
ld hl, (.core.__CALL_BACK__)
30+
ld sp, hl
31+
pop iy
32+
ei
33+
ret
34+
;; --- end of user code ---
35+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/sgni16.asm"
36+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/sgn.asm"
37+
; Returns SGN (SIGN) for 32, 16 and 8 bits signed integers, Fixed and FLOAT
38+
push namespace core
39+
PROC
40+
LOCAL __ENDSGN
41+
__SGNF:
42+
or b
43+
or c
44+
or d
45+
or e
46+
ret z
47+
ld a, e
48+
jr __ENDSGN
49+
__SGNF16:
50+
__SGNI32:
51+
ld a, h
52+
or l
53+
or e
54+
or d
55+
ret z
56+
ld a, d
57+
jr __ENDSGN
58+
__SGNI16:
59+
ld a, h
60+
or l
61+
ret z
62+
ld a, h
63+
__ENDSGN:
64+
or a
65+
ld a, 1
66+
ret p
67+
neg
68+
ret
69+
ENDP
70+
pop namespace
71+
#line 2 "/zxbasic/src/lib/arch/zxnext/runtime/sgni16.asm"
72+
#line 16 "arch/zxnext/sgni16.bas"
73+
END
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dim y as Integer=1
2+
poke 0, sgn y
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
org 32768
2+
.core.__START_PROGRAM:
3+
di
4+
push iy
5+
ld iy, 0x5C3A ; ZX Spectrum ROM variables address
6+
ld (.core.__CALL_BACK__), sp
7+
ei
8+
jp .core.__MAIN_PROGRAM__
9+
.core.__CALL_BACK__:
10+
DEFW 0
11+
.core.ZXBASIC_USER_DATA:
12+
; Defines USER DATA Length in bytes
13+
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
14+
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
15+
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
16+
_y:
17+
DEFB 01h
18+
DEFB 00h
19+
DEFB 00h
20+
DEFB 00h
21+
.core.ZXBASIC_USER_DATA_END:
22+
.core.__MAIN_PROGRAM__:
23+
ld hl, (_y)
24+
ld de, (_y + 2)
25+
call .core.__SGNI32
26+
ld (0), a
27+
ld hl, 0
28+
ld b, h
29+
ld c, l
30+
.core.__END_PROGRAM:
31+
di
32+
ld hl, (.core.__CALL_BACK__)
33+
ld sp, hl
34+
pop iy
35+
ei
36+
ret
37+
;; --- end of user code ---
38+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/sgni32.asm"
39+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/sgn.asm"
40+
; Returns SGN (SIGN) for 32, 16 and 8 bits signed integers, Fixed and FLOAT
41+
push namespace core
42+
PROC
43+
LOCAL __ENDSGN
44+
__SGNF:
45+
or b
46+
or c
47+
or d
48+
or e
49+
ret z
50+
ld a, e
51+
jr __ENDSGN
52+
__SGNF16:
53+
__SGNI32:
54+
ld a, h
55+
or l
56+
or e
57+
or d
58+
ret z
59+
ld a, d
60+
jr __ENDSGN
61+
__SGNI16:
62+
ld a, h
63+
or l
64+
ret z
65+
ld a, h
66+
__ENDSGN:
67+
or a
68+
ld a, 1
69+
ret p
70+
neg
71+
ret
72+
ENDP
73+
pop namespace
74+
#line 2 "/zxbasic/src/lib/arch/zxnext/runtime/sgni32.asm"
75+
#line 17 "arch/zxnext/sgni32.bas"
76+
END
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dim y as Long=1
2+
poke 0, sgn y
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
org 32768
2+
.core.__START_PROGRAM:
3+
di
4+
push iy
5+
ld iy, 0x5C3A ; ZX Spectrum ROM variables address
6+
ld (.core.__CALL_BACK__), sp
7+
ei
8+
jp .core.__MAIN_PROGRAM__
9+
.core.__CALL_BACK__:
10+
DEFW 0
11+
.core.ZXBASIC_USER_DATA:
12+
; Defines USER DATA Length in bytes
13+
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
14+
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
15+
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
16+
_y:
17+
DEFB 01h
18+
.core.ZXBASIC_USER_DATA_END:
19+
.core.__MAIN_PROGRAM__:
20+
ld a, (_y)
21+
call .core.__SGNI8
22+
ld (0), a
23+
ld hl, 0
24+
ld b, h
25+
ld c, l
26+
.core.__END_PROGRAM:
27+
di
28+
ld hl, (.core.__CALL_BACK__)
29+
ld sp, hl
30+
pop iy
31+
ei
32+
ret
33+
;; --- end of user code ---
34+
#line 1 "/zxbasic/src/lib/arch/zxnext/runtime/sgni8.asm"
35+
; Returns SGN (SIGN) for 8 bits signed integer
36+
push namespace core
37+
__SGNI8:
38+
or a
39+
ret z
40+
ld a, 1
41+
ret p
42+
neg
43+
ret
44+
pop namespace
45+
#line 16 "arch/zxnext/sgni8.bas"
46+
END
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dim y as Byte=1
2+
poke 0, sgn y

0 commit comments

Comments
 (0)