Fix bugs in 2! and 2@.

This commit is contained in:
Brad Nelson
2022-07-05 22:01:35 -07:00
parent 28c17e7714
commit 00119678ed
2 changed files with 11 additions and 2 deletions

View File

@ -148,3 +148,12 @@ e: test-arshift
$1234 4 arshift $123 =assert
-1 cell 8 * 1- arshift -1 =assert
;e
e: test-2@2!
create foo 2 cells allot
123 456 foo 2!
999 foo 2@
456 =assert
123 =assert
999 =assert
;e

View File

@ -47,8 +47,8 @@
X("cell/", CELLSLASH, DUP; tos = sizeof(cell_t); DUP; *sp = 1; SSMOD_FUNC; NIP) \
X("2drop", TWODROP, NIP; DROP) \
X("2dup", TWODUP, DUP; tos = sp[-1]; DUP; tos = sp[-1]) \
X("2@", TWOAT, DUP; *sp = ((cell_t *) tos)[1]; tos = *(cell_t *) tos) \
X("2!", TWOSTORE, DUP; ((cell_t *) tos)[0] = sp[-1]; \
X("2@", TWOAT, DUP; *sp = *(cell_t *) tos; tos = ((cell_t *) tos)[1]) \
X("2!", TWOSTORE, ((cell_t *) tos)[0] = sp[-1]; \
((cell_t *) tos)[1] = *sp; sp -= 2; DROP) \
Y(cmove, memmove((void *) *sp, (void *) sp[-1], tos); sp -= 2; DROP) \
X("cmove>", cmove2, memmove((void *) *sp, (void *) sp[-1], tos); sp -= 2; DROP) \