Solved

LMC programing trouble

Posted on 2009-06-27
2
296 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

8 Experts available now in Live!

Get 1:1 Help Now