Solved

LMC programing trouble

Posted on 2009-06-27
2
300 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
parentbit challenge 3 74
strDist challenge 35 97
move one pixel 4 59
Is there any way to copy all SSRS reports/datasets/data sources  to new server? 3 52
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now