summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
46fcda1)
Use CELL instead of 4 in various places.
Fix broken members in c_struct.fth
/* Force Quad alignment. */
#define QUADUP(x) (((x)+3)&~3)
/* Force Quad alignment. */
#define QUADUP(x) (((x)+3)&~3)
#define MIN(a,b) ( ((a)<(b)) ? (a) : (b) )
#define MIN(a,b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a,b) ( ((a)>(b)) ? (a) : (b) )
#define MAX(a,b) ( ((a)>(b)) ? (a) : (b) )
#ifndef TOUCH
#define TOUCH(argument) ((void)argument)
#ifndef TOUCH
#define TOUCH(argument) ((void)argument)
/* Use local copy of CODE_BASE for speed. */
#define LOCAL_CODEREL_TO_ABS( a ) ((cell_t *) (((cell_t) a) + CodeBase))
/* Use local copy of CODE_BASE for speed. */
#define LOCAL_CODEREL_TO_ABS( a ) ((cell_t *) (((cell_t) a) + CodeBase))
-static const char *pfSelectFileModeCreate( int fam );
-static const char *pfSelectFileModeOpen( int fam );
+static const char *pfSelectFileModeCreate( cell_t fam );
+static const char *pfSelectFileModeOpen( cell_t fam );
/**************************************************************/
/**************************************************************/
-static const char *pfSelectFileModeCreate( int fam )
+static const char *pfSelectFileModeCreate( cell_t fam )
{
const char *famText = NULL;
switch( fam )
{
const char *famText = NULL;
switch( fam )
}
/**************************************************************/
}
/**************************************************************/
-static const char *pfSelectFileModeOpen( int fam )
+static const char *pfSelectFileModeOpen( cell_t fam )
{
const char *famText = NULL;
switch( fam )
{
const char *famText = NULL;
switch( fam )
/***************************************************************/
static int Write32ToFile( FileStream *fid, uint32_t Val )
{
/***************************************************************/
static int Write32ToFile( FileStream *fid, uint32_t Val )
{
uint8_t pad[4];
Write32BigEndian(pad,Val);
uint8_t pad[4];
Write32BigEndian(pad,Val);
EvenNumW = EVENUP(NumBytes);
EvenNumW = EVENUP(NumBytes);
- if( Write32ToFile( fid, ID ) < 0 ) goto error;
- if( Write32ToFile( fid, EvenNumW ) < 0 ) goto error;
+ if( Write32ToFile( fid, (uint32_t)ID ) < 0 ) goto error;
+ if( Write32ToFile( fid, (uint32_t)EvenNumW ) < 0 ) goto error;
numw = sdWriteFile( Data, 1, EvenNumW, fid );
if( numw != EvenNumW ) goto error;
numw = sdWriteFile( Data, 1, EvenNumW, fid );
if( numw != EvenNumW ) goto error;
** Compare two strings, case sensitive.
** Return zero if they match, -1 if s1<s2, +1 is s1>s2;
*/
** Compare two strings, case sensitive.
** Return zero if they match, -1 if s1<s2, +1 is s1>s2;
*/
-cell_t ffCompare( const char *s1, cell_t len1, const char *s2, int32_t len2 )
+cell_t ffCompare( const char *s1, cell_t len1, const char *s2, cell_t len2 )
{
cell_t i, result, n, diff;
{
cell_t i, result, n, diff;
char *ForthStringToC( char *dst, const char *FString, cell_t dstSize );
char *CStringToForth( char *dst, const char *CString, cell_t dstSize );
char *ForthStringToC( char *dst, const char *FString, cell_t dstSize );
char *CStringToForth( char *dst, const char *CString, cell_t dstSize );
-cell_t ffCompare( const char *s1, cell_t len1, const char *s2, int32_t len2 );
-cell_t ffCompareText( const char *s1, const char *s2, cell_t len );
+cell_t ffCompare(const char *s1, cell_t len1,
+ const char *s2, cell_t len2 );
+cell_t ffCompareText(const char *s1, const char *s2, cell_t len );
cell_t ffCompareTextCaseN( const char *s1, const char *s2, cell_t len );
void DumpMemory( void *addr, cell_t cnt);
cell_t ffCompareTextCaseN( const char *s1, const char *s2, cell_t len );
void DumpMemory( void *addr, cell_t cnt);
: (S+REL!) ( ptr addr offset -- ) + >r if.use->rel r> ! ;
: compile+!bytes ( offset size -- )
: (S+REL!) ( ptr addr offset -- ) + >r if.use->rel r> ! ;
: compile+!bytes ( offset size -- )
-\ ." compile+!bytes ( " over . dup . ." )" cr
+ ." compile+!bytes ( " over . dup . ." )" cr
swap [compile] literal \ compile offset into word
CASE
cell OF compile (s+!) ENDOF
2 OF compile (s+w!) ENDOF
1 OF compile (s+c!) ENDOF
swap [compile] literal \ compile offset into word
CASE
cell OF compile (s+!) ENDOF
2 OF compile (s+w!) ENDOF
1 OF compile (s+c!) ENDOF
- -4 OF compile (s+rel!) ENDOF \ 00002
+ -cell OF compile (s+rel!) ENDOF \ 00002
-2 OF compile (s+w!) ENDOF
-1 OF compile (s+c!) ENDOF
true abort" s! - illegal size!"
-2 OF compile (s+w!) ENDOF
-1 OF compile (s+c!) ENDOF
true abort" s! - illegal size!"
: !BYTES ( value address size -- )
CASE
cell OF ! ENDOF
: !BYTES ( value address size -- )
CASE
cell OF ! ENDOF
- -4 OF ( aptr addr ) swap if.use->rel swap ! ENDOF \ 00002
+ -cell OF ( aptr addr ) swap if.use->rel swap ! ENDOF \ 00002
ABS
2 OF w! ENDOF
1 OF c! ENDOF
ABS
2 OF w! ENDOF
1 OF c! ENDOF
cell OF @ ENDOF
2 OF w@ ENDOF
1 OF c@ ENDOF
cell OF @ ENDOF
2 OF w@ ENDOF
1 OF c@ ENDOF
- -4 OF @ if.rel->use ENDOF \ 00002
+ -cell OF @ if.rel->use ENDOF \ 00002
-2 OF w@ w->s ENDOF
-1 OF c@ b->s ENDOF
true abort" s@ - illegal size!"
-2 OF w@ w->s ENDOF
-1 OF c@ b->s ENDOF
true abort" s@ - illegal size!"
: (S+W@) ( addr offset -- val ) + w@ w->s ;
: compile+@bytes ( offset size -- )
: (S+W@) ( addr offset -- val ) + w@ w->s ;
: compile+@bytes ( offset size -- )
-\ ." compile+@bytes ( " over . dup . ." )" cr
+ ." compile+@bytes ( " over . dup . ." )" cr
swap [compile] literal \ compile offset into word
CASE
cell OF compile (s+@) ENDOF
2 OF compile (s+uw@) ENDOF
1 OF compile (s+uc@) ENDOF
swap [compile] literal \ compile offset into word
CASE
cell OF compile (s+@) ENDOF
2 OF compile (s+uw@) ENDOF
1 OF compile (s+uc@) ENDOF
- -4 OF compile (s+rel@) ENDOF \ 00002
+ -cell OF compile (s+rel@) ENDOF \ 00002
-2 OF compile (s+w@) ENDOF
-1 OF compile (s+c@) ENDOF
true abort" s@ - illegal size!"
-2 OF compile (s+w@) ENDOF
-1 OF compile (s+c@) ENDOF
true abort" s@ - illegal size!"
:struct mapper
long map_l1
long map_l2
:struct mapper
long map_l1
long map_l2
- aptr map_a1
- rptr map_r1
- flpt map_f1
short map_s1
ushort map_s2
byte map_b1
ubyte map_b2
short map_s1
ushort map_s2
byte map_b1
ubyte map_b2
+ aptr map_a1
+ rptr map_r1
+ flpt map_f1
+ 123456 map1 s! map_l1
+ map1 s@ map_l1 123456 - abort" map_l1 failed!"
+ 987654 map1 s! map_l2
+ map1 s@ map_l2 987654 - abort" map_l2 failed!"
+
- map1 s@ map_s1 -500 - abort" map_s1 failed!"
+ map1 s@ map_s1 dup . cr -500 - abort" map_s1 failed!"
-500 map1 s! map_s2
map1 s@ map_s2 -500 $ FFFF and - abort" map_s2 failed!"
-500 map1 s! map_s2
map1 s@ map_s2 -500 $ FFFF and - abort" map_s2 failed!"
-89 map1 s! map_b1
map1 s@ map_b1 -89 - abort" map_s1 failed!"
here map1 s! map_r1
-89 map1 s! map_b1
map1 s@ map_b1 -89 - abort" map_s1 failed!"
here map1 s! map_r1
;
\ Variables shared with object oriented code.
;
\ Variables shared with object oriented code.
- VARIABLE OB-STATE ( Compilation state. )
- VARIABLE OB-CURRENT-CLASS ( ABS_CLASS_BASE of current class )
- 1 constant OB_DEF_CLASS ( defining a class )
- 2 constant OB_DEF_STRUCT ( defining a structure )
+VARIABLE OB-STATE ( Compilation state. )
+VARIABLE OB-CURRENT-CLASS ( ABS_CLASS_BASE of current class )
+1 constant OB_DEF_CLASS ( defining a class )
+2 constant OB_DEF_STRUCT ( defining a structure )
-4 constant OB_OFFSET_SIZE
+\ A member contains:
+\ cell size of data in bytes (1, 2, cell)
+\ cell offset within structure
+
+cell 1- constant CELL_MASK
+cell negate constant -CELL
+cell constant OB_OFFSET_SIZE
: OB.OFFSET@ ( member_def -- offset ) @ ;
: OB.OFFSET, ( value -- ) , ;
: OB.OFFSET@ ( member_def -- offset ) @ ;
: OB.OFFSET, ( value -- ) , ;
ABS ( -- |+-b| )
ob-current-class @ ( -- b addr-space)
tuck @ ( as #b c , current space needed )
ABS ( -- |+-b| )
ob-current-class @ ( -- b addr-space)
tuck @ ( as #b c , current space needed )
- over 3 and 0= ( multiple of four? )
+ over CELL_MASK and 0= ( multiple of cell? )
\ Aliases
: APTR ( <name> -- ) long ;
\ Aliases
: APTR ( <name> -- ) long ;
-: RPTR ( <name> -- ) -4 bytes ; \ relative relocatable pointer 00001
+: RPTR ( <name> -- ) -cell bytes ; \ relative relocatable pointer 00001
: ULONG ( <name> -- ) long ;
: STRUCT ( <struct> <new_ivar> -- , define a structure as an ivar )
: ULONG ( <name> -- ) long ;
: STRUCT ( <struct> <new_ivar> -- , define a structure as an ivar )
: B->S ( c -- c' , sign extend byte )
dup $ 80 and
IF
: B->S ( c -- c' , sign extend byte )
dup $ 80 and
IF
+ [ $ 0FF invert ] literal or
-: W->S ( 16bit-signed -- 32bit-signed )
+: W->S ( 16bit-signed -- cell-signed )
+ IF
+ [ $ 0FFFF invert ] literal or
;
: WITHIN { n1 n2 n3 -- flag }
;
: WITHIN { n1 n2 n3 -- flag }
FREEZE \ prevent forgetting below this point
.( Dictionary compiled, save in "pforth.dic".) cr
FREEZE \ prevent forgetting below this point
.( Dictionary compiled, save in "pforth.dic".) cr
+\ 300000 headers-size !
+\ 700000 code-size !
c" pforth.dic" save-forth
c" pforth.dic" save-forth