nolimips-0.9-7-g9c67b2b Fix the handling of `.half' assembler directives.

* src/inst/program_builder.hxx (inst::ProgramBuilder::add_half): Use bitwise ``and'' operators instead of logical ``and'' operators. This mistake was reported by clang++ 3.0. * tests/good/print-half.s, * tests/good/print-half.ref: New test. * tests/good/Makefile.am (ASM_FILES): Add print_half.s. --- ChangeLog | 13 +++++++++++++ src/inst/program_builder.hxx | 4 ++-- tests/good/Makefile.am | 3 ++- tests/good/print-half.ref | 1 + tests/good/print-half.s | 22 ++++++++++++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 tests/good/print-half.ref create mode 100644 tests/good/print-half.s diff --git a/ChangeLog b/ChangeLog index 2c122cc..448a49f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2012-05-22 Roland Levillain <roland@lrde.epita.fr> + Fix the handling of `.half' assembler directives. + + * src/inst/program_builder.hxx (inst::ProgramBuilder::add_half): + Use bitwise ``and'' operators instead of logical ``and'' + operators. + This mistake was reported by clang++ 3.0. + * tests/good/print-half.s, + * tests/good/print-half.ref: + New test. + * tests/good/Makefile.am (ASM_FILES): Add print_half.s. + +2012-05-22 Roland Levillain <roland@lrde.epita.fr> + Fix the comparison of produced and expected tests outputs. * tests/nolimips-check: Look for reference outputs in the source diff --git a/src/inst/program_builder.hxx b/src/inst/program_builder.hxx index 971d7a2..bb6a8d7 100644 --- a/src/inst/program_builder.hxx +++ b/src/inst/program_builder.hxx @@ -89,8 +89,8 @@ namespace inst ProgramBuilder::add_half(int imm) { // FIXME: check that imm is less than 0x10000! - add_byte((imm >> 8) && 0xff); - add_byte(imm && 0xff); + add_byte((imm >> 8) & 0xff); + add_byte(imm & 0xff); } inline void diff --git a/tests/good/Makefile.am b/tests/good/Makefile.am index 541a63e..cfc5238 100644 --- a/tests/good/Makefile.am +++ b/tests/good/Makefile.am @@ -13,7 +13,8 @@ ASM_FILES = \ fact.s \ gtcd.s \ extended-euclide.s \ - modular-exponent.s + modular-exponent.s \ + print-half.s INPUT_FILES = \ read_int.in diff --git a/tests/good/print-half.ref b/tests/good/print-half.ref new file mode 100644 index 0000000..38c75f3 --- /dev/null +++ b/tests/good/print-half.ref @@ -0,0 +1 @@ +134088703 diff --git a/tests/good/print-half.s b/tests/good/print-half.s new file mode 100644 index 0000000..a23793b --- /dev/null +++ b/tests/good/print-half.s @@ -0,0 +1,22 @@ +### Test the `.half' directive. + .data +val: + .half 2046 + .half 2047 +eol: + .asciiz "\n" + + .text +main: + # print_int(val) + lw $a0, val($zero) + li $v0, 1 + syscall + # print("\n") + la $a0, eol + li $v0, 4 + syscall + # exit(0) + li $a0, 0 + li $v0, 10 + syscall -- 1.7.2.5
participants (1)
-
Roland Levillain