Deleted Added
full compact
words.c (94290) words.c (102657)
1/*******************************************************************
2** w o r d s . c
3** Forth Inspired Command Language
4** ANS Forth CORE word-set written in C
5** Author: John Sadler (john_sadler@alum.mit.edu)
6** Created: 19 July 1997
7** $Id: words.c,v 1.17 2001/12/05 07:21:34 jsadler Exp $
8*******************************************************************/

--- 27 unchanged lines hidden (view full) ---

36** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41** SUCH DAMAGE.
42*/
43
1/*******************************************************************
2** w o r d s . c
3** Forth Inspired Command Language
4** ANS Forth CORE word-set written in C
5** Author: John Sadler (john_sadler@alum.mit.edu)
6** Created: 19 July 1997
7** $Id: words.c,v 1.17 2001/12/05 07:21:34 jsadler Exp $
8*******************************************************************/

--- 27 unchanged lines hidden (view full) ---

36** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41** SUCH DAMAGE.
42*/
43
44/* $FreeBSD: head/sys/boot/ficl/words.c 94290 2002-04-09 17:45:28Z dcs $ */
44/* $FreeBSD: head/sys/boot/ficl/words.c 102657 2002-08-31 01:04:53Z scottl $ */
45
46#ifdef TESTMAIN
47#include <stdlib.h>
48#include <stdio.h>
49#include <ctype.h>
50#include <fcntl.h>
51#else
52#include <stand.h>

--- 674 unchanged lines hidden (view full) ---

727
728 int formatLength = stackPopINT(pVM->pStack);
729 char *format = (char *)stackPopPtr(pVM->pStack);
730 char *formatStop = format + formatLength;
731
732 int base = 10;
733 int unsignedInteger = FALSE;
734
45
46#ifdef TESTMAIN
47#include <stdlib.h>
48#include <stdio.h>
49#include <ctype.h>
50#include <fcntl.h>
51#else
52#include <stand.h>

--- 674 unchanged lines hidden (view full) ---

