This repository was archived by the owner on Nov 11, 2021. It is now read-only.
Open
Conversation
f61ecc5 to
8bcaa59
Compare
- improves on the built-in print by handling negative integers in compiled
code "properly" -- with a leading minus sign the same as in the simulator.
- currently expands inline due to macros being the only code abstraction
we have
- perhaps useful as a basis of a native print written in porth at some point
- the built-in print is derived from compiling a similar conversion in C
- uses a temporary area within mem (32 bytes) to accumulate the characters
of the output string from back to front.
- a scratch buffer like this might make sense as a peer to mem, str, argv
- alternatively, being able to allocate this temp buffer on the stack seems
like it would be useful in avoiding contention for a global buffer
- uses `rot` which is a basic stack word from ANS forth
- without it, it was not convenient to use the third item on the stack
8bcaa59 to
3308bdc
Compare
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
print1- an example with native code to print an integer viawritetostdoutincludes an additional stack word
rotbecause without it, using the 3rd item on the stack is inconvenientimplemented as an example because perhaps we don't want to expand print inline on every use.
includes signmag that converts an integer to sign-magnitude form