Solved

LMC programing trouble

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Progress

726 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