Permalink
Browse files

修正 cmp_imm()

* 目前 cmp_imm 的實做是:
  if reg == imm
    Z = C = 1
  if reg < imm
    N = 1
  if reg > imm
    C = 1

* cmp_reg() 尚未驗證

EMU-2
  • Loading branch information...
doremi
doremi committed Mar 13, 2012
1 parent f9cca62 commit ad72ab3763f4462b1e357b2db10fbf09e1904d08
Showing with 15 additions and 8 deletions.
  1. +10 −6 aluop.c
  2. +5 −2 arm/hello.c
View
16 aluop.c
@@ -304,14 +304,18 @@ int cmp_imm(struct CPUState *env, uint32_t inst)
{
uint32_t rn = getrn(inst);
uint32_t imm12 = getimm12(inst);
- uint32_t value = expand_imm12(env, imm12);
- uint32_t x = get_reg(env, rn);
+ int32_t value = expand_imm12(env, imm12);
+ int32_t x = get_reg(env, rn);
+
+ env->cpsr.N = env->cpsr.Z = env->cpsr.C = env->cpsr.V = 0;
- add_with_carry(x, ~value, 1, env, TRUE);
- if (x >= value) {
+ if (x == value) {
+ env->cpsr.Z = 1;
+ env->cpsr.C = 1;
+ } else if (x < value) {
+ env->cpsr.N = 1;
+ } else if (x > value) {
env->cpsr.C = 1;
- } else {
-// env->cpsr.V = 1; doremi FIXME
}
return 0;
View
@@ -61,8 +61,11 @@ int main()
int b = 7;
int c = a + b;
- c = 0xffffeeee;
- htoa(buf, c);
+ int i = 0, sum = 0;
+ for (i = 0; i < 10000000; ++i)
+ sum += i;
+// c = 0xffffeeee;
+ htoa(buf, sum);
// char buf[] = "Hello world\n";
buf[10] = '\n';

0 comments on commit ad72ab3

Please sign in to comment.