Skip to content

Commit cd0049a

Browse files
committedFeb 29, 2016
solve arch
1 parent 5632e5c commit cd0049a

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-0
lines changed
 

‎etc/arch/arch

14.2 KB
Binary file not shown.

‎etc/arch/arch.i64

224 KB
Binary file not shown.

‎etc/arch/memo.txt

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<op2num>
2+
0 - add
3+
1 - sub
4+
2 - addi
5+
3 - subi
6+
4 - xor
7+
5 - print
8+
6 - lw
9+
7 - sw
10+
아니면 0xFFFFFFFF
11+
12+
<reg2num>
13+
0 - eax
14+
1 - ebx
15+
2 - ecx
16+
3 - edx
17+
아니면 0xFFFFFFFF
18+
19+
<init>
20+
if_id_ready
21+
id_ex_ready
22+
ex_mem_ready
23+
mem_wb_ready
24+
25+
- 이전 스테이지에서 데이터를 준비할 때까지 기다리고
26+
- 다음 스테이지가 쉴 때까지 기다린다
27+
28+
start_routine -> ID -> EX -> MEM -> WB
29+
30+
[start_routine]
31+
1. while ( if_id_ready )
32+
2. inst에 명령어 받아서 넣음
33+
3. if_id_ready = 1
34+
35+
[ID]
36+
1. while ( !if_id_ready )
37+
2. while ( id_ex_ready )
38+
3. id_ex_op = op2num
39+
4.
40+
{id_reg} - add, sub, xor
41+
1. r0 = reg2num, r1 = reg2num, r2 = reg2num
42+
2. id_ex_dst = r0, id_ex_data1 = reg2value(r1), id_ex_data2 = reg2value(r2)
43+
3. set_reg_busy(id_ex_dst)
44+
45+
{id_imm} - addi, subi, lw, sw
46+
1. r0 = reg2num, r1 = reg2num, r2 = atoi
47+
2. if (id_ex_op == lw || id_ex_op == sw) check valid_mem(reg_value[r1] + r2)
48+
3. id_ex_dst = r0, id_ex_data1 = reg2value(r1), id_ex_data2 = r2
49+
4. set_reg_busy(id_ex_dst)
50+
51+
{id_print} - print
52+
1. r0 = reg2num
53+
2. id_ex_dst = 0xFFFFFFFF, id_ex_data1 = reg2value(r0)
54+
55+
5. id_ex_ready = 1
56+
6. if_id_ready = 0
57+
58+
[EX]
59+
1. while ( !id_ex_ready )
60+
2. while ( ex_mem_ready )
61+
3.
62+
{ex_add} - add, addi, lw, sw
63+
ex_mem_data = id_ex_data1 + id_ex_data2
64+
65+
{ex_sub} - sub, subi
66+
ex_mem_data = id_ex_data1 - id_ex_data2
67+
68+
{ex_xor} - xor
69+
ex_mem_data = id_ex_data1 ^ id_ex_data2
70+
71+
{ex_print} - print
72+
printf("%d", id_ex_data1)
73+
74+
4. ex_mem_dst = id_ex_dst, ex_mem_op = id_ex_op
75+
5. ex_mem_ready = 1
76+
6. id_ex_ready = 0
77+
78+
[MEM]
79+
1. while ( !ex_mem_ready )
80+
2. while ( mem_wb_ready )
81+
3.
82+
if (ex_mem_op == lw)
83+
mem_wb_data = memory[ex_mem_data]
84+
else if (ex_mem_op == sw)
85+
printf("%p\n", &memory[ex_mem_data])
86+
memory[ex_mem_data] = reg2value(ex_mem_dst)
87+
else
88+
mem_wb_data = ex_mem_data
89+
90+
4. mem_wb_dst = ex_mem_dst
91+
5. mem_wb_op = ex_mem_op
92+
6. mem_wb_ready = 1
93+
7. ex_mem_ready = 0
94+
95+
[WB]
96+
1. while ( !mem_wb_ready )
97+
2.
98+
add, sub, addi, subi, xor, lw
99+
set_reg(mem_wb_dst, mem_wb_data)
100+
101+
3. unset_reg_busy(mem_wb_dst)
102+
4. mem_wb_ready = 0
103+
104+
[reg2value]
105+
1. reg_busy[a1]이면 10초 대기
106+
2. return reg_value[a1]

‎etc/arch/scenario.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+

2+
0x401451 = 4199505 - jump here
3+
0x602090 = 6299792 - exit .got.plt
4+
0x602094 = 6299796
5+
0x602140 = 6299968 - memory
6+
7+
diff 0xb0 = 176 | 176/4 = 44
8+
9+
[수상한 부분 1]
10+
valid_mem 체크는 함수로 하지 않고 바로 배열에서 읽음
11+
12+
[수상한 부분 2]
13+
reg2value에서 busy인 경우 0.1초 쉰다
14+
15+
edx = 0 고정
16+
17+
addi eax edx 4199505
18+
-
19+
addi ebx edx 44
20+
addi ebx edx 0
21+
sw eax ebx -44
22+
-
23+
addi ebx edx 43
24+
addi ebx edx 0
25+
sw edx ebx -43

0 commit comments

Comments
 (0)
Please sign in to comment.