static mlval word_mod(mlval argument) { unsigned val1 = CWORD(FIELD(argument, 0)); unsigned val2 = CWORD(FIELD(argument, 1)); if (val2 == 0u) exn_raise(perv_exn_ref_div); return MLINT(val1 % val2); }
static mlval word_to_real (mlval argument) { double x = (double)(CWORD (argument)); mlval result = allocate_real (); SETREAL (result,x); return (result); }
static mlval int_to_word32(mlval argument) { unsigned item; mlval result; item = (unsigned)CWORD(argument); result = allocate_word32(); num_to_word32(item,result); return(result); }
// instruction CMP int cmp(int addr, int addrs) { int n, z, v, c; int diff; diff = *get_word_from_memory(addrs) - *get_word_from_memory(addr); VWORD(v, diff); CWORD(c, diff); NWORD(n, diff); Z(z, diff); set_flags(n, z, v, c); return 0; }
int mul(int addr, int addrs) { int n, z, c; int op; op = (*get_word_from_memory(addr)) * (*get_word_from_memory(addrs)); put_value_w(addrs, (*get_word_from_memory(addr)) * (*get_word_from_memory(addrs))); NWORD(n, op); CWORD(c, op); Z(z, op); set_flags(n, z, 0, c); return 0; }
/* this dispatchers forwards RPC calls to the destination functions */ INT rpc_dispatch(INT index, void *prpc_param[]) { INT status; switch (index) { case RPC_MYTEST: status = rpc_mytest(CBYTE(0), CWORD(1), CINT(2), CFLOAT(3), CDOUBLE(4), CPBYTE(5), CPWORD(6), CPINT(7), CPFLOAT(8), CPDOUBLE(9)); break; default: cm_msg(MERROR, "rpc_dispatch", "received unrecognized command"); } return status; }
// instruction ADD int add(int addr, int addrs) { int n, z, v, c; int op; op = *get_word_from_memory(addr) + *get_word_from_memory(addrs); put_value_w(addr, *get_word_from_memory(addr) + *get_word_from_memory(addrs)); NWORD(n, op); VWORD(v, op); CWORD(c, op); Z(z, op); set_flags(n, z, v, c); return 0; }
static mlval word_times(mlval argument) { unsigned val1 = CWORD(FIELD(argument, 0)); unsigned val2 = CWORD(FIELD(argument, 1)); return MLINT(val1 * val2); }