Minor Forth Tweak

This commit is contained in:
Jeremiah Orians 2017-07-12 21:07:53 -04:00
parent 23b12e0ef9
commit 69a77610cf
No known key found for this signature in database
GPG Key ID: 7457821534D2ACCD
2 changed files with 6 additions and 6 deletions

View File

@ -32,12 +32,14 @@ Added TUCK, MIN, SPACES, :NONAME, FILL, and <> to stage3 FORTH
Added LSHIFT and RSHIFT to stage2 FORTH
Added PRINT to stage2 FORTH
Added Low memory detection to stage2 FORTH and now exits gracefully
Added Low memory detection to stage2 Lisp and now exists gracefully
** Changed
Minor refactor of stage3 FORTH by reepa
Stage3 FORTH WHILE's compile-time stack effect is now consistent with gforth
Changed behavior of stage2 FORTH's CREATE to better match the way it usually works.
Stage0 vm now will show an error message if the size of the rom exceeds the available memory
Modified stage3 forth library to dump upper case hex values
** Fixed
Updated checksums to reflect changes in stage2 FORTH

View File

@ -108,7 +108,7 @@
: S" STATE IF ['] BRANCH , HERE 0 , STR" ROT HERE TARGET! SWAP LITERAL LITERAL
ELSE STR" THEN ; IMMEDIATE
\ Extends S" to behave the way most users want "
\ Extends S" to behave the way most users want
: ." [COMPILE] S" STATE IF ['] TYPE , ELSE TYPE THEN ; IMMEDIATE
\ add the ANS keyword for modulus
@ -142,7 +142,7 @@ CREATE BASE 10 ,
\ works for hex and stuff
: >ASCII-DIGIT DUP 10 < IF 48 ELSE 87 THEN + ;
: >ASCII-DIGIT DUP 10 < IF 48 ELSE 55 THEN + ;
\ Given a number and address write out string form of number at address and
\ returns address and length (address should have at least 10 free bytes).
@ -195,15 +195,13 @@ CREATE BASE 10 ,
\ that+cell on the stack (for use by what follows DOES>) and run DOCOL. (Note:
\ implemented in forth.s)
\ Assumes most significant byte is at lower address
\ I'm not sure why that 65535 AND is necessary, but it seems to be. Some issue
\ with signed division I guess.
: 2C, 65535 AND DUP 256 / C, 255 AND C, ; \ ghetto right shift
: 2C, DUP 0xFF00 AND 8 RSHIFT C, 0xFF AND C, ;
\ Compiles an assembly-level jump to a location. Note that this isn't
\ future-proof, as if HERE gets past 30k or so 16 bits won't be large enough for
\ that jump. We may have to compile more than just a jump in the future in order
\ for DOES> to work properly - we'd need to load the address into a register,
\ having the actual address nearby, and then use that coroutine jump thing. 12
\ bytes.
\ bytes.
: JUMP-TO, HERE 0x3C C, 0x00 C, - 2C, ;
\ Sets the action of the latest word
: DOES> ['] LATEST , ['] DOER! , 'DODOES JUMP-TO, ; IMMEDIATE