7:42 p.m.

(0) Comments

Little Man Computer(LMC)

Jean-Michel

Stumble Upon Toolbar
Hello, today while answering questions on yahoo@answers , i saw a question about LMC. I didnt know anything about that thing but i found out fast enough.

LMC is a instructional model of a computer, it's used to teach students about basic features of a modern computer.

it looks like a good thing to learn before assembly.


So i went on that page http://www.atkinson.yorku.ca/~sychen/research/LMC/LittleMan.html
and i started coding.

LMC is not hard it had a set of 10 instruction

INP = prompt the user to a value to put in the accumulator
OUT = output the value of the accumulator
LDA = load in the acumulator the data at the specified memory
STA = store the value of the accumulator at a specified memory
ADD = add a specified value to the accumulator
SUB = sub a specified value to the accumulator
BRZ = goto specified label if the value inside the accumulator is 0
BRP = goto to specified label if the value inside the accumulator is 0 or greater
BRA = declare a label
DAT = declare a variable
HLT = end program



after 30 min i had answer the guy question : how to do a multiplication in LMC
here i give you the code

INP
STA NUMBER1
INP
STA NUMBER2
SUB NUMBER1
BRP NO2GREATER
LDA NUMBER1
STA FACTOR
LDA NUMBER2
STA MULTIPLIER
LDA ZERO
BRZ LOOKIFZERO
NO2GREATER LDA NUMBER2
STA FACTOR
LDA NUMBER1
STA MULTIPLIER
LDA ZERO
BRZ LOOKIFZERO
LOOKIFZERO LDA NUMBER1
BRZ ISZERO
LDA NUMBER2
BRZ ISZERO
LDA ZERO
BRZ LOOPTOP
ISZERO OUT ZERO
HLT
LOOPTOP LDA RESULT
ADD FACTOR
STA RESULT
LDA MULTIPLIER
SUB ONE
BRZ LOOPEND
STA MULTIPLIER
BRP LOOPTOP
LOOPEND STA RESULT
OUT
HLT
BRA NO2GREATER
BRA LOOKIFZERO
BRA ISZERO
BRA LOOPTOP
BRA LOOPEND
NUMBER1 DAT
NUMBER2 DAT
FACTOR DAT
MULTIPLIER DAT
RESULT DAT 000
ONE DAT 001
ZERO DAT 000

hope it was usefull to someone
NJR-TEAM
Stumble Upon Toolbar
0 Responses to "Little Man Computer(LMC)"

Post a Comment

Have an opinion say it!