[from now] Tue Dec  4 18:26:19 JST 2012

diff --git a/2nd/alu/alu.vhd b/2nd/alu/alu.vhd
index 02236da..de87fd2 100644
--- a/2nd/alu/alu.vhd
+++ b/2nd/alu/alu.vhd
@@ -60,6 +60,7 @@ architecture behave of alu is
   constant SLLI : std_logic_vector(5 downto 0) := "000110";
   constant SRAI : std_logic_vector(5 downto 0) := "000111";

+  constant SETI  : std_logic_vector(5 downto 0) := "010000";
   constant FMVLO : std_logic_vector(5 downto 0) := "010010";
   constant FMVHI : std_logic_vector(5 downto 0) := "010011";
   constant IMOVF : std_logic_vector(5 downto 0) := "010110";
diff --git a/compiler_set/assembler/encode.cpp b/compiler_set/assembler/encode.cpp
index 398ecaa..012d179 100644
--- a/compiler_set/assembler/encode.cpp
+++ b/compiler_set/assembler/encode.cpp
@@ -121,6 +121,17 @@ bool encode(char* instName, char* buffer, map<uint32_t, string>& labelNames, uin
 			return true;
 		}
 	}
+	if (eq(instName, "setl"))
+	{
+		int n = sscanf(buffer, formRL, dummy, label);
+		if (n == 3)
+		{
+			labelNames[currentLine] = string(label);
+			useLabel = true;
+			code = _setl(rs, rt, 0);
+			return true;
+		}
+	}
 	if (eq(instName, "subi"))
 	{
 		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
@@ -534,16 +545,6 @@ vector<bool> mnemonic(char* instName, char mnemonicBuffer[][MAX_LINE_SIZE], map<
 		}
 		return	useLabels;
 	}
-	if (eq(instName, "setl"))
-	{
-		if (sscanf(mnemonicBuffer[0], formRL, dummy, &rs, label) == 3)
-		{
-			labelNames[currentLine] = string(label);
-			sprintf(mnemonicBuffer[0], "addi\t$r%d, $r0, 0", rs);
-			useLabels.push_back(true);
-		}
-		return	useLabels;
-	}
 	if (eq(instName, "fliw"))
 	{
 		if (sscanf(mnemonicBuffer[0], formFD, dummy, &rs, &d) == 3)
diff --git a/compiler_set/include/common.h b/compiler_set/include/common.h
index f1615d7..3ab7e61 100644
--- a/compiler_set/include/common.h
+++ b/compiler_set/include/common.h
@@ -32,6 +32,7 @@
 #define SLLI    (0b000110)
 #define SRAI    (0b000111)

+#define FMVLO   (0b010000)
 #define FMVLO   (0b010010)
 #define FMVHI   (0b010011)
 #define IMOVF   (0b010110)
[from now] Tue Dec  4 23:34:41 JST 2012

diff --git a/2nd/alu/alu.vhd b/2nd/alu/alu.vhd
index de87fd2..290ad53 100644
--- a/2nd/alu/alu.vhd
+++ b/2nd/alu/alu.vhd
@@ -13,6 +13,7 @@ use IEEE.NUMERIC_STD.all;
 -- alias XORI 000101
 -- alias SLLI 000110
 -- alias SRAI 000111
+-- alias SETL 010000
 -- alias FMVLO 010010
 -- alias FMVHI 010011
 -- alias IMOVF 010110
@@ -33,6 +34,7 @@ use IEEE.NUMERIC_STD.all;
 -- FMVLO |131072|2 |   3 |      1 |    2 |131075|     1
 -- IMOVF |  5 |  2 |   0 |      1 |    2 |    5 |     1
 -- FMOVI |  5 |  2 |   0 |      1 |    2 |    5 |     0
+-- SETL  |  9 | 18 |   3 |      1 |    2 |    3 |     0
 -- 111111|  0 |  0 |   0 |      0 |    - |    - |     -
 -- /TEST

@@ -60,7 +62,7 @@ architecture behave of alu is
   constant SLLI : std_logic_vector(5 downto 0) := "000110";
   constant SRAI : std_logic_vector(5 downto 0) := "000111";

-  constant SETI  : std_logic_vector(5 downto 0) := "010000";
+  constant SETL  : std_logic_vector(5 downto 0) := "010000";
   constant FMVLO : std_logic_vector(5 downto 0) := "010010";
   constant FMVHI : std_logic_vector(5 downto 0) := "010011";
   constant IMOVF : std_logic_vector(5 downto 0) := "010110";
@@ -86,7 +88,7 @@ begin  -- behave
         enable <= '1';
         addr <= rd_addr;
         other <= rt;
-      when ADDI | SUBI | XORI | SLLI | SRAI | FMVLO | FMVHI | IMOVF | FMOVI =>
+      when ADDI | SUBI | XORI | SLLI | SRAI | FMVLO | FMVHI | IMOVF | FMOVI | SETL =>
         enable <= '1';
         addr <= rt_addr;
         other <= imm;
@@ -127,6 +129,8 @@ begin  -- behave
         out_buf <= rs(31 downto 16) & imm(15 downto 0);
       when FMVHI =>
         out_buf <= imm(15 downto 0) & x"0000";
+      when SETL =>
+        out_buf <= other;
       when others =>
         out_buf <= (others => 'X');
     end case;
[from now] Tue Dec  4 23:48:49 JST 2012

diff --git a/2nd/decoder/decoder.v b/2nd/decoder/decoder.v
index 2c88232..22d2f50 100644
--- a/2nd/decoder/decoder.v
+++ b/2nd/decoder/decoder.v
@@ -89,7 +89,8 @@ module decoder(input clk,
           || op == SLLI
           || op == SRAI

-          || op == FMVLO // misc
+          || op == SETL  // misc
+          || op == FMVLO
           || op == FMVHI
           || op == IMOVF
           || op == FMOVI
diff --git a/2nd/opcode.h b/2nd/opcode.h
index bb13dc2..6a8c094 100644
--- a/2nd/opcode.h
+++ b/2nd/opcode.h
@@ -8,6 +8,7 @@ parameter XORI    = 6'b000101;
 parameter SLLI    = 6'b000110;
 parameter SRAI    = 6'b000111;

+parameter SETL    = 6'b010000;
 parameter FMVLO   = 6'b010010;
 parameter FMVHI   = 6'b010011;
 parameter IMOVF   = 6'b010110;
[from now] Tue Dec  4 23:50:25 JST 2012

diff --git a/2nd/decoder/decoder.v b/2nd/decoder/decoder.v
index 22d2f50..06a953d 100644
--- a/2nd/decoder/decoder.v
+++ b/2nd/decoder/decoder.v
@@ -76,7 +76,7 @@ module decoder(input clk,

    reg use_rs, use_rt;
    always @ (op) begin
-      if (op == FMVHI || op == J || op == CALL || op == RETURN
+      if (op == SETL || op == FMVHI || op == J || op == CALL || op == RETURN
           || op == INPUTB || op == OUTPUTB || op == HALT
           || op == READKEY)
         use_rs <= 1'b0;
[from now] Tue Dec  4 23:53:37 JST 2012

diff --git a/compiler_set/assembler/assembler.h b/compiler_set/assembler/assembler.h
index 34fd4ae..75cdc41 100644
--- a/compiler_set/assembler/assembler.h
+++ b/compiler_set/assembler/assembler.h
@@ -45,6 +45,7 @@ PROTO_R(_fmul);
 PROTO_R(_fmuln);
 PROTO_R(_finv);
 PROTO_R(_fsqrt);
+PROTO_I(_setl);
 PROTO_R(_imovf);
 PROTO_R(_fmovi);
 PROTO_I(_fmvlo);
diff --git a/compiler_set/assembler/encode.cpp b/compiler_set/assembler/encode.cpp
index 012d179..8ab0216 100644
--- a/compiler_set/assembler/encode.cpp
+++ b/compiler_set/assembler/encode.cpp
@@ -9,6 +9,7 @@ DEFINE_I(_xori, XORI);
 DEFINE_I(_slli, SLLI);
 DEFINE_I(_srai, SRAI);

+DEFINE_I(_setl, SETL);
 DEFINE_I(_fmvlo, FMVLO);
 DEFINE_I(_fmvhi, FMVHI);
 DEFINE_R(_imovf, IMOVF, 0, 0);
[from now] Tue Dec  4 23:56:06 JST 2012

diff --git a/compiler_set/assembler/encode.cpp b/compiler_set/assembler/encode.cpp
index 8ab0216..76ec1e7 100644
--- a/compiler_set/assembler/encode.cpp
+++ b/compiler_set/assembler/encode.cpp
@@ -124,7 +124,7 @@ bool encode(char* instName, char* buffer, map<uint32_t, string>& labelNames, uin
 	}
 	if (eq(instName, "setl"))
 	{
-		int n = sscanf(buffer, formRL, dummy, label);
+		int n = sscanf(buffer, formRL, dummy, &rt, label);
 		if (n == 3)
 		{
 			labelNames[currentLine] = string(label);
@@ -506,7 +506,6 @@ vector<bool> mnemonic(char* instName, char mnemonicBuffer[][MAX_LINE_SIZE], map<
 	uint32_t rs = 0;
 	uint32_t rt = 0;
 	double d = 0;
-	char label[MAX_LINE_SIZE];
 	char dummy[MAX_LINE_SIZE];
 	vector<bool> useLabels;

diff --git a/compiler_set/include/common.h b/compiler_set/include/common.h
index 3ab7e61..65b26fa 100644
--- a/compiler_set/include/common.h
+++ b/compiler_set/include/common.h
@@ -32,7 +32,7 @@
 #define SLLI    (0b000110)
 #define SRAI    (0b000111)

-#define FMVLO   (0b010000)
+#define SETL    (0b010000)
 #define FMVLO   (0b010010)
 #define FMVHI   (0b010011)
 #define IMOVF   (0b010110)
[from now] Wed Dec  5 00:09:33 JST 2012

diff --git a/compiler_set/assembler/assembler.cpp b/compiler_set/assembler/assembler.cpp
index 9172c1d..05a46d5 100644
--- a/compiler_set/assembler/assembler.cpp
+++ b/compiler_set/assembler/assembler.cpp
@@ -163,6 +163,16 @@ void resolveLabels()
 				name = labelNames[i];
 				binaries[i].setJumpImm(getAddr(name));
 				break;
+			case SETL:
+				// 絶対アドレス 16 bits
+				if (labelNames.count(i) <= 0)
+				{
+					cout << i << " is not assigned in labelNames.(" << i << ")" << endl;
+					exit(-1);
+				}
+				name = labelNames[i];
+				binaries[i].setImm(getAddr(name));
+				break;
 			default:
 				break;
 		}
diff --git a/compiler_set/simulator/simulator.cpp b/compiler_set/simulator/simulator.cpp
index d858d08..26493fe 100644
--- a/compiler_set/simulator/simulator.cpp
+++ b/compiler_set/simulator/simulator.cpp
@@ -416,6 +416,10 @@ int simulate(simulation_options * opt)
 				logger.reg("FSQRT", get_rd(inst), myfsqrt(FRS));
 				FRD = myfsqrt(FRS);
 				break;
+			case SETL:
+				logger.reg("SETL", get_rt(inst), IMM);
+				IRT = IMM;
+				break;
 			case IMOVF:
 				logger.reg("IMOVF", get_rt(inst), IRS);
 				memcpy(&FRT, &IRS, 4);
[from now] Wed Dec  5 00:12:53 JST 2012

diff --git a/core_runner/bootloader.s b/core_runner/bootloader.s
index 02a69b8..e1820fd 100644
--- a/core_runner/bootloader.s
+++ b/core_runner/bootloader.s
@@ -4,15 +4,17 @@
 # r5: opcode (+ 2bits)
 # r8: 0xffffffff
 # r9: pc offset (end of loader)
-# r10: jump opcode
-# r11: call opcode
-# r12: instruction pointer (increment)
+# r10: instruction pointer (increment)
+# r11: jump opcode
+# r12: call opcode
+# r13: setl opcode
 loader:
 	subi	$r8, $r0, 1	# end marker ffffffff
 	setl	$r9, end_of_loader	# offset
-	addi	$r10, $r0, 224	# jump
-	addi	$r11, $r0, 232	# call
-	setl	$r12, end_of_loader	# instruction pointer
+	setl	$r10, end_of_loader	# instruction pointer
+	addi	$r11, $r0, 224	# jump
+	addi	$r12, $r0, 232	# call
+	addi	$r13, $r0, 64	# setl
 load_start:
 	inputb	$r3
 	addi	$r5, $r3, 0	# backup
@@ -30,20 +32,23 @@ load_start:
 	nop

 	# add pc for jump and call
-	beq	$r5, $r10, add_pc
+	beq	$r5, $r11, add_pc
 	nop
 	nop
-	beq	$r5, $r11, add_pc
+	beq	$r5, $r12, add_pc
+	nop
+	nop
+	beq	$r5, $r13, add_pc
 	nop
 	nop

-	program	$r12, $r4
-	addi	$r12, $r12, 1
+	program	$r10, $r4
+	addi	$r10, $r10, 1
 	j	load_start
 add_pc:
 	add	$r4, $r4, $r9	# add offset
-	program	$r12, $r4
-	addi	$r12, $r12, 1
+	program	$r10, $r4
+	addi	$r10, $r10, 1
 	j	load_start
 load_end:
 	call	end_of_loader