> I have a few questions about assignment #1.
> 1. In the CPU instruction set there are no immediate instruction i.e. to
> compute y = x + 5. Can I assume there are additional immediate
> instructions such as INCi 5 which would increment the accumulator by 5?
No, you may not. The instruction set provided is adequate to compute
expressions like yours above. This is not one of the extensions I had in mind
(and which you can easily figure out) when I prepared the assignment and gave
you the "Hints" in the final paragraph.
> 2.Can I also assume that the memory locations containing x, y, and i are
> initialized to zero before I begin my assembly code.
You rise an interesting point. The C code fragment that you are to "compile"
computes a recursive function of x, yet x does not appear to be initialized
(its initial content would be garbage if the code were compiled by a real C
compiler). Whether the lack of initialization is a problem or not depends
on the application. Generally speaking it is, since the program behaviour
and results cannot be predicted, unless the used algorithm can provably
converge to a meaningful solution regardless of the initialization (e.g. if
the computed function is a contractive mapping).
However some applications (and notably crypto ones) may take advantage of
sources of randomness like these.
So, to answer your question, you are free to make your assumptions about the
value of x, namely:
- to initialize yourself to zero or any other "meaningful" value
(where what is "meaningful" to you is to be carefully explained
and supported)
- to use whatever bit pattern happens to be in word 0xa0001
when your code is entered.
As far the value of variable y is concerned, you question is obviously
ill-posed. Reread the C source to see why.
As an aside, someone else has asked a similar question about the
initialization of p, q and r. This is a different issue altogether, since the
C source specifies that p, q and r are to be initialized. Again, I suggest
to consider the "Hint" and apply the famed new revolutionary screaming-edge
object-oriented visual windoze-compatible plug'n'play design methodology:
(1) Read.
(2) Think.
(3) Figure out what's missing.
(4) Make juicy judicious assumption.
(5) Does it make sense?
(5.1) No; goto (1).
(5.2) Yes; continue.
(6) Are you sure?
(6.1) Maybe not after all; goto (1).
(6.2) Yes, positive; continue.
(7) *Write* it down (you know, "Mind Reading 101" is
an altogether different class).
(8) Stick to it in your solution.
Cheers
Franco.