Jan-Langevad

STACKCHECKER.TXT

Feb 11th, 2026 (edited)
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | Source Code | 0 0
  1. \ STACKCHECKER.TXT
  2. \ Stack issue fixing tool by Jan Langevad / [email protected] 2026-02-10
  3. \ Place Copystack in your code/word that seems to have a stack problem.
  4. \ Place CheckStack in code/word, where you will check that stack is still intact,
  5. \ both in DEPTH and i content.
  6. \ Your program will stop if your stack has been changed unintentionally.
  7. \ By "zooming in" in your placement of these words, you should be able to locate
  8. \ nasty stack issues even in recursive programs.
  9. \ See alternative solution to same problem:
  10. \ https://github.com/forth2020/frenchie68/blob/main/sdigest-generic.4th
  11. \ by Francois Laagel
  12.  
  13. 100 value StackLength \ choose your own wanted length!
  14. create StackCopy StackLength allot
  15. : CopyStack
  16. depth StackLength 1- >
  17. if CR ." StackCopy's StackLength is to small! Will call QUIT efter a KEY is entered"
  18. KEY drop QUIT
  19. then
  20. depth \ any data on stack?
  21. if depth StackCopy ! \ remember depth
  22. depth 0
  23. do depth i - 1- pick
  24. StackCopy i +
  25. 1+ \ skip over copy depth
  26. !
  27. loop
  28. then
  29. ;
  30. : CheckStack \ is stack = saved stack?
  31. Depth
  32. StackCopy @ =
  33. if \ cr ." Stack DEPTH OK !"
  34. \ check if stack content is unchanged:
  35. depth 0
  36. do depth i - 1- pick \ get stack entry
  37. StackCopy i + \ now, get saved entry
  38. 1+ \ skip over copy depth
  39. @
  40. =
  41. 0=
  42. if cr ." Stack entry changed! Hit ENTER! " KEY drop
  43. else \ cr ." Stack unchanged- OK! " cr
  44. then
  45. loop
  46. cr
  47. else cr ." Stack depth changed! Content: " cr .S
  48. ." Hit ENTER! " KEY drop
  49. then
  50. ;
Advertisement
Add Comment
Please, Sign In to add comment