source: CIVL/examples/languageFeatures/duffs.cvl@ d8bb437

1.23 2.0 main test-branch
Last change on this file since d8bb437 was 598f725, checked in by Tim Zirkel <zirkeltk@…>, 13 years ago

Corrected arguments in function call.

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

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