예제 #1
0
파일: rpn.c 프로젝트: pcpa/lightning
/* Store in R0 the result of evaluating the operator TOK with
   a register operand SRC and an immediate operand IMM.  */
void
gen_reg_imm (int src, int imm, int tok)
{
  switch (tok)
    {
    case '+': jit_addi_i (JIT_R0, src, imm); break;
    case '-': jit_subi_i (JIT_R0, src, imm); break;
    case '*': jit_muli_i (JIT_R0, src, imm); break;
    case '/': jit_divi_i (JIT_R0, src, imm); break;
    case '%': jit_modi_i (JIT_R0, src, imm); break;
    case '&': jit_andi_i (JIT_R0, src, imm); break;
    case '|': jit_ori_i (JIT_R0, src, imm); break;
    case '^': jit_xori_i (JIT_R0, src, imm); break;
    case '=': jit_eqi_i (JIT_R0, src, imm); break;
    case '<': jit_lti_i (JIT_R0, src, imm); break;
    case '>': jit_gti_i (JIT_R0, src, imm); break;
    case LE: jit_lei_i (JIT_R0, src, imm); break;
    case GE: jit_gei_i (JIT_R0, src, imm); break;
    case NE: jit_nei_i (JIT_R0, src, imm); break;
    case LSH: jit_lshi_i (JIT_R0, src, imm); break;
    case RSH: jit_rshi_i (JIT_R0, src, imm); break;
    case RSHU: jit_rshi_ui (JIT_R0, src, imm); break;
    default: abort ();
    }
}
예제 #2
0
파일: incr.C 프로젝트: pippijn/rasm
int main()
{
  pifi  myFunction= (pifi) (jit_set_ip(codeBuffer).iptr);
  int	ofs;				/* offset of the argument */

  jit_leaf(1);
  ofs = jit_arg_i();
  jit_getarg_i(JIT_R0, ofs);
  jit_addi_i(JIT_RET, JIT_R0, 1);
  jit_ret();
  jit_flush_code(codeBuffer, jit_get_ip().ptr);

  /* call the generated code, passing its size as argument */
#ifdef LIGHTNING_DISASSEMBLE
  disassemble(stderr, codeBuffer, jit_get_ip().ptr);
#endif
#ifndef LIGHTNING_CROSS
  printf("%d + 1 = %d\n", 5, myFunction(5));
#endif
  return 0;
}