mult.asm

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

mult.asm

sharmaankush347
mult is showing 0x0=-1 with script otherwise no such issue without script. Here's screenshot...kindly tell me mistake if any
Thanks
multquery.jpg
Reply | Threaded
Open this post in threaded view
|

Re: mult.asm

WBahn
Administrator
I can't evaluate your code if I can't see all of your code.

Have you walked through the code execution by hand to see what it does?
Reply | Threaded
Open this post in threaded view
|

Re: mult.asm

sharmaankush347
ya,even its working without script, I modified the repeat 20 to some higher value in script. Here's my code-


  @R2       //making R2 =0  
        M=0
    @R0
    D=M
    @ZERO
    D;JEQ     //if R0=0, goto ZERO
    @R1
    D=M
    @ZERO
    D;JEQ  //if R1=1, goto ZERO


       
    @i
        M=1          //i=1
       
        @Prod        // Product
        M=0          // Product=0
       
       
(LOOP)
   
    @i
        D=M
        @R0
        D=D-M        //D=i-RAM[0]
       
        @STOP
        D;JGT        //IF i-n>0, GOTO STOP
       
        @Prod
        D=M
        @R2
        M=D
        @R1
        D=D+M        // D=Prod+m
        @Prod
        M=D          //Prod=Prod+m
        @i
        M=M+1        //i=i+1
       
        @LOOP
        0;JMP        //UNCONDITIONAL JUMP
       

(ZERO)
        @R2
        M=0
        //@R2
        D=M
        @END
        0;JMP
       
(STOP)

    @Prod
        D=M
        @R2
    M=D     // RAM[2]=Prod
        @END
        0;JMP
       
       



(END)
        @END
        0;JMP