diff options
author | David Schleef <ds@schleef.org> | 2009-03-02 21:00:31 -0800 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2009-03-02 21:00:31 -0800 |
commit | 7d42fdd2be7dfe8e83a7b40fb9da091243fccef5 (patch) | |
tree | 1f7a1cdf7dd328220911aeb310111b8e61c18fbd /examples | |
parent | 4806688ef8e255e37256d9f0665716d19f59441e (diff) |
Add support for byte-sized data
Diffstat (limited to 'examples')
-rw-r--r-- | examples/simple.c | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/examples/simple.c b/examples/simple.c index 77031c1..ca95646 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -19,13 +19,14 @@ int16_t dest[N]; void test1(void); void test2(void); void test3(void); +void test4(void); int main (int argc, char *argv[]) { orc_init (); - test3(); + test4(); exit(0); } @@ -207,3 +208,57 @@ test3(void) } +uint8_t bsrc1[N+4]; +uint8_t bsrc2[N]; +uint8_t bdest_test[N]; +uint8_t bdest_ref[N]; +uint8_t bdest[N]; + +void +test4(void) +{ + OrcProgram *p; + OrcExecutor *ex; + int n; + + p = orc_program_new_dss (1, 1, 1); + + orc_program_append_str (p, "addb", "d1", "s1", "s2"); + + orc_program_compile (p); + + ex = orc_executor_new (p); + orc_executor_set_n (ex, N - 4); + orc_executor_set_array_str (ex, "s1", bsrc1); + orc_executor_set_array_str (ex, "s2", bsrc2); + orc_executor_set_array_str (ex, "d1", bdest); + + for(n=0;n<20;n++) { + int i; + + for(i=0;i<n;i++){ + bsrc1[i] = rand()&0xf; + bsrc2[i] = rand()&0xf; + } + for(i=0;i<n+4;i++){ + bdest[i] = 0; + } + + orc_executor_set_n (ex, n); + orc_executor_set_array_str (ex, "d1", bdest_ref); + orc_executor_emulate (ex); + + orc_executor_set_array_str (ex, "d1", bdest_test); + orc_executor_run (ex); + + for(i=0;i<n+4;i++){ + printf("# %4d %4d %4d %4d %c\n", bsrc1[i], bsrc2[i], bdest_ref[i], + bdest_test[i], + (bdest_ref[i] == bdest_test[i])?' ':'*'); + } + } + + orc_executor_free (ex); + orc_program_free (p); +} + |