Here is the start of a case to go in tests/movi.c:
#include "test.h"
// Should really test all of the cases seen in
// arm-cpu.c: encode_thumb_immediate()
/* 00000000 00000000 00000000 abcdefgh */
/* 00000000 abcdefgh 00000000 abcdefgh */
/* abcdefgh 00000000 abcdefgh 00000000 */
/* abcdefgh abcdefgh abcdefgh abcdefgh */
/* 1bcdefgh << 24 ... 1bcdefgh << 1 */
static void
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
{
jit_begin(j, arena_base, arena_size);
jit_movi(j, JIT_R0, 0xa500a500);
jit_retr(j, JIT_R0);
jit_uword_t (*f)(void) = jit_end(j, NULL);
fprintf(stderr, "returns 0x%08x\n", f());
ASSERT(f() == 0xa500a500);
}
int
main (int argc, char *argv[])
{
return main_helper(argc, argv, run_test);
}