@@ -4,10 +4,10 @@ mod tests {
44 use binary_room:: translate:: * ;
55 use binary_room:: utils;
66 use binary_room:: utils:: translate_to_file;
7- use binary_room:: utils:: START ;
7+ use binary_room:: utils:: ARM_START ;
88
99 const buf: & str = r#"
10- . buf:
10+ buf:
1111 .string "hello world\n"
1212"# ;
1313
@@ -18,7 +18,28 @@ mod tests {
1818 text: buf. to_string( ) ,
1919 } ,
2020 RiscVInstruction :: Verbatim {
21- text: START . to_string( ) ,
21+ text: ARM_START . to_string( ) ,
22+ } ,
23+ // While i < 1000
24+ RiscVInstruction :: Li {
25+ dest: RiscVRegister :: A3 ,
26+ imm: 1000 ,
27+ } ,
28+ RiscVInstruction :: Label {
29+ name: ".loop" . to_string( ) ,
30+ } ,
31+ RiscVInstruction :: Addi {
32+ dest: RiscVRegister :: A3 ,
33+ src: RiscVRegister :: A3 ,
34+ imm: -1 ,
35+ } ,
36+ RiscVInstruction :: Ble {
37+ arg1: RiscVRegister :: A3 ,
38+ arg2: RiscVRegister :: X0 ,
39+ target: RiscVVal :: LabelOffset {
40+ label: ".end" . to_string( ) ,
41+ offset: 0 ,
42+ } ,
2243 } ,
2344 // write syscall
2445 RiscVInstruction :: Li {
@@ -32,15 +53,15 @@ mod tests {
3253 RiscVInstruction :: Lui {
3354 dest: RiscVRegister :: A0 ,
3455 src: RiscVVal :: LabelOffset {
35- label: ". buf" . to_string( ) ,
56+ label: "buf" . to_string( ) ,
3657 offset: 9998 ,
3758 } ,
3859 } ,
3960 RiscVInstruction :: Addl {
4061 dest: RiscVRegister :: A1 ,
4162 src: RiscVRegister :: A0 ,
4263 label: RiscVVal :: LabelOffset {
43- label: ". buf" . to_string( ) ,
64+ label: "buf" . to_string( ) ,
4465 offset: 9999 ,
4566 } ,
4667 } ,
@@ -49,12 +70,24 @@ mod tests {
4970 imm: 1 ,
5071 } ,
5172 RiscVInstruction :: ECall ,
73+ RiscVInstruction :: J {
74+ target: RiscVVal :: LabelOffset {
75+ label: ".loop" . to_string( ) ,
76+ offset: 0 ,
77+ } ,
78+ } ,
79+ RiscVInstruction :: Label {
80+ name: ".end" . to_string( ) ,
81+ } ,
5282 // exit syscall
5383 RiscVInstruction :: Li {
5484 dest: RiscVRegister :: A7 ,
5585 imm: 93 ,
5686 } ,
57- // RiscVInstruction::Li { dest: RiscVRegister::A0, imm: 0 },
87+ RiscVInstruction :: Li {
88+ dest: RiscVRegister :: A0 ,
89+ imm: 0 ,
90+ } ,
5891 RiscVInstruction :: ECall ,
5992 ] ;
6093
0 commit comments