Little man computer Program

  Kiến thức lập trình

The program takes an integer input (let’s call it n) to determine the number of bits. Then, it asks for n more inputs (each representing a bit of a binary number). After receiving all the inputs, it converts the binary number into a decimal number and displays it as output.

My attempt:
INP
STO 99
LDA 900
STO 98

loop:
LDA 99
SUB 901
BRZ end
INP
BRP bit_one
BR loop

bit_one:
LDA 98
ADD 98
STO 98
BR loop

bit_zero:
LDA 98
STO 98
BR loop

end:
LDA 98
OUT
HLT

but the LMC IDE i am using doesn’t recognize the most of the instructions sets and mnemonic. it only recognize STO, ADD, SUB, IN, ADD, HLT, BR, BRZ, BRP. and i have to use memory access. so Help me. THANK YOU

New contributor

Human is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT