gnupic: gpsim/gpasm assertions
Subject:
gpsim/gpasm assertions
From:
"Scott Dattalo" ####@####.####
Date:
21 May 2005 17:38:18 +0100
Message-Id: <63541.67.118.98.139.1116693485.squirrel@67.118.98.139>
I've just added preliminary support for simulation assertions.
(allow a few hours for the public CVS cache to be updated).
The syntax in gpasm is:
.direct "A" "expression"
Where the quoted expression can be any legal gpsim expression. The quotes
are required.
This directive associates an expression with a program memory address.
When gpsim simulates the instruction at the address, the expression will
be evaluated. If the expression evaluates to true, then gpsim will halt.
Note that gpasm will not parse the expression. So if there's a syntax
error, you won't know until you start the simulation.
The expression must be a boolean expression and the syntax is identical to
C's. By boolean I mean that when evaluated, the expression must return
true or false. Here's are a few examples that can be found in
regression/assertions/assertions.asm:
clrf var1
clrf var2
clrf var3
; var1 and var2 have just been cleared, so the following two
; assertions should fail
.direct "A", "var1==5"
nop
.direct "A", "var2==6"
nop
; compound expression
.direct "A", "var2!=0 || var1!=0"
nop
Note, currently you cannot write:
.direct "A", "var2" ; break if var2 is non zero
nop
Instead, explicitly check for non-zero
.direct "A", "var2!=0" ; break if var2 is non zero
nop
One exception is a null expression. If you write:
.direct "A", ""
nop
This assertion will always be true. This is identical to a break point.
----
This is the first real pass at simulation assertions - I'd appreciate any
feed back. Also, I expect to make some changes/improvements.
Scott