Skip to content
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

DOES> doesn't work #1

Closed
drj11 opened this issue Sep 25, 2016 · 2 comments
Closed

DOES> doesn't work #1

drj11 opened this issue Sep 25, 2016 · 2 comments

Comments

@drj11
Copy link
Owner

drj11 commented Sep 25, 2016

It's not implemented yet.

Implementation Note:

The compile time behaviour of DOES> is to compile (does>) followed by EXIT into the current word, followed by(INIT), a short primary machine code sequence that implements the initialisation time behaviour. (note that the rest of the current word will be compiled after(INIT)up to the final;.

The run time behaviour of DOES> (implemented by (does>)) is to modify the Code Field of the most recently defined word to point to (INIT) (which immediately follows (does>) in the word list).

The initialisation time behaviour (of the word defined using the defining word that contains DOES> in its source) is implemented by the (INIT) code:
it is to set CODEPOINTER to the words following (INIT) and continue in the threaded interpreter.
Thus executing the word following DOES>.

(INIT) is the same code everywhere is appears, it needs to setup CODEPOINTER to a different sequence of threaded code (each defining word will instantiate a fresh (INIT)).
This is possible because after the indirect jump THIS will point to (INIT).

The minimal (INIT) then is just a jmp to the code that actually does the work.
Intel-64 doesn't have an absolute 64-bit jump.
But it does have this:

See http://www.ragestorm.net/blogs/?p=107 for this piece of code:

jmp [rip+0]
DQ someaddr

This is handy.
It's a fixed 14 byte sequence that will jump to a fixed location.

So at compile time DOES> can copy this fixed machine code sequence after (does>).

@drj11
Copy link
Owner Author

drj11 commented Mar 5, 2017

does> is now implemented, but it's not particular well tested.

@drj11
Copy link
Owner Author

drj11 commented Apr 3, 2017

There were bugs. They've been fixed 11ae5c4

@drj11 drj11 closed this as completed Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant