コード例 #1
0
ファイル: asm.c プロジェクト: drcz/drczlang
void assemble(SE *code,FILE *out,char first) {
  char *opsym;
  /* 1) machine code file should always start with number of used env-slots (symbols),
     2) machine code should at first add T atom to its environment, like this: (CONST t NAME t). */
  if(first==1) fprintf(out,"(%d %d t %d 0 ",symbols_p,O_CONST,O_NAME);
  else fprintf(out,"( ");
  while(code!=NULL) {
    opsym=symval(car(code));
    fprintf(out,"%d ",opcode(opsym));
    if(strcmp(opsym,"const")==0) {      
      write_se(car(cdr(code)),out); fprintf(out," ");
      code=cdr(cdr(code)); continue;

    } else if(strcmp(opsym,"lookup")==0 || strcmp(opsym,"name")==0 || strcmp(opsym,"forget")==0) {
      fprintf(out,"%d ",sym2num(symval(car(cdr(code)))));
      code=cdr(cdr(code)); continue;

    } else if(strcmp(opsym,"select")==0 || strcmp(opsym,"srelect")==0) {
      assemble(car(cdr(code)),out,0);
      assemble(car(cdr(cdr(code))),out,0);
      code=cdr(cdr(cdr(code)));
      continue;

    } else if(strcmp(opsym,"proc")==0) {
      assemble(car(cdr(code)),out,0);
      code=cdr(cdr(code));
      continue;

    } else {
      code=cdr(code);
    }
  } /* while... */
  fprintf(out,") ");
}
コード例 #2
0
ファイル: test_arrange.c プロジェクト: paulsaturn/linux_test
main()
{
	int k,h;
	
	k = assemble(10,4)*assemble(6,3)*assemble(3,3);
	printf("共有%d种排法!\n",k);
}
コード例 #3
0
ファイル: public03.c プロジェクト: Foshie/Classes
int main() {
  Mem mem[SZ];
  short registers[NUM_REGISTERS]= {0, 11, 9, 7, 5, 2, 0, 0};
  short exp_registers[NUM_REGISTERS]= {0, 0, 1, 1, 1, 5};
  int num_instructions;
  Status ret;

  num_instructions= assemble("public03.a", mem);

  if (num_instructions == 0)
    printf("Regretfully the program couldn't be assembled.  Bye.\n");
  else {

    ret= execute_program(mem, registers, 0, num_instructions, 0);

    if (ret != ACTIVE)  /* because there's no halt instruction */
      printf("execute_program() returned unexpected value (%d).\n", ret);
    else
      if ((ret= compare_registers(registers, exp_registers, 1, 5)) != -1) {
        printf("Registers appear incorrect after execute_program() call.\n");
        printf("First incorrect register is %d (%d instead of %d).\n",
               ret, registers[ret], exp_registers[ret]);
      } else printf("Registers are correct after execute_program() call!\n");

  }

  return 0;
}
コード例 #4
0
ファイル: ocore_asmcho.c プロジェクト: occho/cpu
int main(int argc, char **argv, char **envp) {
	int i;
	if (argc < 2) {
		puts("USAGE:./asmcho [filename] [options]:\n");
		return 1;
	}

	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-b") == 0) {
			output_type = 1;
		} else if (strcmp(argv[i], "-h") == 0) {
			output_type = 2;
		} else if (strcmp(argv[i], "-coe") == 0) {
			output_type = 3;
		}
	}

	for (i = 1; i < argc; i++) {
		if (argv[i][0] != '-') {
			assemble(argv[i]);
		}
	}

	return 0;
}
コード例 #5
0
ファイル: assembler.c プロジェクト: endeav0r/ravm
int main (int argc, char * argv[]) {
    int source_i;
    char * text;
    struct _token * tokens;
    struct _parser parser;
    
    memset(&parser, 0, sizeof(struct _parser));
    
    if (argc < 3) {
        fprintf(stderr, "usage: %s <binary_out> <assembly source file>s\n", argv[0]);
        exit(0);
    }
    
    lexer_init();
    
    for (source_i = 2; source_i < argc; source_i++) {
        text = assembler_read_file(argv[source_i]);
        tokens = lexer(text);
        free(text);
        parser_parse(&parser, tokens);
    }
    
    assembler_memory_definition_labels(&parser);
    
    assemble(&parser, argv[1]);
    lexer_tokens_delete(tokens);
       
    return 0;
}
コード例 #6
0
void AssembleScans::assemble()
{
    if (scrSelectFiles->nFiles < 2)
        return;
    
    //fill a vector with select filenames
    vector<string> filenames;
    for (int i=0; i<scrSelectFiles->nFiles; i++)
        if (scrSelectFiles->selected[i])
            filenames.push_back(scrSelectFiles->getPath(i));
        
    
    if (filenames.size() < 1)
        return;

	//data is the base
    data.load(filenames[0]);
    
    ScanSet other;
    
    for (int iOther = 1; iOther < filenames.size(); iOther++)
    {
        other.load(filenames[iOther]);
        assemble(data, other);        
    }
}
コード例 #7
0
ファイル: assembler.c プロジェクト: betawaffle/dcpu16
int main(int argc, char **argv) {
	const char *outfn = "out.hex";

	while (argc > 1) {
		argc--;
		argv++;
		if (argv[0][0] == '-') {
			if (!strcmp(argv[0],"-o")) {
				if (argc > 1) {
					outfn = argv[1];
					argc--;
					argv++;
					continue;
				}
			}
			die("unknown option: %s", argv[0]);
		}
		assemble(argv[0]);
	}

	if (PC != 0) {
		linebuffer[0] = 0;
		resolve_fixups();
		emit(outfn);
	}
	return 0;
}
コード例 #8
0
ファイル: fd2_program.c プロジェクト: Haifen/Mesa-3D
/* Creates shader:
 *    EXEC ADDR(0x3) CNT(0x1)
 *       (S)FETCH:	VERTEX	R1.xyz1 = R0.x FMT_32_32_32_FLOAT
 *                           UNSIGNED STRIDE(12) CONST(26, 0)
 *    ALLOC POSITION SIZE(0x0)
 *    EXEC ADDR(0x4) CNT(0x1)
 *          ALU:	MAXv	export62 = R1, R1	; gl_Position
 *    ALLOC PARAM/PIXEL SIZE(0x0)
 *    EXEC_END ADDR(0x5) CNT(0x0)
 */
