aboutsummaryrefslogblamecommitdiffstats
path: root/test/autowasm.c
blob: 7e4150a1ede236a298c2b2a252a7bc380320e28a (plain) (tree)
1
2
3
4
5
6
7
8
9






                     

                      
                        
 

















                                           
                                   


                                              
                                       




               
#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "./structs.h"
#include "./read.h"
#include "./aggregate.h"

#pragma weak main
int main (int argc, char** argv) {
  int wasm = open("./test.wasm", O_RDONLY);
  uint64_t test_u = 0U;
  int64_t test_s = 0;
  unsigned char test_byte;
  unsigned char byte;
  uint32_t word;
  uint32_t counter = 0U;

  read(wasm, &word, 8);
  printf("test_byte:%08x\n", word);

  lseek(wasm, 9, SEEK_SET);
  read(wasm, &word, 8);
  printf("test_byte:%08x\n", word);

  lseek(wasm, 9, SEEK_SET);
  test_u = read_leb_128_u(wasm, 5);
  printf("read u res is: %lu.\n", test_u);
  lseek(wasm, 0, SEEK_SET);
  while(read(wasm, &word, sizeof(uint32_t))) {
    printf("%d:%02x\t", counter, word);
    counter++;
  }
  printf("\n");
  return 0;
}