瀏覽代碼

forth: Forth-ify "*"

pull/95/head
Virgil Dupras 4 年之前
父節點
當前提交
40eda1d933
共有 3 個文件被更改,包括 22 次插入27 次删除
  1. 二進制
      emul/forth/z80c.bin
  2. +1
    -27
      forth/forth.asm
  3. +21
    -0
      forth/z80c.fs

二進制
emul/forth/z80c.bin 查看文件


+ 1
- 27
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


+ 21
- 0
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 )


Loading…
取消
儲存