static struct fd2_shader_stateobj *
create_solid_vp(void)
{
	struct fd2_shader_stateobj *so = create_shader(SHADER_VERTEX);
	struct ir2_cf *cf;
	struct ir2_instruction *instr;

	if (!so)
		return NULL;

	so->ir = ir2_shader_create();

	cf = ir2_cf_create(so->ir, EXEC);

	instr = ir2_instr_create_vtx_fetch(cf, 26, 0, FMT_32_32_32_FLOAT, false, 12);
	ir2_reg_create(instr, 1, "xyz1", 0);
	ir2_reg_create(instr, 0, "x", 0);

	cf = ir2_cf_create_alloc(so->ir, SQ_POSITION, 0);
	cf = ir2_cf_create(so->ir, EXEC);

	instr = ir2_instr_create_alu(cf, MAXv, ~0);
	ir2_reg_create(instr, 62, NULL, IR2_REG_EXPORT);
	ir2_reg_create(instr, 1, NULL, 0);
	ir2_reg_create(instr, 1, NULL, 0);

	cf = ir2_cf_create_alloc(so->ir, SQ_PARAMETER_PIXEL, 0);
	cf = ir2_cf_create(so->ir, EXEC_END);

	return assemble(so);
}
コード例 #9
0
ファイル: elasticitySolver.cpp プロジェクト: live-clones/gmsh
void elasticitySolver::solve()
{
  std::string sysname = "A";
  if(pAssembler && pAssembler->getLinearSystem(sysname))
    delete pAssembler->getLinearSystem(sysname);

#if defined(HAVE_PETSC)
  linearSystemPETSc<double> *lsys = new linearSystemPETSc<double>;
#elif defined(HAVE_GMM)
  linearSystemCSRGmm<double> *lsys = new linearSystemCSRGmm<double>;
#else
  linearSystemFull<double> *lsys = new linearSystemFull<double>;
#endif

  assemble(lsys);
  // printLinearSystem(lsys,pAssembler->sizeOfR());
  lsys->systemSolve();
  printf("-- done solving!\n");

  double energ = 0;
  GaussQuadrature Integ_Bulk(GaussQuadrature::GradGrad);
  for(std::size_t i = 0; i < elasticFields.size(); i++) {
    SolverField<SVector3> Field(pAssembler, LagSpace);
    IsotropicElasticTerm Eterm(Field, elasticFields[i]._e,
                               elasticFields[i]._nu);
    BilinearTermToScalarTerm Elastic_Energy_Term(Eterm);
    Assemble(Elastic_Energy_Term, elasticFields[i].g->begin(),
             elasticFields[i].g->end(), Integ_Bulk, energ);
  }
  printf("elastic energy=%f\n", energ);
}
コード例 #10
0
ファイル: crossasm.c プロジェクト: ncc25/crossasm
int processfile(FILE *srcfile, int start, int flags) {
    char srctemp[80];
    char *srcline;
    int thispass;

    for(thispass=0; thispass<=1; thispass++) {
        asmpass=flags+(thispass<<1);
        rewind(srcfile);
        destadr=start;
        lineno=1;
        while(fgets(srctemp, 80, srcfile) != NULL) {
            srcline=srctemp;
            skipspace(srcline);
            if(*srcline=='.') {
                srcline=checklabel(srcline+1, codeorig+destadr);
                skipspace(srcline);
            }
            if(*srcline=='#')
                asmdirect(srcline);
            else if(*srcline!='/')
                assemble(srcline);
            lineno++;
        }
    }
    return(destadr);
}
コード例 #11
0
ファイル: public03.c プロジェクト: Jornason/Class-Projects
int main() {
  Memory_word program[MEMORY_SIZE]= {0};
  Int_register reg[NUM_REGISTERS]= {0};
  Float_register freg[NUM_REGISTERS]= {0.0};
  char *filename= "public03.a";
  int num_instructions;
  State status;
  int q;

  num_instructions= assemble(filename, program, 0);

  if (num_instructions == 0)
    printf("Couldn't assemble \"%s\", exiting.\n", filename);
  else {

    status= run(program, reg, freg, -1, -1);

    if (status != FINISHED)
      printf("\nError - run() returned status %d.\n", status);
    else {
      printf("Integer Registers:\n");
      for (q= 0; q < NUM_REGISTERS; q++)
        printf("Register R%02d: %d\n", q, reg[q]);
      printf("\n");
      printf("Float Registers:\n");
      for (q= 0; q < NUM_REGISTERS; q++)
        printf("Register F%02d: %f\n", q, freg[q]);
      printf("\n");
      printf("Memory:\n");
      check_memory(program, (num_instructions + 1) * BYTES_PER_WORD);
    }
  }

  return 0;
}
コード例 #12
0
      void operator()(LinPdeSysT const & pde_system,
                      SegmentT   const & segment,
                      StorageType      & storage,
                      MatrixT          & system_matrix,
                      VectorT          & load_vector)
      {
        typedef viennamath::equation                          equ_type;
        typedef viennamath::expr                              expr_type;
        typedef typename expr_type::interface_type            interface_type;
        typedef typename expr_type::numeric_type              numeric_type;

        typedef typename viennagrid::result_of::cell_tag<SegmentT>::type CellTag;

        std::size_t map_index = viennafvm::create_mapping(pde_system, segment, storage);

        system_matrix.clear();
        system_matrix.resize(map_index, map_index, false);
        load_vector.clear();
        load_vector.resize(map_index);


        for (std::size_t pde_index = 0; pde_index < pde_system.size(); ++pde_index)
        {
#ifdef VIENNAFVM_DEBUG
          std::cout << std::endl;
          std::cout << "//" << std::endl;
          std::cout << "//   Equation " << pde_index << std::endl;
          std::cout << "//" << std::endl;
#endif
          assemble(pde_system, pde_index,
                   segment, storage,
                   system_matrix, load_vector);

        } // for pde_index
      } // functor
