shithub: riscv

Download patch

ref: 9632ff2381580179060faa0f7e69eb80d0c27e50
parent: 20e695c1787144dd922002c55a3f0a2dc16cb198
author: aiju <devnull@localhost>
date: Sat Mar 31 08:41:41 EDT 2018

forp(1): document [] and some bugs

--- a/sys/man/1/forp
+++ b/sys/man/1/forp
@@ -88,9 +88,13 @@
 Expressions can be formed just as in C, however when used in an expression, all variables are automatically promoted to an infinite size signed type.
 The valid operators are listed below, in decreasing precedence. Note that logical operations treat all non-zero values as 1, whereas bitwise operators operate on all bits independently.
 .TP "\w'\fL<\fR, \fL<=\fR, \fL>\fR, \fL>=\fR  'u"
-\fL!\fR, \fL~\fR, \fL-\fR
-(Unary operators) Logical and bitwise "not", arithmetic negation. Because of promotion, \fL~\fR and \fL-\fR operate beyond the width of variables.
+\fL[]\fR
+Array indexing. The syntax is \fIvar\fL[\fIidx\fL:\fIn\fR] to address \fIn\fR bits with the least-significant bit at \fIidx\fR.
+Omiting \fL:\fIn\fR addresses a single bit.
 .TP
+\fL!\fR, \fL~\fR, \fL+\fR, \fL-\fR
+(Unary operators) Logical and bitwise "not", unary plus (no-op), arithmetic negation. Because of promotion, \fL~\fR and \fL-\fR operate beyond the width of variables.
+.TP
 \fL*\fR, \fL/\fR, \fL%\fR
 Multiplication, division, modulo.
 Division and modulo add an assumption that the divisor is non-zero.
@@ -188,6 +192,12 @@
 .IR spin (1)
 .SH BUGS
 Any proof is only as good as the assumptions made, in particular care has to be taken with respect to truncation of intermediate results.
+.PP
+Array indices must be constants.
+.PP
+Left shifting can produce a huge number of intermediate bits.
+.I Forp
+will try to identify the minimum needed number but it may be a good idea to help it by assigning the result of a left shift to a variable.
 .SH HISTORY
 .I Forp
 first appeared in 9front in March, 2018.