mirror of
https://github.com/hsoft/collapseos.git
synced 2025-02-19 04:26:03 +11:00
forth: Forth-ify "*"
This commit is contained in:
parent
e82f13acf1
commit
40eda1d933
Binary file not shown.
@ -1340,35 +1340,9 @@ MINUS:
|
|||||||
push hl
|
push hl
|
||||||
jp next
|
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 )
|
; ( a1 a2 -- b )
|
||||||
.db "SCMP"
|
.db "SCMP"
|
||||||
.dw $-MULT
|
.dw $-MINUS
|
||||||
.db 4
|
.db 4
|
||||||
SCMP:
|
SCMP:
|
||||||
.dw nativeWord
|
.dw nativeWord
|
||||||
|
@ -113,6 +113,27 @@ CODE XOR
|
|||||||
HL PUSHqq,
|
HL PUSHqq,
|
||||||
;CODE
|
;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/ )
|
( Borrowed from http://wikiti.brandonw.net/ )
|
||||||
( Divides AC by DE and places the quotient in AC and the
|
( Divides AC by DE and places the quotient in AC and the
|
||||||
remainder in HL )
|
remainder in HL )
|
||||||
|
Loading…
Reference in New Issue
Block a user