File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,10 +28,12 @@ __MUL32_64START:
2828 ; sinclair zx81 rom for the mantissa multiply
2929
3030__LMUL:
31- and a ; reset carry flag
32- sbc hl , hl ; result bits 32..47 = 0
31+ xor a ; reset carry flag
32+ ld h , a ; result bits 32..47 = 0
33+ ld l , a
3334 exx
34- sbc hl , hl ; result bits 48..63 = 0
35+ ld h , a ; result bits 48..63 = 0
36+ ld l , a
3537 exx
3638 ld a , b ; mpr is b'c'ac
3739 ld b , 33 ; initialize loop counter
Original file line number Diff line number Diff line change @@ -28,10 +28,12 @@ __MUL32_64START:
2828 ; sinclair zx81 rom for the mantissa multiply
2929
3030__LMUL:
31- and a ; reset carry flag
32- sbc hl , hl ; result bits 32..47 = 0
31+ xor a ; reset carry flag
32+ ld h , a ; result bits 32..47 = 0
33+ ld l , a
3334 exx
34- sbc hl , hl ; result bits 48..63 = 0
35+ ld h , a ; result bits 48..63 = 0
36+ ld l , a
3537 exx
3638 ld a , b ; mpr is b'c'ac
3739 ld b , 33 ; initialize loop counter
Original file line number Diff line number Diff line change 6565; An init directive is useful for initialization routines.
6666; They will be added automatically if needed.
6767
68- #init "core.__MEM_INIT"
68+ #init ". core.__MEM_INIT"
6969
7070
7171; ---------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -5,32 +5,30 @@ __MUL16: ; Mutiplies HL with the last value stored into de stack
55
66 PROC
77
8- LOCAL __MUL16LOOP
9- LOCAL __MUL16NOADD
10-
118 ex de , hl
129 pop hl ; Return address
1310 ex ( sp ) , hl ; CALLEE caller convention
1411
1512__MUL16_FAST:
16- ld b , 16
17- ld a , h
18- ld c , l
19- ld hl , 0
20-
21- __MUL16LOOP:
22- add hl , hl ; hl << 1
23- sla c
24- rla ; a,c << 1
25- jp nc , __MUL16NOADD
26- add hl , de
27-
28- __MUL16NOADD:
29- djnz __MUL16LOOP
13+ ld a , d ; a = xh
14+ ld d , h ; d = yh
15+ ld h , a ; h = xh
16+ ld c , e ; c = xl
17+ ld b , l ; b = yl
18+ mul d , e ; yh * yl
19+ ex de , hl
20+ mul d , e ; xh * yl
21+ add hl , de ; add cross products
22+ ld e , c
23+ ld d , b
24+ mul d , e ; yl * xl
25+ ld a , l ; cross products lsb
26+ add a , d ; add to msb final
27+ ld h , a
28+ ld l , e ; hl = final
3029
3130 ret ; Result in hl (16 lower bits)
3231
3332 ENDP
3433
3534 pop namespace
36-
Original file line number Diff line number Diff line change 22
33__MUL8: ; Performs 8bit x 8bit multiplication
44 PROC
5-
6- ;LOCAL __MUL8A
7- LOCAL __MUL8LOOP
8- LOCAL __MUL8B
95 ; 1st operand (byte) in A, 2nd operand into the stack (AF)
106 pop hl ; return address
117 ex ( sp ) , hl ; CALLE convention
128
13- ;;__MUL8_FAST: ; __FASTCALL__ entry
14- ;; ld e, a
15- ;; ld d, 0
16- ;; ld l, d
17- ;;
18- ;; sla h
19- ;; jr nc, __MUL8A
20- ;; ld l, e
21- ;;
22- ;;__MUL8A:
23- ;;
24- ;; ld b, 7
25- ;;__MUL8LOOP:
26- ;; add hl, hl
27- ;; jr nc, __MUL8B
28- ;;
29- ;; add hl, de
30- ;;
31- ;;__MUL8B:
32- ;; djnz __MUL8LOOP
33- ;;
34- ;; ld a, l ; result = A and HL (Truncate to lower 8 bits)
35-
369__MUL8_FAST: ; __FASTCALL__ entry, a = a * h (8 bit mul) and Carry
37-
38- ld b , 8
39- ld l , a
40- xor a
41-
42- __MUL8LOOP:
43- add a , a ; a *= 2
44- sla l
45- jp nc , __MUL8B
46- add a , h
47-
48- __MUL8B:
49- djnz __MUL8LOOP
50-
51- ret ; result = HL
10+ ; zx next
11+ ld e , a ; 4t
12+ ld d , h ; 4t
13+ mul d , e ; 8t
14+ ld a , e ; 4 ; 20t
15+ ret ; result = DE & A
16+
5217 ENDP
5318
5419 pop namespace
55-
Original file line number Diff line number Diff line change 2121; Putting a comment starting with @INIT <address>
2222; will make the compiler to add a CALL to <address>
2323; It is useful for initialization routines.
24- #init core.__PRINT_INIT
24+ #init . core.__PRINT_INIT
2525
2626 push namespace core
2727
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ read_restart:
6868 jr nz , cont
6969 ;; Signals out of data
7070
71- ld hl , __DATA__0
71+ ld hl , .DATA. __DATA__0
7272 ld (__DATA_ADDR) , hl
7373 jr read_restart ; Start again
7474cont:
@@ -339,7 +339,7 @@ __09_decode_float:
339339 ret
340340
341341__DATA_ADDR: ;; Stores current DATA ptr
342- dw __DATA__0
342+ dw .DATA. __DATA__0
343343 ENDP
344344
345345#undef _str
Original file line number Diff line number Diff line change @@ -226,10 +226,12 @@ __MUL32_64START:
226226 ; this routine was with tiny differences in the
227227 ; sinclair zx81 rom for the mantissa multiply
228228__LMUL:
229- and a ; reset carry flag
230- sbc hl , hl ; result bits 32..47 = 0
229+ xor a ; reset carry flag
230+ ld h , a ; result bits 32..47 = 0
231+ ld l , a
231232 exx
232- sbc hl , hl ; result bits 48..63 = 0
233+ ld h , a ; result bits 48..63 = 0
234+ ld l , a
233235 exx
234236 ld a , b ; mpr is b'c'ac
235237 ld b , 33 ; initialize loop counter
Original file line number Diff line number Diff line change @@ -222,10 +222,12 @@ __MUL32_64START:
222222 ; this routine was with tiny differences in the
223223 ; sinclair zx81 rom for the mantissa multiply
224224__LMUL:
225- and a ; reset carry flag
226- sbc hl , hl ; result bits 32..47 = 0
225+ xor a ; reset carry flag
226+ ld h , a ; result bits 32..47 = 0
227+ ld l , a
227228 exx
228- sbc hl , hl ; result bits 48..63 = 0
229+ ld h , a ; result bits 48..63 = 0
230+ ld l , a
229231 exx
230232 ld a , b ; mpr is b'c'ac
231233 ld b , 33 ; initialize loop counter
Original file line number Diff line number Diff line change @@ -331,10 +331,12 @@ __MUL32_64START:
331331 ; this routine was with tiny differences in the
332332 ; sinclair zx81 rom for the mantissa multiply
333333__LMUL:
334- and a ; reset carry flag
335- sbc hl , hl ; result bits 32..47 = 0
334+ xor a ; reset carry flag
335+ ld h , a ; result bits 32..47 = 0
336+ ld l , a
336337 exx
337- sbc hl , hl ; result bits 48..63 = 0
338+ ld h , a ; result bits 48..63 = 0
339+ ld l , a
338340 exx
339341 ld a , b ; mpr is b'c'ac
340342 ld b , 33 ; initialize loop counter
You can’t perform that action at this time.
0 commit comments