Solved

LMC programing trouble

Posted on 2009-06-27
2
307 Views
Last Modified: 2012-05-07
Im writing a program that accepts 3 values as input and produces the largest of the 3 as output.

Still having code issues, have utilized all my resources, what and where am i going wrong in writing the correct code format to achieve the above execution, can you advise thanks.

00 INP   901
01 STO  399
02 INP   901
03 STO   398
04 INP   901
05 STO   397
06 LDA   599
07 BRZ   712
08 LDA   599
09 SUB   298
10 OUT   902
11 BR      615
12 LDA   598
13 ADD   197
14 OUT   902
15 STOP 000

Open in new window

0
Comment
Question by:USN4x4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 31

Expert Comment

by:moorhouselondon
ID: 24729174
I don't know the intricacies of this language, but assuming this is like standard assembler code, let me have a try:-

Am I right in thinking that INP is equivalent to an Opcode of 9?  LDA = 5?  ADD = 1? etc.

If so:-

A is put into 99
B is put into 98
C is put into 97


The contents of 99 are then being loaded into the Accumulator and testing it for Zero.

Does BRZ really mean Branch if zero?  Are there not Operation Codes more suited for testing whether things are Greater Than or Less Than each other?

I could go further into the code, but let me know whether I'm understanding the language correctly or not first.
0
 
LVL 31

Accepted Solution

by:
moorhouselondon earned 500 total points
ID: 24729198
Sorry, I rewrote the whole of my comment cos my first attempt was useless, and I left a bit out in the middle, but my question was in fact about the line

11 BR 615

What does this test do?  

In actual fact, if you precede all of the lines with a comment and resubmit them here, I suspect you will have a lightbulb moment and want to close the question.  Yes yes, you are learning programming and programmers aren't supposed to comment things ;-))

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 114
Apps blocked by Java 9 98
Using Third Party DLL with Access VBA 14 51
collection output issue 9 62
A short article about a problem I had getting the GPS LocationListener working.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question