Skip to content

Commit

Permalink
use zf_int instead int in bitops word code
Browse files Browse the repository at this point in the history
  • Loading branch information
0x754C committed May 24, 2024
1 parent 2053d2e commit 4f61d92
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/atmega8/zfconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ typedef int32_t zf_cell;
#define ZF_CELL_FMT "%ld"
#define ZF_SCAN_FMT "%ld"

/* zf_int use for bitops, some arch int type width is less than register width,
it will cause sign fill, so we need manual specify it */
typedef int zf_int;

/* The type to use for pointers and adresses. 'unsigned int' is usually a good
* choice for best performance and smallest code size */
Expand Down
3 changes: 3 additions & 0 deletions src/linux/zfconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ typedef float zf_cell;
#define ZF_CELL_FMT "%.14g"
#define ZF_SCAN_FMT "%f"

/* zf_int use for bitops, some arch int type width is less than register width,
it will cause sign fill, so we need manual specify it */
typedef int zf_int;

/* The type to use for pointers and adresses. 'unsigned int' is usually a good
* choice for best performance and smallest code size */
Expand Down
10 changes: 5 additions & 5 deletions src/zforth/zforth.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,25 +727,25 @@ static void do_prim(zf_prim op, const char *input)
break;

case PRIM_AND:
zf_push((int)zf_pop() & (int)zf_pop());
zf_push((zf_int)zf_pop() & (zf_int)zf_pop());
break;

case PRIM_OR:
zf_push((int)zf_pop() | (int)zf_pop());
zf_push((zf_int)zf_pop() | (zf_int)zf_pop());
break;

case PRIM_XOR:
zf_push((int)zf_pop() ^ (int)zf_pop());
zf_push((zf_int)zf_pop() ^ (zf_int)zf_pop());
break;

case PRIM_SHL:
d1 = zf_pop();
zf_push((int)zf_pop() << (int)d1);
zf_push((zf_int)zf_pop() << (zf_int)d1);
break;

case PRIM_SHR:
d1 = zf_pop();
zf_push((int)zf_pop() >> (int)d1);
zf_push((zf_int)zf_pop() >> (zf_int)d1);
break;

default:
Expand Down

0 comments on commit 4f61d92

Please sign in to comment.