Merge tag 'upstream/0.2.1'
[debian/yforth] / blocke.c
1 /* yForth? - A Forth interpreter written in ANSI C
2  * Copyright (C) 2012 Luca Padovani
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  * ------------------------------------------------------------------------
17  * Module name: blocke.c
18  * Abstract:    Block extension word set
19  */
20
21 #include <stdio.h>
22 #include "yforth.h"
23 #include "core.h"
24 #include "coree.h"
25 #include "block.h"
26 #include "blocke.h"
27
28 /**************************************************************************/
29 /* VARIABLES ************** ***********************************************/
30 /**************************************************************************/
31
32 UCell _s_c_r;
33
34 /**************************************************************************/
35 /* WORDS ****************** ***********************************************/
36 /**************************************************************************/
37
38 void _empty_buffers() {
39         register int i;
40         for (i = 0; i < NUM_BLOCKS; i++) block_data[i].block_no = 0;
41 }
42
43 void _list() {
44         register Char *buffer;
45         register int i;
46         _block();
47         buffer = (Char *) *sp++;
48         for (i = 0; i < BLOCK_SIZE; i += 64) {
49                 *--sp = i / 64;
50                 *--sp = 2;
51                 _dot_r();
52                 *--sp = ':';
53                 _emit();
54                 _b_l();
55                 _emit();
56                 *--sp = (Cell) buffer + i;
57                 *--sp = 64;
58                 _type();
59                 _c_r();
60         }
61 }
62
63 void _thru() {
64         register UCell u2 = (UCell) *sp++;
65         register UCell u1 = (UCell) *sp++;
66         for (; u1 <= u2; u1++) {
67                 *--sp = u1;
68                 _load();
69         }
70 }
71
72