727
728 int formatLength = stackPopINT(pVM->pStack);
729 char *format = (char *)stackPopPtr(pVM->pStack);
730 char *formatStop = format + formatLength;
731
732 int base = 10;
733 int unsignedInteger = FALSE;
734
735 int append = FICL_TRUE;
735 FICL_INT append = FICL_TRUE;
736
737 while (format < formatStop)
738 {
739 char scratch[64];
740 char *source;
741 int actualLength;
742 int desiredLength;
743 int leadingZeroes;

--- 67 unchanged lines hidden (view full) ---

811 case '%':
812 source = format;
813 actualLength = 1;
814 default:
815 continue;
816 }
817 }
818
736
737 while (format < formatStop)
738 {
739 char scratch[64];
740 char *source;
741 int actualLength;
742 int desiredLength;
743 int leadingZeroes;

--- 67 unchanged lines hidden (view full) ---

811 case '%':
812 source = format;
813 actualLength = 1;
814 default:
815 continue;
816 }
817 }
818
819 if (append == FICL_TRUE)
819 if (append != FICL_FALSE)
820 {
821 if (!desiredLength)
822 desiredLength = actualLength;
823 if (desiredLength > bufferLength)
824 {
825 append = FICL_FALSE;
826 desiredLength = bufferLength;
827 }

--- 429 unchanged lines hidden (view full) ---

1257 flag = stackPopUNS(pVM->pStack);
1258
1259 if (flag)
1260 { /* fall through */
1261 vmBranchRelative(pVM, 1);
1262 }
1263 else
1264 { /* take branch (to else/endif/begin) */
820 {
821 if (!desiredLength)
822 desiredLength = actualLength;
823 if (desiredLength > bufferLength)
824 {
825 append = FICL_FALSE;
826 desiredLength = bufferLength;
827 }

--- 429 unchanged lines hidden (view full) ---

1257 flag = stackPopUNS(pVM->pStack);
1258
1259 if (flag)
1260 { /* fall through */
1261 vmBranchRelative(pVM, 1);
1262 }
1263 else
1264 { /* take branch (to else/endif/begin) */
1265 vmBranchRelative(pVM, *(int *)(pVM->ip));
1265 vmBranchRelative(pVM, (uintptr_t)*(pVM->ip));
1266 }
1267
1268 return;
1269}
1270
1271
1272/**************************************************************************
1273 e l s e C o I m

--- 32 unchanged lines hidden (view full) ---

1306 b r a n c h P a r e n
1307**
1308** Runtime for "(branch)" -- expects a literal offset in the next
1309** compilation address, and branches to that location.
1310**************************************************************************/
1311
1312static void branchParen(FICL_VM *pVM)
1313{
1266 }
1267
1268 return;
1269}
1270
1271
1272/**************************************************************************
1273 e l s e C o I m

--- 32 unchanged lines hidden (view full) ---

1306 b r a n c h P a r e n
1307**
1308** Runtime for "(branch)" -- expects a literal offset in the next
1309** compilation address, and branches to that location.
1310**************************************************************************/
1311
1312static void branchParen(FICL_VM *pVM)
1313{
1314 vmBranchRelative(pVM, *(int *)(pVM->ip));
1314 vmBranchRelative(pVM, (uintptr_t)*(pVM->ip));
1315 return;
1316}
1317
1318
1319/**************************************************************************
1320 e n d i f C o I m
1321**
1322**************************************************************************/

--- 145 unchanged lines hidden (view full) ---

1468 if (tempFW != NULL)
1469 {
1470 if (wordIsCompileOnly(tempFW))
1471 {
1472 vmThrowErr(pVM, "Error: Compile only!");
1473 }
1474
1475 vmExecute(pVM, tempFW);
1315 return;
1316}
1317
1318
1319/**************************************************************************
1320 e n d i f C o I m
1321**
1322**************************************************************************/

--- 145 unchanged lines hidden (view full) ---

1468 if (tempFW != NULL)
1469 {
1470 if (wordIsCompileOnly(tempFW))
1471 {
1472 vmThrowErr(pVM, "Error: Compile only!");
1473 }
1474
1475 vmExecute(pVM, tempFW);
1476 return FICL_TRUE;
1476 return (int)FICL_TRUE;
1477 }
1478 }
1479
1480 else /* (pVM->state == COMPILE) */
1481 {
1482 if (tempFW != NULL)
1483 {
1484 if (wordIsImmediate(tempFW))
1485 {
1486 vmExecute(pVM, tempFW);
1487 }
1488 else
1489 {
1490 dictAppendCell(dp, LVALUEtoCELL(tempFW));
1491 }
1477 }
1478 }
1479
1480 else /* (pVM->state == COMPILE) */
1481 {
1482 if (tempFW != NULL)
1483 {
1484 if (wordIsImmediate(tempFW))
1485 {
1486 vmExecute(pVM, tempFW);
1487 }
1488 else
1489 {
1490 dictAppendCell(dp, LVALUEtoCELL(tempFW));
1491 }
1492 return FICL_TRUE;
1492 return (int)FICL_TRUE;
1493 }
1494 }
1495
1496 return FICL_FALSE;
1497}
1498
1499
1500/*

--- 416 unchanged lines hidden (view full) ---

1917 if (index >= limit)
1918 {
1919 stackDrop(pVM->rStack, 3); /* nuke the loop indices & "leave" addr */
1920 vmBranchRelative(pVM, 1); /* fall through the loop */
1921 }
1922 else
1923 { /* update index, branch to loop head */
1924 stackSetTop(pVM->rStack, LVALUEtoCELL(index));
1493 }
1494 }
1495
1496 return FICL_FALSE;
1497}
1498
1499
1500/*

--- 416 unchanged lines hidden (view full) ---

1917 if (index >= limit)
1918 {
1919 stackDrop(pVM->rStack, 3); /* nuke the loop indices & "leave" addr */
1920 vmBranchRelative(pVM, 1); /* fall through the loop */
1921 }
1922 else
1923 { /* update index, branch to loop head */
1924 stackSetTop(pVM->rStack, LVALUEtoCELL(index));
1925 vmBranchRelative(pVM, *(int *)(pVM->ip));
1925 vmBranchRelative(pVM, (uintptr_t)*(pVM->ip));
1926 }
1927
1928 return;
1929}
1930
1931
1932static void plusLoopParen(FICL_VM *pVM)
1933{

--- 18 unchanged lines hidden (view full) ---

1952 if (flag)
1953 {
1954 stackDrop(pVM->rStack, 3); /* nuke the loop indices & "leave" addr */
1955 vmBranchRelative(pVM, 1); /* fall through the loop */
1956 }
1957 else
1958 { /* update index, branch to loop head */
1959 stackSetTop(pVM->rStack, LVALUEtoCELL(index));
1926 }
1927
1928 return;
1929}
1930
1931
1932static void plusLoopParen(FICL_VM *pVM)
1933{

--- 18 unchanged lines hidden (view full) ---

1952 if (flag)
1953 {
1954 stackDrop(pVM->rStack, 3); /* nuke the loop indices & "leave" addr */
1955 vmBranchRelative(pVM, 1); /* fall through the loop */
1956 }
1957 else
1958 { /* update index, branch to loop head */
1959 stackSetTop(pVM->rStack, LVALUEtoCELL(index));
1960 vmBranchRelative(pVM, *(int *)(pVM->ip));
1960 vmBranchRelative(pVM, (uintptr_t)*(pVM->ip));
1961 }
1962
1963 return;
1964}
1965
1966
1967static void loopICo(FICL_VM *pVM)
1968{

--- 2975 unchanged lines hidden ---
1961 }
1962
1963 return;
1964}
1965
1966
1967static void loopICo(FICL_VM *pVM)
1968{

--- 2975 unchanged lines hidden ---