source: CIVL/examples/languageFeatures/duffs.cvl

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 766 bytes
Line 
1/* Commandline execution:
2 * civl verify duffs.cvl
3 * */
4#include <civlc.cvh>
5
6$input int a[8];
7
8// This is Stroustrup's version of Duff's device.
9void send(int *to, int *from, int count)
10{
11 int n = (count + 7) / 8;
12 switch(count % 8) {
13 case 0: do { *to++ = *from++;
14 case 7: *to++ = *from++;
15 case 6: *to++ = *from++;
16 case 5: *to++ = *from++;
17 case 4: *to++ = *from++;
18 case 3: *to++ = *from++;
19 case 2: *to++ = *from++;
20 case 1: *to++ = *from++;
21 --n;
22 } while(n > 0);
23 }
24}
25
26void main() {
27 int b[8];
28 send(b, a, 8);
29 for (int i = 0; i < 8; i++) {
30 $assert(a[i] == b[i]);
31 }
32}
Note: See TracBrowser for help on using the repository browser.