File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
22import pathlib
3+
34from setuptools import setup
45
56packages = ["src" ]
Original file line number Diff line number Diff line change @@ -884,6 +884,17 @@ def execute(self, asm_code):
884884 self .set (o [0 ], None )
885885 return
886886
887+ if i == "mul" :
888+ val_d = self .getv (o [0 ])
889+ val_e = self .getv (o [1 ])
890+ if val_d is not None and val_e is not None :
891+ val = val_d * val_e
892+ self .set ("de" , val )
893+ self .Z = int (val == 0 )
894+ self .C = int (val < 0 )
895+ self .S = int (val < 0 )
896+ return
897+
887898 # Unknown. Resets ALL
888899 self .reset ()
889900
Original file line number Diff line number Diff line change @@ -170,6 +170,8 @@ def destroys(self) -> Set[str]:
170170 res .add ("f" )
171171 elif i in ("set" , "res" ):
172172 res .update (helpers .single_registers (o [1 ]))
173+ elif i == "mul" :
174+ res .update ("d" , "e" )
173175
174176 return res
175177
@@ -310,6 +312,9 @@ def requires(self) -> Set[str]:
310312 elif i == "im" :
311313 result .add ("i" )
312314
315+ elif i == "mul" :
316+ result .update ("d" , "e" )
317+
313318 return result
314319
315320 def affects (self , reglist : Union [List [str ], str ]) -> bool :
Original file line number Diff line number Diff line change 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+ _x:
22+ DEFB 00 , 00
23+ _y:
24+ DEFB 00
25+ .core.ZXBASIC_USER_DATA_END:
26+ .core.__MAIN_PROGRAM__:
27+ ld a , 1
28+ ld (_y) , a
29+ ld d , 16
30+ ld e , a
31+ mul d , e
32+ ld a , e
33+ push af
34+ ld hl , (_x)
35+ call .core.__MUL16_FAST
36+ push hl
37+ call _printTest
38+ ld bc , 0
39+ .core.__END_PROGRAM:
40+ di
41+ ld hl , (.core.__CALL_BACK__)
42+ ld sp , hl
43+ exx
44+ pop hl
45+ pop iy
46+ pop ix
47+ exx
48+ ei
49+ ret
50+ _printTest:
51+ push ix
52+ ld ix , 0
53+ add ix , sp
54+ ld a , (ix + 7 )
55+ ld ( 0 ) , a
56+ _printTest__leave:
57+ ld sp , ix
58+ pop ix
59+ exx
60+ pop hl
61+ pop bc
62+ ex ( sp ) , hl
63+ exx
64+ ret
65+ ;; --- end of user code ---
66+ #line 1 "/zxbasic/src/arch/zxnext/library-asm/mul16.asm"
67+ push namespace core
68+ __MUL16: ; Mutiplies HL with the last value stored into de stack
69+ ; Works for both signed and unsigned
70+ PROC
71+ ex de , hl
72+ pop hl ; Return address
73+ ex ( sp ) , hl ; CALLEE caller convention
74+ __MUL16_FAST:
75+ ld a , d ; a = xh
76+ ld d , h ; d = yh
77+ ld h , a ; h = xh
78+ ld c , e ; c = xl
79+ ld b , l ; b = yl
80+ mul d , e ; yh * yl
81+ ex de , hl
82+ mul d , e ; xh * yl
83+ add hl , de ; add cross products
84+ ld e , c
85+ ld d , b
86+ mul d , e ; yl * xl
87+ ld a , l ; cross products lsb
88+ add a , d ; add to msb final
89+ ld h , a
90+ ld l , e ; hl = final
91+ ret ; Result in hl (16 lower bits)
92+ ENDP
93+ pop namespace
94+ #line 41 "zxnext/opt4_mul8.bas"
95+ END
Original file line number Diff line number Diff line change 1+ dim x as uinteger
2+ dim y as ubyte
3+
4+ y = 1
5+
6+ printTest(x* 16 ,y* 16 )
7+
8+ sub printTest(xpos as uinteger, ypos as ubyte)
9+ poke 0 , ypos
10+ end sub
Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
22
3- import sys
43import re
5-
4+ import sys
65
76INDENT = 4 * " "
87RE_END_ASM = re .compile ("^END[ \t ]+ASM$" )
Original file line number Diff line number Diff line change 22# -*- coding: utf-8 -*-
33# vim: ts=4:sw=4:et:
44
5- import sys
65import os
6+ import sys
77
88sys .path .append (os .path .dirname (__file__ ))
99
Original file line number Diff line number Diff line change 1111# This is the Parser for the ZXBASM (ZXBasic Assembler)
1212# ----------------------------------------------------------------------
1313
14- import sys
1514import os
15+ import sys
1616
1717sys .path .append (os .path .dirname (__file__ ))
1818
Original file line number Diff line number Diff line change 22# -*- coding: utf-8 -*-
33# vim: ts=4:sw=4:et:
44
5- import sys
65import os
6+ import sys
77
88sys .path .append (os .path .dirname (__file__ ))
99
Original file line number Diff line number Diff line change 1111# This is the Parser for the ZXBpp (ZXBasic Preprocessor)
1212# ----------------------------------------------------------------------
1313
14- import sys
1514import os
15+ import sys
1616
1717sys .path .append (os .path .dirname (__file__ ))
1818
You can’t perform that action at this time.
0 commit comments