[BACK]Return to test1.c CVS log [TXT][DIR] Up to [local] / OpenXM / doc / oxlib

File: [local] / OpenXM / doc / oxlib / test1.c (download)

Revision 1.3, Thu Mar 16 07:34:37 2000 UTC (24 years, 2 months ago) by noro
Branch: MAIN
CVS Tags: maekawa-ipv6, RELEASE_1_2_1, RELEASE_1_1_3, RELEASE_1_1_2
Changes since 1.2: +3 -4 lines

Makefile : cleanup around the directory names.
test1.c, test2.c : modified the name and the location of the header file.
test3.c : another sample.

% test3
Input>asir 123     <- push 123
Input>pop          <- pop and print
Output>
00 00 00 14 00 00 00 01 00 00 00 7b
Input>push 00 00 00 14 00 00 00 01 00 00 00 0c  <- push 12
Input>push 00 00 00 14 00 00 00 01 00 00 00 08  <- push 8
Input>push 00 00 00 02 00 00 00 02              <- push int32 2
Input>asir "igcd"   <- push a string (function name)
Input>cmd 269       <- executeFunction
Input>pop
Output>
00 00 00 14 00 00 00 01 00 00 00 04     <- 4 = gcd(12,8)
Input>asir quit                         <- execute asir 'quit' command
%

/* $OpenXM: OpenXM/doc/oxlib/test1.c,v 1.3 2000/03/16 07:34:37 noro Exp $ */
#include <asir/ox.h>

main() {
  hoge();
}

hoge() {
  /*  (CMO_ZZ,12); */
  unsigned char cmo0[]=
  {00, 00, 00, 0x14,
   00, 00, 00, 01, 00, 00, 00, 0xc};

  /* (CMO_ZZ,8) */
  unsigned char cmo1[] =
  {00, 00, 00, 0x14,
   00, 00, 00, 01, 00, 00, 00, 8};  

  /* (CMO_INT32,2); */
  unsigned char cmo2[] =
  { 00, 00, 00, 02, 00, 00, 00, 02}; 

  /* (CMO_STRING,"igcd") */
  unsigned char cmo3[] =
  {00, 00, 00, 04, 00, 00, 00, 04,
   0x69,0x67,0x63,0x64 };
  unsigned char cmo[1024];
  int i,size;

  asir_ox_init(1);
  asir_ox_push_cmo(cmo0);
  asir_ox_push_cmo(cmo1);
  asir_ox_push_cmo(cmo2);
  asir_ox_push_cmo(cmo3);

  asir_ox_push_cmd(SM_executeFunction);  /* execute function */
  
  size = asir_ox_peek_cmo_size();
  if (size < 1024) {
	asir_ox_pop_cmo(cmo, size);
  }else{
	fprintf(stderr,"Too big cmo size.\n"); exit(1);
  }

  printf("gcd of 12 and 8, in the cmo format, is \n");
  for (i=0; i<size; i++) {
	printf(" %2x ",cmo[i]);
  }
  printf("\n");
}