


































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



































LMC.jar is a simple interpreter based on "The Little Man Computer." The language that this interpreter runs is representative of the kind of machine language that your computer processor might run. Demo ...
add : add value at given address to accumulator goto : go to given line number ifzero : if accumulator contains zero, go to given line number input : prompt for number and store at given address load : load value at given address into accumulator store : store accumulator value at given address subtract : subtract value at given address from accumulator
0: input 15 1: load 14 2: store 13 3: load 15 4: ifzero 11 5: subtract 14 6: store 15 7: load 13 8: add 13 9: store 13 10: goto 3 ... 13: data //answer 14: data 1 15: data //x input x answer = 1; while (x != 0) { x = x - 1; answer = answer + answer;
Java x Machine Language 0: load 14 ... 14: data //x
Java x = 3; Machine Language 0: load 15 1: store 14 ... 14: data //x 15: data 3
Java if (x == 3) {
Java while (x != 3) {
int x; x = 3; S.o.p(x + x); 6 load 15 add 15 15: data 3 6 int x; x = 3; S.o.p(x + x); load 15 add 15 15: data 3 Interpreter (program) Compiler (program) Processor (machine)