Imported Upstream version 0.1beta
[debian/yforth] / tools.c
1 /* yForth? - Written by Luca Padovani (C) 1996/97
2  * ------------------------------------------------------------------------
3  * This software is FreeWare as long as it comes with this header in each
4  * source file, anyway you can use it or any part of it whatever
5  * you want. It comes without any warranty, so use it at your own risk.
6  * ------------------------------------------------------------------------
7  * Module name: tools.c
8  * Abstract:    Programming Tools word set
9  */
10
11 #include <stdio.h>
12 #include "yforth.h"
13 #include "tools.h"
14 #include "core.h"
15
16 /**************************************************************************/
17 /* WORDS ******************************************************************/
18 /**************************************************************************/
19
20 void _dot_s() {
21         register Cell *p = sp;
22         while (p < sp_top) {
23                 *--sp = *p;
24                 _dot();
25                 p++;
26         }
27 }
28
29 void _question() {
30         _fetch();
31         _dot();
32 }
33
34 void _dump() {
35         register UCell u = *sp++;
36         register Char *addr = (Char *) *sp++;
37         while (u) {
38                 register int i;
39                 printf("%08p: ", addr);
40                 for (i = 0; i < 16; i++)
41                         if ((int) (u - i) > 0) printf("%02x ", *(addr + i) & 0xff);
42                         else printf("   ");
43                 for (i = 0; i < 16 && (u - i) > 0; i++)
44                         printf("%c", *(addr + i) < 32 ? '.' : *(addr + i));
45                 putchar('\n');
46                 addr += i;
47                 u -= i;
48         }
49 }
50
51 void _see() {
52         _error = E_NOPRIM;
53 }
54
55 void _words() {
56         register int i = 0;
57         register struct word_def *p;
58         register Cell col = 1;
59         while (i < VOC_HASH) {
60                 p = voc->voc[i++];
61                 while (p) {
62                         *--sp = (Cell) p->name;
63                         _count();
64                         if (col + sp[0] > 79) {
65                                 col = 1;
66                                 _c_r();
67                         }
68                         col += sp[0] + 1;
69                         _type();
70                         _b_l();
71                         _emit();
72                         p = p->link;
73                 }
74         }
75 }
76