Skip to content

Commit 30c3cea

Browse files
committed
Allow using %() at the left side of assignment.
This allows storing floating point values through a pointer.
1 parent 6fbce81 commit 30c3cea

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

manual.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,14 @@ with the hardware. Use with care!
984984
This returns the floating-point
985985
value stored at memory address _n_.
986986

987+
This function is special, as it is
988+
possible to use it also at the left
989+
side of an assignment, to store a
990+
floating point into an address:
991+
992+
%(1536) = 0.1234
993+
? %(1536)
994+
987995

988996
List Of Statements
989997
==================

src/syntax/float.syn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ FP_FUNCS:
8383
"Val" STR_EXPR emit TOK_FP_VAL
8484
"RNd()" emit TOK_FP_RND
8585
"%Time" emit TOK_FP_TIME
86-
"%" PAR_EXPR emit TOK_FP_LOAD
8786

8887
ADR_EXPR:
8988
emit { TOK_VAR_LOAD, VT_ARRAY_FLOAT } E_VAR_SEARCH "%"
@@ -129,6 +128,7 @@ INPUT_VAR:
129128
ARRAY_FLOAT_ADDR:
130129
emit { TOK_VAR_LOAD, VT_ARRAY_FLOAT } E_VAR_SEARCH "%" emit TOK_PUSH PAR_EXPR emit { TOK_MUL6, TOK_ADD }
131130
emit { TOK_NUM, VT_ARRAY_FLOAT } E_LABEL "%" emit TOK_PUSH PAR_EXPR emit { TOK_MUL6, TOK_ADD }
131+
"%" PAR_EXPR
132132
133133
# This is added at start of current table (<)
134134
DIM_VAR_TYPE:<

testsuite/tests/floatadr.bas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ ENDPROC
1111
DIM A%(2)
1212
A%(0) = 0.125
1313
A%(1) = 0.0625
14-
A%(2) = 0.03125
14+
' Test storing into pointer
15+
%(&A%+12)= 0.03125
1516

1617
@SUM &A%, 3
1718
? SUM%

0 commit comments

Comments
 (0)