MARIE Assembly finding the product of two number with subroutine using JNS function

65 Views Asked by At

I want to find the product 2*3 with subroutine but my program goes on infinite loop. Below is the code in MARIE assembly language. I think the logic is okay but I don't know where is the problem that my program goes on infinite loop. Thank you for your consideration

ORG 100
    INPUT 
    STORE A
    INPUT 
    STORE B
    JNS subr
    JUMP result

subr,   HEX 0
loop1,  LOAD A
        ADD sum1
        STORE sum1
        LOAD B
        SUBT One
        STORE B
        SKIPCOND 400
        JUMP loop1
        JUMPI subr
        
result, LOAD sum1   
        OUTPUT  
        HALT
    
A,  DEC 0
B,  DEC 0
C,  DEC 0
D,  DEC 0
One,    DEC 1
sum1,   DEC 0
sum2,   DEC 0
total,  DEC 0
0

There are 0 best solutions below