My question If possible to answer the questions from (a) to (e) which the question is asking in simple way so that can understand how this program is working ? pls .
Main Topics
Browse All TopicsI attached a file with all the details .
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
thats fair enough , I will send the answer I managed to solve and see what you think ? is that acceptable , I am going mad with this assembly , its really hard to understand , at least thats how I see it , ok one question pls can you explain what the stack and what the stack pointer is other than a place where the main program remeber to go to when it run the call instruction.thank you .
>> is that acceptable
Definitely. I'll have a look at what you posted, and give you my comments.
>> ok one question pls can you explain what the stack and what the stack pointer is other
The stack is a region in memory where all local variables, function arguments, call return addresses etc. are saved.
For each function call, a stack frame is set up and added to the top of the current stack. That stack frame contains among other things the return address (where the execution should continue once the function ends), the local function variables, as well as saved registers (in case their value has to be placed back when the function ends).
If, at any time, you walk through the stack from bottom to top, you'll find the stack frames for all current nested function calls. You could see the stack as the current state of the execution.
The stack pointer simply points to the current top of the stack (ie. where the push and pop operations are done).
I am really grateful , I just can not get my head round it at the moment , I invest lots of hours with the simulator I got to understand the stack but still unable to grasp what it exactly do and unless I do I can not move one step ahead I feel depress ..at the moment , write If I attach apic for some activitis I captured with the simulator and pose question on that will that be ok .(its activities not assignment or thing like that ).?
>> I got to understand the stack but still unable to grasp what it exactly do and unless I do I can not move one step ahead
The image you posted is not for a question directly related to the stack, so even if you don't fully understand what the stack is and how it works, that shouldn't prevent you from answering the questions there.
Do you know the concept of a stack (LIFO) data structure ?
Yes, compare it to a stack of papers on your desk. You add new papers on top of the stack, making the stack grow, and you take the top-most paper off of the stack, making the stack shrink. LIFO = last-in-first-out.
The stack in this case is exactly the same : it grows in one direction (increasing in size whenever a function is called or local variables are allocated, or ...), and then shrinks again (when returning from a function, etc.)
cool , I am learning great deal about the processor now and I do understand lots of things but its some how complicated and the connection it seems as if u r in a dark tunnel , but I will never give up to understanding it , eg. we know thats inforamtion does not stop b/n main memory and processor so if I ask where is the first instruction starting who initiate it first ?what your answer will be , by the way this is not at all exam questions or anything like that , just question from my head .
>> but I will never give up to understanding it
That's good :)
>> so if I ask where is the first instruction starting who initiate it first ?what your answer will be
The operating system that runs on the computer takes care of starting and managing processes. A process has an entry point, so when the operating system starts a process, it starts execution at that entry point (main for example). From then on, the instructions that are called depend on the flow of control (comparisons, sumps, loops, etc.).
In the case of the code you posted, I can't tell you who will call it - it's just a piece of code that could be called when needed.
ahh ok ,I am begining to understand it more and more now thank you , you r beeing very helpful , but I am not going to leave alone haaa because I am going to bombard you with questions if thats okay with you , I am more intrested in understanding to be honest nothing more . so will keep in touch if any issue arise and sure you deserve all the pointa no doubt about that , I am just leaving the question open so that I can save it to my knowledge base also I want to answer this question (my self ) but need some help to check if I am on the right track.cheers mate you r being great help .
Hello there , its me again with answers so pls let e know what you think ?
(a). the register rB is used as loop counter .
(b).the loop will be executed 64 time in hex whihc is 100 in denary .
(c) still can not figure it out .
(d). add immediate r1 0000 is used to test whats in r1 weather its -ve , +ve or zero .
(e). the subroutine is a peice of code (program) withen a main program that needs to be executed n numbers of time .
thats what I could come up with but could not find the gihest and lowest value in this program so pls I appreciate any help .thks in advance
>>(a). the register rB is used as loop counter .
Correct.
>> (b).the loop will be executed 64 time in hex whihc is 100 in denary .
I assume that denary is the same as decimal (ie. base 10) ? If so, then that looks ok.
>> (c) still can not figure it out .
I'll give you a hint : 0500, which is loaded into rE at the start, is a memory address.
>> (d). add immediate r1 0000 is used to test whats in r1 weather its -ve , +ve or zero .
Indeed. We're not interested in the immediate impact (adding 0 doesn't change the value), but in the side effects of the instruction.
>> (e). the subroutine is a peice of code (program) withen a main program that needs to be executed n numbers of time .
You need to explain what it actually does ... For example "it sums an array of integers" or something like that (this is just an example, not actually what this code does).
right , regarding denary means decimal yes but we have been tought to use denary otherwise the computer geeks gets upset haaa...
so ,I presume that the adress 0500 is the lowest address in data memory and the higest is 0564 because this is the last value rE has got when rB got to 0000 in the simulater, is that correct ?
if yes I will be left only with what this subroutine does as u mentioned .....I followed the instruction step by step but all I can tel for now there is a loop going on for 100 times it increases rE by one , decrease the loop counter by one , it checkes whats in R1 (0,+.-) when rB reach the value zero it jumps and store 0600 in rA if value is not zero then it goes back fff7 which I think its -9 ,what do you think ?
pls if I did not reply quick for ur comments this is because I have dr.appointment in half an hour time , nothing serious just not feeling well ....but sure as soon as I get reply I will keep in touch so patience ..patience ..thank you very much ...what mechanism best to use to know what the program is doing ? I understand is to run it and see what i does but when I did that nothing much happened ,all I could see increase in rE , DECREASE IN rB , and zero flag is ticked when it got to zero and it jump back fff7 so .....
>> regarding denary means decimal yes but we have been tought to use denary otherwise the computer geeks gets upset haaa...
Heh. Well I've never heard of the term denary ;)
>> I presume that the adress 0500 is the lowest address in data memory and the higest is 0564 because this is the last value rE has got when rB got to 0000 in the simulater, is that correct ?
0500 is the lowest indeed. The load register-indirect instruction reads the value at the current memory address.
However, 0564 is not the highest ... In the last iteration of the loop, what will be the address ? In the first, it's 0500, in the second 0501, etc. And for the 100th iteration ?
>> all I can tel for now there is a loop going on for 100 times it increases rE by one , decrease the loop counter by one
Right.
>> it checkes whats in R1 (0,+.-)
And what's in r1 at that moment ?
>> when rB reach the value zero it jumps
Ok.
>> and store 0600 in rA
It's the other way around ... Think memory address again ;)
>> if value is not zero then it goes back fff7 which I think its -9 ,what do you think ?
Right. And to which instruction would that jump bring you ?
>> is 0563 it must be correct this time ?
Yes :) 0563 is the memory address of the last processed item.
>> can you give me more clue of what the subroutine does pls .
Well, the load register-indirect instruction reads the item at the current memory address, and places it in r1.
What happens to r1 after that ?
the instruction says load register -indirect via rE r1 so my understanding is it copies the contents of the location in data memory that corrospond to rE and put it in r1 so the contnts of rE means the contents of 0500 address (which I do not know) and copy it in r1 !!!! its a puzzle to me how will I know the contents or rE ?
>> the instruction says load register -indirect via rE r1 so my understanding is it copies the contents of the location in data memory that corrospond to rE and put it in r1 so the contnts of rE means the contents of 0500 address (which I do not know) and copy it in r1 !!!!
That's what I said, yes ;)
>> its a puzzle to me how will I know the contents or rE ?
rE contains the memory addresses that start at 0500 and are incremented on each iteration, remember ?
The data at those memory addresses is irrelevant to understanding what happens in the code. Knowing that it takes an item from the given memory address, and places it in r1 is sufficient to continue.
So, now that r1 contains a value read from memory, what happens to r1 after that ?
so when add 0000 to r1 it does the test that is jump if negative relative 0001 so if the result in r1 negative then jump one step otherwise jump relative 0001 which means jump another time to get to the instruction subtract immediate rB 0001 (decrement the loop by one) once the loop reach to zero value that is rB =0000 JUMP ONCE to get to the store direct rA 0600 (i.e copy the contents of rA the location with address 0600 otherwise go back fff7 .
Hello again , ok if result is in r1 -ve then jump one instruction to add immediate rA 0001 otherwise jump relative will get execute and jump one step to add immediate rE 0001 . I have to say I run the program 5 times and all its doing is incrementing rE by one every time and when loop get to zero it copy the content of rA into the location where the address is 0600 . so can I say the purpose is to incrementing rE by one .?
>> -ve then jump one instruction to add immediate rA 0001 otherwise jump relative will get execute and jump one step to add immediate rE 0001 .
Right.
>> I have to say I run the program 5 times and all its doing is incrementing rE by one every time
It's doing something else too, isn't it ? You just mentioned it above ...
>> so can I say the purpose is to incrementing rE by one .?
No. Do you remember what rE holds ? What rE is used for ?
>> so could I say the purpose of this subroutine is to show the next item or adding numbers ?
It isn't "showing" anything.
It isn't adding any numbers (except for the increments).
So, no, that's not the purpose of the function ;)
Refer back to my earlier post http:#24265332, namely the second comment I made there ...
>> but the addresses I got say 0500 is not any where in the table I got that indicate what it does .so any thought on that pls .
0500 is just a memory address ... It doesn't do anything special ... It's just a location in memory where some data can be found.
It doesn't matter which data either. All that matters is what the code does with that data ... We already figured out that there's a loop that loops over the first 100 items starting from that address. Now, what does it do with each of those 100 items ?
>> each time the loop occure it repeat it again and again till 100 times done
It repeats what ?
Again, allow me to refer to my second comment in my earlier post http:#24265332. There is a decrement used for the loop counter, an increment used for going to the next item in memory, and one more increment. the latter one is the interesting one ... What does it do ?
if you look at the file i sent , the only thing happen there is under zero flag you got a tick , that s to say at this stage in the program result is zero ,just once you execuate the nest step the zero flag is empted , so the whole purpose to teat if the rE Iis zero or not -ve and if zero it keeps doing the loop till it become -ve then it jumps out side the loop ? what do u think ?
>> rA will contain the final value . right when loop is finished
Come on, just think about it. It's right in front of you ... if the value read from memory is negative, rA is incremented, if it's not, then it's not incremented ... So, what will rA contain in the end ?
I can't give you any better hints than that ... Just think about it.
Business Accounts
Answer for Membership
by: Infinity08Posted on 2009-04-27 at 04:46:53ID: 24240744
And what's your question ?