![]() |
|
|||||||
| Homework Help Stuck on a textbook question or coursework? Cramming for a test and need help understanding something? Post your questions and attempts here and let others help. |
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hello. I have this problem to collect 8 numbers from the user and find which one is the lowest and which is the highest. I tried to perform this task by using 16 if/else statements but the compiler complained, saying "statement label must be unique". Here is what i have now:
Code:
Input Store Num1 Input Store Num2 Input Store Num3 Input Store Num4 Input Store Num5 Input Store Num6 Input Store Num7 Input Store Num8 If, Load Num1 Subt Num2 Skipcond 800 Jump Else Then, Load Num1 Store Lowest Else, Load Num2 Store Lowest If, Load Lowest Subt Num3 Skipcond 800 Jump Else Then, Load Lowest Store Lowest Else, Load Num3 Store Lowest If, Load Lowest Subt Num4 Skipcond 800 Jump Else Then, Load Lowest Store Lowest Else, Load Num4 Store Lowest If, Load Lowest Subt Num5 Skipcond 800 Jump Else Then, Load Lowest Store Lowest Else, Load Num5 Store Lowest If, Load Lowest Subt Num6 Skipcond 800 Jump Else Then, Load Lowest Store Lowest Else, Load Num6 Store Lowest If, Load Lowest Subt Num7 Skipcond 800 Jump Else Then, Load Lowest Store Lowest Else, Load Num7 Store Lowest If, Load Lowest Subt Num8 Skipcond 800 Jump Else Then, Load Lowest Store Lowest Else, Load Num8 Store Lowest If, Load Num1 Subt Num2 Skipcond 800 Jump Else Then, Load Num2 Store Highest Else, Load Num1 Store Highest If, Load Highest Subt Num3 Skipcond 800 Jump Else Then, Load Num3 Store Highest Else, Load Highest Store Highest If, Load Highest Subt Num4 Skipcond 800 Jump Else Then, Load Num4 Store Highest Else, Load Highest Store Highest If, Load Highest Subt Num5 Skipcond 800 Jump Else Then, Load Num5 Store Highest Else, Load Highest Store Highest If, Load Highest Subt Num6 Skipcond 800 Jump Else Then, Load Num6 Store Highest Else, Load Highest Store Highest If, Load Highest Subt Num7 Skipcond 800 Jump Else Then, Load Num7 Store Highest Else, Load Highest Store Highest Halt If, Load Highest Subt Num8 Skipcond 800 Jump Else Then, Load Num8 Store Highest Else, Load Highest Store Highest Load Lowest Output Load Highest Output Halt Num1, Dec 0 Num2, Dec 0 Num3, Dec 0 Num4, Dec 0 Num5, Dec 0 Num6, Dec 0 Num7, Dec 0 Num8, Dec 0 Lowest, Dec 0 Highest, Dec 0 I was wondering if there was a way to loop through all 8 numbers to find the lowest and the highest without having to use 16 if/else statements. Thank you in advance |
|
#2
|
||||
|
||||
|
While the language, MARIE, is a mystery, it appears that you have made some fundamental errors (or they would be in every other language).
Your Input statement does not specify what to input, or from what source. You tell the simulator to Store the input, but do not specify a location. Your conditional statement do not appear to be valid. The usual convention is IF - Then, Else. So an evaluation of Num1 might appear as: IF Num1 > 0 THEN GOSUB EVAL ;The subroutine does something ELSE Flag 1 = 0 ;Flag 1 at 0 means Num1 is not the largest I might also expect that some register be explicitly loaded with the value of Num1, which would be the label for a memory storage location. That is the fun part of not having the instruction set of MARIE, but knowing how high level languages get coded.
__________________
First comes the hardware, then the software. |
|
#3
|
||||
|
||||
|
I am unfamiliar with MARIE Assembly Language.
However, in most other assembly languages, labels begin in column 1 (ie: no space before the label). Since your If, Then, and Else statements begin in column 1, the Assembler is interpreting them as labels rather than program statements. I'll bet that if you insert at least one space before those statements, the Assembler will no longer complain about non-unique labels. Hint: Initialize the variable "Lowest" to the highest value possible, and "Highest" to the lowest possible value. IE: if Marie uses 8-bit signed integers, initialize Lowest to 32767 dec, and Highest to -32768 dec. |
|
#4
|
|||||
|
|||||
|
Quote:
Quote:
Quote:
" STORE num1" ...that the contents of the accumulator are placed into the memory location(s) labeled "num1" Quote:
Quote:
![]() Since Num1 is defined at the end of the program as a type decimal with a value of zero, the assembler is very likely "smart enough" to handle the offset from program start (by default ORG 000h) to the label Num1 and the length of Num1. But I don't want to confuse our OP with the facts. ![]() When I was writing Assembler code on IBM mainframes, labels started in column 1, opcodes started in column 10, single operands started in column 20, and comments started in column 40. That's why old programmers have a hard time spelling anything over 8 characters long. However, it made the source code neat, easy to read, and it was very easy to find opcodes/mnemonics and labels that were in the wrong columns.
|
|
#5
|
||||
|
||||
|
Hello,
Here I found two PDF's on the net about MARIE assembly. Greetings, Bertus
__________________
You don't have to know everything, if you know where to find it. When you do ask questions, you may look stupid. When you do NOT ask questions, you will STAY stupid. It would be nice to have the Timezone ( GMT +/- x ) in the location field in the profile.(User CP -> Edit Your Details) |
|
#6
|
||||
|
||||
|
Thanks, Bertus - that helped a good bit.
I see in the example provided in: http://forum.allaboutcircuits.com/at...0&d=1257702689 ...that IF, THEN, ELSE are not valid opcodes in Marie; they are labels. However, labels must be unique; and Evilsithgirl has used multiple occurrences of IF, THEN, and ELSE as labels. Apparently, labels must have a comma after them. |
|
#7
|
|||
|
|||
|
thanks for all your helpful tips everybody. my program is working
|
|
| Bookmarks |
| Tags |
| assemby, marie, program |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Matlab loops...help! | natashakhan | Programmer's Corner | 1 | 05-10-2009 08:39 PM |
| Working out delay loops | vk4tec | Embedded Systems and Microcontrollers | 10 | 02-21-2009 03:18 PM |