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)
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
Comments
Leave a comment