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

Add UNRAVEL , dumps call stack #197

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions csrc/pf_guts.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@
** FV10 - 20170103 - Added ID_FILE_FLUSH ID_FILE_RENAME ID_FILE_RESIZE
** FV11 - 20241226 - Added ID_SLEEP_P, ID_VAR_BYE_CODE, ID_VERSION_CODE
** FV12 - 20241227 - Added Long name support, ID_FLAG_SMUDGE, ID_MASK_NAME_SIZE
** FV13 - 20250120 - Added R0 for UNRAVEL
*/

#define PF_FILE_VERSION (12) /* Bump this whenever primitives added. */
#define PF_FILE_VERSION (13) /* Bump this whenever primitives added. */

#if defined(PF_SUPPORT_LONG_NAMES)
#define PF_EARLIEST_FILE_VERSION (12) /* earliest one still compatible */
Expand Down Expand Up @@ -323,6 +324,7 @@ enum cforth_primitive_ids
ID_VERSION_CODE,
ID_FLAG_SMUDGE,
ID_MASK_NAME_SIZE,
ID_R_ZERO, /* R0 , base of return stack */
/* If you add a word above here,
** 1. update PF_FILE_VERSION
** 2. take away one reserved word below
Expand All @@ -331,7 +333,6 @@ enum cforth_primitive_ids
/* Only reserve space if we are adding FP so that we can detect
** unsupported primitives when loading dictionary.
*/
ID_RESERVED05,
ID_RESERVED06,
ID_RESERVED07,
ID_RESERVED08,
Expand Down
5 changes: 5 additions & 0 deletions csrc/pf_inner.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,11 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql ));
M_DROP;
endcase;

case ID_R_ZERO: /* ( -- rbase , base of return stack ) */
PUSH_TOS;
TOS = (cell_t)gCurrentTask->td_ReturnBase;
endcase;

case ID_ROLL: /* ( xu xu-1 xu-1 ... x0 u -- xu-1 xu-1 ... x0 xu ) */
{
cell_t ri;
Expand Down
1 change: 1 addition & 0 deletions csrc/pfcompil.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ PForthDictionary pfBuildDictionary( cell_t HeaderSize, cell_t CodeSize )
CreateDicEntryC( ID_R_FROM, "R>", 0 );
CreateDicEntryC( ID_RP_FETCH, "RP@", 0 );
CreateDicEntryC( ID_RP_STORE, "RP!", 0 );
CreateDicEntryC( ID_R_ZERO, "R0", 0 );
CreateDicEntryC( ID_SEMICOLON, ";", FLAG_IMMEDIATE );
CreateDicEntryC( ID_SP_FETCH, "SP@", 0 );
CreateDicEntryC( ID_SP_STORE, "SP!", 0 );
Expand Down
16 changes: 16 additions & 0 deletions fth/misc1.fth
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,19 @@ variable CLOSEST-XT
UNTIL
THEN
;

: UNRAVEL ( -- , show names of words on return stack )
>newline ." Calling sequence:" cr
r0 rp@ - cell /
1- \ skip call into unravel
0 max 50 min \ clip to reasonable range
0
?DO 4 spaces
rp@ i 2+ \ skip over DO LOOP control and call to UNRAVEL
cell* + @
dup code> >name ?dup
IF id. drop
ELSE .
THEN cr?
LOOP cr
;
Loading