Skip to content

Commit efc47a3

Browse files
authored
Merge pull request #615 from boriel/fix/hang_on_MODF_usage
fix: fix MODF
2 parents 30a292f + 3a58187 commit efc47a3

File tree

5 files changed

+191
-22
lines changed

5 files changed

+191
-22
lines changed

.github/workflows/python-app.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,37 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- uses: actions/checkout@v2
21+
- name: Checkout code
22+
uses: actions/checkout@v2
23+
2224
- name: Set up Python 3.8
2325
uses: actions/setup-python@v2
2426
with:
25-
python-version: 3.8.7
27+
python-version: 3.8.11
28+
2629
- name: Caches pip
27-
uses: actions/cache@v1
30+
uses: actions/cache@v2
2831
with:
2932
path: ~/.cache/pip
30-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
31-
restore-keys: |
32-
${{ runner.os }}-pip-
33+
key: ${{ runner.os }}-pip-py3.8.11
34+
3335
- name: Install dependencies
3436
run: |
3537
python -m pip install --upgrade pip
36-
pip install poetry
37-
poetry install
38+
pip install poetry==1.1.14
39+
poetry config virtualenvs.in-project true
40+
41+
- name: Set up poetry cache
42+
uses: actions/cache@v2
43+
with:
44+
path: .venv
45+
key: venv-${{ runner.os }}-python3.8-${{ hashFiles('poetry.lock') }}
46+
47+
- name: Install dependencies
48+
run: poetry install
3849

3950
- name: Lint code
40-
run: poe lint
51+
run: poetry run poe lint
4152

4253
- name: Run tests
43-
run: poe test
54+
run: poetry run poe test

pyproject.toml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,10 @@ homepage = "http://zxbasic.net"
1010
readme = "README.md"
1111

1212
classifiers = [
13-
# How mature is this project? Common values are
14-
# 3 - Alpha
15-
# 4 - Beta
16-
# 5 - Production/Stable
1713
'Development Status :: 5 - Production/Stable',
18-
19-
# Indicate who your project is intended for
2014
'Intended Audience :: Developers',
2115
'Topic :: Software Development :: Build Tools',
22-
23-
# Pick your license as you wish (should match "license" above)
2416
'License :: OSI Approved :: GNU Affero General Public License v3',
25-
26-
# Specify the Python versions you support here. In particular, ensure
27-
# that you indicate whether you support Python 2, Python 3 or both.
2817
'Programming Language :: Python :: 3.8',
2918
]
3019

src/arch/zx48k/library-asm/modf.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ __MODF: ; MODULO
1919
rst 28h
2020
defb 01h ; EXCHANGE
2121
defb 32h ; MOD
22+
defb 02h ; Discard (POP)
2223
defb 38h; ; END CALC
2324

2425
jp __FPSTACK_POP
2526

2627
pop namespace
27-

