diff options
author | Thomas Huth <thuth@linux.vnet.ibm.com> | 2011-11-30 22:16:12 +0100 |
---|---|---|
committer | Thomas Huth <thuth@linux.vnet.ibm.com> | 2011-12-20 17:56:48 +0100 |
commit | c94eb8530fc3f09f6fd73b5520e4901e7b5b1273 (patch) | |
tree | 91085ea30709eae6c9792e3988d521fe398fb98e /slof | |
parent | f1fbd787c70c3d34aa9cadbcaf891956b84bba47 (diff) | |
download | SLOF-c94eb8530fc3f09f6fd73b5520e4901e7b5b1273.zip SLOF-c94eb8530fc3f09f6fd73b5520e4901e7b5b1273.tar.gz SLOF-c94eb8530fc3f09f6fd73b5520e4901e7b5b1273.tar.bz2 |
FCODE: Support for fcode programs with 8-bit offsets
IEEE1275 allows offset values to be either encoded with 8-bit values or
16-bit values. So far our FCODE engine only supported 16-bit offsets.
Now 8-bit offsets are working, too.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Diffstat (limited to 'slof')
-rw-r--r-- | slof/fs/fcode/1275.fs | 29 | ||||
-rw-r--r-- | slof/fs/fcode/core.fs | 2 | ||||
-rw-r--r-- | slof/fs/fcode/evaluator.fs | 2 |
3 files changed, 21 insertions, 12 deletions
diff --git a/slof/fs/fcode/1275.fs b/slof/fs/fcode/1275.fs index 13b68f9..597f7ed 100644 --- a/slof/fs/fcode/1275.fs +++ b/slof/fs/fcode/1275.fs @@ -30,8 +30,11 @@ ; : ?jump-direction ( n -- ) - dup 8000 >= IF FFFF swap - negate 2- THEN - ; + dup 8000 >= IF + 10000 - \ Create cell-sized negative value + THEN + fcode-offset - \ IP is already behind offset, so substract offset size +; : ?negative 8000 and @@ -43,9 +46,15 @@ drop ; -: read-fcode-offset \ ELSE needs to be fixed! - ?offset16 IF next-ip read-fcode-num16 ELSE THEN - ; +: read-fcode-offset + next-ip + ?offset16 IF + read-fcode-num16 + ELSE + read-byte + dup 80 and IF FF00 or THEN \ Fake 16-bit signed offset + THEN +; : b?branch ( flag -- ) ?compile-mode IF @@ -56,10 +65,10 @@ THEN ELSE ( flag ) IF - 2 jump-n-ip + fcode-offset jump-n-ip \ Skip over offset value ELSE read-fcode-offset - ?jump-direction 2- jump-n-ip + ?jump-direction jump-n-ip THEN THEN ; immediate @@ -78,7 +87,7 @@ THEN THEN ELSE - read-fcode-offset ?jump-direction 2- jump-n-ip + read-fcode-offset ?jump-direction jump-n-ip THEN ; immediate @@ -324,12 +333,12 @@ ; : offset16 ( -- ) - 16 to fcode-offset + 2 to fcode-offset ; : version1 ( -- ) 1 to fcode-spread - 8 to fcode-offset + 1 to fcode-offset read-header ; diff --git a/slof/fs/fcode/core.fs b/slof/fs/fcode/core.fs index fed7061..42b18d5 100644 --- a/slof/fs/fcode/core.fs +++ b/slof/fs/fcode/core.fs @@ -11,7 +11,7 @@ \ ****************************************************************************/ : ?offset16 ( -- true|false ) - fcode-offset 16 = + fcode-offset 2 = ; : ?arch64 ( -- true|false ) diff --git a/slof/fs/fcode/evaluator.fs b/slof/fs/fcode/evaluator.fs index e51676e..327b5ed 100644 --- a/slof/fs/fcode/evaluator.fs +++ b/slof/fs/fcode/evaluator.fs @@ -15,7 +15,7 @@ variable ip variable fcode-end variable fcode-num 1 value fcode-spread -16 value fcode-offset + 2 value fcode-offset false value eva-debug? true value fcode-debug? defer fcode-rb@ |