forth: Forth-ify "SWAP"

This commit is contained in:
Virgil Dupras 2020-03-30 08:06:11 -04:00
parent cc4700e389
commit d09ec0d757
4 changed files with 12 additions and 15 deletions

Binary file not shown.

View File

@ -928,22 +928,10 @@ DROP:
pop hl pop hl
jp next jp next
; ( a b -- b a ) .fill 167
.db "SWAP"
.dw $-DROP
.db 4
SWAP:
.dw nativeWord
pop hl
call chkPS
ex (sp), hl
push hl
jp next
.fill 149
.db "_bend" .db "_bend"
.dw $-SWAP .dw $-DROP
.db 5 .db 5
; Offset: 06ee ; Offset: 06ee
.out $ .out $

View File

@ -122,7 +122,7 @@
( Adjust HERE -1 because SCPY copies the null ) ( Adjust HERE -1 because SCPY copies the null )
HERE @ 1 _c - ( h h' ) HERE @ 1 _c - ( h h' )
_c DUP HERE ! ( h h' ) _c DUP HERE ! ( h h' )
SWAP _c - ( sz ) _c SWAP _c - ( sz )
( write prev value ) ( write prev value )
HERE @ CURRENT @ _c - , HERE @ CURRENT @ _c - ,
( write size ) ( write size )

View File

@ -39,6 +39,15 @@ CODE DUP
HL PUSHqq, ( A ) HL PUSHqq, ( A )
;CODE ;CODE
( a b -- b a )
CODE SWAP
HL POPqq, ( B )
DE POPqq, ( A )
chkPS,
HL PUSHqq, ( B )
DE PUSHqq, ( A )
;CODE
( a b -- a b a ) ( a b -- a b a )
CODE OVER CODE OVER
HL POPqq, ( B ) HL POPqq, ( B )