JVM test

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
lynxeyed_atsu
Date:
Sat Sep 07 04:59:10 2013 +0000
Parent:
8:d9e205196dfc
Commit message:
added if_icmp* mnemonics

Changed in this revision

device_depend.cpp Show annotated file Show diff for this revision Revisions of this file
pool.h Show annotated file Show diff for this revision Revisions of this file
ravem.cpp Show annotated file Show diff for this revision Revisions of this file
ravem.h Show annotated file Show diff for this revision Revisions of this file
diff -r d9e205196dfc -r 4ea7773ea2b0 device_depend.cpp
--- a/device_depend.cpp	Thu Aug 29 14:15:47 2013 +0000
+++ b/device_depend.cpp	Sat Sep 07 04:59:10 2013 +0000
@@ -2,7 +2,7 @@
 #include <string.h>
 #include "device_depend.h"
 
-#define bc_str_length 1024 // from 32 to 1024
+#define bc_str_length 2048 // from 32 to 1024
 
 BusInOut ledport(LED1, LED2, LED3, LED4);
 Serial pc(USBTX, USBRX); // tx, rx
diff -r d9e205196dfc -r 4ea7773ea2b0 pool.h
--- a/pool.h	Thu Aug 29 14:15:47 2013 +0000
+++ b/pool.h	Sat Sep 07 04:59:10 2013 +0000
@@ -16,7 +16,7 @@
 
 #define memory_available    1
 #define memory_invalid      0
-#define pool_size           256 // 256 * (sizeof(int)) = 1kByte
+#define pool_size           512 // 256 * (sizeof(int)) = 1kByte
 #define magic_value         0xDEADDEAD
 //#define USE_MAGIC
 
diff -r d9e205196dfc -r 4ea7773ea2b0 ravem.cpp
--- a/ravem.cpp	Thu Aug 29 14:15:47 2013 +0000
+++ b/ravem.cpp	Sat Sep 07 04:59:10 2013 +0000
@@ -637,6 +637,11 @@
 				setIntegerToStack(cl,getIntegerFromOperandStack(cl) + getIntegerFromOperandStack(cl));
 				break;
 
+			case JAVA_iinc:
+				cl.local_reg[*bc_seek(now_code + 1, 1)] = cl.local_reg[*bc_seek(now_code + 1, 1)] + (int8_t)(*bc_seek(now_code + 2, 1));
+				now_code = now_code + 3;
+				break;
+
 			case JAVA_getstatic:
 				now_code = now_code + 3;
 				break;
@@ -645,6 +650,7 @@
 				cl = getField(cl,(*bc_seek(now_code + 1, 1) << 8) + *bc_seek(now_code + 2, 1));
 				now_code = now_code + 3;
 				break;
+			
 			case JAVA_putfield:
 				cl = putField(cl,(*bc_seek(now_code + 1, 1) << 8) + *bc_seek(now_code + 2, 1));
 				now_code = now_code + 3;
@@ -660,6 +666,42 @@
 				cl = changeStackType(cl, Stack_CharType);	
 				break;
 			
+			case JAVA_if_icmplt:
+				if(getIntegerFromOperandStack(cl) > getIntegerFromOperandStack(cl)){
+					now_code = now_code +(int16_t)((*bc_seek(now_code + 1, 1) << 8) + *bc_seek(now_code + 2, 1)); // goto
+					break;
+				}else{
+					now_code = now_code + 3;
+ 				}
+				break;
+			
+			case JAVA_if_icmpge:
+				if(getIntegerFromOperandStack(cl) <= getIntegerFromOperandStack(cl)){
+					now_code = now_code +(int16_t)((*bc_seek(now_code + 1, 1) << 8) + *bc_seek(now_code + 2, 1)); // goto
+					break;
+				}else{
+					now_code = now_code + 3;
+ 				}				
+				break;
+				
+			case JAVA_if_icmpgt:
+				if(getIntegerFromOperandStack(cl) < getIntegerFromOperandStack(cl)){
+					now_code = now_code +(int16_t)((*bc_seek(now_code + 1, 1) << 8) + *bc_seek(now_code + 2, 1)); // goto
+					break;
+				}else{
+					now_code = now_code + 3;
+ 				}
+				break;
+			
+			case JAVA_if_icmple:
+				if(getIntegerFromOperandStack(cl) >= getIntegerFromOperandStack(cl)){
+					now_code = now_code +(int16_t)((*bc_seek(now_code + 1, 1) << 8) + *bc_seek(now_code + 2, 1)); // goto
+					break;
+				}else{
+					now_code = now_code + 3;
+ 				}
+				break;
+								
 			case JAVA_goto:
 				now_code = now_code +(int16_t)((*bc_seek(now_code + 1, 1) << 8) + *bc_seek(now_code + 2, 1));
 				break;
@@ -707,6 +749,7 @@
 	return cl;
 }
 
