Lisa79
asked on
Little Man Computer programming
Hi everyone!
I need some help with a task that I have to do in my university class. I have been doing some java programming but I don´t understand the assembler programming that I have to use in "Little Man Computer". I could use a tip or two... :)
The program have to have this function... you have to write in to numbers and then you have to choose if the program shall add or multibly the numbers. If you type in "1" you are choosing addition and if you type in "2" you are choosing multiplication.
I have to use this LMC program > http://www.atkinson.yorku.ca/~sychen/research/LMC/LMCHome.html
I need some help with a task that I have to do in my university class. I have been doing some java programming but I don´t understand the assembler programming that I have to use in "Little Man Computer". I could use a tip or two... :)
The program have to have this function... you have to write in to numbers and then you have to choose if the program shall add or multibly the numbers. If you type in "1" you are choosing addition and if you type in "2" you are choosing multiplication.
I have to use this LMC program > http://www.atkinson.yorku.ca/~sychen/research/LMC/LMCHome.html
that link has all sort of example plz check before asking questions
>> I could use a tip or two... :)
Ok, what is it that you have a problem with ? Are you stuck somewhere ? Or don't know how to start ? If you tried anything yet, can you post that, so we can see how far you got ?
Ok, what is it that you have a problem with ? Are you stuck somewhere ? Or don't know how to start ? If you tried anything yet, can you post that, so we can see how far you got ?
ASKER
blaaze>
Thank you for your answer. But I belive it is obvious that I have already checked that link... and I tried to use that information a long time (two weeks) before I wrote my question here. Because some people writes here before they try by themself doesn´t mean that everyone does that!
Thank you for your answer. But I belive it is obvious that I have already checked that link... and I tried to use that information a long time (two weeks) before I wrote my question here. Because some people writes here before they try by themself doesn´t mean that everyone does that!
ASKER
Infinity08>
Hi! Thank you for helping me.. :)
Yes you can say that I´m stuck. I understand how I load and store the two numbers.. I don´t really understand how to use the (Branch if...) BRZ. And then I think I have to use loops to get the multiplication right? But I don´t understand how to write the code... and then I have to check that the code can handle if the inputs are zero. Can I do that through "Branch if zero or positive"?
I have done this:
Hi! Thank you for helping me.. :)
Yes you can say that I´m stuck. I understand how I load and store the two numbers.. I don´t really understand how to use the (Branch if...) BRZ. And then I think I have to use loops to get the multiplication right? But I don´t understand how to write the code... and then I have to check that the code can handle if the inputs are zero. Can I do that through "Branch if zero or positive"?
I have done this:
INP
STA FIRST
INP
STA SECOND
INP
STA NUMBERONE
BRZ SUBTRACTION
LDA FIRST
SUB SECOND
OUT
INP
STA NUMBERTWO
(LOOP)
OUT
HLT
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Infinity08>
Hi again,
sorry that I haven´t answered you until know.
I have a little problem with reading the operation type and to store it in the memory. But I have done this.. but I´m not sure that it is right.
Hi again,
sorry that I haven´t answered you until know.
I have a little problem with reading the operation type and to store it in the memory. But I have done this.. but I´m not sure that it is right.
INP
STA FIRST
INP
STA SECOND
LDA FIRST
OUT
LDA SECOND
OUT
STA ONE_SUB
HLT
FIRST DAT
SECOND DAT
ONE_SUB DAT
>> But I have done this.. but I´m not sure that it is right.
So, you take the two values as input, and then show them to the user.
Then you try to store ONE_SUB, but you haven't asked for the value yet. The user needs to tell you the operation type, so use the INP instruction to get it.
So, you take the two values as input, and then show them to the user.
Then you try to store ONE_SUB, but you haven't asked for the value yet. The user needs to tell you the operation type, so use the INP instruction to get it.
ASKER
sorry... I see that I forgot that.
INP
STA FIRST
INP
STA SECOND
LDA FIRST
OUT
LDA SECOND
OUT
INP
STA ONE_SUB
HLT
FIRST DAT
SECOND DAT
ONE_SUB DAT
Ok, so now you've got the three values. Now, based on the operation type, you have to do two different things ... That seems like a job for the branch instructions ...
ASKER
If I have understood everything right, I have to use addition and a loop for the multiplication. But I don´t understand how the program are going to know how many times it has to add the numbers. The example om the website has set the loop on ten times... but that is not going to work in my case!
>> But I don´t understand how the program are going to know how many times it has to add the numbers.
If you have to multiply by 10, then you add the same value together 10 times.
If you have to multiply by 20, then you add the same value together 20 times.
If you have to multiply by x, then you add the same value together x times.
If you have to multiply by 10, then you add the same value together 10 times.
If you have to multiply by 20, then you add the same value together 20 times.
If you have to multiply by x, then you add the same value together x times.
ASKER
Ok, but how do I know how many times I have to multiply? Do I have to specify that in the code? I´m thinking that I have to write the code so that the program calculates it in some way... of course... should I add the first number as many times as the second number? i.e run the loop as many times that I have printed in the second number? Adding the first number the same number of times as the second number? Am I going in the right direction...
My brain doesn´t want to think in this language. I´m sorry that I´m so "stupid" and asking so dumb questions. But I appreciate that you aren´t just giving me the code, because I still have to learn. :) And I´m sorry if my english isn´t perfect. :)
My brain doesn´t want to think in this language. I´m sorry that I´m so "stupid" and asking so dumb questions. But I appreciate that you aren´t just giving me the code, because I still have to learn. :) And I´m sorry if my english isn´t perfect. :)
>> Ok, but how do I know how many times I have to multiply?
What do you mean ? If you have to calculate x * y, then that's what you have to do : one multiplication.
Note that :
x * y = x + x + x + ... + x
where there are y x's on the right side, added together. Or a more specific example with x = 5 and y = 7 :
5 * 7 = 5 + 5 + 5 + 5 + 5 + 5 + 5
What do you mean ? If you have to calculate x * y, then that's what you have to do : one multiplication.
Note that :
x * y = x + x + x + ... + x
where there are y x's on the right side, added together. Or a more specific example with x = 5 and y = 7 :
5 * 7 = 5 + 5 + 5 + 5 + 5 + 5 + 5
ASKER
Ok, that was what I thought.. but I couldn´t explain it better.
Now I have written a code, but it will not compile. >>>>
"LittleManException: Target Label "ONE" is not valid.
LittleManException: ----- Compile Unsuccessful -----"
Now I have written a code, but it will not compile. >>>>
"LittleManException: Target Label "ONE" is not valid.
LittleManException: ----- Compile Unsuccessful -----"
INP
STA FIRST
INP
STA SECOND
LDA FIRST
OUT
LDA SECOND
OUT
INP
STA ONEORTWO
SUB ONE
BRZ NRONE
LDA FIRST
ADD SECOND
OUT
LDA ONEORTWO
SUB TWO
BRZ NRTWO
LDA FIRST
STA COUNT
LOOPTOP LDA COUNT
ADD SECOND
OUT
STA COUNT
SUB SECOND
BRP ENDLOOP
BRA LOOPTOP
ENDLOOP HLT
FIRST DAT
SECOND DAT
ONEORTWO DAT
COUNT DAT
>> "LittleManException: Target Label "ONE" is not valid.
That's because you haven't defined the label ONE. You need to give it some storage space (using DAT) and give it the appropriate value.
That's because you haven't defined the label ONE. You need to give it some storage space (using DAT) and give it the appropriate value.
Listening...
(I hate the way EE doesn't allow text to line up properly.....)
t0t0, do you realize that this was an assignment ? And that you're not supposed to solve the assignment ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
VeeMod
Thank you.
As you can see, you got there before I was able to complete and post my last comment.
I didn't know you could do that in these circumstances.
Thank you.
As you can see, you got there before I was able to complete and post my last comment.
I didn't know you could do that in these circumstances.
Lisa79
I submitted code earlier which has since been removed by the moderators. I apologise for the confusion in my last comment. Please ignore it's contents.
I submitted code earlier which has since been removed by the moderators. I apologise for the confusion in my last comment. Please ignore it's contents.
I'm not sure if Lisa79 is still around (it has been a few days), and how far she got with this assignment since our last interaction.
Lisa79, if you're still working on this, there are now two experts here ready to help you out if needed :) So, just let us know if you need our help ...
Lisa79, if you're still working on this, there are now two experts here ready to help you out if needed :) So, just let us know if you need our help ...
VeeMod
I appreciate your assistance in this matter.
1974 was a good year. Lots of sun, great music blaring out of our 'transistors', adolescence, girls, roller-skating and socialising - it's not surprising you left Assembly tucked away in the dark corners of your mind :)
I appreciate your assistance in this matter.
1974 was a good year. Lots of sun, great music blaring out of our 'transistors', adolescence, girls, roller-skating and socialising - it's not surprising you left Assembly tucked away in the dark corners of your mind :)
Infinity08
Thank you for the mention.... and please don't feel I intended to steal your chances to earn points, it's just that I have a passion with LMC.
I would love to offer some help however, my attepts do tend to be quite direct and I must learn to 'guide' rather than 'solve' for the asker.
Please permit me to add a comment to Lisa79.
Thank you for the mention.... and please don't feel I intended to steal your chances to earn points, it's just that I have a passion with LMC.
I would love to offer some help however, my attepts do tend to be quite direct and I must learn to 'guide' rather than 'solve' for the asker.
Please permit me to add a comment to Lisa79.
No worries, t0t0. If Lisa79 comes back, I'll step back and let you guide her, how does that sound ? ;)
Infinity08
I was rather hoping to offer a complete discussion on techniques and ideas relevent only to Lisa79's assignment and LMC. I don't want to exclude you from that discussion and I hope you are able to continue to offer Lisa79 assistance. From that point on, I will be happy to retire from this thread without credit. My motivation is a desire to evaluate the effectiveness of the conveyance of ideas and principles in Assembly language using the LMC machine.
I was rather hoping to offer a complete discussion on techniques and ideas relevent only to Lisa79's assignment and LMC. I don't want to exclude you from that discussion and I hope you are able to continue to offer Lisa79 assistance. From that point on, I will be happy to retire from this thread without credit. My motivation is a desire to evaluate the effectiveness of the conveyance of ideas and principles in Assembly language using the LMC machine.
ASKER
Hi Everyone!
You could say that I was surprised when I saw my mailbox today. A lot of messages... :)
I´m sorry that I haven´t responded to your messages but I got sick in the beginning of the week and I have not done anything on this asignment. I have not seen the complete code, and I am glad/happy fot that because I want to understand the code not just have the right answer. I will sit down and do the asignment tomorrow... thank you for your messages! :)
You could say that I was surprised when I saw my mailbox today. A lot of messages... :)
I´m sorry that I haven´t responded to your messages but I got sick in the beginning of the week and I have not done anything on this asignment. I have not seen the complete code, and I am glad/happy fot that because I want to understand the code not just have the right answer. I will sit down and do the asignment tomorrow... thank you for your messages! :)
Hiya all
I had a nasty fall yesterday and as a result I have not been able to concentrate on EE. Havine spent nearly 10 hours in hospital and sitting here with my leg bandaged up, I'm feeling quite sorry for myself.
Lisa79
I didn't just provide a solution. I did a whole write-up. I'm pleased to hear you would rather learn for yourself. With that said, I hope to be able to post something a little later once I am settled.
I had a nasty fall yesterday and as a result I have not been able to concentrate on EE. Havine spent nearly 10 hours in hospital and sitting here with my leg bandaged up, I'm feeling quite sorry for myself.
Lisa79
I didn't just provide a solution. I did a whole write-up. I'm pleased to hear you would rather learn for yourself. With that said, I hope to be able to post something a little later once I am settled.
ASKER
t0t0>
I´m sorry to hear about your injury! But it´s a good thing that you are at home again... take care!
I´m sorry to hear about your injury! But it´s a good thing that you are at home again... take care!
>> I will sit down and do the asignment tomorrow...
So, how far did you get with that ? Any trouble ?
So, how far did you get with that ? Any trouble ?
Hiya all
It was really unfortunate I haven't been able to put any time into this due to my accident. Anyway, I've returned from my surgery and I've got an hour before I have to reurn so here goes. by the way, hiya infinity08..
It was really unfortunate I haven't been able to put any time into this due to my accident. Anyway, I've returned from my surgery and I've got an hour before I have to reurn so here goes. by the way, hiya infinity08..
ASKER
Infinity08>
Well.. I have problems with the multiplication. It doesn´t work... I guess my loop is incorrect. I´m just looking at it and trying to get a solution. :)
This is my code right now.
Well.. I have problems with the multiplication. It doesn´t work... I guess my loop is incorrect. I´m just looking at it and trying to get a solution. :)
This is my code right now.
INP
STA FIRST
INP
STA SECOND
LDA FIRST
OUT
LDA SECOND
OUT
INP
STA ONEORTWO
SUB ONE
BRZ NRONE
LDA FIRST
ADD SECOND
OUT
LDA ONEORTWO
SUB TWO
BRZ NRTWO
LDA FIRST
STA COUNT
LOOPTOP LDA COUNT
ADD SECOND
OUT
STA COUNT
SUB SECOND
BRP ENDLOOP
BRA LOOPTOP
ENDLOOP HLT
FIRST DAT
SECOND DAT
ONEORTWO DAT
ONE DAT
TWO DAT
NRONE DAT
NRTWO DAT
COUNT DAT
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
t0t0>
Hi!
Yes, I do agree. If I understand right you want me to change the order in my code?
Should it be like this?
1)
FIRST DAT
SECOND DAT
OPTION DAT
ONE DAT
TWO DAT
NRONE DAT
NRTWO DAT
COUNT DAT
2)
INP
STA FIRST
INP
STA SECOND
LDA FIRST
OUT
LDA SECOND
OUT
3)
INP
STA OPTION
Correct?
I´m still looking att the rest.. The program should first decide that input 1 is addition and number 2 is multiplication? And then depending on the choise the program jumps? Right? I have seen a instruction for jump in other assembler languages... but I´m not sure this LMC has the instruction "Jump"?
I have read one of your other messages and I saw that your tip was to write the code so it can not take se number "0". But I have to make a program that can read the input "0".
Hi!
Yes, I do agree. If I understand right you want me to change the order in my code?
Should it be like this?
1)
FIRST DAT
SECOND DAT
OPTION DAT
ONE DAT
TWO DAT
NRONE DAT
NRTWO DAT
COUNT DAT
2)
INP
STA FIRST
INP
STA SECOND
LDA FIRST
OUT
LDA SECOND
OUT
3)
INP
STA OPTION
Correct?
I´m still looking att the rest.. The program should first decide that input 1 is addition and number 2 is multiplication? And then depending on the choise the program jumps? Right? I have seen a instruction for jump in other assembler languages... but I´m not sure this LMC has the instruction "Jump"?
I have read one of your other messages and I saw that your tip was to write the code so it can not take se number "0". But I have to make a program that can read the input "0".
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Give me a moment to comment.....
ASKER
but... I have reserved space for the variables?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
okay, my fault... looking at my list of 8 sections, you may have interpretted that as placing the variables and constants at the start of the code. These should always (normally) appear at the end of the code.
I'm looking at your code and this is what we have so far....
INP
STA FIRST
INP
STA SECOND
LDA FIRST
OUT
LDA SECOND
OUT
FIRST DAT
SECOND DAT
OPTION DAT
ONE DAT
TWO DAT
NRONE DAT
NRTWO DAT
COUNT DAT
Please allow me to simplify this for you.
(At this stage, because we're concentrating on the input section only, I'm going to omit some of your variables and only include those necessary for this section).
Looking at your code, you're getting both numbers in and storing them. That looks good. Then, you've decdied to re-load and output them. Is this really necessary? Might it not be simpler to just do the following and call it a day as far as getting your data in is concerned?
GetInput INP First
STA First
INP Second
STA Second
First DAT
Second DAT
I'm looking at your code and this is what we have so far....
INP
STA FIRST
INP
STA SECOND
LDA FIRST
OUT
LDA SECOND
OUT
FIRST DAT
SECOND DAT
OPTION DAT
ONE DAT
TWO DAT
NRONE DAT
NRTWO DAT
COUNT DAT
Please allow me to simplify this for you.
(At this stage, because we're concentrating on the input section only, I'm going to omit some of your variables and only include those necessary for this section).
Looking at your code, you're getting both numbers in and storing them. That looks good. Then, you've decdied to re-load and output them. Is this really necessary? Might it not be simpler to just do the following and call it a day as far as getting your data in is concerned?
GetInput INP First
STA First
INP Second
STA Second
First DAT
Second DAT
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you happy with the code so far?
OOOoooppps! Sorry.... I meant the following: (I don't know how the 'INP First' crept in, it meant to be just 'INP')
So, so far we have....
GetInput INP
STA First
INP
STA Second
GetOption INP
First DAT
Second DAT
So, so far we have....
GetInput INP
STA First
INP
STA Second
GetOption INP
First DAT
Second DAT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
t0t0>
about your example:
One DAT 1
Zero DAT 0
Start LDA One
ADD Six
OUT
End HLT
No it doen´t run or compile. It says that the target LABEL 6 is not valid. That´s because you haven´t reserved space for the variable Six.
about your example:
One DAT 1
Zero DAT 0
Start LDA One
ADD Six
OUT
End HLT
No it doen´t run or compile. It says that the target LABEL 6 is not valid. That´s because you haven´t reserved space for the variable Six.
ASKER
t0t0>
About blank lines... I didn´t know that it was possible to have blank lines. Every example that I have, didn´t have any blank lines. I personally prefer that, because it is so much easier to read the code if you have blank lines. So thank you!
About blank lines... I didn´t know that it was possible to have blank lines. Every example that I have, didn´t have any blank lines. I personally prefer that, because it is so much easier to read the code if you have blank lines. So thank you!
ASKER
t0t0>
It has been a BIG help for me. I´m really think that I understand your examples!
I see that we are heading for the next part of the code...addition and substraction. Should it not be addition and "multiplication". I know that the LMC doesn´t have any instructions for multiplication. But it has to be done with addition and a loop? Right?
It has been a BIG help for me. I´m really think that I understand your examples!
I see that we are heading for the next part of the code...addition and substraction. Should it not be addition and "multiplication". I know that the LMC doesn´t have any instructions for multiplication. But it has to be done with addition and a loop? Right?
Sory... I was half asleep when I posted my last comment, by whic time my mind had turned to mush.... Yes, multiplication.....
Here's our code so far....
GetInput INP
STA First
INP
STA Second
GetOption INP
BRZ End
SUB One
BRZ Addition
SUB One
BRZ Multiply
BRA GetOption
Addition [SECTION 5]
Multiply [SECTION 6]
[SECTION 7]
End [SECTION 8]
First DAT
Second DAT
One DAT 1
Here's our code so far....
GetInput INP
STA First
INP
STA Second
GetOption INP
BRZ End
SUB One
BRZ Addition
SUB One
BRZ Multiply
BRA GetOption
Addition [SECTION 5]
Multiply [SECTION 6]
[SECTION 7]
End [SECTION 8]
First DAT
Second DAT
One DAT 1
ASKER
then I´m back in the game. :)
BIG time mate!!!! Get prepared for some BIG marks.....
Oh, that comment of mine on section (4) - make sure you really understand why and how it works...
Now then, are you able to complete the next section - section (5): Addition?
Hint, This should consist of no more than 4 lines of code - the last line is a branch to section (7) instruction.
Oh, that comment of mine on section (4) - make sure you really understand why and how it works...
Now then, are you able to complete the next section - section (5): Addition?
Hint, This should consist of no more than 4 lines of code - the last line is a branch to section (7) instruction.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You wrote "Which now brings me to a subtle suggestion. How about incorporating a simple 'exit' mechanism so that we can abort the program by inputing a '0'?".
That would be a problem... My teacher said that the program must be able to multiply two zeros ("0") and it has to handle that the option is "0" too.
That would be a problem... My teacher said that the program must be able to multiply two zeros ("0") and it has to handle that the option is "0" too.
ASKER
About section (4).
I thought I had to use "BRP" instruction for the multiplication? If my input is 4 and it substracts with one I get 3? And then its "zero or positive".
Why do I have to write "BRA GetOption"? Otherwise I think I have understood the logic.. :)
I thought I had to use "BRP" instruction for the multiplication? If my input is 4 and it substracts with one I get 3? And then its "zero or positive".
Why do I have to write "BRA GetOption"? Otherwise I think I have understood the logic.. :)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I understand the sections... and if I have some questions about the LMC´s instruction I will let you know.
I´m doing the asignment on my free time and because I had to be at work I´m not finished with the rest of the code. Perhaps in a few hours...
I´m doing the asignment on my free time and because I had to be at work I´m not finished with the rest of the code. Perhaps in a few hours...
ASKER
this is what I have done this far... I´m now looking at section 7.
GetInput INP
STA First
INP
STA Second
GetOption INP
BRZ End
SUB One
BRZ Addition
SUB One
BRZ Multiply
BRA GetOption
Addition LDA First
ADD Second
OUT
BRA End
Multiply LDA First
ADD Second
STA Count
End HLT
First DAT
Second DAT
One DAT 1
Count DAT
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Something like this?
GetInput INP
STA First
INP
STA Second
GetOption INP
BRZ End
SUB One
BRZ Addition
SUB One
BRZ Multiply
BRA GetOption
Addition LDA First
ADD Second
STA Sum
BRA DisplayResult
Multiply
DisplayResult LDA Sum
OUT
End HLT
First DAT
Second DAT
Sum DAT
One DAT 1
Count DAT
It's looking good. you must be pleased....
if i were you, i'd keep this assignment close to your chest and not share it with others as it might seem as though you copied from their work rather than them copying from yours!! - that's just the competitive side of me talking now.
just one small point.... we'll be using the same memory location to save our result to when we do our multiplication as well.... I'm just wondering whether the label "Sum" would be appropriate because 'sum' actually implies 'addition'. i am just wondering if it can be named something else - something neutral.
Right! time to press on with the Section (6) Multiply....
if i were you, i'd keep this assignment close to your chest and not share it with others as it might seem as though you copied from their work rather than them copying from yours!! - that's just the competitive side of me talking now.
just one small point.... we'll be using the same memory location to save our result to when we do our multiplication as well.... I'm just wondering whether the label "Sum" would be appropriate because 'sum' actually implies 'addition'. i am just wondering if it can be named something else - something neutral.
Right! time to press on with the Section (6) Multiply....
Do you have any thoughts about how you'd like to tackle the multiply section of your code?
ASKER
I´m very pleased. :) And I´m bot going to share my code with anyone!
Kan I call it Result?
About Section (6) Multiply... my thoughts is if I want to multiplu I have to use addition and a loop. For ex if my first number is 5 and my second number is 3. Then the loop has to "loop" 3 times and add the first number to itself three times (5+5+5) Right?
Kan I call it Result?
About Section (6) Multiply... my thoughts is if I want to multiplu I have to use addition and a loop. For ex if my first number is 5 and my second number is 3. Then the loop has to "loop" 3 times and add the first number to itself three times (5+5+5) Right?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
after you've coded that up, I'm going to discuss a method to optimise this section - this will EARN you MEGA marks!!!!
ASKER
It looks good... But I have to go and do some errands. :(
I will be back in two-three hours and start coding again.
I will be back in two-three hours and start coding again.
okay....
ASKER
you wrote earlier about this section...
"Hint for section (5)..... Just looking at it logically...
You need to load one of our numbers we input previously.
You need to add the other number to it.
You need to strore the result away so that it can be processed in a later section of the code.
You need to branch to that section of code which will process the result."
I guess I have to include this too?
I have a qustion about the "Set Result = 0". Should it be "Result Dat 0" then? I´m sorry if I´m a slow learner..
I´m going to work now but I will try to login and look at the code at work. Thank you for you patience!
"Hint for section (5)..... Just looking at it logically...
You need to load one of our numbers we input previously.
You need to add the other number to it.
You need to strore the result away so that it can be processed in a later section of the code.
You need to branch to that section of code which will process the result."
I guess I have to include this too?
I have a qustion about the "Set Result = 0". Should it be "Result Dat 0" then? I´m sorry if I´m a slow learner..
I´m going to work now but I will try to login and look at the code at work. Thank you for you patience!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
just to let you know, in your final listing, there'll be THREE parts to the multiply section.
you've already got the first TWO parts:
Pt.1: reset Result to '0'
Pt.2: ??????????????? <--- I'll leave you to stew over this one for a bit
Pt.3: do the multiplication
and this would normally be all you'll need to do to accomplish the task.... however, we're going to explorer a method to OPTIMISE this section - this will be a small bit of code slipped in between Pt.1 and Pt.3. This will a MASSIVE marks earner.
this is what's left to do:
1) write the code for Section (5) Multiply.
2) discuss and slip in Pt.2.
and that would normally be the end of it HOWEVER..... i will discuss a final RE-EDIT of the code suited to the attitude of your tutor (based on his/her own experience) and suited to the actual course you are doing this for - I will explain all this when we get to that point. so...
3) OPTIMISE code (FINAL EDIT)
and that will be all. at which point your code will be the most professional piece of work your tutor have probably EVER clapped his/her eyes on.
you've already got the first TWO parts:
Pt.1: reset Result to '0'
Pt.2: ??????????????? <--- I'll leave you to stew over this one for a bit
Pt.3: do the multiplication
and this would normally be all you'll need to do to accomplish the task.... however, we're going to explorer a method to OPTIMISE this section - this will be a small bit of code slipped in between Pt.1 and Pt.3. This will a MASSIVE marks earner.
this is what's left to do:
1) write the code for Section (5) Multiply.
2) discuss and slip in Pt.2.
and that would normally be the end of it HOWEVER..... i will discuss a final RE-EDIT of the code suited to the attitude of your tutor (based on his/her own experience) and suited to the actual course you are doing this for - I will explain all this when we get to that point. so...
3) OPTIMISE code (FINAL EDIT)
and that will be all. at which point your code will be the most professional piece of work your tutor have probably EVER clapped his/her eyes on.
Lisa
Have you made any progress?
Have you made any progress?
ASKER
t0t0
I was at work yesterday evening.. but now I´m back. I´m not getting the code right.. but this is what I got now. But I´m still working on it.
I was at work yesterday evening.. but now I´m back. I´m not getting the code right.. but this is what I got now. But I´m still working on it.
GetInput INP
STA First
INP
STA Second
GetOption INP
BRZ End
SUB One
BRZ Addition
SUB One
BRZ Multiply
BRA GetOption
Addition LDA First
ADD Second
STA Result
BRA DisplayRes
Multiply LDA a
ADD b
STA a
OUT
HLT
LDA a
ADD First
STA Count
OUT
LOOPTOP LDA Count
SUB One
STA Count
BRZ DisplayRes
LDA First
ADD SECOND
STA Count
BRZ LOOPTOP
DisplayRes LDA Result
OUT
End HLT
First DAT
Second DAT
Result DAT 1
One DAT 1
Count DAT
a DAT 0
b DAT 1
Lisa, why did you put this in your code?....
LDA a
ADD b
STA a
OUT
HLT
That was maent to be put into the LMC all by itself as a mini-program. It's purpose is to demonstrate that even if you pre-initialise memory, you can't rely on it being initialised again the 2nd time you run the program.
LDA a
ADD b
STA a
OUT
HLT
That was maent to be put into the LMC all by itself as a mini-program. It's purpose is to demonstrate that even if you pre-initialise memory, you can't rely on it being initialised again the 2nd time you run the program.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Okay, so we haven't figured out a way yet to initialise Result to '0'..
The obvious way would be to define another data constant, and use that (just as we did for "One").
The obvious way would be to define another data constant, and use that (just as we did for "One").
ASKER
is this correct? I´m still working on the rest of the loop... when you say "Good intention". What do you mean should i keep the code or change it in some way?
Multiply LDA ResultMul
STA Count
ADD First
STA Count
Loop LDA Count
*
*
*
*
DisplayRes LDA Result
OUT
End HLT
First DAT
Second DAT
Result DAT
One DAT 1
ResultMul DAT 0
Count DAT
Have this instead....
First DAT
Second DAT
Result DAT
One DAT 1
Zero DAT 0
Count DAT
ASKER
Are you helping me too much if you explain to me in words (not finished code) how the multiplication works?
If I have understand it right.. the program has to do some type of check. Like in section (2) and depending on the result it "jumps" to a specifik part in the code. I think it is very hard to understand the logik behind the code and that´s why it´s hard to write it.
I don´t understand how the program uses the two input numbers... I understand that if the first number is 3 and the second is 5, the first number has to loop 5 times. correct? But how (!) can the program check how many times it has to loop? I guess I have to do as in section (2), test if the input i "0" and then make a choice? I thought that I was supposed to use "One" but as you said I have to be careful with that.
If I have understand it right.. the program has to do some type of check. Like in section (2) and depending on the result it "jumps" to a specifik part in the code. I think it is very hard to understand the logik behind the code and that´s why it´s hard to write it.
I don´t understand how the program uses the two input numbers... I understand that if the first number is 3 and the second is 5, the first number has to loop 5 times. correct? But how (!) can the program check how many times it has to loop? I guess I have to do as in section (2), test if the input i "0" and then make a choice? I thought that I was supposed to use "One" but as you said I have to be careful with that.
ASKER
Zero is a much better choice.. I had a black out and could not come up with a good "name".
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you don't mind me asking, what college course are you doing this assignment for?
ASKER
I´m doing a University Course. It´s a basic course in computer Science.. I don´t know why I have such a problem with this language.. the other assignments I have finished by myself. I think Java is more logical..
I have changed "DisplayResult" ti "DisplayRes" because the simulator applet that I´m using are not accepting "DisplayResult". It has to many letter... it can only be 9 letters.
I´m at work again.. but I´m looking at the code when I can. Otherwise I do it at home tonight...
I have changed "DisplayResult" ti "DisplayRes" because the simulator applet that I´m using are not accepting "DisplayResult". It has to many letter... it can only be 9 letters.
I´m at work again.. but I´m looking at the code when I can. Otherwise I do it at home tonight...
Lisa
Don't look upon it as a computer language. Imagine LMC's instruction are simple single instructions you might give a blind person, or a driver, to perform a task. Each instruction does ONLY just one small operation. The challenge is to use this limited set of instructions in a logical order to achieve the task.
Don't look upon it as a computer language. Imagine LMC's instruction are simple single instructions you might give a blind person, or a driver, to perform a task. Each instruction does ONLY just one small operation. The challenge is to use this limited set of instructions in a logical order to achieve the task.
ASKER
I´m still looking att the decrement part...
Multiply LDA Zero
STA Result
ADD First
STA Count
Loop LDA Count
SUB One
BRZ DisplayRes
LDA Result
ADD Second
STA Result
*
*
BRZ Loop
DisplayRes LDA Result
OUT
End HLT
First DAT
Second DAT
Result DAT
One DAT 1
Zero DAT 0
Count DAT
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi again,
"ADD First" should be "LDA First".
Now I have replaced "DisplayRes" with "ShowResult". Your suggestion was much better.. :)
I have also replaced "Count" with "Counter". I hope that´s ok! Now when I´m lerning more... I think Counter is more logical.
"ADD First" should be "LDA First".
Now I have replaced "DisplayRes" with "ShowResult". Your suggestion was much better.. :)
I have also replaced "Count" with "Counter". I hope that´s ok! Now when I´m lerning more... I think Counter is more logical.
GetInput INP
STA First
INP
STA Second
GetOption INP
BRZ End
SUB One
BRZ Addition
SUB One
BRZ Multiply
BRA GetOption
Addition LDA First
ADD Second
STA Result
BRA ShowResult
Multiply LDA Zero
STA Result
LDA First
STA Counter
Loop BRZ ShowResult
LDA Result
ADD Second
STA Result
LDA Counter
SUB One
STA Counter
BRZ Loop
ShowResult LDA Result
OUT
End HLT
First DAT
Second DAT
Result DAT
One DAT 1
Zero DAT 0
Counter DAT
ASKER
t0t0>
"I can see your label "Loop" and I can also see "BRZ DisplayRes". Looking at the flowchart, I can see the label "Loop" and I can also see the instruction "If Count is '0' then branch to DisplayResult".... but where did the two lines "LDA Count" and "SUB One" come from?... This isn't shown on the flowchart".
I don´t really know what I was thinking about. I hope my new code is better..
I guess the next step is to get the LMC to understand which of the two inputs is the greatest?
"I can see your label "Loop" and I can also see "BRZ DisplayRes". Looking at the flowchart, I can see the label "Loop" and I can also see the instruction "If Count is '0' then branch to DisplayResult".... but where did the two lines "LDA Count" and "SUB One" come from?... This isn't shown on the flowchart".
I don´t really know what I was thinking about. I hope my new code is better..
I guess the next step is to get the LMC to understand which of the two inputs is the greatest?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
right.. because I want it to always branch to the beginning of the loop!
I changed "Counter" back to "Count" again.. :)
I changed "Counter" back to "Count" again.. :)
GetInput INP
STA First
INP
STA Second
GetOption INP
BRZ End
SUB One
BRZ Addition
SUB One
BRZ Multiply
BRA GetOption
Addition LDA First
ADD Second
STA Result
BRA ShowResult
Multiply LDA Zero
STA Result
LDA First
STA Count
Loop BRZ ShowResult
LDA Result
ADD Second
STA Result
LDA Count
SUB One
STA Count
BRA Loop
ShowResult LDA Result
OUT
End HLT
First DAT
Second DAT
Result DAT
One DAT 1
Zero DAT 0
Count DAT
ASKER
it works! :)
It looks GREAT!!!! Have you checked if it works?
Sorry, you already answered ...... of course it works!!..... now for some serious stuff....
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
something like this?
Multiply LDA Zero
STA Result
LDA Second
SUB One
BRP NoSwap
Swap LDA First
STA Count
LDA Second
STA First
NoSwap LDA Second
STA Count
LDA First
STA Count
Loop BRZ ShowResult
LDA Result
ADD Second
STA Result
LDA Count
SUB One
STA Count
BRA Loop
ShowResult LDA Result
OUT
End HLT
First DAT
Second DAT
Result DAT
One DAT 1
Zero DAT 0
Count DAT
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I wrote "One" by mistake.. I´m sure that I wrote "First" but I see now that I wrote "One" by mistake. But I was thinking right anyway.. :)
I´m listening (reading) and learning.. :)
I´m listening (reading) and learning.. :)
GetInput INP
STA First
INP
STA Second
GetOption INP
BRZ End
SUB One
BRZ Addition
SUB One
BRZ Multiply
BRA GetOption
Addition LDA First
ADD Second
STA Result
BRA ShowResult
Multiply LDA Zero
STA Result
LDA Second
SUB First
BRP NoSwap
Swap LDA First
STA Temp
LDA Second
STA First
LDA Temp
STA Second
NoSwap LDA First
STA Count
Loop LDA Count
BRZ ShowResult
LDA Result
ADD Second
STA Result
LDA Count
SUB One
STA Count
BRA Loop
ShowResult LDA Result
OUT
End HLT
First DAT
Second DAT
Result DAT
One DAT 1
Zero DAT 0
Count DAT
Temp DAT
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Will you have to do a write-up as part of this assignment?
Have you considered what test-data you might use to test the code?
Have you considered what test-data you might use to test the code?
ASKER
I have to write a report, with the code and a explanation to it. I have not considered what test-data I might use.. I have just tested the program and checked that it works.
If I'm correct, even with the best program in the world, if your write-up is crap you could very easily fail this assignment. It wouldn't surprise me if the code itself is worth only 18% of the overall marks!
Okay, I would consider the following to be essential.
1) Introduction
2) Program requirements specification
3) Overall design
4) Overall flowchart (showing only the main control of the program)
5) Refined design identifying individual sections of processes/functions
6) Refined flowcharts for the main sections showing data flow and process control
7) Full description of your data and how your program manages memory storage
8) Skeleton code showing the main control structure of your program
9) Refined code for each section of your program
10) Detailed explanation of any areas which are improved/optimised/comprom ised
11) Full program listing with remarks
12) Full description of test data / table showing expected and actual results
13) Description of LMC, it's limitations, it's user-friendliness
14) How you went about researching and completing the assignment
15) conclusion
16) Glossary of LMC's instructions
At the very most, half page for each (except the glossary and flowcharts)
When does your assignment need to be handed in?
Are you a mature student or a recent school-leaver?
Have you got the details of what you're supposed to do for your asignment?
Do you have to give a self appraisal?
Okay, I would consider the following to be essential.
1) Introduction
2) Program requirements specification
3) Overall design
4) Overall flowchart (showing only the main control of the program)
5) Refined design identifying individual sections of processes/functions
6) Refined flowcharts for the main sections showing data flow and process control
7) Full description of your data and how your program manages memory storage
8) Skeleton code showing the main control structure of your program
9) Refined code for each section of your program
10) Detailed explanation of any areas which are improved/optimised/comprom
11) Full program listing with remarks
12) Full description of test data / table showing expected and actual results
13) Description of LMC, it's limitations, it's user-friendliness
14) How you went about researching and completing the assignment
15) conclusion
16) Glossary of LMC's instructions
At the very most, half page for each (except the glossary and flowcharts)
When does your assignment need to be handed in?
Are you a mature student or a recent school-leaver?
Have you got the details of what you're supposed to do for your asignment?
Do you have to give a self appraisal?
ASKER
This is a small basic asignment and non of the information that I have got shows that I have to do such a big write-up. But thank you for the information I will take it under consideration for my future asignments. :)
I have a few days left until I have to hand it in. I´m a "mature" student but it is not long ago that I studied at the university last time but then it was not Computer Science. I have all the details and I don´t have to give myself appraisal this time.
Thank you very much for all the time and effort that you have given me! If I could I would give you 1000 points... :) I will close this question as soon as I pass the asignment!
I have a few days left until I have to hand it in. I´m a "mature" student but it is not long ago that I studied at the university last time but then it was not Computer Science. I have all the details and I don´t have to give myself appraisal this time.
Thank you very much for all the time and effort that you have given me! If I could I would give you 1000 points... :) I will close this question as soon as I pass the asignment!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you require an explantion of the above final code then let me know.
Don't worry about points however, please consider infinity08's initial help - i feel guilty taking this question away from him.
Don't worry about points however, please consider infinity08's initial help - i feel guilty taking this question away from him.
>> please consider infinity08's initial help - i feel guilty taking this question away from him.
No worries. You handled it great, and deserve them ;)
No worries. You handled it great, and deserve them ;)
ASKER
Hi,
my teacher hasn´t checked the assignment get but I will close the question anyway. I´m sure I will pass. :) Thank you both for your help. Although t0t0 helpt me most, it was you Infinity08 who helped me in the beginning. Of course I will take both of your help in consideration when I split up the points. :)
my teacher hasn´t checked the assignment get but I will close the question anyway. I´m sure I will pass. :) Thank you both for your help. Although t0t0 helpt me most, it was you Infinity08 who helped me in the beginning. Of course I will take both of your help in consideration when I split up the points. :)
ASKER
I think that you (t0t0) has guided me through my question in a good way.
I ´m very thankful for that. :)
I ´m very thankful for that. :)
Good luck with your marks. Most of all, I hope you gained from this exercise.
Thank you for posting an interesting question and thank you for accepting my answer and awarding me points.
Thank you for posting an interesting question and thank you for accepting my answer and awarding me points.
ASKER
Hi t0t0.
I have learned a lot thanks to you! I´m not a expert... but I think I got a basic understanding for the assembler language. And that is a lot more than I thought when I started this assignment and didn´t understand anything. :)
Have a nice dag!
I have learned a lot thanks to you! I´m not a expert... but I think I got a basic understanding for the assembler language. And that is a lot more than I thought when I started this assignment and didn´t understand anything. :)
Have a nice dag!
thank you and good luck
Hiya Lisa...
I was just wondering how you got on with your Littleman Computer Assignment.
Looking at the list of Top Solutions for Assembly, this question ranks the highest.
I was just wondering how you got on with your Littleman Computer Assignment.
Looking at the list of Top Solutions for Assembly, this question ranks the highest.