confusion in CPU emu

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

confusion in CPU emu

liangke
my code is:
D=D-A
@JUMP1
D;JEQ
@0
D=A
@JUMP2
0;JMP
(JUMP1)
@-1
D=A
(JUMP2)
@17
D=A
In CPU emu the code is :
30 D=D-A
31 @115
32 D;JEQ
33 @0
34 D=A
35 @386
36 0;JMP
37
38 D=A
39 @17

the line of 37 is 0
when the emu execute the line 37 ,the PC is to set 0.the code was reseted.
why CPU emu  has  assemble this code to this form.
and why execute line 37 ,the PC was set 0.
Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: confusion in CPU emu

liangke
I think the code
@-1
it in mem should be :
0111 1111 1111 1111
not
1111 1111 1111 1111

how can I figure it?
Reply | Threaded
Open this post in threaded view
|

Re: confusion in CPU emu

cadet1620
Administrator
@-1 is an illegal command.

The argument to @ commands must be a number between 0 and 32767, inclusive.  You can set the A register to -1 by using the A=-1 command.

If you want to set any other negative number into A you need to do something like
    @27
    A=-A
or to get -27 into D
    @27
    D=-A

--Mark