#ifndef _RTYPES_H_
#define _RTYPES_H_
-/*
- * Common types. These types should be the same for most of the architectures.
- */
-typedef long rlong;
-typedef int rint;
-typedef short rshort;
-typedef char rchar;
-typedef unsigned long rulong;
-typedef unsigned int ruint;
-typedef unsigned short rushort;
-typedef unsigned char ruchar;
-typedef double rdouble;
-typedef float rfloat;
-typedef rint rboolean;
-typedef void *rpointer;
-typedef const void *rconstpointer;
-
/*
* Architecture dependent types. These types have to be redifined
* for every architecture
typedef signed long rssize_t;
typedef unsigned int ratomic_t;
+
+/*
+ * Common types. These types should be the same for most of the architectures.
+ */
+typedef long rlong;
+typedef int rint;
+typedef short rshort;
+typedef char rchar;
+typedef unsigned long rulong;
+typedef unsigned int ruint;
+typedef unsigned short rushort;
+typedef unsigned char ruchar;
+typedef double rdouble;
+typedef float rfloat;
+typedef rint rboolean;
+typedef void *rpointer;
+typedef const void *rconstpointer;
+typedef struct {ruint32 p1; ruint32 p2;} rpair;
+
/*
* Atomic operations (Architecture Dependent)
*/
if (pi->type == RVM_DTYPE_DOUBLE) {
RVM_REG_SETD(regda, pi->data.d);
} else {
- RVM_REG_SETU(regda, pi->data.u);
+ RVM_REG_SETU64(regda, pi->data.u);
}
RVM_REG_SETTYPE(regda, pi->type);
RVM_REG_ASSIGNFLAGS(regda, (pi->type >= RVM_DTYPE_STRING) ? RVM_INFOBIT_ROBJECT : 0);
struct rvm_asmins_s {
union {
- rword u;
+ ruint64 u;
rdouble d;
+ rpair p;
} data;
ruint16 op1:RVM_OPERAND_BITS;
ruint16 op2:RVM_OPERAND_BITS;
#define RVM_CPUREG_CLRFLAG(__cpu__, __r__, __flag__) RVM_REG_CLRFLAG(RVM_CPUREG_PTR(__cpu__, __r__), __flag__)
#define RVM_CPUREG_ASSIGNFLAGS(__cpu__, __r__, __flags__) RVM_REG_ASSIGNFLAGS(RVM_CPUREG_PTR(__cpu__, __r__), __flags__)
+
#define RVM_REG_GETU(__r__) (__r__)->v.w
#define RVM_REG_SETU(__r__, __val__) do { (__r__)->v.w = (rword)(__val__); } while (0)
#define RVM_CPUREG_GETU(__cpu__, __r__) RVM_CPUREG_PTR(__cpu__, __r__)->v.w
#define RVM_CPUREG_GETD(__cpu__, __r__) RVM_CPUREG_PTR(__cpu__, __r__)->v.d
#define RVM_CPUREG_SETD(__cpu__, __r__, __val__) RVM_REG_SETD(RVM_CPUREG_PTR(__cpu__, __r__), __val__)
+#define RVM_REG_GETU64(__r__) (__r__)->v.u64
+#define RVM_REG_SETU64(__r__, __val__) do { (__r__)->v.u64 = (ruint64)(__val__); } while (0)
+#define RVM_CPUREG_GETU64(__cpu__, __r__) RVM_CPUREG_PTR(__cpu__, __r__)->v.u64
+#define RVM_CPUREG_SETU64(__cpu__, __r__, __val__) RVM_REG_SETU64(RVM_CPUREG_PTR(__cpu__, __r__), __val__)
+
+#define RVM_REG_GETPAIR(__r__) (__r__)->v.pair
+#define RVM_REG_SETPAIR(__r__, __val__) do { (__r__)->v.pair = (ruint64)(__val__); } while (0)
+#define RVM_CPUREG_GETPAIR(__cpu__, __r__) RVM_CPUREG_PTR(__cpu__, __r__)->v.pair
+#define RVM_CPUREG_SETPAIR(__cpu__, __r__, __val__) RVM_REG_SETPAIR(RVM_CPUREG_PTR(__cpu__, __r__), __val__)
+
+
#define RVM_REG_GETIP(__r__) (rvm_asmins_t*)((__r__)->v.p)
#define RVM_REG_SETIP(__r__, __val__) do { (__r__)->v.p = (rpointer)(__val__); } while (0)
#define RVM_REG_INCIP(__r__, __val__) do {rvm_asmins_t *p = RVM_REG_GETIP(__r__); (__r__)->v.p = (rpointer)(p + (__val__)); } while (0)
typedef struct rvmreg_s {
union {
+ ruint64 u64;
+ rpair pair;
rword w;
rlong l;
rpointer p;
rvm_cpu_addswitable(vm, common_calltable);
- vmcode[off++] = rvm_asm(RVM_MOV, R0, DA, XX, 1);
- vmcode[off++] = rvm_asmp(RVM_LDRR, R1, DA, XX, &d1s);
- vmcode[off++] = rvm_asm(RVM_EADD, R0, R0, R1, 0);
- VMTEST_REGD(vmcode, off, 0, 3.0, "1: EADD");
- VMTEST_STATUS(vmcode, off, 0, "1: EADD STATUS");
- vmcode[off++] = rvm_asm(RVM_PRN, R0, XX, XX, 0);
- vmcode[off++] = rvm_asm(RVM_PRN, R1, XX, XX, 0);
-
-
- vmcode[off++] = rvm_asm(RVM_MOV, R0, DA, XX, 1);
- vmcode[off++] = rvm_asmp(RVM_LDRR, R1, DA, XX, &d1s);
- vmcode[off++] = rvm_asm(RVM_EADD, R0, R1, R0, 0);
- VMTEST_REGP(vmcode, off, 0, &d2, "2: EADD");
- VMTEST_STATUS(vmcode, off, 0, "2: EADD STATUS");
vmcode[off++] = rvm_asm(RVM_MOV, R0, DA, XX, 1);
vmcode[off++] = rvm_asm(RVM_MOV, R1, DA, XX, 2);
vmcode[off++] = rvm_asm(RVM_MOV, R0, DA, XX, 1);
vmcode[off++] = rvm_asmd(RVM_MOV, R1, DA, XX, 2.0);
-// vmcode[off++] = rvm_asm(RVM_SETTYPE, R1, DA, XX, RVM_DTYPE_DOUBLE);
vmcode[off++] = rvm_asm(RVM_EADD, R0, R1, R0, 0);
vmcode[off++] = rvm_asm(RVM_PRN, R0, XX, XX, 0);
ruint off = 0;
rvmreg_t d1 = rvm_reg_create_double(1.0);
rvmreg_t d1s = rvm_reg_create_string_ansi("2.0");
- rvmreg_t d2 = rvm_reg_create_double(3.0);
-
rvm_asmins_t vmcode[256];
rvmcpu_t *vm = rvm_cpu_create_default();
rvm_cpu_addswitable(vm, common_calltable);
- vmcode[off++] = rvm_asm(RVM_MOV, R0, DA, XX, 1);
- vmcode[off++] = rvm_asmp(RVM_LDRR, R1, DA, XX, &d1s);
- vmcode[off++] = rvm_asm(RVM_EADD, R0, R0, R1, 0);
- VMTEST_REGP(vmcode, off, 0, &d2, "ADD");
- VMTEST_STATUS(vmcode, off, 0, "ADD STATUS");
- vmcode[off++] = rvm_asm(RVM_PRN, R0, XX, XX, 0);
- vmcode[off++] = rvm_asm(RVM_PRN, R1, XX, XX, 0);
-
vmcode[off++] = rvm_asm(RVM_MOV, R0, DA, XX, 8);
vmcode[off++] = rvm_asm(RVM_MOV, R1, DA, XX, 1);
vmcode[off++] = rvm_asm(RVM_ELSL, R2, R0, R1, 0);
#include "rvmcpu.h"
#include <stdio.h>
-#define EXECDEBUG 1
-#define VMTEST_CHECK_REG 0
-#define VMTEST_CHECK_STATUS 1
+//#define EXECDEBUG 1
+
#define VMTEST_REG(code, index, reg, val, msg) \
do { code[index++] = rvm_asm(RVM_MOV, R8, DA, XX, reg); \