1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 09:38:06 +11:00

forth: Forth-ify "*"

This commit is contained in:
Virgil Dupras 2020-03-26 14:36:14 -04:00
parent e82f13acf1
commit 40eda1d933
3 changed files with 22 additions and 27 deletions

Binary file not shown.

View File

@ -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

View File

@ -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 )