immortalvm / ivm-implementations

iVM contemporary implementations
5 stars 0 forks source link

simulation bug related with ivm optimizations #20

Closed elnv closed 4 years ago

elnv commented 4 years ago

We have found a bug when executing some codes using the ivm as-run utility. It works correctly by disabling the optimization (--noopt).

Attached you can find a snapshot showing three executions. The first one is the wrong execution without "--noopt". The second is the right one with "--noopt". The third one is execution on the host, which is the reference.

Observe the numerical values printed by the program.

The code is one of the examples in the compiler project: /tests/examples/12-floats.c

We attach the assembly file. 12-floats.zip

imagen

ivar-rummelhoff commented 4 years ago

Hm. This assembly file has more than 1/2 million lines. A small example would have been more useful...

ivar-rummelhoff commented 4 years ago

I found a minimal example:

    and!! (load1 d) 0x1
    exit
d:
    data1 [2]

### EXPECTED STACK:
###
### 0

Until I have fixed this bug, you should use the -n / --noopt option.