Hi,

Please help me overcome the type checks in c.

Given: long int r[100],m,n,v;

  Each 4-byte cell of array r can contain a value or an address.
  An address can point to a 1,2, or 4-byte word (little endian).
  m and n are used as cell indexes (0-99).
  v is used to hold a value or address (wathever).

I already know the answer to these 3 questions:

Q1. Store contents of v into cell n. answer: r[n]=v
Q2. Store contents of cell n into v. answer: v=r[n]
Q3. Store contents of cell m into cell n. answer: r[n]=r[m]

Please answers the next questions.
How to store addresses in array cells?

Q4. store the address of cell m into cell n.
Q5. store the address of a label into cell n.
Q6. store the address of a function into cell n.

In the assumption that cell r[n] contains a valid address,
how do we dereference it?

Q7. load the 1-byte value addressed by r[n] into variable v.
Q8. same as Q7, but for a 2-byte, and a 4-byte word.
Q9. same as Q7, but for a sign-extended 2-byte word.
Q10. how to we apply an offset to the address?

Notes:
. the cell indexes are within the bounds.
. all addresses point to accesible memory.
. dont use functions (unless it is a better or simpler approach)
. try to minimize the generated code
. dont use C++ (restrict to ansi C if possible)

Thankx
Teletep




Reply via email to