forked from M2IHP13-admin/JonesForth-arm
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge my work around CREATE...;CODE and CREATE...DOES> #8
Open
andreiw
wants to merge
12
commits into
organix:master
Choose a base branch
from
andreiw:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
annexia/jonesforth.s.txt uses LITSTRING, while jonesforth.s/f use LITS. There's no real reason why this should be different from the original. Signed-off-by: Andrei Warkentin <[email protected]>
The ARM Jonesforth is version 47, while the prelude and x86 version under annexia were version 42. Signed-off-by: Andrei Warkentin <[email protected]>
It's error-prone and doesn't quite help the readability, so implicitly calculate the length within the macro. Signed-off-by: Andrei Warkentin <[email protected]>
Now we can make machine code definitions in Forth. I've decided to make all machine code emitters start with $ (such as $NEXT), although this may change in the future. Signed-off-by: Andrei Warkentin <[email protected]>
putchar may buffer after all. Signed-off-by: Andrei Warkentin <[email protected]>
Make ;CODE behave like the gforth variant, i.e. usable inside a level 2 (word defining) word (i.e. after CREATE). Before (see x86 jonesforth 47): : FOO ;CODE Now: CODE FOO END-CODE Or with CREATE: : MKNOTHING WORD CREATE 0 , ;CODE END-CODE MKNOTHING FOO More examples... so now we could do something like: defword "$DOCON",F_IMM,ASMDOCON .int LIT @ r0 points to DFA ldr r12, [r0, #4] @ read cell from DFA .int COMMA .int LIT PUSHDSP r12 @ push to stack .int COMMA .int EXIT : MKCON WORD CREATE 0 , ( push dummy codeword, rewritten by (;CODE)) , ( actual constant ) ;CODE $DOCON END-CODE 5 MKCON CON5 CON5 . CR CODE ... ENDCODE instead can be used to make `defcode' definitions in Forth instead of jonesforth.s. So now we could do something like: @ push r0 to stack defword "$<R0",F_IMM,ASMFROMR0 .int LIT PUSHDSP r0 .int COMMA .int EXIT @ push r7 to stack defword "$<R7",F_IMM,ASMFROMR7 .int LIT PUSHDSP r7 .int COMMA .int EXIT @ pop stack to r0 defword "$>R0",F_IMM,ASMTOR0 .int LIT POPDSP r0 .int COMMA .int EXIT @ pop stack to r7 defword "$>R7",F_IMM,ASMTOR7 .int LIT POPDSP r7 .int COMMA .int EXIT CODE SWAP $>R0 $>R7 $<R0 $<R7 END-CODE HEX 1337 FOOF SWAP . . CR Signed-off-by: Andrei Warkentin <[email protected]>
DICT signature is changed. On success: ( -- dictionary_address ) On failure ( -- word_addr word_len 0 ) Introduce DICT-CHECKED wrapper around DICT to log error about unknown word and throws an ABORT. Fix all words using DICT to instead use DICT-CHECKED. As an unfortunate side effect, the exception handling code had to travel upwards somewhat. Signed-off-by: Andrei Warkentin <[email protected]>
[instead of segfaulting or printing nothing, of course] Now: CODE FOO END-CODE SEE ...gives CODE FOO ( CODEWORD FOO+0 ) E49A0004 E5901000 E12FFF11 (END-CODE) ...where the hex stuff is the $NEXT macro. CREATE ... ;CODE words: : MKNOTHING WORD CREATE 0 , 3 , ;CODE END-CODE MKNOTHING BAR SEE MKNOTHING SEE BAR ...gives : MKNOTHING WORD CREATE 0 , 3 , ;CODE ( MKNOTHING+9 ) E49A0004 E5901000 E12FFF11 (END-CODE) CODE BAR ( CODEWORD MKNOTHING+9 ) 3 (END-CODE) ...which shows you that BAR is a word created with MKNOTHING. Native words: SEE 2SWAP ...gives CODE 2SWAP ( CODEWORD 85BC ) (END-CODE) ...since length isn't encoded defcode definitions, this is the best we can do. Signed-off-by: Andrei Warkentin <[email protected]>
See my blog post for details. http://osdevnotes.blogspot.com/2015/07/does-in-jonesforth.html Signed-off-by: Andrei Warkentin <[email protected]>
I really just want this to be a bunch of useful stuff built around a generic jonesforth.s. Signed-off-by: Andrei Warkentin <[email protected]>
Be more explicit about arch. Signed-off-by: Andrei Warkentin <[email protected]>
This is still a wip. Some basic things seem to work, but a lot more is to be done. Signed-off-by: Andrei Warkentin <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A little while ago I ended up implementing fairly normal-behavior ;CODE and DOES>. Initially I ported ;CODE from the original x86 Jonesforth, but it was useless with a CREATE and did not match Forth. There are a few other cleanups, which I hope you will find useful, like SEE and improvements around how machine words are defined.
I'm happy to say that contrary to Jonesforth documentation, DOES> really is possible 👍