コード例 #13
0
ファイル: op.cpp プロジェクト: retrage/TK-80
int main(int argc, char *argv[]) {

    if(argc!=2) {
        std::cout << "No input file." << std::endl;
        return 0;
    }
    
    std::ifstream ifs;
    ifs.open(argv[1], std::ifstream::in);
    
    std::vector<codeinfo> vec = code2vec(ifs);

    std::string str;

    while(ifs.good()) {
        std::getline(ifs, str);
        if(str.size()) {
            codeinfo res = assemble(parse(str, ' '));
            switch(res.optype) {
                case origin:
                    start_addr = res.bin;
                    break;
                case opcode:
                    program_len += res.len;

                case label:

            }
        }
    }
コード例 #14
0
void elasticitySolver::solve()
{

  //linearSystemFull<double> *lsys = new linearSystemFull<double>;

#if defined(HAVE_TAUCS)
  linearSystemCSRTaucs<double> *lsys = new linearSystemCSRTaucs<double>;
#elif defined(HAVE_PETSC)
  linearSystemPETSc<double> *lsys = new linearSystemPETSc<double>;
#else
  linearSystemGmm<double> *lsys = new linearSystemGmm<double>;
  lsys->setNoisy(2);
#endif

  assemble(lsys);
  lsys->systemSolve();
  printf("-- done solving!\n");
  GaussQuadrature Integ_Bulk(GaussQuadrature::GradGrad);

//   printLinearSystem(lsys);

  double energ=0;
  for (unsigned int i = 0; i < elasticFields.size(); i++)
  {
    SolverField<SVector3> Field(pAssembler, LagSpace);
    IsotropicElasticTerm Eterm(Field,elasticFields[i]._E,elasticFields[i]._nu);
    BilinearTermToScalarTerm Elastic_Energy_Term(Eterm);
    Assemble(Elastic_Energy_Term,elasticFields[i].g->begin(),elasticFields[i].g->end(),
             Integ_Bulk,energ);
  }
  printf("elastic energy=%f\n",energ);
}
コード例 #15
0
static PyObject *
py_assemble(PyObject *self, PyObject *args)
{
	int (*assemble)(char **out, size_t *outlen, const char *in) = NULL;
	int result = 0;
	char *assembly = NULL;
	char *executable = NULL;
	size_t length = 0;

	if (!PyArg_ParseTuple(args, "s", &assembly))
		return NULL;

	assemble = dlsym(external_library, "assemble"); 

	if (assemble == NULL) {
		PyErr_Clear();
		PyErr_SetString(PyExc_NameError, FUNCTION_ERROR_MSG);
		dlclose(external_library);
		return NULL;
	}

	result = assemble(&executable, &length, (const char *) assembly);

	if (result != 0) {
		handle_assemble_error(result);
		dlclose(external_library);
		return NULL;
	}
	
    dlclose(external_library);
	return PyString_FromStringAndSize(executable, length);
}
コード例 #16
0
ファイル: fd2_program.c プロジェクト: Haifen/Mesa-3D
/* Creates shader:
 *    EXEC ADDR(0x2) CNT(0x1)
 *       (S)FETCH:	SAMPLE	R0.xyzw = R0.xyx CONST(0) LOCATION(CENTER)
 *    ALLOC PARAM/PIXEL SIZE(0x0)
 *    EXEC_END ADDR(0x3) CNT(0x1)
 *          ALU:	MAXv	export0 = R0, R0	; gl_FragColor
 *    NOP
 */
static struct fd2_shader_stateobj *
create_blit_fp(void)
{
	struct fd2_shader_stateobj *so = create_shader(SHADER_FRAGMENT);
	struct ir2_cf *cf;
	struct ir2_instruction *instr;

	if (!so)
		return NULL;

	so->ir = ir2_shader_create();

	cf = ir2_cf_create(so->ir, EXEC);

	instr = ir2_instr_create_tex_fetch(cf, 0);
	ir2_reg_create(instr, 0, "xyzw", 0);
	ir2_reg_create(instr, 0, "xyx", 0);
	instr->sync = true;

	cf = ir2_cf_create_alloc(so->ir, SQ_PARAMETER_PIXEL, 0);
	cf = ir2_cf_create(so->ir, EXEC_END);

	instr = ir2_instr_create_alu(cf, MAXv, ~0);
	ir2_reg_create(instr, 0, NULL, IR2_REG_EXPORT);
	ir2_reg_create(instr, 0, NULL, 0);
	ir2_reg_create(instr, 0, NULL, 0);

	return assemble(so);
}
コード例 #17
0
arma::Mat<ResultType>
ElementaryPotentialOperator<BasisFunctionType, KernelType, ResultType>::
    evaluateAtPoints(
        const GridFunction<BasisFunctionType, ResultType> &argument,
        const arma::Mat<CoordinateType> &evaluationPoints,
        const QuadratureStrategy &quadStrategy,
        const EvaluationOptions &options) const {
  if (evaluationPoints.n_rows != argument.grid()->dimWorld())
    throw std::invalid_argument(
        "ElementaryPotentialOperator::evaluateAtPoints(): "
        "the number of coordinates of each evaluation point must be "
        "equal to the dimension of the space containing the surface "
        "on which the grid function 'argument' is defined");

  if (options.evaluationMode() == EvaluationOptions::DENSE) {
    std::unique_ptr<Evaluator> evaluator =
        makeEvaluator(argument, quadStrategy, options);

    // right now we don't bother about far and near field
    // (this might depend on evaluation options)
    arma::Mat<ResultType> result;
    evaluator->evaluate(Evaluator::FAR_FIELD, evaluationPoints, result);
    return result;
  } else if (options.evaluationMode() == EvaluationOptions::ACA) {
    AssembledPotentialOperator<BasisFunctionType, ResultType> assembledOp =
        assemble(argument.space(), make_shared_from_ref(evaluationPoints),
                 quadStrategy, options);
    return assembledOp.apply(argument);
  } else
    throw std::invalid_argument(
        "ElementaryPotentialOperator::evaluateAtPoints(): "
        "Invalid evaluation mode");
}
コード例 #18
0
ファイル: public12.c プロジェクト: Foshie/Classes
int main() {
  Mem mem[SZ]= {0};
  short registers[NUM_REGISTERS]= {0};
  short exp_registers[NUM_REGISTERS]= {0, 3, 5, 9, 14, 4, 0xfe, 0xa};
  int num_instructions;
  Status ret;

  num_instructions= assemble("public12.a", &mem[10]);

  if (num_instructions == 0)
    printf("Regretfully the program couldn't be assembled.  Bye.\n");
  else {

    ret= execute_program(mem, registers, 20, num_instructions, 0);

    if (ret != TERMINATED)
      printf("execute_program() returned unexpected value (%d).\n", ret);
    else

      if ((ret= compare_registers(registers, exp_registers, 0, 8)) != -1) {

        printf("Registers appear incorrect after execute_program() call.\n");
        printf("First incorrect register is %d (%d instead of %d).\n",
               ret, registers[ret], exp_registers[ret]);

      } else printf("Registers are correct after execute_program() call!\n");

  }

  return 0;
}
コード例 #19
0
ファイル: main.c プロジェクト: JustinLardinois/basm
int main(int argc , char** argv)
{
	setbuf(stdout,0);
	program_name = argv[0];
	parse_args(argc,argv);
	FILE* in = fopen(input,"r");
	if(in == NULL) die(input);
	
	
	FILE* out = fopen(output,"wb");
	// I had what was quite possibly the worst bug ever in this line.
	// Apparently, "w" is not sufficient on non-Unix C89 implementations
	// if you're writing binary data. You may wonder if people still use
	// such archaic systems. I do; it's called Windows 8.1.
	//
	// My problem was that if the hex byte 0A was fwritten (which is PUSH #10
	// in BASIL assembly) the byte 0D was written after it. After a lot of pain
	// and tears, I discovered that since 0A is a line feed (\n), a carriage
	// return (\r), which 0D represents, was being written after it. I solved
	// the bug by using "wb" instead of "w", which writes literal bytes.
	
	if(out == NULL) die(output);
	assemble(in,out);
	fclose(in);
	fclose(out);
	exit(EXIT_SUCCESS);
}
コード例 #20
0
ファイル: data_test.c プロジェクト: mikeakohn/naken_asm
void test_float(const char *source, float *answer, int length, int endian)
{
  struct _asm_context asm_context = { 0 };
  int oops = 0;
  int i;

  printf("Testing: %s (%s) ... ", source, endian == LITTLE ? "little":"big");

  tokens_open_buffer(&asm_context, source);
  tokens_reset(&asm_context);

  if (endian == BIG)
  {
    asm_context.memory.endian = 1;
  }

  assemble(&asm_context);

  uint32_t f = 0;

  for (i = 0; i < length * 4; i++)
  {
    if ((i % 4) == 0) { f = 0; }

    // printf("%d) %02x\n", i, memory_read_m(&asm_context.memory, i));
    if (endian == LITTLE)
    {
      f = (f >> 8) | (memory_read_m(&asm_context.memory, i) << 24);
    }
      else
    {
コード例 #21
0
		void environment::spawn_player(point2 location)
		{
			// player props
			auto weapon = std::make_shared<body_component::item_type>();
			weapon->add({ rl::effect::weapon_damage, 0x00, 50 });
			weapon->add({ rl::effect::equipment, static_cast<unsigned int>(rl::equipment_slot::hand_main) });
			weapon->set_name("Copper Sword");
			weapon->set_tag("copper_sword");

			// make player
			auto task = m_factory->produce();
			auto img = task->add_appearance('@', { 1, 1, 1 });
			auto pawn = task->add_location(location);
			auto body = task->add_body(100, 100);
			auto character = task->add_character();

			// setup
			body->set_name("You");
			body->set_tag("player");
			body->join_faction(1);
			body->add(weapon);
			body->equip(weapon);

			character->add_skill("sk_bash");
			character->add_skill("sk_panacea");
			character->add_skill("sk_teleport");
			character->add_skill("sk_fireball");
			character->add_skill("sk_indigo");

			m_terrain.add(task->assemble(persistency::permanent));

			impersonate(pawn);
		}
コード例 #22
0
ファイル: main.c プロジェクト: ChecksumCharlie/CDA-Assembler
int
main(int argc, char ** argv)
{
	vector_string_t * mips_assembly;
	vector_uint_t * machine_code;

    if (argc != 3)
    {
        fprintf(
                stderr,
                "To execute this program, use the following command line call:\n"
               );
        fprintf(
                stderr,
                "\t./assembler   NAME_OF_INPUT_FILE   NAME_OF_OUTPUT_FILE\n"
               );
        exit(1);
    }

    mips_assembly = vector_string_create();
    machine_code = vector_uint_create();

	
    
    read_file(argv[1], mips_assembly);
    assemble(mips_assembly, machine_code);
    write_file(argv[2], machine_code);
    
    vector_string_destroy(mips_assembly);
    vector_uint_destroy(machine_code);
    
    return 0;
}
コード例 #23
0
ファイル: pc1dec.c プロジェクト: BASLQC/snes9xTYL
main()
{
si=0;
x1a2=0;
i=0;


/* ('abcdefghijklmnopqrstuvwxyz012345') is the default password used*/
/* if the user enter a key < 32 characters, characters of the default */
/* password will be used */

strcpy(cle,"abcdefghijklmnopqrstuvwxyz012345");

printf ("PC1 Cipher 256 bits \nDECRYPT file OUT.BIN to IN.BIN\n");
printf("Enter a 32 chars password:"******"out.bin","rb")) == NULL) {printf("\nError reading file OUT.BIN !\n");fin();}
if ((out=fopen("in.bin","wb")) == NULL) {printf("\nError writing file IN.BIN !\n");fin();}

/* the decrypted file is in IN.BIN */

while ( (c=fgetc(in)) != EOF) /* c contains the byte read in the file */
{
assemble();
cfc=inter>>8;
cfd=inter&255; /* cfc^cfd = random byte */

/* K ZONE !!!!!!!!!!!!! */
/* here the mix of c and cle[compte] is after the decryption of c */

c = c ^ (cfc^cfd);

for (compte=0;compte<=31;compte++)
{
/* we mix the plaintext byte with the key */
cle[compte]=cle[compte]^c;
}

fputc(c,out); /* we write the decrypted byte in the file IN.BIN */
}
fclose (in);
fclose (out);
fin();
return(0);
}
コード例 #24
0
ファイル: Boonas.cpp プロジェクト: fuag15/boonas_modeler
Boonas::Boonas(int argc, char** argv)
{
	cursor = 0;
	orig = new LNHHolder();
	temp = 0;
	colorValue = 0;
	Transformation matrix;
	
	if(argc < 3)
	{
		return;
	}
	if(strcmp(argv[1], "polygon") == 0) // DONE
	{
		polygon(argc, argv); // default the color to a grey, or a blue
	}
	else if(strcmp(argv[1], "polygonC") == 0)
	{
		polygonC(argc, argv);
	}
	else if(strcmp(argv[1], "assemble") == 0) // DONE
	{
		assemble(argc, argv);
	}
	else if(strcmp(argv[1], "transform") == 0) //WORKS
	{
		loadFile(argv[2]); // loads the data into a LNHHolder 
		matrix = parseParams(3, argc, argv, matrix); 
		doMult(matrix); // applies the matrix transformation
		writeFile(argv[2]); // writes file;
	}
	else if(strcmp(argv[1], "create") == 0) // WORKS
	{
		loadFile(argv[3]);
		matrix = parseParams(4, argc, argv, matrix);
		doMult(matrix);
		writeFile(argv[2]);
	}
	else if(strcmp(argv[1], "extrude") == 0) // WORKS
	{
		loadFile(argv[2]);
		doExtrude(argv[4], argv[3]); // extrudes argv 3 distance
	}
	else if(strcmp(argv[1], "clip") == 0) // clip, file, inpolies, outpolies, normalx normaly normalz, pointx, pointy, pointz
	{
		loadFile(argv[2]);
		//doClip(argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]);
		doClip(argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9]);
	}
	else if(strcmp(argv[1], "rot") == 0) // rot infile outfile vectorx, y, z pointx, y, z, divisions, degrees
	{
		loadFile(argv[2]);
		doRotate(argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11]);
		writeFile(argv[3]);
	}
	return;
}
コード例 #25
0
ファイル: assemble.cpp プロジェクト: nathanhaigh/sga
//
// Main
//
int assembleMain(int argc, char** argv)
{
    Timer* pTimer = new Timer("sga assemble");
    parseAssembleOptions(argc, argv);
    assemble();
    delete pTimer;

    return 0;
}
コード例 #26
0
ファイル: SIC.c プロジェクト: elifah93/Systems-Programming
/* Get the command, and performes a function,
if the command is exit return 1 otherwise 0*/
int command(char line[], char ** args)
{
	int i;
	for (i=0; i<4; i++)
	{
		strncpy(args[i],"",strlen(args[i])); //Set an empty string to each argument.
	}

	printf("Command> "); // Ask for a command.

	fgets(line,99,stdin);	// Gets the line that the user typed as a command.
	int lineSize=strlen(line)-1;	// Gets the size of the line.

	char ** comm=breakCommand(line,lineSize,args);	// Gets each argument from the line.

	int len=strlen(comm[0]);	// Gets the size of the command.

	if(len==0)	/* If the command is empty, asks again for a command */
	{
		return 0;
	}
	/* Since SIC can recognize abbreviated commands, 
	I set it that a command should be at least 3 or more characters. */
	else if(len < 3)
	{
		printf("Cannot recognize any command. "
			"Need at least three characters.\n\n");
	}
	/* Performe the given command if the programm recognizes it.
	If not it will prompt and error message. 
	Also it command checks for the prescence and abscence. 
	Compares up to the length of the given command with the list of valids commands in SIC. 
	So it will recognize the first few characters of the command.*/
	else
	{
		if(strncmp(comm[0],"help",len)==0)
			{help(comm[1]);}
		else if(strncmp(comm[0],"directory",len)==0)
			{directory(comm[1]);}
		else if (strncmp(comm[0],"load",len)==0)
			{load(comm[1],comm[2]);}
		else if(strncmp(comm[0],"dump",len)==0)
			{dump(comm[1],comm[2],comm[3]);}
		else if (strncmp(comm[0],"assemble",len)==0)
			{assemble(comm[1],comm[2]);}
		else if (strncmp(comm[0],"executes",len)==0)
			{executes(comm[1]);}
		else if (strncmp(comm[0],"debug",len)==0)
			{debug(comm[1]);}
		else if(strncmp(comm[0],"exit",len)==0)
			{return 1;}
		else
			{noComm();}
	}    

	return 0;
}
コード例 #27
0
int main()
{
  typedef viennagrid::tetrahedral_3d_mesh MeshType;
  typedef viennagrid::tetrahedral_3d_segmentation SegmentationType;

//   typedef viennagrid::triangular_2d_mesh                      MeshType;        //use this for a 2d example
//   typedef viennagrid::triangular_2d_segmentation                SegmentationType;  //use this for a 2d example

  std::cout << "----------------------------------------------------------" << std::endl;
  std::cout << "-- ViennaGrid tutorial: Finite Volumes using ViennaGrid --" << std::endl;
  std::cout << "----------------------------------------------------------" << std::endl;
  std::cout << std::endl;

  MeshType mesh;
  SegmentationType segmentation(mesh);

  viennagrid::io::netgen_reader reader;
  #ifdef _MSC_VER      //Visual Studio builds in a subfolder
  std::string path = "../../examples/data/";
  #else
  std::string path = "../../examples/data/";
  #endif
  reader(mesh, segmentation, path + "cube48.mesh"); //use this for a 3d example
//   reader(mesh, segmentation, path + "square32.mesh"); //use this for a 2d example

  sparse_matrix<double> system_matrix;
  std::vector<double> load_vector;

  assemble(mesh, system_matrix, load_vector);

  //
  // Next step: Solve here using a linear algebra library, e.g. ViennaCL. (not included in this tutorial to avoid external dependencies)
  // Instead, we print the matrix
  std::cout << std::endl << "System matrix: " << std::endl;
  for (std::size_t i=0; i<load_vector.size(); ++i)
  {
    std::cout << "Row " << i << ": ";
    for (std::size_t j=0; j<load_vector.size(); ++j)
    {
      if (system_matrix(i,j) != 0)
        std::cout << "(" << j << ", " << system_matrix(i,j) << "), ";
    }
    std::cout << std::endl;
  }

  std::cout << std::endl << "Load vector: " << std::endl;
  for (std::size_t i=0; i<load_vector.size(); ++i)
    std::cout << load_vector[i] << " " << std::endl;
  std::cout << std::endl;

  std::cout << "-----------------------------------------------" << std::endl;
  std::cout << " \\o/    Tutorial finished successfully!    \\o/ " << std::endl;
  std::cout << "-----------------------------------------------" << std::endl;

  return EXIT_SUCCESS;
}
コード例 #28
0
ファイル: lex.c プロジェクト: hfeeki/go
void
main(int argc, char *argv[])
{
	char *p;
	int c;

	thechar = '5';
	thestring = "arm";

	ensuresymb(NSYMB);
	memset(debug, 0, sizeof(debug));
	cinit();
	outfile = 0;
	setinclude(".");
	ARGBEGIN {
	default:
		c = ARGC();
		if(c >= 0 || c < sizeof(debug))
			debug[c] = 1;
		break;

	case 'o':
		outfile = ARGF();
		break;

	case 'D':
		p = ARGF();
		if(p) {
			if (nDlist%8 == 0) 
				Dlist = allocn(Dlist, nDlist*sizeof(char *), 
					8*sizeof(char *));
			Dlist[nDlist++] = p;
		}
		break;

	case 'I':
		p = ARGF();
		setinclude(p);
		break;
	case 't':
		thechar = 't';
		thestring = "thumb";
		break;
	} ARGEND
	if(*argv == 0) {
		print("usage: %ca [-options] file.s\n", thechar);
		errorexit();
	}
	if(argc > 1){
		print("can't assemble multiple files\n");
		errorexit();
	}
	if(assemble(argv[0]))
		errorexit();
	exits(0);
}
コード例 #29
0
ファイル: Assembler.c プロジェクト: MineC0w/Assembler
int main(int argc, char *argv[])
{
	int i;
	for (i = 1; i < argc; ++i)
	{
		assemble(argv[i]);
	}

	return 0;
}
コード例 #30
0
ファイル: main.c プロジェクト: iliankostov/C
int main(int argc, char** argv) {

    slice("source.png", "", PARTS);

    const char *parts[] = {"Part-1.png", "Part-2.png", "Part-3.png", "Part-4.png", "Part-5.png"};

    assemble(parts, "destination.png");

    return (EXIT_SUCCESS);
}