mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-02 12:20:56 +11:00
Compare commits
3 Commits
cf2f6703bb
...
cb3e6469b8
Author | SHA1 | Date | |
---|---|---|---|
|
cb3e6469b8 | ||
|
40eda1d933 | ||
|
e82f13acf1 |
Binary file not shown.
@ -296,6 +296,8 @@ strskip:
|
|||||||
parseDecimal:
|
parseDecimal:
|
||||||
; First char is special: it has to succeed.
|
; First char is special: it has to succeed.
|
||||||
ld a, (hl)
|
ld a, (hl)
|
||||||
|
cp '-'
|
||||||
|
jr z, .negative
|
||||||
; Parse the decimal char at A and extract it's 0-9 numerical value. Put the
|
; Parse the decimal char at A and extract it's 0-9 numerical value. Put the
|
||||||
; result in A.
|
; result in A.
|
||||||
; On success, the carry flag is reset. On error, it is set.
|
; On success, the carry flag is reset. On error, it is set.
|
||||||
@ -349,6 +351,19 @@ parseDecimal:
|
|||||||
cp a ; ensure Z
|
cp a ; ensure Z
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
.negative:
|
||||||
|
inc hl
|
||||||
|
call parseDecimal
|
||||||
|
ret nz
|
||||||
|
push hl ; --> lvl 1
|
||||||
|
or a ; clear carry
|
||||||
|
ld hl, 0
|
||||||
|
sbc hl, de
|
||||||
|
ex de, hl
|
||||||
|
pop hl ; <-- lvl 1
|
||||||
|
xor a ; set Z
|
||||||
|
ret
|
||||||
|
|
||||||
; *** Support routines ***
|
; *** Support routines ***
|
||||||
; Find the entry corresponding to word where (HL) points to and sets DE to
|
; Find the entry corresponding to word where (HL) points to and sets DE to
|
||||||
; point to that entry.
|
; point to that entry.
|
||||||
@ -1313,39 +1328,9 @@ R2P:
|
|||||||
push hl
|
push hl
|
||||||
jp next
|
jp next
|
||||||
|
|
||||||
.db "I"
|
|
||||||
.dw $-R2P
|
|
||||||
.db 1
|
|
||||||
I:
|
|
||||||
.dw nativeWord
|
|
||||||
ld l, (ix)
|
|
||||||
ld h, (ix+1)
|
|
||||||
push hl
|
|
||||||
jp next
|
|
||||||
|
|
||||||
.db "I'"
|
|
||||||
.dw $-I
|
|
||||||
.db 2
|
|
||||||
IPRIME:
|
|
||||||
.dw nativeWord
|
|
||||||
ld l, (ix-2)
|
|
||||||
ld h, (ix-1)
|
|
||||||
push hl
|
|
||||||
jp next
|
|
||||||
|
|
||||||
.db "J"
|
|
||||||
.dw $-IPRIME
|
|
||||||
.db 1
|
|
||||||
J:
|
|
||||||
.dw nativeWord
|
|
||||||
ld l, (ix-4)
|
|
||||||
ld h, (ix-3)
|
|
||||||
push hl
|
|
||||||
jp next
|
|
||||||
|
|
||||||
; ( a b -- c ) A + B
|
; ( a b -- c ) A + B
|
||||||
.db "+"
|
.db "+"
|
||||||
.dw $-J
|
.dw $-R2P
|
||||||
.db 1
|
.db 1
|
||||||
PLUS:
|
PLUS:
|
||||||
.dw nativeWord
|
.dw nativeWord
|
||||||
@ -1370,35 +1355,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
|
||||||
|
@ -26,6 +26,12 @@
|
|||||||
extra 0xdd / 0xfd and then spit the equivalent of HL )
|
extra 0xdd / 0xfd and then spit the equivalent of HL )
|
||||||
: IX 0xdd A, HL ;
|
: IX 0xdd A, HL ;
|
||||||
: IY 0xfd A, HL ;
|
: IY 0xfd A, HL ;
|
||||||
|
: _ix+- 0xff AND 0xdd A, (HL) ;
|
||||||
|
: _iy+- 0xff AND 0xfd A, (HL) ;
|
||||||
|
: IX+ _ix+- ;
|
||||||
|
: IX- 0 -^ _ix+- ;
|
||||||
|
: IY+ _iy+- ;
|
||||||
|
: IY- 0 -^ _iy+- ;
|
||||||
|
|
||||||
( -- )
|
( -- )
|
||||||
: OP1 CREATE C, DOES> C@ A, ;
|
: OP1 CREATE C, DOES> C@ A, ;
|
||||||
@ -77,17 +83,35 @@
|
|||||||
0x03 OP1qq INCss,
|
0x03 OP1qq INCss,
|
||||||
0x09 OP1qq ADDHLss,
|
0x09 OP1qq ADDHLss,
|
||||||
|
|
||||||
( rd rr )
|
: _1rr
|
||||||
: OP1rr
|
|
||||||
CREATE C,
|
|
||||||
DOES>
|
|
||||||
C@ ( rd rr op )
|
C@ ( rd rr op )
|
||||||
ROT ( rr op rd )
|
ROT ( rr op rd )
|
||||||
8 * ( rr op rd<<3 )
|
8 * ( rr op rd<<3 )
|
||||||
OR OR A,
|
OR OR A,
|
||||||
;
|
;
|
||||||
|
|
||||||
|
( rd rr )
|
||||||
|
: OP1rr
|
||||||
|
CREATE C,
|
||||||
|
DOES>
|
||||||
|
_1rr
|
||||||
|
;
|
||||||
0x40 OP1rr LDrr,
|
0x40 OP1rr LDrr,
|
||||||
|
|
||||||
|
( ixy+- HL rd )
|
||||||
|
: LDIXYr,
|
||||||
|
( dd/fd has already been spit )
|
||||||
|
LDrr, ( ixy+- )
|
||||||
|
A,
|
||||||
|
;
|
||||||
|
|
||||||
|
( rd ixy+- HL )
|
||||||
|
: LDrIXY,
|
||||||
|
ROT ( ixy+- HL rd )
|
||||||
|
SWAP ( ixy+- rd HL )
|
||||||
|
LDIXYr,
|
||||||
|
;
|
||||||
|
|
||||||
( n -- )
|
( n -- )
|
||||||
: OP2n
|
: OP2n
|
||||||
CREATE C,
|
CREATE C,
|
||||||
|
@ -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,
|
||||||
|
-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 )
|
||||||
@ -133,7 +154,7 @@ CODE /MOD
|
|||||||
DE ADDHLss,
|
DE ADDHLss,
|
||||||
C DECr,
|
C DECr,
|
||||||
( skip )
|
( skip )
|
||||||
0 12 - DJNZe, ( loop )
|
-12 DJNZe, ( loop )
|
||||||
B A LDrr,
|
B A LDrr,
|
||||||
HL PUSHqq,
|
HL PUSHqq,
|
||||||
BC PUSHqq,
|
BC PUSHqq,
|
||||||
@ -168,3 +189,21 @@ CODE PC@
|
|||||||
L INr(C),
|
L INr(C),
|
||||||
HL PUSHqq,
|
HL PUSHqq,
|
||||||
;CODE
|
;CODE
|
||||||
|
|
||||||
|
CODE I
|
||||||
|
L 0 IX+ LDrIXY,
|
||||||
|
H 1 IX+ LDrIXY,
|
||||||
|
HL PUSHqq,
|
||||||
|
;CODE
|
||||||
|
|
||||||
|
CODE I'
|
||||||
|
L 2 IX- LDrIXY,
|
||||||
|
H 1 IX- LDrIXY,
|
||||||
|
HL PUSHqq,
|
||||||
|
;CODE
|
||||||
|
|
||||||
|
CODE J
|
||||||
|
L 4 IX- LDrIXY,
|
||||||
|
H 3 IX- LDrIXY,
|
||||||
|
HL PUSHqq,
|
||||||
|
;CODE
|
||||||
|
Loading…
Reference in New Issue
Block a user