DCPUTeam / DCPUToolchain

[ARCHIVED] The code repository for the DCPU-16 Toolchain.
http://dcputoolcha.in/
MIT License
96 stars 14 forks source link

IFL not working correctly #210

Closed orlof closed 11 years ago

orlof commented 11 years ago

Platform: Windows 7 Version: http://bb.dcputoolcha.in/builds/windows/dists/dcputoolchain-windows--791381db25a032a622ed91e1cc5e55024946a098.exe

Following test program's logic is IF 0<12: a=10. When run with dtemu it skips the SET as can be seen from the debug log.

For me it seems that the literal value "12" has been changed to 0x0000.

IFL [val], 12
  SET A, 10
:halt
  SET PC, halt

:val DAT 0
0x0001: IFL NXT NXT_LIT (0x0000)  (0x0007) 
--------------------------------
A:   0x0000   [A]:   0x7FD6
B:   0x0000   [B]:   0x7FD6
C:   0x0000   [C]:   0x7FD6
X:   0x0000   [X]:   0x7FD6
Y:   0x0000   [Y]:   0x7FD6
Z:   0x0000   [Z]:   0x7FD6
I:   0x0000   [I]:   0x7FD6
J:   0x0000   [J]:   0x7FD6
PC:  0x0003   SP:    0x0000
EX:  0x0000   IA:    0x0000
IRQ ENABLED:      false
IRQ COUNT:   0x0000
CYCLES TO SLEEP: 0x0000

0x0004: (skipped) SET A NXT_LIT (0x000A) 
--------------------------------
A:   0x0000   [A]:   0x7FD6
B:   0x0000   [B]:   0x7FD6
C:   0x0000   [C]:   0x7FD6
X:   0x0000   [X]:   0x7FD6
Y:   0x0000   [Y]:   0x7FD6
Z:   0x0000   [Z]:   0x7FD6
I:   0x0000   [I]:   0x7FD6
J:   0x0000   [J]:   0x7FD6
PC:  0x0005   SP:    0x0000
EX:  0x0000   IA:    0x0000
IRQ ENABLED:      false
IRQ COUNT:   0x0000
CYCLES TO SLEEP: 0x0000

0x0006: SET PC NXT_LIT (0x0005) 
--------------------------------
A:   0x0000   [A]:   0x7FD6
B:   0x0000   [B]:   0x7FD6
C:   0x0000   [C]:   0x7FD6
X:   0x0000   [X]:   0x7FD6
Y:   0x0000   [Y]:   0x7FD6
Z:   0x0000   [Z]:   0x7FD6
I:   0x0000   [I]:   0x7FD6
J:   0x0000   [J]:   0x7FD6
PC:  0x0005   SP:    0x0000
EX:  0x0000   IA:    0x0000
IRQ ENABLED:      false
IRQ COUNT:   0x0000
CYCLES TO SLEEP: 0x0000

...and here is the same thing run with dtdb. In this memory dump the literal value seels to be ok (000C).

> step
> inspect memory 0 10
0000: 7FD6 000C 0007 7C01 000A 7F81 0005 0000
0008: 0000 0000
> disasm
0x0000 (0x7FD6):     IFL [0x0007], 0x000C
0x0003 (0x7C01): >>> SET A, 0x000A
0x0005 (0x7F81):     SET PC, 0x0005
0x0007 (0x0000):     
0x0008 (0x0000):     
0x0009 (0x0000):     
0x000A (0x0000):     
0x000B (0x0000):     
0x000C (0x0000):     

> step
> disasm
0x0000 (0x7FD6):     IFL [0x0007], 0x000C
0x0003 (0x7C01):     SET A, 0x000A
0x0005 (0x7F81): >>> SET PC, 0x0005
0x0007 (0x0000):     
0x0008 (0x0000):     
0x0009 (0x0000):     
0x000A (0x0000):     
0x000B (0x0000):     
0x000C (0x0000):     
0x000D (0x0000):     
0x000E (0x0000):     

> inspect cpu
A:   0x0000   [A]:   0x7FD6
B:   0x0000   [B]:   0x7FD6
C:   0x0000   [C]:   0x7FD6
X:   0x0000   [X]:   0x7FD6
Y:   0x0000   [Y]:   0x7FD6
Z:   0x0000   [Z]:   0x7FD6
I:   0x0000   [I]:   0x7FD6
J:   0x0000   [J]:   0x7FD6
PC:  0x0005   SP:    0x0000
EX:  0x0000   IA:    0x0000
IRQ ENABLED:      false
IRQ COUNT:       0x0000
CYCLES TO SLEEP: 0x0000
patflick commented 11 years ago

@orlof fixed, also admiral's edit() now works