Skip to content

Commit f20c133

Browse files
committed
Add function to read floating point value from address.
This is the same as "DPEEK()" for integers or "$()" for strings.
1 parent ad18ffc commit f20c133

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

manual.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,10 @@ with the hardware. Use with care!
955955
x = ADR("Hello")
956956
? $( x )
957957

958+
- %(_n_) :
959+
This returns the floating-point
960+
value stored at memory address _n_.
961+
958962

959963
List Of Statements
960964
==================

src/syntax/float.syn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ FP_FUNCS:
8282
"COs" FP_T_EXPR emit TOK_FP_COS
8383
"Val" STR_PAR_EXPR emit TOK_FP_VAL
8484
"RNd()" emit TOK_FP_RND
85+
"%" PAR_EXPR emit TOK_FP_LOAD
8586

8687
ADR_EXPR:
8788
emit { TOK_VAR_LOAD, VT_ARRAY_FLOAT } E_VAR_SEARCH "%"

testsuite/tests/floatadr.bas

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
' Procedure to sum N elements of an array:
2+
PROC SUM P N
3+
SUM% = 0
4+
WHILE N>0
5+
DEC N
6+
SUM% = SUM% + %(P)
7+
P = P + 6
8+
WEND
9+
ENDPROC
10+
11+
DIM A%(2)
12+
A%(0) = 0.125
13+
A%(1) = 0.0625
14+
A%(2) = 0.03125
15+
16+
@SUM &A%, 3
17+
? SUM%
18+
19+
X%=1234.5
20+
21+
@SUM &X%, 1
22+
? SUM%

testsuite/tests/floatadr.chk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Name: Test for using address of floating point vars
2+
Test: run-fp
3+
Output:
4+
0.21875
5+
1234.5

0 commit comments

Comments
 (0)