+
 class_st invokespecial_callFunction(class_st cl, int cp_num){
 
 	char* func_name = (char *)seekNameAndType_name(cp_num).stack_pt;
diff -r d9e205196dfc -r 4ea7773ea2b0 ravem.h
--- a/ravem.h	Thu Aug 29 14:15:47 2013 +0000
+++ b/ravem.h	Sat Sep 07 04:59:10 2013 +0000
@@ -47,61 +47,68 @@
 #define Thread_initIsDone					6	
 #define	Thread_inSleep						7
 
-// instruction code					mnemonic code		number of arguments
-#define JAVA_nop					0x00					// 0
-#define JAVA_iconst_0				0x03					// 0
-#define JAVA_iconst_1				0x04					// 0
-#define JAVA_iconst_2				0x05					// 0
-#define JAVA_iconst_3				0x06					// 0
-#define JAVA_iconst_4				0x07					// 0
-#define JAVA_iconst_5				0x08					// 0
-#define JAVA_bipush					0x10					// 1
-#define JAVA_sipush					0x11					// 2
-#define JAVA_ldc					0x12					// 1
-//#define JAVA_ldc_w				0x13					// xxx
-#define JAVA_ldc2_w					0x14					// 2
+// instruction code			mnemonic code		number of arguments(in bytes)
+#define JAVA_nop							0x00					// 0
+#define JAVA_iconst_0						0x03					// 0
+#define JAVA_iconst_1						0x04					// 0
+#define JAVA_iconst_2						0x05					// 0
+#define JAVA_iconst_3						0x06					// 0
+#define JAVA_iconst_4						0x07					// 0
+#define JAVA_iconst_5						0x08					// 0
+#define JAVA_bipush							0x10					// 1
+#define JAVA_sipush							0x11					// 2
+#define JAVA_ldc							0x12					// 1
+//#define JAVA_ldc_w						0x13					// xxx
+#define JAVA_ldc2_w							0x14					// 2
+//#define JAVA_iload						0x15
 
-#define JAVA_aload					0x19					// 1
+#define JAVA_aload							0x19					// 1
 
-#define JAVA_iload_0				0x1A					// 0
-#define JAVA_iload_1				0x1B					// 0
-#define JAVA_iload_2				0x1C					// 0
-#define JAVA_iload_3				0x1D					// 0
+#define JAVA_iload_0						0x1A					// 0
+#define JAVA_iload_1						0x1B					// 0
+#define JAVA_iload_2						0x1C					// 0
+#define JAVA_iload_3						0x1D					// 0
 
-#define JAVA_aload_0				0x2a					// 0
-#define JAVA_aload_1				0x2b					// 0
-#define JAVA_aload_2				0x2c					// 0
-#define JAVA_aload_3				0x2d					// 0
+#define JAVA_aload_0						0x2a					// 0
+#define JAVA_aload_1						0x2b					// 0
+#define JAVA_aload_2						0x2c					// 0
+#define JAVA_aload_3						0x2d					// 0
 
-#define JAVA_astore					0x3A					// 1
+#define JAVA_astore							0x3A					// 1
 
-#define JAVA_istore_0				0x3B					// 0
-#define JAVA_istore_1				0x3C					// 0
-#define JAVA_istore_2				0x3D					// 0
-#define JAVA_istore_3				0x3E					// 0
+#define JAVA_istore_0						0x3B					// 0
+#define JAVA_istore_1						0x3C					// 0
+#define JAVA_istore_2						0x3D					// 0
+#define JAVA_istore_3						0x3E					// 0
 
-#define JAVA_astore_0				0x4b					// 0
-#define JAVA_astore_1				0x4c					// 0
-#define JAVA_astore_2				0x4d					// 0
-#define JAVA_astore_3				0x4e					// 0
+#define JAVA_astore_0						0x4b					// 0
+#define JAVA_astore_1						0x4c					// 0
+#define JAVA_astore_2						0x4d					// 0
+#define JAVA_astore_3						0x4e					// 0
 
-#define	JAVA_dup					0x59					// 0
+#define	JAVA_dup							0x59					// 0
 
-#define JAVA_iadd					0x60					// 0
+#define JAVA_iadd							0x60					// 0
 
-#define JAVA_i2l					0x85					// 0
-#define JAVA_i2c					0x92					// 0
+#define JAVA_iinc							0x84					// 2
+#define JAVA_i2l							0x85					// 0
+#define JAVA_i2c							0x92					// 0
+
+#define JAVA_if_icmplt						0xa1					// 2
+#define JAVA_if_icmpge						0xa2					// 2
+#define JAVA_if_icmpgt						0xa3					// 2
+#define JAVA_if_icmple						0xa4					// 2
 
-#define JAVA_goto					0xa7					// 2
-#define JAVA_return					0xb1					// 0
-#define JAVA_getstatic				0xb2					// 2
-#define JAVA_getfield				0xb4					// 2
-#define JAVA_putfield				0xb5					// 2
-#define JAVA_invokevirtual			0xb6					// 2
-#define JAVA_invokespecial			0xb7					// 2  //not imprement
-#define JAVA_invokestatic			0xb8					// 2
+#define JAVA_goto							0xa7					// 2
+#define JAVA_return							0xb1					// 0
+#define JAVA_getstatic						0xb2					// 2
+#define JAVA_getfield						0xb4					// 2
+#define JAVA_putfield						0xb5					// 2
+#define JAVA_invokevirtual					0xb6					// 2
+#define JAVA_invokespecial					0xb7					// 2 
+#define JAVA_invokestatic					0xb8					// 2
 
-#define JAVA_new					0xbb					// 2
+#define JAVA_new							0xbb					// 2
 
 typedef struct {
 	int		tag;