Answer to Question #320710 in Assembler for ibrahim

Question #320710

Write an assembly program using MARIE's assembly Instruction set that prompts the user to enter a non-negative integer that is less than 10. The program should include a subroutine that keeps prompting until a valid value is obtained. When a valid number is entered, it will be displayed. (Hint: Use JNS & JUMPI instructions to implement the subroutine)


1
Expert's answer
2022-03-30T15:49:02-0400
    ORG        0            
start,    LOAD        chN        
    OUTPUT        / output N
    LOAD        ch    
    OUTPUT        
    LOAD        chSpace    
    OUTPUT    

END,    INPUT
    STORE        N        / save N
    SUBT        N10        / compare with 10
    SKIPCOND    00        / if N>=10
    JUMP        start

    LOAD        N        / save N
    ADD  N0                / N to ASCII
    OUTPUT                / display N

    HALT

chN,        HEX    4E            / N
ch,         HEX    3A            / :
chSpace,    HEX    20            /
            HEX    0            / NULL char
N10,        DEC    10
N,          DEC    0
N0,         HEX    30

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS