mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-28 08:58:07 +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
|
||||
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
|
||||
|
@ -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 )
|
||||
|
Loading…
Reference in New Issue
Block a user