diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index f8a2b42..f9c2830 100644 Binary files a/emul/forth/z80c.bin and b/emul/forth/z80c.bin differ diff --git a/forth/forth.asm b/forth/forth.asm index 31f53dc..742804f 100644 --- a/forth/forth.asm +++ b/forth/forth.asm @@ -1340,35 +1340,9 @@ MINUS: push hl jp next -; ( a b -- c ) A * B - .db "*" - .dw $-MINUS - .db 1 -MULT: - .dw nativeWord - pop de - pop bc - call chkPS - ; DE * BC -> DE (high) and HL (low) - ld hl, 0 - ld a, 0x10 -.loop: - add hl, hl - rl e - rl d - jr nc, .noinc - add hl, bc - jr nc, .noinc - inc de -.noinc: - dec a - jr nz, .loop - push hl - jp next - ; ( a1 a2 -- b ) .db "SCMP" - .dw $-MULT + .dw $-MINUS .db 4 SCMP: .dw nativeWord diff --git a/forth/z80c.fs b/forth/z80c.fs index 1ed407a..fbe7ac5 100644 --- a/forth/z80c.fs +++ b/forth/z80c.fs @@ -113,6 +113,27 @@ CODE XOR HL PUSHqq, ;CODE +CODE * + DE POPqq, + BC POPqq, + chkPS, + ( DE * BC -> DE (high) and HL (low) ) + HL 0 LDddnn, + A 0x10 LDrn, +( loop ) + HL ADDHLss, + E RLr, + D RLr, + 6 JRNCe, ( noinc ) + BC ADDHLss, + 3 JRNCe, ( noinc ) + DE INCss, +( noinc ) + A DECr, + 0 12 - JRNZe, ( loop ) + HL PUSHqq, +;CODE + ( Borrowed from http://wikiti.brandonw.net/ ) ( Divides AC by DE and places the quotient in AC and the remainder in HL )