tests/functional/zx48k/modf.asm

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
org 32768
2+
.core.__START_PROGRAM:
3+
di
4+
push ix
5+
push iy
6+
exx
7+
push hl
8+
exx
9+
ld hl, 0
10+
add hl, sp
11+
ld (.core.__CALL_BACK__), hl
12+
ei
13+
jp .core.__MAIN_PROGRAM__
14+
.core.__CALL_BACK__:
15+
DEFW 0
16+
.core.ZXBASIC_USER_DATA:
17+
; Defines USER DATA Length in bytes
18+
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
19+
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
20+
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
21+
_a:
22+
DEFB 00, 00, 00, 00, 00
23+
.core.ZXBASIC_USER_DATA_END:
24+
.core.__MAIN_PROGRAM__:
25+
ld hl, _a + 4
26+
call .core.__FP_PUSH_REV
27+
ld a, 081h
28+
ld de, 00000h
29+
ld bc, 00000h
30+
call .core.__MODF
31+
ld hl, _a
32+
call .core.__STOREF
33+
ld hl, 0
34+
ld b, h
35+
ld c, l
36+
.core.__END_PROGRAM:
37+
di
38+
ld hl, (.core.__CALL_BACK__)
39+
ld sp, hl
40+
exx
41+
pop hl
42+
exx
43+
pop iy
44+
pop ix
45+
ei
46+
ret
47+
;; --- end of user code ---
48+
#line 1 "/zxbasic/src/arch/zx48k/library-asm/modf.asm"
49+
#line 1 "/zxbasic/src/arch/zx48k/library-asm/stackf.asm"
50+
; -------------------------------------------------------------
51+
; Functions to manage FP-Stack of the ZX Spectrum ROM CALC
52+
; -------------------------------------------------------------
53+
push namespace core
54+
__FPSTACK_PUSH EQU 2AB6h ; Stores an FP number into the ROM FP stack (A, ED CB)
55+
__FPSTACK_POP EQU 2BF1h ; Pops an FP number out of the ROM FP stack (A, ED CB)
56+
__FPSTACK_PUSH2: ; Pushes Current A ED CB registers and top of the stack on (SP + 4)
57+
; Second argument to push into the stack calculator is popped out of the stack
58+
; Since the caller routine also receives the parameters into the top of the stack
59+
; four bytes must be removed from SP before pop them out
60+
call __FPSTACK_PUSH ; Pushes A ED CB into the FP-STACK
61+
exx
62+
pop hl ; Caller-Caller return addr
63+
exx
64+
pop hl ; Caller return addr
65+
pop af
66+
pop de
67+
pop bc
68+
push hl ; Caller return addr
69+
exx
70+
push hl ; Caller-Caller return addr
71+
exx
72+
jp __FPSTACK_PUSH
73+
__FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK
74+
; This format is specified in the ZX 48K Manual
75+
; You can push a 16 bit signed integer as
76+
; 0 SS LL HH 0, being SS the sign and LL HH the low
77+
; and High byte respectively
78+
ld a, h
79+
rla ; sign to Carry
80+
sbc a, a ; 0 if positive, FF if negative
81+
ld e, a
82+
ld d, l
83+
ld c, h
84+
xor a
85+
ld b, a
86+
jp __FPSTACK_PUSH
87+
pop namespace
88+
#line 2 "/zxbasic/src/arch/zx48k/library-asm/modf.asm"
89+
; -------------------------------------------------------------
90+
; Floating point library using the FP ROM Calculator (ZX 48K)
91+
; All of them uses A EDCB registers as 1st paramter.
92+
; For binary operators, the 2n operator must be pushed into the
93+
; stack, in the order A DE BC.
94+
;
95+
; Uses CALLEE convention
96+
; -------------------------------------------------------------
97+
push namespace core
98+
__MODF: ; MODULO
99+
call __FPSTACK_PUSH2 ; Enters B, A
100+
; ------------- ROM DIV
101+
rst 28h
102+
defb 01h ; EXCHANGE
103+
defb 32h ; MOD
104+
defb 02h ; Discard (POP)
105+
defb 38h; ; END CALC
106+
jp __FPSTACK_POP
107+
pop namespace
108+
#line 25 "zx48k/modf.bas"
109+
#line 1 "/zxbasic/src/arch/zx48k/library-asm/pushf.asm"
110+
; Routine to push Float pointed by HL
111+
; Into the stack. Notice that the hl points to the last
112+
; byte of the FP number.
113+
; Uses H'L' B'C' and D'E' to preserve ABCDEHL registers
114+
push namespace core
115+
__FP_PUSH_REV:
116+
push hl
117+
exx
118+
pop hl
119+
pop bc ; Return Address
120+
ld d, (hl)
121+
dec hl
122+
ld e, (hl)
123+
dec hl
124+
push de
125+
ld d, (hl)
126+
dec hl
127+
ld e, (hl)
128+
dec hl
129+
push de
130+
ld d, (hl)
131+
push de
132+
push bc ; Return Address
133+
exx
134+
ret
135+
pop namespace
136+
#line 26 "zx48k/modf.bas"
137+
#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm"
138+
push namespace core
139+
__PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL)
140+
push de
141+
ex de, hl ; DE <- HL
142+
push ix
143+
pop hl ; HL <- IX
144+
add hl, de ; HL <- IX + HL
145+
pop de
146+
__ISTOREF: ; Load address at hl, and stores A,E,D,C,B registers at that address. Modifies A' register
147+
ex af, af'
148+
ld a, (hl)
149+
inc hl
150+
ld h, (hl)
151+
ld l, a ; HL = (HL)
152+
ex af, af'
153+
__STOREF: ; Stores the given FP number in A EDCB at address HL
154+
ld (hl), a
155+
inc hl
156+
ld (hl), e
157+
inc hl
158+
ld (hl), d
159+
inc hl
160+
ld (hl), c
161+
inc hl
162+
ld (hl), b
163+
ret
164+
pop namespace
165+
#line 27 "zx48k/modf.bas"
166+
END

tests/functional/zx48k/modf.bas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DIM a as Float
2+
3+
LET a = a MOD 1

0 commit comments

Comments
 (0)